@aws-amplify/adapter-nextjs 0.0.2-api-v6-rebase-2023-10-11.3fb8920.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.
- package/LICENSE +201 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/runWithAmplifyServerContext.d.ts +45 -0
- package/lib/runWithAmplifyServerContext.js +118 -0
- package/lib/runWithAmplifyServerContext.js.map +1 -0
- package/lib/types/NextServer.d.ts +59 -0
- package/lib/types/NextServer.js +5 -0
- package/lib/types/NextServer.js.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +5 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/createCookieStorageAdapterFromNextServerContext.d.ts +4 -0
- package/lib/utils/createCookieStorageAdapterFromNextServerContext.js +165 -0
- package/lib/utils/createCookieStorageAdapterFromNextServerContext.js.map +1 -0
- package/lib/utils/getAmplifyConfig.d.ts +2 -0
- package/lib/utils/getAmplifyConfig.js +35 -0
- package/lib/utils/getAmplifyConfig.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +10 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/withAmplify.d.ts +12 -0
- package/lib/withAmplify.js +35 -0
- package/lib/withAmplify.js.map +1 -0
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js +4 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/runWithAmplifyServerContext.d.ts +45 -0
- package/lib-esm/runWithAmplifyServerContext.js +114 -0
- package/lib-esm/runWithAmplifyServerContext.js.map +1 -0
- package/lib-esm/types/NextServer.d.ts +59 -0
- package/lib-esm/types/NextServer.js +4 -0
- package/lib-esm/types/NextServer.js.map +1 -0
- package/lib-esm/types/index.d.ts +1 -0
- package/lib-esm/types/index.js +4 -0
- package/lib-esm/types/index.js.map +1 -0
- package/lib-esm/utils/createCookieStorageAdapterFromNextServerContext.d.ts +4 -0
- package/lib-esm/utils/createCookieStorageAdapterFromNextServerContext.js +161 -0
- package/lib-esm/utils/createCookieStorageAdapterFromNextServerContext.js.map +1 -0
- package/lib-esm/utils/getAmplifyConfig.d.ts +2 -0
- package/lib-esm/utils/getAmplifyConfig.js +28 -0
- package/lib-esm/utils/getAmplifyConfig.js.map +1 -0
- package/lib-esm/utils/index.d.ts +2 -0
- package/lib-esm/utils/index.js +5 -0
- package/lib-esm/utils/index.js.map +1 -0
- package/lib-esm/withAmplify.d.ts +12 -0
- package/lib-esm/withAmplify.js +31 -0
- package/lib-esm/withAmplify.js.map +1 -0
- package/package.json +112 -0
- package/src/index.ts +4 -0
- package/src/runWithAmplifyServerContext.ts +103 -0
- package/src/types/NextServer.ts +78 -0
- package/src/types/index.ts +4 -0
- package/src/utils/createCookieStorageAdapterFromNextServerContext.ts +218 -0
- package/src/utils/getAmplifyConfig.ts +35 -0
- package/src/utils/index.ts +5 -0
- package/src/withAmplify.ts +36 -0
- package/with-amplify/package.json +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { runWithAmplifyServerContext } from './runWithAmplifyServerContext';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.runWithAmplifyServerContext = void 0;
|
|
6
|
+
var runWithAmplifyServerContext_1 = require("./runWithAmplifyServerContext");
|
|
7
|
+
Object.defineProperty(exports, "runWithAmplifyServerContext", { enumerable: true, get: function () { return runWithAmplifyServerContext_1.runWithAmplifyServerContext; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;AAEtC,6EAA4E;AAAnE,0IAAA,2BAA2B,OAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { NextServer } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Runs the {@link operation} with the the context created from the {@link nextServerContext}.
|
|
4
|
+
*
|
|
5
|
+
* @param input The input to call the {@link runWithAmplifyServerContext}.
|
|
6
|
+
* @param input.nextServerContext The Next.js server context. It varies depends
|
|
7
|
+
* where the {@link runWithAmplifyServerContext} is being called.
|
|
8
|
+
* - In the [middleware](https://nextjs.org/docs/app/building-your-application/routing/middleware):
|
|
9
|
+
* the context consists of an instance of the `NextRequest` and an instance
|
|
10
|
+
* of the `NextResponse`.
|
|
11
|
+
* - In a [Page server component](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts#pages):
|
|
12
|
+
* the context is the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
|
|
13
|
+
* function provided by Next.js.
|
|
14
|
+
* - In a [Route Handler](https://nextjs.org/docs/app/building-your-application/routing/route-handlers):
|
|
15
|
+
* the context can be the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
|
|
16
|
+
* function or a combination of an instance of the `NextRequest` and an instance
|
|
17
|
+
* of the `NextResponse`.
|
|
18
|
+
* - In a [Server Action](https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations#how-server-actions-work):
|
|
19
|
+
* the context is the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
|
|
20
|
+
* function provided by Next.js.
|
|
21
|
+
* @param input.operation The function that contains the business logic calling
|
|
22
|
+
* Amplify APIs. It expects a `contextSpec` parameter.
|
|
23
|
+
* @returns The result returned by the {@link operation}.
|
|
24
|
+
* @example
|
|
25
|
+
* // Use the `fetchAuthSession` API in the Next.js `middleware`.
|
|
26
|
+
* import { NextRequest, NextResponse } from "next/server";
|
|
27
|
+
* import { fetchAuthSession } from "aws-amplify/auth/server";
|
|
28
|
+
* import { runWithAmplifyServerContext } from "@aws-amplify/adapter-nextjs";
|
|
29
|
+
|
|
30
|
+
* export async function middleware(request: NextRequest) {
|
|
31
|
+
* const response = NextResponse.next();
|
|
32
|
+
* const authenticated = await runWithAmplifyServerContext({
|
|
33
|
+
* nextServerContext: { request, response },
|
|
34
|
+
* operation: async (contextSpec) => {
|
|
35
|
+
* const session = await fetchAuthSession(contextSpec);
|
|
36
|
+
* return session.tokens !== undefined;
|
|
37
|
+
* }
|
|
38
|
+
* });
|
|
39
|
+
* if (authenticated) {
|
|
40
|
+
* return response;
|
|
41
|
+
* }
|
|
42
|
+
* return NextResponse.redirect(new URL('/sign-in', request.url));
|
|
43
|
+
* }
|
|
44
|
+
*/
|
|
45
|
+
export declare const runWithAmplifyServerContext: NextServer.RunOperationWithContext;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
14
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
15
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
16
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17
|
+
function step(op) {
|
|
18
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
19
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
20
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
21
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
22
|
+
switch (op[0]) {
|
|
23
|
+
case 0: case 1: t = op; break;
|
|
24
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
25
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
26
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
27
|
+
default:
|
|
28
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
29
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
30
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
31
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
32
|
+
if (t[2]) _.ops.pop();
|
|
33
|
+
_.trys.pop(); continue;
|
|
34
|
+
}
|
|
35
|
+
op = body.call(thisArg, _);
|
|
36
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
37
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.runWithAmplifyServerContext = void 0;
|
|
42
|
+
var utils_1 = require("./utils");
|
|
43
|
+
var core_1 = require("@aws-amplify/core");
|
|
44
|
+
var adapter_core_1 = require("aws-amplify/internals/adapter-core");
|
|
45
|
+
/**
|
|
46
|
+
* Runs the {@link operation} with the the context created from the {@link nextServerContext}.
|
|
47
|
+
*
|
|
48
|
+
* @param input The input to call the {@link runWithAmplifyServerContext}.
|
|
49
|
+
* @param input.nextServerContext The Next.js server context. It varies depends
|
|
50
|
+
* where the {@link runWithAmplifyServerContext} is being called.
|
|
51
|
+
* - In the [middleware](https://nextjs.org/docs/app/building-your-application/routing/middleware):
|
|
52
|
+
* the context consists of an instance of the `NextRequest` and an instance
|
|
53
|
+
* of the `NextResponse`.
|
|
54
|
+
* - In a [Page server component](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts#pages):
|
|
55
|
+
* the context is the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
|
|
56
|
+
* function provided by Next.js.
|
|
57
|
+
* - In a [Route Handler](https://nextjs.org/docs/app/building-your-application/routing/route-handlers):
|
|
58
|
+
* the context can be the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
|
|
59
|
+
* function or a combination of an instance of the `NextRequest` and an instance
|
|
60
|
+
* of the `NextResponse`.
|
|
61
|
+
* - In a [Server Action](https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations#how-server-actions-work):
|
|
62
|
+
* the context is the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
|
|
63
|
+
* function provided by Next.js.
|
|
64
|
+
* @param input.operation The function that contains the business logic calling
|
|
65
|
+
* Amplify APIs. It expects a `contextSpec` parameter.
|
|
66
|
+
* @returns The result returned by the {@link operation}.
|
|
67
|
+
* @example
|
|
68
|
+
* // Use the `fetchAuthSession` API in the Next.js `middleware`.
|
|
69
|
+
* import { NextRequest, NextResponse } from "next/server";
|
|
70
|
+
* import { fetchAuthSession } from "aws-amplify/auth/server";
|
|
71
|
+
* import { runWithAmplifyServerContext } from "@aws-amplify/adapter-nextjs";
|
|
72
|
+
|
|
73
|
+
* export async function middleware(request: NextRequest) {
|
|
74
|
+
* const response = NextResponse.next();
|
|
75
|
+
* const authenticated = await runWithAmplifyServerContext({
|
|
76
|
+
* nextServerContext: { request, response },
|
|
77
|
+
* operation: async (contextSpec) => {
|
|
78
|
+
* const session = await fetchAuthSession(contextSpec);
|
|
79
|
+
* return session.tokens !== undefined;
|
|
80
|
+
* }
|
|
81
|
+
* });
|
|
82
|
+
* if (authenticated) {
|
|
83
|
+
* return response;
|
|
84
|
+
* }
|
|
85
|
+
* return NextResponse.redirect(new URL('/sign-in', request.url));
|
|
86
|
+
* }
|
|
87
|
+
*/
|
|
88
|
+
var runWithAmplifyServerContext = function (_a) {
|
|
89
|
+
var nextServerContext = _a.nextServerContext, operation = _a.operation;
|
|
90
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
var amplifyConfig, keyValueStorage, credentialsProvider, tokenProvider;
|
|
92
|
+
return __generator(this, function (_b) {
|
|
93
|
+
amplifyConfig = (0, utils_1.getAmplifyConfig)();
|
|
94
|
+
// When the Auth config is presented, attempt to create a Amplify server
|
|
95
|
+
// context with token and credentials provider.
|
|
96
|
+
if (amplifyConfig.Auth) {
|
|
97
|
+
keyValueStorage =
|
|
98
|
+
// When `null` is passed as the value of `nextServerContext`, opt-in
|
|
99
|
+
// unauthenticated role (primarily for static rendering). It's
|
|
100
|
+
// safe to use the singleton `MemoryKeyValueStorage` here, as the
|
|
101
|
+
// static rendering uses the same unauthenticated role cross-sever.
|
|
102
|
+
nextServerContext === null
|
|
103
|
+
? core_1.sharedInMemoryStorage
|
|
104
|
+
: (0, adapter_core_1.createKeyValueStorageFromCookieStorageAdapter)((0, utils_1.createCookieStorageAdapterFromNextServerContext)(nextServerContext));
|
|
105
|
+
credentialsProvider = (0, adapter_core_1.createAWSCredentialsAndIdentityIdProvider)(amplifyConfig.Auth, keyValueStorage);
|
|
106
|
+
tokenProvider = (0, adapter_core_1.createUserPoolsTokenProvider)(amplifyConfig.Auth, keyValueStorage);
|
|
107
|
+
return [2 /*return*/, (0, adapter_core_1.runWithAmplifyServerContext)(amplifyConfig, {
|
|
108
|
+
Auth: { credentialsProvider: credentialsProvider, tokenProvider: tokenProvider },
|
|
109
|
+
}, operation)];
|
|
110
|
+
}
|
|
111
|
+
// Otherwise it may be the case that auth is not used, e.g. API key.
|
|
112
|
+
// Omitting the `Auth` in the second parameter.
|
|
113
|
+
return [2 /*return*/, (0, adapter_core_1.runWithAmplifyServerContext)(amplifyConfig, {}, operation)];
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
exports.runWithAmplifyServerContext = runWithAmplifyServerContext;
|
|
118
|
+
//# sourceMappingURL=runWithAmplifyServerContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runWithAmplifyServerContext.js","sourceRoot":"","sources":["../src/runWithAmplifyServerContext.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGtC,iCAGiB;AACjB,0CAA0D;AAC1D,mEAK4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACI,IAAM,2BAA2B,GACvC,UAAO,EAAgC;QAA9B,iBAAiB,uBAAA,EAAE,SAAS,eAAA;;;;YAM9B,aAAa,GAAG,IAAA,wBAAgB,GAAE,CAAC;YAEzC,wEAAwE;YACxE,+CAA+C;YAC/C,IAAI,aAAa,CAAC,IAAI,EAAE;gBACjB,eAAe;gBACpB,oEAAoE;gBACpE,8DAA8D;gBAC9D,iEAAiE;gBACjE,mEAAmE;gBACnE,iBAAiB,KAAK,IAAI;oBACzB,CAAC,CAAC,4BAAqB;oBACvB,CAAC,CAAC,IAAA,4DAA6C,EAC7C,IAAA,uDAA+C,EAAC,iBAAiB,CAAC,CACjE,CAAC;gBACA,mBAAmB,GAAG,IAAA,wDAAyC,EACpE,aAAa,CAAC,IAAI,EAClB,eAAe,CACf,CAAC;gBACI,aAAa,GAAG,IAAA,2CAA4B,EACjD,aAAa,CAAC,IAAI,EAClB,eAAe,CACf,CAAC;gBAEF,sBAAO,IAAA,0CAA+B,EACrC,aAAa,EACb;wBACC,IAAI,EAAE,EAAE,mBAAmB,qBAAA,EAAE,aAAa,eAAA,EAAE;qBAC5C,EACD,SAAS,CACT,EAAC;aACF;YAED,oEAAoE;YACpE,+CAA+C;YAC/C,sBAAO,IAAA,0CAA+B,EAAC,aAAa,EAAE,EAAE,EAAE,SAAS,CAAC,EAAC;;;CACrE,CAAC;AA3CU,QAAA,2BAA2B,+BA2CrC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { GetServerSidePropsContext as NextGetServerSidePropsContext } from 'next';
|
|
2
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
3
|
+
import { cookies } from 'next/headers';
|
|
4
|
+
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
5
|
+
export declare namespace NextServer {
|
|
6
|
+
/**
|
|
7
|
+
* This context is normally available in the following:
|
|
8
|
+
* - Next App Router [middleware](https://nextjs.org/docs/app/building-your-application/routing/middleware)
|
|
9
|
+
* - Next App Router [route handler](https://nextjs.org/docs/app/building-your-application/routing/route-handlers)
|
|
10
|
+
* when using `NextResponse` to create the response of the route handler
|
|
11
|
+
*/
|
|
12
|
+
type NextRequestAndNextResponseContext = {
|
|
13
|
+
request: NextRequest;
|
|
14
|
+
response: NextResponse;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* This context is normally available in the following:
|
|
18
|
+
* - Next App Router [route handler](https://nextjs.org/docs/app/building-your-application/routing/route-handlers)
|
|
19
|
+
* when using the Web API [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
20
|
+
* to create the response of the route handler
|
|
21
|
+
*/
|
|
22
|
+
type NextRequestAndResponseContext = {
|
|
23
|
+
request: NextRequest;
|
|
24
|
+
response: Response;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* This context is normally available in the following:
|
|
28
|
+
* - Next [Server Component](https://nextjs.org/docs/getting-started/react-essentials#server-components)
|
|
29
|
+
* where the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
|
|
30
|
+
* function can be imported and called
|
|
31
|
+
*/
|
|
32
|
+
type ServerComponentContext = {
|
|
33
|
+
cookies: typeof cookies;
|
|
34
|
+
};
|
|
35
|
+
type ServerActionContext = ServerComponentContext;
|
|
36
|
+
/**
|
|
37
|
+
* This context is normally available in the
|
|
38
|
+
* [`getServerSideProps`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props)
|
|
39
|
+
* function of the Next Pages Router.
|
|
40
|
+
*/
|
|
41
|
+
type GetServerSidePropsContext = {
|
|
42
|
+
request: NextGetServerSidePropsContext['req'];
|
|
43
|
+
response: NextGetServerSidePropsContext['res'];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The union of possible Next.js app server context types.
|
|
47
|
+
*/
|
|
48
|
+
type Context = NextRequestAndNextResponseContext | NextRequestAndResponseContext | ServerComponentContext | GetServerSidePropsContext;
|
|
49
|
+
/**
|
|
50
|
+
* The interface of the input of {@link RunOperationWithContext}.
|
|
51
|
+
*/
|
|
52
|
+
interface RunWithContextInput<OperationResult> {
|
|
53
|
+
nextServerContext: Context | null;
|
|
54
|
+
operation: (contextSpec: AmplifyServer.ContextSpec) => OperationResult | Promise<OperationResult>;
|
|
55
|
+
}
|
|
56
|
+
interface RunOperationWithContext {
|
|
57
|
+
<OperationResult>(input: RunWithContextInput<OperationResult>): Promise<OperationResult>;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextServer.js","sourceRoot":"","sources":["../../src/types/NextServer.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NextServer } from './NextServer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NextServer } from '../types';
|
|
2
|
+
import { CookieStorage } from '@aws-amplify/core/internals/adapter-core';
|
|
3
|
+
export declare const DATE_IN_THE_PAST: Date;
|
|
4
|
+
export declare const createCookieStorageAdapterFromNextServerContext: (context: NextServer.Context) => CookieStorage.Adapter;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var __assign = (this && this.__assign) || function () {
|
|
5
|
+
__assign = Object.assign || function(t) {
|
|
6
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
7
|
+
s = arguments[i];
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
9
|
+
t[p] = s[p];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign.apply(this, arguments);
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.createCookieStorageAdapterFromNextServerContext = exports.DATE_IN_THE_PAST = void 0;
|
|
17
|
+
var server_1 = require("next/server");
|
|
18
|
+
var adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
|
|
19
|
+
exports.DATE_IN_THE_PAST = new Date(0);
|
|
20
|
+
var createCookieStorageAdapterFromNextServerContext = function (context) {
|
|
21
|
+
var _a = context, req = _a.request, res = _a.response;
|
|
22
|
+
// When the server context is from `getServerSideProps`, the `req` is an instance
|
|
23
|
+
// of IncomingMessage, and the `res` is an instance of ServerResponse.
|
|
24
|
+
// We cannot import these two classes here from `http` as it breaks in Next
|
|
25
|
+
// Edge Runtime. Hence, we check the methods that we need to use for creating
|
|
26
|
+
// cookie adapter.
|
|
27
|
+
if (req &&
|
|
28
|
+
res &&
|
|
29
|
+
Object.prototype.toString.call(req.cookies) === '[object Object]' &&
|
|
30
|
+
typeof res.setHeader === 'function') {
|
|
31
|
+
return createCookieStorageAdapterFromGetServerSidePropsContext(req, res);
|
|
32
|
+
}
|
|
33
|
+
var _b = context, request = _b.request, response = _b.response;
|
|
34
|
+
// When the server context is from `middleware`, the `request` is an instance
|
|
35
|
+
// of `NextRequest`.
|
|
36
|
+
// When the server context is from a route handler, the `request` is an `Proxy`
|
|
37
|
+
// wrapped `Request`.
|
|
38
|
+
// The `NextRequest` and the `Proxy` are sharing the same interface by Next
|
|
39
|
+
// implementation. So we don't need to detect the difference.
|
|
40
|
+
if (request && response) {
|
|
41
|
+
if (response instanceof server_1.NextResponse) {
|
|
42
|
+
return createCookieStorageAdapterFromNextRequestAndNextResponse(request, response);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return createCookieStorageAdapterFromNextRequestAndHttpResponse(request, response);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var cookies = context.cookies;
|
|
49
|
+
if (typeof cookies === 'function') {
|
|
50
|
+
return createCookieStorageAdapterFromNextCookies(cookies);
|
|
51
|
+
}
|
|
52
|
+
// This should not happen normally.
|
|
53
|
+
throw new adapter_core_1.AmplifyServerContextError({
|
|
54
|
+
message: 'Attempted to create cookie storage adapter from an unsupported Next.js server context.',
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
exports.createCookieStorageAdapterFromNextServerContext = createCookieStorageAdapterFromNextServerContext;
|
|
58
|
+
var createCookieStorageAdapterFromNextRequestAndNextResponse = function (request, response) {
|
|
59
|
+
var readonlyCookieStore = request.cookies;
|
|
60
|
+
var mutableCookieStore = response.cookies;
|
|
61
|
+
return {
|
|
62
|
+
get: readonlyCookieStore.get.bind(readonlyCookieStore),
|
|
63
|
+
getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),
|
|
64
|
+
set: mutableCookieStore.set.bind(mutableCookieStore),
|
|
65
|
+
delete: mutableCookieStore.delete.bind(mutableCookieStore),
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
var createCookieStorageAdapterFromNextRequestAndHttpResponse = function (request, response) {
|
|
69
|
+
var readonlyCookieStore = request.cookies;
|
|
70
|
+
var mutableCookieStore = createMutableCookieStoreFromHeaders(response.headers);
|
|
71
|
+
return __assign({ get: readonlyCookieStore.get.bind(readonlyCookieStore), getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore) }, mutableCookieStore);
|
|
72
|
+
};
|
|
73
|
+
var createCookieStorageAdapterFromNextCookies = function (cookies) {
|
|
74
|
+
var cookieStore = cookies();
|
|
75
|
+
// When Next cookies() is called in a server component, it returns a readonly
|
|
76
|
+
// cookie store. Hence calling set and delete throws an error. However,
|
|
77
|
+
// cookies() returns a mutable cookie store when called in a server action.
|
|
78
|
+
// We have no way to detect which one is returned, so we try to call set and delete
|
|
79
|
+
// and safely ignore the error if it is thrown.
|
|
80
|
+
var setFunc = function (name, value, options) {
|
|
81
|
+
try {
|
|
82
|
+
cookieStore.set(name, value, options);
|
|
83
|
+
}
|
|
84
|
+
catch (_a) {
|
|
85
|
+
// no-op
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var deleteFunc = function (name) {
|
|
89
|
+
try {
|
|
90
|
+
cookieStore.delete(name);
|
|
91
|
+
}
|
|
92
|
+
catch (_a) {
|
|
93
|
+
// no-op
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
get: cookieStore.get.bind(cookieStore),
|
|
98
|
+
getAll: cookieStore.getAll.bind(cookieStore),
|
|
99
|
+
set: setFunc,
|
|
100
|
+
delete: deleteFunc,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
var createCookieStorageAdapterFromGetServerSidePropsContext = function (request, response) {
|
|
104
|
+
var cookiesMap = __assign({}, request.cookies);
|
|
105
|
+
var allCookies = Object.entries(cookiesMap).map(function (_a) {
|
|
106
|
+
var name = _a[0], value = _a[1];
|
|
107
|
+
return ({
|
|
108
|
+
name: name,
|
|
109
|
+
value: value,
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
get: function (name) {
|
|
114
|
+
var value = cookiesMap[name];
|
|
115
|
+
return value
|
|
116
|
+
? {
|
|
117
|
+
name: name,
|
|
118
|
+
value: value,
|
|
119
|
+
}
|
|
120
|
+
: undefined;
|
|
121
|
+
},
|
|
122
|
+
getAll: function () {
|
|
123
|
+
return allCookies;
|
|
124
|
+
},
|
|
125
|
+
set: function (name, value, options) {
|
|
126
|
+
response.setHeader('Set-Cookie', "".concat(name, "=").concat(value, ";").concat(options ? serializeSetCookieOptions(options) : ''));
|
|
127
|
+
},
|
|
128
|
+
delete: function (name) {
|
|
129
|
+
response.setHeader('Set-Cookie', "".concat(name, "=;Expires=").concat(exports.DATE_IN_THE_PAST.toUTCString()));
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
var createMutableCookieStoreFromHeaders = function (headers) {
|
|
134
|
+
var setFunc = function (name, value, options) {
|
|
135
|
+
headers.append('Set-Cookie', "".concat(name, "=").concat(value, ";").concat(options ? serializeSetCookieOptions(options) : ''));
|
|
136
|
+
};
|
|
137
|
+
var deleteFunc = function (name) {
|
|
138
|
+
headers.append('Set-Cookie', "".concat(name, "=;Expires=").concat(exports.DATE_IN_THE_PAST.toUTCString()));
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
set: setFunc,
|
|
142
|
+
delete: deleteFunc,
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
var serializeSetCookieOptions = function (options) {
|
|
146
|
+
var expires = options.expires, maxAge = options.maxAge, domain = options.domain, httpOnly = options.httpOnly, sameSite = options.sameSite, secure = options.secure;
|
|
147
|
+
var serializedOptions = [];
|
|
148
|
+
if (domain) {
|
|
149
|
+
serializedOptions.push("Domain=".concat(domain));
|
|
150
|
+
}
|
|
151
|
+
if (expires) {
|
|
152
|
+
serializedOptions.push("Expires=".concat(expires.toUTCString()));
|
|
153
|
+
}
|
|
154
|
+
if (httpOnly) {
|
|
155
|
+
serializedOptions.push("HttpOnly");
|
|
156
|
+
}
|
|
157
|
+
if (sameSite) {
|
|
158
|
+
serializedOptions.push("SameSite=".concat(sameSite));
|
|
159
|
+
}
|
|
160
|
+
if (secure) {
|
|
161
|
+
serializedOptions.push("Secure");
|
|
162
|
+
}
|
|
163
|
+
return serializedOptions.join(';');
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=createCookieStorageAdapterFromNextServerContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCookieStorageAdapterFromNextServerContext.js","sourceRoot":"","sources":["../../src/utils/createCookieStorageAdapterFromNextServerContext.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;;;;;;;;;;;;AAEtC,sCAAwD;AAExD,yEAGkD;AAErC,QAAA,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AAErC,IAAM,+CAA+C,GAAG,UAC9D,OAA2B;IAErB,IAAA,KACL,OAAwD,EADxC,GAAG,aAAA,EAAY,GAAG,cACsB,CAAC;IAE1D,iFAAiF;IACjF,sEAAsE;IACtE,2EAA2E;IAC3E,6EAA6E;IAC7E,kBAAkB;IAClB,IACC,GAAG;QACH,GAAG;QACH,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IA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