Skip to content

Commit 406157d

Browse files
authored
fix(core): build in CookieSerializeOptions def (#14213)
* fix(core): build in CookieSerializeOptions def * chore(adapter-nextjs): bump aws-amplify peer version
1 parent 8054bf7 commit 406157d

File tree

4 files changed

+100
-16
lines changed

4 files changed

+100
-16
lines changed

packages/adapter-nextjs/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
"version": "1.5.0",
55
"description": "The adapter for the supporting of using Amplify APIs in Next.js.",
66
"peerDependencies": {
7-
"aws-amplify": "^6.13.0",
7+
"aws-amplify": "^6.13.1",
88
"next": ">=13.5.0 <16.0.0"
99
},
1010
"dependencies": {
11-
"aws-jwt-verify": "^4.0.1",
12-
"cookie": "^0.7.0"
11+
"aws-jwt-verify": "^4.0.1"
1312
},
1413
"devDependencies": {
15-
"@types/cookie": "^0.5.1",
1614
"@types/node": "^20.3.1",
1715
"@types/react": "^18.2.13",
1816
"@types/react-dom": "^18.2.6",

packages/core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"@aws-sdk/types": "3.398.0",
5555
"@smithy/util-hex-encoding": "2.0.0",
5656
"@types/uuid": "^9.0.0",
57-
"cookie": "^0.7.0",
5857
"js-cookie": "^3.0.5",
5958
"rxjs": "^7.8.1",
6059
"tslib": "^2.5.0",

packages/core/src/adapterCore/serverContext/types/cookieStorage.ts

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,104 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { CookieSerializeOptions } from 'cookie';
4+
interface CookieSerializeOptions {
5+
/**
6+
* Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no
7+
* domain is set, and most clients will consider the cookie to apply to only
8+
* the current domain.
9+
*/
10+
domain?: string | undefined;
11+
12+
/**
13+
* Specifies a function that will be used to encode a cookie's value. Since
14+
* value of a cookie has a limited character set (and must be a simple
15+
* string), this function can be used to encode a value into a string suited
16+
* for a cookie's value.
17+
*
18+
* The default function is the global `encodeURIComponent`, which will
19+
* encode a JavaScript string into UTF-8 byte sequences and then URL-encode
20+
* any that fall outside of the cookie range.
21+
*/
22+
encode?(value: string): string;
23+
24+
/**
25+
* Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1|`Expires` `Set-Cookie` attribute}. By default,
26+
* no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
27+
* it on a condition like exiting a web browser application.
28+
*
29+
* *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
30+
* states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
31+
* possible not all clients by obey this, so if both are set, they should
32+
* point to the same date and time.
33+
*/
34+
expires?: Date | undefined;
35+
/**
36+
* Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}.
37+
* When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
38+
* default, the `HttpOnly` attribute is not set.
39+
*
40+
* *Note* be careful when setting this to true, as compliant clients will
41+
* not allow client-side JavaScript to see the cookie in `document.cookie`.
42+
*/
43+
httpOnly?: boolean | undefined;
44+
/**
45+
* Specifies the number (in seconds) to be the value for the `Max-Age`
46+
* `Set-Cookie` attribute. The given number will be converted to an integer
47+
* by rounding down. By default, no maximum age is set.
48+
*
49+
* *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
50+
* states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
51+
* possible not all clients by obey this, so if both are set, they should
52+
* point to the same date and time.
53+
*/
54+
maxAge?: number | undefined;
55+
/**
56+
* Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
57+
* By default, the path is considered the "default path".
58+
*/
59+
path?: string | undefined;
60+
/**
61+
* Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
62+
*
63+
* - `'low'` will set the `Priority` attribute to `Low`.
64+
* - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
65+
* - `'high'` will set the `Priority` attribute to `High`.
66+
*
67+
* More information about the different priority levels can be found in
68+
* [the specification][rfc-west-cookie-priority-00-4.1].
69+
*
70+
* **note** This is an attribute that has not yet been fully standardized, and may change in the future.
71+
* This also means many clients may ignore this attribute until they understand it.
72+
*/
73+
priority?: 'low' | 'medium' | 'high' | undefined;
74+
/**
75+
* Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.
76+
*
77+
* - `true` will set the `SameSite` attribute to `Strict` for strict same
78+
* site enforcement.
79+
* - `false` will not set the `SameSite` attribute.
80+
* - `'lax'` will set the `SameSite` attribute to Lax for lax same site
81+
* enforcement.
82+
* - `'strict'` will set the `SameSite` attribute to Strict for strict same
83+
* site enforcement.
84+
* - `'none'` will set the SameSite attribute to None for an explicit
85+
* cross-site cookie.
86+
*
87+
* More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
88+
*
89+
* *note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
90+
*/
91+
sameSite?: true | false | 'lax' | 'strict' | 'none' | undefined;
92+
/**
93+
* Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the
94+
* `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
95+
*
96+
* *Note* be careful when setting this to `true`, as compliant clients will
97+
* not send the cookie back to the server in the future if the browser does
98+
* not have an HTTPS connection.
99+
*/
100+
secure?: boolean | undefined;
101+
}
5102

6103
export declare namespace CookieStorage {
7104
export type SetCookieOptions = Partial<

yarn.lock

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)