Skip to content

Commit 08a01dd

Browse files
authored
release(required): Amplify JS release (#14473)
2 parents 9417313 + ce2ce10 commit 08a01dd

File tree

21 files changed

+2122
-1756
lines changed

21 files changed

+2122
-1756
lines changed

.github/actions/node-and-build/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ inputs:
77
runs:
88
using: 'composite'
99
steps:
10-
- name: Setup Node.js 20
11-
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
10+
- name: Setup Node.js 22
11+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1212
with:
13-
node-version: 20
13+
node-version: 22
1414
env:
1515
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
1616
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0

.github/dependency-review/dependency-review-config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
allow-licenses:
22
- '0BSD'
33
- 'Apache-2.0'
4-
- 'Apache-2.0 AND MIT'
54
- 'BlueOak-1.0.0'
65
- 'BSD-1-Clause'
76
- 'BSD-2-Clause-FreeBSD'
@@ -14,7 +13,6 @@ allow-licenses:
1413
- 'CC0-1.0'
1514
- 'curl'
1615
- 'ISC'
17-
- 'ISC AND MIT'
1816
- 'JSON'
1917
- 'MIT'
2018
- 'OpenSSL'

.github/workflows/callable-dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ jobs:
1616
- name: 'Checkout Repository'
1717
uses: actions/checkout@e2a5a1afd5d7305b13671410c52a31819ab9fad9 # v4.0.0 https://github.com/actions/checkout/commit/e2a5a1afd5d7305b13671410c52a31819ab9fad9
1818
- name: 'Dependency Review'
19-
uses: actions/dependency-review-action@7bbfa034e752445ea40215fff1c3bf9597993d3f # v3.1.3 https://github.com/actions/dependency-review-action/commit/7bbfa034e752445ea40215fff1c3bf9597993d3f
19+
uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1 https://github.com/actions/dependency-review-action/commit/[hash]
2020
with:
2121
config-file: '.github/dependency-review/dependency-review-config.yml'

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,15 @@
140140
"nx": "16.7.0",
141141
"xml2js": "0.5.0",
142142
"tar": "6.2.1",
143-
"**/cross-spawn": "7.0.5"
143+
"**/cross-spawn": "7.0.5",
144+
"**/brace-expansion": "1.1.12",
145+
"**/on-headers": "1.1.0",
146+
"**/form-data": "4.0.4"
144147
},
145148
"overrides": {
146149
"tar": "6.2.1",
147-
"cross-spawn": "7.0.5"
150+
"cross-spawn": "7.0.5",
151+
"brace-expansion": "1.1.12"
148152
},
149153
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
150154
}

packages/adapter-nextjs/__tests__/auth/utils/predicates.test.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,124 @@ describe('isNextRequest', () => {
3939

4040
expect(isNextRequest(request)).toBe(true);
4141
});
42+
43+
it('returns true when the request is like a next request', () => {
44+
const mockNextRequest = {
45+
nextUrl: {
46+
pathname: '/api/auth',
47+
search: '?param=value',
48+
searchParams: new URLSearchParams('param=value'),
49+
href: 'https://example.com/api/auth?param=value',
50+
},
51+
cookies: {
52+
get: jest.fn(),
53+
set: jest.fn(),
54+
delete: jest.fn(),
55+
},
56+
url: 'https://example.com/api/auth?param=value',
57+
headers: new Headers({
58+
'content-type': 'application/json',
59+
'user-agent': 'test-agent',
60+
}),
61+
method: 'POST',
62+
body: null,
63+
bodyUsed: false,
64+
};
65+
66+
expect(isNextRequest(mockNextRequest)).toBe(true);
67+
});
68+
69+
it('returns false for regular Request objects without NextRequest properties', () => {
70+
const regularRequest = {
71+
headers: new Headers(),
72+
method: 'GET',
73+
url: 'https://example.com',
74+
};
75+
76+
expect(isNextRequest(regularRequest)).toBe(false);
77+
});
78+
79+
it('returns false for objects with nextUrl but missing other required properties', () => {
80+
const incompleteObject = {
81+
nextUrl: {
82+
pathname: '/test',
83+
search: '',
84+
},
85+
};
86+
87+
expect(isNextRequest(incompleteObject)).toBe(false);
88+
});
89+
90+
it('returns false for objects with malformed nextUrl', () => {
91+
const malformedNextUrl = {
92+
nextUrl: 'not-an-object',
93+
cookies: {},
94+
headers: new Headers(),
95+
method: 'GET',
96+
url: 'https://example.com',
97+
};
98+
99+
expect(isNextRequest(malformedNextUrl)).toBe(false);
100+
});
101+
102+
it('returns false for objects with null nextUrl', () => {
103+
const nullNextUrl = {
104+
nextUrl: null,
105+
cookies: {},
106+
headers: new Headers(),
107+
method: 'GET',
108+
url: 'https://example.com',
109+
};
110+
111+
expect(isNextRequest(nullNextUrl)).toBe(false);
112+
});
113+
114+
it('returns false for objects missing cookies property', () => {
115+
const missingCookies = {
116+
nextUrl: {
117+
pathname: '/test',
118+
search: '',
119+
},
120+
headers: new Headers(),
121+
method: 'GET',
122+
url: 'https://example.com',
123+
};
124+
125+
expect(isNextRequest(missingCookies)).toBe(false);
126+
});
127+
128+
it('returns false for objects with non-string method', () => {
129+
const invalidMethod = {
130+
nextUrl: {
131+
pathname: '/test',
132+
search: '',
133+
},
134+
cookies: {},
135+
headers: new Headers(),
136+
method: 123,
137+
url: 'https://example.com',
138+
};
139+
140+
expect(isNextRequest(invalidMethod)).toBe(false);
141+
});
142+
143+
it('returns false for objects with non-string url', () => {
144+
const invalidUrl = {
145+
nextUrl: {
146+
pathname: '/test',
147+
search: '',
148+
},
149+
cookies: {},
150+
headers: new Headers(),
151+
method: 'GET',
152+
url: 123,
153+
};
154+
155+
expect(isNextRequest(invalidUrl)).toBe(false);
156+
});
157+
158+
it('returns false for null or undefined inputs', () => {
159+
expect(isNextRequest(null as any)).toBe(false);
160+
expect(isNextRequest(undefined as any)).toBe(false);
161+
});
42162
});

packages/adapter-nextjs/src/auth/utils/predicates.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,25 @@ import { AuthRoutesHandlerContext } from '../types';
1010
export function isNextRequest(request: object): request is NextRequest {
1111
// NextRequest extends the Web Request API with additional convenience methods.
1212
// Details: https://nextjs.org/docs/app/api-reference/functions/next-request#nexturl
13-
return request instanceof Request && 'nextUrl' in request;
13+
//
14+
// Use duck typing instead of instanceof to handle Lambda/serverless environments
15+
// where Request constructor references may differ between invocations
16+
17+
return (
18+
typeof request === 'object' &&
19+
request !== null &&
20+
// NextRequest-specific properties
21+
'nextUrl' in request &&
22+
typeof request.nextUrl === 'object' &&
23+
request.nextUrl !== null &&
24+
'cookies' in request &&
25+
// Basic Request API properties
26+
'url' in request &&
27+
typeof request.url === 'string' &&
28+
'headers' in request &&
29+
'method' in request &&
30+
typeof request.method === 'string'
31+
);
1432
}
1533

1634
// AuthRoutesHandlersContext is the 2nd parameter type for the API route handlers in the App Router

packages/api-rest/__tests__/apis/common/publicApis.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,36 @@ describe('public APIs', () => {
192192
);
193193
});
194194

195+
if (!['HEAD'].includes(method.toUpperCase())) {
196+
it('should support body', async () => {
197+
await fn(mockAmplifyInstance, {
198+
apiName: 'restApi1',
199+
path: '/items',
200+
options: {
201+
body: {
202+
message: 'body',
203+
},
204+
},
205+
}).response;
206+
expect(mockAuthenticatedHandler).toHaveBeenCalledWith(
207+
{
208+
url: new URL(
209+
'https://123.execute-api.us-west-2.amazonaws.com/development/items',
210+
),
211+
method,
212+
headers: {
213+
'content-type': 'application/json; charset=UTF-8',
214+
},
215+
body: '{"message":"body"}',
216+
},
217+
expect.objectContaining({
218+
region: 'us-west-2',
219+
service: 'execute-api',
220+
}),
221+
);
222+
});
223+
}
224+
195225
it('should support path parameters', async () => {
196226
await fn(mockAmplifyInstance, {
197227
apiName: 'restApi1',

packages/api-rest/src/types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ export type GetInput = ApiInput<RestApiOptionsBase>;
66
export type PostInput = ApiInput<RestApiOptionsBase>;
77
export type PutInput = ApiInput<RestApiOptionsBase>;
88
export type PatchInput = ApiInput<RestApiOptionsBase>;
9-
export type DeleteInput = ApiInput<Omit<RestApiOptionsBase, 'body'>>;
9+
export type DeleteInput = ApiInput<RestApiOptionsBase>;
1010
export type HeadInput = ApiInput<Omit<RestApiOptionsBase, 'body'>>;
1111

1212
export type GetOperation = Operation<RestApiResponse>;
1313
export type PostOperation = Operation<RestApiResponse>;
1414
export type PutOperation = Operation<RestApiResponse>;
1515
export type PatchOperation = Operation<RestApiResponse>;
16-
export type DeleteOperation = Operation<Omit<RestApiResponse, 'body'>>;
16+
export type DeleteOperation = Operation<RestApiResponse>;
1717
export type HeadOperation = Operation<Omit<RestApiResponse, 'body'>>;
1818

1919
/**

0 commit comments

Comments
 (0)