@hot-updater/aws 0.12.6 → 0.13.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/dist/iac/index.cjs +8872 -0
- package/dist/iac/index.d.cts +3 -0
- package/dist/iac/index.d.ts +3 -0
- package/dist/iac/index.js +8883 -0
- package/dist/{src/index.cjs → index.cjs} +309 -149
- package/dist/{src/index.d.cts → index.d.cts} +4 -2
- package/dist/{src/index.d.ts → index.d.ts} +4 -2
- package/dist/{src/index.js → index.js} +309 -146
- package/dist/lambda/index.cjs +363 -1637
- package/package.json +34 -22
- package/dist/sdk/index.cjs +0 -46
- package/dist/sdk/index.d.cts +0 -17
- package/dist/sdk/index.d.ts +0 -17
- package/dist/sdk/index.js +0 -12
package/dist/lambda/index.cjs
CHANGED
|
@@ -33,1533 +33,9 @@ __export(index_exports, {
|
|
|
33
33
|
handler: () => handler
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
|
-
var import_client_s32 = require("@aws-sdk/client-s3");
|
|
37
36
|
|
|
38
|
-
// ../../
|
|
39
|
-
var
|
|
40
|
-
var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
41
|
-
|
|
42
|
-
// ../../node_modules/.pnpm/@smithy+querystring-builder@4.0.1/node_modules/@smithy/querystring-builder/dist-es/index.js
|
|
43
|
-
function buildQueryString(query) {
|
|
44
|
-
const parts = [];
|
|
45
|
-
for (let key of Object.keys(query).sort()) {
|
|
46
|
-
const value = query[key];
|
|
47
|
-
key = escapeUri(key);
|
|
48
|
-
if (Array.isArray(value)) {
|
|
49
|
-
for (let i = 0, iLen = value.length; i < iLen; i++) {
|
|
50
|
-
parts.push(`${key}=${escapeUri(value[i])}`);
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
let qsEntry = key;
|
|
54
|
-
if (value || typeof value === "string") {
|
|
55
|
-
qsEntry += `=${escapeUri(value)}`;
|
|
56
|
-
}
|
|
57
|
-
parts.push(qsEntry);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return parts.join("&");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ../../node_modules/.pnpm/@aws-sdk+util-format-url@3.734.0/node_modules/@aws-sdk/util-format-url/dist-es/index.js
|
|
64
|
-
function formatUrl(request) {
|
|
65
|
-
const { port, query } = request;
|
|
66
|
-
let { protocol, path, hostname } = request;
|
|
67
|
-
if (protocol && protocol.slice(-1) !== ":") {
|
|
68
|
-
protocol += ":";
|
|
69
|
-
}
|
|
70
|
-
if (port) {
|
|
71
|
-
hostname += `:${port}`;
|
|
72
|
-
}
|
|
73
|
-
if (path && path.charAt(0) !== "/") {
|
|
74
|
-
path = `/${path}`;
|
|
75
|
-
}
|
|
76
|
-
let queryString = query ? buildQueryString(query) : "";
|
|
77
|
-
if (queryString && queryString[0] !== "?") {
|
|
78
|
-
queryString = `?${queryString}`;
|
|
79
|
-
}
|
|
80
|
-
let auth = "";
|
|
81
|
-
if (request.username != null || request.password != null) {
|
|
82
|
-
const username = request.username ?? "";
|
|
83
|
-
const password = request.password ?? "";
|
|
84
|
-
auth = `${username}:${password}@`;
|
|
85
|
-
}
|
|
86
|
-
let fragment = "";
|
|
87
|
-
if (request.fragment) {
|
|
88
|
-
fragment = `#${request.fragment}`;
|
|
89
|
-
}
|
|
90
|
-
return `${protocol}//${auth}${hostname}${path}${queryString}${fragment}`;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ../../node_modules/.pnpm/@smithy+middleware-endpoint@4.0.5/node_modules/@smithy/middleware-endpoint/dist-es/service-customizations/s3.js
|
|
94
|
-
var resolveParamsForS3 = async (endpointParams) => {
|
|
95
|
-
const bucket = endpointParams?.Bucket || "";
|
|
96
|
-
if (typeof endpointParams.Bucket === "string") {
|
|
97
|
-
endpointParams.Bucket = bucket.replace(/#/g, encodeURIComponent("#")).replace(/\?/g, encodeURIComponent("?"));
|
|
98
|
-
}
|
|
99
|
-
if (isArnBucketName(bucket)) {
|
|
100
|
-
if (endpointParams.ForcePathStyle === true) {
|
|
101
|
-
throw new Error("Path-style addressing cannot be used with ARN buckets");
|
|
102
|
-
}
|
|
103
|
-
} else if (!isDnsCompatibleBucketName(bucket) || bucket.indexOf(".") !== -1 && !String(endpointParams.Endpoint).startsWith("http:") || bucket.toLowerCase() !== bucket || bucket.length < 3) {
|
|
104
|
-
endpointParams.ForcePathStyle = true;
|
|
105
|
-
}
|
|
106
|
-
if (endpointParams.DisableMultiRegionAccessPoints) {
|
|
107
|
-
endpointParams.disableMultiRegionAccessPoints = true;
|
|
108
|
-
endpointParams.DisableMRAP = true;
|
|
109
|
-
}
|
|
110
|
-
return endpointParams;
|
|
111
|
-
};
|
|
112
|
-
var DOMAIN_PATTERN = /^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/;
|
|
113
|
-
var IP_ADDRESS_PATTERN = /(\d+\.){3}\d+/;
|
|
114
|
-
var DOTS_PATTERN = /\.\./;
|
|
115
|
-
var isDnsCompatibleBucketName = (bucketName) => DOMAIN_PATTERN.test(bucketName) && !IP_ADDRESS_PATTERN.test(bucketName) && !DOTS_PATTERN.test(bucketName);
|
|
116
|
-
var isArnBucketName = (bucketName) => {
|
|
117
|
-
const [arn, partition, service, , , bucket] = bucketName.split(":");
|
|
118
|
-
const isArn = arn === "arn" && bucketName.split(":").length >= 6;
|
|
119
|
-
const isValidArn = Boolean(isArn && partition && service && bucket);
|
|
120
|
-
if (isArn && !isValidArn) {
|
|
121
|
-
throw new Error(`Invalid ARN: ${bucketName} was an invalid ARN.`);
|
|
122
|
-
}
|
|
123
|
-
return isValidArn;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// ../../node_modules/.pnpm/@smithy+middleware-endpoint@4.0.5/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/createConfigValueProvider.js
|
|
127
|
-
var createConfigValueProvider = (configKey, canonicalEndpointParamKey, config) => {
|
|
128
|
-
const configProvider = async () => {
|
|
129
|
-
const configValue = config[configKey] ?? config[canonicalEndpointParamKey];
|
|
130
|
-
if (typeof configValue === "function") {
|
|
131
|
-
return configValue();
|
|
132
|
-
}
|
|
133
|
-
return configValue;
|
|
134
|
-
};
|
|
135
|
-
if (configKey === "credentialScope" || canonicalEndpointParamKey === "CredentialScope") {
|
|
136
|
-
return async () => {
|
|
137
|
-
const credentials = typeof config.credentials === "function" ? await config.credentials() : config.credentials;
|
|
138
|
-
const configValue = credentials?.credentialScope ?? credentials?.CredentialScope;
|
|
139
|
-
return configValue;
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
if (configKey === "accountId" || canonicalEndpointParamKey === "AccountId") {
|
|
143
|
-
return async () => {
|
|
144
|
-
const credentials = typeof config.credentials === "function" ? await config.credentials() : config.credentials;
|
|
145
|
-
const configValue = credentials?.accountId ?? credentials?.AccountId;
|
|
146
|
-
return configValue;
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
if (configKey === "endpoint" || canonicalEndpointParamKey === "endpoint") {
|
|
150
|
-
return async () => {
|
|
151
|
-
const endpoint = await configProvider();
|
|
152
|
-
if (endpoint && typeof endpoint === "object") {
|
|
153
|
-
if ("url" in endpoint) {
|
|
154
|
-
return endpoint.url.href;
|
|
155
|
-
}
|
|
156
|
-
if ("hostname" in endpoint) {
|
|
157
|
-
const { protocol, hostname, port, path } = endpoint;
|
|
158
|
-
return `${protocol}//${hostname}${port ? ":" + port : ""}${path}`;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return endpoint;
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return configProvider;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// ../../node_modules/.pnpm/@smithy+property-provider@4.0.1/node_modules/@smithy/property-provider/dist-es/ProviderError.js
|
|
168
|
-
var ProviderError = class _ProviderError extends Error {
|
|
169
|
-
constructor(message, options = true) {
|
|
170
|
-
let logger;
|
|
171
|
-
let tryNextLink = true;
|
|
172
|
-
if (typeof options === "boolean") {
|
|
173
|
-
logger = void 0;
|
|
174
|
-
tryNextLink = options;
|
|
175
|
-
} else if (options != null && typeof options === "object") {
|
|
176
|
-
logger = options.logger;
|
|
177
|
-
tryNextLink = options.tryNextLink ?? true;
|
|
178
|
-
}
|
|
179
|
-
super(message);
|
|
180
|
-
this.name = "ProviderError";
|
|
181
|
-
this.tryNextLink = tryNextLink;
|
|
182
|
-
Object.setPrototypeOf(this, _ProviderError.prototype);
|
|
183
|
-
logger?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
184
|
-
}
|
|
185
|
-
static from(error, options = true) {
|
|
186
|
-
return Object.assign(new this(error.message, options), error);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// ../../node_modules/.pnpm/@smithy+property-provider@4.0.1/node_modules/@smithy/property-provider/dist-es/CredentialsProviderError.js
|
|
191
|
-
var CredentialsProviderError = class _CredentialsProviderError extends ProviderError {
|
|
192
|
-
constructor(message, options = true) {
|
|
193
|
-
super(message, options);
|
|
194
|
-
this.name = "CredentialsProviderError";
|
|
195
|
-
Object.setPrototypeOf(this, _CredentialsProviderError.prototype);
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// ../../node_modules/.pnpm/@smithy+property-provider@4.0.1/node_modules/@smithy/property-provider/dist-es/chain.js
|
|
200
|
-
var chain = (...providers) => async () => {
|
|
201
|
-
if (providers.length === 0) {
|
|
202
|
-
throw new ProviderError("No providers in chain");
|
|
203
|
-
}
|
|
204
|
-
let lastProviderError;
|
|
205
|
-
for (const provider of providers) {
|
|
206
|
-
try {
|
|
207
|
-
const credentials = await provider();
|
|
208
|
-
return credentials;
|
|
209
|
-
} catch (err) {
|
|
210
|
-
lastProviderError = err;
|
|
211
|
-
if (err?.tryNextLink) {
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
throw err;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
throw lastProviderError;
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
// ../../node_modules/.pnpm/@smithy+property-provider@4.0.1/node_modules/@smithy/property-provider/dist-es/fromStatic.js
|
|
221
|
-
var fromStatic = (staticValue) => () => Promise.resolve(staticValue);
|
|
222
|
-
|
|
223
|
-
// ../../node_modules/.pnpm/@smithy+property-provider@4.0.1/node_modules/@smithy/property-provider/dist-es/memoize.js
|
|
224
|
-
var memoize = (provider, isExpired, requiresRefresh) => {
|
|
225
|
-
let resolved;
|
|
226
|
-
let pending;
|
|
227
|
-
let hasResult;
|
|
228
|
-
let isConstant = false;
|
|
229
|
-
const coalesceProvider = async () => {
|
|
230
|
-
if (!pending) {
|
|
231
|
-
pending = provider();
|
|
232
|
-
}
|
|
233
|
-
try {
|
|
234
|
-
resolved = await pending;
|
|
235
|
-
hasResult = true;
|
|
236
|
-
isConstant = false;
|
|
237
|
-
} finally {
|
|
238
|
-
pending = void 0;
|
|
239
|
-
}
|
|
240
|
-
return resolved;
|
|
241
|
-
};
|
|
242
|
-
if (isExpired === void 0) {
|
|
243
|
-
return async (options) => {
|
|
244
|
-
if (!hasResult || options?.forceRefresh) {
|
|
245
|
-
resolved = await coalesceProvider();
|
|
246
|
-
}
|
|
247
|
-
return resolved;
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
return async (options) => {
|
|
251
|
-
if (!hasResult || options?.forceRefresh) {
|
|
252
|
-
resolved = await coalesceProvider();
|
|
253
|
-
}
|
|
254
|
-
if (isConstant) {
|
|
255
|
-
return resolved;
|
|
256
|
-
}
|
|
257
|
-
if (requiresRefresh && !requiresRefresh(resolved)) {
|
|
258
|
-
isConstant = true;
|
|
259
|
-
return resolved;
|
|
260
|
-
}
|
|
261
|
-
if (isExpired(resolved)) {
|
|
262
|
-
await coalesceProvider();
|
|
263
|
-
return resolved;
|
|
264
|
-
}
|
|
265
|
-
return resolved;
|
|
266
|
-
};
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
// ../../node_modules/.pnpm/@smithy+node-config-provider@4.0.1/node_modules/@smithy/node-config-provider/dist-es/getSelectorName.js
|
|
270
|
-
function getSelectorName(functionString) {
|
|
271
|
-
try {
|
|
272
|
-
const constants = new Set(Array.from(functionString.match(/([A-Z_]){3,}/g) ?? []));
|
|
273
|
-
constants.delete("CONFIG");
|
|
274
|
-
constants.delete("CONFIG_PREFIX_SEPARATOR");
|
|
275
|
-
constants.delete("ENV");
|
|
276
|
-
return [...constants].join(", ");
|
|
277
|
-
} catch (e) {
|
|
278
|
-
return functionString;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// ../../node_modules/.pnpm/@smithy+node-config-provider@4.0.1/node_modules/@smithy/node-config-provider/dist-es/fromEnv.js
|
|
283
|
-
var fromEnv = (envVarSelector, logger) => async () => {
|
|
284
|
-
try {
|
|
285
|
-
const config = envVarSelector(process.env);
|
|
286
|
-
if (config === void 0) {
|
|
287
|
-
throw new Error();
|
|
288
|
-
}
|
|
289
|
-
return config;
|
|
290
|
-
} catch (e) {
|
|
291
|
-
throw new CredentialsProviderError(e.message || `Not found in ENV: ${getSelectorName(envVarSelector.toString())}`, { logger });
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/getHomeDir.js
|
|
296
|
-
var import_os = require("os");
|
|
297
|
-
var import_path = require("path");
|
|
298
|
-
var homeDirCache = {};
|
|
299
|
-
var getHomeDirCacheKey = () => {
|
|
300
|
-
if (process && process.geteuid) {
|
|
301
|
-
return `${process.geteuid()}`;
|
|
302
|
-
}
|
|
303
|
-
return "DEFAULT";
|
|
304
|
-
};
|
|
305
|
-
var getHomeDir = () => {
|
|
306
|
-
const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${import_path.sep}` } = process.env;
|
|
307
|
-
if (HOME)
|
|
308
|
-
return HOME;
|
|
309
|
-
if (USERPROFILE)
|
|
310
|
-
return USERPROFILE;
|
|
311
|
-
if (HOMEPATH)
|
|
312
|
-
return `${HOMEDRIVE}${HOMEPATH}`;
|
|
313
|
-
const homeDirCacheKey = getHomeDirCacheKey();
|
|
314
|
-
if (!homeDirCache[homeDirCacheKey])
|
|
315
|
-
homeDirCache[homeDirCacheKey] = (0, import_os.homedir)();
|
|
316
|
-
return homeDirCache[homeDirCacheKey];
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/getProfileName.js
|
|
320
|
-
var ENV_PROFILE = "AWS_PROFILE";
|
|
321
|
-
var DEFAULT_PROFILE = "default";
|
|
322
|
-
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
323
|
-
|
|
324
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFromFile.js
|
|
325
|
-
var import_fs = require("fs");
|
|
326
|
-
var { readFile } = import_fs.promises;
|
|
327
|
-
|
|
328
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
|
|
329
|
-
var import_path4 = require("path");
|
|
330
|
-
|
|
331
|
-
// ../../node_modules/.pnpm/@smithy+types@4.1.0/node_modules/@smithy/types/dist-es/auth/auth.js
|
|
332
|
-
var HttpAuthLocation;
|
|
333
|
-
(function(HttpAuthLocation2) {
|
|
334
|
-
HttpAuthLocation2["HEADER"] = "header";
|
|
335
|
-
HttpAuthLocation2["QUERY"] = "query";
|
|
336
|
-
})(HttpAuthLocation || (HttpAuthLocation = {}));
|
|
337
|
-
|
|
338
|
-
// ../../node_modules/.pnpm/@smithy+types@4.1.0/node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
|
|
339
|
-
var HttpApiKeyAuthLocation;
|
|
340
|
-
(function(HttpApiKeyAuthLocation2) {
|
|
341
|
-
HttpApiKeyAuthLocation2["HEADER"] = "header";
|
|
342
|
-
HttpApiKeyAuthLocation2["QUERY"] = "query";
|
|
343
|
-
})(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
|
|
344
|
-
|
|
345
|
-
// ../../node_modules/.pnpm/@smithy+types@4.1.0/node_modules/@smithy/types/dist-es/endpoint.js
|
|
346
|
-
var EndpointURLScheme;
|
|
347
|
-
(function(EndpointURLScheme2) {
|
|
348
|
-
EndpointURLScheme2["HTTP"] = "http";
|
|
349
|
-
EndpointURLScheme2["HTTPS"] = "https";
|
|
350
|
-
})(EndpointURLScheme || (EndpointURLScheme = {}));
|
|
351
|
-
|
|
352
|
-
// ../../node_modules/.pnpm/@smithy+types@4.1.0/node_modules/@smithy/types/dist-es/extensions/checksum.js
|
|
353
|
-
var AlgorithmId;
|
|
354
|
-
(function(AlgorithmId2) {
|
|
355
|
-
AlgorithmId2["MD5"] = "md5";
|
|
356
|
-
AlgorithmId2["CRC32"] = "crc32";
|
|
357
|
-
AlgorithmId2["CRC32C"] = "crc32c";
|
|
358
|
-
AlgorithmId2["SHA1"] = "sha1";
|
|
359
|
-
AlgorithmId2["SHA256"] = "sha256";
|
|
360
|
-
})(AlgorithmId || (AlgorithmId = {}));
|
|
361
|
-
|
|
362
|
-
// ../../node_modules/.pnpm/@smithy+types@4.1.0/node_modules/@smithy/types/dist-es/http.js
|
|
363
|
-
var FieldPosition;
|
|
364
|
-
(function(FieldPosition2) {
|
|
365
|
-
FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
|
|
366
|
-
FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
|
|
367
|
-
})(FieldPosition || (FieldPosition = {}));
|
|
368
|
-
|
|
369
|
-
// ../../node_modules/.pnpm/@smithy+types@4.1.0/node_modules/@smithy/types/dist-es/profile.js
|
|
370
|
-
var IniSectionType;
|
|
371
|
-
(function(IniSectionType2) {
|
|
372
|
-
IniSectionType2["PROFILE"] = "profile";
|
|
373
|
-
IniSectionType2["SSO_SESSION"] = "sso-session";
|
|
374
|
-
IniSectionType2["SERVICES"] = "services";
|
|
375
|
-
})(IniSectionType || (IniSectionType = {}));
|
|
376
|
-
|
|
377
|
-
// ../../node_modules/.pnpm/@smithy+types@4.1.0/node_modules/@smithy/types/dist-es/transfer.js
|
|
378
|
-
var RequestHandlerProtocol;
|
|
379
|
-
(function(RequestHandlerProtocol2) {
|
|
380
|
-
RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
|
|
381
|
-
RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
|
|
382
|
-
RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
|
|
383
|
-
})(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
|
|
384
|
-
|
|
385
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigData.js
|
|
386
|
-
var getConfigData = (data) => Object.entries(data).filter(([key]) => {
|
|
387
|
-
const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
|
|
388
|
-
if (indexOfSeparator === -1) {
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
return Object.values(IniSectionType).includes(key.substring(0, indexOfSeparator));
|
|
392
|
-
}).reduce((acc, [key, value]) => {
|
|
393
|
-
const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
|
|
394
|
-
const updatedKey = key.substring(0, indexOfSeparator) === IniSectionType.PROFILE ? key.substring(indexOfSeparator + 1) : key;
|
|
395
|
-
acc[updatedKey] = value;
|
|
396
|
-
return acc;
|
|
397
|
-
}, {
|
|
398
|
-
...data.default && { default: data.default }
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigFilepath.js
|
|
402
|
-
var import_path2 = require("path");
|
|
403
|
-
var ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
|
|
404
|
-
var getConfigFilepath = () => process.env[ENV_CONFIG_PATH] || (0, import_path2.join)(getHomeDir(), ".aws", "config");
|
|
405
|
-
|
|
406
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/getCredentialsFilepath.js
|
|
407
|
-
var import_path3 = require("path");
|
|
408
|
-
var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
|
|
409
|
-
var getCredentialsFilepath = () => process.env[ENV_CREDENTIALS_PATH] || (0, import_path3.join)(getHomeDir(), ".aws", "credentials");
|
|
410
|
-
|
|
411
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/parseIni.js
|
|
412
|
-
var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
413
|
-
var profileNameBlockList = ["__proto__", "profile __proto__"];
|
|
414
|
-
var parseIni = (iniData) => {
|
|
415
|
-
const map = {};
|
|
416
|
-
let currentSection;
|
|
417
|
-
let currentSubSection;
|
|
418
|
-
for (const iniLine of iniData.split(/\r?\n/)) {
|
|
419
|
-
const trimmedLine = iniLine.split(/(^|\s)[;#]/)[0].trim();
|
|
420
|
-
const isSection = trimmedLine[0] === "[" && trimmedLine[trimmedLine.length - 1] === "]";
|
|
421
|
-
if (isSection) {
|
|
422
|
-
currentSection = void 0;
|
|
423
|
-
currentSubSection = void 0;
|
|
424
|
-
const sectionName = trimmedLine.substring(1, trimmedLine.length - 1);
|
|
425
|
-
const matches = prefixKeyRegex.exec(sectionName);
|
|
426
|
-
if (matches) {
|
|
427
|
-
const [, prefix, , name] = matches;
|
|
428
|
-
if (Object.values(IniSectionType).includes(prefix)) {
|
|
429
|
-
currentSection = [prefix, name].join(CONFIG_PREFIX_SEPARATOR);
|
|
430
|
-
}
|
|
431
|
-
} else {
|
|
432
|
-
currentSection = sectionName;
|
|
433
|
-
}
|
|
434
|
-
if (profileNameBlockList.includes(sectionName)) {
|
|
435
|
-
throw new Error(`Found invalid profile name "${sectionName}"`);
|
|
436
|
-
}
|
|
437
|
-
} else if (currentSection) {
|
|
438
|
-
const indexOfEqualsSign = trimmedLine.indexOf("=");
|
|
439
|
-
if (![0, -1].includes(indexOfEqualsSign)) {
|
|
440
|
-
const [name, value] = [
|
|
441
|
-
trimmedLine.substring(0, indexOfEqualsSign).trim(),
|
|
442
|
-
trimmedLine.substring(indexOfEqualsSign + 1).trim()
|
|
443
|
-
];
|
|
444
|
-
if (value === "") {
|
|
445
|
-
currentSubSection = name;
|
|
446
|
-
} else {
|
|
447
|
-
if (currentSubSection && iniLine.trimStart() === iniLine) {
|
|
448
|
-
currentSubSection = void 0;
|
|
449
|
-
}
|
|
450
|
-
map[currentSection] = map[currentSection] || {};
|
|
451
|
-
const key = currentSubSection ? [currentSubSection, name].join(CONFIG_PREFIX_SEPARATOR) : name;
|
|
452
|
-
map[currentSection][key] = value;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
return map;
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/slurpFile.js
|
|
461
|
-
var import_fs2 = require("fs");
|
|
462
|
-
var { readFile: readFile2 } = import_fs2.promises;
|
|
463
|
-
var filePromisesHash = {};
|
|
464
|
-
var slurpFile = (path, options) => {
|
|
465
|
-
if (!filePromisesHash[path] || options?.ignoreCache) {
|
|
466
|
-
filePromisesHash[path] = readFile2(path, "utf8");
|
|
467
|
-
}
|
|
468
|
-
return filePromisesHash[path];
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.0.1/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
|
|
472
|
-
var swallowError = () => ({});
|
|
473
|
-
var CONFIG_PREFIX_SEPARATOR = ".";
|
|
474
|
-
var loadSharedConfigFiles = async (init = {}) => {
|
|
475
|
-
const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
|
|
476
|
-
const homeDir = getHomeDir();
|
|
477
|
-
const relativeHomeDirPrefix = "~/";
|
|
478
|
-
let resolvedFilepath = filepath;
|
|
479
|
-
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
480
|
-
resolvedFilepath = (0, import_path4.join)(homeDir, filepath.slice(2));
|
|
481
|
-
}
|
|
482
|
-
let resolvedConfigFilepath = configFilepath;
|
|
483
|
-
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
484
|
-
resolvedConfigFilepath = (0, import_path4.join)(homeDir, configFilepath.slice(2));
|
|
485
|
-
}
|
|
486
|
-
const parsedFiles = await Promise.all([
|
|
487
|
-
slurpFile(resolvedConfigFilepath, {
|
|
488
|
-
ignoreCache: init.ignoreCache
|
|
489
|
-
}).then(parseIni).then(getConfigData).catch(swallowError),
|
|
490
|
-
slurpFile(resolvedFilepath, {
|
|
491
|
-
ignoreCache: init.ignoreCache
|
|
492
|
-
}).then(parseIni).catch(swallowError)
|
|
493
|
-
]);
|
|
494
|
-
return {
|
|
495
|
-
configFile: parsedFiles[0],
|
|
496
|
-
credentialsFile: parsedFiles[1]
|
|
497
|
-
};
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
// ../../node_modules/.pnpm/@smithy+node-config-provider@4.0.1/node_modules/@smithy/node-config-provider/dist-es/fromSharedConfigFiles.js
|
|
501
|
-
var fromSharedConfigFiles = (configSelector, { preferredFile = "config", ...init } = {}) => async () => {
|
|
502
|
-
const profile = getProfileName(init);
|
|
503
|
-
const { configFile, credentialsFile } = await loadSharedConfigFiles(init);
|
|
504
|
-
const profileFromCredentials = credentialsFile[profile] || {};
|
|
505
|
-
const profileFromConfig = configFile[profile] || {};
|
|
506
|
-
const mergedProfile = preferredFile === "config" ? { ...profileFromCredentials, ...profileFromConfig } : { ...profileFromConfig, ...profileFromCredentials };
|
|
507
|
-
try {
|
|
508
|
-
const cfgFile = preferredFile === "config" ? configFile : credentialsFile;
|
|
509
|
-
const configValue = configSelector(mergedProfile, cfgFile);
|
|
510
|
-
if (configValue === void 0) {
|
|
511
|
-
throw new Error();
|
|
512
|
-
}
|
|
513
|
-
return configValue;
|
|
514
|
-
} catch (e) {
|
|
515
|
-
throw new CredentialsProviderError(e.message || `Not found in config files w/ profile [${profile}]: ${getSelectorName(configSelector.toString())}`, { logger: init.logger });
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
// ../../node_modules/.pnpm/@smithy+node-config-provider@4.0.1/node_modules/@smithy/node-config-provider/dist-es/fromStatic.js
|
|
520
|
-
var isFunction = (func) => typeof func === "function";
|
|
521
|
-
var fromStatic2 = (defaultValue) => isFunction(defaultValue) ? async () => await defaultValue() : fromStatic(defaultValue);
|
|
522
|
-
|
|
523
|
-
// ../../node_modules/.pnpm/@smithy+node-config-provider@4.0.1/node_modules/@smithy/node-config-provider/dist-es/configLoader.js
|
|
524
|
-
var loadConfig = ({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => memoize(chain(fromEnv(environmentVariableSelector), fromSharedConfigFiles(configFileSelector, configuration), fromStatic2(defaultValue)));
|
|
525
|
-
|
|
526
|
-
// ../../node_modules/.pnpm/@smithy+middleware-endpoint@4.0.5/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/getEndpointUrlConfig.js
|
|
527
|
-
var ENV_ENDPOINT_URL = "AWS_ENDPOINT_URL";
|
|
528
|
-
var CONFIG_ENDPOINT_URL = "endpoint_url";
|
|
529
|
-
var getEndpointUrlConfig = (serviceId) => ({
|
|
530
|
-
environmentVariableSelector: (env) => {
|
|
531
|
-
const serviceSuffixParts = serviceId.split(" ").map((w) => w.toUpperCase());
|
|
532
|
-
const serviceEndpointUrl = env[[ENV_ENDPOINT_URL, ...serviceSuffixParts].join("_")];
|
|
533
|
-
if (serviceEndpointUrl)
|
|
534
|
-
return serviceEndpointUrl;
|
|
535
|
-
const endpointUrl = env[ENV_ENDPOINT_URL];
|
|
536
|
-
if (endpointUrl)
|
|
537
|
-
return endpointUrl;
|
|
538
|
-
return void 0;
|
|
539
|
-
},
|
|
540
|
-
configFileSelector: (profile, config) => {
|
|
541
|
-
if (config && profile.services) {
|
|
542
|
-
const servicesSection = config[["services", profile.services].join(CONFIG_PREFIX_SEPARATOR)];
|
|
543
|
-
if (servicesSection) {
|
|
544
|
-
const servicePrefixParts = serviceId.split(" ").map((w) => w.toLowerCase());
|
|
545
|
-
const endpointUrl2 = servicesSection[[servicePrefixParts.join("_"), CONFIG_ENDPOINT_URL].join(CONFIG_PREFIX_SEPARATOR)];
|
|
546
|
-
if (endpointUrl2)
|
|
547
|
-
return endpointUrl2;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
const endpointUrl = profile[CONFIG_ENDPOINT_URL];
|
|
551
|
-
if (endpointUrl)
|
|
552
|
-
return endpointUrl;
|
|
553
|
-
return void 0;
|
|
554
|
-
},
|
|
555
|
-
default: void 0
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
// ../../node_modules/.pnpm/@smithy+middleware-endpoint@4.0.5/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/getEndpointFromConfig.js
|
|
559
|
-
var getEndpointFromConfig = async (serviceId) => loadConfig(getEndpointUrlConfig(serviceId ?? ""))();
|
|
560
|
-
|
|
561
|
-
// ../../node_modules/.pnpm/@smithy+querystring-parser@4.0.1/node_modules/@smithy/querystring-parser/dist-es/index.js
|
|
562
|
-
function parseQueryString(querystring) {
|
|
563
|
-
const query = {};
|
|
564
|
-
querystring = querystring.replace(/^\?/, "");
|
|
565
|
-
if (querystring) {
|
|
566
|
-
for (const pair of querystring.split("&")) {
|
|
567
|
-
let [key, value = null] = pair.split("=");
|
|
568
|
-
key = decodeURIComponent(key);
|
|
569
|
-
if (value) {
|
|
570
|
-
value = decodeURIComponent(value);
|
|
571
|
-
}
|
|
572
|
-
if (!(key in query)) {
|
|
573
|
-
query[key] = value;
|
|
574
|
-
} else if (Array.isArray(query[key])) {
|
|
575
|
-
query[key].push(value);
|
|
576
|
-
} else {
|
|
577
|
-
query[key] = [query[key], value];
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return query;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// ../../node_modules/.pnpm/@smithy+url-parser@4.0.1/node_modules/@smithy/url-parser/dist-es/index.js
|
|
585
|
-
var parseUrl = (url) => {
|
|
586
|
-
if (typeof url === "string") {
|
|
587
|
-
return parseUrl(new URL(url));
|
|
588
|
-
}
|
|
589
|
-
const { hostname, pathname, port, protocol, search } = url;
|
|
590
|
-
let query;
|
|
591
|
-
if (search) {
|
|
592
|
-
query = parseQueryString(search);
|
|
593
|
-
}
|
|
594
|
-
return {
|
|
595
|
-
hostname,
|
|
596
|
-
port: port ? parseInt(port) : void 0,
|
|
597
|
-
protocol,
|
|
598
|
-
path: pathname,
|
|
599
|
-
query
|
|
600
|
-
};
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
// ../../node_modules/.pnpm/@smithy+middleware-endpoint@4.0.5/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/toEndpointV1.js
|
|
604
|
-
var toEndpointV1 = (endpoint) => {
|
|
605
|
-
if (typeof endpoint === "object") {
|
|
606
|
-
if ("url" in endpoint) {
|
|
607
|
-
return parseUrl(endpoint.url);
|
|
608
|
-
}
|
|
609
|
-
return endpoint;
|
|
610
|
-
}
|
|
611
|
-
return parseUrl(endpoint);
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
// ../../node_modules/.pnpm/@smithy+middleware-endpoint@4.0.5/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/getEndpointFromInstructions.js
|
|
615
|
-
var getEndpointFromInstructions = async (commandInput, instructionsSupplier, clientConfig, context) => {
|
|
616
|
-
if (!clientConfig.endpoint) {
|
|
617
|
-
let endpointFromConfig;
|
|
618
|
-
if (clientConfig.serviceConfiguredEndpoint) {
|
|
619
|
-
endpointFromConfig = await clientConfig.serviceConfiguredEndpoint();
|
|
620
|
-
} else {
|
|
621
|
-
endpointFromConfig = await getEndpointFromConfig(clientConfig.serviceId);
|
|
622
|
-
}
|
|
623
|
-
if (endpointFromConfig) {
|
|
624
|
-
clientConfig.endpoint = () => Promise.resolve(toEndpointV1(endpointFromConfig));
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
const endpointParams = await resolveParams(commandInput, instructionsSupplier, clientConfig);
|
|
628
|
-
if (typeof clientConfig.endpointProvider !== "function") {
|
|
629
|
-
throw new Error("config.endpointProvider is not set.");
|
|
630
|
-
}
|
|
631
|
-
const endpoint = clientConfig.endpointProvider(endpointParams, context);
|
|
632
|
-
return endpoint;
|
|
633
|
-
};
|
|
634
|
-
var resolveParams = async (commandInput, instructionsSupplier, clientConfig) => {
|
|
635
|
-
const endpointParams = {};
|
|
636
|
-
const instructions = instructionsSupplier?.getEndpointParameterInstructions?.() || {};
|
|
637
|
-
for (const [name, instruction] of Object.entries(instructions)) {
|
|
638
|
-
switch (instruction.type) {
|
|
639
|
-
case "staticContextParams":
|
|
640
|
-
endpointParams[name] = instruction.value;
|
|
641
|
-
break;
|
|
642
|
-
case "contextParams":
|
|
643
|
-
endpointParams[name] = commandInput[instruction.name];
|
|
644
|
-
break;
|
|
645
|
-
case "clientContextParams":
|
|
646
|
-
case "builtInParams":
|
|
647
|
-
endpointParams[name] = await createConfigValueProvider(instruction.name, name, clientConfig)();
|
|
648
|
-
break;
|
|
649
|
-
case "operationContextParams":
|
|
650
|
-
endpointParams[name] = instruction.get(commandInput);
|
|
651
|
-
break;
|
|
652
|
-
default:
|
|
653
|
-
throw new Error("Unrecognized endpoint parameter instruction: " + JSON.stringify(instruction));
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
if (Object.keys(instructions).length === 0) {
|
|
657
|
-
Object.assign(endpointParams, clientConfig);
|
|
658
|
-
}
|
|
659
|
-
if (String(clientConfig.serviceId).toLowerCase() === "s3") {
|
|
660
|
-
await resolveParamsForS3(endpointParams);
|
|
661
|
-
}
|
|
662
|
-
return endpointParams;
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
// ../../node_modules/.pnpm/@smithy+util-middleware@4.0.1/node_modules/@smithy/util-middleware/dist-es/normalizeProvider.js
|
|
666
|
-
var normalizeProvider = (input) => {
|
|
667
|
-
if (typeof input === "function")
|
|
668
|
-
return input;
|
|
669
|
-
const promisified = Promise.resolve(input);
|
|
670
|
-
return () => promisified;
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
// ../../node_modules/.pnpm/@smithy+middleware-serde@4.0.2/node_modules/@smithy/middleware-serde/dist-es/serdePlugin.js
|
|
674
|
-
var serializerMiddlewareOption = {
|
|
675
|
-
name: "serializerMiddleware",
|
|
676
|
-
step: "serialize",
|
|
677
|
-
tags: ["SERIALIZER"],
|
|
678
|
-
override: true
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
// ../../node_modules/.pnpm/@smithy+core@3.1.4/node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js
|
|
682
|
-
var httpAuthSchemeMiddlewareOptions = {
|
|
683
|
-
step: "serialize",
|
|
684
|
-
tags: ["HTTP_AUTH_SCHEME"],
|
|
685
|
-
name: "httpAuthSchemeMiddleware",
|
|
686
|
-
override: true,
|
|
687
|
-
relation: "before",
|
|
688
|
-
toMiddleware: serializerMiddlewareOption.name
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
// ../../node_modules/.pnpm/@smithy+protocol-http@5.0.1/node_modules/@smithy/protocol-http/dist-es/httpRequest.js
|
|
692
|
-
var HttpRequest = class _HttpRequest {
|
|
693
|
-
constructor(options) {
|
|
694
|
-
this.method = options.method || "GET";
|
|
695
|
-
this.hostname = options.hostname || "localhost";
|
|
696
|
-
this.port = options.port;
|
|
697
|
-
this.query = options.query || {};
|
|
698
|
-
this.headers = options.headers || {};
|
|
699
|
-
this.body = options.body;
|
|
700
|
-
this.protocol = options.protocol ? options.protocol.slice(-1) !== ":" ? `${options.protocol}:` : options.protocol : "https:";
|
|
701
|
-
this.path = options.path ? options.path.charAt(0) !== "/" ? `/${options.path}` : options.path : "/";
|
|
702
|
-
this.username = options.username;
|
|
703
|
-
this.password = options.password;
|
|
704
|
-
this.fragment = options.fragment;
|
|
705
|
-
}
|
|
706
|
-
static clone(request) {
|
|
707
|
-
const cloned = new _HttpRequest({
|
|
708
|
-
...request,
|
|
709
|
-
headers: { ...request.headers }
|
|
710
|
-
});
|
|
711
|
-
if (cloned.query) {
|
|
712
|
-
cloned.query = cloneQuery(cloned.query);
|
|
713
|
-
}
|
|
714
|
-
return cloned;
|
|
715
|
-
}
|
|
716
|
-
static isInstance(request) {
|
|
717
|
-
if (!request) {
|
|
718
|
-
return false;
|
|
719
|
-
}
|
|
720
|
-
const req = request;
|
|
721
|
-
return "method" in req && "protocol" in req && "hostname" in req && "path" in req && typeof req["query"] === "object" && typeof req["headers"] === "object";
|
|
722
|
-
}
|
|
723
|
-
clone() {
|
|
724
|
-
return _HttpRequest.clone(this);
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
function cloneQuery(query) {
|
|
728
|
-
return Object.keys(query).reduce((carry, paramName) => {
|
|
729
|
-
const param = query[paramName];
|
|
730
|
-
return {
|
|
731
|
-
...carry,
|
|
732
|
-
[paramName]: Array.isArray(param) ? [...param] : param
|
|
733
|
-
};
|
|
734
|
-
}, {});
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
// ../../node_modules/.pnpm/@smithy+is-array-buffer@4.0.0/node_modules/@smithy/is-array-buffer/dist-es/index.js
|
|
738
|
-
var isArrayBuffer = (arg) => typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer || Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
739
|
-
|
|
740
|
-
// ../../node_modules/.pnpm/@smithy+util-buffer-from@4.0.0/node_modules/@smithy/util-buffer-from/dist-es/index.js
|
|
741
|
-
var import_buffer = require("buffer");
|
|
742
|
-
var fromString = (input, encoding) => {
|
|
743
|
-
if (typeof input !== "string") {
|
|
744
|
-
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
|
745
|
-
}
|
|
746
|
-
return encoding ? import_buffer.Buffer.from(input, encoding) : import_buffer.Buffer.from(input);
|
|
747
|
-
};
|
|
748
|
-
|
|
749
|
-
// ../../node_modules/.pnpm/@smithy+util-utf8@4.0.0/node_modules/@smithy/util-utf8/dist-es/fromUtf8.js
|
|
750
|
-
var fromUtf8 = (input) => {
|
|
751
|
-
const buf = fromString(input, "utf8");
|
|
752
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
753
|
-
};
|
|
754
|
-
|
|
755
|
-
// ../../node_modules/.pnpm/@smithy+util-utf8@4.0.0/node_modules/@smithy/util-utf8/dist-es/toUint8Array.js
|
|
756
|
-
var toUint8Array = (data) => {
|
|
757
|
-
if (typeof data === "string") {
|
|
758
|
-
return fromUtf8(data);
|
|
759
|
-
}
|
|
760
|
-
if (ArrayBuffer.isView(data)) {
|
|
761
|
-
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
762
|
-
}
|
|
763
|
-
return new Uint8Array(data);
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
// ../../node_modules/.pnpm/@smithy+util-stream@4.1.1/node_modules/@smithy/util-stream/dist-es/createBufferedReadable.js
|
|
767
|
-
var import_node_stream = require("stream");
|
|
768
|
-
|
|
769
|
-
// ../../node_modules/.pnpm/@smithy+util-hex-encoding@4.0.0/node_modules/@smithy/util-hex-encoding/dist-es/index.js
|
|
770
|
-
var SHORT_TO_HEX = {};
|
|
771
|
-
var HEX_TO_SHORT = {};
|
|
772
|
-
for (let i = 0; i < 256; i++) {
|
|
773
|
-
let encodedByte = i.toString(16).toLowerCase();
|
|
774
|
-
if (encodedByte.length === 1) {
|
|
775
|
-
encodedByte = `0${encodedByte}`;
|
|
776
|
-
}
|
|
777
|
-
SHORT_TO_HEX[i] = encodedByte;
|
|
778
|
-
HEX_TO_SHORT[encodedByte] = i;
|
|
779
|
-
}
|
|
780
|
-
function fromHex(encoded) {
|
|
781
|
-
if (encoded.length % 2 !== 0) {
|
|
782
|
-
throw new Error("Hex encoded strings must have an even number length");
|
|
783
|
-
}
|
|
784
|
-
const out = new Uint8Array(encoded.length / 2);
|
|
785
|
-
for (let i = 0; i < encoded.length; i += 2) {
|
|
786
|
-
const encodedByte = encoded.slice(i, i + 2).toLowerCase();
|
|
787
|
-
if (encodedByte in HEX_TO_SHORT) {
|
|
788
|
-
out[i / 2] = HEX_TO_SHORT[encodedByte];
|
|
789
|
-
} else {
|
|
790
|
-
throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`);
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
return out;
|
|
794
|
-
}
|
|
795
|
-
function toHex(bytes) {
|
|
796
|
-
let out = "";
|
|
797
|
-
for (let i = 0; i < bytes.byteLength; i++) {
|
|
798
|
-
out += SHORT_TO_HEX[bytes[i]];
|
|
799
|
-
}
|
|
800
|
-
return out;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
// ../../node_modules/.pnpm/@smithy+core@3.1.4/node_modules/@smithy/core/dist-es/util-identity-and-auth/memoizeIdentityProvider.js
|
|
804
|
-
var createIsIdentityExpiredFunction = (expirationMs) => (identity) => doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs;
|
|
805
|
-
var EXPIRATION_MS = 3e5;
|
|
806
|
-
var isIdentityExpired = createIsIdentityExpiredFunction(EXPIRATION_MS);
|
|
807
|
-
var doesIdentityRequireRefresh = (identity) => identity.expiration !== void 0;
|
|
808
|
-
|
|
809
|
-
// ../../node_modules/.pnpm/@smithy+middleware-endpoint@4.0.5/node_modules/@smithy/middleware-endpoint/dist-es/getEndpointPlugin.js
|
|
810
|
-
var endpointMiddlewareOptions = {
|
|
811
|
-
step: "serialize",
|
|
812
|
-
tags: ["ENDPOINT_PARAMETERS", "ENDPOINT_V2", "ENDPOINT"],
|
|
813
|
-
name: "endpointV2Middleware",
|
|
814
|
-
override: true,
|
|
815
|
-
relation: "before",
|
|
816
|
-
toMiddleware: serializerMiddlewareOption.name
|
|
817
|
-
};
|
|
818
|
-
|
|
819
|
-
// ../../node_modules/.pnpm/@smithy+smithy-client@4.1.5/node_modules/@smithy/smithy-client/dist-es/parse-utils.js
|
|
820
|
-
var MAX_FLOAT = Math.ceil(2 ** 127 * (2 - 2 ** -23));
|
|
821
|
-
|
|
822
|
-
// ../../node_modules/.pnpm/@smithy+smithy-client@4.1.5/node_modules/@smithy/smithy-client/dist-es/date-utils.js
|
|
823
|
-
var RFC3339 = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/);
|
|
824
|
-
var RFC3339_WITH_OFFSET = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(([-+]\d{2}\:\d{2})|[zZ])$/);
|
|
825
|
-
var IMF_FIXDATE = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/);
|
|
826
|
-
var RFC_850_DATE = new RegExp(/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/);
|
|
827
|
-
var ASC_TIME = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( [1-9]|\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? (\d{4})$/);
|
|
828
|
-
var FIFTY_YEARS_IN_MILLIS = 50 * 365 * 24 * 60 * 60 * 1e3;
|
|
829
|
-
|
|
830
|
-
// ../../node_modules/.pnpm/@smithy+smithy-client@4.1.5/node_modules/@smithy/smithy-client/dist-es/lazy-json.js
|
|
831
|
-
var LazyJsonString = function LazyJsonString2(val) {
|
|
832
|
-
const str = Object.assign(new String(val), {
|
|
833
|
-
deserializeJSON() {
|
|
834
|
-
return JSON.parse(String(val));
|
|
835
|
-
},
|
|
836
|
-
toString() {
|
|
837
|
-
return String(val);
|
|
838
|
-
},
|
|
839
|
-
toJSON() {
|
|
840
|
-
return String(val);
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
return str;
|
|
844
|
-
};
|
|
845
|
-
LazyJsonString.from = (object) => {
|
|
846
|
-
if (object && typeof object === "object" && (object instanceof LazyJsonString || "deserializeJSON" in object)) {
|
|
847
|
-
return object;
|
|
848
|
-
} else if (typeof object === "string" || Object.getPrototypeOf(object) === String.prototype) {
|
|
849
|
-
return LazyJsonString(String(object));
|
|
850
|
-
}
|
|
851
|
-
return LazyJsonString(JSON.stringify(object));
|
|
852
|
-
};
|
|
853
|
-
LazyJsonString.fromObject = LazyJsonString.from;
|
|
854
|
-
|
|
855
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/constants.js
|
|
856
|
-
var ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
|
|
857
|
-
var CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
|
|
858
|
-
var AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
|
|
859
|
-
var SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
|
|
860
|
-
var EXPIRES_QUERY_PARAM = "X-Amz-Expires";
|
|
861
|
-
var SIGNATURE_QUERY_PARAM = "X-Amz-Signature";
|
|
862
|
-
var TOKEN_QUERY_PARAM = "X-Amz-Security-Token";
|
|
863
|
-
var AUTH_HEADER = "authorization";
|
|
864
|
-
var AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase();
|
|
865
|
-
var DATE_HEADER = "date";
|
|
866
|
-
var GENERATED_HEADERS = [AUTH_HEADER, AMZ_DATE_HEADER, DATE_HEADER];
|
|
867
|
-
var SIGNATURE_HEADER = SIGNATURE_QUERY_PARAM.toLowerCase();
|
|
868
|
-
var SHA256_HEADER = "x-amz-content-sha256";
|
|
869
|
-
var TOKEN_HEADER = TOKEN_QUERY_PARAM.toLowerCase();
|
|
870
|
-
var ALWAYS_UNSIGNABLE_HEADERS = {
|
|
871
|
-
authorization: true,
|
|
872
|
-
"cache-control": true,
|
|
873
|
-
connection: true,
|
|
874
|
-
expect: true,
|
|
875
|
-
from: true,
|
|
876
|
-
"keep-alive": true,
|
|
877
|
-
"max-forwards": true,
|
|
878
|
-
pragma: true,
|
|
879
|
-
referer: true,
|
|
880
|
-
te: true,
|
|
881
|
-
trailer: true,
|
|
882
|
-
"transfer-encoding": true,
|
|
883
|
-
upgrade: true,
|
|
884
|
-
"user-agent": true,
|
|
885
|
-
"x-amzn-trace-id": true
|
|
886
|
-
};
|
|
887
|
-
var PROXY_HEADER_PATTERN = /^proxy-/;
|
|
888
|
-
var SEC_HEADER_PATTERN = /^sec-/;
|
|
889
|
-
var ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
|
|
890
|
-
var EVENT_ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256-PAYLOAD";
|
|
891
|
-
var UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
|
|
892
|
-
var MAX_CACHE_SIZE = 50;
|
|
893
|
-
var KEY_TYPE_IDENTIFIER = "aws4_request";
|
|
894
|
-
var MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7;
|
|
895
|
-
|
|
896
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/credentialDerivation.js
|
|
897
|
-
var signingKeyCache = {};
|
|
898
|
-
var cacheQueue = [];
|
|
899
|
-
var createScope = (shortDate, region, service) => `${shortDate}/${region}/${service}/${KEY_TYPE_IDENTIFIER}`;
|
|
900
|
-
var getSigningKey = async (sha256Constructor, credentials, shortDate, region, service) => {
|
|
901
|
-
const credsHash = await hmac(sha256Constructor, credentials.secretAccessKey, credentials.accessKeyId);
|
|
902
|
-
const cacheKey = `${shortDate}:${region}:${service}:${toHex(credsHash)}:${credentials.sessionToken}`;
|
|
903
|
-
if (cacheKey in signingKeyCache) {
|
|
904
|
-
return signingKeyCache[cacheKey];
|
|
905
|
-
}
|
|
906
|
-
cacheQueue.push(cacheKey);
|
|
907
|
-
while (cacheQueue.length > MAX_CACHE_SIZE) {
|
|
908
|
-
delete signingKeyCache[cacheQueue.shift()];
|
|
909
|
-
}
|
|
910
|
-
let key = `AWS4${credentials.secretAccessKey}`;
|
|
911
|
-
for (const signable of [shortDate, region, service, KEY_TYPE_IDENTIFIER]) {
|
|
912
|
-
key = await hmac(sha256Constructor, key, signable);
|
|
913
|
-
}
|
|
914
|
-
return signingKeyCache[cacheKey] = key;
|
|
915
|
-
};
|
|
916
|
-
var hmac = (ctor, secret, data) => {
|
|
917
|
-
const hash = new ctor(secret);
|
|
918
|
-
hash.update(toUint8Array(data));
|
|
919
|
-
return hash.digest();
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/getCanonicalHeaders.js
|
|
923
|
-
var getCanonicalHeaders = ({ headers }, unsignableHeaders, signableHeaders) => {
|
|
924
|
-
const canonical = {};
|
|
925
|
-
for (const headerName of Object.keys(headers).sort()) {
|
|
926
|
-
if (headers[headerName] == void 0) {
|
|
927
|
-
continue;
|
|
928
|
-
}
|
|
929
|
-
const canonicalHeaderName = headerName.toLowerCase();
|
|
930
|
-
if (canonicalHeaderName in ALWAYS_UNSIGNABLE_HEADERS || unsignableHeaders?.has(canonicalHeaderName) || PROXY_HEADER_PATTERN.test(canonicalHeaderName) || SEC_HEADER_PATTERN.test(canonicalHeaderName)) {
|
|
931
|
-
if (!signableHeaders || signableHeaders && !signableHeaders.has(canonicalHeaderName)) {
|
|
932
|
-
continue;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
canonical[canonicalHeaderName] = headers[headerName].trim().replace(/\s+/g, " ");
|
|
936
|
-
}
|
|
937
|
-
return canonical;
|
|
938
|
-
};
|
|
939
|
-
|
|
940
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/getCanonicalQuery.js
|
|
941
|
-
var getCanonicalQuery = ({ query = {} }) => {
|
|
942
|
-
const keys = [];
|
|
943
|
-
const serialized = {};
|
|
944
|
-
for (const key of Object.keys(query)) {
|
|
945
|
-
if (key.toLowerCase() === SIGNATURE_HEADER) {
|
|
946
|
-
continue;
|
|
947
|
-
}
|
|
948
|
-
const encodedKey = escapeUri(key);
|
|
949
|
-
keys.push(encodedKey);
|
|
950
|
-
const value = query[key];
|
|
951
|
-
if (typeof value === "string") {
|
|
952
|
-
serialized[encodedKey] = `${encodedKey}=${escapeUri(value)}`;
|
|
953
|
-
} else if (Array.isArray(value)) {
|
|
954
|
-
serialized[encodedKey] = value.slice(0).reduce((encoded, value2) => encoded.concat([`${encodedKey}=${escapeUri(value2)}`]), []).sort().join("&");
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
return keys.sort().map((key) => serialized[key]).filter((serialized2) => serialized2).join("&");
|
|
958
|
-
};
|
|
959
|
-
|
|
960
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/getPayloadHash.js
|
|
961
|
-
var getPayloadHash = async ({ headers, body }, hashConstructor) => {
|
|
962
|
-
for (const headerName of Object.keys(headers)) {
|
|
963
|
-
if (headerName.toLowerCase() === SHA256_HEADER) {
|
|
964
|
-
return headers[headerName];
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
if (body == void 0) {
|
|
968
|
-
return "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
969
|
-
} else if (typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) {
|
|
970
|
-
const hashCtor = new hashConstructor();
|
|
971
|
-
hashCtor.update(toUint8Array(body));
|
|
972
|
-
return toHex(await hashCtor.digest());
|
|
973
|
-
}
|
|
974
|
-
return UNSIGNED_PAYLOAD;
|
|
975
|
-
};
|
|
976
|
-
|
|
977
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js
|
|
978
|
-
var HeaderFormatter = class {
|
|
979
|
-
format(headers) {
|
|
980
|
-
const chunks = [];
|
|
981
|
-
for (const headerName of Object.keys(headers)) {
|
|
982
|
-
const bytes = fromUtf8(headerName);
|
|
983
|
-
chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
|
|
984
|
-
}
|
|
985
|
-
const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
|
|
986
|
-
let position = 0;
|
|
987
|
-
for (const chunk of chunks) {
|
|
988
|
-
out.set(chunk, position);
|
|
989
|
-
position += chunk.byteLength;
|
|
990
|
-
}
|
|
991
|
-
return out;
|
|
992
|
-
}
|
|
993
|
-
formatHeaderValue(header) {
|
|
994
|
-
switch (header.type) {
|
|
995
|
-
case "boolean":
|
|
996
|
-
return Uint8Array.from([header.value ? 0 : 1]);
|
|
997
|
-
case "byte":
|
|
998
|
-
return Uint8Array.from([2, header.value]);
|
|
999
|
-
case "short":
|
|
1000
|
-
const shortView = new DataView(new ArrayBuffer(3));
|
|
1001
|
-
shortView.setUint8(0, 3);
|
|
1002
|
-
shortView.setInt16(1, header.value, false);
|
|
1003
|
-
return new Uint8Array(shortView.buffer);
|
|
1004
|
-
case "integer":
|
|
1005
|
-
const intView = new DataView(new ArrayBuffer(5));
|
|
1006
|
-
intView.setUint8(0, 4);
|
|
1007
|
-
intView.setInt32(1, header.value, false);
|
|
1008
|
-
return new Uint8Array(intView.buffer);
|
|
1009
|
-
case "long":
|
|
1010
|
-
const longBytes = new Uint8Array(9);
|
|
1011
|
-
longBytes[0] = 5;
|
|
1012
|
-
longBytes.set(header.value.bytes, 1);
|
|
1013
|
-
return longBytes;
|
|
1014
|
-
case "binary":
|
|
1015
|
-
const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
|
|
1016
|
-
binView.setUint8(0, 6);
|
|
1017
|
-
binView.setUint16(1, header.value.byteLength, false);
|
|
1018
|
-
const binBytes = new Uint8Array(binView.buffer);
|
|
1019
|
-
binBytes.set(header.value, 3);
|
|
1020
|
-
return binBytes;
|
|
1021
|
-
case "string":
|
|
1022
|
-
const utf8Bytes = fromUtf8(header.value);
|
|
1023
|
-
const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
|
|
1024
|
-
strView.setUint8(0, 7);
|
|
1025
|
-
strView.setUint16(1, utf8Bytes.byteLength, false);
|
|
1026
|
-
const strBytes = new Uint8Array(strView.buffer);
|
|
1027
|
-
strBytes.set(utf8Bytes, 3);
|
|
1028
|
-
return strBytes;
|
|
1029
|
-
case "timestamp":
|
|
1030
|
-
const tsBytes = new Uint8Array(9);
|
|
1031
|
-
tsBytes[0] = 8;
|
|
1032
|
-
tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
|
|
1033
|
-
return tsBytes;
|
|
1034
|
-
case "uuid":
|
|
1035
|
-
if (!UUID_PATTERN.test(header.value)) {
|
|
1036
|
-
throw new Error(`Invalid UUID received: ${header.value}`);
|
|
1037
|
-
}
|
|
1038
|
-
const uuidBytes = new Uint8Array(17);
|
|
1039
|
-
uuidBytes[0] = 9;
|
|
1040
|
-
uuidBytes.set(fromHex(header.value.replace(/\-/g, "")), 1);
|
|
1041
|
-
return uuidBytes;
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
};
|
|
1045
|
-
var HEADER_VALUE_TYPE;
|
|
1046
|
-
(function(HEADER_VALUE_TYPE2) {
|
|
1047
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolTrue"] = 0] = "boolTrue";
|
|
1048
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolFalse"] = 1] = "boolFalse";
|
|
1049
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byte"] = 2] = "byte";
|
|
1050
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["short"] = 3] = "short";
|
|
1051
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["integer"] = 4] = "integer";
|
|
1052
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["long"] = 5] = "long";
|
|
1053
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byteArray"] = 6] = "byteArray";
|
|
1054
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["string"] = 7] = "string";
|
|
1055
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["timestamp"] = 8] = "timestamp";
|
|
1056
|
-
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["uuid"] = 9] = "uuid";
|
|
1057
|
-
})(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
|
|
1058
|
-
var UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
1059
|
-
var Int64 = class _Int64 {
|
|
1060
|
-
constructor(bytes) {
|
|
1061
|
-
this.bytes = bytes;
|
|
1062
|
-
if (bytes.byteLength !== 8) {
|
|
1063
|
-
throw new Error("Int64 buffers must be exactly 8 bytes");
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
static fromNumber(number) {
|
|
1067
|
-
if (number > 9223372036854776e3 || number < -9223372036854776e3) {
|
|
1068
|
-
throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
|
|
1069
|
-
}
|
|
1070
|
-
const bytes = new Uint8Array(8);
|
|
1071
|
-
for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
|
|
1072
|
-
bytes[i] = remaining;
|
|
1073
|
-
}
|
|
1074
|
-
if (number < 0) {
|
|
1075
|
-
negate(bytes);
|
|
1076
|
-
}
|
|
1077
|
-
return new _Int64(bytes);
|
|
1078
|
-
}
|
|
1079
|
-
valueOf() {
|
|
1080
|
-
const bytes = this.bytes.slice(0);
|
|
1081
|
-
const negative = bytes[0] & 128;
|
|
1082
|
-
if (negative) {
|
|
1083
|
-
negate(bytes);
|
|
1084
|
-
}
|
|
1085
|
-
return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);
|
|
1086
|
-
}
|
|
1087
|
-
toString() {
|
|
1088
|
-
return String(this.valueOf());
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
function negate(bytes) {
|
|
1092
|
-
for (let i = 0; i < 8; i++) {
|
|
1093
|
-
bytes[i] ^= 255;
|
|
1094
|
-
}
|
|
1095
|
-
for (let i = 7; i > -1; i--) {
|
|
1096
|
-
bytes[i]++;
|
|
1097
|
-
if (bytes[i] !== 0)
|
|
1098
|
-
break;
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/headerUtil.js
|
|
1103
|
-
var hasHeader = (soughtHeader, headers) => {
|
|
1104
|
-
soughtHeader = soughtHeader.toLowerCase();
|
|
1105
|
-
for (const headerName of Object.keys(headers)) {
|
|
1106
|
-
if (soughtHeader === headerName.toLowerCase()) {
|
|
1107
|
-
return true;
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
return false;
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js
|
|
1114
|
-
var moveHeadersToQuery = (request, options = {}) => {
|
|
1115
|
-
const { headers, query = {} } = HttpRequest.clone(request);
|
|
1116
|
-
for (const name of Object.keys(headers)) {
|
|
1117
|
-
const lname = name.toLowerCase();
|
|
1118
|
-
if (lname.slice(0, 6) === "x-amz-" && !options.unhoistableHeaders?.has(lname) || options.hoistableHeaders?.has(lname)) {
|
|
1119
|
-
query[name] = headers[name];
|
|
1120
|
-
delete headers[name];
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
return {
|
|
1124
|
-
...request,
|
|
1125
|
-
headers,
|
|
1126
|
-
query
|
|
1127
|
-
};
|
|
1128
|
-
};
|
|
1129
|
-
|
|
1130
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/prepareRequest.js
|
|
1131
|
-
var prepareRequest = (request) => {
|
|
1132
|
-
request = HttpRequest.clone(request);
|
|
1133
|
-
for (const headerName of Object.keys(request.headers)) {
|
|
1134
|
-
if (GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {
|
|
1135
|
-
delete request.headers[headerName];
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
return request;
|
|
1139
|
-
};
|
|
1140
|
-
|
|
1141
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/utilDate.js
|
|
1142
|
-
var iso8601 = (time) => toDate(time).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
1143
|
-
var toDate = (time) => {
|
|
1144
|
-
if (typeof time === "number") {
|
|
1145
|
-
return new Date(time * 1e3);
|
|
1146
|
-
}
|
|
1147
|
-
if (typeof time === "string") {
|
|
1148
|
-
if (Number(time)) {
|
|
1149
|
-
return new Date(Number(time) * 1e3);
|
|
1150
|
-
}
|
|
1151
|
-
return new Date(time);
|
|
1152
|
-
}
|
|
1153
|
-
return time;
|
|
1154
|
-
};
|
|
1155
|
-
|
|
1156
|
-
// ../../node_modules/.pnpm/@smithy+signature-v4@5.0.1/node_modules/@smithy/signature-v4/dist-es/SignatureV4.js
|
|
1157
|
-
var SignatureV4 = class {
|
|
1158
|
-
constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath = true }) {
|
|
1159
|
-
this.headerFormatter = new HeaderFormatter();
|
|
1160
|
-
this.service = service;
|
|
1161
|
-
this.sha256 = sha256;
|
|
1162
|
-
this.uriEscapePath = uriEscapePath;
|
|
1163
|
-
this.applyChecksum = typeof applyChecksum === "boolean" ? applyChecksum : true;
|
|
1164
|
-
this.regionProvider = normalizeProvider(region);
|
|
1165
|
-
this.credentialProvider = normalizeProvider(credentials);
|
|
1166
|
-
}
|
|
1167
|
-
async presign(originalRequest, options = {}) {
|
|
1168
|
-
const { signingDate = /* @__PURE__ */ new Date(), expiresIn = 3600, unsignableHeaders, unhoistableHeaders, signableHeaders, hoistableHeaders, signingRegion, signingService } = options;
|
|
1169
|
-
const credentials = await this.credentialProvider();
|
|
1170
|
-
this.validateResolvedCredentials(credentials);
|
|
1171
|
-
const region = signingRegion ?? await this.regionProvider();
|
|
1172
|
-
const { longDate, shortDate } = formatDate(signingDate);
|
|
1173
|
-
if (expiresIn > MAX_PRESIGNED_TTL) {
|
|
1174
|
-
return Promise.reject("Signature version 4 presigned URLs must have an expiration date less than one week in the future");
|
|
1175
|
-
}
|
|
1176
|
-
const scope = createScope(shortDate, region, signingService ?? this.service);
|
|
1177
|
-
const request = moveHeadersToQuery(prepareRequest(originalRequest), { unhoistableHeaders, hoistableHeaders });
|
|
1178
|
-
if (credentials.sessionToken) {
|
|
1179
|
-
request.query[TOKEN_QUERY_PARAM] = credentials.sessionToken;
|
|
1180
|
-
}
|
|
1181
|
-
request.query[ALGORITHM_QUERY_PARAM] = ALGORITHM_IDENTIFIER;
|
|
1182
|
-
request.query[CREDENTIAL_QUERY_PARAM] = `${credentials.accessKeyId}/${scope}`;
|
|
1183
|
-
request.query[AMZ_DATE_QUERY_PARAM] = longDate;
|
|
1184
|
-
request.query[EXPIRES_QUERY_PARAM] = expiresIn.toString(10);
|
|
1185
|
-
const canonicalHeaders = getCanonicalHeaders(request, unsignableHeaders, signableHeaders);
|
|
1186
|
-
request.query[SIGNED_HEADERS_QUERY_PARAM] = getCanonicalHeaderList(canonicalHeaders);
|
|
1187
|
-
request.query[SIGNATURE_QUERY_PARAM] = await this.getSignature(longDate, scope, this.getSigningKey(credentials, region, shortDate, signingService), this.createCanonicalRequest(request, canonicalHeaders, await getPayloadHash(originalRequest, this.sha256)));
|
|
1188
|
-
return request;
|
|
1189
|
-
}
|
|
1190
|
-
async sign(toSign, options) {
|
|
1191
|
-
if (typeof toSign === "string") {
|
|
1192
|
-
return this.signString(toSign, options);
|
|
1193
|
-
} else if (toSign.headers && toSign.payload) {
|
|
1194
|
-
return this.signEvent(toSign, options);
|
|
1195
|
-
} else if (toSign.message) {
|
|
1196
|
-
return this.signMessage(toSign, options);
|
|
1197
|
-
} else {
|
|
1198
|
-
return this.signRequest(toSign, options);
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
async signEvent({ headers, payload }, { signingDate = /* @__PURE__ */ new Date(), priorSignature, signingRegion, signingService }) {
|
|
1202
|
-
const region = signingRegion ?? await this.regionProvider();
|
|
1203
|
-
const { shortDate, longDate } = formatDate(signingDate);
|
|
1204
|
-
const scope = createScope(shortDate, region, signingService ?? this.service);
|
|
1205
|
-
const hashedPayload = await getPayloadHash({ headers: {}, body: payload }, this.sha256);
|
|
1206
|
-
const hash = new this.sha256();
|
|
1207
|
-
hash.update(headers);
|
|
1208
|
-
const hashedHeaders = toHex(await hash.digest());
|
|
1209
|
-
const stringToSign = [
|
|
1210
|
-
EVENT_ALGORITHM_IDENTIFIER,
|
|
1211
|
-
longDate,
|
|
1212
|
-
scope,
|
|
1213
|
-
priorSignature,
|
|
1214
|
-
hashedHeaders,
|
|
1215
|
-
hashedPayload
|
|
1216
|
-
].join("\n");
|
|
1217
|
-
return this.signString(stringToSign, { signingDate, signingRegion: region, signingService });
|
|
1218
|
-
}
|
|
1219
|
-
async signMessage(signableMessage, { signingDate = /* @__PURE__ */ new Date(), signingRegion, signingService }) {
|
|
1220
|
-
const promise = this.signEvent({
|
|
1221
|
-
headers: this.headerFormatter.format(signableMessage.message.headers),
|
|
1222
|
-
payload: signableMessage.message.body
|
|
1223
|
-
}, {
|
|
1224
|
-
signingDate,
|
|
1225
|
-
signingRegion,
|
|
1226
|
-
signingService,
|
|
1227
|
-
priorSignature: signableMessage.priorSignature
|
|
1228
|
-
});
|
|
1229
|
-
return promise.then((signature) => {
|
|
1230
|
-
return { message: signableMessage.message, signature };
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
async signString(stringToSign, { signingDate = /* @__PURE__ */ new Date(), signingRegion, signingService } = {}) {
|
|
1234
|
-
const credentials = await this.credentialProvider();
|
|
1235
|
-
this.validateResolvedCredentials(credentials);
|
|
1236
|
-
const region = signingRegion ?? await this.regionProvider();
|
|
1237
|
-
const { shortDate } = formatDate(signingDate);
|
|
1238
|
-
const hash = new this.sha256(await this.getSigningKey(credentials, region, shortDate, signingService));
|
|
1239
|
-
hash.update(toUint8Array(stringToSign));
|
|
1240
|
-
return toHex(await hash.digest());
|
|
1241
|
-
}
|
|
1242
|
-
async signRequest(requestToSign, { signingDate = /* @__PURE__ */ new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService } = {}) {
|
|
1243
|
-
const credentials = await this.credentialProvider();
|
|
1244
|
-
this.validateResolvedCredentials(credentials);
|
|
1245
|
-
const region = signingRegion ?? await this.regionProvider();
|
|
1246
|
-
const request = prepareRequest(requestToSign);
|
|
1247
|
-
const { longDate, shortDate } = formatDate(signingDate);
|
|
1248
|
-
const scope = createScope(shortDate, region, signingService ?? this.service);
|
|
1249
|
-
request.headers[AMZ_DATE_HEADER] = longDate;
|
|
1250
|
-
if (credentials.sessionToken) {
|
|
1251
|
-
request.headers[TOKEN_HEADER] = credentials.sessionToken;
|
|
1252
|
-
}
|
|
1253
|
-
const payloadHash = await getPayloadHash(request, this.sha256);
|
|
1254
|
-
if (!hasHeader(SHA256_HEADER, request.headers) && this.applyChecksum) {
|
|
1255
|
-
request.headers[SHA256_HEADER] = payloadHash;
|
|
1256
|
-
}
|
|
1257
|
-
const canonicalHeaders = getCanonicalHeaders(request, unsignableHeaders, signableHeaders);
|
|
1258
|
-
const signature = await this.getSignature(longDate, scope, this.getSigningKey(credentials, region, shortDate, signingService), this.createCanonicalRequest(request, canonicalHeaders, payloadHash));
|
|
1259
|
-
request.headers[AUTH_HEADER] = `${ALGORITHM_IDENTIFIER} Credential=${credentials.accessKeyId}/${scope}, SignedHeaders=${getCanonicalHeaderList(canonicalHeaders)}, Signature=${signature}`;
|
|
1260
|
-
return request;
|
|
1261
|
-
}
|
|
1262
|
-
createCanonicalRequest(request, canonicalHeaders, payloadHash) {
|
|
1263
|
-
const sortedHeaders = Object.keys(canonicalHeaders).sort();
|
|
1264
|
-
return `${request.method}
|
|
1265
|
-
${this.getCanonicalPath(request)}
|
|
1266
|
-
${getCanonicalQuery(request)}
|
|
1267
|
-
${sortedHeaders.map((name) => `${name}:${canonicalHeaders[name]}`).join("\n")}
|
|
1268
|
-
|
|
1269
|
-
${sortedHeaders.join(";")}
|
|
1270
|
-
${payloadHash}`;
|
|
1271
|
-
}
|
|
1272
|
-
async createStringToSign(longDate, credentialScope, canonicalRequest) {
|
|
1273
|
-
const hash = new this.sha256();
|
|
1274
|
-
hash.update(toUint8Array(canonicalRequest));
|
|
1275
|
-
const hashedRequest = await hash.digest();
|
|
1276
|
-
return `${ALGORITHM_IDENTIFIER}
|
|
1277
|
-
${longDate}
|
|
1278
|
-
${credentialScope}
|
|
1279
|
-
${toHex(hashedRequest)}`;
|
|
1280
|
-
}
|
|
1281
|
-
getCanonicalPath({ path }) {
|
|
1282
|
-
if (this.uriEscapePath) {
|
|
1283
|
-
const normalizedPathSegments = [];
|
|
1284
|
-
for (const pathSegment of path.split("/")) {
|
|
1285
|
-
if (pathSegment?.length === 0)
|
|
1286
|
-
continue;
|
|
1287
|
-
if (pathSegment === ".")
|
|
1288
|
-
continue;
|
|
1289
|
-
if (pathSegment === "..") {
|
|
1290
|
-
normalizedPathSegments.pop();
|
|
1291
|
-
} else {
|
|
1292
|
-
normalizedPathSegments.push(pathSegment);
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
const normalizedPath = `${path?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path?.endsWith("/") ? "/" : ""}`;
|
|
1296
|
-
const doubleEncoded = escapeUri(normalizedPath);
|
|
1297
|
-
return doubleEncoded.replace(/%2F/g, "/");
|
|
1298
|
-
}
|
|
1299
|
-
return path;
|
|
1300
|
-
}
|
|
1301
|
-
async getSignature(longDate, credentialScope, keyPromise, canonicalRequest) {
|
|
1302
|
-
const stringToSign = await this.createStringToSign(longDate, credentialScope, canonicalRequest);
|
|
1303
|
-
const hash = new this.sha256(await keyPromise);
|
|
1304
|
-
hash.update(toUint8Array(stringToSign));
|
|
1305
|
-
return toHex(await hash.digest());
|
|
1306
|
-
}
|
|
1307
|
-
getSigningKey(credentials, region, shortDate, service) {
|
|
1308
|
-
return getSigningKey(this.sha256, credentials, shortDate, region, service || this.service);
|
|
1309
|
-
}
|
|
1310
|
-
validateResolvedCredentials(credentials) {
|
|
1311
|
-
if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
|
|
1312
|
-
throw new Error("Resolved credential object is not valid");
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
var formatDate = (now) => {
|
|
1317
|
-
const longDate = iso8601(now).replace(/[\-:]/g, "");
|
|
1318
|
-
return {
|
|
1319
|
-
longDate,
|
|
1320
|
-
shortDate: longDate.slice(0, 8)
|
|
1321
|
-
};
|
|
1322
|
-
};
|
|
1323
|
-
var getCanonicalHeaderList = (headers) => Object.keys(headers).sort().join(";");
|
|
1324
|
-
|
|
1325
|
-
// ../../node_modules/.pnpm/@smithy+util-config-provider@4.0.0/node_modules/@smithy/util-config-provider/dist-es/types.js
|
|
1326
|
-
var SelectorType;
|
|
1327
|
-
(function(SelectorType2) {
|
|
1328
|
-
SelectorType2["ENV"] = "env";
|
|
1329
|
-
SelectorType2["CONFIG"] = "shared config entry";
|
|
1330
|
-
})(SelectorType || (SelectorType = {}));
|
|
1331
|
-
|
|
1332
|
-
// ../../node_modules/.pnpm/@aws-sdk+middleware-sdk-s3@3.750.0/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/constants.js
|
|
1333
|
-
var SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
|
|
1334
|
-
var SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
|
|
1335
|
-
|
|
1336
|
-
// ../../node_modules/.pnpm/@aws-sdk+middleware-sdk-s3@3.750.0/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/classes/SignatureV4S3Express.js
|
|
1337
|
-
var SignatureV4S3Express = class extends SignatureV4 {
|
|
1338
|
-
async signWithCredentials(requestToSign, credentials, options) {
|
|
1339
|
-
const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
|
|
1340
|
-
requestToSign.headers[SESSION_TOKEN_HEADER] = credentials.sessionToken;
|
|
1341
|
-
const privateAccess = this;
|
|
1342
|
-
setSingleOverride(privateAccess, credentialsWithoutSessionToken);
|
|
1343
|
-
return privateAccess.signRequest(requestToSign, options ?? {});
|
|
1344
|
-
}
|
|
1345
|
-
async presignWithCredentials(requestToSign, credentials, options) {
|
|
1346
|
-
const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
|
|
1347
|
-
delete requestToSign.headers[SESSION_TOKEN_HEADER];
|
|
1348
|
-
requestToSign.headers[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
|
|
1349
|
-
requestToSign.query = requestToSign.query ?? {};
|
|
1350
|
-
requestToSign.query[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
|
|
1351
|
-
const privateAccess = this;
|
|
1352
|
-
setSingleOverride(privateAccess, credentialsWithoutSessionToken);
|
|
1353
|
-
return this.presign(requestToSign, options);
|
|
1354
|
-
}
|
|
1355
|
-
};
|
|
1356
|
-
function getCredentialsWithoutSessionToken(credentials) {
|
|
1357
|
-
const credentialsWithoutSessionToken = {
|
|
1358
|
-
accessKeyId: credentials.accessKeyId,
|
|
1359
|
-
secretAccessKey: credentials.secretAccessKey,
|
|
1360
|
-
expiration: credentials.expiration
|
|
1361
|
-
};
|
|
1362
|
-
return credentialsWithoutSessionToken;
|
|
1363
|
-
}
|
|
1364
|
-
function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
|
|
1365
|
-
const id = setTimeout(() => {
|
|
1366
|
-
throw new Error("SignatureV4S3Express credential override was created but not called.");
|
|
1367
|
-
}, 10);
|
|
1368
|
-
const currentCredentialProvider = privateAccess.credentialProvider;
|
|
1369
|
-
const overrideCredentialsProviderOnce = () => {
|
|
1370
|
-
clearTimeout(id);
|
|
1371
|
-
privateAccess.credentialProvider = currentCredentialProvider;
|
|
1372
|
-
return Promise.resolve(credentialsWithoutSessionToken);
|
|
1373
|
-
};
|
|
1374
|
-
privateAccess.credentialProvider = overrideCredentialsProviderOnce;
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
// ../../node_modules/.pnpm/@aws-sdk+signature-v4-multi-region@3.750.0/node_modules/@aws-sdk/signature-v4-multi-region/dist-es/signature-v4-crt-container.js
|
|
1378
|
-
var signatureV4CrtContainer = {
|
|
1379
|
-
CrtSignerV4: null
|
|
1380
|
-
};
|
|
1381
|
-
|
|
1382
|
-
// ../../node_modules/.pnpm/@aws-sdk+signature-v4-multi-region@3.750.0/node_modules/@aws-sdk/signature-v4-multi-region/dist-es/SignatureV4MultiRegion.js
|
|
1383
|
-
var SignatureV4MultiRegion = class {
|
|
1384
|
-
sigv4aSigner;
|
|
1385
|
-
sigv4Signer;
|
|
1386
|
-
signerOptions;
|
|
1387
|
-
constructor(options) {
|
|
1388
|
-
this.sigv4Signer = new SignatureV4S3Express(options);
|
|
1389
|
-
this.signerOptions = options;
|
|
1390
|
-
}
|
|
1391
|
-
async sign(requestToSign, options = {}) {
|
|
1392
|
-
if (options.signingRegion === "*") {
|
|
1393
|
-
if (this.signerOptions.runtime !== "node")
|
|
1394
|
-
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
1395
|
-
return this.getSigv4aSigner().sign(requestToSign, options);
|
|
1396
|
-
}
|
|
1397
|
-
return this.sigv4Signer.sign(requestToSign, options);
|
|
1398
|
-
}
|
|
1399
|
-
async signWithCredentials(requestToSign, credentials, options = {}) {
|
|
1400
|
-
if (options.signingRegion === "*") {
|
|
1401
|
-
if (this.signerOptions.runtime !== "node")
|
|
1402
|
-
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
1403
|
-
return this.getSigv4aSigner().signWithCredentials(requestToSign, credentials, options);
|
|
1404
|
-
}
|
|
1405
|
-
return this.sigv4Signer.signWithCredentials(requestToSign, credentials, options);
|
|
1406
|
-
}
|
|
1407
|
-
async presign(originalRequest, options = {}) {
|
|
1408
|
-
if (options.signingRegion === "*") {
|
|
1409
|
-
if (this.signerOptions.runtime !== "node")
|
|
1410
|
-
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
1411
|
-
return this.getSigv4aSigner().presign(originalRequest, options);
|
|
1412
|
-
}
|
|
1413
|
-
return this.sigv4Signer.presign(originalRequest, options);
|
|
1414
|
-
}
|
|
1415
|
-
async presignWithCredentials(originalRequest, credentials, options = {}) {
|
|
1416
|
-
if (options.signingRegion === "*") {
|
|
1417
|
-
throw new Error("Method presignWithCredentials is not supported for [signingRegion=*].");
|
|
1418
|
-
}
|
|
1419
|
-
return this.sigv4Signer.presignWithCredentials(originalRequest, credentials, options);
|
|
1420
|
-
}
|
|
1421
|
-
getSigv4aSigner() {
|
|
1422
|
-
if (!this.sigv4aSigner) {
|
|
1423
|
-
let CrtSignerV4 = null;
|
|
1424
|
-
try {
|
|
1425
|
-
CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4;
|
|
1426
|
-
if (typeof CrtSignerV4 !== "function")
|
|
1427
|
-
throw new Error();
|
|
1428
|
-
} catch (e) {
|
|
1429
|
-
e.message = `${e.message}
|
|
1430
|
-
Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly.
|
|
1431
|
-
You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";].
|
|
1432
|
-
For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`;
|
|
1433
|
-
throw e;
|
|
1434
|
-
}
|
|
1435
|
-
this.sigv4aSigner = new CrtSignerV4({
|
|
1436
|
-
...this.signerOptions,
|
|
1437
|
-
signingAlgorithm: 1
|
|
1438
|
-
});
|
|
1439
|
-
}
|
|
1440
|
-
return this.sigv4aSigner;
|
|
1441
|
-
}
|
|
1442
|
-
};
|
|
1443
|
-
|
|
1444
|
-
// ../../node_modules/.pnpm/@aws-sdk+s3-request-presigner@3.750.0/node_modules/@aws-sdk/s3-request-presigner/dist-es/constants.js
|
|
1445
|
-
var UNSIGNED_PAYLOAD2 = "UNSIGNED-PAYLOAD";
|
|
1446
|
-
var SHA256_HEADER2 = "X-Amz-Content-Sha256";
|
|
1447
|
-
|
|
1448
|
-
// ../../node_modules/.pnpm/@aws-sdk+s3-request-presigner@3.750.0/node_modules/@aws-sdk/s3-request-presigner/dist-es/presigner.js
|
|
1449
|
-
var S3RequestPresigner = class {
|
|
1450
|
-
signer;
|
|
1451
|
-
constructor(options) {
|
|
1452
|
-
const resolvedOptions = {
|
|
1453
|
-
service: options.signingName || options.service || "s3",
|
|
1454
|
-
uriEscapePath: options.uriEscapePath || false,
|
|
1455
|
-
applyChecksum: options.applyChecksum || false,
|
|
1456
|
-
...options
|
|
1457
|
-
};
|
|
1458
|
-
this.signer = new SignatureV4MultiRegion(resolvedOptions);
|
|
1459
|
-
}
|
|
1460
|
-
presign(requestToSign, { unsignableHeaders = /* @__PURE__ */ new Set(), hoistableHeaders = /* @__PURE__ */ new Set(), unhoistableHeaders = /* @__PURE__ */ new Set(), ...options } = {}) {
|
|
1461
|
-
this.prepareRequest(requestToSign, {
|
|
1462
|
-
unsignableHeaders,
|
|
1463
|
-
unhoistableHeaders,
|
|
1464
|
-
hoistableHeaders
|
|
1465
|
-
});
|
|
1466
|
-
return this.signer.presign(requestToSign, {
|
|
1467
|
-
expiresIn: 900,
|
|
1468
|
-
unsignableHeaders,
|
|
1469
|
-
unhoistableHeaders,
|
|
1470
|
-
...options
|
|
1471
|
-
});
|
|
1472
|
-
}
|
|
1473
|
-
presignWithCredentials(requestToSign, credentials, { unsignableHeaders = /* @__PURE__ */ new Set(), hoistableHeaders = /* @__PURE__ */ new Set(), unhoistableHeaders = /* @__PURE__ */ new Set(), ...options } = {}) {
|
|
1474
|
-
this.prepareRequest(requestToSign, {
|
|
1475
|
-
unsignableHeaders,
|
|
1476
|
-
unhoistableHeaders,
|
|
1477
|
-
hoistableHeaders
|
|
1478
|
-
});
|
|
1479
|
-
return this.signer.presignWithCredentials(requestToSign, credentials, {
|
|
1480
|
-
expiresIn: 900,
|
|
1481
|
-
unsignableHeaders,
|
|
1482
|
-
unhoistableHeaders,
|
|
1483
|
-
...options
|
|
1484
|
-
});
|
|
1485
|
-
}
|
|
1486
|
-
prepareRequest(requestToSign, { unsignableHeaders = /* @__PURE__ */ new Set(), unhoistableHeaders = /* @__PURE__ */ new Set(), hoistableHeaders = /* @__PURE__ */ new Set() } = {}) {
|
|
1487
|
-
unsignableHeaders.add("content-type");
|
|
1488
|
-
Object.keys(requestToSign.headers).map((header) => header.toLowerCase()).filter((header) => header.startsWith("x-amz-server-side-encryption")).forEach((header) => {
|
|
1489
|
-
if (!hoistableHeaders.has(header)) {
|
|
1490
|
-
unhoistableHeaders.add(header);
|
|
1491
|
-
}
|
|
1492
|
-
});
|
|
1493
|
-
requestToSign.headers[SHA256_HEADER2] = UNSIGNED_PAYLOAD2;
|
|
1494
|
-
const currentHostHeader = requestToSign.headers.host;
|
|
1495
|
-
const port = requestToSign.port;
|
|
1496
|
-
const expectedHostHeader = `${requestToSign.hostname}${requestToSign.port != null ? ":" + port : ""}`;
|
|
1497
|
-
if (!currentHostHeader || currentHostHeader === requestToSign.hostname && requestToSign.port != null) {
|
|
1498
|
-
requestToSign.headers.host = expectedHostHeader;
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
};
|
|
1502
|
-
|
|
1503
|
-
// ../../node_modules/.pnpm/@aws-sdk+s3-request-presigner@3.750.0/node_modules/@aws-sdk/s3-request-presigner/dist-es/getSignedUrl.js
|
|
1504
|
-
var getSignedUrl = async (client, command, options = {}) => {
|
|
1505
|
-
let s3Presigner;
|
|
1506
|
-
let region;
|
|
1507
|
-
if (typeof client.config.endpointProvider === "function") {
|
|
1508
|
-
const endpointV2 = await getEndpointFromInstructions(command.input, command.constructor, client.config);
|
|
1509
|
-
const authScheme = endpointV2.properties?.authSchemes?.[0];
|
|
1510
|
-
if (authScheme?.name === "sigv4a") {
|
|
1511
|
-
region = authScheme?.signingRegionSet?.join(",");
|
|
1512
|
-
} else {
|
|
1513
|
-
region = authScheme?.signingRegion;
|
|
1514
|
-
}
|
|
1515
|
-
s3Presigner = new S3RequestPresigner({
|
|
1516
|
-
...client.config,
|
|
1517
|
-
signingName: authScheme?.signingName,
|
|
1518
|
-
region: async () => region
|
|
1519
|
-
});
|
|
1520
|
-
} else {
|
|
1521
|
-
s3Presigner = new S3RequestPresigner(client.config);
|
|
1522
|
-
}
|
|
1523
|
-
const presignInterceptMiddleware = (next, context) => async (args) => {
|
|
1524
|
-
const { request } = args;
|
|
1525
|
-
if (!HttpRequest.isInstance(request)) {
|
|
1526
|
-
throw new Error("Request to be presigned is not an valid HTTP request.");
|
|
1527
|
-
}
|
|
1528
|
-
delete request.headers["amz-sdk-invocation-id"];
|
|
1529
|
-
delete request.headers["amz-sdk-request"];
|
|
1530
|
-
delete request.headers["x-amz-user-agent"];
|
|
1531
|
-
let presigned2;
|
|
1532
|
-
const presignerOptions = {
|
|
1533
|
-
...options,
|
|
1534
|
-
signingRegion: options.signingRegion ?? context["signing_region"] ?? region,
|
|
1535
|
-
signingService: options.signingService ?? context["signing_service"]
|
|
1536
|
-
};
|
|
1537
|
-
if (context.s3ExpressIdentity) {
|
|
1538
|
-
presigned2 = await s3Presigner.presignWithCredentials(request, context.s3ExpressIdentity, presignerOptions);
|
|
1539
|
-
} else {
|
|
1540
|
-
presigned2 = await s3Presigner.presign(request, presignerOptions);
|
|
1541
|
-
}
|
|
1542
|
-
return {
|
|
1543
|
-
response: {},
|
|
1544
|
-
output: {
|
|
1545
|
-
$metadata: { httpStatusCode: 200 },
|
|
1546
|
-
presigned: presigned2
|
|
1547
|
-
}
|
|
1548
|
-
};
|
|
1549
|
-
};
|
|
1550
|
-
const middlewareName = "presignInterceptMiddleware";
|
|
1551
|
-
const clientStack = client.middlewareStack.clone();
|
|
1552
|
-
clientStack.addRelativeTo(presignInterceptMiddleware, {
|
|
1553
|
-
name: middlewareName,
|
|
1554
|
-
relation: "before",
|
|
1555
|
-
toMiddleware: "awsAuthMiddleware",
|
|
1556
|
-
override: true
|
|
1557
|
-
});
|
|
1558
|
-
const handler2 = command.resolveMiddleware(clientStack, client.config, {});
|
|
1559
|
-
const { output } = await handler2({ input: command.input });
|
|
1560
|
-
const { presigned } = output;
|
|
1561
|
-
return formatUrl(presigned);
|
|
1562
|
-
};
|
|
37
|
+
// ../../packages/core/dist/index.js
|
|
38
|
+
var NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
1563
39
|
|
|
1564
40
|
// ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/body.js
|
|
1565
41
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
@@ -3140,7 +1616,7 @@ var convertHeaders = (headers) => {
|
|
|
3140
1616
|
};
|
|
3141
1617
|
var handle = (app2) => {
|
|
3142
1618
|
return async (event, context, callback) => {
|
|
3143
|
-
const res = await app2.fetch(
|
|
1619
|
+
const res = await app2.fetch(createRequest(event), {
|
|
3144
1620
|
event,
|
|
3145
1621
|
context,
|
|
3146
1622
|
callback: (err, result) => {
|
|
@@ -3163,7 +1639,7 @@ var createResult = async (res) => {
|
|
|
3163
1639
|
...isBase64Encoded ? { bodyEncoding: "base64" } : {}
|
|
3164
1640
|
};
|
|
3165
1641
|
};
|
|
3166
|
-
var
|
|
1642
|
+
var createRequest = (event) => {
|
|
3167
1643
|
const queryString = event.Records[0].cf.request.querystring;
|
|
3168
1644
|
const urlPath = `https://${event.Records[0].cf.config.distributionDomainName}${event.Records[0].cf.request.uri}`;
|
|
3169
1645
|
const url = queryString ? `${urlPath}?${queryString}` : urlPath;
|
|
@@ -3198,11 +1674,212 @@ var isContentTypeBinary = (contentType) => {
|
|
|
3198
1674
|
);
|
|
3199
1675
|
};
|
|
3200
1676
|
|
|
3201
|
-
//
|
|
3202
|
-
var
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
1677
|
+
// ../../node_modules/.pnpm/@aws-sdk+cloudfront-signer@3.772.0/node_modules/@aws-sdk/cloudfront-signer/dist-es/sign.js
|
|
1678
|
+
var import_crypto = require("crypto");
|
|
1679
|
+
function getSignedUrl({ dateLessThan, dateGreaterThan, url, keyPairId, privateKey, ipAddress, policy, passphrase }) {
|
|
1680
|
+
const cloudfrontSignBuilder = new CloudfrontSignBuilder({
|
|
1681
|
+
keyPairId,
|
|
1682
|
+
privateKey,
|
|
1683
|
+
passphrase
|
|
1684
|
+
});
|
|
1685
|
+
if (!url && !policy) {
|
|
1686
|
+
throw new Error("@aws-sdk/cloudfront-signer: Please provide 'url' or 'policy'.");
|
|
1687
|
+
}
|
|
1688
|
+
if (policy) {
|
|
1689
|
+
cloudfrontSignBuilder.setCustomPolicy(policy);
|
|
1690
|
+
} else {
|
|
1691
|
+
cloudfrontSignBuilder.setPolicyParameters({
|
|
1692
|
+
url,
|
|
1693
|
+
dateLessThan,
|
|
1694
|
+
dateGreaterThan,
|
|
1695
|
+
ipAddress
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
let baseUrl;
|
|
1699
|
+
if (url) {
|
|
1700
|
+
baseUrl = url;
|
|
1701
|
+
} else if (policy) {
|
|
1702
|
+
const resources = getPolicyResources(policy);
|
|
1703
|
+
if (!resources[0]) {
|
|
1704
|
+
throw new Error("@aws-sdk/cloudfront-signer: No URL provided and unable to determine URL from first policy statement resource.");
|
|
1705
|
+
}
|
|
1706
|
+
baseUrl = resources[0].replace("*://", "https://");
|
|
1707
|
+
}
|
|
1708
|
+
const newURL = new URL(baseUrl);
|
|
1709
|
+
newURL.search = Array.from(newURL.searchParams.entries()).concat(Object.entries(cloudfrontSignBuilder.createCloudfrontAttribute())).filter(([, value]) => value !== void 0).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
|
|
1710
|
+
return getResource(newURL);
|
|
1711
|
+
}
|
|
1712
|
+
function getPolicyResources(policy) {
|
|
1713
|
+
const parsedPolicy = typeof policy === "string" ? JSON.parse(policy) : policy;
|
|
1714
|
+
return (parsedPolicy?.Statement ?? []).map((s) => s.Resource);
|
|
1715
|
+
}
|
|
1716
|
+
function getResource(url) {
|
|
1717
|
+
switch (url.protocol) {
|
|
1718
|
+
case "http:":
|
|
1719
|
+
case "https:":
|
|
1720
|
+
case "ws:":
|
|
1721
|
+
case "wss:":
|
|
1722
|
+
return url.toString();
|
|
1723
|
+
case "rtmp:":
|
|
1724
|
+
return url.pathname.replace(/^\//, "") + url.search + url.hash;
|
|
1725
|
+
default:
|
|
1726
|
+
throw new Error("Invalid URI scheme. Scheme must be one of http, https, or rtmp");
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
var CloudfrontSignBuilder = class {
|
|
1730
|
+
keyPairId;
|
|
1731
|
+
privateKey;
|
|
1732
|
+
passphrase;
|
|
1733
|
+
policy;
|
|
1734
|
+
customPolicy = false;
|
|
1735
|
+
dateLessThan;
|
|
1736
|
+
constructor({ privateKey, keyPairId, passphrase }) {
|
|
1737
|
+
this.keyPairId = keyPairId;
|
|
1738
|
+
this.privateKey = privateKey;
|
|
1739
|
+
this.policy = "";
|
|
1740
|
+
this.passphrase = passphrase;
|
|
1741
|
+
}
|
|
1742
|
+
buildPolicy(args) {
|
|
1743
|
+
const policy = {
|
|
1744
|
+
Statement: [
|
|
1745
|
+
{
|
|
1746
|
+
Resource: args.resource,
|
|
1747
|
+
Condition: {
|
|
1748
|
+
DateLessThan: {
|
|
1749
|
+
"AWS:EpochTime": args.dateLessThan
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
]
|
|
1754
|
+
};
|
|
1755
|
+
if (args.dateGreaterThan) {
|
|
1756
|
+
policy.Statement[0].Condition["DateGreaterThan"] = {
|
|
1757
|
+
"AWS:EpochTime": args.dateGreaterThan
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
if (args.ipAddress) {
|
|
1761
|
+
const cidr = this.parseCIDR(args.ipAddress);
|
|
1762
|
+
policy.Statement[0].Condition["IpAddress"] = {
|
|
1763
|
+
"AWS:SourceIp": cidr
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
return policy;
|
|
1767
|
+
}
|
|
1768
|
+
normalizeBase64(str) {
|
|
1769
|
+
const replacements = {
|
|
1770
|
+
"+": "-",
|
|
1771
|
+
"=": "_",
|
|
1772
|
+
"/": "~"
|
|
1773
|
+
};
|
|
1774
|
+
return str.replace(/[+=/]/g, function(match) {
|
|
1775
|
+
return replacements[match];
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
encodeToBase64(str) {
|
|
1779
|
+
return this.normalizeBase64(Buffer.from(str).toString("base64"));
|
|
1780
|
+
}
|
|
1781
|
+
validateIP(ipStr) {
|
|
1782
|
+
const octets = ipStr.split(".");
|
|
1783
|
+
if (octets.length !== 4) {
|
|
1784
|
+
throw new Error(`IP does not contain four octets.`);
|
|
1785
|
+
}
|
|
1786
|
+
const isValid = octets.every((octet) => {
|
|
1787
|
+
const num = Number(octet);
|
|
1788
|
+
return Number.isInteger(num) && num >= 0 && num <= 255;
|
|
1789
|
+
});
|
|
1790
|
+
if (!isValid) {
|
|
1791
|
+
throw new Error("invalid IP octets");
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
validateMask(maskStr) {
|
|
1795
|
+
const mask = Number(maskStr);
|
|
1796
|
+
const isValid = Number.isInteger(mask) && mask >= 0 && mask <= 32;
|
|
1797
|
+
if (!isValid) {
|
|
1798
|
+
throw new Error("invalid mask");
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
parseCIDR(cidrStr) {
|
|
1802
|
+
try {
|
|
1803
|
+
const cidrParts = cidrStr.split("/");
|
|
1804
|
+
if (cidrParts.some((part) => part.length === 0)) {
|
|
1805
|
+
throw new Error("missing ip or mask part of CIDR");
|
|
1806
|
+
}
|
|
1807
|
+
this.validateIP(cidrParts[0]);
|
|
1808
|
+
let mask = "32";
|
|
1809
|
+
if (cidrParts.length === 2) {
|
|
1810
|
+
this.validateMask(cidrParts[1]);
|
|
1811
|
+
mask = cidrParts[1];
|
|
1812
|
+
}
|
|
1813
|
+
return `${cidrParts[0]}/${mask}`;
|
|
1814
|
+
} catch (error) {
|
|
1815
|
+
const errMessage = `IP address "${cidrStr}" is invalid`;
|
|
1816
|
+
if (error instanceof Error) {
|
|
1817
|
+
throw new Error(`${errMessage} due to ${error.message}.`);
|
|
1818
|
+
} else {
|
|
1819
|
+
throw new Error(`${errMessage}.`);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
epochTime(date) {
|
|
1824
|
+
return Math.round(date.getTime() / 1e3);
|
|
1825
|
+
}
|
|
1826
|
+
parseDate(date) {
|
|
1827
|
+
if (!date) {
|
|
1828
|
+
return void 0;
|
|
1829
|
+
}
|
|
1830
|
+
const parsedDate = new Date(date);
|
|
1831
|
+
return isNaN(parsedDate.getTime()) ? void 0 : this.epochTime(parsedDate);
|
|
1832
|
+
}
|
|
1833
|
+
parseDateWindow(expiration, start) {
|
|
1834
|
+
const dateLessThan = this.parseDate(expiration);
|
|
1835
|
+
if (!dateLessThan) {
|
|
1836
|
+
throw new Error("dateLessThan is invalid. Ensure the date value is compatible with the Date constructor.");
|
|
1837
|
+
}
|
|
1838
|
+
return {
|
|
1839
|
+
dateLessThan,
|
|
1840
|
+
dateGreaterThan: this.parseDate(start)
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
signData(data, privateKey, passphrase) {
|
|
1844
|
+
const sign = (0, import_crypto.createSign)("RSA-SHA1");
|
|
1845
|
+
sign.update(data);
|
|
1846
|
+
return sign.sign({ key: privateKey, passphrase }, "base64");
|
|
1847
|
+
}
|
|
1848
|
+
signPolicy(policy, privateKey, passphrase) {
|
|
1849
|
+
return this.normalizeBase64(this.signData(policy, privateKey, passphrase));
|
|
1850
|
+
}
|
|
1851
|
+
setCustomPolicy(policy) {
|
|
1852
|
+
this.customPolicy = true;
|
|
1853
|
+
this.policy = policy;
|
|
1854
|
+
}
|
|
1855
|
+
setPolicyParameters({ url, dateLessThan, dateGreaterThan, ipAddress }) {
|
|
1856
|
+
if (!url || !dateLessThan) {
|
|
1857
|
+
return false;
|
|
1858
|
+
}
|
|
1859
|
+
const resource = getResource(new URL(url));
|
|
1860
|
+
const parsedDates = this.parseDateWindow(dateLessThan, dateGreaterThan);
|
|
1861
|
+
this.dateLessThan = parsedDates.dateLessThan;
|
|
1862
|
+
this.customPolicy = Boolean(parsedDates.dateGreaterThan) || Boolean(ipAddress);
|
|
1863
|
+
this.policy = JSON.stringify(this.buildPolicy({
|
|
1864
|
+
resource,
|
|
1865
|
+
ipAddress,
|
|
1866
|
+
dateLessThan: parsedDates.dateLessThan,
|
|
1867
|
+
dateGreaterThan: parsedDates.dateGreaterThan
|
|
1868
|
+
}));
|
|
1869
|
+
}
|
|
1870
|
+
createCloudfrontAttribute() {
|
|
1871
|
+
if (!Boolean(this.policy)) {
|
|
1872
|
+
throw new Error("Invalid policy");
|
|
1873
|
+
}
|
|
1874
|
+
const signature = this.signPolicy(this.policy, this.privateKey, this.passphrase);
|
|
1875
|
+
return {
|
|
1876
|
+
Expires: this.customPolicy ? void 0 : this.dateLessThan,
|
|
1877
|
+
Policy: this.customPolicy ? this.encodeToBase64(this.policy) : void 0,
|
|
1878
|
+
"Key-Pair-Id": this.keyPairId,
|
|
1879
|
+
Signature: signature
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
3206
1883
|
|
|
3207
1884
|
// ../js/dist/index.js
|
|
3208
1885
|
var __webpack_modules__ = {
|
|
@@ -4550,15 +3227,6 @@ function __webpack_require__(moduleId) {
|
|
|
4550
3227
|
(() => {
|
|
4551
3228
|
__webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
4552
3229
|
})();
|
|
4553
|
-
var isNullable = (value) => null == value;
|
|
4554
|
-
var checkForRollback = (bundles, currentBundleId) => {
|
|
4555
|
-
if (currentBundleId === NIL_UUID) return false;
|
|
4556
|
-
if (0 === bundles.length) return true;
|
|
4557
|
-
const enabled = bundles.find((item) => item.id === currentBundleId)?.enabled;
|
|
4558
|
-
const availableOldVersion = bundles.find((item) => item.id.localeCompare(currentBundleId) < 0 && item.enabled)?.enabled;
|
|
4559
|
-
if (isNullable(enabled)) return Boolean(availableOldVersion);
|
|
4560
|
-
return !enabled;
|
|
4561
|
-
};
|
|
4562
3230
|
var semver = __webpack_require__("../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/index.js");
|
|
4563
3231
|
var semver_default = /* @__PURE__ */ __webpack_require__.n(semver);
|
|
4564
3232
|
var semverSatisfies = (targetAppVersion, currentVersion) => {
|
|
@@ -4566,85 +3234,123 @@ var semverSatisfies = (targetAppVersion, currentVersion) => {
|
|
|
4566
3234
|
if (!currentCoerce) return false;
|
|
4567
3235
|
return semver_default().satisfies(currentCoerce.version, targetAppVersion);
|
|
4568
3236
|
};
|
|
4569
|
-
var
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
3237
|
+
var INIT_BUNDLE_ROLLBACK_UPDATE_INFO = {
|
|
3238
|
+
message: null,
|
|
3239
|
+
id: NIL_UUID,
|
|
3240
|
+
shouldForceUpdate: true,
|
|
3241
|
+
status: "ROLLBACK"
|
|
3242
|
+
};
|
|
3243
|
+
var makeResponse = (bundle, status) => ({
|
|
3244
|
+
id: bundle.id,
|
|
3245
|
+
message: bundle.message,
|
|
3246
|
+
shouldForceUpdate: "ROLLBACK" === status ? true : bundle.shouldForceUpdate,
|
|
3247
|
+
status
|
|
3248
|
+
});
|
|
3249
|
+
var getUpdateInfo = async (bundles, { platform, bundleId, appVersion, minBundleId = NIL_UUID, channel = "production" }) => {
|
|
3250
|
+
const candidateBundles = [];
|
|
3251
|
+
for (const b of bundles) if (!(b.platform !== platform || b.channel !== channel || !semverSatisfies(b.targetAppVersion, appVersion) || !b.enabled || minBundleId && b.id.localeCompare(minBundleId) < 0)) candidateBundles.push(b);
|
|
3252
|
+
if (0 === candidateBundles.length) {
|
|
3253
|
+
if (bundleId === NIL_UUID || minBundleId && bundleId.localeCompare(minBundleId) <= 0) return null;
|
|
3254
|
+
return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
|
|
3255
|
+
}
|
|
3256
|
+
let latestCandidate = null;
|
|
3257
|
+
let updateCandidate = null;
|
|
3258
|
+
let rollbackCandidate = null;
|
|
3259
|
+
let currentBundle;
|
|
3260
|
+
for (const b of candidateBundles) {
|
|
3261
|
+
if (!latestCandidate || b.id.localeCompare(latestCandidate.id) > 0) latestCandidate = b;
|
|
3262
|
+
if (b.id === bundleId) currentBundle = b;
|
|
3263
|
+
else if (bundleId !== NIL_UUID) {
|
|
3264
|
+
if (b.id.localeCompare(bundleId) > 0) {
|
|
3265
|
+
if (!updateCandidate || b.id.localeCompare(updateCandidate.id) > 0) updateCandidate = b;
|
|
3266
|
+
} else if (b.id.localeCompare(bundleId) < 0) {
|
|
3267
|
+
if (!rollbackCandidate || b.id.localeCompare(rollbackCandidate.id) > 0) rollbackCandidate = b;
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
if (bundleId === NIL_UUID) {
|
|
3272
|
+
if (latestCandidate && latestCandidate.id.localeCompare(bundleId) > 0) return makeResponse(latestCandidate, "UPDATE");
|
|
4582
3273
|
return null;
|
|
4583
3274
|
}
|
|
4584
|
-
if (
|
|
4585
|
-
if (
|
|
4586
|
-
|
|
4587
|
-
if (latestBundle.id.localeCompare(bundleId) > 0) return {
|
|
4588
|
-
id: latestBundle.id,
|
|
4589
|
-
shouldForceUpdate: Boolean(latestBundle.shouldForceUpdate),
|
|
4590
|
-
fileUrl: latestBundle.fileUrl,
|
|
4591
|
-
fileHash: latestBundle.fileHash,
|
|
4592
|
-
status: "UPDATE"
|
|
4593
|
-
};
|
|
4594
|
-
return {
|
|
4595
|
-
id: latestBundle.id,
|
|
4596
|
-
shouldForceUpdate: true,
|
|
4597
|
-
fileUrl: latestBundle.fileUrl,
|
|
4598
|
-
fileHash: latestBundle.fileHash,
|
|
4599
|
-
status: "ROLLBACK"
|
|
4600
|
-
};
|
|
4601
|
-
}
|
|
3275
|
+
if (currentBundle) {
|
|
3276
|
+
if (latestCandidate && latestCandidate.id.localeCompare(currentBundle.id) > 0) return makeResponse(latestCandidate, "UPDATE");
|
|
3277
|
+
return null;
|
|
4602
3278
|
}
|
|
4603
|
-
if (
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
fileHash: latestBundle.fileHash,
|
|
4608
|
-
status: "UPDATE"
|
|
4609
|
-
};
|
|
4610
|
-
return null;
|
|
3279
|
+
if (updateCandidate) return makeResponse(updateCandidate, "UPDATE");
|
|
3280
|
+
if (rollbackCandidate) return makeResponse(rollbackCandidate, "ROLLBACK");
|
|
3281
|
+
if (minBundleId && bundleId.localeCompare(minBundleId) <= 0) return null;
|
|
3282
|
+
return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
|
|
4611
3283
|
};
|
|
4612
3284
|
var filterCompatibleAppVersions = (targetAppVersionList, currentVersion) => {
|
|
4613
3285
|
const compatibleAppVersionList = targetAppVersionList.filter((version) => semverSatisfies(version, currentVersion));
|
|
4614
3286
|
return compatibleAppVersionList.sort((a, b) => b.localeCompare(a));
|
|
4615
3287
|
};
|
|
3288
|
+
var encoder = new TextEncoder();
|
|
3289
|
+
var decoder = new TextDecoder();
|
|
3290
|
+
var minute = 60;
|
|
3291
|
+
var hour = 60 * minute;
|
|
3292
|
+
var day = 24 * hour;
|
|
3293
|
+
var week = 7 * day;
|
|
3294
|
+
var year = 365.25 * day;
|
|
4616
3295
|
|
|
4617
3296
|
// lambda/getUpdateInfo.ts
|
|
4618
|
-
var
|
|
3297
|
+
var getCdnJson = async ({
|
|
3298
|
+
baseUrl,
|
|
3299
|
+
key,
|
|
3300
|
+
keyPairId,
|
|
3301
|
+
privateKey
|
|
3302
|
+
}) => {
|
|
4619
3303
|
try {
|
|
4620
|
-
const
|
|
4621
|
-
|
|
4622
|
-
|
|
3304
|
+
const url = new URL(baseUrl);
|
|
3305
|
+
url.pathname = `/${key}`;
|
|
3306
|
+
const signedUrl = getSignedUrl({
|
|
3307
|
+
url: url.toString(),
|
|
3308
|
+
keyPairId,
|
|
3309
|
+
privateKey,
|
|
3310
|
+
dateLessThan: new Date(Date.now() + 60 * 1e3).toISOString()
|
|
3311
|
+
});
|
|
3312
|
+
const res = await fetch(signedUrl, {
|
|
3313
|
+
headers: {
|
|
3314
|
+
"Content-Type": "application/json"
|
|
3315
|
+
}
|
|
3316
|
+
});
|
|
3317
|
+
if (!res.ok) {
|
|
4623
3318
|
return null;
|
|
4624
3319
|
}
|
|
4625
|
-
|
|
4626
|
-
return JSON.parse(jsonString);
|
|
3320
|
+
return res.json();
|
|
4627
3321
|
} catch {
|
|
4628
3322
|
return null;
|
|
4629
3323
|
}
|
|
4630
3324
|
};
|
|
4631
|
-
var getUpdateInfo2 = async (
|
|
3325
|
+
var getUpdateInfo2 = async ({
|
|
3326
|
+
baseUrl,
|
|
3327
|
+
keyPairId,
|
|
3328
|
+
privateKey
|
|
3329
|
+
}, {
|
|
4632
3330
|
platform,
|
|
4633
3331
|
appVersion,
|
|
4634
|
-
bundleId
|
|
3332
|
+
bundleId,
|
|
3333
|
+
minBundleId = NIL_UUID,
|
|
3334
|
+
channel = "production"
|
|
4635
3335
|
}) => {
|
|
4636
|
-
const targetAppVersions = await
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
3336
|
+
const targetAppVersions = await getCdnJson({
|
|
3337
|
+
baseUrl,
|
|
3338
|
+
key: `${channel}/${platform}/target-app-versions.json`,
|
|
3339
|
+
keyPairId,
|
|
3340
|
+
privateKey
|
|
3341
|
+
});
|
|
4641
3342
|
const matchingVersions = filterCompatibleAppVersions(
|
|
4642
3343
|
targetAppVersions ?? [],
|
|
4643
3344
|
appVersion
|
|
4644
3345
|
);
|
|
4645
3346
|
const results = await Promise.allSettled(
|
|
4646
3347
|
matchingVersions.map(
|
|
4647
|
-
(targetAppVersion) =>
|
|
3348
|
+
(targetAppVersion) => getCdnJson({
|
|
3349
|
+
baseUrl,
|
|
3350
|
+
key: `${channel}/${platform}/${targetAppVersion}/update.json`,
|
|
3351
|
+
keyPairId,
|
|
3352
|
+
privateKey
|
|
3353
|
+
})
|
|
4648
3354
|
)
|
|
4649
3355
|
);
|
|
4650
3356
|
const bundles = results.filter(
|
|
@@ -4653,39 +3359,44 @@ var getUpdateInfo2 = async (s32, bucketName, {
|
|
|
4653
3359
|
return getUpdateInfo(bundles, {
|
|
4654
3360
|
platform,
|
|
4655
3361
|
bundleId,
|
|
4656
|
-
appVersion
|
|
3362
|
+
appVersion,
|
|
3363
|
+
minBundleId,
|
|
3364
|
+
channel
|
|
4657
3365
|
});
|
|
4658
3366
|
};
|
|
4659
3367
|
|
|
4660
|
-
// lambda/
|
|
4661
|
-
var
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
return { isS3Url: true, bucket, key };
|
|
4670
|
-
} catch {
|
|
4671
|
-
return { isS3Url: false };
|
|
4672
|
-
}
|
|
4673
|
-
}
|
|
4674
|
-
async function createPresignedUrl(url) {
|
|
4675
|
-
const { isS3Url, bucket, key } = parseS3Url(url);
|
|
4676
|
-
if (!isS3Url || !bucket || !key) {
|
|
4677
|
-
return url;
|
|
3368
|
+
// lambda/withSignedUrl.ts
|
|
3369
|
+
var withSignedUrl = async ({
|
|
3370
|
+
data,
|
|
3371
|
+
reqUrl,
|
|
3372
|
+
keyPairId,
|
|
3373
|
+
privateKey
|
|
3374
|
+
}) => {
|
|
3375
|
+
if (!data) {
|
|
3376
|
+
return null;
|
|
4678
3377
|
}
|
|
4679
|
-
|
|
4680
|
-
|
|
3378
|
+
if (data.id === NIL_UUID) {
|
|
3379
|
+
return { ...data, fileUrl: null };
|
|
3380
|
+
}
|
|
3381
|
+
const key = `${data.id}/bundle.zip`;
|
|
3382
|
+
const url = new URL(reqUrl);
|
|
3383
|
+
url.pathname = `/${key}`;
|
|
3384
|
+
const signedUrl = getSignedUrl({
|
|
3385
|
+
url: url.toString(),
|
|
3386
|
+
keyPairId,
|
|
3387
|
+
privateKey,
|
|
3388
|
+
dateLessThan: new Date(Date.now() + 60 * 1e3).toISOString()
|
|
3389
|
+
// Valid for 60 seconds
|
|
4681
3390
|
});
|
|
4682
|
-
}
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
3391
|
+
return { ...data, fileUrl: signedUrl };
|
|
3392
|
+
};
|
|
3393
|
+
|
|
3394
|
+
// lambda/index.ts
|
|
3395
|
+
var CLOUDFRONT_KEY_PAIR_ID = HotUpdater.CLOUDFRONT_KEY_PAIR_ID;
|
|
3396
|
+
var CLOUDFRONT_PRIVATE_KEY = Buffer.from(
|
|
3397
|
+
HotUpdater.CLOUDFRONT_PRIVATE_KEY_BASE64,
|
|
3398
|
+
"base64"
|
|
3399
|
+
).toString("utf-8");
|
|
4689
3400
|
var app = new Hono2();
|
|
4690
3401
|
app.get("/api/check-update", async (c) => {
|
|
4691
3402
|
try {
|
|
@@ -4693,30 +3404,45 @@ app.get("/api/check-update", async (c) => {
|
|
|
4693
3404
|
const bundleId = headers["x-bundle-id"]?.[0]?.value;
|
|
4694
3405
|
const appPlatform = headers["x-app-platform"]?.[0]?.value;
|
|
4695
3406
|
const appVersion = headers["x-app-version"]?.[0]?.value;
|
|
3407
|
+
const minBundleId = headers["x-min-bundle-id"]?.[0]?.value ?? NIL_UUID;
|
|
3408
|
+
const channel = headers["x-channel"]?.[0]?.value ?? "production";
|
|
4696
3409
|
if (!bundleId || !appPlatform || !appVersion) {
|
|
4697
3410
|
return c.json({ error: "Missing required headers." }, 400);
|
|
4698
3411
|
}
|
|
4699
|
-
const
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
appVersion
|
|
4703
|
-
});
|
|
4704
|
-
if (!updateInfo) {
|
|
4705
|
-
return c.json(null);
|
|
3412
|
+
const cdnHost = headers["host"]?.[0]?.value;
|
|
3413
|
+
if (!cdnHost) {
|
|
3414
|
+
return c.json({ error: "Missing host header." }, 500);
|
|
4706
3415
|
}
|
|
4707
|
-
const
|
|
4708
|
-
return c.json(finalInfo);
|
|
4709
|
-
} catch {
|
|
4710
|
-
return c.json(
|
|
3416
|
+
const updateInfo = await getUpdateInfo2(
|
|
4711
3417
|
{
|
|
4712
|
-
|
|
3418
|
+
baseUrl: c.req.url,
|
|
3419
|
+
keyPairId: CLOUDFRONT_KEY_PAIR_ID,
|
|
3420
|
+
privateKey: CLOUDFRONT_PRIVATE_KEY
|
|
4713
3421
|
},
|
|
4714
|
-
|
|
3422
|
+
{
|
|
3423
|
+
platform: appPlatform,
|
|
3424
|
+
bundleId,
|
|
3425
|
+
appVersion,
|
|
3426
|
+
minBundleId,
|
|
3427
|
+
channel
|
|
3428
|
+
}
|
|
4715
3429
|
);
|
|
3430
|
+
if (!updateInfo) {
|
|
3431
|
+
return c.json(null);
|
|
3432
|
+
}
|
|
3433
|
+
const appUpdateInfo = await withSignedUrl({
|
|
3434
|
+
data: updateInfo,
|
|
3435
|
+
reqUrl: c.req.url,
|
|
3436
|
+
keyPairId: CLOUDFRONT_KEY_PAIR_ID,
|
|
3437
|
+
privateKey: CLOUDFRONT_PRIVATE_KEY
|
|
3438
|
+
});
|
|
3439
|
+
return c.json(appUpdateInfo);
|
|
3440
|
+
} catch {
|
|
3441
|
+
return c.json({ error: "Internal Server Error" }, 500);
|
|
4716
3442
|
}
|
|
4717
3443
|
});
|
|
4718
3444
|
app.get("*", async (c) => {
|
|
4719
|
-
c.env.callback(null, c.env.request);
|
|
3445
|
+
return c.env.callback(null, c.env.request);
|
|
4720
3446
|
});
|
|
4721
3447
|
var handler = handle(app);
|
|
4722
3448
|
// Annotate the CommonJS export names for ESM import in node:
|