aws-amplify 6.12.1-server-auth.778c2b6.0 → 6.12.1-unstable.c279ae0.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.
@@ -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.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;
6
+ 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,13 +11,4 @@ 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; } });
23
14
  //# 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.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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"}
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;;"}
@@ -4,35 +4,31 @@
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");
8
7
  exports.defaultSetCookieOptions = {
9
8
  // TODO: allow configure with a public interface
10
9
  sameSite: 'lax',
11
10
  secure: true,
12
11
  path: '/',
13
12
  };
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, setCookieOptions = {}) => {
20
+ const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator) => {
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
- const mergedCookieOptions = {
27
+ // TODO(HuiSF): follow up the default CookieSerializeOptions values
28
+ cookieStorageAdapter.set(key, value, {
28
29
  ...exports.defaultSetCookieOptions,
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);
30
+ expires: new Date(Date.now() + ONE_YEAR_IN_MS),
31
+ });
36
32
  return Promise.resolve();
37
33
  },
38
34
  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;\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;;"}
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;;"}
@@ -3,5 +3,3 @@ 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,6 +2,4 @@ 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';
7
5
  //# 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, setCookieOptions?: CookieStorage.SetCookieOptions) => KeyValueStorageInterface;
10
+ export declare const createKeyValueStorageFromCookieStorageAdapter: (cookieStorageAdapter: CookieStorage.Adapter, validator?: KeyValueStorageMethodValidator) => KeyValueStorageInterface;
@@ -1,5 +1,3 @@
1
- import { DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE } from '../constants.mjs';
2
-
3
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
2
  // SPDX-License-Identifier: Apache-2.0
5
3
  const defaultSetCookieOptions = {
@@ -8,28 +6,25 @@ const defaultSetCookieOptions = {
8
6
  secure: true,
9
7
  path: '/',
10
8
  };
9
+ const ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000;
11
10
  /**
12
11
  * Creates a Key Value storage interface using the `cookieStorageAdapter` as the
13
12
  * underlying storage.
14
13
  * @param cookieStorageAdapter An implementation of the `Adapter` in {@link CookieStorage}.
15
14
  * @returns An object that implements {@link KeyValueStorageInterface}.
16
15
  */
17
- const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator, setCookieOptions = {}) => {
16
+ const createKeyValueStorageFromCookieStorageAdapter = (cookieStorageAdapter, validator) => {
18
17
  return {
19
18
  setItem(key, value) {
20
19
  // Delete the cookie item first then set it. This results:
21
20
  // SetCookie: key=;expires=1970-01-01;(path='current-path') <- remove path'ed cookies
22
21
  // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true
23
22
  cookieStorageAdapter.delete(key);
24
- const mergedCookieOptions = {
23
+ // TODO(HuiSF): follow up the default CookieSerializeOptions values
24
+ cookieStorageAdapter.set(key, value, {
25
25
  ...defaultSetCookieOptions,
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);
26
+ expires: new Date(Date.now() + ONE_YEAR_IN_MS),
27
+ });
33
28
  return Promise.resolve();
34
29
  },
35
30
  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\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;;;;"}
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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-amplify",
3
- "version": "6.12.1-server-auth.778c2b6.0+778c2b6",
3
+ "version": "6.12.1-unstable.c279ae0.0+c279ae0",
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.66-server-auth.778c2b6.0+778c2b6",
280
- "@aws-amplify/api": "6.2.1-server-auth.778c2b6.0+778c2b6",
281
- "@aws-amplify/auth": "6.9.2-server-auth.778c2b6.0+778c2b6",
282
- "@aws-amplify/core": "6.9.1-server-auth.778c2b6.0+778c2b6",
283
- "@aws-amplify/datastore": "5.0.68-server-auth.778c2b6.0+778c2b6",
284
- "@aws-amplify/notifications": "2.0.66-server-auth.778c2b6.0+778c2b6",
285
- "@aws-amplify/storage": "6.7.7-server-auth.778c2b6.0+778c2b6",
279
+ "@aws-amplify/analytics": "7.0.66-unstable.c279ae0.0+c279ae0",
280
+ "@aws-amplify/api": "6.2.1-unstable.c279ae0.0+c279ae0",
281
+ "@aws-amplify/auth": "6.9.2-unstable.c279ae0.0+c279ae0",
282
+ "@aws-amplify/core": "6.9.1-unstable.c279ae0.0+c279ae0",
283
+ "@aws-amplify/datastore": "5.0.68-unstable.c279ae0.0+c279ae0",
284
+ "@aws-amplify/notifications": "2.0.66-unstable.c279ae0.0+c279ae0",
285
+ "@aws-amplify/storage": "6.7.7-unstable.c279ae0.0+c279ae0",
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": "778c2b6a83aedb49aa46d4df0083ff460f3000be"
521
+ "gitHead": "c279ae0e4c228c0958529002780f7a5b65c084aa"
522
522
  }
@@ -15,12 +15,3 @@ 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,14 +7,13 @@ 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
-
12
10
  export const defaultSetCookieOptions: CookieStorage.SetCookieOptions = {
13
11
  // TODO: allow configure with a public interface
14
12
  sameSite: 'lax',
15
13
  secure: true,
16
14
  path: '/',
17
15
  };
16
+ const ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000;
18
17
 
19
18
  /**
20
19
  * Creates a Key Value storage interface using the `cookieStorageAdapter` as the
@@ -25,7 +24,6 @@ export const defaultSetCookieOptions: CookieStorage.SetCookieOptions = {
25
24
  export const createKeyValueStorageFromCookieStorageAdapter = (
26
25
  cookieStorageAdapter: CookieStorage.Adapter,
27
26
  validator?: KeyValueStorageMethodValidator,
28
- setCookieOptions: CookieStorage.SetCookieOptions = {},
29
27
  ): KeyValueStorageInterface => {
30
28
  return {
31
29
  setItem(key, value) {
@@ -34,17 +32,11 @@ export const createKeyValueStorageFromCookieStorageAdapter = (
34
32
  // SetCookie: key=value;expires=Date.now() + 365 days;path=/;secure=true
35
33
  cookieStorageAdapter.delete(key);
36
34
 
37
- const mergedCookieOptions = {
35
+ // TODO(HuiSF): follow up the default CookieSerializeOptions values
36
+ cookieStorageAdapter.set(key, value, {
38
37
  ...defaultSetCookieOptions,
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);
38
+ expires: new Date(Date.now() + ONE_YEAR_IN_MS),
39
+ });
48
40
 
49
41
  return Promise.resolve();
50
42
  },
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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;;"}
@@ -1 +0,0 @@
1
- export declare const DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE: number;
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
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;;;;"}
@@ -1,4 +0,0 @@
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