wirejs-deploy-amplify-basic 0.1.167 → 0.1.169
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/amplify-backend-assets/api/handler.ts +1 -0
- package/amplify-backend-assets/backend.ts +1 -0
- package/amplify-hosting-assets/compute/default/index.js +46 -16
- package/amplify-hosting-assets/compute/default/package.json +1 -1
- package/dist/resources/distributed-table.d.ts +1 -0
- package/dist/resources/distributed-table.js +2 -1
- package/dist/services/authentication.js +12 -5
- package/package.json +2 -2
|
@@ -101,6 +101,7 @@ function extractSetCookies(context: Context) {
|
|
|
101
101
|
if (cookie.maxAge) cookieOptions.push(`Max-Age=${cookie.maxAge}`);
|
|
102
102
|
if (cookie.httpOnly) cookieOptions.push('HttpOnly');
|
|
103
103
|
if (cookie.secure) cookieOptions.push('Secure');
|
|
104
|
+
if (cookie.path) cookieOptions.push(`Path=${cookie.path}`);
|
|
104
105
|
cookies.push(`${cookie.name}=${cookie.value}; ${cookieOptions.join('; ')}`);
|
|
105
106
|
}
|
|
106
107
|
return cookies;
|
|
@@ -182,6 +182,7 @@ for (const resource of generated) {
|
|
|
182
182
|
removalPolicy: RemovalPolicy.RETAIN,
|
|
183
183
|
billingMode: BillingMode.PAY_PER_REQUEST,
|
|
184
184
|
pointInTimeRecovery: true,
|
|
185
|
+
timeToLiveAttribute: resource.options.ttlAttribute,
|
|
185
186
|
});
|
|
186
187
|
|
|
187
188
|
new TableIndexes(tableStack, `${tableName}Indexes`,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
|
+
import https from 'https';
|
|
2
3
|
import fs from 'fs';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
|
|
@@ -311,25 +312,54 @@ async function proxyRequest(context, res, targetUrl) {
|
|
|
311
312
|
const body = context.requestBody;
|
|
312
313
|
|
|
313
314
|
try {
|
|
314
|
-
const
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
315
|
+
const parsedUrl = new URL(targetUrl);
|
|
316
|
+
const isHttps = parsedUrl.protocol === 'https:';
|
|
317
|
+
const requester = isHttps ? https : http;
|
|
318
|
+
|
|
319
|
+
return await new Promise((resolve) => {
|
|
320
|
+
const req = requester.request({
|
|
321
|
+
hostname: parsedUrl.hostname,
|
|
322
|
+
port: parsedUrl.port || (isHttps ? 443 : 80),
|
|
323
|
+
path: parsedUrl.pathname + (parsedUrl.search || ''),
|
|
324
|
+
method,
|
|
325
|
+
headers,
|
|
326
|
+
}, (proxyRes) => {
|
|
327
|
+
res.statusCode = proxyRes.statusCode;
|
|
328
|
+
|
|
329
|
+
for (const [header, value] of Object.entries(proxyRes.headers)) {
|
|
330
|
+
if (header === 'x-wirejs-redirect') {
|
|
331
|
+
res.setHeader('Location', value);
|
|
332
|
+
} else {
|
|
333
|
+
res.setHeader(header, value);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
327
336
|
|
|
328
|
-
|
|
337
|
+
const chunks = [];
|
|
338
|
+
proxyRes.on('data', chunk => chunks.push(chunk));
|
|
339
|
+
proxyRes.on('end', () => {
|
|
340
|
+
res.end(Buffer.concat(chunks));
|
|
341
|
+
resolve(true);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
req.on('error', (error) => {
|
|
346
|
+
logger.error('Error while proxying request:', error);
|
|
347
|
+
if (!res.headersSent) {
|
|
348
|
+
res.statusCode = 500;
|
|
349
|
+
res.end('Internal Server Error');
|
|
350
|
+
}
|
|
351
|
+
resolve(true);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
if (body) req.write(body);
|
|
355
|
+
req.end();
|
|
356
|
+
});
|
|
329
357
|
} catch (error) {
|
|
330
358
|
logger.error('Error while proxying request:', error);
|
|
331
|
-
res.
|
|
332
|
-
|
|
359
|
+
if (!res.headersSent) {
|
|
360
|
+
res.statusCode = 500;
|
|
361
|
+
res.end('Internal Server Error');
|
|
362
|
+
}
|
|
333
363
|
}
|
|
334
364
|
|
|
335
365
|
return true;
|
|
@@ -22,6 +22,7 @@ export declare class DistributedTable<const P extends Parser<any>, const T exten
|
|
|
22
22
|
parse: P;
|
|
23
23
|
key: Key;
|
|
24
24
|
indexes?: Indexes;
|
|
25
|
+
ttlAttribute?: string;
|
|
25
26
|
});
|
|
26
27
|
get partitionKeyName(): Key['partition']['field'];
|
|
27
28
|
get sortKeyName(): 'field' extends keyof Key['sort'] ? (Key['sort']['field'] extends string ? Key['sort']['field'] : undefined) : undefined;
|
|
@@ -134,7 +134,8 @@ export class DistributedTable extends Resource {
|
|
|
134
134
|
absoluteId: this.absoluteId,
|
|
135
135
|
partitionKey: this.key.partition,
|
|
136
136
|
sortKey: this.key.sort,
|
|
137
|
-
indexes: this.indexes
|
|
137
|
+
indexes: this.indexes,
|
|
138
|
+
ttlAttribute: options.ttlAttribute,
|
|
138
139
|
};
|
|
139
140
|
addResource('DistributedTable', resourceDefinition);
|
|
140
141
|
}
|
|
@@ -132,10 +132,10 @@ export class AuthenticationService extends AuthenticationServiceBase {
|
|
|
132
132
|
if (state?.state === 'authenticated') {
|
|
133
133
|
if (this.#keepalive)
|
|
134
134
|
await this.#cookie.write(cookies, state);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
135
|
+
const actions = state.user.oidcProvider
|
|
136
|
+
? machineActions('signout')
|
|
137
|
+
: machineActions('changepassword', 'signout');
|
|
138
|
+
return { ...state, actions };
|
|
139
139
|
}
|
|
140
140
|
else {
|
|
141
141
|
if (state?.substate === 'pending-completesignup') {
|
|
@@ -160,10 +160,14 @@ export class AuthenticationService extends AuthenticationServiceBase {
|
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
else {
|
|
163
|
+
const oidcActions = await this.getOidcMachineActions();
|
|
163
164
|
return {
|
|
164
165
|
state: 'unauthenticated',
|
|
165
166
|
user: undefined,
|
|
166
|
-
actions:
|
|
167
|
+
actions: {
|
|
168
|
+
...machineActions('signin', 'startsignup', 'startforgotpassword'),
|
|
169
|
+
...oidcActions,
|
|
170
|
+
}
|
|
167
171
|
};
|
|
168
172
|
}
|
|
169
173
|
}
|
|
@@ -364,6 +368,9 @@ export class AuthenticationService extends AuthenticationServiceBase {
|
|
|
364
368
|
this.#cookie.clear(cookies);
|
|
365
369
|
return this.getMachineState(cookies);
|
|
366
370
|
}
|
|
371
|
+
if (state.user.oidcProvider) {
|
|
372
|
+
return { errors: [{ message: 'Password change is not available for social sign-in accounts.' }] };
|
|
373
|
+
}
|
|
367
374
|
try {
|
|
368
375
|
// change password requires an access token, which we don't actually store.
|
|
369
376
|
// so, first step is to actually authenticate.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wirejs-deploy-amplify-basic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.169",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"recursive-copy": "^2.0.14",
|
|
45
45
|
"rimraf": "^6.0.1",
|
|
46
46
|
"wirejs-dom": "^1.0.44",
|
|
47
|
-
"wirejs-resources": "^0.1.
|
|
47
|
+
"wirejs-resources": "^0.1.169"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@aws-amplify/backend": "^1.14.0",
|