@aws-amplify/adapter-nextjs 1.6.7-unstable.e5a8569.0 → 1.6.7
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.
- package/dist/cjs/api/generateServerClient.js.map +1 -1
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/cjs/auth/createAuthRouteHandlersFactory.js.map +1 -1
- package/dist/cjs/auth/handleAuthApiRouteRequestForAppRouter.js.map +1 -1
- package/dist/cjs/auth/handleAuthApiRouteRequestForPagesRouter.js.map +1 -1
- package/dist/cjs/auth/handlers/handleSignInCallbackRequest.js.map +1 -1
- package/dist/cjs/auth/handlers/handleSignInCallbackRequestForPagesRouter.js.map +1 -1
- package/dist/cjs/auth/handlers/handleSignOutCallbackRequest.js.map +1 -1
- package/dist/cjs/auth/handlers/handleSignOutCallbackRequestForPagesRouter.js.map +1 -1
- package/dist/cjs/auth/handlers/index.js.map +1 -1
- package/dist/cjs/auth/index.js.map +1 -1
- package/dist/cjs/auth/utils/appendSetCookieHeaders.js.map +1 -1
- package/dist/cjs/auth/utils/appendSetCookieHeadersToNextApiResponse.js.map +1 -1
- package/dist/cjs/auth/utils/createErrorSearchParamsString.js.map +1 -1
- package/dist/cjs/auth/utils/createUrlSearchParams.js.map +1 -1
- package/dist/cjs/auth/utils/getCookieValuesFromNextApiRequest.js.map +1 -1
- package/dist/cjs/auth/utils/getCookieValuesFromRequest.js.map +1 -1
- package/dist/cjs/auth/utils/getSearchParamValueFromUrl.js.map +1 -1
- package/dist/cjs/auth/utils/hasActiveUserSession.js.map +1 -1
- package/dist/cjs/auth/utils/index.js.map +1 -1
- package/dist/cjs/auth/utils/origin.js.map +1 -1
- package/dist/cjs/auth/utils/predicates.js +16 -1
- package/dist/cjs/auth/utils/predicates.js.map +1 -1
- package/dist/cjs/auth/utils/resolveIdentityProviderFromUrl.js.map +1 -1
- package/dist/cjs/auth/utils/resolveRedirectUrl.js.map +1 -1
- package/dist/cjs/auth/utils/tokenCookies.js.map +1 -1
- package/dist/cjs/createServerRunner.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/cookie/index.js.map +1 -1
- package/dist/cjs/utils/cookie/serializeCookie.js.map +1 -1
- package/dist/cjs/utils/createCookieStorageAdapterFromNextServerContext.js.map +1 -1
- package/dist/cjs/utils/createRunWithAmplifyServerContext.js.map +1 -1
- package/dist/cjs/utils/createTokenValidator.js.map +1 -1
- package/dist/cjs/utils/globalSettings.js.map +1 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/isValidCognitoToken.js.map +1 -1
- package/dist/esm/api/generateServerClient.mjs.map +1 -1
- package/dist/esm/auth/createAuthRouteHandlersFactory.mjs.map +1 -1
- package/dist/esm/auth/handleAuthApiRouteRequestForAppRouter.mjs.map +1 -1
- package/dist/esm/auth/handleAuthApiRouteRequestForPagesRouter.mjs.map +1 -1
- package/dist/esm/auth/handlers/handleSignInCallbackRequest.mjs.map +1 -1
- package/dist/esm/auth/handlers/handleSignInCallbackRequestForPagesRouter.mjs.map +1 -1
- package/dist/esm/auth/handlers/handleSignOutCallbackRequest.mjs.map +1 -1
- package/dist/esm/auth/handlers/handleSignOutCallbackRequestForPagesRouter.mjs.map +1 -1
- package/dist/esm/auth/utils/appendSetCookieHeaders.mjs.map +1 -1
- package/dist/esm/auth/utils/appendSetCookieHeadersToNextApiResponse.mjs.map +1 -1
- package/dist/esm/auth/utils/createErrorSearchParamsString.mjs.map +1 -1
- package/dist/esm/auth/utils/createUrlSearchParams.mjs.map +1 -1
- package/dist/esm/auth/utils/getCookieValuesFromNextApiRequest.mjs.map +1 -1
- package/dist/esm/auth/utils/getCookieValuesFromRequest.mjs.map +1 -1
- package/dist/esm/auth/utils/getSearchParamValueFromUrl.mjs.map +1 -1
- package/dist/esm/auth/utils/hasActiveUserSession.mjs.map +1 -1
- package/dist/esm/auth/utils/origin.mjs.map +1 -1
- package/dist/esm/auth/utils/predicates.mjs +16 -1
- package/dist/esm/auth/utils/predicates.mjs.map +1 -1
- package/dist/esm/auth/utils/resolveIdentityProviderFromUrl.mjs.map +1 -1
- package/dist/esm/auth/utils/resolveRedirectUrl.mjs.map +1 -1
- package/dist/esm/auth/utils/tokenCookies.mjs.map +1 -1
- package/dist/esm/createServerRunner.mjs.map +1 -1
- package/dist/esm/utils/cookie/serializeCookie.mjs.map +1 -1
- package/dist/esm/utils/createCookieStorageAdapterFromNextServerContext.mjs.map +1 -1
- package/dist/esm/utils/createRunWithAmplifyServerContext.mjs.map +1 -1
- package/dist/esm/utils/createTokenValidator.mjs.map +1 -1
- package/dist/esm/utils/globalSettings.mjs.map +1 -1
- package/dist/esm/utils/isValidCognitoToken.mjs.map +1 -1
- package/package.json +70 -70
- package/src/auth/utils/predicates.ts +19 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveIdentityProviderFromUrl.js","sources":["../../../../src/auth/utils/resolveIdentityProviderFromUrl.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.resolveIdentityProviderFromUrl = void 0;\nconst constant_1 = require(\"../constant\");\nconst getSearchParamValueFromUrl_1 = require(\"./getSearchParamValueFromUrl\");\nconst resolveIdentityProviderFromUrl = (urlStr) => resolveProvider((0, getSearchParamValueFromUrl_1.getSearchParamValueFromUrl)(urlStr, 'provider'));\nexports.resolveIdentityProviderFromUrl = resolveIdentityProviderFromUrl;\nconst resolveProvider = (provider) => {\n if (!provider) {\n return null;\n }\n return constant_1.COGNITO_IDENTITY_PROVIDERS[capitalize(provider)] ?? provider;\n};\nconst capitalize = (value) => `${value[0].toUpperCase()}${value.substring(1).toLowerCase()}`;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,8BAA8B,GAAG,MAAM;AAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;AACzC,MAAM,4BAA4B,GAAG,OAAO,CAAC,8BAA8B,CAAC;AAC5E,MAAM,8BAA8B,GAAG,CAAC,MAAM,KAAK,eAAe,CAAC,IAAI,4BAA4B,CAAC,0BAA0B,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AACpJ,OAAO,CAAC,8BAA8B,GAAG,8BAA8B;AACvE,MAAM,eAAe,GAAG,CAAC,QAAQ,KAAK;AACtC,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,OAAO,IAAI;AACnB;
|
|
1
|
+
{"version":3,"file":"resolveIdentityProviderFromUrl.js","sources":["../../../../src/auth/utils/resolveIdentityProviderFromUrl.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.resolveIdentityProviderFromUrl = void 0;\nconst constant_1 = require(\"../constant\");\nconst getSearchParamValueFromUrl_1 = require(\"./getSearchParamValueFromUrl\");\nconst resolveIdentityProviderFromUrl = (urlStr) => resolveProvider((0, getSearchParamValueFromUrl_1.getSearchParamValueFromUrl)(urlStr, 'provider'));\nexports.resolveIdentityProviderFromUrl = resolveIdentityProviderFromUrl;\nconst resolveProvider = (provider) => {\n if (!provider) {\n return null;\n }\n return constant_1.COGNITO_IDENTITY_PROVIDERS[capitalize(provider)] ?? provider;\n};\nconst capitalize = (value) => `${value[0].toUpperCase()}${value.substring(1).toLowerCase()}`;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,8BAA8B,GAAG,MAAM;AAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;AACzC,MAAM,4BAA4B,GAAG,OAAO,CAAC,8BAA8B,CAAC;AAC5E,MAAM,8BAA8B,GAAG,CAAC,MAAM,KAAK,eAAe,CAAC,IAAI,4BAA4B,CAAC,0BAA0B,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AACpJ,OAAO,CAAC,8BAA8B,GAAG,8BAA8B;AACvE,MAAM,eAAe,GAAG,CAAC,QAAQ,KAAK;AACtC,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ,IAAI,OAAO,UAAU,CAAC,0BAA0B,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,QAAQ;AAClF,CAAC;AACD,MAAM,UAAU,GAAG,CAAC,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveRedirectUrl.js","sources":["../../../../src/auth/utils/resolveRedirectUrl.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.resolveRedirectSignOutUrl = exports.resolveRedirectSignInUrl = void 0;\nconst internals_1 = require(\"aws-amplify/adapter-core/internals\");\nconst resolveRedirectSignInUrl = (origin, oAuthConfig) => {\n const redirectUrl = oAuthConfig.redirectSignIn.find(url => url.startsWith(origin));\n if (!redirectUrl) {\n throw createError('redirectSignIn');\n }\n return redirectUrl;\n};\nexports.resolveRedirectSignInUrl = resolveRedirectSignInUrl;\nconst resolveRedirectSignOutUrl = (origin, oAuthConfig) => {\n const redirectUrl = oAuthConfig.redirectSignOut.find(url => url.startsWith(origin));\n if (!redirectUrl) {\n throw createError('redirectSignOut');\n }\n return redirectUrl;\n};\nexports.resolveRedirectSignOutUrl = resolveRedirectSignOutUrl;\nconst createError = (urlType) => new internals_1.AmplifyServerContextError({\n message: `No valid ${urlType} url found in the OAuth config.`,\n recoverySuggestion: `Check the OAuth config and ensure the ${urlType} url is valid.`,\n});\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,GAAG,MAAM;AAC7E,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC;AACjE,MAAM,wBAAwB,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK;AAC1D,IAAI,MAAM,WAAW,GAAG,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACtF,IAAI,IAAI,CAAC,WAAW,EAAE;AACtB,QAAQ,MAAM,WAAW,CAAC,gBAAgB,CAAC;AAC3C;
|
|
1
|
+
{"version":3,"file":"resolveRedirectUrl.js","sources":["../../../../src/auth/utils/resolveRedirectUrl.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.resolveRedirectSignOutUrl = exports.resolveRedirectSignInUrl = void 0;\nconst internals_1 = require(\"aws-amplify/adapter-core/internals\");\nconst resolveRedirectSignInUrl = (origin, oAuthConfig) => {\n const redirectUrl = oAuthConfig.redirectSignIn.find(url => url.startsWith(origin));\n if (!redirectUrl) {\n throw createError('redirectSignIn');\n }\n return redirectUrl;\n};\nexports.resolveRedirectSignInUrl = resolveRedirectSignInUrl;\nconst resolveRedirectSignOutUrl = (origin, oAuthConfig) => {\n const redirectUrl = oAuthConfig.redirectSignOut.find(url => url.startsWith(origin));\n if (!redirectUrl) {\n throw createError('redirectSignOut');\n }\n return redirectUrl;\n};\nexports.resolveRedirectSignOutUrl = resolveRedirectSignOutUrl;\nconst createError = (urlType) => new internals_1.AmplifyServerContextError({\n message: `No valid ${urlType} url found in the OAuth config.`,\n recoverySuggestion: `Check the OAuth config and ensure the ${urlType} url is valid.`,\n});\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,GAAG,MAAM;AAC7E,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC;AACjE,MAAM,wBAAwB,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK;AAC1D,IAAI,MAAM,WAAW,GAAG,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACtF,IAAI,IAAI,CAAC,WAAW,EAAE;AACtB,QAAQ,MAAM,WAAW,CAAC,gBAAgB,CAAC;AAC3C,IAAI;AACJ,IAAI,OAAO,WAAW;AACtB,CAAC;AACD,OAAO,CAAC,wBAAwB,GAAG,wBAAwB;AAC3D,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK;AAC3D,IAAI,MAAM,WAAW,GAAG,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACvF,IAAI,IAAI,CAAC,WAAW,EAAE;AACtB,QAAQ,MAAM,WAAW,CAAC,iBAAiB,CAAC;AAC5C,IAAI;AACJ,IAAI,OAAO,WAAW;AACtB,CAAC;AACD,OAAO,CAAC,yBAAyB,GAAG,yBAAyB;AAC7D,MAAM,WAAW,GAAG,CAAC,OAAO,KAAK,IAAI,WAAW,CAAC,yBAAyB,CAAC;AAC3E,IAAI,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,+BAA+B,CAAC;AACjE,IAAI,kBAAkB,EAAE,CAAC,sCAAsC,EAAE,OAAO,CAAC,cAAc,CAAC;AACxF,CAAC,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenCookies.js","sources":["../../../../src/auth/utils/tokenCookies.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.isServerSideAuthAllowedCookie = exports.createTokenCookiesRemoveOptions = exports.createTokenCookiesSetOptions = exports.createTokenRemoveCookies = exports.createTokenCookies = void 0;\nconst adapter_core_1 = require(\"aws-amplify/adapter-core\");\nconst constant_1 = require(\"../constant\");\nconst getAccessTokenUsername_1 = require(\"./getAccessTokenUsername\");\nconst origin_1 = require(\"./origin\");\nconst createTokenCookies = ({ tokensPayload, userPoolClientId, }) => {\n const { access_token, id_token, refresh_token } = tokensPayload;\n const username = (0, getAccessTokenUsername_1.getAccessTokenUsername)(access_token);\n const authCookiesKeys = (0, adapter_core_1.createKeysForAuthStorage)(adapter_core_1.AUTH_KEY_PREFIX, `${userPoolClientId}.${username}`);\n return [\n {\n name: authCookiesKeys.accessToken,\n value: access_token,\n },\n {\n name: authCookiesKeys.idToken,\n value: id_token,\n },\n {\n name: authCookiesKeys.refreshToken,\n value: refresh_token,\n },\n {\n name: `${adapter_core_1.AUTH_KEY_PREFIX}.${userPoolClientId}.LastAuthUser`,\n value: username,\n },\n ];\n};\nexports.createTokenCookies = createTokenCookies;\nconst createTokenRemoveCookies = (keys) => keys.map(key => ({ name: key, value: '' }));\nexports.createTokenRemoveCookies = createTokenRemoveCookies;\nconst createTokenCookiesSetOptions = ({ domain, sameSite, expires, maxAge }, origin) => {\n const result = {\n domain,\n path: '/',\n httpOnly: true,\n secure: (0, origin_1.isSSLOrigin)(origin),\n sameSite: sameSite ?? 'strict',\n expires,\n maxAge,\n };\n // when expires and maxAge both are not specified, we set a default maxAge\n if (!result.expires && !result.maxAge) {\n result.maxAge = adapter_core_1.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE;\n }\n return result;\n};\nexports.createTokenCookiesSetOptions = createTokenCookiesSetOptions;\nconst createTokenCookiesRemoveOptions = (setCookieOptions) => ({\n domain: setCookieOptions?.domain,\n path: '/',\n maxAge: constant_1.REMOVE_COOKIE_MAX_AGE, // Expire immediately (remove the cookie)\n});\nexports.createTokenCookiesRemoveOptions = createTokenCookiesRemoveOptions;\nconst isServerSideAuthAllowedCookie = (cookieName) => constant_1.SERVER_AUTH_ALLOWED_AMPLIFY_AUTH_KEY_SUFFIX.some(suffix => cookieName.endsWith(suffix));\nexports.isServerSideAuthAllowedCookie = isServerSideAuthAllowedCookie;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,+BAA+B,GAAG,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,kBAAkB,GAAG,MAAM;AAC/L,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC;AAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;AACzC,MAAM,wBAAwB,GAAG,OAAO,CAAC,0BAA0B,CAAC;AACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;AACpC,MAAM,kBAAkB,GAAG,CAAC,EAAE,aAAa,EAAE,gBAAgB,GAAG,KAAK;AACrE,IAAI,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,aAAa;AACnE,IAAI,MAAM,QAAQ,GAAG,IAAI,wBAAwB,CAAC,sBAAsB,EAAE,YAAY,CAAC;AACvF,IAAI,MAAM,eAAe,GAAG,IAAI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I,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;AAC3C,QAAQ,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC,kCAAkC;AACzE;
|
|
1
|
+
{"version":3,"file":"tokenCookies.js","sources":["../../../../src/auth/utils/tokenCookies.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.isServerSideAuthAllowedCookie = exports.createTokenCookiesRemoveOptions = exports.createTokenCookiesSetOptions = exports.createTokenRemoveCookies = exports.createTokenCookies = void 0;\nconst adapter_core_1 = require(\"aws-amplify/adapter-core\");\nconst constant_1 = require(\"../constant\");\nconst getAccessTokenUsername_1 = require(\"./getAccessTokenUsername\");\nconst origin_1 = require(\"./origin\");\nconst createTokenCookies = ({ tokensPayload, userPoolClientId, }) => {\n const { access_token, id_token, refresh_token } = tokensPayload;\n const username = (0, getAccessTokenUsername_1.getAccessTokenUsername)(access_token);\n const authCookiesKeys = (0, adapter_core_1.createKeysForAuthStorage)(adapter_core_1.AUTH_KEY_PREFIX, `${userPoolClientId}.${username}`);\n return [\n {\n name: authCookiesKeys.accessToken,\n value: access_token,\n },\n {\n name: authCookiesKeys.idToken,\n value: id_token,\n },\n {\n name: authCookiesKeys.refreshToken,\n value: refresh_token,\n },\n {\n name: `${adapter_core_1.AUTH_KEY_PREFIX}.${userPoolClientId}.LastAuthUser`,\n value: username,\n },\n ];\n};\nexports.createTokenCookies = createTokenCookies;\nconst createTokenRemoveCookies = (keys) => keys.map(key => ({ name: key, value: '' }));\nexports.createTokenRemoveCookies = createTokenRemoveCookies;\nconst createTokenCookiesSetOptions = ({ domain, sameSite, expires, maxAge }, origin) => {\n const result = {\n domain,\n path: '/',\n httpOnly: true,\n secure: (0, origin_1.isSSLOrigin)(origin),\n sameSite: sameSite ?? 'strict',\n expires,\n maxAge,\n };\n // when expires and maxAge both are not specified, we set a default maxAge\n if (!result.expires && !result.maxAge) {\n result.maxAge = adapter_core_1.DEFAULT_AUTH_TOKEN_COOKIES_MAX_AGE;\n }\n return result;\n};\nexports.createTokenCookiesSetOptions = createTokenCookiesSetOptions;\nconst createTokenCookiesRemoveOptions = (setCookieOptions) => ({\n domain: setCookieOptions?.domain,\n path: '/',\n maxAge: constant_1.REMOVE_COOKIE_MAX_AGE, // Expire immediately (remove the cookie)\n});\nexports.createTokenCookiesRemoveOptions = createTokenCookiesRemoveOptions;\nconst isServerSideAuthAllowedCookie = (cookieName) => constant_1.SERVER_AUTH_ALLOWED_AMPLIFY_AUTH_KEY_SUFFIX.some(suffix => cookieName.endsWith(suffix));\nexports.isServerSideAuthAllowedCookie = isServerSideAuthAllowedCookie;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,+BAA+B,GAAG,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,kBAAkB,GAAG,MAAM;AAC/L,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC;AAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;AACzC,MAAM,wBAAwB,GAAG,OAAO,CAAC,0BAA0B,CAAC;AACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;AACpC,MAAM,kBAAkB,GAAG,CAAC,EAAE,aAAa,EAAE,gBAAgB,GAAG,KAAK;AACrE,IAAI,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,aAAa;AACnE,IAAI,MAAM,QAAQ,GAAG,IAAI,wBAAwB,CAAC,sBAAsB,EAAE,YAAY,CAAC;AACvF,IAAI,MAAM,eAAe,GAAG,IAAI,cAAc,CAAC,wBAAwB,E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AO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;AAC3C,QAAQ,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC,kCAAkC;AACzE,IAAI;AACJ,IAAI,OAAO,MAAM;AACjB,CAAC;AACD,OAAO,CAAC,4BAA4B,GAAG,4BAA4B;AACnE,MAAM,+BAA+B,GAAG,CAAC,gBAAgB,MAAM;AAC/D,IAAI,MAAM,EAAE,gBAAgB,EAAE,MAAM;AACpC,IAAI,IAAI,EAAE,GAAG;AACb,IAAI,MAAM,EAAE,UAAU,CAAC,qBAAqB;AAC5C,CAAC,CAAC;AACF,OAAO,CAAC,+BAA+B,GAAG,+BAA+B;AACzE,MAAM,6BAA6B,GAAG,CAAC,UAAU,KAAK,UAAU,CAAC,2CAA2C,CAAC,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACxJ,OAAO,CAAC,6BAA6B,GAAG,6BAA6B;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServerRunner.js","sources":["../../src/createServerRunner.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.createServerRunner = void 0;\nconst utils_1 = require(\"aws-amplify/utils\");\nconst utils_2 = require(\"./utils\");\nconst createTokenValidator_1 = require(\"./utils/createTokenValidator\");\nconst auth_1 = require(\"./auth\");\nconst utils_3 = require(\"./auth/utils\");\n/**\n * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context.\n *\n * @remarks\n * This function should be called only once; you can use the returned `runWithAmplifyServerContext` across\n * your codebase.\n *\n * @param input The input used to create the `runWithAmplifyServerContext` function.\n * @param input.config The {@link ResourcesConfig} imported from the `amplifyconfiguration.json` file or manually\n * created.\n * @returns An object that contains the `runWithAmplifyServerContext` function.\n *\n * @example\n * import { createServerRunner } from '@aws-amplify/adapter-nextjs';\n * import config from './amplifyconfiguration.json';\n *\n * export const { runWithAmplifyServerContext } = createServerRunner({ config })\n */\nconst createServerRunner = ({ config, runtimeOptions, }) => {\n const amplifyConfig = (0, utils_1.parseAmplifyConfig)(config);\n const amplifyAppOrigin = process.env.AMPLIFY_APP_ORIGIN;\n utils_2.globalSettings.setRuntimeOptions(runtimeOptions ?? {});\n if ((0, utils_3.isValidOrigin)(amplifyAppOrigin)) {\n utils_2.globalSettings.setIsSSLOrigin((0, utils_3.isSSLOrigin)(amplifyAppOrigin));\n // update the isServerSideAuthEnabled flag of the globalSettings to true\n utils_2.globalSettings.enableServerSideAuth();\n }\n let tokenValidator;\n if (amplifyConfig?.Auth) {\n const { Cognito } = amplifyConfig.Auth;\n tokenValidator = (0, createTokenValidator_1.createTokenValidator)({\n userPoolId: Cognito?.userPoolId,\n userPoolClientId: Cognito?.userPoolClientId,\n });\n }\n const runWithAmplifyServerContext = (0, utils_2.createRunWithAmplifyServerContext)({\n config: amplifyConfig,\n tokenValidator,\n globalSettings: utils_2.globalSettings,\n });\n return {\n runWithAmplifyServerContext,\n createAuthRouteHandlers: (0, auth_1.createAuthRouteHandlersFactory)({\n config: amplifyConfig,\n amplifyAppOrigin,\n globalSettings: utils_2.globalSettings,\n runWithAmplifyServerContext,\n }),\n };\n};\nexports.createServerRunner = createServerRunner;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,MAAM;AACnC,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;AAClC,MAAM,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;AACtE,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAE,cAAc,GAAG,KAAK;AAC5D,IAAI,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC;AACjE,IAAI,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB;AAC3D,IAAI,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,cAAc,IAAI,EAAE,CAAC;AAClE,IAAI,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAAE;AACtD,QAAQ,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AACzF;AACA,QAAQ,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE;AACrD;
|
|
1
|
+
{"version":3,"file":"createServerRunner.js","sources":["../../src/createServerRunner.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.createServerRunner = void 0;\nconst utils_1 = require(\"aws-amplify/utils\");\nconst utils_2 = require(\"./utils\");\nconst createTokenValidator_1 = require(\"./utils/createTokenValidator\");\nconst auth_1 = require(\"./auth\");\nconst utils_3 = require(\"./auth/utils\");\n/**\n * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context.\n *\n * @remarks\n * This function should be called only once; you can use the returned `runWithAmplifyServerContext` across\n * your codebase.\n *\n * @param input The input used to create the `runWithAmplifyServerContext` function.\n * @param input.config The {@link ResourcesConfig} imported from the `amplifyconfiguration.json` file or manually\n * created.\n * @returns An object that contains the `runWithAmplifyServerContext` function.\n *\n * @example\n * import { createServerRunner } from '@aws-amplify/adapter-nextjs';\n * import config from './amplifyconfiguration.json';\n *\n * export const { runWithAmplifyServerContext } = createServerRunner({ config })\n */\nconst createServerRunner = ({ config, runtimeOptions, }) => {\n const amplifyConfig = (0, utils_1.parseAmplifyConfig)(config);\n const amplifyAppOrigin = process.env.AMPLIFY_APP_ORIGIN;\n utils_2.globalSettings.setRuntimeOptions(runtimeOptions ?? {});\n if ((0, utils_3.isValidOrigin)(amplifyAppOrigin)) {\n utils_2.globalSettings.setIsSSLOrigin((0, utils_3.isSSLOrigin)(amplifyAppOrigin));\n // update the isServerSideAuthEnabled flag of the globalSettings to true\n utils_2.globalSettings.enableServerSideAuth();\n }\n let tokenValidator;\n if (amplifyConfig?.Auth) {\n const { Cognito } = amplifyConfig.Auth;\n tokenValidator = (0, createTokenValidator_1.createTokenValidator)({\n userPoolId: Cognito?.userPoolId,\n userPoolClientId: Cognito?.userPoolClientId,\n });\n }\n const runWithAmplifyServerContext = (0, utils_2.createRunWithAmplifyServerContext)({\n config: amplifyConfig,\n tokenValidator,\n globalSettings: utils_2.globalSettings,\n });\n return {\n runWithAmplifyServerContext,\n createAuthRouteHandlers: (0, auth_1.createAuthRouteHandlersFactory)({\n config: amplifyConfig,\n amplifyAppOrigin,\n globalSettings: utils_2.globalSettings,\n runWithAmplifyServerContext,\n }),\n };\n};\nexports.createServerRunner = createServerRunner;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,MAAM;AACnC,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;AAClC,MAAM,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;AACtE,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,OAAO,GAAG,OAAO,CAAC,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,aAAa;AACjC,YAAY,gBAAgB;AAC5B,YAAY,cAAc,EAAE,OAAO,CAAC,cAAc;AAClD,YAAY,2BAA2B;AACvC,SAAS,CAAC;AACV,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/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.createServerRunner = void 0;\nvar createServerRunner_1 = require(\"./createServerRunner\");\nObject.defineProperty(exports, \"createServerRunner\", { enumerable: true, get: function () { return createServerRunner_1.createServerRunner; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,MAAM;AACnC,IAAI,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC;AAC1D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,oBAAoB,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/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.createServerRunner = void 0;\nvar createServerRunner_1 = require(\"./createServerRunner\");\nObject.defineProperty(exports, \"createServerRunner\", { enumerable: true, get: function () { return createServerRunner_1.createServerRunner; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,MAAM;AACnC,IAAI,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC;AAC1D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/utils/cookie/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.serializeCookie = exports.ensureEncodedForJSCookie = void 0;\nvar ensureEncodedForJSCookie_1 = require(\"./ensureEncodedForJSCookie\");\nObject.defineProperty(exports, \"ensureEncodedForJSCookie\", { enumerable: true, get: function () { return ensureEncodedForJSCookie_1.ensureEncodedForJSCookie; } });\nvar serializeCookie_1 = require(\"./serializeCookie\");\nObject.defineProperty(exports, \"serializeCookie\", { enumerable: true, get: function () { return serializeCookie_1.serializeCookie; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,wBAAwB,GAAG,MAAM;AACnE,IAAI,0BAA0B,GAAG,OAAO,CAAC,4BAA4B,CAAC;AACtE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,0BAA0B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,0BAA0B,CAAC,wBAAwB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/utils/cookie/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.serializeCookie = exports.ensureEncodedForJSCookie = void 0;\nvar ensureEncodedForJSCookie_1 = require(\"./ensureEncodedForJSCookie\");\nObject.defineProperty(exports, \"ensureEncodedForJSCookie\", { enumerable: true, get: function () { return ensureEncodedForJSCookie_1.ensureEncodedForJSCookie; } });\nvar serializeCookie_1 = require(\"./serializeCookie\");\nObject.defineProperty(exports, \"serializeCookie\", { enumerable: true, get: function () { return serializeCookie_1.serializeCookie; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,wBAAwB,GAAG,MAAM;AACnE,IAAI,0BAA0B,GAAG,OAAO,CAAC,4BAA4B,CAAC;AACtE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,0BAA0B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,0BAA0B,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC;AAClK,IAAI,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;AACpD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeCookie.js","sources":["../../../../src/utils/cookie/serializeCookie.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.serializeCookie = void 0;\nconst serializeCookie = (name, value, options) => `${name}=${value};${options ? serializeSetCookieOptions(options) : ''}`;\nexports.serializeCookie = serializeCookie;\nconst serializeSetCookieOptions = (options) => {\n const { expires, domain, httpOnly, sameSite, secure, path, maxAge } = options;\n const serializedOptions = [];\n if (domain) {\n serializedOptions.push(`Domain=${domain}`);\n }\n if (expires) {\n serializedOptions.push(`Expires=${expires.toUTCString()}`);\n }\n if (httpOnly) {\n serializedOptions.push(`HttpOnly`);\n }\n if (sameSite) {\n serializedOptions.push(`SameSite=${sameSite}`);\n }\n if (secure) {\n serializedOptions.push(`Secure`);\n }\n if (path) {\n serializedOptions.push(`Path=${path}`);\n }\n if (maxAge) {\n serializedOptions.push(`Max-Age=${maxAge}`);\n }\n return serializedOptions.join(';');\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,MAAM;AAChC,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,yBAAyB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AACzH,OAAO,CAAC,eAAe,GAAG,eAAe;AACzC,MAAM,yBAAyB,GAAG,CAAC,OAAO,KAAK;AAC/C,IAAI,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;AACjF,IAAI,MAAM,iBAAiB,GAAG,EAAE;AAChC,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAClD;
|
|
1
|
+
{"version":3,"file":"serializeCookie.js","sources":["../../../../src/utils/cookie/serializeCookie.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.serializeCookie = void 0;\nconst serializeCookie = (name, value, options) => `${name}=${value};${options ? serializeSetCookieOptions(options) : ''}`;\nexports.serializeCookie = serializeCookie;\nconst serializeSetCookieOptions = (options) => {\n const { expires, domain, httpOnly, sameSite, secure, path, maxAge } = options;\n const serializedOptions = [];\n if (domain) {\n serializedOptions.push(`Domain=${domain}`);\n }\n if (expires) {\n serializedOptions.push(`Expires=${expires.toUTCString()}`);\n }\n if (httpOnly) {\n serializedOptions.push(`HttpOnly`);\n }\n if (sameSite) {\n serializedOptions.push(`SameSite=${sameSite}`);\n }\n if (secure) {\n serializedOptions.push(`Secure`);\n }\n if (path) {\n serializedOptions.push(`Path=${path}`);\n }\n if (maxAge) {\n serializedOptions.push(`Max-Age=${maxAge}`);\n }\n return serializedOptions.join(';');\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,MAAM;AAChC,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,yBAAyB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AACzH,OAAO,CAAC,eAAe,GAAG,eAAe;AACzC,MAAM,yBAAyB,GAAG,CAAC,OAAO,KAAK;AAC/C,IAAI,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;AACjF,IAAI,MAAM,iBAAiB,GAAG,EAAE;AAChC,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAClD,IAAI;AACJ,IAAI,IAAI,OAAO,EAAE;AACjB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAClE,IAAI;AACJ,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC1C,IAAI;AACJ,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACtD,IAAI;AACJ,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AACxC,IAAI;AACJ,IAAI,IAAI,IAAI,EAAE;AACd,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9C,IAAI;AACJ,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AACnD,IAAI;AACJ,IAAI,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC;AACtC,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCookieStorageAdapterFromNextServerContext.js","sources":["../../../src/utils/createCookieStorageAdapterFromNextServerContext.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.createCookieStorageAdapterFromNextServerContext = exports.DATE_IN_THE_PAST = void 0;\nconst server_js_1 = require(\"next/server.js\");\nconst internals_1 = require(\"aws-amplify/adapter-core/internals\");\nconst utils_1 = require(\"../auth/utils\");\nconst cookie_1 = require(\"./cookie\");\nexports.DATE_IN_THE_PAST = new Date(0);\nconst createCookieStorageAdapterFromNextServerContext = async (context, ignoreNonServerSideCookies = false) => {\n const { request: req, response: res } = context;\n // When the server context is from `getServerSideProps`, the `req` is an instance\n // of IncomingMessage, and the `res` is an instance of ServerResponse.\n // We cannot import these two classes here from `http` as it breaks in Next\n // Edge Runtime. Hence, we check the methods that we need to use for creating\n // cookie adapter.\n if (req &&\n res &&\n Object.prototype.toString.call(req.cookies) === '[object Object]' &&\n typeof res.setHeader === 'function') {\n return createCookieStorageAdapterFromGetServerSidePropsContext(req, res, ignoreNonServerSideCookies);\n }\n const { request, response } = context;\n // When the server context is from `middleware`, the `request` is an instance\n // of `NextRequest`.\n // When the server context is from a route handler, the `request` is an `Proxy`\n // wrapped `Request`.\n // The `NextRequest` and the `Proxy` are sharing the same interface by Next\n // implementation. So we don't need to detect the difference.\n if (request && response) {\n if (response instanceof server_js_1.NextResponse) {\n return createCookieStorageAdapterFromNextRequestAndNextResponse(request, response, ignoreNonServerSideCookies);\n }\n else {\n return createCookieStorageAdapterFromNextRequestAndHttpResponse(request, response, ignoreNonServerSideCookies);\n }\n }\n const { cookies } = context;\n if (typeof cookies === 'function') {\n return createCookieStorageAdapterFromNextCookies(cookies, ignoreNonServerSideCookies);\n }\n // This should not happen normally.\n throw new internals_1.AmplifyServerContextError({\n message: 'Attempted to create cookie storage adapter from an unsupported Next.js server context.',\n });\n};\nexports.createCookieStorageAdapterFromNextServerContext = createCookieStorageAdapterFromNextServerContext;\nconst createCookieStorageAdapterFromNextRequestAndNextResponse = (request, response, ignoreNonServerSideCookies) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = response.cookies;\n return {\n get(name) {\n return readonlyCookieStore.get((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n set(name, value, options) {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n mutableCookieStore.set((0, cookie_1.ensureEncodedForJSCookie)(name), value, options);\n },\n delete(name) {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n mutableCookieStore.delete((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n };\n};\nconst createCookieStorageAdapterFromNextRequestAndHttpResponse = (request, response, ignoreNonServerSideCookies) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = createMutableCookieStoreFromHeaders(response.headers, ignoreNonServerSideCookies);\n return {\n get(name) {\n return readonlyCookieStore.get((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n ...mutableCookieStore,\n };\n};\nconst createCookieStorageAdapterFromNextCookies = async (cookies, ignoreNonServerSideCookies) => {\n const cookieStore = await cookies();\n // When Next cookies() is called in a server component, it returns a readonly\n // cookie store. Hence calling set and delete throws an error. However,\n // cookies() returns a mutable cookie store when called in a server action.\n // We have no way to detect which one is returned, so we try to call set and delete\n // and safely ignore the error if it is thrown.\n const setFunc = (name, value, options) => {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n try {\n cookieStore.set((0, cookie_1.ensureEncodedForJSCookie)(name), value, options);\n }\n catch {\n // no-op\n }\n };\n const deleteFunc = name => {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n try {\n cookieStore.delete((0, cookie_1.ensureEncodedForJSCookie)(name));\n }\n catch {\n // no-op\n }\n };\n return {\n get(name) {\n return cookieStore.get((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n getAll: cookieStore.getAll.bind(cookieStore),\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst createCookieStorageAdapterFromGetServerSidePropsContext = (request, response, ignoreNonServerSideCookies) => {\n const cookiesMap = { ...request.cookies };\n const allCookies = Object.entries(cookiesMap).map(([name, value]) => ({\n name,\n value,\n }));\n return {\n get(name) {\n const value = cookiesMap[(0, cookie_1.ensureEncodedForJSCookie)(name)];\n return value\n ? {\n name,\n value,\n }\n : undefined;\n },\n getAll() {\n return allCookies;\n },\n set(name, value, options) {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n const encodedName = (0, cookie_1.ensureEncodedForJSCookie)(name);\n const existingValues = getExistingSetCookieValues(response.getHeader('Set-Cookie'));\n // if the cookies have already been set, we don't need to set them again.\n if (existingValues.findIndex(cookieValue => cookieValue.startsWith(`${encodedName}=`) &&\n !cookieValue.startsWith(`${encodedName}=;`)) > -1) {\n return;\n }\n response.appendHeader('Set-Cookie', (0, cookie_1.serializeCookie)(encodedName, value, options));\n },\n delete(name) {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n const encodedName = (0, cookie_1.ensureEncodedForJSCookie)(name);\n const setCookieValue = `${encodedName}=;Expires=${exports.DATE_IN_THE_PAST.toUTCString()}`;\n const existingValues = getExistingSetCookieValues(response.getHeader('Set-Cookie'));\n // if the value for cookie deletion is already in the Set-Cookie header, we\n // don't need to add the deletion value again.\n if (existingValues.includes(setCookieValue)) {\n return;\n }\n response.appendHeader('Set-Cookie', setCookieValue);\n },\n };\n};\nconst createMutableCookieStoreFromHeaders = (headers, ignoreNonServerSideCookies) => {\n const setFunc = (name, value, options) => {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n headers.append('Set-Cookie', (0, cookie_1.serializeCookie)((0, cookie_1.ensureEncodedForJSCookie)(name), value, options));\n };\n const deleteFunc = name => {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n headers.append('Set-Cookie', `${(0, cookie_1.ensureEncodedForJSCookie)(name)}=;Expires=${exports.DATE_IN_THE_PAST.toUTCString()}`);\n };\n return {\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst getExistingSetCookieValues = (values) => values === undefined ? [] : Array.isArray(values) ? values : [String(values)];\nconst shouldIgnoreCookie = (ignoreNonServerSideCookies, cookieName) => ignoreNonServerSideCookies && !(0, utils_1.isServerSideAuthAllowedCookie)(cookieName);\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,+CAA+C,GAAG,OAAO,CAAC,gBAAgB,GAAG,MAAM;AAC3F,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;AAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC;AACjE,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;AACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;AACpC,OAAO,CAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;AACtC,MAAM,+CAA+C,GAAG,OAAO,OAAO,EAAE,0BAA0B,GAAG,KAAK,KAAK;AAC/G,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO;AACnD;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,GAAG;AACX,QAAQ,GAAG;AACX,QAAQ,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,iBAAiB;AACzE,QAAQ,OAAO,GAAG,CAAC,SAAS,KAAK,UAAU,EAAE;AAC7C,QAAQ,OAAO,uDAAuD,CAAC,GAAG,EAAE,GAAG,EAAE,0BAA0B,CAAC;AAC5G;AACA,IAAI,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,OAAO,IAAI,QAAQ,EAAE;AAC7B,QAAQ,IAAI,QAAQ,YAAY,WAAW,CAAC,YAAY,EAAE;AA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KAAK;AACL,CAAC;AACD,MAAM,mCAAmC,GAAG,CAAC,OAAO,EAAE,0BAA0B,KAAK;AACrF,IAAI,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,KAAK;AAC9C,QAAQ,IAAI,kBAAkB,CAAC,0BAA0B,EAAE,IAAI,CAAC,EAAE;AAClE,YAAY;AACZ;AACA,QAAQ,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,QAAQ,CAAC,eAAe,EAAE,IAAI,QAAQ,CAAC,wBAAwB,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACjI,KAAK;AACL,IAAI,MAAM,UAAU,GAAG,IAAI,IAAI;AAC/B,QAAQ,IAAI,kBAAkB,CAAC,0BAA0B,EAAE,IAAI,CAAC,EAAE;AAClE,YAAY;AACZ;AACA,QAAQ,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,QAAQ,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC1I,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,OAAO;AACpB,QAAQ,MAAM,EAAE,UAAU;AAC1B,KAAK;AACL,CAAC;AACD,MAAM,0BAA0B,GAAG,CAAC,MAAM,KAAK,MAAM,KAAK,SAAS,GAAG,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5H,MAAM,kBAAkB,GAAG,CAAC,0BAA0B,EAAE,UAAU,KAAK,0BAA0B,IAAI,CAAC,IAAI,OAAO,CAAC,6BAA6B,EAAE,UAAU,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"createCookieStorageAdapterFromNextServerContext.js","sources":["../../../src/utils/createCookieStorageAdapterFromNextServerContext.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.createCookieStorageAdapterFromNextServerContext = exports.DATE_IN_THE_PAST = void 0;\nconst server_js_1 = require(\"next/server.js\");\nconst internals_1 = require(\"aws-amplify/adapter-core/internals\");\nconst utils_1 = require(\"../auth/utils\");\nconst cookie_1 = require(\"./cookie\");\nexports.DATE_IN_THE_PAST = new Date(0);\nconst createCookieStorageAdapterFromNextServerContext = async (context, ignoreNonServerSideCookies = false) => {\n const { request: req, response: res } = context;\n // When the server context is from `getServerSideProps`, the `req` is an instance\n // of IncomingMessage, and the `res` is an instance of ServerResponse.\n // We cannot import these two classes here from `http` as it breaks in Next\n // Edge Runtime. Hence, we check the methods that we need to use for creating\n // cookie adapter.\n if (req &&\n res &&\n Object.prototype.toString.call(req.cookies) === '[object Object]' &&\n typeof res.setHeader === 'function') {\n return createCookieStorageAdapterFromGetServerSidePropsContext(req, res, ignoreNonServerSideCookies);\n }\n const { request, response } = context;\n // When the server context is from `middleware`, the `request` is an instance\n // of `NextRequest`.\n // When the server context is from a route handler, the `request` is an `Proxy`\n // wrapped `Request`.\n // The `NextRequest` and the `Proxy` are sharing the same interface by Next\n // implementation. So we don't need to detect the difference.\n if (request && response) {\n if (response instanceof server_js_1.NextResponse) {\n return createCookieStorageAdapterFromNextRequestAndNextResponse(request, response, ignoreNonServerSideCookies);\n }\n else {\n return createCookieStorageAdapterFromNextRequestAndHttpResponse(request, response, ignoreNonServerSideCookies);\n }\n }\n const { cookies } = context;\n if (typeof cookies === 'function') {\n return createCookieStorageAdapterFromNextCookies(cookies, ignoreNonServerSideCookies);\n }\n // This should not happen normally.\n throw new internals_1.AmplifyServerContextError({\n message: 'Attempted to create cookie storage adapter from an unsupported Next.js server context.',\n });\n};\nexports.createCookieStorageAdapterFromNextServerContext = createCookieStorageAdapterFromNextServerContext;\nconst createCookieStorageAdapterFromNextRequestAndNextResponse = (request, response, ignoreNonServerSideCookies) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = response.cookies;\n return {\n get(name) {\n return readonlyCookieStore.get((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n set(name, value, options) {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n mutableCookieStore.set((0, cookie_1.ensureEncodedForJSCookie)(name), value, options);\n },\n delete(name) {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n mutableCookieStore.delete((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n };\n};\nconst createCookieStorageAdapterFromNextRequestAndHttpResponse = (request, response, ignoreNonServerSideCookies) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = createMutableCookieStoreFromHeaders(response.headers, ignoreNonServerSideCookies);\n return {\n get(name) {\n return readonlyCookieStore.get((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n ...mutableCookieStore,\n };\n};\nconst createCookieStorageAdapterFromNextCookies = async (cookies, ignoreNonServerSideCookies) => {\n const cookieStore = await cookies();\n // When Next cookies() is called in a server component, it returns a readonly\n // cookie store. Hence calling set and delete throws an error. However,\n // cookies() returns a mutable cookie store when called in a server action.\n // We have no way to detect which one is returned, so we try to call set and delete\n // and safely ignore the error if it is thrown.\n const setFunc = (name, value, options) => {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n try {\n cookieStore.set((0, cookie_1.ensureEncodedForJSCookie)(name), value, options);\n }\n catch {\n // no-op\n }\n };\n const deleteFunc = name => {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n try {\n cookieStore.delete((0, cookie_1.ensureEncodedForJSCookie)(name));\n }\n catch {\n // no-op\n }\n };\n return {\n get(name) {\n return cookieStore.get((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n getAll: cookieStore.getAll.bind(cookieStore),\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst createCookieStorageAdapterFromGetServerSidePropsContext = (request, response, ignoreNonServerSideCookies) => {\n const cookiesMap = { ...request.cookies };\n const allCookies = Object.entries(cookiesMap).map(([name, value]) => ({\n name,\n value,\n }));\n return {\n get(name) {\n const value = cookiesMap[(0, cookie_1.ensureEncodedForJSCookie)(name)];\n return value\n ? {\n name,\n value,\n }\n : undefined;\n },\n getAll() {\n return allCookies;\n },\n set(name, value, options) {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n const encodedName = (0, cookie_1.ensureEncodedForJSCookie)(name);\n const existingValues = getExistingSetCookieValues(response.getHeader('Set-Cookie'));\n // if the cookies have already been set, we don't need to set them again.\n if (existingValues.findIndex(cookieValue => cookieValue.startsWith(`${encodedName}=`) &&\n !cookieValue.startsWith(`${encodedName}=;`)) > -1) {\n return;\n }\n response.appendHeader('Set-Cookie', (0, cookie_1.serializeCookie)(encodedName, value, options));\n },\n delete(name) {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n const encodedName = (0, cookie_1.ensureEncodedForJSCookie)(name);\n const setCookieValue = `${encodedName}=;Expires=${exports.DATE_IN_THE_PAST.toUTCString()}`;\n const existingValues = getExistingSetCookieValues(response.getHeader('Set-Cookie'));\n // if the value for cookie deletion is already in the Set-Cookie header, we\n // don't need to add the deletion value again.\n if (existingValues.includes(setCookieValue)) {\n return;\n }\n response.appendHeader('Set-Cookie', setCookieValue);\n },\n };\n};\nconst createMutableCookieStoreFromHeaders = (headers, ignoreNonServerSideCookies) => {\n const setFunc = (name, value, options) => {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n headers.append('Set-Cookie', (0, cookie_1.serializeCookie)((0, cookie_1.ensureEncodedForJSCookie)(name), value, options));\n };\n const deleteFunc = name => {\n if (shouldIgnoreCookie(ignoreNonServerSideCookies, name)) {\n return;\n }\n headers.append('Set-Cookie', `${(0, cookie_1.ensureEncodedForJSCookie)(name)}=;Expires=${exports.DATE_IN_THE_PAST.toUTCString()}`);\n };\n return {\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst getExistingSetCookieValues = (values) => values === undefined ? [] : Array.isArray(values) ? values : [String(values)];\nconst shouldIgnoreCookie = (ignoreNonServerSideCookies, cookieName) => ignoreNonServerSideCookies && !(0, utils_1.isServerSideAuthAllowedCookie)(cookieName);\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,+CAA+C,GAAG,OAAO,CAAC,gBAAgB,GAAG,MAAM;AAC3F,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;AAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC;AACjE,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;AACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;AACpC,OAAO,CAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;AACtC,MAAM,+CAA+C,GAAG,OAAO,OAAO,EAAE,0BAA0B,GAAG,KAAK,KAAK;AAC/G,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO;AACnD;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,GAAG;AACX,QAAQ,GAAG;AACX,QAAQ,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,iBAAiB;AACzE,QAAQ,OAAO,GAAG,CAAC,SAAS,KAAK,UAAU,EAAE;AAC7C,QAAQ,OAAO,uDAAuD,CAAC,GAAG,EAAE,GAAG,EAAE,0BAA0B,CAAC;AAC5G,IAAI;AACJ,IAAI,MAA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AM,0BAA0B,GAAG,CAAC,MAAM,KAAK,MAAM,KAAK,SAAS,GAAG,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5H,MAAM,kBAAkB,GAAG,CAAC,0BAA0B,EAAE,UAAU,KAAK,0BAA0B,IAAI,CAAC,IAAI,OAAO,CAAC,6BAA6B,EAAE,UAAU,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRunWithAmplifyServerContext.js","sources":["../../../src/utils/createRunWithAmplifyServerContext.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.createRunWithAmplifyServerContext = void 0;\nconst utils_1 = require(\"aws-amplify/utils\");\nconst adapter_core_1 = require(\"aws-amplify/adapter-core\");\nconst constant_1 = require(\"../auth/constant\");\nconst createCookieStorageAdapterFromNextServerContext_1 = require(\"./createCookieStorageAdapterFromNextServerContext\");\nconst createRunWithAmplifyServerContext = ({ config: resourcesConfig, tokenValidator, globalSettings, }) => {\n const isServerSideAuthEnabled = globalSettings.isServerSideAuthEnabled();\n const isSSLOrigin = globalSettings.isSSLOrigin();\n const setCookieOptions = globalSettings.getRuntimeOptions().cookies ?? {};\n const mergedSetCookieOptions = {\n // default options when not specified\n ...(isServerSideAuthEnabled && constant_1.DEFAULT_SERVER_SIDE_AUTH_SET_COOKIE_OPTIONS),\n // user-specified options\n ...setCookieOptions,\n // enforced options when server-side auth is enabled\n ...(isServerSideAuthEnabled && {\n ...constant_1.ENFORCED_SERVER_SIDE_AUTH_SET_COOKIE_OPTIONS,\n secure: isSSLOrigin,\n }),\n // only support root path\n path: '/',\n };\n const runWithAmplifyServerContext = async ({ nextServerContext, operation }) => {\n // When the Auth config is presented, attempt to create a Amplify server\n // context with token and credentials provider.\n if (resourcesConfig.Auth) {\n const keyValueStorage = \n // When `null` is passed as the value of `nextServerContext`, opt-in\n // unauthenticated role (primarily for static rendering). It's\n // safe to use the singleton `MemoryKeyValueStorage` here, as the\n // static rendering uses the same unauthenticated role cross-sever.\n nextServerContext === null\n ? utils_1.sharedInMemoryStorage\n : (0, adapter_core_1.createKeyValueStorageFromCookieStorageAdapter)(await (0, createCookieStorageAdapterFromNextServerContext_1.createCookieStorageAdapterFromNextServerContext)(nextServerContext, isServerSideAuthEnabled), tokenValidator, mergedSetCookieOptions);\n const credentialsProvider = (0, adapter_core_1.createAWSCredentialsAndIdentityIdProvider)(resourcesConfig.Auth, keyValueStorage);\n const tokenProvider = (0, adapter_core_1.createUserPoolsTokenProvider)(resourcesConfig.Auth, keyValueStorage);\n return (0, adapter_core_1.runWithAmplifyServerContext)(resourcesConfig, {\n Auth: { credentialsProvider, tokenProvider },\n }, operation);\n }\n // Otherwise it may be the case that auth is not used, e.g. API key.\n // Omitting the `Auth` in the second parameter.\n return (0, adapter_core_1.runWithAmplifyServerContext)(resourcesConfig, {}, operation);\n };\n return runWithAmplifyServerContext;\n};\nexports.createRunWithAmplifyServerContext = createRunWithAmplifyServerContext;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,iCAAiC,GAAG,MAAM;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC5C,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC;AAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC;AAC9C,MAAM,iDAAiD,GAAG,OAAO,CAAC,mDAAmD,CAAC;AACtH,MAAM,iCAAiC,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAG,KAAK;AAC5G,IAAI,MAAM,uBAAuB,GAA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":"createRunWithAmplifyServerContext.js","sources":["../../../src/utils/createRunWithAmplifyServerContext.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.createRunWithAmplifyServerContext = void 0;\nconst utils_1 = require(\"aws-amplify/utils\");\nconst adapter_core_1 = require(\"aws-amplify/adapter-core\");\nconst constant_1 = require(\"../auth/constant\");\nconst createCookieStorageAdapterFromNextServerContext_1 = require(\"./createCookieStorageAdapterFromNextServerContext\");\nconst createRunWithAmplifyServerContext = ({ config: resourcesConfig, tokenValidator, globalSettings, }) => {\n const isServerSideAuthEnabled = globalSettings.isServerSideAuthEnabled();\n const isSSLOrigin = globalSettings.isSSLOrigin();\n const setCookieOptions = globalSettings.getRuntimeOptions().cookies ?? {};\n const mergedSetCookieOptions = {\n // default options when not specified\n ...(isServerSideAuthEnabled && constant_1.DEFAULT_SERVER_SIDE_AUTH_SET_COOKIE_OPTIONS),\n // user-specified options\n ...setCookieOptions,\n // enforced options when server-side auth is enabled\n ...(isServerSideAuthEnabled && {\n ...constant_1.ENFORCED_SERVER_SIDE_AUTH_SET_COOKIE_OPTIONS,\n secure: isSSLOrigin,\n }),\n // only support root path\n path: '/',\n };\n const runWithAmplifyServerContext = async ({ nextServerContext, operation }) => {\n // When the Auth config is presented, attempt to create a Amplify server\n // context with token and credentials provider.\n if (resourcesConfig.Auth) {\n const keyValueStorage = \n // When `null` is passed as the value of `nextServerContext`, opt-in\n // unauthenticated role (primarily for static rendering). It's\n // safe to use the singleton `MemoryKeyValueStorage` here, as the\n // static rendering uses the same unauthenticated role cross-sever.\n nextServerContext === null\n ? utils_1.sharedInMemoryStorage\n : (0, adapter_core_1.createKeyValueStorageFromCookieStorageAdapter)(await (0, createCookieStorageAdapterFromNextServerContext_1.createCookieStorageAdapterFromNextServerContext)(nextServerContext, isServerSideAuthEnabled), tokenValidator, mergedSetCookieOptions);\n const credentialsProvider = (0, adapter_core_1.createAWSCredentialsAndIdentityIdProvider)(resourcesConfig.Auth, keyValueStorage);\n const tokenProvider = (0, adapter_core_1.createUserPoolsTokenProvider)(resourcesConfig.Auth, keyValueStorage);\n return (0, adapter_core_1.runWithAmplifyServerContext)(resourcesConfig, {\n Auth: { credentialsProvider, tokenProvider },\n }, operation);\n }\n // Otherwise it may be the case that auth is not used, e.g. API key.\n // Omitting the `Auth` in the second parameter.\n return (0, adapter_core_1.runWithAmplifyServerContext)(resourcesConfig, {}, operation);\n };\n return runWithAmplifyServerContext;\n};\nexports.createRunWithAmplifyServerContext = createRunWithAmplifyServerContext;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,iCAAiC,GAAG,MAAM;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC5C,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC;AAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC;AAC9C,MAAM,iDAAiD,GAAG,OAAO,CAAC,mDAAmD,CAAC;AACtH,MAAM,iCAAiC,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAG,KAAK;AAC5G,IAAI,MAAM,uBAAuB,GAAG,cAAc,CAAC,uBAAuB,EAAE;AAC5E,IAAI,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE;AACpD,IAAI,MAAM,gBAAgB,GAAG,cAAc,CAAC,iBAAiB,EAAE,CAAC,OAAO,IAAI,EAAE;AAC7E,IAAI,MAAM,sBAAsB,GAAG;AACnC;AACA,QAAQ,IAAI,uBAAuB,IAAI,UAAU,CAAC,2CAA2C,CAAC;AAC9F;AACA,QAAQ,GAAG,gBAAgB;AAC3B;AACA,QAAQ,IAAI,uBAAuB,IAAI;AACvC,YAAY,GAAG,UAAU,CAAC,4CAA4C;AACtE,YAAY,MAAM,EAAE,WAAW;AAC/B,SAAS,CAAC;AACV;AACA,QAAQ,IAAI,EAAE,GAAG;AACjB,KAAK;AACL,IAAI,MAAM,2BAA2B,GAAG,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK;AACpF;AACA;AACA,QAAQ,IAAI,eAAe,CAAC,IAAI,EAAE;AAClC,YAAY,MAAM,eAAe;AACjC;AACA;AACA;AACA;AACA,YAAY,iBAAiB,KAAK;AAClC,kBAAkB,OAAO,CAAC;AAC1B,kBAAkB,IAAI,cAAc,CAAC,6CAA6C,EAAE,MAAM,IAAI,iDAAiD,CAAC,+CAA+C,EAAE,iBAAiB,EAAE,uBAAuB,CAAC,EAAE,cAAc,EAAE,sBAAsB,CAAC;AACrR,YAAY,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAAC,yCAAyC,EAAE,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC;AAC5I,YAAY,MAAM,aAAa,GAAG,IAAI,cAAc,CAAC,4BAA4B,EAAE,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC;AACzH,YAAY,OAAO,IAAI,cAAc,CAAC,2BAA2B,EAAE,eAAe,EAAE;AACpF,gBAAgB,IAAI,EAAE,EAAE,mBAAmB,EAAE,aAAa,EAAE;AAC5D,aAAa,EAAE,SAAS,CAAC;AACzB,QAAQ;AACR;AACA;AACA,QAAQ,OAAO,IAAI,cAAc,CAAC,2BAA2B,EAAE,eAAe,EAAE,EAAE,EAAE,SAAS,CAAC;AAC9F,IAAI,CAAC;AACL,IAAI,OAAO,2BAA2B;AACtC,CAAC;AACD,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTokenValidator.js","sources":["../../../src/utils/createTokenValidator.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.createTokenValidator = void 0;\nconst aws_jwt_verify_1 = require(\"aws-jwt-verify\");\nconst isValidCognitoToken_1 = require(\"./isValidCognitoToken\");\n/**\n * Creates a validator object for validating methods in a KeyValueStorage.\n */\nconst createTokenValidator = ({ userPoolId, userPoolClientId: clientId, }) => {\n let idTokenVerifier;\n let accessTokenVerifier;\n return {\n // validate access, id tokens\n getItem: async (key, value) => {\n const isAccessToken = key.includes('.accessToken');\n const isIdToken = key.includes('.idToken');\n if (!isAccessToken && !isIdToken) {\n return true;\n }\n if (!userPoolId || !clientId) {\n return false;\n }\n if (isAccessToken && !accessTokenVerifier) {\n accessTokenVerifier = aws_jwt_verify_1.CognitoJwtVerifier.create({\n userPoolId,\n tokenUse: 'access',\n clientId,\n });\n }\n if (isIdToken && !idTokenVerifier) {\n idTokenVerifier = aws_jwt_verify_1.CognitoJwtVerifier.create({\n userPoolId,\n tokenUse: 'id',\n clientId,\n });\n }\n return (0, isValidCognitoToken_1.isValidCognitoToken)({\n token: value,\n verifier: isAccessToken ? accessTokenVerifier : idTokenVerifier,\n });\n },\n };\n};\nexports.createTokenValidator = createTokenValidator;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,oBAAoB,GAAG,MAAM;AACrC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;AAClD,MAAM,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC;AAC9D;AACA;AACA;AACA,MAAM,oBAAoB,GAAG,CAAC,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,GAAG,KAAK;AAC9E,IAAI,IAAI,eAAe;AACvB,IAAI,IAAI,mBAAmB;AAC3B,IAAI,OAAO;AACX;AACA,QAAQ,OAAO,EAAE,OAAO,GAAG,EAAE,KAAK,KAAK;AACvC,YAAY,MAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC;AAC9D,YAAY,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC;AACtD,YAAY,IAAI,CAAC,aAAa,IAAI,CAAC,SAAS,EAAE;AAC9C,gBAAgB,OAAO,IAAI;AAC3B;
|
|
1
|
+
{"version":3,"file":"createTokenValidator.js","sources":["../../../src/utils/createTokenValidator.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.createTokenValidator = void 0;\nconst aws_jwt_verify_1 = require(\"aws-jwt-verify\");\nconst isValidCognitoToken_1 = require(\"./isValidCognitoToken\");\n/**\n * Creates a validator object for validating methods in a KeyValueStorage.\n */\nconst createTokenValidator = ({ userPoolId, userPoolClientId: clientId, }) => {\n let idTokenVerifier;\n let accessTokenVerifier;\n return {\n // validate access, id tokens\n getItem: async (key, value) => {\n const isAccessToken = key.includes('.accessToken');\n const isIdToken = key.includes('.idToken');\n if (!isAccessToken && !isIdToken) {\n return true;\n }\n if (!userPoolId || !clientId) {\n return false;\n }\n if (isAccessToken && !accessTokenVerifier) {\n accessTokenVerifier = aws_jwt_verify_1.CognitoJwtVerifier.create({\n userPoolId,\n tokenUse: 'access',\n clientId,\n });\n }\n if (isIdToken && !idTokenVerifier) {\n idTokenVerifier = aws_jwt_verify_1.CognitoJwtVerifier.create({\n userPoolId,\n tokenUse: 'id',\n clientId,\n });\n }\n return (0, isValidCognitoToken_1.isValidCognitoToken)({\n token: value,\n verifier: isAccessToken ? accessTokenVerifier : idTokenVerifier,\n });\n },\n };\n};\nexports.createTokenValidator = createTokenValidator;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,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E,gBAAgB,KAAK,EAAE,KAAK;AAC5B,gBAAgB,QAAQ,EAAE,aAAa,GAAG,mBAAmB,GAAG,eAAe;AAC/E,aAAa,CAAC;AACd,QAAQ,CAAC;AACT,KAAK;AACL,CAAC;AACD,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalSettings.js","sources":["../../../src/utils/globalSettings.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.globalSettings = void 0;\nlet isServerSideAuthEnabled = false;\nlet runtimeOptions = {};\nlet isSSLOrigin = false;\nexports.globalSettings = {\n enableServerSideAuth() {\n isServerSideAuthEnabled = true;\n },\n isServerSideAuthEnabled() {\n return isServerSideAuthEnabled;\n },\n setRuntimeOptions(options) {\n // make a copy instead of set the reference\n runtimeOptions = structuredClone(options);\n },\n getRuntimeOptions() {\n return runtimeOptions;\n },\n setIsSSLOrigin(value) {\n isSSLOrigin = value;\n },\n isSSLOrigin() {\n return isSSLOrigin;\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,MAAM;AAC/B,IAAI,uBAAuB,GAAG,KAAK;AACnC,IAAI,cAAc,GAAG,EAAE;AACvB,IAAI,WAAW,GAAG,KAAK;AACvB,OAAO,CAAC,cAAc,GAAG;AACzB,IAAI,oBAAoB,GAAG;AAC3B,QAAQ,uBAAuB,GAAG,IAAI;AACtC,
|
|
1
|
+
{"version":3,"file":"globalSettings.js","sources":["../../../src/utils/globalSettings.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.globalSettings = void 0;\nlet isServerSideAuthEnabled = false;\nlet runtimeOptions = {};\nlet isSSLOrigin = false;\nexports.globalSettings = {\n enableServerSideAuth() {\n isServerSideAuthEnabled = true;\n },\n isServerSideAuthEnabled() {\n return isServerSideAuthEnabled;\n },\n setRuntimeOptions(options) {\n // make a copy instead of set the reference\n runtimeOptions = structuredClone(options);\n },\n getRuntimeOptions() {\n return runtimeOptions;\n },\n setIsSSLOrigin(value) {\n isSSLOrigin = value;\n },\n isSSLOrigin() {\n return isSSLOrigin;\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,MAAM;AAC/B,IAAI,uBAAuB,GAAG,KAAK;AACnC,IAAI,cAAc,GAAG,EAAE;AACvB,IAAI,WAAW,GAAG,KAAK;AACvB,OAAO,CAAC,cAAc,GAAG;AACzB,IAAI,oBAAoB,GAAG;AAC3B,QAAQ,uBAAuB,GAAG,IAAI;AACtC,IAAI,CAAC;AACL,IAAI,uBAAuB,GAAG;AAC9B,QAAQ,OAAO,uBAAuB;AACtC,IAAI,CAAC;AACL,IAAI,iBAAiB,CAAC,OAAO,EAAE;AAC/B;AACA,QAAQ,cAAc,GAAG,eAAe,CAAC,OAAO,CAAC;AACjD,IAAI,CAAC;AACL,IAAI,iBAAiB,GAAG;AACxB,QAAQ,OAAO,cAAc;AAC7B,IAAI,CAAC;AACL,IAAI,cAAc,CAAC,KAAK,EAAE;AAC1B,QAAQ,WAAW,GAAG,KAAK;AAC3B,IAAI,CAAC;AACL,IAAI,WAAW,GAAG;AAClB,QAAQ,OAAO,WAAW;AAC1B,IAAI,CAAC;AACL,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/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.globalSettings = exports.isValidCognitoToken = exports.createRunWithAmplifyServerContext = void 0;\nvar createRunWithAmplifyServerContext_1 = require(\"./createRunWithAmplifyServerContext\");\nObject.defineProperty(exports, \"createRunWithAmplifyServerContext\", { enumerable: true, get: function () { return createRunWithAmplifyServerContext_1.createRunWithAmplifyServerContext; } });\nvar isValidCognitoToken_1 = require(\"./isValidCognitoToken\");\nObject.defineProperty(exports, \"isValidCognitoToken\", { enumerable: true, get: function () { return isValidCognitoToken_1.isValidCognitoToken; } });\nvar globalSettings_1 = require(\"./globalSettings\");\nObject.defineProperty(exports, \"globalSettings\", { enumerable: true, get: function () { return globalSettings_1.globalSettings; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,iCAAiC,GAAG,MAAM;AACzG,IAAI,mCAAmC,GAAG,OAAO,CAAC,qCAAqC,CAAC;AACxF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mCAAmC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mCAAmC,CAAC,iCAAiC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/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.globalSettings = exports.isValidCognitoToken = exports.createRunWithAmplifyServerContext = void 0;\nvar createRunWithAmplifyServerContext_1 = require(\"./createRunWithAmplifyServerContext\");\nObject.defineProperty(exports, \"createRunWithAmplifyServerContext\", { enumerable: true, get: function () { return createRunWithAmplifyServerContext_1.createRunWithAmplifyServerContext; } });\nvar isValidCognitoToken_1 = require(\"./isValidCognitoToken\");\nObject.defineProperty(exports, \"isValidCognitoToken\", { enumerable: true, get: function () { return isValidCognitoToken_1.isValidCognitoToken; } });\nvar globalSettings_1 = require(\"./globalSettings\");\nObject.defineProperty(exports, \"globalSettings\", { enumerable: true, get: function () { return globalSettings_1.globalSettings; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,iCAAiC,GAAG,MAAM;AACzG,IAAI,mCAAmC,GAAG,OAAO,CAAC,qCAAqC,CAAC;AACxF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mCAAmC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mCAAmC,CAAC,iCAAiC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7L,IAAI,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC;AAC5D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,qBAAqB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,qBAAqB,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC;AACnJ,IAAI,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;AAClD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidCognitoToken.js","sources":["../../../src/utils/isValidCognitoToken.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.isValidCognitoToken = void 0;\nconst error_1 = require(\"aws-jwt-verify/error\");\n/**\n * Verifies a Cognito JWT token for its validity.\n *\n * @param input - An object containing:\n * - token: The JWT token as a string that needs to be verified.\n * - verifier: The JWT verifier which will verify the token.\n * @internal\n */\nconst isValidCognitoToken = async (input) => {\n const { token, verifier } = input;\n try {\n await verifier.verify(token);\n return true;\n }\n catch (error) {\n // When `JwtExpiredError` is thrown, the token should have valid signature\n // but expired. So, we can consider it as a valid token.\n // Reference https://github.com/awslabs/aws-jwt-verify/blob/8d8f714d7281913ecd660147f5c30311479601c1/src/jwt-rsa.ts#L290-L301\n if (error instanceof error_1.JwtExpiredError) {\n return true;\n }\n // TODO (ashwinkumar6): surface invalid cognito token error to customer\n // TODO: clear invalid tokens from Storage\n return false;\n }\n};\nexports.isValidCognitoToken = isValidCognitoToken;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,mBAAmB,GAAG,MAAM;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,mBAAmB,GAAG,OAAO,KAAK,KAAK;AAC7C,IAAI,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK;AACrC,IAAI,IAAI;AACR,QAAQ,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;AACpC,QAAQ,OAAO,IAAI;AACnB;
|
|
1
|
+
{"version":3,"file":"isValidCognitoToken.js","sources":["../../../src/utils/isValidCognitoToken.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.isValidCognitoToken = void 0;\nconst error_1 = require(\"aws-jwt-verify/error\");\n/**\n * Verifies a Cognito JWT token for its validity.\n *\n * @param input - An object containing:\n * - token: The JWT token as a string that needs to be verified.\n * - verifier: The JWT verifier which will verify the token.\n * @internal\n */\nconst isValidCognitoToken = async (input) => {\n const { token, verifier } = input;\n try {\n await verifier.verify(token);\n return true;\n }\n catch (error) {\n // When `JwtExpiredError` is thrown, the token should have valid signature\n // but expired. So, we can consider it as a valid token.\n // Reference https://github.com/awslabs/aws-jwt-verify/blob/8d8f714d7281913ecd660147f5c30311479601c1/src/jwt-rsa.ts#L290-L301\n if (error instanceof error_1.JwtExpiredError) {\n return true;\n }\n // TODO (ashwinkumar6): surface invalid cognito token error to customer\n // TODO: clear invalid tokens from Storage\n return false;\n }\n};\nexports.isValidCognitoToken = isValidCognitoToken;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,mBAAmB,GAAG,MAAM;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,mBAAmB,GAAG,OAAO,KAAK,KAAK;AAC7C,IAAI,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK;AACrC,IAAI,IAAI;AACR,QAAQ,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;AACpC,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ,IAAI,OAAO,KAAK,EAAE;AAClB;AACA;AACA;AACA,QAAQ,IAAI,KAAK,YAAY,OAAO,CAAC,eAAe,EAAE;AACtD,YAAY,OAAO,IAAI;AACvB,QAAQ;AACR;AACA;AACA,QAAQ,OAAO,KAAK;AACpB,IAAI;AACJ,CAAC;AACD,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateServerClient.mjs","sources":["../../../src/api/generateServerClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { generateClientWithAmplifyInstance, } from 'aws-amplify/api/internals';\nimport { generateClient } from 'aws-amplify/api/server';\nimport { AmplifyServerContextError, getAmplifyServerContext, } from 'aws-amplify/adapter-core/internals';\nimport { parseAmplifyConfig } from 'aws-amplify/utils';\nimport { createServerRunnerForAPI } from './createServerRunnerForAPI';\n/**\n * Generates an API client that can be used inside a Next.js Server Component with Dynamic Rendering\n *\n * @example\n * import { cookies } from \"next/headers\"\n *\n * const client = generateServerClientUsingCookies({ cookies });\n * const result = await client.graphql({ query: listPosts });\n */\nexport function generateServerClientUsingCookies(options) {\n if (typeof options.cookies !== 'function') {\n throw new AmplifyServerContextError({\n message: 'generateServerClientUsingCookies is only compatible with the `cookies` Dynamic Function available in Server Components.',\n // TODO: link to docs\n recoverySuggestion: 'use `generateServerClient` inside of `runWithAmplifyServerContext` with the `request` object.',\n });\n }\n const { runWithAmplifyServerContext, resourcesConfig } = createServerRunnerForAPI({ config: options.config });\n // This function reference gets passed down to InternalGraphQLAPI.ts.graphql\n // where this._graphql is passed in as the `fn` argument\n // causing it to always get invoked inside `runWithAmplifyServerContext`\n const getAmplify = (fn) => runWithAmplifyServerContext({\n nextServerContext: { cookies: options.cookies },\n operation: contextSpec => fn(getAmplifyServerContext(contextSpec).amplify),\n });\n const { cookies: _cookies, config: _config, ...params } = options;\n return generateClientWithAmplifyInstance({\n amplify: getAmplify,\n config: resourcesConfig,\n ...params,\n }); // TS can't narrow the type here.\n}\n/**\n * Generates an API client that can be used with both Pages Router and App Router\n *\n * @example\n * import config from './amplifyconfiguration.json';\n * import { listPosts } from './graphql/queries';\n *\n * const client = generateServerClientUsingReqRes({ config });\n *\n * const result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nexport function generateServerClientUsingReqRes(options) {\n const amplifyConfig = parseAmplifyConfig(options.config);\n const { config: _config, ...params } = options;\n return generateClient({\n config: amplifyConfig,\n ...params,\n });\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,OAAO,EAAE;AAC1D,IAAI,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE;AAC/C,QAAQ,MAAM,IAAI,yBAAyB,CAAC;AAC5C,YAAY,OAAO,EAAE,yHAAyH;AAC9I;AACA,YAAY,kBAAkB,EAAE,+FAA+F;AAC/H,SAAS,CAAC;AACV;
|
|
1
|
+
{"version":3,"file":"generateServerClient.mjs","sources":["../../../src/api/generateServerClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { generateClientWithAmplifyInstance, } from 'aws-amplify/api/internals';\nimport { generateClient } from 'aws-amplify/api/server';\nimport { AmplifyServerContextError, getAmplifyServerContext, } from 'aws-amplify/adapter-core/internals';\nimport { parseAmplifyConfig } from 'aws-amplify/utils';\nimport { createServerRunnerForAPI } from './createServerRunnerForAPI';\n/**\n * Generates an API client that can be used inside a Next.js Server Component with Dynamic Rendering\n *\n * @example\n * import { cookies } from \"next/headers\"\n *\n * const client = generateServerClientUsingCookies({ cookies });\n * const result = await client.graphql({ query: listPosts });\n */\nexport function generateServerClientUsingCookies(options) {\n if (typeof options.cookies !== 'function') {\n throw new AmplifyServerContextError({\n message: 'generateServerClientUsingCookies is only compatible with the `cookies` Dynamic Function available in Server Components.',\n // TODO: link to docs\n recoverySuggestion: 'use `generateServerClient` inside of `runWithAmplifyServerContext` with the `request` object.',\n });\n }\n const { runWithAmplifyServerContext, resourcesConfig } = createServerRunnerForAPI({ config: options.config });\n // This function reference gets passed down to InternalGraphQLAPI.ts.graphql\n // where this._graphql is passed in as the `fn` argument\n // causing it to always get invoked inside `runWithAmplifyServerContext`\n const getAmplify = (fn) => runWithAmplifyServerContext({\n nextServerContext: { cookies: options.cookies },\n operation: contextSpec => fn(getAmplifyServerContext(contextSpec).amplify),\n });\n const { cookies: _cookies, config: _config, ...params } = options;\n return generateClientWithAmplifyInstance({\n amplify: getAmplify,\n config: resourcesConfig,\n ...params,\n }); // TS can't narrow the type here.\n}\n/**\n * Generates an API client that can be used with both Pages Router and App Router\n *\n * @example\n * import config from './amplifyconfiguration.json';\n * import { listPosts } from './graphql/queries';\n *\n * const client = generateServerClientUsingReqRes({ config });\n *\n * const result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nexport function generateServerClientUsingReqRes(options) {\n const amplifyConfig = parseAmplifyConfig(options.config);\n const { config: _config, ...params } = options;\n return generateClient({\n config: amplifyConfig,\n ...params,\n });\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,OAAO,EAAE;AAC1D,IAAI,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE;AAC/C,QAAQ,MAAM,IAAI,yBAAyB,CAAC;AAC5C,YAAY,OAAO,EAAE,yHAAyH;AAC9I;AACA,YAAY,kBAAkB,EAAE,+FAA+F;AAC/H,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,MAAM,EAAE,2BAA2B,EAAE,eAAe,EAAE,GAAG,wBAAwB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AACjH;AACA;AACA;AACA,IAAI,MAAM,UAAU,GAAG,CAAC,EAAE,KAAK,2BAA2B,CAAC;AAC3D,QAAQ,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;AACvD,QAAQ,SAAS,EAAE,WAAW,IAAI,EAAE,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;AAClF,KAAK,CAAC;AACN,IAAI,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO;AACrE,IAAI,OAAO,iCAAiC,CAAC;AAC7C,QAAQ,OAAO,EAAE,UAAU;AAC3B,QAAQ,MAAM,EAAE,eAAe;AAC/B,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC,CAAC;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,+BAA+B,CAAC,OAAO,EAAE;AACzD,IAAI,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC;AAC5D,IAAI,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO;AAClD,IAAI,OAAO,cAAc,CAAC;AAC1B,QAAQ,MAAM,EAAE,aAAa;AAC7B,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC;AACN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthRouteHandlersFactory.mjs","sources":["../../../src/auth/createAuthRouteHandlersFactory.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyServerContextError, assertOAuthConfig, assertTokenProviderConfig, } from 'aws-amplify/adapter-core/internals';\nimport { isAuthRoutesHandlersContext, isNextApiRequest, isNextApiResponse, isNextRequest, isValidOrigin, } from './utils';\nimport { handleAuthApiRouteRequestForAppRouter } from './handleAuthApiRouteRequestForAppRouter';\nimport { handleAuthApiRouteRequestForPagesRouter } from './handleAuthApiRouteRequestForPagesRouter';\nexport const createAuthRouteHandlersFactory = ({ config: resourcesConfig, amplifyAppOrigin, runWithAmplifyServerContext, globalSettings, }) => {\n const handleRequest = async ({ request, contextOrResponse, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n if (isNextApiRequest(request) && isNextApiResponse(contextOrResponse)) {\n // In pages router the response is sent via calling `response.end()` or\n // `response.send()`. The response is not returned from the handler.\n // To ensure these two methods are called before the handler returns,\n // we use `await` here.\n await handleAuthApiRouteRequestForPagesRouter({\n request,\n response: contextOrResponse,\n handlerInput,\n userPoolClientId,\n oAuthConfig,\n setCookieOptions,\n origin,\n runWithAmplifyServerContext,\n });\n // In the Pages Router, the final response is handled by contextOrResponse\n return;\n }\n if (isNextRequest(request) &&\n isAuthRoutesHandlersContext(contextOrResponse)) {\n // In the App Router, the final response is constructed and returned\n return handleAuthApiRouteRequestForAppRouter({\n request,\n handlerContext: contextOrResponse,\n handlerInput,\n userPoolClientId,\n oAuthConfig,\n setCookieOptions,\n origin,\n runWithAmplifyServerContext,\n });\n }\n // this should not be happening\n throw new Error('Invalid request and context/response combination. The request cannot be handled.');\n };\n return (createAuthRoutesHandlersInput = {}) => {\n // origin validation should happen when createAuthRouteHandlers is being called to create\n // Auth API routes.\n if (!amplifyAppOrigin) {\n throw new AmplifyServerContextError({\n message: 'Could not find the AMPLIFY_APP_ORIGIN environment variable.',\n recoverySuggestion: 'Add the AMPLIFY_APP_ORIGIN environment variable to the `.env` file of your Next.js project.',\n });\n }\n if (!isValidOrigin(amplifyAppOrigin)) {\n throw new AmplifyServerContextError({\n message: 'AMPLIFY_APP_ORIGIN environment variable contains an invalid origin string.',\n recoverySuggestion: 'Ensure the AMPLIFY_APP_ORIGIN environment variable is a valid origin string.',\n });\n }\n // OAuth config validation should happen when createAuthRouteHandlers is being called to create\n // Auth API routes.\n assertTokenProviderConfig(resourcesConfig.Auth?.Cognito);\n assertOAuthConfig(resourcesConfig.Auth.Cognito);\n const { userPoolClientId } = resourcesConfig.Auth.Cognito;\n const { oauth: oAuthConfig } = resourcesConfig.Auth.Cognito.loginWith;\n const setCookieOptions = globalSettings.getRuntimeOptions().cookies ?? {};\n // The call-site of this returned function is the Next.js API route file\n return (request, contextOrResponse) => handleRequest({\n request,\n contextOrResponse,\n handlerInput: createAuthRoutesHandlersInput,\n userPoolClientId,\n oAuthConfig,\n setCookieOptions,\n origin: amplifyAppOrigin,\n });\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAKY,MAAC,8BAA8B,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,cAAc,GAAG,KAAK;AAC/I,IAAI,MAAM,aAAa,GAAG,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AAC5I,QAAQ,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,EAAE;AAC/E;AACA;AACA;AACA;AACA,YAAY,MAAM,uCAAuC,CAAC;AAC1D,gBAAgB,OAAO;AACvB,gBAAgB,QAAQ,EAAE,iBAAiB;AAC3C,gBAAgB,YAAY;AAC5B,gBAAgB,gBAAgB;AAChC,gBAAgB,WAAW;AAC3B,gBAAgB,gBAAgB;AAChC,gBAAgB,MAAM;AACtB,gBAAgB,2BAA2B;AAC3C,aAAa,CAAC;AACd;AACA,YAAY;AACZ;
|
|
1
|
+
{"version":3,"file":"createAuthRouteHandlersFactory.mjs","sources":["../../../src/auth/createAuthRouteHandlersFactory.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyServerContextError, assertOAuthConfig, assertTokenProviderConfig, } from 'aws-amplify/adapter-core/internals';\nimport { isAuthRoutesHandlersContext, isNextApiRequest, isNextApiResponse, isNextRequest, isValidOrigin, } from './utils';\nimport { handleAuthApiRouteRequestForAppRouter } from './handleAuthApiRouteRequestForAppRouter';\nimport { handleAuthApiRouteRequestForPagesRouter } from './handleAuthApiRouteRequestForPagesRouter';\nexport const createAuthRouteHandlersFactory = ({ config: resourcesConfig, amplifyAppOrigin, runWithAmplifyServerContext, globalSettings, }) => {\n const handleRequest = async ({ request, contextOrResponse, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n if (isNextApiRequest(request) && isNextApiResponse(contextOrResponse)) {\n // In pages router the response is sent via calling `response.end()` or\n // `response.send()`. The response is not returned from the handler.\n // To ensure these two methods are called before the handler returns,\n // we use `await` here.\n await handleAuthApiRouteRequestForPagesRouter({\n request,\n response: contextOrResponse,\n handlerInput,\n userPoolClientId,\n oAuthConfig,\n setCookieOptions,\n origin,\n runWithAmplifyServerContext,\n });\n // In the Pages Router, the final response is handled by contextOrResponse\n return;\n }\n if (isNextRequest(request) &&\n isAuthRoutesHandlersContext(contextOrResponse)) {\n // In the App Router, the final response is constructed and returned\n return handleAuthApiRouteRequestForAppRouter({\n request,\n handlerContext: contextOrResponse,\n handlerInput,\n userPoolClientId,\n oAuthConfig,\n setCookieOptions,\n origin,\n runWithAmplifyServerContext,\n });\n }\n // this should not be happening\n throw new Error('Invalid request and context/response combination. The request cannot be handled.');\n };\n return (createAuthRoutesHandlersInput = {}) => {\n // origin validation should happen when createAuthRouteHandlers is being called to create\n // Auth API routes.\n if (!amplifyAppOrigin) {\n throw new AmplifyServerContextError({\n message: 'Could not find the AMPLIFY_APP_ORIGIN environment variable.',\n recoverySuggestion: 'Add the AMPLIFY_APP_ORIGIN environment variable to the `.env` file of your Next.js project.',\n });\n }\n if (!isValidOrigin(amplifyAppOrigin)) {\n throw new AmplifyServerContextError({\n message: 'AMPLIFY_APP_ORIGIN environment variable contains an invalid origin string.',\n recoverySuggestion: 'Ensure the AMPLIFY_APP_ORIGIN environment variable is a valid origin string.',\n });\n }\n // OAuth config validation should happen when createAuthRouteHandlers is being called to create\n // Auth API routes.\n assertTokenProviderConfig(resourcesConfig.Auth?.Cognito);\n assertOAuthConfig(resourcesConfig.Auth.Cognito);\n const { userPoolClientId } = resourcesConfig.Auth.Cognito;\n const { oauth: oAuthConfig } = resourcesConfig.Auth.Cognito.loginWith;\n const setCookieOptions = globalSettings.getRuntimeOptions().cookies ?? {};\n // The call-site of this returned function is the Next.js API route file\n return (request, contextOrResponse) => handleRequest({\n request,\n contextOrResponse,\n handlerInput: createAuthRoutesHandlersInput,\n userPoolClientId,\n oAuthConfig,\n setCookieOptions,\n origin: amplifyAppOrigin,\n });\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAKY,MAAC,8BAA8B,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,cAAc,GAAG,KAAK;AAC/I,IAAI,MAAM,aAAa,GAAG,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AAC5I,QAAQ,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,EAAE;AAC/E;AACA;AACA;AACA;AACA,YAAY,MAAM,uCAAuC,CAAC;AAC1D,gBAAgB,OAAO;AACvB,gBAAgB,QAAQ,EAAE,iBAAiB;AAC3C,gBAAgB,YAAY;AAC5B,gBAAgB,gBAAgB;AAChC,gBAAgB,WAAW;AAC3B,gBAAgB,gBAAgB;AAChC,gBAAgB,MAAM;AACtB,gBAAgB,2BAA2B;AAC3C,aAAa,CAAC;AACd;AACA,YAAY;AACZ,QAAQ;AACR,QAAQ,IAAI,aAAa,CAAC,OAAO,CAAC;AAClC,YAAY,2BAA2B,CAAC,iBAAiB,CAAC,EAAE;AAC5D;AACA,YAAY,OAAO,qCAAqC,CAAC;AACzD,gBAAgB,OAAO;AACvB,gBAAgB,cA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AACvD,YAAY,gBAAgB;AAC5B,YAAY,WAAW;AACvB,YAAY,gBAAgB;AAC5B,YAAY,MAAM,EAAE,gBAAgB;AACpC,SAAS,CAAC;AACV,IAAI,CAAC;AACL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleAuthApiRouteRequestForAppRouter.mjs","sources":["../../../src/auth/handleAuthApiRouteRequestForAppRouter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getRedirectOrDefault, hasActiveUserSessionWithAppRouter, isSupportedAuthApiRoutePath, } from './utils';\nimport { handleSignInCallbackRequest, handleSignInSignUpRequest, handleSignOutCallbackRequest, handleSignOutRequest, } from './handlers';\nexport const handleAuthApiRouteRequestForAppRouter = async ({ request, handlerContext, handlerInput, userPoolClientId, oAuthConfig, origin, setCookieOptions, runWithAmplifyServerContext, }) => {\n if (request.method !== 'GET') {\n return new Response(null, { status: 405 });\n }\n const { slug } = await handlerContext.params;\n // don't support [...slug] here\n if (slug === undefined || Array.isArray(slug)) {\n return new Response(null, { status: 400 });\n }\n if (!isSupportedAuthApiRoutePath(slug)) {\n return new Response(null, { status: 404 });\n }\n switch (slug) {\n case 'sign-up': {\n const hasActiveUserSession = await hasActiveUserSessionWithAppRouter({\n request,\n runWithAmplifyServerContext,\n });\n if (hasActiveUserSession) {\n return new Response(null, {\n status: 302,\n headers: new Headers({\n Location: getRedirectOrDefault(handlerInput.redirectOnSignInComplete),\n }),\n });\n }\n return handleSignInSignUpRequest({\n customState: handlerInput.customState,\n oAuthConfig,\n origin,\n request,\n setCookieOptions,\n type: 'signUp',\n userPoolClientId,\n });\n }\n case 'sign-in': {\n const hasActiveUserSession = await hasActiveUserSessionWithAppRouter({\n request,\n runWithAmplifyServerContext,\n });\n if (hasActiveUserSession) {\n return new Response(null, {\n status: 302,\n headers: new Headers({\n Location: getRedirectOrDefault(handlerInput.redirectOnSignInComplete),\n }),\n });\n }\n return handleSignInSignUpRequest({\n customState: handlerInput.customState,\n oAuthConfig,\n origin,\n request,\n setCookieOptions,\n type: 'signIn',\n userPoolClientId,\n });\n }\n case 'sign-out':\n return handleSignOutRequest({\n oAuthConfig,\n origin,\n setCookieOptions,\n userPoolClientId,\n });\n case 'sign-in-callback':\n return handleSignInCallbackRequest({\n handlerInput,\n oAuthConfig,\n origin,\n request,\n setCookieOptions,\n userPoolClientId,\n });\n case 'sign-out-callback':\n return handleSignOutCallbackRequest({\n handlerInput,\n oAuthConfig,\n origin,\n request,\n setCookieOptions,\n userPoolClientId,\n });\n // default:\n // is unreachable by the guard of isSupportedAuthApiRoutePath()\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;AAGY,MAAC,qCAAqC,GAAG,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,2BAA2B,GAAG,KAAK;AACjM,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE;AAClC,QAAQ,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AAClD;
|
|
1
|
+
{"version":3,"file":"handleAuthApiRouteRequestForAppRouter.mjs","sources":["../../../src/auth/handleAuthApiRouteRequestForAppRouter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getRedirectOrDefault, hasActiveUserSessionWithAppRouter, isSupportedAuthApiRoutePath, } from './utils';\nimport { handleSignInCallbackRequest, handleSignInSignUpRequest, handleSignOutCallbackRequest, handleSignOutRequest, } from './handlers';\nexport const handleAuthApiRouteRequestForAppRouter = async ({ request, handlerContext, handlerInput, userPoolClientId, oAuthConfig, origin, setCookieOptions, runWithAmplifyServerContext, }) => {\n if (request.method !== 'GET') {\n return new Response(null, { status: 405 });\n }\n const { slug } = await handlerContext.params;\n // don't support [...slug] here\n if (slug === undefined || Array.isArray(slug)) {\n return new Response(null, { status: 400 });\n }\n if (!isSupportedAuthApiRoutePath(slug)) {\n return new Response(null, { status: 404 });\n }\n switch (slug) {\n case 'sign-up': {\n const hasActiveUserSession = await hasActiveUserSessionWithAppRouter({\n request,\n runWithAmplifyServerContext,\n });\n if (hasActiveUserSession) {\n return new Response(null, {\n status: 302,\n headers: new Headers({\n Location: getRedirectOrDefault(handlerInput.redirectOnSignInComplete),\n }),\n });\n }\n return handleSignInSignUpRequest({\n customState: handlerInput.customState,\n oAuthConfig,\n origin,\n request,\n setCookieOptions,\n type: 'signUp',\n userPoolClientId,\n });\n }\n case 'sign-in': {\n const hasActiveUserSession = await hasActiveUserSessionWithAppRouter({\n request,\n runWithAmplifyServerContext,\n });\n if (hasActiveUserSession) {\n return new Response(null, {\n status: 302,\n headers: new Headers({\n Location: getRedirectOrDefault(handlerInput.redirectOnSignInComplete),\n }),\n });\n }\n return handleSignInSignUpRequest({\n customState: handlerInput.customState,\n oAuthConfig,\n origin,\n request,\n setCookieOptions,\n type: 'signIn',\n userPoolClientId,\n });\n }\n case 'sign-out':\n return handleSignOutRequest({\n oAuthConfig,\n origin,\n setCookieOptions,\n userPoolClientId,\n });\n case 'sign-in-callback':\n return handleSignInCallbackRequest({\n handlerInput,\n oAuthConfig,\n origin,\n request,\n setCookieOptions,\n userPoolClientId,\n });\n case 'sign-out-callback':\n return handleSignOutCallbackRequest({\n handlerInput,\n oAuthConfig,\n origin,\n request,\n setCookieOptions,\n userPoolClientId,\n });\n // default:\n // is unreachable by the guard of isSupportedAuthApiRoutePath()\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;AAGY,MAAC,qCAAqC,GAAG,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,2BAA2B,GAAG,KAAK;AACjM,IAAI,IAAI,OAAO,CAAC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AChC,gBAAgB,gBAAgB;AAChC,aAAa,CAAC;AACd;AACA;AACA;AACA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleAuthApiRouteRequestForPagesRouter.mjs","sources":["../../../src/auth/handleAuthApiRouteRequestForPagesRouter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getRedirectOrDefault, hasActiveUserSessionWithPagesRouter, isSupportedAuthApiRoutePath, } from './utils';\nimport { handleSignInCallbackRequestForPagesRouter, handleSignInSignUpRequestForPagesRouter, handleSignOutCallbackRequestForPagesRouter, handleSignOutRequestForPagesRouter, } from './handlers';\nexport const handleAuthApiRouteRequestForPagesRouter = async ({ request, response, userPoolClientId, oAuthConfig, handlerInput, origin, setCookieOptions, runWithAmplifyServerContext, }) => {\n if (request.method !== 'GET') {\n response.status(405).end();\n return;\n }\n const { slug } = request.query;\n // don't support [...slug] here\n if (slug === undefined || Array.isArray(slug)) {\n response.status(400).end();\n return;\n }\n if (!isSupportedAuthApiRoutePath(slug)) {\n response.status(404).end();\n return;\n }\n switch (slug) {\n case 'sign-up': {\n const hasActiveUserSession = await hasActiveUserSessionWithPagesRouter({\n request,\n response,\n runWithAmplifyServerContext,\n });\n if (hasActiveUserSession) {\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignInComplete));\n return;\n }\n handleSignInSignUpRequestForPagesRouter({\n customState: handlerInput.customState,\n oAuthConfig,\n origin,\n request,\n response,\n setCookieOptions,\n type: 'signUp',\n userPoolClientId,\n });\n break;\n }\n case 'sign-in': {\n const hasActiveUserSession = await hasActiveUserSessionWithPagesRouter({\n request,\n response,\n runWithAmplifyServerContext,\n });\n if (hasActiveUserSession) {\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignInComplete));\n return;\n }\n handleSignInSignUpRequestForPagesRouter({\n customState: handlerInput.customState,\n oAuthConfig,\n origin,\n request,\n response,\n setCookieOptions,\n type: 'signIn',\n userPoolClientId,\n });\n break;\n }\n case 'sign-out':\n handleSignOutRequestForPagesRouter({\n oAuthConfig,\n origin,\n response,\n setCookieOptions,\n userPoolClientId,\n });\n break;\n case 'sign-in-callback':\n // In pages router the response is sent via calling `response.end()` or\n // `response.send()`. The response is not returned from the handler.\n // To ensure these two methods are called before the handler returns,\n // we use `await` here.\n await handleSignInCallbackRequestForPagesRouter({\n handlerInput,\n oAuthConfig,\n origin,\n request,\n response,\n setCookieOptions,\n userPoolClientId,\n });\n break;\n case 'sign-out-callback':\n // In pages router the response is sent via calling `response.end()` or\n // `response.send()`. The response is not returned from the handler.\n // To ensure these two methods are called before the handler returns,\n // we use `await` here.\n await handleSignOutCallbackRequestForPagesRouter({\n handlerInput,\n oAuthConfig,\n origin,\n request,\n response,\n setCookieOptions,\n userPoolClientId,\n });\n break;\n // default:\n // is unreachable by the guard of isSupportedAuthApiRoutePath()\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;AAGY,MAAC,uCAAuC,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,2BAA2B,GAAG,KAAK;AAC7L,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE;AAClC,QAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;AAClC,QAAQ;AACR;
|
|
1
|
+
{"version":3,"file":"handleAuthApiRouteRequestForPagesRouter.mjs","sources":["../../../src/auth/handleAuthApiRouteRequestForPagesRouter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getRedirectOrDefault, hasActiveUserSessionWithPagesRouter, isSupportedAuthApiRoutePath, } from './utils';\nimport { handleSignInCallbackRequestForPagesRouter, handleSignInSignUpRequestForPagesRouter, handleSignOutCallbackRequestForPagesRouter, handleSignOutRequestForPagesRouter, } from './handlers';\nexport const handleAuthApiRouteRequestForPagesRouter = async ({ request, response, userPoolClientId, oAuthConfig, handlerInput, origin, setCookieOptions, runWithAmplifyServerContext, }) => {\n if (request.method !== 'GET') {\n response.status(405).end();\n return;\n }\n const { slug } = request.query;\n // don't support [...slug] here\n if (slug === undefined || Array.isArray(slug)) {\n response.status(400).end();\n return;\n }\n if (!isSupportedAuthApiRoutePath(slug)) {\n response.status(404).end();\n return;\n }\n switch (slug) {\n case 'sign-up': {\n const hasActiveUserSession = await hasActiveUserSessionWithPagesRouter({\n request,\n response,\n runWithAmplifyServerContext,\n });\n if (hasActiveUserSession) {\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignInComplete));\n return;\n }\n handleSignInSignUpRequestForPagesRouter({\n customState: handlerInput.customState,\n oAuthConfig,\n origin,\n request,\n response,\n setCookieOptions,\n type: 'signUp',\n userPoolClientId,\n });\n break;\n }\n case 'sign-in': {\n const hasActiveUserSession = await hasActiveUserSessionWithPagesRouter({\n request,\n response,\n runWithAmplifyServerContext,\n });\n if (hasActiveUserSession) {\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignInComplete));\n return;\n }\n handleSignInSignUpRequestForPagesRouter({\n customState: handlerInput.customState,\n oAuthConfig,\n origin,\n request,\n response,\n setCookieOptions,\n type: 'signIn',\n userPoolClientId,\n });\n break;\n }\n case 'sign-out':\n handleSignOutRequestForPagesRouter({\n oAuthConfig,\n origin,\n response,\n setCookieOptions,\n userPoolClientId,\n });\n break;\n case 'sign-in-callback':\n // In pages router the response is sent via calling `response.end()` or\n // `response.send()`. The response is not returned from the handler.\n // To ensure these two methods are called before the handler returns,\n // we use `await` here.\n await handleSignInCallbackRequestForPagesRouter({\n handlerInput,\n oAuthConfig,\n origin,\n request,\n response,\n setCookieOptions,\n userPoolClientId,\n });\n break;\n case 'sign-out-callback':\n // In pages router the response is sent via calling `response.end()` or\n // `response.send()`. The response is not returned from the handler.\n // To ensure these two methods are called before the handler returns,\n // we use `await` here.\n await handleSignOutCallbackRequestForPagesRouter({\n handlerInput,\n oAuthConfig,\n origin,\n request,\n response,\n setCookieOptions,\n userPoolClientId,\n });\n break;\n // default:\n // is unreachable by the guard of isSupportedAuthApiRoutePath()\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;AAGY,MAAC,uCAAuC,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,2BAA2B,GAAG,KAAK;AAC7L,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE;AAClC,QAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;AAClC,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK;AAClC;AACA,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACnD,QAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;AAClC,QAAQ;AACR,IAAI;AACJ,IAAI,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,EAAE;AAC5C,QAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;AAClC,QAAQ;AACR,IAAI;AACJ,IAAI,QAAQ,IAAI;AAChB,QAAQ,KAAK,SAAS,EAAE;AACxB,YAAY,MAAM,oBAAoB,GAAG,MAAM,mCAAmC,CAAC;AACnF,gBAAgB,OAAO;AACvB,gBAAgB,QAAQ;AACxB,gBAAgB,2BAA2B;AAC3C,aAAa,CAAC;AACd,YAAY,IAAI,oBAAoB,EAAE;AACtC,gBAAgB,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC;AACn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,MAAM;AACtB,gBAAgB,OAAO;AACvB,gBAAgB,QAAQ;AACxB,gBAAgB,gBAAgB;AAChC,gBAAgB,gBAAgB;AAChC,aAAa,CAAC;AACd,YAAY;AACZ,QAAQ,KAAK,mBAAmB;AAChC;AACA;AACA;AACA;AACA,YAAY,MAAM,0CAA0C,CAAC;AAC7D,gBAAgB,YAAY;AAC5B,gBAAgB,WAAW;AAC3B,gBAAgB,MAAM;AACtB,gBAAgB,OAAO;AACvB,gBAAgB,QAAQ;AACxB,gBAAgB,gBAAgB;AAChC,gBAAgB,gBAAgB;AAChC,aAAa,CAAC;AACd,YAAY;AACZ;AACA;AACA;AACA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleSignInCallbackRequest.mjs","sources":["../../../../src/auth/handlers/handleSignInCallbackRequest.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PKCE_COOKIE_NAME, SIGN_IN_TIMEOUT_ERROR_CODE, SIGN_IN_TIMEOUT_ERROR_MESSAGE, STATE_COOKIE_NAME, } from '../constant';\nimport { appendSetCookieHeaders, createAuthFlowProofCookiesRemoveOptions, createErrorSearchParamsString, createRedirectionIntermediary, createSignInFlowProofCookies, createTokenCookies, createTokenCookiesSetOptions, exchangeAuthNTokens, getCookieValuesFromRequest, getRedirectOrDefault, parseSignInCallbackUrl, resolveRedirectSignInUrl, } from '../utils';\nexport const handleSignInCallbackRequest = async ({ request, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n const { code, state, error, errorDescription } = parseSignInCallbackUrl(request.url);\n if (errorDescription || error) {\n const searchParamsString = createErrorSearchParamsString({\n error,\n errorDescription,\n });\n return new Response(null, {\n status: 302,\n headers: new Headers({\n location: `${getRedirectOrDefault(handlerInput.redirectOnSignOutComplete)}?${searchParamsString}`,\n }),\n });\n }\n if (!code || !state) {\n return new Response(null, { status: 400 });\n }\n const { [PKCE_COOKIE_NAME]: clientPkce, [STATE_COOKIE_NAME]: clientState } = getCookieValuesFromRequest(request, [PKCE_COOKIE_NAME, STATE_COOKIE_NAME]);\n // The state and pkce cookies are removed from cookie store after 5 minutes\n if (!clientState || !clientPkce) {\n const searchParamsString = createErrorSearchParamsString({\n error: SIGN_IN_TIMEOUT_ERROR_CODE,\n errorDescription: SIGN_IN_TIMEOUT_ERROR_MESSAGE,\n });\n return new Response(null, {\n status: 302,\n headers: new Headers({\n location: `${getRedirectOrDefault(handlerInput.redirectOnSignOutComplete)}?${searchParamsString}`,\n }),\n });\n }\n // Most likely the cookie has been tampered\n if (clientState !== state) {\n return new Response(null, { status: 400 });\n }\n const tokensPayload = await exchangeAuthNTokens({\n redirectUri: resolveRedirectSignInUrl(origin, oAuthConfig),\n userPoolClientId,\n oAuthConfig,\n code,\n codeVerifier: clientPkce,\n });\n if ('error' in tokensPayload) {\n return new Response(tokensPayload.error, { status: 500 });\n }\n const headers = new Headers();\n appendSetCookieHeaders(headers, createTokenCookies({\n tokensPayload,\n userPoolClientId,\n }), createTokenCookiesSetOptions(setCookieOptions, origin));\n appendSetCookieHeaders(headers, createSignInFlowProofCookies({ state: '', pkce: '' }), createAuthFlowProofCookiesRemoveOptions(setCookieOptions));\n // When Cognito redirects back to `/sign-in-callback`, the referer is Cognito\n // endpoint. If redirect end user to `redirectOnSignInComplete` from this point,\n // the referer remains the same.\n // When authN token cookies set as `sameSite: 'strict'`, this may cause the\n // authN tokens cookies set with the redirect response not to be sent to the\n // server. Hence, sending a html page with status 200 to the client, and perform\n // the redirection on the client side.\n headers.set('Content-Type', 'text/html');\n return new Response(createRedirectionIntermediary({\n redirectTo: getRedirectOrDefault(handlerInput.redirectOnSignInComplete),\n }), {\n status: 200,\n headers,\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAGY,MAAC,2BAA2B,GAAG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AAC1I,IAAI,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC;AACxF,IAAI,IAAI,gBAAgB,IAAI,KAAK,EAAE;AACnC,QAAQ,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACjE,YAAY,KAAK;AACjB,YAAY,gBAAgB;AAC5B,SAAS,CAAC;AACV,QAAQ,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;AAClC,YAAY,MAAM,EAAE,GAAG;AACvB,YAAY,OAAO,EAAE,IAAI,OAAO,CAAC;AACjC,gBAAgB,QAAQ,EAAE,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;AACjH,aAAa,CAAC;AACd,SAAS,CAAC;AACV;
|
|
1
|
+
{"version":3,"file":"handleSignInCallbackRequest.mjs","sources":["../../../../src/auth/handlers/handleSignInCallbackRequest.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PKCE_COOKIE_NAME, SIGN_IN_TIMEOUT_ERROR_CODE, SIGN_IN_TIMEOUT_ERROR_MESSAGE, STATE_COOKIE_NAME, } from '../constant';\nimport { appendSetCookieHeaders, createAuthFlowProofCookiesRemoveOptions, createErrorSearchParamsString, createRedirectionIntermediary, createSignInFlowProofCookies, createTokenCookies, createTokenCookiesSetOptions, exchangeAuthNTokens, getCookieValuesFromRequest, getRedirectOrDefault, parseSignInCallbackUrl, resolveRedirectSignInUrl, } from '../utils';\nexport const handleSignInCallbackRequest = async ({ request, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n const { code, state, error, errorDescription } = parseSignInCallbackUrl(request.url);\n if (errorDescription || error) {\n const searchParamsString = createErrorSearchParamsString({\n error,\n errorDescription,\n });\n return new Response(null, {\n status: 302,\n headers: new Headers({\n location: `${getRedirectOrDefault(handlerInput.redirectOnSignOutComplete)}?${searchParamsString}`,\n }),\n });\n }\n if (!code || !state) {\n return new Response(null, { status: 400 });\n }\n const { [PKCE_COOKIE_NAME]: clientPkce, [STATE_COOKIE_NAME]: clientState } = getCookieValuesFromRequest(request, [PKCE_COOKIE_NAME, STATE_COOKIE_NAME]);\n // The state and pkce cookies are removed from cookie store after 5 minutes\n if (!clientState || !clientPkce) {\n const searchParamsString = createErrorSearchParamsString({\n error: SIGN_IN_TIMEOUT_ERROR_CODE,\n errorDescription: SIGN_IN_TIMEOUT_ERROR_MESSAGE,\n });\n return new Response(null, {\n status: 302,\n headers: new Headers({\n location: `${getRedirectOrDefault(handlerInput.redirectOnSignOutComplete)}?${searchParamsString}`,\n }),\n });\n }\n // Most likely the cookie has been tampered\n if (clientState !== state) {\n return new Response(null, { status: 400 });\n }\n const tokensPayload = await exchangeAuthNTokens({\n redirectUri: resolveRedirectSignInUrl(origin, oAuthConfig),\n userPoolClientId,\n oAuthConfig,\n code,\n codeVerifier: clientPkce,\n });\n if ('error' in tokensPayload) {\n return new Response(tokensPayload.error, { status: 500 });\n }\n const headers = new Headers();\n appendSetCookieHeaders(headers, createTokenCookies({\n tokensPayload,\n userPoolClientId,\n }), createTokenCookiesSetOptions(setCookieOptions, origin));\n appendSetCookieHeaders(headers, createSignInFlowProofCookies({ state: '', pkce: '' }), createAuthFlowProofCookiesRemoveOptions(setCookieOptions));\n // When Cognito redirects back to `/sign-in-callback`, the referer is Cognito\n // endpoint. If redirect end user to `redirectOnSignInComplete` from this point,\n // the referer remains the same.\n // When authN token cookies set as `sameSite: 'strict'`, this may cause the\n // authN tokens cookies set with the redirect response not to be sent to the\n // server. Hence, sending a html page with status 200 to the client, and perform\n // the redirection on the client side.\n headers.set('Content-Type', 'text/html');\n return new Response(createRedirectionIntermediary({\n redirectTo: getRedirectOrDefault(handlerInput.redirectOnSignInComplete),\n }), {\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AACA;AACA,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC;AAC5C,IAAI,OAAO,IAAI,QAAQ,CAAC,6BAA6B,CAAC;AACtD,QAAQ,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,wBAAwB,CAAC;AAC/E,KAAK,CAAC,EAAE;AACR,QAAQ,MAAM,EAAE,GAAG;AACnB,QAAQ,OAAO;AACf,KAAK,CAAC;AACN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleSignInCallbackRequestForPagesRouter.mjs","sources":["../../../../src/auth/handlers/handleSignInCallbackRequestForPagesRouter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PKCE_COOKIE_NAME, SIGN_IN_TIMEOUT_ERROR_CODE, SIGN_IN_TIMEOUT_ERROR_MESSAGE, STATE_COOKIE_NAME, } from '../constant';\nimport { appendSetCookieHeadersToNextApiResponse, createAuthFlowProofCookiesRemoveOptions, createErrorSearchParamsString, createRedirectionIntermediary, createSignInFlowProofCookies, createTokenCookies, createTokenCookiesSetOptions, exchangeAuthNTokens, getCookieValuesFromNextApiRequest, getRedirectOrDefault, parseSignInCallbackUrl, resolveRedirectSignInUrl, } from '../utils';\nexport const handleSignInCallbackRequestForPagesRouter = async ({ request, response, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n const { code, state, error, errorDescription } = parseSignInCallbackUrl(request.url);\n if (errorDescription || error) {\n const searchParamsString = createErrorSearchParamsString({\n error,\n errorDescription,\n });\n response.redirect(302, `${getRedirectOrDefault(handlerInput.redirectOnSignOutComplete)}?${searchParamsString}`);\n return;\n }\n if (!code || !state) {\n response.status(400).end();\n return;\n }\n const { [PKCE_COOKIE_NAME]: clientPkce, [STATE_COOKIE_NAME]: clientState } = getCookieValuesFromNextApiRequest(request, [\n PKCE_COOKIE_NAME,\n STATE_COOKIE_NAME,\n ]);\n // The state and pkce cookies are removed from cookie store after 5 minutes\n if (!clientState || !clientPkce) {\n const searchParamsString = createErrorSearchParamsString({\n error: SIGN_IN_TIMEOUT_ERROR_CODE,\n errorDescription: SIGN_IN_TIMEOUT_ERROR_MESSAGE,\n });\n response.redirect(302, `${getRedirectOrDefault(handlerInput.redirectOnSignOutComplete)}?${searchParamsString}`);\n return;\n }\n // Most likely the cookie has been tampered\n if (clientState !== state) {\n response.status(400).end();\n return;\n }\n const tokensPayload = await exchangeAuthNTokens({\n redirectUri: resolveRedirectSignInUrl(origin, oAuthConfig),\n userPoolClientId,\n oAuthConfig,\n code,\n codeVerifier: clientPkce,\n });\n if ('error' in tokensPayload) {\n response.status(500).send(tokensPayload.error);\n return;\n }\n appendSetCookieHeadersToNextApiResponse(response, createTokenCookies({\n tokensPayload,\n userPoolClientId,\n }), createTokenCookiesSetOptions(setCookieOptions, origin));\n appendSetCookieHeadersToNextApiResponse(response, createSignInFlowProofCookies({ state: '', pkce: '' }), createAuthFlowProofCookiesRemoveOptions(setCookieOptions));\n // When Cognito redirects back to `/sign-in-callback`, the referer is Cognito\n // endpoint. If redirect end user to `redirectOnSignInComplete` from this point,\n // the referer remains the same.\n // When authN token cookies set as `sameSite: 'strict'`, this may cause the\n // authN tokens cookies set with the redirect response not to be sent to the\n // server. Hence, sending a html page with status 200 to the client, and perform\n // the redirection on the client side.\n response\n .appendHeader('Content-Type', 'text/html')\n .status(200)\n .send(createRedirectionIntermediary({\n redirectTo: getRedirectOrDefault(handlerInput.redirectOnSignInComplete),\n }));\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAGY,MAAC,yCAAyC,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AAClK,IAAI,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC;AACxF,IAAI,IAAI,gBAAgB,IAAI,KAAK,EAAE;AACnC,QAAQ,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACjE,YAAY,KAAK;AACjB,YAAY,gBAAgB;AAC5B,SAAS,CAAC;AACV,QAAQ,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC;AACvH,QAAQ;AACR;
|
|
1
|
+
{"version":3,"file":"handleSignInCallbackRequestForPagesRouter.mjs","sources":["../../../../src/auth/handlers/handleSignInCallbackRequestForPagesRouter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PKCE_COOKIE_NAME, SIGN_IN_TIMEOUT_ERROR_CODE, SIGN_IN_TIMEOUT_ERROR_MESSAGE, STATE_COOKIE_NAME, } from '../constant';\nimport { appendSetCookieHeadersToNextApiResponse, createAuthFlowProofCookiesRemoveOptions, createErrorSearchParamsString, createRedirectionIntermediary, createSignInFlowProofCookies, createTokenCookies, createTokenCookiesSetOptions, exchangeAuthNTokens, getCookieValuesFromNextApiRequest, getRedirectOrDefault, parseSignInCallbackUrl, resolveRedirectSignInUrl, } from '../utils';\nexport const handleSignInCallbackRequestForPagesRouter = async ({ request, response, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n const { code, state, error, errorDescription } = parseSignInCallbackUrl(request.url);\n if (errorDescription || error) {\n const searchParamsString = createErrorSearchParamsString({\n error,\n errorDescription,\n });\n response.redirect(302, `${getRedirectOrDefault(handlerInput.redirectOnSignOutComplete)}?${searchParamsString}`);\n return;\n }\n if (!code || !state) {\n response.status(400).end();\n return;\n }\n const { [PKCE_COOKIE_NAME]: clientPkce, [STATE_COOKIE_NAME]: clientState } = getCookieValuesFromNextApiRequest(request, [\n PKCE_COOKIE_NAME,\n STATE_COOKIE_NAME,\n ]);\n // The state and pkce cookies are removed from cookie store after 5 minutes\n if (!clientState || !clientPkce) {\n const searchParamsString = createErrorSearchParamsString({\n error: SIGN_IN_TIMEOUT_ERROR_CODE,\n errorDescription: SIGN_IN_TIMEOUT_ERROR_MESSAGE,\n });\n response.redirect(302, `${getRedirectOrDefault(handlerInput.redirectOnSignOutComplete)}?${searchParamsString}`);\n return;\n }\n // Most likely the cookie has been tampered\n if (clientState !== state) {\n response.status(400).end();\n return;\n }\n const tokensPayload = await exchangeAuthNTokens({\n redirectUri: resolveRedirectSignInUrl(origin, oAuthConfig),\n userPoolClientId,\n oAuthConfig,\n code,\n codeVerifier: clientPkce,\n });\n if ('error' in tokensPayload) {\n response.status(500).send(tokensPayload.error);\n return;\n }\n appendSetCookieHeadersToNextApiResponse(response, createTokenCookies({\n tokensPayload,\n userPoolClientId,\n }), createTokenCookiesSetOptions(setCookieOptions, origin));\n appendSetCookieHeadersToNextApiResponse(response, createSignInFlowProofCookies({ state: '', pkce: '' }), createAuthFlowProofCookiesRemoveOptions(setCookieOptions));\n // When Cognito redirects back to `/sign-in-callback`, the referer is Cognito\n // endpoint. If redirect end user to `redirectOnSignInComplete` from this point,\n // the referer remains the same.\n // When authN token cookies set as `sameSite: 'strict'`, this may cause the\n // authN tokens cookies set with the redirect response not to be sent to the\n // server. Hence, sending a html page with status 200 to the client, and perform\n // the redirection on the client side.\n response\n .appendHeader('Content-Type', 'text/html')\n .status(200)\n .send(createRedirectionIntermediary({\n redirectTo: getRedirectOrDefault(handlerInput.redirectOnSignInComplete),\n }));\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAGY,MAAC,yCAAyC,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AAClK,IAAI,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE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AACJ,IAAI,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC;AACpD,QAAQ,WAAW,EAAE,wBAAwB,CAAC,MAAM,EAAE,WAAW,CAAC;AAClE,QAAQ,gBAAgB;AACxB,QAAQ,WAAW;AACnB,QAAQ,IAAI;AACZ,QAAQ,YAAY,EAAE,UAAU;AAChC,KAAK,CAAC;AACN,IAAI,IAAI,OAAO,IAAI,aAAa,EAAE;AAClC,QAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;AACtD,QAAQ;AACR,IAAI;AACJ,IAAI,uCAAuC,CAAC,QAAQ,EAAE,kBAAkB,CAAC;AACzE,QAAQ,aAAa;AACrB,QAAQ,gBAAgB;AACxB,KAAK,CAAC,EAAE,4BAA4B,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAC/D,IAAI,uCAAuC,CAAC,QAAQ,EAAE,4BAA4B,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,uCAAuC,CAAC,gBAAgB,CAAC,CAAC;AACvK;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ,SAAS,YAAY,CAAC,cAAc,EAAE,WAAW;AACjD,SAAS,MAAM,CAAC,GAAG;AACnB,SAAS,IAAI,CAAC,6BAA6B,CAAC;AAC5C,QAAQ,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,wBAAwB,CAAC;AAC/E,KAAK,CAAC,CAAC;AACP;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleSignOutCallbackRequest.mjs","sources":["../../../../src/auth/handlers/handleSignOutCallbackRequest.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AUTH_KEY_PREFIX, createKeysForAuthStorage, } from 'aws-amplify/adapter-core';\nimport { IS_SIGNING_OUT_COOKIE_NAME, IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME, } from '../constant';\nimport { appendSetCookieHeaders, createAuthFlowProofCookiesRemoveOptions, createRedirectionIntermediary, createTokenCookiesRemoveOptions, createTokenRemoveCookies, getCookieValuesFromRequest, getRedirectOrDefault, resolveRedirectSignOutUrl, revokeAuthNTokens, } from '../utils';\nexport const handleSignOutCallbackRequest = async ({ request, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n const { [IS_SIGNING_OUT_COOKIE_NAME]: isSigningOut, [IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME]: isSigningOutRedirecting, } = getCookieValuesFromRequest(request, [\n IS_SIGNING_OUT_COOKIE_NAME,\n IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME,\n ]);\n if (!isSigningOut) {\n return new Response(null, { status: 400 });\n }\n // When Cognito /logout endpoint redirects back, response has code 302, the browsers (Safari and Firefox)\n // assume the incoming request is a cross-site request and block the cookies.\n // To workaround this issue, we send an intermediate page with 200 response. This page will redirect\n // to the /sign-out-callback (this handler) again, since it's the same-site request, the cookies will be\n // sent back to the server.\n if (isSigningOutRedirecting) {\n const headers = new Headers();\n headers.set('Content-Type', 'text/html');\n appendSetCookieHeaders(headers, \n // remove the IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME cookie to the next request to this\n // handler can proceed.\n createTokenRemoveCookies([IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME]), createAuthFlowProofCookiesRemoveOptions(setCookieOptions));\n return new Response(createRedirectionIntermediary({\n redirectTo: resolveRedirectSignOutUrl(origin, oAuthConfig),\n }), {\n status: 200,\n headers,\n });\n }\n const lastAuthUserCookieName = `${AUTH_KEY_PREFIX}.${userPoolClientId}.LastAuthUser`;\n const { [lastAuthUserCookieName]: username } = getCookieValuesFromRequest(request, [lastAuthUserCookieName]);\n if (!username) {\n return new Response(null, {\n status: 302,\n headers: new Headers({\n Location: getRedirectOrDefault(handlerInput.redirectOnSignOutComplete),\n }),\n });\n }\n const authCookiesKeys = createKeysForAuthStorage(AUTH_KEY_PREFIX, `${userPoolClientId}.${username}`);\n const { [authCookiesKeys.refreshToken]: refreshToken } = getCookieValuesFromRequest(request, [authCookiesKeys.refreshToken]);\n if (!refreshToken) {\n return new Response(null, {\n status: 302,\n headers: new Headers({\n Location: getRedirectOrDefault(handlerInput.redirectOnSignOutComplete),\n }),\n });\n }\n const result = await revokeAuthNTokens({\n refreshToken,\n userPoolClientId,\n endpointDomain: oAuthConfig.domain,\n });\n if (result.error) {\n return new Response(result.error, { status: 500 });\n }\n const headers = new Headers();\n appendSetCookieHeaders(headers, [\n ...createTokenRemoveCookies([\n authCookiesKeys.accessToken,\n authCookiesKeys.idToken,\n authCookiesKeys.refreshToken,\n lastAuthUserCookieName,\n IS_SIGNING_OUT_COOKIE_NAME,\n ]),\n ], createTokenCookiesRemoveOptions(setCookieOptions));\n headers.set('Location', getRedirectOrDefault(handlerInput.redirectOnSignOutComplete));\n return new Response(null, {\n status: 302,\n headers,\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAIY,MAAC,4BAA4B,GAAG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AAC3I,IAAI,MAAM,EAAE,CAAC,0BAA0B,GAAG,YAAY,EAAE,CAAC,sCAAsC,GAAG,uBAAuB,GAAG,GAAG,0BAA0B,CAAC,OAAO,EAAE;AACnK,QAAQ,0BAA0B;AAClC,QAAQ,sCAAsC;AAC9C,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,YAAY,EAAE;AACvB,QAAQ,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AAClD;
|
|
1
|
+
{"version":3,"file":"handleSignOutCallbackRequest.mjs","sources":["../../../../src/auth/handlers/handleSignOutCallbackRequest.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AUTH_KEY_PREFIX, createKeysForAuthStorage, } from 'aws-amplify/adapter-core';\nimport { IS_SIGNING_OUT_COOKIE_NAME, IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME, } from '../constant';\nimport { appendSetCookieHeaders, createAuthFlowProofCookiesRemoveOptions, createRedirectionIntermediary, createTokenCookiesRemoveOptions, createTokenRemoveCookies, getCookieValuesFromRequest, getRedirectOrDefault, resolveRedirectSignOutUrl, revokeAuthNTokens, } from '../utils';\nexport const handleSignOutCallbackRequest = async ({ request, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n const { [IS_SIGNING_OUT_COOKIE_NAME]: isSigningOut, [IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME]: isSigningOutRedirecting, } = getCookieValuesFromRequest(request, [\n IS_SIGNING_OUT_COOKIE_NAME,\n IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME,\n ]);\n if (!isSigningOut) {\n return new Response(null, { status: 400 });\n }\n // When Cognito /logout endpoint redirects back, response has code 302, the browsers (Safari and Firefox)\n // assume the incoming request is a cross-site request and block the cookies.\n // To workaround this issue, we send an intermediate page with 200 response. This page will redirect\n // to the /sign-out-callback (this handler) again, since it's the same-site request, the cookies will be\n // sent back to the server.\n if (isSigningOutRedirecting) {\n const headers = new Headers();\n headers.set('Content-Type', 'text/html');\n appendSetCookieHeaders(headers, \n // remove the IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME cookie to the next request to this\n // handler can proceed.\n createTokenRemoveCookies([IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME]), createAuthFlowProofCookiesRemoveOptions(setCookieOptions));\n return new Response(createRedirectionIntermediary({\n redirectTo: resolveRedirectSignOutUrl(origin, oAuthConfig),\n }), {\n status: 200,\n headers,\n });\n }\n const lastAuthUserCookieName = `${AUTH_KEY_PREFIX}.${userPoolClientId}.LastAuthUser`;\n const { [lastAuthUserCookieName]: username } = getCookieValuesFromRequest(request, [lastAuthUserCookieName]);\n if (!username) {\n return new Response(null, {\n status: 302,\n headers: new Headers({\n Location: getRedirectOrDefault(handlerInput.redirectOnSignOutComplete),\n }),\n });\n }\n const authCookiesKeys = createKeysForAuthStorage(AUTH_KEY_PREFIX, `${userPoolClientId}.${username}`);\n const { [authCookiesKeys.refreshToken]: refreshToken } = getCookieValuesFromRequest(request, [authCookiesKeys.refreshToken]);\n if (!refreshToken) {\n return new Response(null, {\n status: 302,\n headers: new Headers({\n Location: getRedirectOrDefault(handlerInput.redirectOnSignOutComplete),\n }),\n });\n }\n const result = await revokeAuthNTokens({\n refreshToken,\n userPoolClientId,\n endpointDomain: oAuthConfig.domain,\n });\n if (result.error) {\n return new Response(result.error, { status: 500 });\n }\n const headers = new Headers();\n appendSetCookieHeaders(headers, [\n ...createTokenRemoveCookies([\n authCookiesKeys.accessToken,\n authCookiesKeys.idToken,\n authCookiesKeys.refreshToken,\n lastAuthUserCookieName,\n IS_SIGNING_OUT_COOKIE_NAME,\n ]),\n ], createTokenCookiesRemoveOptions(setCookieOptions));\n headers.set('Location', getRedirectOrDefault(handlerInput.redirectOnSignOutComplete));\n return new Response(null, {\n status: 302,\n headers,\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAIY,MAAC,4BAA4B,GAAG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AAC3I,IAAI,MAAM,EAAE,CAAC,0BAA0B,GAAG,YAAY,EAAE,CAAC,sCAAsC,GAAG,uBAAuB,GAAG,GAAG,0BAA0B,CAAC,OAAO,EAAE;AACnK,QAAQ,0BAA0B;AAClC,QAAQ,sCAAsC;AAC9C,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,YAAY,EAAE;AACvB,QAAQ,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAA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RequestForPagesRouter.mjs","sources":["../../../../src/auth/handlers/handleSignOutCallbackRequestForPagesRouter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AUTH_KEY_PREFIX, createKeysForAuthStorage, } from 'aws-amplify/adapter-core';\nimport { IS_SIGNING_OUT_COOKIE_NAME, IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME, } from '../constant';\nimport { appendSetCookieHeadersToNextApiResponse, createAuthFlowProofCookiesRemoveOptions, createRedirectionIntermediary, createTokenCookiesRemoveOptions, createTokenRemoveCookies, getCookieValuesFromNextApiRequest, getRedirectOrDefault, resolveRedirectSignOutUrl, revokeAuthNTokens, } from '../utils';\nexport const handleSignOutCallbackRequestForPagesRouter = async ({ request, response, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n const { [IS_SIGNING_OUT_COOKIE_NAME]: isSigningOut, [IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME]: isSigningOutRedirecting, } = getCookieValuesFromNextApiRequest(request, [\n IS_SIGNING_OUT_COOKIE_NAME,\n IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME,\n ]);\n if (!isSigningOut) {\n response.status(400).end();\n return;\n }\n // When Cognito /logout endpoint redirects back, response has code 302, the browsers (Safari and Firefox)\n // assume the incoming request is a cross-site request and block the cookies.\n // To workaround this issue, we send an intermediate page with 200 response. This page will redirect\n // to the /sign-out-callback (this handler) again, since it's the same-site request, the cookies will be\n // sent back to the server.\n if (isSigningOutRedirecting) {\n appendSetCookieHeadersToNextApiResponse(response, \n // remove the IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME cookie to the next request to this\n // handler can proceed.\n createTokenRemoveCookies([IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME]), createAuthFlowProofCookiesRemoveOptions(setCookieOptions));\n response\n .appendHeader('Content-Type', 'text/html')\n .status(200)\n .send(createRedirectionIntermediary({\n redirectTo: resolveRedirectSignOutUrl(origin, oAuthConfig),\n }));\n return;\n }\n const lastAuthUserCookieName = `${AUTH_KEY_PREFIX}.${userPoolClientId}.LastAuthUser`;\n const { [lastAuthUserCookieName]: username } = getCookieValuesFromNextApiRequest(request, [lastAuthUserCookieName]);\n if (!username) {\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignOutComplete));\n return;\n }\n const authCookiesKeys = createKeysForAuthStorage(AUTH_KEY_PREFIX, `${userPoolClientId}.${username}`);\n const { [authCookiesKeys.refreshToken]: refreshToken } = getCookieValuesFromNextApiRequest(request, [\n authCookiesKeys.refreshToken,\n ]);\n if (!refreshToken) {\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignOutComplete));\n return;\n }\n const result = await revokeAuthNTokens({\n refreshToken,\n userPoolClientId,\n endpointDomain: oAuthConfig.domain,\n });\n if (result.error) {\n response.status(500).send(result.error);\n return;\n }\n appendSetCookieHeadersToNextApiResponse(response, [\n ...createTokenRemoveCookies([\n authCookiesKeys.accessToken,\n authCookiesKeys.idToken,\n authCookiesKeys.refreshToken,\n lastAuthUserCookieName,\n IS_SIGNING_OUT_COOKIE_NAME,\n ]),\n ], createTokenCookiesRemoveOptions(setCookieOptions));\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignOutComplete));\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAIY,MAAC,0CAA0C,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AACnK,IAAI,MAAM,EAAE,CAAC,0BAA0B,GAAG,YAAY,EAAE,CAAC,sCAAsC,GAAG,uBAAuB,GAAG,GAAG,iCAAiC,CAAC,OAAO,EAAE;AAC1K,QAAQ,0BAA0B;AAClC,QAAQ,sCAAsC;AAC9C,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,YAAY,EAAE;AACvB,QAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;AAClC,QAAQ;AACR;
|
|
1
|
+
{"version":3,"file":"handleSignOutCallbackRequestForPagesRouter.mjs","sources":["../../../../src/auth/handlers/handleSignOutCallbackRequestForPagesRouter.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AUTH_KEY_PREFIX, createKeysForAuthStorage, } from 'aws-amplify/adapter-core';\nimport { IS_SIGNING_OUT_COOKIE_NAME, IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME, } from '../constant';\nimport { appendSetCookieHeadersToNextApiResponse, createAuthFlowProofCookiesRemoveOptions, createRedirectionIntermediary, createTokenCookiesRemoveOptions, createTokenRemoveCookies, getCookieValuesFromNextApiRequest, getRedirectOrDefault, resolveRedirectSignOutUrl, revokeAuthNTokens, } from '../utils';\nexport const handleSignOutCallbackRequestForPagesRouter = async ({ request, response, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n const { [IS_SIGNING_OUT_COOKIE_NAME]: isSigningOut, [IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME]: isSigningOutRedirecting, } = getCookieValuesFromNextApiRequest(request, [\n IS_SIGNING_OUT_COOKIE_NAME,\n IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME,\n ]);\n if (!isSigningOut) {\n response.status(400).end();\n return;\n }\n // When Cognito /logout endpoint redirects back, response has code 302, the browsers (Safari and Firefox)\n // assume the incoming request is a cross-site request and block the cookies.\n // To workaround this issue, we send an intermediate page with 200 response. This page will redirect\n // to the /sign-out-callback (this handler) again, since it's the same-site request, the cookies will be\n // sent back to the server.\n if (isSigningOutRedirecting) {\n appendSetCookieHeadersToNextApiResponse(response, \n // remove the IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME cookie to the next request to this\n // handler can proceed.\n createTokenRemoveCookies([IS_SIGNING_OUT_REDIRECTING_COOKIE_NAME]), createAuthFlowProofCookiesRemoveOptions(setCookieOptions));\n response\n .appendHeader('Content-Type', 'text/html')\n .status(200)\n .send(createRedirectionIntermediary({\n redirectTo: resolveRedirectSignOutUrl(origin, oAuthConfig),\n }));\n return;\n }\n const lastAuthUserCookieName = `${AUTH_KEY_PREFIX}.${userPoolClientId}.LastAuthUser`;\n const { [lastAuthUserCookieName]: username } = getCookieValuesFromNextApiRequest(request, [lastAuthUserCookieName]);\n if (!username) {\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignOutComplete));\n return;\n }\n const authCookiesKeys = createKeysForAuthStorage(AUTH_KEY_PREFIX, `${userPoolClientId}.${username}`);\n const { [authCookiesKeys.refreshToken]: refreshToken } = getCookieValuesFromNextApiRequest(request, [\n authCookiesKeys.refreshToken,\n ]);\n if (!refreshToken) {\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignOutComplete));\n return;\n }\n const result = await revokeAuthNTokens({\n refreshToken,\n userPoolClientId,\n endpointDomain: oAuthConfig.domain,\n });\n if (result.error) {\n response.status(500).send(result.error);\n return;\n }\n appendSetCookieHeadersToNextApiResponse(response, [\n ...createTokenRemoveCookies([\n authCookiesKeys.accessToken,\n authCookiesKeys.idToken,\n authCookiesKeys.refreshToken,\n lastAuthUserCookieName,\n IS_SIGNING_OUT_COOKIE_NAME,\n ]),\n ], createTokenCookiesRemoveOptions(setCookieOptions));\n response.redirect(302, getRedirectOrDefault(handlerInput.redirectOnSignOutComplete));\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAIY,MAAC,0CAA0C,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,KAAK;AACnK,IAAI,MAAM,EAAE,CAAC,0BAA0B,GAAG,YAAY,EAAE,CAAC,sCAAsC,GAAG,uBAAuB,GAAG,GAAG,iCAAiC,CAAC,OAAO,EAAE;AAC1K,QAAQ,0BAA0B;AAClC,QAAQ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AAI,IAAI,CAAC,YAAY,EAAE;AACvB,QAAQ,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;AAC5F,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC;AAC3C,QAAQ,YAAY;AACpB,QAAQ,gBAAgB;AACxB,QAAQ,cAAc,EAAE,WAAW,CAAC,MAAM;AAC1C,KAAK,CAAC;AACN,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE;AACtB,QAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;AAC/C,QAAQ;AACR,IAAI;AACJ,IAAI,uCAAuC,CAAC,QAAQ,EAAE;AACtD,QAAQ,GAAG,wBAAwB,CAAC;AACpC,YAAY,eAAe,CAAC,WAAW;AACvC,YAAY,eAAe,CAAC,OAAO;AACnC,YAAY,eAAe,CAAC,YAAY;AACxC,YAAY,sBAAsB;AAClC,YAAY,0BAA0B;AACtC,SAAS,CAAC;AACV,KAAK,EAAE,+BAA+B,CAAC,gBAAgB,CAAC,CAAC;AACzD,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;AACxF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendSetCookieHeaders.mjs","sources":["../../../../src/auth/utils/appendSetCookieHeaders.ts"],"sourcesContent":["import { serializeCookie } from '../../utils/cookie';\nexport const appendSetCookieHeaders = (headers, cookies, setCookieOptions) => {\n for (const { name, value } of cookies) {\n headers.append('Set-Cookie', serializeCookie(name, value, setCookieOptions));\n }\n};\n"],"names":[],"mappings":";;AACY,MAAC,sBAAsB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,KAAK;AAC9E,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE;AAC3C,QAAQ,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACpF;
|
|
1
|
+
{"version":3,"file":"appendSetCookieHeaders.mjs","sources":["../../../../src/auth/utils/appendSetCookieHeaders.ts"],"sourcesContent":["import { serializeCookie } from '../../utils/cookie';\nexport const appendSetCookieHeaders = (headers, cookies, setCookieOptions) => {\n for (const { name, value } of cookies) {\n headers.append('Set-Cookie', serializeCookie(name, value, setCookieOptions));\n }\n};\n"],"names":[],"mappings":";;AACY,MAAC,sBAAsB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,KAAK;AAC9E,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE;AAC3C,QAAQ,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACpF,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendSetCookieHeadersToNextApiResponse.mjs","sources":["../../../../src/auth/utils/appendSetCookieHeadersToNextApiResponse.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { serializeCookie } from '../../utils/cookie';\nexport const appendSetCookieHeadersToNextApiResponse = (response, cookies, setCookieOptions) => {\n for (const { name, value } of cookies) {\n response.appendHeader('Set-Cookie', serializeCookie(name, value, setCookieOptions));\n }\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,uCAAuC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,gBAAgB,KAAK;AAChG,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE;AAC3C,QAAQ,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAC3F;
|
|
1
|
+
{"version":3,"file":"appendSetCookieHeadersToNextApiResponse.mjs","sources":["../../../../src/auth/utils/appendSetCookieHeadersToNextApiResponse.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { serializeCookie } from '../../utils/cookie';\nexport const appendSetCookieHeadersToNextApiResponse = (response, cookies, setCookieOptions) => {\n for (const { name, value } of cookies) {\n response.appendHeader('Set-Cookie', serializeCookie(name, value, setCookieOptions));\n }\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,uCAAuC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,gBAAgB,KAAK;AAChG,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE;AAC3C,QAAQ,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAC3F,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createErrorSearchParamsString.mjs","sources":["../../../../src/auth/utils/createErrorSearchParamsString.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const createErrorSearchParamsString = ({ error, errorDescription, }) => {\n const errorParams = new URLSearchParams();\n if (error) {\n errorParams.set('error', error);\n }\n if (errorDescription) {\n errorParams.set('error_description', errorDescription);\n }\n return errorParams.toString();\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,6BAA6B,GAAG,CAAC,EAAE,KAAK,EAAE,gBAAgB,GAAG,KAAK;AAC/E,IAAI,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE;AAC7C,IAAI,IAAI,KAAK,EAAE;AACf,QAAQ,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC;AACvC;
|
|
1
|
+
{"version":3,"file":"createErrorSearchParamsString.mjs","sources":["../../../../src/auth/utils/createErrorSearchParamsString.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const createErrorSearchParamsString = ({ error, errorDescription, }) => {\n const errorParams = new URLSearchParams();\n if (error) {\n errorParams.set('error', error);\n }\n if (errorDescription) {\n errorParams.set('error_description', errorDescription);\n }\n return errorParams.toString();\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,6BAA6B,GAAG,CAAC,EAAE,KAAK,EAAE,gBAAgB,GAAG,KAAK;AAC/E,IAAI,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE;AAC7C,IAAI,IAAI,KAAK,EAAE;AACf,QAAQ,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC;AACvC,IAAI;AACJ,IAAI,IAAI,gBAAgB,EAAE;AAC1B,QAAQ,WAAW,CAAC,GAAG,CAAC,mBAAmB,EAAE,gBAAgB,CAAC;AAC9D,IAAI;AACJ,IAAI,OAAO,WAAW,CAAC,QAAQ,EAAE;AACjC;;;;"}
|