@aws-amplify/adapter-nextjs 1.0.1-unstable.cfbde4c.0 → 1.0.2-unstable.ff4e8d7.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 (107) hide show
  1. package/api/package.json +4 -4
  2. package/{lib → dist/cjs}/api/createServerRunnerForAPI.js +3 -2
  3. package/dist/cjs/api/createServerRunnerForAPI.js.map +1 -0
  4. package/{lib → dist/cjs}/api/generateServerClient.js +3 -2
  5. package/dist/cjs/api/generateServerClient.js.map +1 -0
  6. package/{lib → dist/cjs}/api/index.js +3 -2
  7. package/dist/cjs/api/index.js.map +1 -0
  8. package/{lib → dist/cjs}/createServerRunner.js +4 -10
  9. package/dist/cjs/createServerRunner.js.map +1 -0
  10. package/{lib → dist/cjs}/index.js +3 -2
  11. package/dist/cjs/index.js.map +1 -0
  12. package/{lib → dist/cjs}/types/NextServer.js +3 -2
  13. package/dist/cjs/types/NextServer.js.map +1 -0
  14. package/{lib → dist/cjs}/types/index.js +3 -2
  15. package/dist/cjs/types/index.js.map +1 -0
  16. package/{lib → dist/cjs}/utils/createCookieStorageAdapterFromNextServerContext.js +5 -4
  17. package/dist/cjs/utils/createCookieStorageAdapterFromNextServerContext.js.map +1 -0
  18. package/{lib → dist/cjs}/utils/createRunWithAmplifyServerContext.js +3 -2
  19. package/dist/cjs/utils/createRunWithAmplifyServerContext.js.map +1 -0
  20. package/{lib → dist/cjs}/utils/getAmplifyConfig.js +3 -2
  21. package/dist/cjs/utils/getAmplifyConfig.js.map +1 -0
  22. package/{lib → dist/cjs}/utils/index.js +3 -2
  23. package/dist/cjs/utils/index.js.map +1 -0
  24. package/{lib-esm/api/createServerRunnerForAPI.js → dist/esm/api/createServerRunnerForAPI.mjs} +7 -3
  25. package/dist/esm/api/createServerRunnerForAPI.mjs.map +1 -0
  26. package/{lib-esm/api/generateServerClient.js → dist/esm/api/generateServerClient.mjs} +14 -8
  27. package/dist/esm/api/generateServerClient.mjs.map +1 -0
  28. package/dist/esm/api/index.mjs +2 -0
  29. package/dist/esm/api/index.mjs.map +1 -0
  30. package/{lib-esm/createServerRunner.js → dist/esm/createServerRunner.mjs} +8 -11
  31. package/dist/esm/createServerRunner.mjs.map +1 -0
  32. package/dist/esm/index.mjs +2 -0
  33. package/dist/esm/index.mjs.map +1 -0
  34. package/{lib-esm → dist/esm}/types/NextServer.d.ts +2 -2
  35. package/dist/esm/types/NextServer.mjs +2 -0
  36. package/dist/esm/types/NextServer.mjs.map +1 -0
  37. package/dist/esm/types/index.mjs +2 -0
  38. package/dist/esm/types/index.mjs.map +1 -0
  39. package/{lib-esm/utils/createCookieStorageAdapterFromNextServerContext.js → dist/esm/utils/createCookieStorageAdapterFromNextServerContext.mjs} +8 -5
  40. package/dist/esm/utils/createCookieStorageAdapterFromNextServerContext.mjs.map +1 -0
  41. package/{lib-esm/utils/createRunWithAmplifyServerContext.js → dist/esm/utils/createRunWithAmplifyServerContext.mjs} +12 -9
  42. package/dist/esm/utils/createRunWithAmplifyServerContext.mjs.map +1 -0
  43. package/{lib-esm/utils/getAmplifyConfig.js → dist/esm/utils/getAmplifyConfig.mjs} +6 -3
  44. package/dist/esm/utils/getAmplifyConfig.mjs.map +1 -0
  45. package/dist/esm/utils/index.mjs +3 -0
  46. package/dist/esm/utils/index.mjs.map +1 -0
  47. package/package.json +41 -43
  48. package/src/api/generateServerClient.ts +7 -1
  49. package/src/createServerRunner.ts +1 -10
  50. package/src/types/NextServer.ts +2 -2
  51. package/src/utils/createCookieStorageAdapterFromNextServerContext.ts +1 -1
  52. package/internals/package.json +0 -7
  53. package/lib/api/createServerRunnerForAPI.d.ts +0 -5
  54. package/lib/api/createServerRunnerForAPI.js.map +0 -1
  55. package/lib/api/generateServerClient.d.ts +0 -29
  56. package/lib/api/generateServerClient.js.map +0 -1
  57. package/lib/api/index.d.ts +0 -1
  58. package/lib/api/index.js.map +0 -1
  59. package/lib/createServerRunner.d.ts +0 -21
  60. package/lib/createServerRunner.js.map +0 -1
  61. package/lib/index.d.ts +0 -1
  62. package/lib/index.js.map +0 -1
  63. package/lib/internals/index.d.ts +0 -2
  64. package/lib/internals/index.js +0 -8
  65. package/lib/internals/index.js.map +0 -1
  66. package/lib/types/NextServer.d.ts +0 -70
  67. package/lib/types/NextServer.js.map +0 -1
  68. package/lib/types/index.d.ts +0 -1
  69. package/lib/types/index.js.map +0 -1
  70. package/lib/utils/createCookieStorageAdapterFromNextServerContext.d.ts +0 -4
  71. package/lib/utils/createCookieStorageAdapterFromNextServerContext.js.map +0 -1
  72. package/lib/utils/createRunWithAmplifyServerContext.d.ts +0 -5
  73. package/lib/utils/createRunWithAmplifyServerContext.js.map +0 -1
  74. package/lib/utils/getAmplifyConfig.d.ts +0 -3
  75. package/lib/utils/getAmplifyConfig.js.map +0 -1
  76. package/lib/utils/index.d.ts +0 -2
  77. package/lib/utils/index.js.map +0 -1
  78. package/lib-esm/api/createServerRunnerForAPI.js.map +0 -1
  79. package/lib-esm/api/generateServerClient.js.map +0 -1
  80. package/lib-esm/api/index.js +0 -4
  81. package/lib-esm/api/index.js.map +0 -1
  82. package/lib-esm/createServerRunner.js.map +0 -1
  83. package/lib-esm/index.js +0 -4
  84. package/lib-esm/index.js.map +0 -1
  85. package/lib-esm/internals/index.d.ts +0 -2
  86. package/lib-esm/internals/index.js +0 -4
  87. package/lib-esm/internals/index.js.map +0 -1
  88. package/lib-esm/types/NextServer.js +0 -4
  89. package/lib-esm/types/NextServer.js.map +0 -1
  90. package/lib-esm/types/index.js +0 -4
  91. package/lib-esm/types/index.js.map +0 -1
  92. package/lib-esm/utils/createCookieStorageAdapterFromNextServerContext.js.map +0 -1
  93. package/lib-esm/utils/createRunWithAmplifyServerContext.js.map +0 -1
  94. package/lib-esm/utils/getAmplifyConfig.js.map +0 -1
  95. package/lib-esm/utils/index.js +0 -5
  96. package/lib-esm/utils/index.js.map +0 -1
  97. package/src/internals/index.ts +0 -5
  98. /package/{lib-esm → dist/esm}/api/createServerRunnerForAPI.d.ts +0 -0
  99. /package/{lib-esm → dist/esm}/api/generateServerClient.d.ts +0 -0
  100. /package/{lib-esm → dist/esm}/api/index.d.ts +0 -0
  101. /package/{lib-esm → dist/esm}/createServerRunner.d.ts +0 -0
  102. /package/{lib-esm → dist/esm}/index.d.ts +0 -0
  103. /package/{lib-esm → dist/esm}/types/index.d.ts +0 -0
  104. /package/{lib-esm → dist/esm}/utils/createCookieStorageAdapterFromNextServerContext.d.ts +0 -0
  105. /package/{lib-esm → dist/esm}/utils/createRunWithAmplifyServerContext.d.ts +0 -0
  106. /package/{lib-esm → dist/esm}/utils/getAmplifyConfig.d.ts +0 -0
  107. /package/{lib-esm → dist/esm}/utils/index.d.ts +0 -0
package/api/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aws-amplify/adapter-nextjs/api",
3
- "main": "../lib/api/index.js",
4
- "browser": "../lib-esm/api/index.js",
5
- "module": "../lib-esm/api/index.js",
6
- "typings": "../lib-esm/api/index.d.ts"
3
+ "main": "../dist/cjs/api/index.js",
4
+ "browser": "../dist/esm/api/index.mjs",
5
+ "module": "../dist/esm/api/index.mjs",
6
+ "typings": "../dist/esm/api/index.d.ts"
7
7
  }
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -14,4 +15,4 @@ const createServerRunnerForAPI = ({ config, }) => {
14
15
  };
15
16
  };
16
17
  exports.createServerRunnerForAPI = createServerRunnerForAPI;
17
- //# sourceMappingURL=createServerRunnerForAPI.js.map
18
+ //# sourceMappingURL=createServerRunnerForAPI.js.map
@@ -0,0 +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(\"../utils\");\nconst createServerRunnerForAPI = ({ config, }) => {\n const amplifyConfig = (0, utils_1.getAmplifyConfig)(config);\n return {\n runWithAmplifyServerContext: (0, utils_1.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,UAAU,CAAC,CAAC;AACpC,MAAM,wBAAwB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AAClD,IAAI,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAChE,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,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -73,4 +74,4 @@ function generateServerClientUsingReqRes({ config }) {
73
74
  return client;
74
75
  }
75
76
  exports.generateServerClientUsingReqRes = generateServerClientUsingReqRes;
76
- //# sourceMappingURL=generateServerClient.js.map
77
+ //# sourceMappingURL=generateServerClient.js.map
@@ -0,0 +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 adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nconst api_graphql_1 = require(\"@aws-amplify/api-graphql\");\nconst createServerRunnerForAPI_1 = require(\"./createServerRunnerForAPI\");\nconst utils_1 = require(\"../utils\");\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({ config, cookies, }) {\n if (typeof 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 });\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 },\n operation: contextSpec => fn((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify),\n });\n return (0, internals_1.generateServerClient)({\n amplify: getAmplify,\n config: resourcesConfig,\n });\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();\n *\n * result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nfunction generateServerClientUsingReqRes({ config }) {\n const amplifyConfig = (0, utils_1.getAmplifyConfig)(config);\n // passing `null` instance because each (future model) method must retrieve a valid instance\n // from server context\n const client = (0, internals_1.generateServerClient)({\n amplify: null,\n config: amplifyConfig,\n });\n // TODO: improve this and the next type\n const prevGraphql = client.graphql;\n const wrappedGraphql = (contextSpec, options, additionalHeaders) => {\n const amplifyInstance = (0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify;\n return prevGraphql.call({ [api_graphql_1.__amplify]: amplifyInstance }, options, additionalHeaders);\n };\n client.graphql = wrappedGraphql;\n return client;\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,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,MAAM,aAAa,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC1D,MAAM,0BAA0B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACzE,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,gCAAgC,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,EAAE;AAChE,IAAI,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;AACvC,QAAQ,MAAM,IAA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AM,eAAe,GAAG,IAAI,cAAc,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC;AACjG,QAAQ,OAAO,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,GAAG,eAAe,EAAE,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAC5G,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,OAAO,GAAG,cAAc,CAAC;AACpC,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,+BAA+B,GAAG,+BAA+B;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6,4 +7,4 @@ exports.generateServerClientUsingCookies = exports.generateServerClientUsingReqR
6
7
  var generateServerClient_1 = require("./generateServerClient");
7
8
  Object.defineProperty(exports, "generateServerClientUsingReqRes", { enumerable: true, get: function () { return generateServerClient_1.generateServerClientUsingReqRes; } });
8
9
  Object.defineProperty(exports, "generateServerClientUsingCookies", { enumerable: true, get: function () { return generateServerClient_1.generateServerClientUsingCookies; } });
9
- //# sourceMappingURL=index.js.map
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/api/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateServerClientUsingCookies = exports.generateServerClientUsingReqRes = void 0;\nvar generateServerClient_1 = require(\"./generateServerClient\");\nObject.defineProperty(exports, \"generateServerClientUsingReqRes\", { enumerable: true, get: function () { return generateServerClient_1.generateServerClientUsingReqRes; } });\nObject.defineProperty(exports, \"generateServerClientUsingCookies\", { enumerable: true, get: function () { return generateServerClient_1.generateServerClientUsingCookies; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gCAAgC,GAAG,OAAO,CAAC,+BAA+B,GAAG,KAAK,CAAC,CAAC;AAC5F,IAAI,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC/D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iCAAiC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,sBAAsB,CAAC,+BAA+B,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7K,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kCAAkC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,sBAAsB,CAAC,gCAAgC,CAAC,EAAE,EAAE,CAAC;;"}
@@ -1,11 +1,10 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
5
6
  exports.createServerRunner = void 0;
6
- const adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
7
7
  const utils_1 = require("./utils");
8
- let amplifyConfig;
9
8
  /**
10
9
  * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context.
11
10
  *
@@ -26,12 +25,7 @@ let amplifyConfig;
26
25
  *
27
26
  */
28
27
  const createServerRunner = ({ config, }) => {
29
- if (amplifyConfig) {
30
- throw new adapter_core_1.AmplifyServerContextError({
31
- message: '`createServerRunner` needs to be called only once.',
32
- });
33
- }
34
- amplifyConfig = (0, utils_1.getAmplifyConfig)(config);
28
+ const amplifyConfig = (0, utils_1.getAmplifyConfig)(config);
35
29
  return {
36
30
  runWithAmplifyServerContext: (0, utils_1.createRunWithAmplifyServerContext)({
37
31
  config: amplifyConfig,
@@ -39,4 +33,4 @@ const createServerRunner = ({ config, }) => {
39
33
  };
40
34
  };
41
35
  exports.createServerRunner = createServerRunner;
42
- //# sourceMappingURL=createServerRunner.js.map
36
+ //# sourceMappingURL=createServerRunner.js.map
@@ -0,0 +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(\"./utils\");\n/**\n * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context.\n *\n * @remarks\n * This function should be called only once; you can use the returned `runWithAmplifyServerContext` across\n * your codebase.\n *\n * @param input The input used to create the `runWithAmplifyServerContext` function.\n * @param input.config The {@link ResourcesConfig} imported from the `amplifyconfiguration.json` file or manually\n * created.\n * @returns An object that contains the `runWithAmplifyServerContext` function.\n *\n * @example\n * import { createServerRunner } from '@aws-amplify/adapter-nextjs';\n * import config from './amplifyconfiguration.json';\n *\n * export const { runWithAmplifyServerContext } = createServerRunner({ config })\n *\n */\nconst createServerRunner = ({ config, }) => {\n const amplifyConfig = (0, utils_1.getAmplifyConfig)(config);\n return {\n runWithAmplifyServerContext: (0, utils_1.createRunWithAmplifyServerContext)({\n config: amplifyConfig,\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,SAAS,CAAC,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AAC5C,IAAI,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAChE,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,IAAI,OAAO,CAAC,iCAAiC,EAAE;AACpF,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
@@ -1,8 +1,9 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
5
6
  exports.createServerRunner = void 0;
6
7
  var createServerRunner_1 = require("./createServerRunner");
7
8
  Object.defineProperty(exports, "createServerRunner", { enumerable: true, get: function () { return createServerRunner_1.createServerRunner; } });
8
- //# sourceMappingURL=index.js.map
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createServerRunner = void 0;\nvar createServerRunner_1 = require(\"./createServerRunner\");\nObject.defineProperty(exports, \"createServerRunner\", { enumerable: true, get: function () { return createServerRunner_1.createServerRunner; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,IAAI,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC3D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,oBAAoB,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC;;"}
@@ -1,5 +1,6 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
5
- //# sourceMappingURL=NextServer.js.map
6
+ //# sourceMappingURL=NextServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NextServer.js","sources":["../../../src/types/NextServer.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 });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
@@ -1,5 +1,6 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
5
- //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/types/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
@@ -1,9 +1,10 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
5
6
  exports.createCookieStorageAdapterFromNextServerContext = exports.DATE_IN_THE_PAST = void 0;
6
- const server_1 = require("next/server");
7
+ const server_js_1 = require("next/server.js");
7
8
  const adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
8
9
  exports.DATE_IN_THE_PAST = new Date(0);
9
10
  const createCookieStorageAdapterFromNextServerContext = (context) => {
@@ -27,7 +28,7 @@ const createCookieStorageAdapterFromNextServerContext = (context) => {
27
28
  // The `NextRequest` and the `Proxy` are sharing the same interface by Next
28
29
  // implementation. So we don't need to detect the difference.
29
30
  if (request && response) {
30
- if (response instanceof server_1.NextResponse) {
31
+ if (response instanceof server_js_1.NextResponse) {
31
32
  return createCookieStorageAdapterFromNextRequestAndNextResponse(request, response);
32
33
  }
33
34
  else {
@@ -169,4 +170,4 @@ const serializeSetCookieOptions = (options) => {
169
170
  // The implementation is borrowed from js-cookie without escaping `[()]` as
170
171
  // we are not using those chars in the auth keys.
171
172
  const ensureEncodedForJSCookie = (name) => encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);
172
- //# sourceMappingURL=createCookieStorageAdapterFromNextServerContext.js.map
173
+ //# sourceMappingURL=createCookieStorageAdapterFromNextServerContext.js.map
@@ -0,0 +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\");\nexports.DATE_IN_THE_PAST = new Date(0);\nconst createCookieStorageAdapterFromNextServerContext = (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(ensureEncodedForJSCookie(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n set(name, value, options) {\n mutableCookieStore.set(ensureEncodedForJSCookie(name), value, options);\n },\n delete(name) {\n mutableCookieStore.delete(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(ensureEncodedForJSCookie(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n ...mutableCookieStore,\n };\n};\nconst createCookieStorageAdapterFromNextCookies = (cookies) => {\n const cookieStore = 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(ensureEncodedForJSCookie(name), value, options);\n }\n catch {\n // no-op\n }\n };\n const deleteFunc = name => {\n try {\n cookieStore.delete(ensureEncodedForJSCookie(name));\n }\n catch {\n // no-op\n }\n };\n return {\n get(name) {\n return cookieStore.get(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[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 response.setHeader('Set-Cookie', `${ensureEncodedForJSCookie(name)}=${value};${options ? serializeSetCookieOptions(options) : ''}`);\n },\n delete(name) {\n response.setHeader('Set-Cookie', `${ensureEncodedForJSCookie(name)}=;Expires=${exports.DATE_IN_THE_PAST.toUTCString()}`);\n },\n };\n};\nconst createMutableCookieStoreFromHeaders = (headers) => {\n const setFunc = (name, value, options) => {\n headers.append('Set-Cookie', `${ensureEncodedForJSCookie(name)}=${value};${options ? serializeSetCookieOptions(options) : ''}`);\n };\n const deleteFunc = name => {\n headers.append('Set-Cookie', `${ensureEncodedForJSCookie(name)}=;Expires=${exports.DATE_IN_THE_PAST.toUTCString()}`);\n };\n return {\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst serializeSetCookieOptions = (options) => {\n const { expires, domain, httpOnly, sameSite, secure } = options;\n const serializedOptions = [];\n if (domain) {\n serializedOptions.push(`Domain=${domain}`);\n }\n if (expires) {\n serializedOptions.push(`Expires=${expires.toUTCString()}`);\n }\n if (httpOnly) {\n serializedOptions.push(`HttpOnly`);\n }\n if (sameSite) {\n serializedOptions.push(`SameSite=${sameSite}`);\n }\n if (secure) {\n serializedOptions.push(`Secure`);\n }\n return serializedOptions.join(';');\n};\n// Ensures the cookie names are encoded in order to look up the cookie store\n// that is manipulated by js-cookie on the client side.\n// Details of the js-cookie encoding behavior see:\n// https://github.com/js-cookie/js-cookie#encoding\n// The implementation is borrowed from js-cookie without escaping `[()]` as\n// we are not using those chars in the auth keys.\nconst ensureEncodedForJSCookie = (name) => encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);\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,OAAO,CAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AACvC,MAAM,+CAA+C,GAAG,CAAC,OAAO,KAAK;AACrE,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,GAAG;AACX,QAAQ,GAAG;AACX,QAAQ,MAAM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CAAC,OAAO,KAAK;AAC/C,IAAI,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;AACpE,IAAI,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACjC,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,IAAI,OAAO,EAAE;AACjB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;AACnE,KAAK;AACL,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC3C,KAAK;AACL,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACvD,KAAK;AACL,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,wBAAwB,GAAG,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,kBAAkB,CAAC;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -32,4 +33,4 @@ const createRunWithAmplifyServerContext = ({ config: resourcesConfig, }) => {
32
33
  return runWithAmplifyServerContext;
33
34
  };
34
35
  exports.createRunWithAmplifyServerContext = createRunWithAmplifyServerContext;
35
- //# sourceMappingURL=createRunWithAmplifyServerContext.js.map
36
+ //# sourceMappingURL=createRunWithAmplifyServerContext.js.map
@@ -0,0 +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, }) => {\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)((0, createCookieStorageAdapterFromNextServerContext_1.createCookieStorageAdapterFromNextServerContext)(nextServerContext));\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,GAAG,KAAK;AAC5E,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,IAAI,iDAAiD,CAAC,+CAA+C,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAC/M,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,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,4 +9,4 @@ const getAmplifyConfig = (config) => Object.keys(config).some(key => key.startsW
8
9
  ? (0, utils_1.parseAWSExports)(config)
9
10
  : config;
10
11
  exports.getAmplifyConfig = getAmplifyConfig;
11
- //# sourceMappingURL=getAmplifyConfig.js.map
12
+ //# sourceMappingURL=getAmplifyConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAmplifyConfig.js","sources":["../../../src/utils/getAmplifyConfig.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.getAmplifyConfig = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst getAmplifyConfig = (config) => Object.keys(config).some(key => key.startsWith('aws_'))\n ? (0, utils_1.parseAWSExports)(config)\n : config;\nexports.getAmplifyConfig = getAmplifyConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAClC,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,gBAAgB,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5F,MAAM,IAAI,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC;AAC1C,MAAM,MAAM,CAAC;AACb,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -7,4 +8,4 @@ var getAmplifyConfig_1 = require("./getAmplifyConfig");
7
8
  Object.defineProperty(exports, "getAmplifyConfig", { enumerable: true, get: function () { return getAmplifyConfig_1.getAmplifyConfig; } });
8
9
  var createRunWithAmplifyServerContext_1 = require("./createRunWithAmplifyServerContext");
9
10
  Object.defineProperty(exports, "createRunWithAmplifyServerContext", { enumerable: true, get: function () { return createRunWithAmplifyServerContext_1.createRunWithAmplifyServerContext; } });
10
- //# sourceMappingURL=index.js.map
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/utils/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createRunWithAmplifyServerContext = exports.getAmplifyConfig = void 0;\nvar getAmplifyConfig_1 = require(\"./getAmplifyConfig\");\nObject.defineProperty(exports, \"getAmplifyConfig\", { enumerable: true, get: function () { return getAmplifyConfig_1.getAmplifyConfig; } });\nvar createRunWithAmplifyServerContext_1 = require(\"./createRunWithAmplifyServerContext\");\nObject.defineProperty(exports, \"createRunWithAmplifyServerContext\", { enumerable: true, get: function () { return createRunWithAmplifyServerContext_1.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,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAC9E,IAAI,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACvD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3I,IAAI,mCAAmC,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACzF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mCAAmC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mCAAmC,CAAC,iCAAiC,CAAC,EAAE,EAAE,CAAC;;"}
@@ -1,7 +1,9 @@
1
+ import { getAmplifyConfig } from '../utils/getAmplifyConfig.mjs';
2
+ import { createRunWithAmplifyServerContext } from '../utils/createRunWithAmplifyServerContext.mjs';
3
+
1
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
5
  // SPDX-License-Identifier: Apache-2.0
3
- import { createRunWithAmplifyServerContext, getAmplifyConfig } from '../utils';
4
- export const createServerRunnerForAPI = ({ config, }) => {
6
+ const createServerRunnerForAPI = ({ config, }) => {
5
7
  const amplifyConfig = getAmplifyConfig(config);
6
8
  return {
7
9
  runWithAmplifyServerContext: createRunWithAmplifyServerContext({
@@ -10,4 +12,6 @@ export const createServerRunnerForAPI = ({ config, }) => {
10
12
  resourcesConfig: amplifyConfig,
11
13
  };
12
14
  };
13
- //# sourceMappingURL=createServerRunnerForAPI.js.map
15
+
16
+ export { createServerRunnerForAPI };
17
+ //# sourceMappingURL=createServerRunnerForAPI.mjs.map
@@ -0,0 +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 { createRunWithAmplifyServerContext, getAmplifyConfig } from '../utils';\nexport const createServerRunnerForAPI = ({ config, }) => {\n const amplifyConfig = getAmplifyConfig(config);\n return {\n runWithAmplifyServerContext: createRunWithAmplifyServerContext({\n config: amplifyConfig,\n }),\n resourcesConfig: amplifyConfig,\n };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAEY,MAAC,wBAAwB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AACzD,IAAI,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACnD,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,10 +1,14 @@
1
+ import { generateServerClient } from '@aws-amplify/api/internals';
2
+ import { AmplifyServerContextError, getAmplifyServerContext } from '@aws-amplify/core/internals/adapter-core';
3
+ import { __amplify } from '@aws-amplify/api-graphql';
4
+ import { createServerRunnerForAPI } from './createServerRunnerForAPI.mjs';
5
+ import { getAmplifyConfig } from '../utils/getAmplifyConfig.mjs';
6
+ import '@aws-amplify/core';
7
+ import 'aws-amplify/adapter-core';
8
+ import 'next/server.js';
9
+
1
10
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
11
  // SPDX-License-Identifier: Apache-2.0
3
- import { generateServerClient } from '@aws-amplify/api/internals';
4
- import { getAmplifyServerContext, AmplifyServerContextError, } from '@aws-amplify/core/internals/adapter-core';
5
- import { __amplify, } from '@aws-amplify/api-graphql';
6
- import { createServerRunnerForAPI } from './createServerRunnerForAPI';
7
- import { getAmplifyConfig } from '../utils';
8
12
  /**
9
13
  * Generates an API client that can be used inside a Next.js Server Component with Dynamic Rendering
10
14
  *
@@ -14,7 +18,7 @@ import { getAmplifyConfig } from '../utils';
14
18
  * const client = generateServerClientUsingCookies({ cookies });
15
19
  * const result = await client.graphql({ query: listPosts });
16
20
  */
17
- export function generateServerClientUsingCookies({ config, cookies, }) {
21
+ function generateServerClientUsingCookies({ config, cookies, }) {
18
22
  if (typeof cookies !== 'function') {
19
23
  throw new AmplifyServerContextError({
20
24
  message: 'generateServerClientUsingCookies is only compatible with the `cookies` Dynamic Function available in Server Components.',
@@ -51,7 +55,7 @@ export function generateServerClientUsingCookies({ config, cookies, }) {
51
55
  * }),
52
56
  * });
53
57
  */
54
- export function generateServerClientUsingReqRes({ config }) {
58
+ function generateServerClientUsingReqRes({ config }) {
55
59
  const amplifyConfig = getAmplifyConfig(config);
56
60
  // passing `null` instance because each (future model) method must retrieve a valid instance
57
61
  // from server context
@@ -68,4 +72,6 @@ export function generateServerClientUsingReqRes({ config }) {
68
72
  client.graphql = wrappedGraphql;
69
73
  return client;
70
74
  }
71
- //# sourceMappingURL=generateServerClient.js.map
75
+
76
+ export { generateServerClientUsingCookies, generateServerClientUsingReqRes };
77
+ //# sourceMappingURL=generateServerClient.mjs.map
@@ -0,0 +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 { generateServerClient } from '@aws-amplify/api/internals';\nimport { getAmplifyServerContext, AmplifyServerContextError, } from '@aws-amplify/core/internals/adapter-core';\nimport { __amplify, } from '@aws-amplify/api-graphql';\nimport { createServerRunnerForAPI } from './createServerRunnerForAPI';\nimport { getAmplifyConfig } from '../utils';\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({ config, cookies, }) {\n if (typeof 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 });\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 },\n operation: contextSpec => fn(getAmplifyServerContext(contextSpec).amplify),\n });\n return generateServerClient({\n amplify: getAmplify,\n config: resourcesConfig,\n });\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();\n *\n * result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nexport function generateServerClientUsingReqRes({ config }) {\n const amplifyConfig = getAmplifyConfig(config);\n // passing `null` instance because each (future model) method must retrieve a valid instance\n // from server context\n const client = generateServerClient({\n amplify: null,\n config: amplifyConfig,\n });\n // TODO: improve this and the next type\n const prevGraphql = client.graphql;\n const wrappedGraphql = (contextSpec, options, additionalHeaders) => {\n const amplifyInstance = getAmplifyServerContext(contextSpec).amplify;\n return prevGraphql.call({ [__amplify]: amplifyInstance }, options, additionalHeaders);\n };\n client.graphql = wrappedGraphql;\n return client;\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAuB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;AAC7E,QAAQ,OAAO,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,eAAe,EAAE,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAC9F,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,OAAO,GAAG,cAAc,CAAC;AACpC,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
@@ -0,0 +1,2 @@
1
+ export { generateServerClientUsingCookies, generateServerClientUsingReqRes } from './generateServerClient.mjs';
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,8 +1,8 @@
1
+ import { getAmplifyConfig } from './utils/getAmplifyConfig.mjs';
2
+ import { createRunWithAmplifyServerContext } from './utils/createRunWithAmplifyServerContext.mjs';
3
+
1
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
5
  // SPDX-License-Identifier: Apache-2.0
3
- import { AmplifyServerContextError } from '@aws-amplify/core/internals/adapter-core';
4
- import { createRunWithAmplifyServerContext, getAmplifyConfig } from './utils';
5
- let amplifyConfig;
6
6
  /**
7
7
  * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context.
8
8
  *
@@ -22,17 +22,14 @@ let amplifyConfig;
22
22
  * export const { runWithAmplifyServerContext } = createServerRunner({ config })
23
23
  *
24
24
  */
25
- export const createServerRunner = ({ config, }) => {
26
- if (amplifyConfig) {
27
- throw new AmplifyServerContextError({
28
- message: '`createServerRunner` needs to be called only once.',
29
- });
30
- }
31
- amplifyConfig = getAmplifyConfig(config);
25
+ const createServerRunner = ({ config, }) => {
26
+ const amplifyConfig = getAmplifyConfig(config);
32
27
  return {
33
28
  runWithAmplifyServerContext: createRunWithAmplifyServerContext({
34
29
  config: amplifyConfig,
35
30
  }),
36
31
  };
37
32
  };
38
- //# sourceMappingURL=createServerRunner.js.map
33
+
34
+ export { createServerRunner };
35
+ //# sourceMappingURL=createServerRunner.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createServerRunner.mjs","sources":["../../src/createServerRunner.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createRunWithAmplifyServerContext, getAmplifyConfig } from './utils';\n/**\n * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context.\n *\n * @remarks\n * This function should be called only once; you can use the returned `runWithAmplifyServerContext` across\n * your codebase.\n *\n * @param input The input used to create the `runWithAmplifyServerContext` function.\n * @param input.config The {@link ResourcesConfig} imported from the `amplifyconfiguration.json` file or manually\n * created.\n * @returns An object that contains the `runWithAmplifyServerContext` function.\n *\n * @example\n * import { createServerRunner } from '@aws-amplify/adapter-nextjs';\n * import config from './amplifyconfiguration.json';\n *\n * export const { runWithAmplifyServerContext } = createServerRunner({ config })\n *\n */\nexport const createServerRunner = ({ config, }) => {\n const amplifyConfig = getAmplifyConfig(config);\n return {\n runWithAmplifyServerContext: createRunWithAmplifyServerContext({\n config: amplifyConfig,\n }),\n };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AACnD,IAAI,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACnD,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,iCAAiC,CAAC;AACvE,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,KAAK,CAAC;AACN;;;;"}
@@ -0,0 +1,2 @@
1
+ export { createServerRunner } from './createServerRunner.mjs';
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { GetServerSidePropsContext as NextGetServerSidePropsContext } from 'next';
2
- import { NextRequest, NextResponse } from 'next/server';
3
- import { cookies } from 'next/headers';
2
+ import { NextRequest, NextResponse } from 'next/server.js';
3
+ import { cookies } from 'next/headers.js';
4
4
  import { LegacyConfig } from 'aws-amplify/adapter-core';
5
5
  import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
6
6
  import { ResourcesConfig } from '@aws-amplify/core';
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=NextServer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NextServer.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,9 +1,10 @@
1
+ import { NextResponse } from 'next/server.js';
2
+ import { AmplifyServerContextError } from '@aws-amplify/core/internals/adapter-core';
3
+
1
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
5
  // SPDX-License-Identifier: Apache-2.0
3
- import { NextResponse } from 'next/server';
4
- import { AmplifyServerContextError, } from '@aws-amplify/core/internals/adapter-core';
5
- export const DATE_IN_THE_PAST = new Date(0);
6
- export const createCookieStorageAdapterFromNextServerContext = (context) => {
6
+ const DATE_IN_THE_PAST = new Date(0);
7
+ const createCookieStorageAdapterFromNextServerContext = (context) => {
7
8
  const { request: req, response: res } = context;
8
9
  // When the server context is from `getServerSideProps`, the `req` is an instance
9
10
  // of IncomingMessage, and the `res` is an instance of ServerResponse.
@@ -165,4 +166,6 @@ const serializeSetCookieOptions = (options) => {
165
166
  // The implementation is borrowed from js-cookie without escaping `[()]` as
166
167
  // we are not using those chars in the auth keys.
167
168
  const ensureEncodedForJSCookie = (name) => encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);
168
- //# sourceMappingURL=createCookieStorageAdapterFromNextServerContext.js.map
169
+
170
+ export { DATE_IN_THE_PAST, createCookieStorageAdapterFromNextServerContext };
171
+ //# sourceMappingURL=createCookieStorageAdapterFromNextServerContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCookieStorageAdapterFromNextServerContext.mjs","sources":["../../../src/utils/createCookieStorageAdapterFromNextServerContext.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { NextResponse } from 'next/server.js';\nimport { AmplifyServerContextError, } from '@aws-amplify/core/internals/adapter-core';\nexport const DATE_IN_THE_PAST = new Date(0);\nexport const createCookieStorageAdapterFromNextServerContext = (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 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 AmplifyServerContextError({\n message: 'Attempted to create cookie storage adapter from an unsupported Next.js server context.',\n });\n};\nconst createCookieStorageAdapterFromNextRequestAndNextResponse = (request, response) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = response.cookies;\n return {\n get(name) {\n return readonlyCookieStore.get(ensureEncodedForJSCookie(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n set(name, value, options) {\n mutableCookieStore.set(ensureEncodedForJSCookie(name), value, options);\n },\n delete(name) {\n mutableCookieStore.delete(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(ensureEncodedForJSCookie(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n ...mutableCookieStore,\n };\n};\nconst createCookieStorageAdapterFromNextCookies = (cookies) => {\n const cookieStore = 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(ensureEncodedForJSCookie(name), value, options);\n }\n catch {\n // no-op\n }\n };\n const deleteFunc = name => {\n try {\n cookieStore.delete(ensureEncodedForJSCookie(name));\n }\n catch {\n // no-op\n }\n };\n return {\n get(name) {\n return cookieStore.get(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[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 response.setHeader('Set-Cookie', `${ensureEncodedForJSCookie(name)}=${value};${options ? serializeSetCookieOptions(options) : ''}`);\n },\n delete(name) {\n response.setHeader('Set-Cookie', `${ensureEncodedForJSCookie(name)}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`);\n },\n };\n};\nconst createMutableCookieStoreFromHeaders = (headers) => {\n const setFunc = (name, value, options) => {\n headers.append('Set-Cookie', `${ensureEncodedForJSCookie(name)}=${value};${options ? serializeSetCookieOptions(options) : ''}`);\n };\n const deleteFunc = name => {\n headers.append('Set-Cookie', `${ensureEncodedForJSCookie(name)}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`);\n };\n return {\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst serializeSetCookieOptions = (options) => {\n const { expires, domain, httpOnly, sameSite, secure } = options;\n const serializedOptions = [];\n if (domain) {\n serializedOptions.push(`Domain=${domain}`);\n }\n if (expires) {\n serializedOptions.push(`Expires=${expires.toUTCString()}`);\n }\n if (httpOnly) {\n serializedOptions.push(`HttpOnly`);\n }\n if (sameSite) {\n serializedOptions.push(`SameSite=${sameSite}`);\n }\n if (secure) {\n serializedOptions.push(`Secure`);\n }\n return serializedOptions.join(';');\n};\n// Ensures the cookie names are encoded in order to look up the cookie store\n// that is manipulated by js-cookie on the client side.\n// Details of the js-cookie encoding behavior see:\n// https://github.com/js-cookie/js-cookie#encoding\n// The implementation is borrowed from js-cookie without escaping `[()]` as\n// we are not using those chars in the auth keys.\nconst ensureEncodedForJSCookie = (name) => encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE;AAChC,MAAC,+CAA+C,GAAG,CAAC,OAAO,KAAK;AAC5E,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,GAAG;AACX,QAAQ,GAAG;AAC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EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;AACpE,IAAI,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACjC,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,IAAI,OAAO,EAAE;AACjB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;AACnE,KAAK;AACL,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC3C,KAAK;AACL,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACvD,KAAK;AACL,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,wBAAwB,GAAG,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,kBAAkB,CAAC;;;;"}
@@ -1,10 +1,11 @@
1
+ import { sharedInMemoryStorage } from '@aws-amplify/core';
2
+ import { createKeyValueStorageFromCookieStorageAdapter, createAWSCredentialsAndIdentityIdProvider, createUserPoolsTokenProvider, runWithAmplifyServerContext } from 'aws-amplify/adapter-core';
3
+ import { createCookieStorageAdapterFromNextServerContext } from './createCookieStorageAdapterFromNextServerContext.mjs';
4
+
1
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
6
  // SPDX-License-Identifier: Apache-2.0
3
- import { sharedInMemoryStorage } from '@aws-amplify/core';
4
- import { createAWSCredentialsAndIdentityIdProvider, createKeyValueStorageFromCookieStorageAdapter, createUserPoolsTokenProvider, runWithAmplifyServerContext as runWithAmplifyServerContextCore, } from 'aws-amplify/adapter-core';
5
- import { createCookieStorageAdapterFromNextServerContext } from './createCookieStorageAdapterFromNextServerContext';
6
- export const createRunWithAmplifyServerContext = ({ config: resourcesConfig, }) => {
7
- const runWithAmplifyServerContext = async ({ nextServerContext, operation }) => {
7
+ const createRunWithAmplifyServerContext = ({ config: resourcesConfig, }) => {
8
+ const runWithAmplifyServerContext$1 = async ({ nextServerContext, operation }) => {
8
9
  // When the Auth config is presented, attempt to create a Amplify server
9
10
  // context with token and credentials provider.
10
11
  if (resourcesConfig.Auth) {
@@ -18,14 +19,16 @@ export const createRunWithAmplifyServerContext = ({ config: resourcesConfig, })
18
19
  : createKeyValueStorageFromCookieStorageAdapter(createCookieStorageAdapterFromNextServerContext(nextServerContext));
19
20
  const credentialsProvider = createAWSCredentialsAndIdentityIdProvider(resourcesConfig.Auth, keyValueStorage);
20
21
  const tokenProvider = createUserPoolsTokenProvider(resourcesConfig.Auth, keyValueStorage);
21
- return runWithAmplifyServerContextCore(resourcesConfig, {
22
+ return runWithAmplifyServerContext(resourcesConfig, {
22
23
  Auth: { credentialsProvider, tokenProvider },
23
24
  }, operation);
24
25
  }
25
26
  // Otherwise it may be the case that auth is not used, e.g. API key.
26
27
  // Omitting the `Auth` in the second parameter.
27
- return runWithAmplifyServerContextCore(resourcesConfig, {}, operation);
28
+ return runWithAmplifyServerContext(resourcesConfig, {}, operation);
28
29
  };
29
- return runWithAmplifyServerContext;
30
+ return runWithAmplifyServerContext$1;
30
31
  };
31
- //# sourceMappingURL=createRunWithAmplifyServerContext.js.map
32
+
33
+ export { createRunWithAmplifyServerContext };
34
+ //# sourceMappingURL=createRunWithAmplifyServerContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRunWithAmplifyServerContext.mjs","sources":["../../../src/utils/createRunWithAmplifyServerContext.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { sharedInMemoryStorage } from '@aws-amplify/core';\nimport { createAWSCredentialsAndIdentityIdProvider, createKeyValueStorageFromCookieStorageAdapter, createUserPoolsTokenProvider, runWithAmplifyServerContext as runWithAmplifyServerContextCore, } from 'aws-amplify/adapter-core';\nimport { createCookieStorageAdapterFromNextServerContext } from './createCookieStorageAdapterFromNextServerContext';\nexport const createRunWithAmplifyServerContext = ({ config: resourcesConfig, }) => {\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 ? sharedInMemoryStorage\n : createKeyValueStorageFromCookieStorageAdapter(createCookieStorageAdapterFromNextServerContext(nextServerContext));\n const credentialsProvider = createAWSCredentialsAndIdentityIdProvider(resourcesConfig.Auth, keyValueStorage);\n const tokenProvider = createUserPoolsTokenProvider(resourcesConfig.Auth, keyValueStorage);\n return runWithAmplifyServerContextCore(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 runWithAmplifyServerContextCore(resourcesConfig, {}, operation);\n };\n return runWithAmplifyServerContext;\n};\n"],"names":["runWithAmplifyServerContext","runWithAmplifyServerContextCore"],"mappings":";;;;AAAA;AACA;AAIY,MAAC,iCAAiC,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK;AACnF,IAAI,MAAMA,6BAA2B,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,qBAAqB;AACvC,kBAAkB,6CAA6C,CAAC,+CAA+C,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACpI,YAAY,MAAM,mBAAmB,GAAG,yCAAyC,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACzH,YAAY,MAAM,aAAa,GAAG,4BAA4B,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACtG,YAAY,OAAOC,2BAA+B,CAAC,eAAe,EAAE;AACpE,gBAAgB,IAAI,EAAE,EAAE,mBAAmB,EAAE,aAAa,EAAE;AAC5D,aAAa,EAAE,SAAS,CAAC,CAAC;AAC1B,SAAS;AACT;AACA;AACA,QAAQ,OAAOA,2BAA+B,CAAC,eAAe,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AAC/E,KAAK,CAAC;AACN,IAAI,OAAOD,6BAA2B,CAAC;AACvC;;;;"}
@@ -1,7 +1,10 @@
1
+ import { parseAWSExports } from '@aws-amplify/core/internals/utils';
2
+
1
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
4
  // SPDX-License-Identifier: Apache-2.0
3
- import { parseAWSExports } from '@aws-amplify/core/internals/utils';
4
- export const getAmplifyConfig = (config) => Object.keys(config).some(key => key.startsWith('aws_'))
5
+ const getAmplifyConfig = (config) => Object.keys(config).some(key => key.startsWith('aws_'))
5
6
  ? parseAWSExports(config)
6
7
  : config;
7
- //# sourceMappingURL=getAmplifyConfig.js.map
8
+
9
+ export { getAmplifyConfig };
10
+ //# sourceMappingURL=getAmplifyConfig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAmplifyConfig.mjs","sources":["../../../src/utils/getAmplifyConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseAWSExports } from '@aws-amplify/core/internals/utils';\nexport const getAmplifyConfig = (config) => Object.keys(config).some(key => key.startsWith('aws_'))\n ? parseAWSExports(config)\n : config;\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,gBAAgB,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACnG,MAAM,eAAe,CAAC,MAAM,CAAC;AAC7B,MAAM;;;;"}
@@ -0,0 +1,3 @@
1
+ export { getAmplifyConfig } from './getAmplifyConfig.mjs';
2
+ export { createRunWithAmplifyServerContext } from './createRunWithAmplifyServerContext.mjs';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}