@kirkelliott/zap 0.1.8 → 0.1.10
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/dist/cli.js +19 -1
- package/dist/init.js +5 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -193,6 +193,18 @@ program
|
|
|
193
193
|
catch (err) {
|
|
194
194
|
console.log('\ndirect invoke failed:', err.message);
|
|
195
195
|
}
|
|
196
|
+
const urlCfg = readConfig();
|
|
197
|
+
if (urlCfg.url) {
|
|
198
|
+
try {
|
|
199
|
+
const res = await fetch(urlCfg.url);
|
|
200
|
+
console.log(`\nurl fetch: HTTP ${res.status}`);
|
|
201
|
+
console.log('headers:', Object.fromEntries([...res.headers.entries()].filter(([k]) => k.startsWith('x-amzn') || k === 'content-type')));
|
|
202
|
+
console.log('body:', await res.text());
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
console.log('\nurl fetch failed:', err.message);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
196
208
|
});
|
|
197
209
|
program
|
|
198
210
|
.command('repair')
|
|
@@ -207,7 +219,13 @@ program
|
|
|
207
219
|
await lambda.send(new client_lambda_1.RemovePermissionCommand({ FunctionName: fn, StatementId: 'public-access' }));
|
|
208
220
|
}
|
|
209
221
|
catch { }
|
|
210
|
-
|
|
222
|
+
for (const sid of ['public-access', 'FunctionURLAllowPublicAccess']) {
|
|
223
|
+
try {
|
|
224
|
+
await lambda.send(new client_lambda_1.RemovePermissionCommand({ FunctionName: fn, StatementId: sid }));
|
|
225
|
+
}
|
|
226
|
+
catch { }
|
|
227
|
+
}
|
|
228
|
+
await lambda.send(new client_lambda_1.AddPermissionCommand({ FunctionName: fn, StatementId: 'public-access', Action: 'lambda:InvokeFunctionUrl', Principal: '*' }));
|
|
211
229
|
console.log('✓ permissions repaired');
|
|
212
230
|
if (cfg.url)
|
|
213
231
|
console.log(`\n → ${cfg.url.trim()}\n`);
|
package/dist/init.js
CHANGED
|
@@ -25,16 +25,17 @@ const policy = (bucket) => JSON.stringify({
|
|
|
25
25
|
],
|
|
26
26
|
});
|
|
27
27
|
async function allowPublicUrl(lambda, functionArn) {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
for (const sid of ['public-access', 'FunctionURLAllowPublicAccess']) {
|
|
29
|
+
try {
|
|
30
|
+
await lambda.send(new client_lambda_1.RemovePermissionCommand({ FunctionName: functionArn, StatementId: sid }));
|
|
31
|
+
}
|
|
32
|
+
catch { }
|
|
30
33
|
}
|
|
31
|
-
catch { }
|
|
32
34
|
await lambda.send(new client_lambda_1.AddPermissionCommand({
|
|
33
35
|
FunctionName: functionArn,
|
|
34
36
|
StatementId: 'public-access',
|
|
35
37
|
Action: 'lambda:InvokeFunctionUrl',
|
|
36
38
|
Principal: '*',
|
|
37
|
-
FunctionUrlAuthType: 'NONE',
|
|
38
39
|
}));
|
|
39
40
|
}
|
|
40
41
|
function step(label) {
|