aws-amplify 6.12.0 → 6.12.1-server-auth.7499b16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = void 0;
7
+ exports.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = 365 * 24 * 60 * 60; // 1 year in seconds
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../src/adapter-core/constants.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = void 0;\nexports.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = 365 * 24 * 60 * 60; // 1 year in seconds\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACpD,OAAO,CAAC,kCAAkC,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;;"}
@@ -3,7 +3,7 @@
3
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createUserPoolsTokenProvider = exports.createAWSCredentialsAndIdentityIdProvider = exports.createKeyValueStorageFromCookieStorageAdapter = exports.runWithAmplifyServerContext = void 0;
6
+ exports.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = exports.AUTH_KEY_PREFIX = exports.createKeysForAuthStorage = exports.validateState = exports.generateCodeVerifier = exports.getRedirectUrl = exports.generateState = exports.createUserPoolsTokenProvider = exports.createAWSCredentialsAndIdentityIdProvider = exports.createKeyValueStorageFromCookieStorageAdapter = exports.runWithAmplifyServerContext = void 0;
7
7
  var runWithAmplifyServerContext_1 = require("./runWithAmplifyServerContext");
8
8
  Object.defineProperty(exports, "runWithAmplifyServerContext", { enumerable: true, get: function () { return runWithAmplifyServerContext_1.runWithAmplifyServerContext; } });
9
9
  var storageFactories_1 = require("./storageFactories");
@@ -11,4 +11,13 @@ Object.defineProperty(exports, "createKeyValueStorageFromCookieStorageAdapter",
11
11
  var cognito_1 = require("./authProvidersFactories/cognito");
12
12
  Object.defineProperty(exports, "createAWSCredentialsAndIdentityIdProvider", { enumerable: true, get: function () { return cognito_1.createAWSCredentialsAndIdentityIdProvider; } });
13
13
  Object.defineProperty(exports, "createUserPoolsTokenProvider", { enumerable: true, get: function () { return cognito_1.createUserPoolsTokenProvider; } });
14
+ var cognito_2 = require("@aws-amplify/auth/cognito");
15
+ Object.defineProperty(exports, "generateState", { enumerable: true, get: function () { return cognito_2.generateState; } });
16
+ Object.defineProperty(exports, "getRedirectUrl", { enumerable: true, get: function () { return cognito_2.getRedirectUrl; } });
17
+ Object.defineProperty(exports, "generateCodeVerifier", { enumerable: true, get: function () { return cognito_2.generateCodeVerifier; } });
18
+ Object.defineProperty(exports, "validateState", { enumerable: true, get: function () { return cognito_2.validateState; } });
19
+ Object.defineProperty(exports, "createKeysForAuthStorage", { enumerable: true, get: function () { return cognito_2.createKeysForAuthStorage; } });
20
+ Object.defineProperty(exports, "AUTH_KEY_PREFIX", { enumerable: true, get: function () { return cognito_2.AUTH_KEY_PREFIX; } });
21
+ var constants_1 = require("./constants");
22
+ Object.defineProperty(exports, "DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE", { enumerable: true, get: function () { return constants_1.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE; } });
14
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/adapter-core/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createUserPoolsTokenProvider = exports.createAWSCredentialsAndIdentityIdProvider = exports.createKeyValueStorageFromCookieStorageAdapter = exports.runWithAmplifyServerContext = void 0;\nvar runWithAmplifyServerContext_1 = require(\"./runWithAmplifyServerContext\");\nObject.defineProperty(exports, \"runWithAmplifyServerContext\", { enumerable: true, get: function () { return runWithAmplifyServerContext_1.runWithAmplifyServerContext; } });\nvar storageFactories_1 = require(\"./storageFactories\");\nObject.defineProperty(exports, \"createKeyValueStorageFromCookieStorageAdapter\", { enumerable: true, get: function () { return storageFactories_1.createKeyValueStorageFromCookieStorageAdapter; } });\nvar cognito_1 = require(\"./authProvidersFactories/cognito\");\nObject.defineProperty(exports, \"createAWSCredentialsAndIdentityIdProvider\", { enumerable: true, get: function () { return cognito_1.createAWSCredentialsAndIdentityIdProvider; } });\nObject.defineProperty(exports, \"createUserPoolsTokenProvider\", { enumerable: true, get: function () { return cognito_1.createUserPoolsTokenProvider; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,yCAAyC,GAAG,OAAO,CAAC,6CAA6C,GAAG,OAAO,CAAC,2BAA2B,GAAG,KAAK,CAAC,CAAC;AAChM,IAAI,6BAA6B,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAC7E,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,6BAA6B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,6BAA6B,CAAC,2BAA2B,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5K,IAAI,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACvD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,+CAA+C,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kBAAkB,CAAC,6CAA6C,CAAC,EAAE,EAAE,CAAC,CAAC;AACrM,IAAI,SAAS,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC5D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,2CAA2C,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,SAAS,CAAC,yCAAyC,CAAC,EAAE,EAAE,CAAC,CAAC;AACpL,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,8BAA8B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,SAAS,CAAC,4BAA4B,CAAC,EAAE,EAAE,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/adapter-core/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = exports.AUTH_KEY_PREFIX = exports.createKeysForAuthStorage = exports.validateState = exports.generateCodeVerifier = exports.getRedirectUrl = exports.generateState = exports.createUserPoolsTokenProvider = exports.createAWSCredentialsAndIdentityIdProvider = exports.createKeyValueStorageFromCookieStorageAdapter = exports.runWithAmplifyServerContext = void 0;\nvar runWithAmplifyServerContext_1 = require(\"./runWithAmplifyServerContext\");\nObject.defineProperty(exports, \"runWithAmplifyServerContext\", { enumerable: true, get: function () { return runWithAmplifyServerContext_1.runWithAmplifyServerContext; } });\nvar storageFactories_1 = require(\"./storageFactories\");\nObject.defineProperty(exports, \"createKeyValueStorageFromCookieStorageAdapter\", { enumerable: true, get: function () { return storageFactories_1.createKeyValueStorageFromCookieStorageAdapter; } });\nvar cognito_1 = require(\"./authProvidersFactories/cognito\");\nObject.defineProperty(exports, \"createAWSCredentialsAndIdentityIdProvider\", { enumerable: true, get: function () { return cognito_1.createAWSCredentialsAndIdentityIdProvider; } });\nObject.defineProperty(exports, \"createUserPoolsTokenProvider\", { enumerable: true, get: function () { return cognito_1.createUserPoolsTokenProvider; } });\nvar cognito_2 = require(\"@aws-amplify/auth/cognito\");\nObject.defineProperty(exports, \"generateState\", { enumerable: true, get: function () { return cognito_2.generateState; } });\nObject.defineProperty(exports, \"getRedirectUrl\", { enumerable: true, get: function () { return cognito_2.getRedirectUrl; } });\nObject.defineProperty(exports, \"generateCodeVerifier\", { enumerable: true, get: function () { return cognito_2.generateCodeVerifier; } });\nObject.defineProperty(exports, \"validateState\", { enumerable: true, get: function () { return cognito_2.validateState; } });\nObject.defineProperty(exports, \"createKeysForAuthStorage\", { enumerable: true, get: function () { return cognito_2.createKeysForAuthStorage; } });\nObject.defineProperty(exports, \"AUTH_KEY_PREFIX\", { enumerable: true, get: function () { return cognito_2.AUTH_KEY_PREFIX; } });\nvar constants_1 = require(\"./constants\");\nObject.defineProperty(exports, \"DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE\", { enumerable: true, get: function () { return constants_1.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE; } });\n"],"names":[],"mappings":"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"}
@@ -4,31 +4,35 @@
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createKeyValueStorageFromCookieStorageAdapter = exports.defaultSetCookieOptions = void 0;
7
+ const constants_1 = require("../constants");
7
8
  exports.defaultSetCookieOptions = {
8
9
  // TODO: allow configure with a public interface
9
10
  sameSite: 'lax',
10
11
  secure: true,
11
12
  path: '/',
12
13
  };
13
- const ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000;
14
14
  /**
15
15
  * Creates a Key Value storage interface using the `cookieStorageAdapter` as the
16
16
  * underlying storage.
17
17
  * @param cookieStorageAdapter An implementation of the `Adapter` in {@link CookieStorage}.
18
18
  * @returns An object that implements {@link KeyValueStorageInterface}.
19
19
  */
20
- const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator) => {
20
+ const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator, setCookieOptions = {}) => {
21
21
  return {
22
22
  setItem(key, value) {
23
23
  // Delete the cookie item first then set it. This results:
24
24
  // SetCookie: key=;expires=1970-01-01;(path='current-path') <- remove path'ed cookies
25
25
  // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true
26
26
  cookieStorageAdapter.delete(key);
27
- // TODO(HuiSF): follow up the default CookieSerializeOptions values
28
- cookieStorageAdapter.set(key, value, {
27
+ const mergedCookieOptions = {
29
28
  ...exports.defaultSetCookieOptions,
30
- expires: new Date(Date.now() + ONE_YEAR_IN_MS),
31
- });
29
+ ...setCookieOptions,
30
+ };
31
+ // when expires and maxAge both are not specified, we set a default maxAge
32
+ if (!mergedCookieOptions.expires && !mergedCookieOptions.maxAge) {
33
+ mergedCookieOptions.maxAge = constants_1.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE;
34
+ }
35
+ cookieStorageAdapter.set(key, value, mergedCookieOptions);
32
36
  return Promise.resolve();
33
37
  },
34
38
  async getItem(key) {
@@ -1 +1 @@
1
- {"version":3,"file":"createKeyValueStorageFromCookieStorageAdapter.js","sources":["../../../../src/adapter-core/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createKeyValueStorageFromCookieStorageAdapter = exports.defaultSetCookieOptions = void 0;\nexports.defaultSetCookieOptions = {\n // TODO: allow configure with a public interface\n sameSite: 'lax',\n secure: true,\n path: '/',\n};\nconst ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000;\n/**\n * Creates a Key Value storage interface using the `cookieStorageAdapter` as the\n * underlying storage.\n * @param cookieStorageAdapter An implementation of the `Adapter` in {@link CookieStorage}.\n * @returns An object that implements {@link KeyValueStorageInterface}.\n */\nconst createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator) => {\n return {\n setItem(key, value) {\n // Delete the cookie item first then set it. This results:\n // SetCookie: key=;expires=1970-01-01;(path='current-path') <- remove path'ed cookies\n // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true\n cookieStorageAdapter.delete(key);\n // TODO(HuiSF): follow up the default CookieSerializeOptions values\n cookieStorageAdapter.set(key, value, {\n ...exports.defaultSetCookieOptions,\n expires: new Date(Date.now() + ONE_YEAR_IN_MS),\n });\n return Promise.resolve();\n },\n async getItem(key) {\n const cookie = cookieStorageAdapter.get(key);\n const value = cookie?.value ?? null;\n if (value && validator?.getItem) {\n const isValid = await validator.getItem(key, value);\n if (!isValid)\n return null;\n }\n return value;\n },\n removeItem(key) {\n cookieStorageAdapter.delete(key);\n return Promise.resolve();\n },\n clear() {\n // TODO(HuiSF): follow up the implementation.\n throw new Error('This method has not implemented.');\n },\n };\n};\nexports.createKeyValueStorageFromCookieStorageAdapter = createKeyValueStorageFromCookieStorageAdapter;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,6CAA6C,GAAG,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACjG,OAAO,CAAC,uBAAuB,GAAG;AAClC;AACA,IAAI,QAAQ,EAAE,KAAK;AACnB,IAAI,MAAM,EAAE,IAAI;AAChB,IAAI,IAAI,EAAE,GAAG;AACb,CAAC,CAAC;AACF,MAAM,cAAc,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACjD;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,6CAA6C,GAAG,CAAC,oBAAoB,EAAE,SAAS,KAAK;AAC3F,IAAI,OAAO;AACX,QAAQ,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE;AAC5B;AACA;AACA;AACA,YAAY,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C;AACA,YAAY,oBAAoB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE;AACjD,gBAAgB,GAAG,OAAO,CAAC,uBAAuB;AAClD,gBAAgB,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,cAAc,CAAC;AAC9D,aAAa,CAAC,CAAC;AACf,YAAY,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACrC,SAAS;AACT,QAAQ,MAAM,OAAO,CAAC,GAAG,EAAE;AAC3B,YAAY,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD,YAAY,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AAChD,YAAY,IAAI,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE;AAC7C,gBAAgB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACpE,gBAAgB,IAAI,CAAC,OAAO;AAC5B,oBAAoB,OAAO,IAAI,CAAC;AAChC,aAAa;AACb,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS;AACT,QAAQ,UAAU,CAAC,GAAG,EAAE;AACxB,YAAY,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C,YAAY,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACrC,SAAS;AACT,QAAQ,KAAK,GAAG;AAChB;AACA,YAAY,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAChE,SAAS;AACT,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,6CAA6C,GAAG,6CAA6C;;"}
1
+ {"version":3,"file":"createKeyValueStorageFromCookieStorageAdapter.js","sources":["../../../../src/adapter-core/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createKeyValueStorageFromCookieStorageAdapter = exports.defaultSetCookieOptions = void 0;\nconst constants_1 = require(\"../constants\");\nexports.defaultSetCookieOptions = {\n // TODO: allow configure with a public interface\n sameSite: 'lax',\n secure: true,\n path: '/',\n};\n/**\n * Creates a Key Value storage interface using the `cookieStorageAdapter` as the\n * underlying storage.\n * @param cookieStorageAdapter An implementation of the `Adapter` in {@link CookieStorage}.\n * @returns An object that implements {@link KeyValueStorageInterface}.\n */\nconst createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator, setCookieOptions = {}) => {\n return {\n setItem(key, value) {\n // Delete the cookie item first then set it. This results:\n // SetCookie: key=;expires=1970-01-01;(path='current-path') <- remove path'ed cookies\n // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true\n cookieStorageAdapter.delete(key);\n const mergedCookieOptions = {\n ...exports.defaultSetCookieOptions,\n ...setCookieOptions,\n };\n // when expires and maxAge both are not specified, we set a default maxAge\n if (!mergedCookieOptions.expires && !mergedCookieOptions.maxAge) {\n mergedCookieOptions.maxAge = constants_1.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE;\n }\n cookieStorageAdapter.set(key, value, mergedCookieOptions);\n return Promise.resolve();\n },\n async getItem(key) {\n const cookie = cookieStorageAdapter.get(key);\n const value = cookie?.value ?? null;\n if (value && validator?.getItem) {\n const isValid = await validator.getItem(key, value);\n if (!isValid)\n return null;\n }\n return value;\n },\n removeItem(key) {\n cookieStorageAdapter.delete(key);\n return Promise.resolve();\n },\n clear() {\n // TODO(HuiSF): follow up the implementation.\n throw new Error('This method has not implemented.');\n },\n };\n};\nexports.createKeyValueStorageFromCookieStorageAdapter = createKeyValueStorageFromCookieStorageAdapter;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,6CAA6C,GAAG,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACjG,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,OAAO,CAAC,uBAAuB,GAAG;AAClC;AACA,IAAI,QAAQ,EAAE,KAAK;AACnB,IAAI,MAAM,EAAE,IAAI;AAChB,IAAI,IAAI,EAAE,GAAG;AACb,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,6CAA6C,GAAG,CAAC,oBAAoB,EAAE,SAAS,EAAE,gBAAgB,GAAG,EAAE,KAAK;AAClH,IAAI,OAAO;AACX,QAAQ,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE;AAC5B;AACA;AACA;AACA,YAAY,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C,YAAY,MAAM,mBAAmB,GAAG;AACxC,gBAAgB,GAAG,OAAO,CAAC,uBAAuB;AAClD,gBAAgB,GAAG,gBAAgB;AACnC,aAAa,CAAC;AACd;AACA,YAAY,IAAI,CAAC,mBAAmB,CAAC,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE;AAC7E,gBAAgB,mBAAmB,CAAC,MAAM,GAAG,WAAW,CAAC,kCAAkC,CAAC;AAC5F,aAAa;AACb,YAAY,oBAAoB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;AACtE,YAAY,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACrC,SAAS;AACT,QAAQ,MAAM,OAAO,CAAC,GAAG,EAAE;AAC3B,YAAY,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD,YAAY,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AAChD,YAAY,IAAI,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE;AAC7C,gBAAgB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACpE,gBAAgB,IAAI,CAAC,OAAO;AAC5B,oBAAoB,OAAO,IAAI,CAAC;AAChC,aAAa;AACb,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS;AACT,QAAQ,UAAU,CAAC,GAAG,EAAE;AACxB,YAAY,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C,YAAY,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACrC,SAAS;AACT,QAAQ,KAAK,GAAG;AAChB;AACA,YAAY,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAChE,SAAS;AACT,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,6CAA6C,GAAG,6CAA6C;;"}
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE: number;
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ const DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = 365 * 24 * 60 * 60; // 1 year in seconds
4
+
5
+ export { DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE };
6
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sources":["../../../src/adapter-core/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = 365 * 24 * 60 * 60; // 1 year in seconds\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,kCAAkC,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG;;;;"}
@@ -3,3 +3,5 @@ export { createKeyValueStorageFromCookieStorageAdapter } from './storageFactorie
3
3
  export { createAWSCredentialsAndIdentityIdProvider, createUserPoolsTokenProvider, } from './authProvidersFactories/cognito';
4
4
  export { LegacyConfig, AmplifyOutputs, } from '@aws-amplify/core/internals/utils';
5
5
  export { AmplifyServer, CookieStorage, } from '@aws-amplify/core/internals/adapter-core';
6
+ export { generateState, getRedirectUrl, generateCodeVerifier, validateState, createKeysForAuthStorage, AUTH_KEY_PREFIX, } from '@aws-amplify/auth/cognito';
7
+ export { DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE } from './constants';
@@ -2,4 +2,6 @@ export { runWithAmplifyServerContext } from './runWithAmplifyServerContext.mjs';
2
2
  export { createKeyValueStorageFromCookieStorageAdapter } from './storageFactories/createKeyValueStorageFromCookieStorageAdapter.mjs';
3
3
  export { createUserPoolsTokenProvider } from './authProvidersFactories/cognito/createUserPoolsTokenProvider.mjs';
4
4
  export { createAWSCredentialsAndIdentityIdProvider } from './authProvidersFactories/cognito/createAWSCredentialsAndIdentityIdProvider.mjs';
5
+ export { AUTH_KEY_PREFIX, createKeysForAuthStorage, generateCodeVerifier, generateState, getRedirectUrl, validateState } from '@aws-amplify/auth/cognito';
6
+ export { DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE } from './constants.mjs';
5
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -7,4 +7,4 @@ export declare const defaultSetCookieOptions: CookieStorage.SetCookieOptions;
7
7
  * @param cookieStorageAdapter An implementation of the `Adapter` in {@link CookieStorage}.
8
8
  * @returns An object that implements {@link KeyValueStorageInterface}.
9
9
  */
10
- export declare const createKeyValueStorageFromCookieStorageAdapter: (cookieStorageAdapter: CookieStorage.Adapter, validator?: KeyValueStorageMethodValidator) => KeyValueStorageInterface;
10
+ export declare const createKeyValueStorageFromCookieStorageAdapter: (cookieStorageAdapter: CookieStorage.Adapter, validator?: KeyValueStorageMethodValidator, setCookieOptions?: CookieStorage.SetCookieOptions) => KeyValueStorageInterface;
@@ -1,3 +1,5 @@
1
+ import { DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE } from '../constants.mjs';
2
+
1
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
4
  // SPDX-License-Identifier: Apache-2.0
3
5
  const defaultSetCookieOptions = {
@@ -6,25 +8,28 @@ const defaultSetCookieOptions = {
6
8
  secure: true,
7
9
  path: '/',
8
10
  };
9
- const ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000;
10
11
  /**
11
12
  * Creates a Key Value storage interface using the `cookieStorageAdapter` as the
12
13
  * underlying storage.
13
14
  * @param cookieStorageAdapter An implementation of the `Adapter` in {@link CookieStorage}.
14
15
  * @returns An object that implements {@link KeyValueStorageInterface}.
15
16
  */
16
- const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator) => {
17
+ const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator, setCookieOptions = {}) => {
17
18
  return {
18
19
  setItem(key, value) {
19
20
  // Delete the cookie item first then set it. This results:
20
21
  // SetCookie: key=;expires=1970-01-01;(path='current-path') <- remove path'ed cookies
21
22
  // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true
22
23
  cookieStorageAdapter.delete(key);
23
- // TODO(HuiSF): follow up the default CookieSerializeOptions values
24
- cookieStorageAdapter.set(key, value, {
24
+ const mergedCookieOptions = {
25
25
  ...defaultSetCookieOptions,
26
- expires: new Date(Date.now() + ONE_YEAR_IN_MS),
27
- });
26
+ ...setCookieOptions,
27
+ };
28
+ // when expires and maxAge both are not specified, we set a default maxAge
29
+ if (!mergedCookieOptions.expires && !mergedCookieOptions.maxAge) {
30
+ mergedCookieOptions.maxAge = DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE;
31
+ }
32
+ cookieStorageAdapter.set(key, value, mergedCookieOptions);
28
33
  return Promise.resolve();
29
34
  },
30
35
  async getItem(key) {
@@ -1 +1 @@
1
- {"version":3,"file":"createKeyValueStorageFromCookieStorageAdapter.mjs","sources":["../../../../src/adapter-core/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const defaultSetCookieOptions = {\n // TODO: allow configure with a public interface\n sameSite: 'lax',\n secure: true,\n path: '/',\n};\nconst ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000;\n/**\n * Creates a Key Value storage interface using the `cookieStorageAdapter` as the\n * underlying storage.\n * @param cookieStorageAdapter An implementation of the `Adapter` in {@link CookieStorage}.\n * @returns An object that implements {@link KeyValueStorageInterface}.\n */\nexport const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator) => {\n return {\n setItem(key, value) {\n // Delete the cookie item first then set it. This results:\n // SetCookie: key=;expires=1970-01-01;(path='current-path') <- remove path'ed cookies\n // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true\n cookieStorageAdapter.delete(key);\n // TODO(HuiSF): follow up the default CookieSerializeOptions values\n cookieStorageAdapter.set(key, value, {\n ...defaultSetCookieOptions,\n expires: new Date(Date.now() + ONE_YEAR_IN_MS),\n });\n return Promise.resolve();\n },\n async getItem(key) {\n const cookie = cookieStorageAdapter.get(key);\n const value = cookie?.value ?? null;\n if (value && validator?.getItem) {\n const isValid = await validator.getItem(key, value);\n if (!isValid)\n return null;\n }\n return value;\n },\n removeItem(key) {\n cookieStorageAdapter.delete(key);\n return Promise.resolve();\n },\n clear() {\n // TODO(HuiSF): follow up the implementation.\n throw new Error('This method has not implemented.');\n },\n };\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,uBAAuB,GAAG;AACvC;AACA,IAAI,QAAQ,EAAE,KAAK;AACnB,IAAI,MAAM,EAAE,IAAI;AAChB,IAAI,IAAI,EAAE,GAAG;AACb,EAAE;AACF,MAAM,cAAc,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACjD;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,6CAA6C,GAAG,CAAC,oBAAoB,EAAE,SAAS,KAAK;AAClG,IAAI,OAAO;AACX,QAAQ,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE;AAC5B;AACA;AACA;AACA,YAAY,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C;AACA,YAAY,oBAAoB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE;AACjD,gBAAgB,GAAG,uBAAuB;AAC1C,gBAAgB,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,cAAc,CAAC;AAC9D,aAAa,CAAC,CAAC;AACf,YAAY,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACrC,SAAS;AACT,QAAQ,MAAM,OAAO,CAAC,GAAG,EAAE;AAC3B,YAAY,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD,YAAY,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AAChD,YAAY,IAAI,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE;AAC7C,gBAAgB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACpE,gBAAgB,IAAI,CAAC,OAAO;AAC5B,oBAAoB,OAAO,IAAI,CAAC;AAChC,aAAa;AACb,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS;AACT,QAAQ,UAAU,CAAC,GAAG,EAAE;AACxB,YAAY,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C,YAAY,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACrC,SAAS;AACT,QAAQ,KAAK,GAAG;AAChB;AACA,YAAY,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAChE,SAAS;AACT,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"createKeyValueStorageFromCookieStorageAdapter.mjs","sources":["../../../../src/adapter-core/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE } from '../constants';\nexport const defaultSetCookieOptions = {\n // TODO: allow configure with a public interface\n sameSite: 'lax',\n secure: true,\n path: '/',\n};\n/**\n * Creates a Key Value storage interface using the `cookieStorageAdapter` as the\n * underlying storage.\n * @param cookieStorageAdapter An implementation of the `Adapter` in {@link CookieStorage}.\n * @returns An object that implements {@link KeyValueStorageInterface}.\n */\nexport const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator, setCookieOptions = {}) => {\n return {\n setItem(key, value) {\n // Delete the cookie item first then set it. This results:\n // SetCookie: key=;expires=1970-01-01;(path='current-path') <- remove path'ed cookies\n // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true\n cookieStorageAdapter.delete(key);\n const mergedCookieOptions = {\n ...defaultSetCookieOptions,\n ...setCookieOptions,\n };\n // when expires and maxAge both are not specified, we set a default maxAge\n if (!mergedCookieOptions.expires && !mergedCookieOptions.maxAge) {\n mergedCookieOptions.maxAge = DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE;\n }\n cookieStorageAdapter.set(key, value, mergedCookieOptions);\n return Promise.resolve();\n },\n async getItem(key) {\n const cookie = cookieStorageAdapter.get(key);\n const value = cookie?.value ?? null;\n if (value && validator?.getItem) {\n const isValid = await validator.getItem(key, value);\n if (!isValid)\n return null;\n }\n return value;\n },\n removeItem(key) {\n cookieStorageAdapter.delete(key);\n return Promise.resolve();\n },\n clear() {\n // TODO(HuiSF): follow up the implementation.\n throw new Error('This method has not implemented.');\n },\n };\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,uBAAuB,GAAG;AACvC;AACA,IAAI,QAAQ,EAAE,KAAK;AACnB,IAAI,MAAM,EAAE,IAAI;AAChB,IAAI,IAAI,EAAE,GAAG;AACb,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,6CAA6C,GAAG,CAAC,oBAAoB,EAAE,SAAS,EAAE,gBAAgB,GAAG,EAAE,KAAK;AACzH,IAAI,OAAO;AACX,QAAQ,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE;AAC5B;AACA;AACA;AACA,YAAY,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C,YAAY,MAAM,mBAAmB,GAAG;AACxC,gBAAgB,GAAG,uBAAuB;AAC1C,gBAAgB,GAAG,gBAAgB;AACnC,aAAa,CAAC;AACd;AACA,YAAY,IAAI,CAAC,mBAAmB,CAAC,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE;AAC7E,gBAAgB,mBAAmB,CAAC,MAAM,GAAG,kCAAkC,CAAC;AAChF,aAAa;AACb,YAAY,oBAAoB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;AACtE,YAAY,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACrC,SAAS;AACT,QAAQ,MAAM,OAAO,CAAC,GAAG,EAAE;AAC3B,YAAY,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD,YAAY,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AAChD,YAAY,IAAI,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE;AAC7C,gBAAgB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACpE,gBAAgB,IAAI,CAAC,OAAO;AAC5B,oBAAoB,OAAO,IAAI,CAAC;AAChC,aAAa;AACb,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS;AACT,QAAQ,UAAU,CAAC,GAAG,EAAE;AACxB,YAAY,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C,YAAY,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACrC,SAAS;AACT,QAAQ,KAAK,GAAG;AAChB;AACA,YAAY,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAChE,SAAS;AACT,KAAK,CAAC;AACN;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-amplify",
3
- "version": "6.12.0",
3
+ "version": "6.12.1-server-auth.7499b16.0+7499b16",
4
4
  "description": "AWS Amplify is a JavaScript library for Frontend and mobile developers building cloud-enabled applications.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -276,13 +276,13 @@
276
276
  "utils"
277
277
  ],
278
278
  "dependencies": {
279
- "@aws-amplify/analytics": "7.0.65",
280
- "@aws-amplify/api": "6.2.0",
281
- "@aws-amplify/auth": "6.9.1",
282
- "@aws-amplify/core": "6.9.0",
283
- "@aws-amplify/datastore": "5.0.67",
284
- "@aws-amplify/notifications": "2.0.65",
285
- "@aws-amplify/storage": "6.7.6",
279
+ "@aws-amplify/analytics": "7.0.66-server-auth.7499b16.0+7499b16",
280
+ "@aws-amplify/api": "6.2.1-server-auth.7499b16.0+7499b16",
281
+ "@aws-amplify/auth": "6.9.2-server-auth.7499b16.0+7499b16",
282
+ "@aws-amplify/core": "6.9.1-server-auth.7499b16.0+7499b16",
283
+ "@aws-amplify/datastore": "5.0.68-server-auth.7499b16.0+7499b16",
284
+ "@aws-amplify/notifications": "2.0.66-server-auth.7499b16.0+7499b16",
285
+ "@aws-amplify/storage": "6.7.7-server-auth.7499b16.0+7499b16",
286
286
  "tslib": "^2.5.0"
287
287
  },
288
288
  "devDependencies": {
@@ -518,5 +518,5 @@
518
518
  "limit": "22.87 kB"
519
519
  }
520
520
  ],
521
- "gitHead": "8b6078afa580c241d87bda5b9591d9c97da4949b"
521
+ "gitHead": "7499b16277f9739368b2d1938cdcc219a52b72e4"
522
522
  }
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE = 365 * 24 * 60 * 60; // 1 year in seconds
@@ -15,3 +15,12 @@ export {
15
15
  AmplifyServer,
16
16
  CookieStorage,
17
17
  } from '@aws-amplify/core/internals/adapter-core';
18
+ export {
19
+ generateState,
20
+ getRedirectUrl,
21
+ generateCodeVerifier,
22
+ validateState,
23
+ createKeysForAuthStorage,
24
+ AUTH_KEY_PREFIX,
25
+ } from '@aws-amplify/auth/cognito';
26
+ export { DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE } from './constants';
@@ -7,13 +7,14 @@ import {
7
7
  KeyValueStorageMethodValidator,
8
8
  } from '@aws-amplify/core/internals/adapter-core';
9
9
 
10
+ import { DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE } from '../constants';
11
+
10
12
  export const defaultSetCookieOptions: CookieStorage.SetCookieOptions = {
11
13
  // TODO: allow configure with a public interface
12
14
  sameSite: 'lax',
13
15
  secure: true,
14
16
  path: '/',
15
17
  };
16
- const ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000;
17
18
 
18
19
  /**
19
20
  * Creates a Key Value storage interface using the `cookieStorageAdapter` as the
@@ -24,6 +25,7 @@ const ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000;
24
25
  export const createKeyValueStorageFromCookieStorageAdapter = (
25
26
  cookieStorageAdapter: CookieStorage.Adapter,
26
27
  validator?: KeyValueStorageMethodValidator,
28
+ setCookieOptions: CookieStorage.SetCookieOptions = {},
27
29
  ): KeyValueStorageInterface => {
28
30
  return {
29
31
  setItem(key, value) {
@@ -32,11 +34,17 @@ export const createKeyValueStorageFromCookieStorageAdapter = (
32
34
  // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true
33
35
  cookieStorageAdapter.delete(key);
34
36
 
35
- // TODO(HuiSF): follow up the default CookieSerializeOptions values
36
- cookieStorageAdapter.set(key, value, {
37
+ const mergedCookieOptions = {
37
38
  ...defaultSetCookieOptions,
38
- expires: new Date(Date.now() + ONE_YEAR_IN_MS),
39
- });
39
+ ...setCookieOptions,
40
+ };
41
+
42
+ // when expires and maxAge both are not specified, we set a default maxAge
43
+ if (!mergedCookieOptions.expires && !mergedCookieOptions.maxAge) {
44
+ mergedCookieOptions.maxAge = DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE;
45
+ }
46
+
47
+ cookieStorageAdapter.set(key, value, mergedCookieOptions);
40
48
 
41
49
  return Promise.resolve();
42
50
  },