@aws-amplify/adapter-nextjs 1.4.1-server-auth.8d7a741.0 → 1.4.1-server-auth.28fa210.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cjs/api/createServerRunnerForAPI.js +1 -1
  2. package/dist/cjs/api/createServerRunnerForAPI.js.map +1 -1
  3. package/dist/cjs/api/generateServerClient.js +5 -5
  4. package/dist/cjs/api/generateServerClient.js.map +1 -1
  5. package/dist/cjs/auth/createAuthRouteHandlersFactory.js +10 -11
  6. package/dist/cjs/auth/createAuthRouteHandlersFactory.js.map +1 -1
  7. package/dist/cjs/auth/utils/createAuthFlowProofs.js +2 -2
  8. package/dist/cjs/auth/utils/createAuthFlowProofs.js.map +1 -1
  9. package/dist/cjs/auth/utils/getAccessTokenUsername.js +2 -2
  10. package/dist/cjs/auth/utils/getAccessTokenUsername.js.map +1 -1
  11. package/dist/cjs/auth/utils/resolveRedirectUrl.js +2 -2
  12. package/dist/cjs/auth/utils/resolveRedirectUrl.js.map +1 -1
  13. package/dist/cjs/createServerRunner.js +1 -1
  14. package/dist/cjs/createServerRunner.js.map +1 -1
  15. package/dist/cjs/utils/createCookieStorageAdapterFromNextServerContext.js +2 -2
  16. package/dist/cjs/utils/createCookieStorageAdapterFromNextServerContext.js.map +1 -1
  17. package/dist/cjs/utils/createRunWithAmplifyServerContext.js +2 -2
  18. package/dist/cjs/utils/createRunWithAmplifyServerContext.js.map +1 -1
  19. package/dist/esm/api/createServerRunnerForAPI.d.ts +1 -1
  20. package/dist/esm/api/createServerRunnerForAPI.mjs +1 -1
  21. package/dist/esm/api/createServerRunnerForAPI.mjs.map +1 -1
  22. package/dist/esm/api/generateServerClient.d.ts +1 -2
  23. package/dist/esm/api/generateServerClient.mjs +3 -3
  24. package/dist/esm/api/generateServerClient.mjs.map +1 -1
  25. package/dist/esm/api/index.d.ts +1 -1
  26. package/dist/esm/auth/createAuthRouteHandlersFactory.mjs +1 -3
  27. package/dist/esm/auth/createAuthRouteHandlersFactory.mjs.map +1 -1
  28. package/dist/esm/auth/handleAuthApiRouteRequestForAppRouter.mjs +1 -3
  29. package/dist/esm/auth/handleAuthApiRouteRequestForAppRouter.mjs.map +1 -1
  30. package/dist/esm/auth/handleAuthApiRouteRequestForPagesRouter.mjs +1 -3
  31. package/dist/esm/auth/handleAuthApiRouteRequestForPagesRouter.mjs.map +1 -1
  32. package/dist/esm/auth/handlers/handleSignInCallbackRequest.mjs +1 -2
  33. package/dist/esm/auth/handlers/handleSignInCallbackRequest.mjs.map +1 -1
  34. package/dist/esm/auth/handlers/handleSignInCallbackRequestForPagesRouter.mjs +1 -2
  35. package/dist/esm/auth/handlers/handleSignInCallbackRequestForPagesRouter.mjs.map +1 -1
  36. package/dist/esm/auth/handlers/handleSignInSignUpRequest.mjs +1 -2
  37. package/dist/esm/auth/handlers/handleSignInSignUpRequest.mjs.map +1 -1
  38. package/dist/esm/auth/handlers/handleSignInSignUpRequestForPagesRouter.mjs +1 -2
  39. package/dist/esm/auth/handlers/handleSignInSignUpRequestForPagesRouter.mjs.map +1 -1
  40. package/dist/esm/auth/handlers/handleSignOutCallbackRequest.mjs +1 -3
  41. package/dist/esm/auth/handlers/handleSignOutCallbackRequest.mjs.map +1 -1
  42. package/dist/esm/auth/handlers/handleSignOutCallbackRequestForPagesRouter.mjs +1 -3
  43. package/dist/esm/auth/handlers/handleSignOutCallbackRequestForPagesRouter.mjs.map +1 -1
  44. package/dist/esm/auth/handlers/handleSignOutRequest.mjs +1 -2
  45. package/dist/esm/auth/handlers/handleSignOutRequest.mjs.map +1 -1
  46. package/dist/esm/auth/handlers/handleSignOutRequestForPagesRouter.mjs +1 -2
  47. package/dist/esm/auth/handlers/handleSignOutRequestForPagesRouter.mjs.map +1 -1
  48. package/dist/esm/auth/handlers/types.d.ts +1 -1
  49. package/dist/esm/auth/types.d.ts +1 -1
  50. package/dist/esm/auth/utils/authNTokens.d.ts +1 -1
  51. package/dist/esm/auth/utils/createAuthFlowProofs.mjs +1 -1
  52. package/dist/esm/auth/utils/createAuthFlowProofs.mjs.map +1 -1
  53. package/dist/esm/auth/utils/createUrlSearchParams.d.ts +1 -1
  54. package/dist/esm/auth/utils/getAccessTokenUsername.mjs +1 -1
  55. package/dist/esm/auth/utils/getAccessTokenUsername.mjs.map +1 -1
  56. package/dist/esm/auth/utils/resolveRedirectUrl.d.ts +1 -1
  57. package/dist/esm/auth/utils/resolveRedirectUrl.mjs +1 -1
  58. package/dist/esm/auth/utils/resolveRedirectUrl.mjs.map +1 -1
  59. package/dist/esm/createServerRunner.mjs +1 -1
  60. package/dist/esm/createServerRunner.mjs.map +1 -1
  61. package/dist/esm/types/NextServer.d.ts +2 -2
  62. package/dist/esm/utils/createCookieStorageAdapterFromNextServerContext.d.ts +1 -1
  63. package/dist/esm/utils/createCookieStorageAdapterFromNextServerContext.mjs +1 -1
  64. package/dist/esm/utils/createCookieStorageAdapterFromNextServerContext.mjs.map +1 -1
  65. package/dist/esm/utils/createRunWithAmplifyServerContext.d.ts +3 -3
  66. package/dist/esm/utils/createRunWithAmplifyServerContext.mjs +1 -1
  67. package/dist/esm/utils/createRunWithAmplifyServerContext.mjs.map +1 -1
  68. package/dist/esm/utils/createTokenValidator.d.ts +1 -1
  69. package/package.json +4 -4
  70. package/src/api/createServerRunnerForAPI.ts +2 -2
  71. package/src/api/generateServerClient.ts +9 -11
  72. package/src/api/index.ts +1 -1
  73. package/src/auth/createAuthRouteHandlersFactory.ts +4 -6
  74. package/src/auth/handlers/types.ts +1 -1
  75. package/src/auth/types.ts +1 -1
  76. package/src/auth/utils/authNTokens.ts +1 -1
  77. package/src/auth/utils/createAuthFlowProofs.ts +1 -1
  78. package/src/auth/utils/createUrlSearchParams.ts +1 -1
  79. package/src/auth/utils/getAccessTokenUsername.ts +1 -1
  80. package/src/auth/utils/resolveRedirectUrl.ts +4 -2
  81. package/src/createServerRunner.ts +2 -2
  82. package/src/types/NextServer.ts +2 -2
  83. package/src/utils/createCookieStorageAdapterFromNextServerContext.ts +1 -1
  84. package/src/utils/createRunWithAmplifyServerContext.ts +3 -2
  85. package/src/utils/createTokenValidator.ts +1 -1
@@ -4,7 +4,7 @@
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createServerRunnerForAPI = void 0;
7
- const utils_1 = require("@aws-amplify/core/internals/utils");
7
+ const utils_1 = require("aws-amplify/utils");
8
8
  const utils_2 = require("../utils");
9
9
  const createServerRunnerForAPI = ({ config, }) => {
10
10
  const amplifyConfig = (0, utils_1.parseAmplifyConfig)(config);
@@ -1 +1 @@
1
- {"version":3,"file":"createServerRunnerForAPI.js","sources":["../../../src/api/createServerRunnerForAPI.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.createServerRunnerForAPI = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../utils\");\nconst createServerRunnerForAPI = ({ config, }) => {\n const amplifyConfig = (0, utils_1.parseAmplifyConfig)(config);\n return {\n runWithAmplifyServerContext: (0, utils_2.createRunWithAmplifyServerContext)({\n config: amplifyConfig,\n }),\n resourcesConfig: amplifyConfig,\n };\n};\nexports.createServerRunnerForAPI = createServerRunnerForAPI;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,wBAAwB,GAAG,KAAK,CAAC,CAAC;AAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,wBAAwB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AAClD,IAAI,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAClE,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,IAAI,OAAO,CAAC,iCAAiC,EAAE;AACpF,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,QAAQ,eAAe,EAAE,aAAa;AACtC,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,wBAAwB,GAAG,wBAAwB;;"}
1
+ {"version":3,"file":"createServerRunnerForAPI.js","sources":["../../../src/api/createServerRunnerForAPI.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.createServerRunnerForAPI = void 0;\nconst utils_1 = require(\"aws-amplify/utils\");\nconst utils_2 = require(\"../utils\");\nconst createServerRunnerForAPI = ({ config, }) => {\n const amplifyConfig = (0, utils_1.parseAmplifyConfig)(config);\n return {\n runWithAmplifyServerContext: (0, utils_2.createRunWithAmplifyServerContext)({\n config: amplifyConfig,\n }),\n resourcesConfig: amplifyConfig,\n };\n};\nexports.createServerRunnerForAPI = createServerRunnerForAPI;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,wBAAwB,GAAG,KAAK,CAAC,CAAC;AAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,wBAAwB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AAClD,IAAI,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAClE,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,IAAI,OAAO,CAAC,iCAAiC,EAAE;AACpF,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,QAAQ,eAAe,EAAE,aAAa;AACtC,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,wBAAwB,GAAG,wBAAwB;;"}
@@ -4,10 +4,10 @@
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateServerClientUsingReqRes = exports.generateServerClientUsingCookies = void 0;
7
- const internals_1 = require("@aws-amplify/api/internals");
7
+ const internals_1 = require("aws-amplify/api/internals");
8
8
  const server_1 = require("aws-amplify/api/server");
9
- const adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
10
- const utils_1 = require("@aws-amplify/core/internals/utils");
9
+ const internals_2 = require("aws-amplify/adapter-core/internals");
10
+ const utils_1 = require("aws-amplify/utils");
11
11
  const createServerRunnerForAPI_1 = require("./createServerRunnerForAPI");
12
12
  /**
13
13
  * Generates an API client that can be used inside a Next.js Server Component with Dynamic Rendering
@@ -20,7 +20,7 @@ const createServerRunnerForAPI_1 = require("./createServerRunnerForAPI");
20
20
  */
21
21
  function generateServerClientUsingCookies(options) {
22
22
  if (typeof options.cookies !== 'function') {
23
- throw new adapter_core_1.AmplifyServerContextError({
23
+ throw new internals_2.AmplifyServerContextError({
24
24
  message: 'generateServerClientUsingCookies is only compatible with the `cookies` Dynamic Function available in Server Components.',
25
25
  // TODO: link to docs
26
26
  recoverySuggestion: 'use `generateServerClient` inside of `runWithAmplifyServerContext` with the `request` object.',
@@ -32,7 +32,7 @@ function generateServerClientUsingCookies(options) {
32
32
  // causing it to always get invoked inside `runWithAmplifyServerContext`
33
33
  const getAmplify = (fn) => runWithAmplifyServerContext({
34
34
  nextServerContext: { cookies: options.cookies },
35
- operation: contextSpec => fn((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify),
35
+ operation: contextSpec => fn((0, internals_2.getAmplifyServerContext)(contextSpec).amplify),
36
36
  });
37
37
  const { cookies: _cookies, config: _config, ...params } = options;
38
38
  return (0, internals_1.generateClientWithAmplifyInstance)({
@@ -1 +1 @@
1
- {"version":3,"file":"generateServerClient.js","sources":["../../../src/api/generateServerClient.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.generateServerClientUsingReqRes = exports.generateServerClientUsingCookies = void 0;\nconst internals_1 = require(\"@aws-amplify/api/internals\");\nconst server_1 = require(\"aws-amplify/api/server\");\nconst adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst createServerRunnerForAPI_1 = require(\"./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 */\nfunction generateServerClientUsingCookies(options) {\n if (typeof options.cookies !== 'function') {\n throw new adapter_core_1.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 } = (0, createServerRunnerForAPI_1.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((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify),\n });\n const { cookies: _cookies, config: _config, ...params } = options;\n return (0, internals_1.generateClientWithAmplifyInstance)({\n amplify: getAmplify,\n config: resourcesConfig,\n ...params,\n }); // TS can't narrow the type here.\n}\nexports.generateServerClientUsingCookies = generateServerClientUsingCookies;\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 */\nfunction generateServerClientUsingReqRes(options) {\n const amplifyConfig = (0, utils_1.parseAmplifyConfig)(options.config);\n const { config: _config, ...params } = options;\n return (0, server_1.generateClient)({\n config: amplifyConfig,\n ...params,\n });\n}\nexports.generateServerClientUsingReqRes = generateServerClientUsingReqRes;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC,CAAC;AAC5F,MAAM,WAAW,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACnD,MAAM,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,0BAA0B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,gCAAgC,CAAC,OAAO,EAAE;AACnD,IAAI,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE;AAC/C,QAAQ,MAAM,IAAI,cAAc,CAAC,yBAAyB,CAAC;AAC3D,YAAY,OAAO,EAAE,yHAAyH;AAC9I;AACA,Y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KAAK,CAAC,CAAC;AACP,CAAC;AACD,OAAO,CAAC,+BAA+B,GAAG,+BAA+B;;"}
1
+ {"version":3,"file":"generateServerClient.js","sources":["../../../src/api/generateServerClient.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.generateServerClientUsingReqRes = exports.generateServerClientUsingCookies = void 0;\nconst internals_1 = require(\"aws-amplify/api/internals\");\nconst server_1 = require(\"aws-amplify/api/server\");\nconst internals_2 = require(\"aws-amplify/adapter-core/internals\");\nconst utils_1 = require(\"aws-amplify/utils\");\nconst createServerRunnerForAPI_1 = require(\"./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 */\nfunction generateServerClientUsingCookies(options) {\n if (typeof options.cookies !== 'function') {\n throw new internals_2.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 } = (0, createServerRunnerForAPI_1.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((0, internals_2.getAmplifyServerContext)(contextSpec).amplify),\n });\n const { cookies: _cookies, config: _config, ...params } = options;\n return (0, internals_1.generateClientWithAmplifyInstance)({\n amplify: getAmplify,\n config: resourcesConfig,\n ...params,\n }); // TS can't narrow the type here.\n}\nexports.generateServerClientUsingCookies = generateServerClientUsingCookies;\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 */\nfunction generateServerClientUsingReqRes(options) {\n const amplifyConfig = (0, utils_1.parseAmplifyConfig)(options.config);\n const { config: _config, ...params } = options;\n return (0, server_1.generateClient)({\n config: amplifyConfig,\n ...params,\n });\n}\nexports.generateServerClientUsingReqRes = generateServerClientUsingReqRes;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC,CAAC;AAC5F,MAAM,WAAW,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACzD,MAAM,QAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACnD,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAClE,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC7C,MAAM,0BAA0B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,gCAAgC,CAAC,OAAO,EAAE;AACnD,IAAI,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE;AAC/C,QAAQ,MAAM,IAAI,WAAW,CAAC,yBAAyB,CAAC;AACxD,YAAY,OAAO,EAAE,yHAAyH;AAC9I;AACA,YAAY,kBAAkB,EAAE,+FAA+F;AAC/H,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAA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4,14 +4,13 @@
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createAuthRouteHandlersFactory = void 0;
7
- const utils_1 = require("@aws-amplify/core/internals/utils");
8
- const adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
9
- const utils_2 = require("./utils");
7
+ const internals_1 = require("aws-amplify/adapter-core/internals");
8
+ const utils_1 = require("./utils");
10
9
  const handleAuthApiRouteRequestForAppRouter_1 = require("./handleAuthApiRouteRequestForAppRouter");
11
10
  const handleAuthApiRouteRequestForPagesRouter_1 = require("./handleAuthApiRouteRequestForPagesRouter");
12
11
  const createAuthRouteHandlersFactory = ({ config: resourcesConfig, runtimeOptions = {}, amplifyAppOrigin, runWithAmplifyServerContext, }) => {
13
12
  const handleRequest = async ({ request, contextOrResponse, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {
14
- if ((0, utils_2.isNextApiRequest)(request) && (0, utils_2.isNextApiResponse)(contextOrResponse)) {
13
+ if ((0, utils_1.isNextApiRequest)(request) && (0, utils_1.isNextApiResponse)(contextOrResponse)) {
15
14
  // In pages router the response is sent via calling `response.end()` or
16
15
  // `response.send()`. The response is not returned from the handler.
17
16
  // To ensure these two methods are called before the handler returns,
@@ -29,8 +28,8 @@ const createAuthRouteHandlersFactory = ({ config: resourcesConfig, runtimeOption
29
28
  // In the Pages Router, the final response is handled by contextOrResponse
30
29
  return;
31
30
  }
32
- if ((0, utils_2.isNextRequest)(request) &&
33
- (0, utils_2.isAuthRoutesHandlersContext)(contextOrResponse)) {
31
+ if ((0, utils_1.isNextRequest)(request) &&
32
+ (0, utils_1.isAuthRoutesHandlersContext)(contextOrResponse)) {
34
33
  // In the App Router, the final response is constructed and returned
35
34
  return (0, handleAuthApiRouteRequestForAppRouter_1.handleAuthApiRouteRequestForAppRouter)({
36
35
  request,
@@ -50,21 +49,21 @@ const createAuthRouteHandlersFactory = ({ config: resourcesConfig, runtimeOption
50
49
  // origin validation should happen when createAuthRouteHandlers is being called to create
51
50
  // Auth API routes.
52
51
  if (!amplifyAppOrigin) {
53
- throw new adapter_core_1.AmplifyServerContextError({
52
+ throw new internals_1.AmplifyServerContextError({
54
53
  message: 'Could not find the AMPLIFY_APP_ORIGIN environment variable.',
55
54
  recoverySuggestion: 'Add the AMPLIFY_APP_ORIGIN environment variable to the `.env` file of your Next.js project.',
56
55
  });
57
56
  }
58
- if (!(0, utils_2.isValidOrigin)(amplifyAppOrigin)) {
59
- throw new adapter_core_1.AmplifyServerContextError({
57
+ if (!(0, utils_1.isValidOrigin)(amplifyAppOrigin)) {
58
+ throw new internals_1.AmplifyServerContextError({
60
59
  message: 'AMPLIFY_APP_ORIGIN environment variable contains an invalid origin string.',
61
60
  recoverySuggestion: 'Ensure the AMPLIFY_APP_ORIGIN environment variable is a valid origin string.',
62
61
  });
63
62
  }
64
63
  // OAuth config validation should happen when createAuthRouteHandlers is being called to create
65
64
  // Auth API routes.
66
- (0, utils_1.assertTokenProviderConfig)(resourcesConfig.Auth?.Cognito);
67
- (0, utils_1.assertOAuthConfig)(resourcesConfig.Auth.Cognito);
65
+ (0, internals_1.assertTokenProviderConfig)(resourcesConfig.Auth?.Cognito);
66
+ (0, internals_1.assertOAuthConfig)(resourcesConfig.Auth.Cognito);
68
67
  const { userPoolClientId } = resourcesConfig.Auth.Cognito;
69
68
  const { oauth: oAuthConfig } = resourcesConfig.Auth.Cognito.loginWith;
70
69
  const { cookies: setCookieOptions = {} } = runtimeOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"createAuthRouteHandlersFactory.js","sources":["../../../src/auth/createAuthRouteHandlersFactory.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.createAuthRouteHandlersFactory = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nconst utils_2 = require(\"./utils\");\nconst handleAuthApiRouteRequestForAppRouter_1 = require(\"./handleAuthApiRouteRequestForAppRouter\");\nconst handleAuthApiRouteRequestForPagesRouter_1 = require(\"./handleAuthApiRouteRequestForPagesRouter\");\nconst createAuthRouteHandlersFactory = ({ config: resourcesConfig, runtimeOptions = {}, amplifyAppOrigin, runWithAmplifyServerContext, }) => {\n const handleRequest = async ({ request, contextOrResponse, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n if ((0, utils_2.isNextApiRequest)(request) && (0, utils_2.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 (0, handleAuthApiRouteRequestForPagesRouter_1.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 ((0, utils_2.isNextRequest)(request) &&\n (0, utils_2.isAuthRoutesHandlersContext)(contextOrResponse)) {\n // In the App Router, the final response is constructed and returned\n return (0, handleAuthApiRouteRequestForAppRouter_1.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 adapter_core_1.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 (!(0, utils_2.isValidOrigin)(amplifyAppOrigin)) {\n throw new adapter_core_1.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 (0, utils_1.assertTokenProviderConfig)(resourcesConfig.Auth?.Cognito);\n (0, utils_1.assertOAuthConfig)(resourcesConfig.Auth.Cognito);\n const { userPoolClientId } = resourcesConfig.Auth.Cognito;\n const { oauth: oAuthConfig } = resourcesConfig.Auth.Cognito.loginWith;\n const { cookies: setCookieOptions = {} } = runtimeOptions;\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};\nexports.createAuthRouteHandlersFactory = createAuthRouteHandlersFactory;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC,CAAC;AAChD,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,uCAAuC,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACnG,MAAM,yCAAyC,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC;AACvG,MAAM,8BAA8B,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,GAAG,EAAE,EAAE,gBAAgB,EAAE,2BAA2B,GAAG,KAAK;AAC7I,IAAI,MAAM,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,6DAA6D;AACtF,gBAAgB,kBAAkB,EAAE,6FAA6F;AACjI,aAAa,CAAC,CAAC;AACf,SAAS;AACT,QAAQ,IAAI,CAAC,IAAI,OAAO,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAAE;AAC3D,YAAY,MAAM,IAAI,cAAc,CAAC,yBAAyB,CAAC;AAC/D,gBAAgB,OAAO,EAAE,4EAA4E;AACrG,gBAAgB,kBAAkB,EAAE,8EAA8E;AAClH,aAAa,CAAC,CAAC;AACf,SAAS;AACT;AACA;AACA,QAAQ,IAAI,OAAO,CAAC,yBAAyB,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9E,QAAQ,IAAI,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACrE,QAAQ,MAAM,EAAE,gBAAgB,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;AAClE,QAAQ,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;AAC9E,QAAQ,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,cAAc,CAAC;AAClE;AACA,QAAQ,OAAO,CAAC,OAAO,EAAE,iBAAiB,KAAK,aAAa,CAAC;AAC7D,YAAY,OAAO;AACnB,YAAY,iBAAiB;AAC7B,YAAY,YAAY,EAAE,6BAA6B;AACvD,YAAY,gBAAgB;AAC5B,YAAY,WAAW;AACvB,YAAY,gBAAgB;AAC5B,YAAY,MAAM,EAAE,gBAAgB;AACpC,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,8BAA8B,GAAG,8BAA8B;;"}
1
+ {"version":3,"file":"createAuthRouteHandlersFactory.js","sources":["../../../src/auth/createAuthRouteHandlersFactory.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.createAuthRouteHandlersFactory = void 0;\nconst internals_1 = require(\"aws-amplify/adapter-core/internals\");\nconst utils_1 = require(\"./utils\");\nconst handleAuthApiRouteRequestForAppRouter_1 = require(\"./handleAuthApiRouteRequestForAppRouter\");\nconst handleAuthApiRouteRequestForPagesRouter_1 = require(\"./handleAuthApiRouteRequestForPagesRouter\");\nconst createAuthRouteHandlersFactory = ({ config: resourcesConfig, runtimeOptions = {}, amplifyAppOrigin, runWithAmplifyServerContext, }) => {\n const handleRequest = async ({ request, contextOrResponse, handlerInput, userPoolClientId, oAuthConfig, setCookieOptions, origin, }) => {\n if ((0, utils_1.isNextApiRequest)(request) && (0, utils_1.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 (0, handleAuthApiRouteRequestForPagesRouter_1.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 ((0, utils_1.isNextRequest)(request) &&\n (0, utils_1.isAuthRoutesHandlersContext)(contextOrResponse)) {\n // In the App Router, the final response is constructed and returned\n return (0, handleAuthApiRouteRequestForAppRouter_1.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 internals_1.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 (!(0, utils_1.isValidOrigin)(amplifyAppOrigin)) {\n throw new internals_1.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 (0, internals_1.assertTokenProviderConfig)(resourcesConfig.Auth?.Cognito);\n (0, internals_1.assertOAuthConfig)(resourcesConfig.Auth.Cognito);\n const { userPoolClientId } = resourcesConfig.Auth.Cognito;\n const { oauth: oAuthConfig } = resourcesConfig.Auth.Cognito.loginWith;\n const { cookies: setCookieOptions = {} } = runtimeOptions;\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};\nexports.createAuthRouteHandlersFactory = createAuthRouteHandlersFactory;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC,CAAC;AAChD,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAClE,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,uCAAuC,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACnG,MAAM,yCAAyC,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC;AACvG,MAAM,8BAA8B,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,GAAG,EAAE,EAAE,gBAA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ule", { value: true });
6
6
  exports.createAuthFlowProofs = void 0;
7
- const utils_1 = require("@aws-amplify/core/internals/utils");
7
+ const internals_1 = require("aws-amplify/adapter-core/internals");
8
8
  const adapter_core_1 = require("aws-amplify/adapter-core");
9
9
  const createAuthFlowProofs = ({ customState, }) => {
10
10
  const codeVerifier = (0, adapter_core_1.generateCodeVerifier)(128);
11
11
  const randomState = (0, adapter_core_1.generateState)();
12
12
  const state = customState
13
- ? `${randomState}-${(0, utils_1.urlSafeEncode)(customState)}`
13
+ ? `${randomState}-${(0, internals_1.urlSafeEncode)(customState)}`
14
14
  : randomState;
15
15
  return { codeVerifier, state };
16
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"createAuthFlowProofs.js","sources":["../../../../src/auth/utils/createAuthFlowProofs.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.createAuthFlowProofs = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst adapter_core_1 = require(\"aws-amplify/adapter-core\");\nconst createAuthFlowProofs = ({ customState, }) => {\n const codeVerifier = (0, adapter_core_1.generateCodeVerifier)(128);\n const randomState = (0, adapter_core_1.generateState)();\n const state = customState\n ? `${randomState}-${(0, utils_1.urlSafeEncode)(customState)}`\n : randomState;\n return { codeVerifier, state };\n};\nexports.createAuthFlowProofs = createAuthFlowProofs;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACtC,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC3D,MAAM,oBAAoB,GAAG,CAAC,EAAE,WAAW,GAAG,KAAK;AACnD,IAAI,MAAM,YAAY,GAAG,IAAI,cAAc,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;AACvE,IAAI,MAAM,WAAW,GAAG,IAAI,cAAc,CAAC,aAAa,GAAG,CAAC;AAC5D,IAAI,MAAM,KAAK,GAAG,WAAW;AAC7B,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AACrE,UAAU,WAAW,CAAC;AACtB,IAAI,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
1
+ {"version":3,"file":"createAuthFlowProofs.js","sources":["../../../../src/auth/utils/createAuthFlowProofs.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.createAuthFlowProofs = void 0;\nconst internals_1 = require(\"aws-amplify/adapter-core/internals\");\nconst adapter_core_1 = require(\"aws-amplify/adapter-core\");\nconst createAuthFlowProofs = ({ customState, }) => {\n const codeVerifier = (0, adapter_core_1.generateCodeVerifier)(128);\n const randomState = (0, adapter_core_1.generateState)();\n const state = customState\n ? `${randomState}-${(0, internals_1.urlSafeEncode)(customState)}`\n : randomState;\n return { codeVerifier, state };\n};\nexports.createAuthFlowProofs = createAuthFlowProofs;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACtC,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAClE,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC3D,MAAM,oBAAoB,GAAG,CAAC,EAAE,WAAW,GAAG,KAAK;AACnD,IAAI,MAAM,YAAY,GAAG,IAAI,cAAc,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;AACvE,IAAI,MAAM,WAAW,GAAG,IAAI,cAAc,CAAC,aAAa,GAAG,CAAC;AAC5D,IAAI,MAAM,KAAK,GAAG,WAAW;AAC7B,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,IAAI,WAAW,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AACzE,UAAU,WAAW,CAAC;AACtB,IAAI,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
@@ -4,7 +4,7 @@
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getAccessTokenUsername = void 0;
7
- const core_1 = require("@aws-amplify/core");
8
- const getAccessTokenUsername = (accessToken) => (0, core_1.decodeJWT)(accessToken).payload.username;
7
+ const internals_1 = require("aws-amplify/adapter-core/internals");
8
+ const getAccessTokenUsername = (accessToken) => (0, internals_1.decodeJWT)(accessToken).payload.username;
9
9
  exports.getAccessTokenUsername = getAccessTokenUsername;
10
10
  //# sourceMappingURL=getAccessTokenUsername.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getAccessTokenUsername.js","sources":["../../../../src/auth/utils/getAccessTokenUsername.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.getAccessTokenUsername = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst getAccessTokenUsername = (accessToken) => (0, core_1.decodeJWT)(accessToken).payload.username;\nexports.getAccessTokenUsername = getAccessTokenUsername;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACxC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,sBAAsB,GAAG,CAAC,WAAW,KAAK,IAAI,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;AACpG,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
1
+ {"version":3,"file":"getAccessTokenUsername.js","sources":["../../../../src/auth/utils/getAccessTokenUsername.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.getAccessTokenUsername = void 0;\nconst internals_1 = require(\"aws-amplify/adapter-core/internals\");\nconst getAccessTokenUsername = (accessToken) => (0, internals_1.decodeJWT)(accessToken).payload.username;\nexports.getAccessTokenUsername = getAccessTokenUsername;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACxC,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAClE,MAAM,sBAAsB,GAAG,CAAC,WAAW,KAAK,IAAI,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;AACzG,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
@@ -4,7 +4,7 @@
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolveRedirectSignOutUrl = exports.resolveRedirectSignInUrl = void 0;
7
- const adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
7
+ const internals_1 = require("aws-amplify/adapter-core/internals");
8
8
  const resolveRedirectSignInUrl = (origin, oAuthConfig) => {
9
9
  const redirectUrl = oAuthConfig.redirectSignIn.find(url => url.startsWith(origin));
10
10
  if (!redirectUrl) {
@@ -21,7 +21,7 @@ const resolveRedirectSignOutUrl = (origin, oAuthConfig) => {
21
21
  return redirectUrl;
22
22
  };
23
23
  exports.resolveRedirectSignOutUrl = resolveRedirectSignOutUrl;
24
- const createError = (urlType) => new adapter_core_1.AmplifyServerContextError({
24
+ const createError = (urlType) => new internals_1.AmplifyServerContextError({
25
25
  message: `No valid ${urlType} url found in the OAuth config.`,
26
26
  recoverySuggestion: `Check the OAuth config and ensure the ${urlType} url is valid.`,
27
27
  });
@@ -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 adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\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 adapter_core_1.AmplifyServerContextError({\n message: `No valid ${urlType}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,IAAI,kBAAkB,EAAE,CAAC,sCAAsC,EAAE,OAAO,CAAC,cAAc,CAAC;AACxF,CAAC,CAAC;;"}
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,CAAC;AAC9D,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,GAAG,KAAK,CAAC,CAAC;AAC9E,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAClE,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,CAAC;AACvF,IAAI,IAAI,CAAC,WAAW,EAAE;AACtB,QAAQ,MAAM,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAC5C,KAAK;AACL,IAAI,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AACF,OAAO,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;AAC5D,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,CAAC;AACxF,IAAI,IAAI,CAAC,WAAW,EAAE;AACtB,QAAQ,MAAM,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAC7C,KAAK;AACL,IAAI,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AACF,OAAO,CAAC,yBAAyB,GAAG,yBAAyB,CAAC;AAC9D,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;;"}
@@ -4,7 +4,7 @@
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createServerRunner = void 0;
7
- const utils_1 = require("@aws-amplify/core/internals/utils");
7
+ const utils_1 = require("aws-amplify/utils");
8
8
  const utils_2 = require("./utils");
9
9
  const createTokenValidator_1 = require("./utils/createTokenValidator");
10
10
  const auth_1 = require("./auth");
@@ -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/core/internals/utils\");\nconst utils_2 = require(\"./utils\");\nconst createTokenValidator_1 = require(\"./utils/createTokenValidator\");\nconst auth_1 = require(\"./auth\");\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 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 runtimeOptions,\n });\n return {\n runWithAmplifyServerContext,\n createAuthRouteHandlers: (0, auth_1.createAuthRouteHandlersFactory)({\n config: amplifyConfig,\n runtimeOptions,\n amplifyAppOrigin,\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,CAAC;AAC9D,OA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;AAC5B,YAAY,2BAA2B;AACvC,SAAS,CAAC;AACV,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
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\");\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 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 runtimeOptions,\n });\n return {\n runWithAmplifyServerContext,\n createAuthRouteHandlers: (0, auth_1.createAuthRouteHandlersFactory)({\n config: amplifyConfig,\n runtimeOptions,\n amplifyAppOrigin,\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,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AACvE,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC;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,CAAC;AAClE,IAAI,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAC5D,IAAI,IAAI,cAAc,CAAC;AACvB,IAAI,IAAI,aAAa,EAAE,IAAI,EAAE;AAC7B,QAAQ,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC;AAC/C,QAAQ,cAAc,GAAG,IAAI,sBAAsB,CAAC,oBAAoB,EAAE;AAC1E,YAAY,UAAU,EAAE,OAAO,EAAE,UAAU;AAC3C,YAAY,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;AACvD,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,2BAA2B,GAAG,IAAI,OAAO,CAAC,iCAAiC,EAAE;AACvF,QAAQ,MAAM,EAAE,aAAa;AAC7B,QAAQ,cAAc;AACtB,QAAQ,cAAc;AACtB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,2BAA2B;AACnC,QAAQ,uBAAuB,EAAE,IAAI,MAAM,CAAC,8BAA8B,EAAE;AAC5E,YAAY,MAAM,EAAE,aAAa;AACjC,YAAY,cAAc;AAC1B,YAAY,gBAAgB;AAC5B,YAAY,2BAA2B;AACvC,SAAS,CAAC;AACV,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
@@ -5,7 +5,7 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createCookieStorageAdapterFromNextServerContext = exports.DATE_IN_THE_PAST = void 0;
7
7
  const server_js_1 = require("next/server.js");
8
- const adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
8
+ const internals_1 = require("aws-amplify/adapter-core/internals");
9
9
  const cookie_1 = require("./cookie");
10
10
  exports.DATE_IN_THE_PAST = new Date(0);
11
11
  const createCookieStorageAdapterFromNextServerContext = async (context) => {
@@ -41,7 +41,7 @@ const createCookieStorageAdapterFromNextServerContext = async (context) => {
41
41
  return createCookieStorageAdapterFromNextCookies(cookies);
42
42
  }
43
43
  // This should not happen normally.
44
- throw new adapter_core_1.AmplifyServerContextError({
44
+ throw new internals_1.AmplifyServerContextError({
45
45
  message: 'Attempted to create cookie storage adapter from an unsupported Next.js server context.',
46
46
  });
47
47
  };
@@ -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 adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nconst cookie_1 = require(\"./cookie\");\nexports.DATE_IN_THE_PAST = new Date(0);\nconst createCookieStorageAdapterFromNextServerContext = async (context) => {\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);\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);\n }\n else {\n return createCookieStorageAdapterFromNextRequestAndHttpResponse(request, response);\n }\n }\n const { cookies } = context;\n if (typeof cookies === 'function') {\n return createCookieStorageAdapterFromNextCookies(cookies);\n }\n // This should not happen normally.\n throw new adapter_core_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) => {\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 mutableCookieStore.set((0, cookie_1.ensureEncodedForJSCookie)(name), value, options);\n },\n delete(name) {\n mutableCookieStore.delete((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n };\n};\nconst createCookieStorageAdapterFromNextRequestAndHttpResponse = (request, response) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = createMutableCookieStoreFromHeaders(response.headers);\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) => {\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 try {\n cookieStore.set((0, cookie_1.ensureEncodedForJSCookie)(name), value, options);\n }\n catch {\n // no-op\n }\n };\n const deleteFunc = name => {\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) => {\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 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 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) => {\n const setFunc = (name, value, options) => {\n headers.append('Set-Cookie', (0, cookie_1.serializeCookie)((0, cookie_1.ensureEncodedForJSCookie)(name), value, options));\n };\n const deleteFunc = name => {\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)];\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,+CAA+C,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAC5F,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC,OAAO,CAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AACvC,MAAM,+CAA+C,GAAG,OAAO,OAAO,KAAK;AAC3E,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,GAAG;AACX,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,QAAQ,CAAC,cAAc,CAAC,EAAE;AACzD,gBAAgB,OAAO;AACvB,aAAa;AACb,YAAY,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AAChE,SAAS;AACT,KAAK,CAAC;AACN,CAAC,CAAC;AACF,MAAM,mCAAmC,GAAG,CAAC,OAAO,KAAK;AACzD,IAAI,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,KAAK;AAC9C,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,CAAC;AAClI,KAAK,CAAC;AACN,IAAI,MAAM,UAAU,GAAG,IAAI,IAAI;AAC/B,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,CAAC;AAC3I,KAAK,CAAC;AACN,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,OAAO;AACpB,QAAQ,MAAM,EAAE,UAAU;AAC1B,KAAK,CAAC;AACN,CAAC,CAAC;AACF,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;;"}
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 cookie_1 = require(\"./cookie\");\nexports.DATE_IN_THE_PAST = new Date(0);\nconst createCookieStorageAdapterFromNextServerContext = async (context) => {\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);\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);\n }\n else {\n return createCookieStorageAdapterFromNextRequestAndHttpResponse(request, response);\n }\n }\n const { cookies } = context;\n if (typeof cookies === 'function') {\n return createCookieStorageAdapterFromNextCookies(cookies);\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) => {\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 mutableCookieStore.set((0, cookie_1.ensureEncodedForJSCookie)(name), value, options);\n },\n delete(name) {\n mutableCookieStore.delete((0, cookie_1.ensureEncodedForJSCookie)(name));\n },\n };\n};\nconst createCookieStorageAdapterFromNextRequestAndHttpResponse = (request, response) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = createMutableCookieStoreFromHeaders(response.headers);\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) => {\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 try {\n cookieStore.set((0, cookie_1.ensureEncodedForJSCookie)(name), value, options);\n }\n catch {\n // no-op\n }\n };\n const deleteFunc = name => {\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) => {\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 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 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) => {\n const setFunc = (name, value, options) => {\n headers.append('Set-Cookie', (0, cookie_1.serializeCookie)((0, cookie_1.ensureEncodedForJSCookie)(name), value, options));\n };\n const deleteFunc = name => {\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)];\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,+CAA+C,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAC5F,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAClE,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC,OAAO,CAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AACvC,MAAM,+CAA+C,GAAG,OAAO,OAAO,KAAK;AAC3E,IAAI,MAAM,EAAE,OAAO,EAA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plifyServerContext = void 0;
7
- const core_1 = require("@aws-amplify/core");
7
+ const utils_1 = require("aws-amplify/utils");
8
8
  const adapter_core_1 = require("aws-amplify/adapter-core");
9
9
  const createCookieStorageAdapterFromNextServerContext_1 = require("./createCookieStorageAdapterFromNextServerContext");
10
10
  const createRunWithAmplifyServerContext = ({ config: resourcesConfig, tokenValidator, runtimeOptions = {}, }) => {
@@ -21,7 +21,7 @@ const createRunWithAmplifyServerContext = ({ config: resourcesConfig, tokenValid
21
21
  // safe to use the singleton `MemoryKeyValueStorage` here, as the
22
22
  // static rendering uses the same unauthenticated role cross-sever.
23
23
  nextServerContext === null
24
- ? core_1.sharedInMemoryStorage
24
+ ? utils_1.sharedInMemoryStorage
25
25
  : (0, adapter_core_1.createKeyValueStorageFromCookieStorageAdapter)(await (0, createCookieStorageAdapterFromNextServerContext_1.createCookieStorageAdapterFromNextServerContext)(nextServerContext), tokenValidator, setCookieOptions);
26
26
  const credentialsProvider = (0, adapter_core_1.createAWSCredentialsAndIdentityIdProvider)(resourcesConfig.Auth, keyValueStorage);
27
27
  const tokenProvider = (0, adapter_core_1.createUserPoolsTokenProvider)(resourcesConfig.Auth, keyValueStorage);
@@ -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 core_1 = require(\"@aws-amplify/core\");\nconst adapter_core_1 = require(\"aws-amplify/adapter-core\");\nconst createCookieStorageAdapterFromNextServerContext_1 = require(\"./createCookieStorageAdapterFromNextServerContext\");\nconst createRunWithAmplifyServerContext = ({ config: resourcesConfig, tokenValidator, runtimeOptions = {}, }) => {\n const setCookieOptions = {\n ...runtimeOptions.cookies,\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 ? core_1.sharedInMemoryStorage\n : (0, adapter_core_1.createKeyValueStorageFromCookieStorageAdapter)(await (0, createCookieStorageAdapterFromNextServerContext_1.createCookieStorageAdapterFromNextServerContext)(nextServerContext), tokenValidator, setCookieOptions);\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,CAAC;AAC9D,OAAO,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AACnD,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC3D,MAAM,iDAAiD,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AACvH,MAAM,iCAAiC,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAG,EAAE,GAAG,KAAK;AACjH,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,GAAG,cAAc,CAAC,OAAO;AACjC,KAAK,CAAC;AACN,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,IAAI;AACtC,kBAAkB,MAAM,CAAC,qBAAqB;AAC9C,kBAAkB,IAAI,cAAc,CAAC,6CAA6C,EAAE,MAAM,IAAI,iDAAiD,CAAC,+CAA+C,EAAE,iBAAiB,CAAC,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;AACvP,YAAY,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAAC,yCAAyC,EAAE,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC7I,YAAY,MAAM,aAAa,GAAG,IAAI,cAAc,CAAC,4BAA4B,EAAE,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC1H,YAAY,OAAO,IAAI,cAAc,CAAC,2BAA2B,EAAE,eAAe,EAAE;AACpF,gBAAgB,IAAI,EAAE,EAAE,mBAAmB,EAAE,aAAa,EAAE;AAC5D,aAAa,EAAE,SAAS,CAAC,CAAC;AAC1B,SAAS;AACT;AACA;AACA,QAAQ,OAAO,IAAI,cAAc,CAAC,2BAA2B,EAAE,eAAe,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AAC/F,KAAK,CAAC;AACN,IAAI,OAAO,2BAA2B,CAAC;AACvC,CAAC,CAAC;AACF,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
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 createCookieStorageAdapterFromNextServerContext_1 = require(\"./createCookieStorageAdapterFromNextServerContext\");\nconst createRunWithAmplifyServerContext = ({ config: resourcesConfig, tokenValidator, runtimeOptions = {}, }) => {\n const setCookieOptions = {\n ...runtimeOptions.cookies,\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), tokenValidator, setCookieOptions);\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,CAAC;AAC9D,O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,EAAE,eAAe,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AAC/F,KAAK,CAAC;AACN,IAAI,OAAO,2BAA2B,CAAC;AACvC,CAAC,CAAC;AACF,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
@@ -1,4 +1,4 @@
1
- import { ResourcesConfig } from '@aws-amplify/core';
1
+ import { ResourcesConfig } from 'aws-amplify';
2
2
  import { NextServer } from '../types';
3
3
  export declare const createServerRunnerForAPI: ({ config, }: NextServer.CreateServerRunnerInput) => Omit<NextServer.CreateServerRunnerOutput, 'createAuthRouteHandlers'> & {
4
4
  resourcesConfig: ResourcesConfig;
@@ -1,4 +1,4 @@
1
- import { parseAmplifyConfig } from '@aws-amplify/core/internals/utils';
1
+ import { parseAmplifyConfig } from 'aws-amplify/utils';
2
2
  import { createRunWithAmplifyServerContext } from '../utils/createRunWithAmplifyServerContext.mjs';
3
3
  import 'aws-jwt-verify/error';
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"createServerRunnerForAPI.mjs","sources":["../../../src/api/createServerRunnerForAPI.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseAmplifyConfig } from '@aws-amplify/core/internals/utils';\nimport { createRunWithAmplifyServerContext } from '../utils';\nexport const createServerRunnerForAPI = ({ config, }) => {\n const amplifyConfig = parseAmplifyConfig(config);\n return {\n runWithAmplifyServerContext: createRunWithAmplifyServerContext({\n config: amplifyConfig,\n }),\n resourcesConfig: amplifyConfig,\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAGY,MAAC,wBAAwB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AACzD,IAAI,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACrD,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,iCAAiC,CAAC;AACvE,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,QAAQ,eAAe,EAAE,aAAa;AACtC,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"createServerRunnerForAPI.mjs","sources":["../../../src/api/createServerRunnerForAPI.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseAmplifyConfig } from 'aws-amplify/utils';\nimport { createRunWithAmplifyServerContext } from '../utils';\nexport const createServerRunnerForAPI = ({ config, }) => {\n const amplifyConfig = parseAmplifyConfig(config);\n return {\n runWithAmplifyServerContext: createRunWithAmplifyServerContext({\n config: amplifyConfig,\n }),\n resourcesConfig: amplifyConfig,\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAGY,MAAC,wBAAwB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AACzD,IAAI,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACrD,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,iCAAiC,CAAC;AACvE,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,QAAQ,eAAe,EAAE,aAAa;AACtC,KAAK,CAAC;AACN;;;;"}
@@ -1,5 +1,4 @@
1
- import { V6ClientSSRCookies, V6ClientSSRRequest } from '@aws-amplify/api-graphql';
2
- import { CommonPublicClientOptions, DefaultCommonClientOptions } from '@aws-amplify/api-graphql/internals';
1
+ import { CommonPublicClientOptions, DefaultCommonClientOptions, V6ClientSSRCookies, V6ClientSSRRequest } from 'aws-amplify/api/internals';
3
2
  import { NextServer } from '../types';
4
3
  interface CookiesClientParams {
5
4
  cookies: NextServer.ServerComponentContext['cookies'];
@@ -1,7 +1,7 @@
1
- import { generateClientWithAmplifyInstance } from '@aws-amplify/api/internals';
1
+ import { generateClientWithAmplifyInstance } from 'aws-amplify/api/internals';
2
2
  import { generateClient } from 'aws-amplify/api/server';
3
- import { AmplifyServerContextError, getAmplifyServerContext } from '@aws-amplify/core/internals/adapter-core';
4
- import { parseAmplifyConfig } from '@aws-amplify/core/internals/utils';
3
+ import { AmplifyServerContextError, getAmplifyServerContext } from 'aws-amplify/adapter-core/internals';
4
+ import { parseAmplifyConfig } from 'aws-amplify/utils';
5
5
  import { createServerRunnerForAPI } from './createServerRunnerForAPI.mjs';
6
6
 
7
7
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -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/core/internals/adapter-core';\nimport { parseAmplifyConfig } from '@aws-amplify/core/internals/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,CAAC;AACX,KAAK;AACL,IAAI,MAAM,EAAE,2BAA2B,EAAE,eAAe,EAAE,GAAG,wBAAwB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAClH;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,CAAC;AACP,IAAI,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;AACtE,IAAI,OAAO,iCAAiC,CAAC;AAC7C,QAAQ,OAAO,EAAE,UAAU;AAC3B,QAAQ,MAAM,EAAE,eAAe;AAC/B,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC,CAAC;AACP,CAAC;AACD;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,CAAC;AAC7D,IAAI,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;AACnD,IAAI,OAAO,cAAc,CAAC;AAC1B,QAAQ,MAAM,EAAE,aAAa;AAC7B,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC,CAAC;AACP;;;;"}
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,CAAC;AACX,KAAK;AACL,IAAI,MAAM,EAAE,2BAA2B,EAAE,eAAe,EAAE,GAAG,wBAAwB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAClH;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,CAAC;AACP,IAAI,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;AACtE,IAAI,OAAO,iCAAiC,CAAC;AAC7C,QAAQ,OAAO,EAAE,UAAU;AAC3B,QAAQ,MAAM,EAAE,eAAe;AAC/B,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC,CAAC;AACP,CAAC;AACD;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,CAAC;AAC7D,IAAI,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;AACnD,IAAI,OAAO,cAAc,CAAC;AAC1B,QAAQ,MAAM,EAAE,aAAa;AAC7B,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC,CAAC;AACP;;;;"}
@@ -1,4 +1,4 @@
1
- import { V6ClientSSRCookies, V6ClientSSRRequest } from '@aws-amplify/api-graphql';
1
+ import { V6ClientSSRCookies, V6ClientSSRRequest } from 'aws-amplify/api/internals';
2
2
  export { generateServerClientUsingReqRes, generateServerClientUsingCookies, } from './generateServerClient';
3
3
  type ClientUsingSSRCookies<T extends Record<any, any> = never> = V6ClientSSRCookies<T>;
4
4
  type ClientUsingSSRReq<T extends Record<any, any> = never> = V6ClientSSRRequest<T>;
@@ -1,7 +1,5 @@
1
- import { assertTokenProviderConfig, assertOAuthConfig } from '@aws-amplify/core/internals/utils';
2
- import { AmplifyServerContextError } from '@aws-amplify/core/internals/adapter-core';
1
+ import { AmplifyServerContextError, assertTokenProviderConfig, assertOAuthConfig } from 'aws-amplify/adapter-core/internals';
3
2
  import 'aws-amplify/adapter-core';
4
- import '@aws-amplify/core';
5
3
  import { isNextApiRequest, isNextApiResponse, isNextRequest, isAuthRoutesHandlersContext } from './utils/predicates.mjs';
6
4
  import 'aws-amplify/auth/server';
7
5
  import { isValidOrigin } from './utils/origin.mjs';
@@ -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 { assertOAuthConfig, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { AmplifyServerContextError, } from '@aws-amplify/core/internals/adapter-core';\nimport { isAuthRoutesHandlersContext, isNextApiRequest, isNextApiResponse, isNextRequest, isValidOrigin, } from './utils';\nimport { handleAuthApiRouteRequestForAppRouter } from './handleAuthApiRouteRequestForAppRouter';\nimport { handleAuthApiRouteRequestForPagesRouter } from './handleAuthApiRouteRequestForPagesRouter';\nexport const createAuthRouteHandlersFactory = ({ config: resourcesConfig, runtimeOptions = {}, amplifyAppOrigin, runWithAmplifyServerContext, }) => {\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 { cookies: setCookieOptions = {} } = runtimeOptions;\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;AAMY,MAAC,8BAA8B,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,GAAG,EAAE,EAAE,gBAAgB,EAAE,2BAA2B,GAAG,KAAK;AACpJ,IAAI,MAAM,aAAa,GAAG,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE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BAAgB,OAAO,EAAE,4EAA4E;AACrG,gBAAgB,kBAAkB,EAAE,8EAA8E;AAClH,aAAa,CAAC,CAAC;AACf,SAAS;AACT;AACA;AACA,QAAQ,yBAAyB,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjE,QAAQ,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxD,QAAQ,MAAM,EAAE,gBAAgB,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;AAClE,QAAQ,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;AAC9E,QAAQ,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,cAAc,CAAC;AAClE;AACA,QAAQ,OAAO,CAAC,OAAO,EAAE,iBAAiB,KAAK,aAAa,CAAC;AAC7D,YAAY,OAAO;AACnB,YAAY,iBAAiB;AAC7B,YAAY,YAAY,EAAE,6BAA6B;AACvD,YAAY,gBAAgB;AAC5B,YAAY,WAAW;AACvB,YAAY,gBAAgB;AAC5B,YAAY,MAAM,EAAE,gBAAgB;AACpC,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN;;;;"}
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, runtimeOptions = {}, amplifyAppOrigin, runWithAmplifyServerContext, }) => {\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 { cookies: setCookieOptions = {} } = runtimeOptions;\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,cAAc,GAAG,EAAE,EAAE,gBAAgB,EAAE,2BAA2B,GAAG,KAAK;AACpJ,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,CAAC;AACf;AACA,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,IAAI,aAAa,CAAC,OAAO,CAAC;AAClC,YAAY,2BAA2B,CAAC,iBAAiB,CAAC,EAAE;AAC5D;AACA,YAAY,OAAO,qCAAqC,CAAC;AACzD,gBAAgB,OAAO;AACvB,gBAAgB,cAAc,EAAE,iBAAiB;AACjD,gBAAgB,YAAY;AAC5B,gBAAgB,gBAAgB;AAChC,gBAAgB,WAAW;AAC3B,gBAAgB,gBAAgB;AAChC,gBAAgB,MAAM;AACtB,gBAAg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C,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN;;;;"}
@@ -1,7 +1,5 @@
1
- import '@aws-amplify/core/internals/adapter-core';
2
- import '@aws-amplify/core/internals/utils';
1
+ import 'aws-amplify/adapter-core/internals';
3
2
  import 'aws-amplify/adapter-core';
4
- import '@aws-amplify/core';
5
3
  import { getRedirectOrDefault } from './utils/getRedirectOrDefault.mjs';
6
4
  import { hasActiveUserSessionWithAppRouter } from './utils/hasActiveUserSession.mjs';
7
5
  import { isSupportedAuthApiRoutePath } from './utils/isSupportedAuthApiRoutePath.mjs';
@@ -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 request,\n userPoolClientId,\n oAuthConfig,\n customState: handlerInput.customState,\n origin,\n setCookieOptions,\n type: 'signUp',\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 request,\n userPoolClientId,\n oAuthConfig,\n customState: handlerInput.customState,\n origin,\n setCookieOptions,\n type: 'signIn',\n });\n }\n case 'sign-out':\n return handleSignOutRequest({\n userPoolClientId,\n oAuthConfig,\n origin,\n setCookieOptions,\n });\n case 'sign-in-callback':\n return handleSignInCallbackRequest({\n request,\n handlerInput,\n oAuthConfig,\n origin,\n setCookieOptions,\n userPoolClientId,\n });\n case 'sign-out-callback':\n return handleSignOutCallbackRequest({\n request,\n handlerInput,\n oAuthConfig,\n userPoolClientId,\n setCookieOptions,\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,CAAC;AACnD,KAAK;AACL,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC;AACjD;AACA,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACnD,QAAQ,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACnD,KAAK;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B,CAAC,YAAY,CAAC,wBAAwB,CAAC;AAC7F,qBAAqB,CAAC;AACtB,iBAAiB,CAAC,CAAC;AACnB,aAAa;AACb,YAAY,OAAO,yBAAyB,CAAC;AAC7C,gBAAgB,OAAO;AACvB,gBAAgB,gBAAgB;AAChC,gBAAgB,WAAW;AAC3B,gBAAgB,WAAW,EAAE,YAAY,CAAC,WAAW;AACrD,gBAAgB,MAAM;AACtB,gBAAgB,gBAAgB;AAChC,gBAAgB,IAAI,EAAE,QAAQ;AAC9B,aAAa,CAAC,CAAC;AACf,SAAS;AACT,QAAQ,KAAK,UAAU;AACvB,YAAY,OAAO,oBAAoB,CAAC;AACxC,gBAAgB,gBAAgB;AAChC,gBAAgB,WAAW;AAC3B,gBAAgB,MAAM;AACtB,gBAAgB,gBAAgB;AAChC,aAAa,CAAC,CAAC;AACf,QAAQ,KAAK,kBAAkB;AAC/B,YAAY,OAAO,2BAA2B,CAAC;AAC/C,gBAAgB,OAAO;AACvB,gBAAgB,YAAY;AAC5B,gBAAgB,WAAW;AAC3B,gBAAgB,MAAM;AACtB,gBAAgB,gBAAgB;AAChC,gBAAgB,gBAAgB;AAChC,aAAa,CAAC,CAAC;AACf,QAAQ,KAAK,mBAAmB;AAChC,YAAY,OAAO,4BAA4B,CAAC;AAChD,gBAAgB,OAAO;AACvB,gBAAgB,YAAY;AAC5B,gBAAgB,WAAW;AAC3B,gBAAgB,gBAAgB;AAChC,gBAAgB,gBAAgB;AAChC,aAAa,CAAC,CAAC;AACf;AACA;AACA,KAAK;AACL;;;;"}
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 request,\n userPoolClientId,\n oAuthConfig,\n customState: handlerInput.customState,\n origin,\n setCookieOptions,\n type: 'signUp',\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 request,\n userPoolClientId,\n oAuthConfig,\n customState: handlerInput.customState,\n origin,\n setCookieOptions,\n type: 'signIn',\n });\n }\n case 'sign-out':\n return handleSignOutRequest({\n userPoolClientId,\n oAuthConfig,\n origin,\n setCookieOptions,\n });\n case 'sign-in-callback':\n return handleSignInCallbackRequest({\n request,\n handlerInput,\n oAuthConfig,\n origin,\n setCookieOptions,\n userPoolClientId,\n });\n case 'sign-out-callback':\n return handleSignOutCallbackRequest({\n request,\n handlerInput,\n oAuthConfig,\n userPoolClientId,\n setCookieOptions,\n });\n // default:\n // is unreachable by the guard of isSupportedAuthApiRoutePath()\n }\n};\n"],"names":[],"mappings":";;;;;;;;;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