@semiont/graph 0.5.11 → 0.5.12

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.
Files changed (55) hide show
  1. package/dist/{chunk-SQRFW5JO.js → chunk-2FZWFAHI.js} +2 -2
  2. package/dist/{chunk-PFPGJZE5.js → chunk-7W3WYDYY.js} +781 -655
  3. package/dist/chunk-7W3WYDYY.js.map +1 -0
  4. package/dist/{chunk-QGGTFZBT.js → chunk-ANBNC7ET.js} +9 -9
  5. package/dist/chunk-ANBNC7ET.js.map +1 -0
  6. package/dist/{chunk-MPEJCIW2.js → chunk-FUH65BXZ.js} +3 -3
  7. package/dist/{chunk-2WJWKJQU.js → chunk-SIIGOCAF.js} +61 -167
  8. package/dist/chunk-SIIGOCAF.js.map +1 -0
  9. package/dist/chunk-TTCF2MVW.js +2238 -0
  10. package/dist/chunk-TTCF2MVW.js.map +1 -0
  11. package/dist/dist-es-2TLZH4GR.js +286 -0
  12. package/dist/dist-es-2TLZH4GR.js.map +1 -0
  13. package/dist/{dist-es-L3LHQ2H4.js → dist-es-3LHYAN2Z.js} +3 -3
  14. package/dist/{dist-es-CKTPSCQB.js → dist-es-ERGUA43M.js} +119 -258
  15. package/dist/dist-es-ERGUA43M.js.map +1 -0
  16. package/dist/{dist-es-TZGZRHJL.js → dist-es-FF2QSTPC.js} +19 -13
  17. package/dist/dist-es-FF2QSTPC.js.map +1 -0
  18. package/dist/{dist-es-RQSF5AZ5.js → dist-es-FYIEMWHW.js} +4 -4
  19. package/dist/{dist-es-UUBLUHQK.js → dist-es-QUWKNR3E.js} +2 -2
  20. package/dist/{dist-es-SHXLUESU.js → dist-es-VWWFUSHN.js} +6 -6
  21. package/dist/dist-es-WPIJNMD4.js +220 -0
  22. package/dist/dist-es-WPIJNMD4.js.map +1 -0
  23. package/dist/{dist-es-G4L6NCN5.js → dist-es-YDMYLFPU.js} +4 -4
  24. package/dist/index.js +45 -19
  25. package/dist/index.js.map +1 -1
  26. package/dist/{loadSso-RFRDEFSI.js → loadSso-XDB76252.js} +8 -10
  27. package/dist/{loadSso-RFRDEFSI.js.map → loadSso-XDB76252.js.map} +1 -1
  28. package/dist/{signin-U5IGPIWD.js → signin-AHFRIARE.js} +8 -10
  29. package/dist/{signin-U5IGPIWD.js.map → signin-AHFRIARE.js.map} +1 -1
  30. package/dist/{sso-oidc-GGDHF3M3.js → sso-oidc-3B3W33KS.js} +8 -10
  31. package/dist/{sso-oidc-GGDHF3M3.js.map → sso-oidc-3B3W33KS.js.map} +1 -1
  32. package/dist/{sts-3TIKUUIA.js → sts-OXRUFMHG.js} +10 -16
  33. package/dist/sts-OXRUFMHG.js.map +1 -0
  34. package/package.json +6 -6
  35. package/dist/chunk-2WJWKJQU.js.map +0 -1
  36. package/dist/chunk-5PYYJZCY.js +0 -576
  37. package/dist/chunk-5PYYJZCY.js.map +0 -1
  38. package/dist/chunk-6C6SP2SJ.js +0 -1113
  39. package/dist/chunk-6C6SP2SJ.js.map +0 -1
  40. package/dist/chunk-BRCSBLGI.js +0 -694
  41. package/dist/chunk-BRCSBLGI.js.map +0 -1
  42. package/dist/chunk-PFPGJZE5.js.map +0 -1
  43. package/dist/chunk-QGGTFZBT.js.map +0 -1
  44. package/dist/dist-es-5CZKMZ7F.js +0 -492
  45. package/dist/dist-es-5CZKMZ7F.js.map +0 -1
  46. package/dist/dist-es-CKTPSCQB.js.map +0 -1
  47. package/dist/dist-es-TZGZRHJL.js.map +0 -1
  48. package/dist/sts-3TIKUUIA.js.map +0 -1
  49. /package/dist/{chunk-SQRFW5JO.js.map → chunk-2FZWFAHI.js.map} +0 -0
  50. /package/dist/{chunk-MPEJCIW2.js.map → chunk-FUH65BXZ.js.map} +0 -0
  51. /package/dist/{dist-es-L3LHQ2H4.js.map → dist-es-3LHYAN2Z.js.map} +0 -0
  52. /package/dist/{dist-es-RQSF5AZ5.js.map → dist-es-FYIEMWHW.js.map} +0 -0
  53. /package/dist/{dist-es-UUBLUHQK.js.map → dist-es-QUWKNR3E.js.map} +0 -0
  54. /package/dist/{dist-es-SHXLUESU.js.map → dist-es-VWWFUSHN.js.map} +0 -0
  55. /package/dist/{dist-es-G4L6NCN5.js.map → dist-es-YDMYLFPU.js.map} +0 -0
@@ -0,0 +1,2238 @@
1
+ import {
2
+ decorateServiceException,
3
+ doesIdentityRequireRefresh,
4
+ getValueFromTextNode,
5
+ isIdentityExpired,
6
+ memoizeIdentityProvider,
7
+ normalizeProvider as normalizeProvider2,
8
+ setCredentialFeature
9
+ } from "./chunk-SIIGOCAF.js";
10
+ import {
11
+ FromStringShapeDeserializer,
12
+ HttpBindingProtocol,
13
+ HttpInterceptingShapeDeserializer,
14
+ HttpInterceptingShapeSerializer,
15
+ HttpRequest,
16
+ HttpResponse,
17
+ NormalizedSchema,
18
+ ProviderError,
19
+ RpcProtocol,
20
+ TypeRegistry,
21
+ collectBody,
22
+ deref,
23
+ determineTimestampFormat,
24
+ escapeUri,
25
+ extendedEncodeURIComponent,
26
+ normalizeProvider
27
+ } from "./chunk-7W3WYDYY.js";
28
+ import {
29
+ LazyJsonString,
30
+ NumericValue,
31
+ dateToUtcString,
32
+ fromBase64,
33
+ fromHex,
34
+ fromUtf8,
35
+ generateIdempotencyToken,
36
+ isArrayBuffer,
37
+ parseEpochTimestamp,
38
+ parseRfc3339DateTimeWithOffset,
39
+ parseRfc7231DateTime,
40
+ toBase64,
41
+ toHex,
42
+ toUint8Array,
43
+ toUtf8
44
+ } from "./chunk-FG7DZRU2.js";
45
+
46
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/getDateHeader.js
47
+ var getDateHeader = (response) => HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : void 0;
48
+
49
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/getSkewCorrectedDate.js
50
+ var getSkewCorrectedDate = (systemClockOffset) => new Date(Date.now() + systemClockOffset);
51
+
52
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/isClockSkewed.js
53
+ var isClockSkewed = (clockTime, systemClockOffset) => Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 3e5;
54
+
55
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js
56
+ var getUpdatedSystemClockOffset = (clockTime, currentSystemClockOffset) => {
57
+ const clockTimeInMs = Date.parse(clockTime);
58
+ if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) {
59
+ return clockTimeInMs - Date.now();
60
+ }
61
+ return currentSystemClockOffset;
62
+ };
63
+
64
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js
65
+ var throwSigningPropertyError = (name, property) => {
66
+ if (!property) {
67
+ throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`);
68
+ }
69
+ return property;
70
+ };
71
+ var validateSigningProperties = async (signingProperties) => {
72
+ const context = throwSigningPropertyError("context", signingProperties.context);
73
+ const config = throwSigningPropertyError("config", signingProperties.config);
74
+ const authScheme = context.endpointV2?.properties?.authSchemes?.[0];
75
+ const signerFunction = throwSigningPropertyError("signer", config.signer);
76
+ const signer = await signerFunction(authScheme);
77
+ const signingRegion = signingProperties?.signingRegion;
78
+ const signingRegionSet = signingProperties?.signingRegionSet;
79
+ const signingName = signingProperties?.signingName;
80
+ return {
81
+ config,
82
+ signer,
83
+ signingRegion,
84
+ signingRegionSet,
85
+ signingName
86
+ };
87
+ };
88
+ var AwsSdkSigV4Signer = class {
89
+ async sign(httpRequest, identity, signingProperties) {
90
+ if (!HttpRequest.isInstance(httpRequest)) {
91
+ throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
92
+ }
93
+ const validatedProps = await validateSigningProperties(signingProperties);
94
+ const { config, signer } = validatedProps;
95
+ let { signingRegion, signingName } = validatedProps;
96
+ const handlerExecutionContext = signingProperties.context;
97
+ if (handlerExecutionContext?.authSchemes?.length ?? 0 > 1) {
98
+ const [first, second] = handlerExecutionContext.authSchemes;
99
+ if (first?.name === "sigv4a" && second?.name === "sigv4") {
100
+ signingRegion = second?.signingRegion ?? signingRegion;
101
+ signingName = second?.signingName ?? signingName;
102
+ }
103
+ }
104
+ signingProperties._preRequestSystemClockOffset = config.systemClockOffset;
105
+ const signedRequest = await signer.sign(httpRequest, {
106
+ signingDate: getSkewCorrectedDate(config.systemClockOffset),
107
+ signingRegion,
108
+ signingService: signingName
109
+ });
110
+ return signedRequest;
111
+ }
112
+ errorHandler(signingProperties) {
113
+ return (error) => {
114
+ const errorException = error;
115
+ const serverTime = errorException.ServerTime ?? getDateHeader(errorException.$response);
116
+ if (serverTime) {
117
+ const config = throwSigningPropertyError("config", signingProperties.config);
118
+ const preRequestOffset = signingProperties._preRequestSystemClockOffset;
119
+ const newOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset);
120
+ const isLocalCorrection = newOffset !== config.systemClockOffset;
121
+ const isConcurrentCorrection = preRequestOffset !== void 0 && preRequestOffset !== newOffset;
122
+ const clockSkewCorrected = isLocalCorrection || isConcurrentCorrection;
123
+ if (clockSkewCorrected && errorException.$metadata) {
124
+ config.systemClockOffset = newOffset;
125
+ errorException.$metadata.clockSkewCorrected = true;
126
+ }
127
+ }
128
+ throw error;
129
+ };
130
+ }
131
+ successHandler(httpResponse, signingProperties) {
132
+ const dateHeader = getDateHeader(httpResponse);
133
+ if (dateHeader) {
134
+ const config = throwSigningPropertyError("config", signingProperties.config);
135
+ config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset);
136
+ }
137
+ }
138
+ };
139
+
140
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.js
141
+ var AwsSdkSigV4ASigner = class extends AwsSdkSigV4Signer {
142
+ async sign(httpRequest, identity, signingProperties) {
143
+ if (!HttpRequest.isInstance(httpRequest)) {
144
+ throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
145
+ }
146
+ const { config, signer, signingRegion, signingRegionSet, signingName } = await validateSigningProperties(signingProperties);
147
+ const configResolvedSigningRegionSet = await config.sigv4aSigningRegionSet?.();
148
+ const multiRegionOverride = (configResolvedSigningRegionSet ?? signingRegionSet ?? [signingRegion]).join(",");
149
+ signingProperties._preRequestSystemClockOffset = config.systemClockOffset;
150
+ const signedRequest = await signer.sign(httpRequest, {
151
+ signingDate: getSkewCorrectedDate(config.systemClockOffset),
152
+ signingRegion: multiRegionOverride,
153
+ signingService: signingName
154
+ });
155
+ return signedRequest;
156
+ }
157
+ };
158
+
159
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/getArrayForCommaSeparatedString.js
160
+ var getArrayForCommaSeparatedString = (str) => typeof str === "string" && str.length > 0 ? str.split(",").map((item) => item.trim()) : [];
161
+
162
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/getBearerTokenEnvKey.js
163
+ var getBearerTokenEnvKey = (signingName) => `AWS_BEARER_TOKEN_${signingName.replace(/[\s-]/g, "_").toUpperCase()}`;
164
+
165
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.js
166
+ var NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY = "AWS_AUTH_SCHEME_PREFERENCE";
167
+ var NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY = "auth_scheme_preference";
168
+ var NODE_AUTH_SCHEME_PREFERENCE_OPTIONS = {
169
+ environmentVariableSelector: (env, options) => {
170
+ if (options?.signingName) {
171
+ const bearerTokenKey = getBearerTokenEnvKey(options.signingName);
172
+ if (bearerTokenKey in env)
173
+ return ["httpBearerAuth"];
174
+ }
175
+ if (!(NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY in env))
176
+ return void 0;
177
+ return getArrayForCommaSeparatedString(env[NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY]);
178
+ },
179
+ configFileSelector: (profile) => {
180
+ if (!(NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY in profile))
181
+ return void 0;
182
+ return getArrayForCommaSeparatedString(profile[NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY]);
183
+ },
184
+ default: []
185
+ };
186
+
187
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.js
188
+ var resolveAwsSdkSigV4AConfig = (config) => {
189
+ config.sigv4aSigningRegionSet = normalizeProvider2(config.sigv4aSigningRegionSet);
190
+ return config;
191
+ };
192
+ var NODE_SIGV4A_CONFIG_OPTIONS = {
193
+ environmentVariableSelector(env) {
194
+ if (env.AWS_SIGV4A_SIGNING_REGION_SET) {
195
+ return env.AWS_SIGV4A_SIGNING_REGION_SET.split(",").map((_) => _.trim());
196
+ }
197
+ throw new ProviderError("AWS_SIGV4A_SIGNING_REGION_SET not set in env.", {
198
+ tryNextLink: true
199
+ });
200
+ },
201
+ configFileSelector(profile) {
202
+ if (profile.sigv4a_signing_region_set) {
203
+ return (profile.sigv4a_signing_region_set ?? "").split(",").map((_) => _.trim());
204
+ }
205
+ throw new ProviderError("sigv4a_signing_region_set not set in profile.", {
206
+ tryNextLink: true
207
+ });
208
+ },
209
+ default: void 0
210
+ };
211
+
212
+ // ../../node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js
213
+ var HeaderFormatter = class {
214
+ format(headers) {
215
+ const chunks = [];
216
+ for (const headerName of Object.keys(headers)) {
217
+ const bytes = fromUtf8(headerName);
218
+ chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
219
+ }
220
+ const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
221
+ let position = 0;
222
+ for (const chunk of chunks) {
223
+ out.set(chunk, position);
224
+ position += chunk.byteLength;
225
+ }
226
+ return out;
227
+ }
228
+ formatHeaderValue(header) {
229
+ switch (header.type) {
230
+ case "boolean":
231
+ return Uint8Array.from([header.value ? 0 : 1]);
232
+ case "byte":
233
+ return Uint8Array.from([2, header.value]);
234
+ case "short":
235
+ const shortView = new DataView(new ArrayBuffer(3));
236
+ shortView.setUint8(0, 3);
237
+ shortView.setInt16(1, header.value, false);
238
+ return new Uint8Array(shortView.buffer);
239
+ case "integer":
240
+ const intView = new DataView(new ArrayBuffer(5));
241
+ intView.setUint8(0, 4);
242
+ intView.setInt32(1, header.value, false);
243
+ return new Uint8Array(intView.buffer);
244
+ case "long":
245
+ const longBytes = new Uint8Array(9);
246
+ longBytes[0] = 5;
247
+ longBytes.set(header.value.bytes, 1);
248
+ return longBytes;
249
+ case "binary":
250
+ const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
251
+ binView.setUint8(0, 6);
252
+ binView.setUint16(1, header.value.byteLength, false);
253
+ const binBytes = new Uint8Array(binView.buffer);
254
+ binBytes.set(header.value, 3);
255
+ return binBytes;
256
+ case "string":
257
+ const utf8Bytes = fromUtf8(header.value);
258
+ const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
259
+ strView.setUint8(0, 7);
260
+ strView.setUint16(1, utf8Bytes.byteLength, false);
261
+ const strBytes = new Uint8Array(strView.buffer);
262
+ strBytes.set(utf8Bytes, 3);
263
+ return strBytes;
264
+ case "timestamp":
265
+ const tsBytes = new Uint8Array(9);
266
+ tsBytes[0] = 8;
267
+ tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
268
+ return tsBytes;
269
+ case "uuid":
270
+ if (!UUID_PATTERN.test(header.value)) {
271
+ throw new Error(`Invalid UUID received: ${header.value}`);
272
+ }
273
+ const uuidBytes = new Uint8Array(17);
274
+ uuidBytes[0] = 9;
275
+ uuidBytes.set(fromHex(header.value.replace(/\-/g, "")), 1);
276
+ return uuidBytes;
277
+ }
278
+ }
279
+ };
280
+ var HEADER_VALUE_TYPE;
281
+ (function(HEADER_VALUE_TYPE2) {
282
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolTrue"] = 0] = "boolTrue";
283
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolFalse"] = 1] = "boolFalse";
284
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byte"] = 2] = "byte";
285
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["short"] = 3] = "short";
286
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["integer"] = 4] = "integer";
287
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["long"] = 5] = "long";
288
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byteArray"] = 6] = "byteArray";
289
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["string"] = 7] = "string";
290
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["timestamp"] = 8] = "timestamp";
291
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["uuid"] = 9] = "uuid";
292
+ })(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
293
+ var UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
294
+ var Int64 = class _Int64 {
295
+ bytes;
296
+ constructor(bytes) {
297
+ this.bytes = bytes;
298
+ if (bytes.byteLength !== 8) {
299
+ throw new Error("Int64 buffers must be exactly 8 bytes");
300
+ }
301
+ }
302
+ static fromNumber(number) {
303
+ if (number > 9223372036854776e3 || number < -9223372036854776e3) {
304
+ throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
305
+ }
306
+ const bytes = new Uint8Array(8);
307
+ for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
308
+ bytes[i] = remaining;
309
+ }
310
+ if (number < 0) {
311
+ negate(bytes);
312
+ }
313
+ return new _Int64(bytes);
314
+ }
315
+ valueOf() {
316
+ const bytes = this.bytes.slice(0);
317
+ const negative = bytes[0] & 128;
318
+ if (negative) {
319
+ negate(bytes);
320
+ }
321
+ return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);
322
+ }
323
+ toString() {
324
+ return String(this.valueOf());
325
+ }
326
+ };
327
+ function negate(bytes) {
328
+ for (let i = 0; i < 8; i++) {
329
+ bytes[i] ^= 255;
330
+ }
331
+ for (let i = 7; i > -1; i--) {
332
+ bytes[i]++;
333
+ if (bytes[i] !== 0)
334
+ break;
335
+ }
336
+ }
337
+
338
+ // ../../node_modules/@smithy/signature-v4/dist-es/constants.js
339
+ var ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
340
+ var CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
341
+ var AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
342
+ var SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
343
+ var EXPIRES_QUERY_PARAM = "X-Amz-Expires";
344
+ var SIGNATURE_QUERY_PARAM = "X-Amz-Signature";
345
+ var TOKEN_QUERY_PARAM = "X-Amz-Security-Token";
346
+ var AUTH_HEADER = "authorization";
347
+ var AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase();
348
+ var DATE_HEADER = "date";
349
+ var GENERATED_HEADERS = [AUTH_HEADER, AMZ_DATE_HEADER, DATE_HEADER];
350
+ var SIGNATURE_HEADER = SIGNATURE_QUERY_PARAM.toLowerCase();
351
+ var SHA256_HEADER = "x-amz-content-sha256";
352
+ var TOKEN_HEADER = TOKEN_QUERY_PARAM.toLowerCase();
353
+ var ALWAYS_UNSIGNABLE_HEADERS = {
354
+ authorization: true,
355
+ "cache-control": true,
356
+ connection: true,
357
+ expect: true,
358
+ from: true,
359
+ "keep-alive": true,
360
+ "max-forwards": true,
361
+ pragma: true,
362
+ referer: true,
363
+ te: true,
364
+ trailer: true,
365
+ "transfer-encoding": true,
366
+ upgrade: true,
367
+ "user-agent": true,
368
+ "x-amzn-trace-id": true
369
+ };
370
+ var PROXY_HEADER_PATTERN = /^proxy-/;
371
+ var SEC_HEADER_PATTERN = /^sec-/;
372
+ var ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
373
+ var EVENT_ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256-PAYLOAD";
374
+ var UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
375
+ var MAX_CACHE_SIZE = 50;
376
+ var KEY_TYPE_IDENTIFIER = "aws4_request";
377
+ var MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7;
378
+
379
+ // ../../node_modules/@smithy/signature-v4/dist-es/getCanonicalQuery.js
380
+ var getCanonicalQuery = ({ query = {} }) => {
381
+ const keys = [];
382
+ const serialized = {};
383
+ for (const key of Object.keys(query)) {
384
+ if (key.toLowerCase() === SIGNATURE_HEADER) {
385
+ continue;
386
+ }
387
+ const encodedKey = escapeUri(key);
388
+ keys.push(encodedKey);
389
+ const value = query[key];
390
+ if (typeof value === "string") {
391
+ serialized[encodedKey] = `${encodedKey}=${escapeUri(value)}`;
392
+ } else if (Array.isArray(value)) {
393
+ serialized[encodedKey] = value.slice(0).reduce((encoded, value2) => encoded.concat([`${encodedKey}=${escapeUri(value2)}`]), []).sort().join("&");
394
+ }
395
+ }
396
+ return keys.sort().map((key) => serialized[key]).filter((serialized2) => serialized2).join("&");
397
+ };
398
+
399
+ // ../../node_modules/@smithy/signature-v4/dist-es/utilDate.js
400
+ var iso8601 = (time) => toDate(time).toISOString().replace(/\.\d{3}Z$/, "Z");
401
+ var toDate = (time) => {
402
+ if (typeof time === "number") {
403
+ return new Date(time * 1e3);
404
+ }
405
+ if (typeof time === "string") {
406
+ if (Number(time)) {
407
+ return new Date(Number(time) * 1e3);
408
+ }
409
+ return new Date(time);
410
+ }
411
+ return time;
412
+ };
413
+
414
+ // ../../node_modules/@smithy/signature-v4/dist-es/SignatureV4Base.js
415
+ var SignatureV4Base = class {
416
+ service;
417
+ regionProvider;
418
+ credentialProvider;
419
+ sha256;
420
+ uriEscapePath;
421
+ applyChecksum;
422
+ constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath = true }) {
423
+ this.service = service;
424
+ this.sha256 = sha256;
425
+ this.uriEscapePath = uriEscapePath;
426
+ this.applyChecksum = typeof applyChecksum === "boolean" ? applyChecksum : true;
427
+ this.regionProvider = normalizeProvider(region);
428
+ this.credentialProvider = normalizeProvider(credentials);
429
+ }
430
+ createCanonicalRequest(request, canonicalHeaders, payloadHash) {
431
+ const sortedHeaders = Object.keys(canonicalHeaders).sort();
432
+ return `${request.method}
433
+ ${this.getCanonicalPath(request)}
434
+ ${getCanonicalQuery(request)}
435
+ ${sortedHeaders.map((name) => `${name}:${canonicalHeaders[name]}`).join("\n")}
436
+
437
+ ${sortedHeaders.join(";")}
438
+ ${payloadHash}`;
439
+ }
440
+ async createStringToSign(longDate, credentialScope, canonicalRequest, algorithmIdentifier) {
441
+ const hash = new this.sha256();
442
+ hash.update(toUint8Array(canonicalRequest));
443
+ const hashedRequest = await hash.digest();
444
+ return `${algorithmIdentifier}
445
+ ${longDate}
446
+ ${credentialScope}
447
+ ${toHex(hashedRequest)}`;
448
+ }
449
+ getCanonicalPath({ path }) {
450
+ if (this.uriEscapePath) {
451
+ const normalizedPathSegments = [];
452
+ for (const pathSegment of path.split("/")) {
453
+ if (pathSegment?.length === 0)
454
+ continue;
455
+ if (pathSegment === ".")
456
+ continue;
457
+ if (pathSegment === "..") {
458
+ normalizedPathSegments.pop();
459
+ } else {
460
+ normalizedPathSegments.push(pathSegment);
461
+ }
462
+ }
463
+ const normalizedPath = `${path?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path?.endsWith("/") ? "/" : ""}`;
464
+ const doubleEncoded = escapeUri(normalizedPath);
465
+ return doubleEncoded.replace(/%2F/g, "/");
466
+ }
467
+ return path;
468
+ }
469
+ validateResolvedCredentials(credentials) {
470
+ if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
471
+ throw new Error("Resolved credential object is not valid");
472
+ }
473
+ }
474
+ formatDate(now) {
475
+ const longDate = iso8601(now).replace(/[\-:]/g, "");
476
+ return {
477
+ longDate,
478
+ shortDate: longDate.slice(0, 8)
479
+ };
480
+ }
481
+ getCanonicalHeaderList(headers) {
482
+ return Object.keys(headers).sort().join(";");
483
+ }
484
+ };
485
+
486
+ // ../../node_modules/@smithy/signature-v4/dist-es/credentialDerivation.js
487
+ var signingKeyCache = {};
488
+ var cacheQueue = [];
489
+ var createScope = (shortDate, region, service) => `${shortDate}/${region}/${service}/${KEY_TYPE_IDENTIFIER}`;
490
+ var getSigningKey = async (sha256Constructor, credentials, shortDate, region, service) => {
491
+ const credsHash = await hmac(sha256Constructor, credentials.secretAccessKey, credentials.accessKeyId);
492
+ const cacheKey = `${shortDate}:${region}:${service}:${toHex(credsHash)}:${credentials.sessionToken}`;
493
+ if (cacheKey in signingKeyCache) {
494
+ return signingKeyCache[cacheKey];
495
+ }
496
+ cacheQueue.push(cacheKey);
497
+ while (cacheQueue.length > MAX_CACHE_SIZE) {
498
+ delete signingKeyCache[cacheQueue.shift()];
499
+ }
500
+ let key = `AWS4${credentials.secretAccessKey}`;
501
+ for (const signable of [shortDate, region, service, KEY_TYPE_IDENTIFIER]) {
502
+ key = await hmac(sha256Constructor, key, signable);
503
+ }
504
+ return signingKeyCache[cacheKey] = key;
505
+ };
506
+ var hmac = (ctor, secret, data) => {
507
+ const hash = new ctor(secret);
508
+ hash.update(toUint8Array(data));
509
+ return hash.digest();
510
+ };
511
+
512
+ // ../../node_modules/@smithy/signature-v4/dist-es/getCanonicalHeaders.js
513
+ var getCanonicalHeaders = ({ headers }, unsignableHeaders, signableHeaders) => {
514
+ const canonical = {};
515
+ for (const headerName of Object.keys(headers).sort()) {
516
+ if (headers[headerName] == void 0) {
517
+ continue;
518
+ }
519
+ const canonicalHeaderName = headerName.toLowerCase();
520
+ if (canonicalHeaderName in ALWAYS_UNSIGNABLE_HEADERS || unsignableHeaders?.has(canonicalHeaderName) || PROXY_HEADER_PATTERN.test(canonicalHeaderName) || SEC_HEADER_PATTERN.test(canonicalHeaderName)) {
521
+ if (!signableHeaders || signableHeaders && !signableHeaders.has(canonicalHeaderName)) {
522
+ continue;
523
+ }
524
+ }
525
+ canonical[canonicalHeaderName] = headers[headerName].trim().replace(/\s+/g, " ");
526
+ }
527
+ return canonical;
528
+ };
529
+
530
+ // ../../node_modules/@smithy/signature-v4/dist-es/getPayloadHash.js
531
+ var getPayloadHash = async ({ headers, body }, hashConstructor) => {
532
+ for (const headerName of Object.keys(headers)) {
533
+ if (headerName.toLowerCase() === SHA256_HEADER) {
534
+ return headers[headerName];
535
+ }
536
+ }
537
+ if (body == void 0) {
538
+ return "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
539
+ } else if (typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) {
540
+ const hashCtor = new hashConstructor();
541
+ hashCtor.update(toUint8Array(body));
542
+ return toHex(await hashCtor.digest());
543
+ }
544
+ return UNSIGNED_PAYLOAD;
545
+ };
546
+
547
+ // ../../node_modules/@smithy/signature-v4/dist-es/headerUtil.js
548
+ var hasHeader = (soughtHeader, headers) => {
549
+ soughtHeader = soughtHeader.toLowerCase();
550
+ for (const headerName of Object.keys(headers)) {
551
+ if (soughtHeader === headerName.toLowerCase()) {
552
+ return true;
553
+ }
554
+ }
555
+ return false;
556
+ };
557
+
558
+ // ../../node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js
559
+ var moveHeadersToQuery = (request, options = {}) => {
560
+ const { headers, query = {} } = HttpRequest.clone(request);
561
+ for (const name of Object.keys(headers)) {
562
+ const lname = name.toLowerCase();
563
+ if (lname.slice(0, 6) === "x-amz-" && !options.unhoistableHeaders?.has(lname) || options.hoistableHeaders?.has(lname)) {
564
+ query[name] = headers[name];
565
+ delete headers[name];
566
+ }
567
+ }
568
+ return {
569
+ ...request,
570
+ headers,
571
+ query
572
+ };
573
+ };
574
+
575
+ // ../../node_modules/@smithy/signature-v4/dist-es/prepareRequest.js
576
+ var prepareRequest = (request) => {
577
+ request = HttpRequest.clone(request);
578
+ for (const headerName of Object.keys(request.headers)) {
579
+ if (GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {
580
+ delete request.headers[headerName];
581
+ }
582
+ }
583
+ return request;
584
+ };
585
+
586
+ // ../../node_modules/@smithy/signature-v4/dist-es/SignatureV4.js
587
+ var SignatureV4 = class extends SignatureV4Base {
588
+ headerFormatter = new HeaderFormatter();
589
+ constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath = true }) {
590
+ super({
591
+ applyChecksum,
592
+ credentials,
593
+ region,
594
+ service,
595
+ sha256,
596
+ uriEscapePath
597
+ });
598
+ }
599
+ async presign(originalRequest, options = {}) {
600
+ const { signingDate = /* @__PURE__ */ new Date(), expiresIn = 3600, unsignableHeaders, unhoistableHeaders, signableHeaders, hoistableHeaders, signingRegion, signingService } = options;
601
+ const credentials = await this.credentialProvider();
602
+ this.validateResolvedCredentials(credentials);
603
+ const region = signingRegion ?? await this.regionProvider();
604
+ const { longDate, shortDate } = this.formatDate(signingDate);
605
+ if (expiresIn > MAX_PRESIGNED_TTL) {
606
+ return Promise.reject("Signature version 4 presigned URLs must have an expiration date less than one week in the future");
607
+ }
608
+ const scope = createScope(shortDate, region, signingService ?? this.service);
609
+ const request = moveHeadersToQuery(prepareRequest(originalRequest), { unhoistableHeaders, hoistableHeaders });
610
+ if (credentials.sessionToken) {
611
+ request.query[TOKEN_QUERY_PARAM] = credentials.sessionToken;
612
+ }
613
+ request.query[ALGORITHM_QUERY_PARAM] = ALGORITHM_IDENTIFIER;
614
+ request.query[CREDENTIAL_QUERY_PARAM] = `${credentials.accessKeyId}/${scope}`;
615
+ request.query[AMZ_DATE_QUERY_PARAM] = longDate;
616
+ request.query[EXPIRES_QUERY_PARAM] = expiresIn.toString(10);
617
+ const canonicalHeaders = getCanonicalHeaders(request, unsignableHeaders, signableHeaders);
618
+ request.query[SIGNED_HEADERS_QUERY_PARAM] = this.getCanonicalHeaderList(canonicalHeaders);
619
+ 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)));
620
+ return request;
621
+ }
622
+ async sign(toSign, options) {
623
+ if (typeof toSign === "string") {
624
+ return this.signString(toSign, options);
625
+ } else if (toSign.headers && toSign.payload) {
626
+ return this.signEvent(toSign, options);
627
+ } else if (toSign.message) {
628
+ return this.signMessage(toSign, options);
629
+ } else {
630
+ return this.signRequest(toSign, options);
631
+ }
632
+ }
633
+ async signEvent({ headers, payload }, { signingDate = /* @__PURE__ */ new Date(), priorSignature, signingRegion, signingService, eventStreamCredentials }) {
634
+ const region = signingRegion ?? await this.regionProvider();
635
+ const { shortDate, longDate } = this.formatDate(signingDate);
636
+ const scope = createScope(shortDate, region, signingService ?? this.service);
637
+ const hashedPayload = await getPayloadHash({ headers: {}, body: payload }, this.sha256);
638
+ const hash = new this.sha256();
639
+ hash.update(headers);
640
+ const hashedHeaders = toHex(await hash.digest());
641
+ const stringToSign = [
642
+ EVENT_ALGORITHM_IDENTIFIER,
643
+ longDate,
644
+ scope,
645
+ priorSignature,
646
+ hashedHeaders,
647
+ hashedPayload
648
+ ].join("\n");
649
+ return this.signString(stringToSign, {
650
+ signingDate,
651
+ signingRegion: region,
652
+ signingService,
653
+ eventStreamCredentials
654
+ });
655
+ }
656
+ async signMessage(signableMessage, { signingDate = /* @__PURE__ */ new Date(), signingRegion, signingService, eventStreamCredentials }) {
657
+ const promise = this.signEvent({
658
+ headers: this.headerFormatter.format(signableMessage.message.headers),
659
+ payload: signableMessage.message.body
660
+ }, {
661
+ signingDate,
662
+ signingRegion,
663
+ signingService,
664
+ priorSignature: signableMessage.priorSignature,
665
+ eventStreamCredentials
666
+ });
667
+ return promise.then((signature) => {
668
+ return { message: signableMessage.message, signature };
669
+ });
670
+ }
671
+ async signString(stringToSign, { signingDate = /* @__PURE__ */ new Date(), signingRegion, signingService, eventStreamCredentials } = {}) {
672
+ const credentials = eventStreamCredentials ?? await this.credentialProvider();
673
+ this.validateResolvedCredentials(credentials);
674
+ const region = signingRegion ?? await this.regionProvider();
675
+ const { shortDate } = this.formatDate(signingDate);
676
+ const hash = new this.sha256(await this.getSigningKey(credentials, region, shortDate, signingService));
677
+ hash.update(toUint8Array(stringToSign));
678
+ return toHex(await hash.digest());
679
+ }
680
+ async signRequest(requestToSign, { signingDate = /* @__PURE__ */ new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService } = {}) {
681
+ const credentials = await this.credentialProvider();
682
+ this.validateResolvedCredentials(credentials);
683
+ const region = signingRegion ?? await this.regionProvider();
684
+ const request = prepareRequest(requestToSign);
685
+ const { longDate, shortDate } = this.formatDate(signingDate);
686
+ const scope = createScope(shortDate, region, signingService ?? this.service);
687
+ request.headers[AMZ_DATE_HEADER] = longDate;
688
+ if (credentials.sessionToken) {
689
+ request.headers[TOKEN_HEADER] = credentials.sessionToken;
690
+ }
691
+ const payloadHash = await getPayloadHash(request, this.sha256);
692
+ if (!hasHeader(SHA256_HEADER, request.headers) && this.applyChecksum) {
693
+ request.headers[SHA256_HEADER] = payloadHash;
694
+ }
695
+ const canonicalHeaders = getCanonicalHeaders(request, unsignableHeaders, signableHeaders);
696
+ const signature = await this.getSignature(longDate, scope, this.getSigningKey(credentials, region, shortDate, signingService), this.createCanonicalRequest(request, canonicalHeaders, payloadHash));
697
+ request.headers[AUTH_HEADER] = `${ALGORITHM_IDENTIFIER} Credential=${credentials.accessKeyId}/${scope}, SignedHeaders=${this.getCanonicalHeaderList(canonicalHeaders)}, Signature=${signature}`;
698
+ return request;
699
+ }
700
+ async getSignature(longDate, credentialScope, keyPromise, canonicalRequest) {
701
+ const stringToSign = await this.createStringToSign(longDate, credentialScope, canonicalRequest, ALGORITHM_IDENTIFIER);
702
+ const hash = new this.sha256(await keyPromise);
703
+ hash.update(toUint8Array(stringToSign));
704
+ return toHex(await hash.digest());
705
+ }
706
+ getSigningKey(credentials, region, shortDate, service) {
707
+ return getSigningKey(this.sha256, credentials, shortDate, region, service || this.service);
708
+ }
709
+ };
710
+
711
+ // ../../node_modules/@smithy/signature-v4/dist-es/signature-v4a-container.js
712
+ var signatureV4aContainer = {
713
+ SignatureV4a: null
714
+ };
715
+
716
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js
717
+ var resolveAwsSdkSigV4Config = (config) => {
718
+ let inputCredentials = config.credentials;
719
+ let isUserSupplied = !!config.credentials;
720
+ let resolvedCredentials = void 0;
721
+ Object.defineProperty(config, "credentials", {
722
+ set(credentials) {
723
+ if (credentials && credentials !== inputCredentials && credentials !== resolvedCredentials) {
724
+ isUserSupplied = true;
725
+ }
726
+ inputCredentials = credentials;
727
+ const memoizedProvider = normalizeCredentialProvider(config, {
728
+ credentials: inputCredentials,
729
+ credentialDefaultProvider: config.credentialDefaultProvider
730
+ });
731
+ const boundProvider = bindCallerConfig(config, memoizedProvider);
732
+ if (isUserSupplied && !boundProvider.attributed) {
733
+ const isCredentialObject = typeof inputCredentials === "object" && inputCredentials !== null;
734
+ resolvedCredentials = async (options) => {
735
+ const creds = await boundProvider(options);
736
+ const attributedCreds = creds;
737
+ if (isCredentialObject && (!attributedCreds.$source || Object.keys(attributedCreds.$source).length === 0)) {
738
+ return setCredentialFeature(attributedCreds, "CREDENTIALS_CODE", "e");
739
+ }
740
+ return attributedCreds;
741
+ };
742
+ resolvedCredentials.memoized = boundProvider.memoized;
743
+ resolvedCredentials.configBound = boundProvider.configBound;
744
+ resolvedCredentials.attributed = true;
745
+ } else {
746
+ resolvedCredentials = boundProvider;
747
+ }
748
+ },
749
+ get() {
750
+ return resolvedCredentials;
751
+ },
752
+ enumerable: true,
753
+ configurable: true
754
+ });
755
+ config.credentials = inputCredentials;
756
+ const { signingEscapePath = true, systemClockOffset = config.systemClockOffset || 0, sha256 } = config;
757
+ let signer;
758
+ if (config.signer) {
759
+ signer = normalizeProvider2(config.signer);
760
+ } else if (config.regionInfoProvider) {
761
+ signer = () => normalizeProvider2(config.region)().then(async (region) => [
762
+ await config.regionInfoProvider(region, {
763
+ useFipsEndpoint: await config.useFipsEndpoint(),
764
+ useDualstackEndpoint: await config.useDualstackEndpoint()
765
+ }) || {},
766
+ region
767
+ ]).then(([regionInfo, region]) => {
768
+ const { signingRegion, signingService } = regionInfo;
769
+ config.signingRegion = config.signingRegion || signingRegion || region;
770
+ config.signingName = config.signingName || signingService || config.serviceId;
771
+ const params = {
772
+ ...config,
773
+ credentials: config.credentials,
774
+ region: config.signingRegion,
775
+ service: config.signingName,
776
+ sha256,
777
+ uriEscapePath: signingEscapePath
778
+ };
779
+ const SignerCtor = config.signerConstructor || SignatureV4;
780
+ return new SignerCtor(params);
781
+ });
782
+ } else {
783
+ signer = async (authScheme) => {
784
+ authScheme = Object.assign({}, {
785
+ name: "sigv4",
786
+ signingName: config.signingName || config.defaultSigningName,
787
+ signingRegion: await normalizeProvider2(config.region)(),
788
+ properties: {}
789
+ }, authScheme);
790
+ const signingRegion = authScheme.signingRegion;
791
+ const signingService = authScheme.signingName;
792
+ config.signingRegion = config.signingRegion || signingRegion;
793
+ config.signingName = config.signingName || signingService || config.serviceId;
794
+ const params = {
795
+ ...config,
796
+ credentials: config.credentials,
797
+ region: config.signingRegion,
798
+ service: config.signingName,
799
+ sha256,
800
+ uriEscapePath: signingEscapePath
801
+ };
802
+ const SignerCtor = config.signerConstructor || SignatureV4;
803
+ return new SignerCtor(params);
804
+ };
805
+ }
806
+ const resolvedConfig = Object.assign(config, {
807
+ systemClockOffset,
808
+ signingEscapePath,
809
+ signer
810
+ });
811
+ return resolvedConfig;
812
+ };
813
+ function normalizeCredentialProvider(config, { credentials, credentialDefaultProvider }) {
814
+ let credentialsProvider;
815
+ if (credentials) {
816
+ if (!credentials?.memoized) {
817
+ credentialsProvider = memoizeIdentityProvider(credentials, isIdentityExpired, doesIdentityRequireRefresh);
818
+ } else {
819
+ credentialsProvider = credentials;
820
+ }
821
+ } else {
822
+ if (credentialDefaultProvider) {
823
+ credentialsProvider = normalizeProvider2(credentialDefaultProvider(Object.assign({}, config, {
824
+ parentClientConfig: config
825
+ })));
826
+ } else {
827
+ credentialsProvider = async () => {
828
+ throw new Error("@aws-sdk/core::resolveAwsSdkSigV4Config - `credentials` not provided and no credentialDefaultProvider was configured.");
829
+ };
830
+ }
831
+ }
832
+ credentialsProvider.memoized = true;
833
+ return credentialsProvider;
834
+ }
835
+ function bindCallerConfig(config, credentialsProvider) {
836
+ if (credentialsProvider.configBound) {
837
+ return credentialsProvider;
838
+ }
839
+ const fn = async (options) => credentialsProvider({ ...options, callerClientConfig: config });
840
+ fn.memoized = credentialsProvider.memoized;
841
+ fn.configBound = true;
842
+ return fn;
843
+ }
844
+
845
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/ProtocolLib.js
846
+ var ProtocolLib = class {
847
+ queryCompat;
848
+ errorRegistry;
849
+ constructor(queryCompat = false) {
850
+ this.queryCompat = queryCompat;
851
+ }
852
+ resolveRestContentType(defaultContentType, inputSchema) {
853
+ const members = inputSchema.getMemberSchemas();
854
+ const httpPayloadMember = Object.values(members).find((m) => {
855
+ return !!m.getMergedTraits().httpPayload;
856
+ });
857
+ if (httpPayloadMember) {
858
+ const mediaType = httpPayloadMember.getMergedTraits().mediaType;
859
+ if (mediaType) {
860
+ return mediaType;
861
+ } else if (httpPayloadMember.isStringSchema()) {
862
+ return "text/plain";
863
+ } else if (httpPayloadMember.isBlobSchema()) {
864
+ return "application/octet-stream";
865
+ } else {
866
+ return defaultContentType;
867
+ }
868
+ } else if (!inputSchema.isUnitSchema()) {
869
+ const hasBody = Object.values(members).find((m) => {
870
+ const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
871
+ const noPrefixHeaders = httpPrefixHeaders === void 0;
872
+ return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && noPrefixHeaders;
873
+ });
874
+ if (hasBody) {
875
+ return defaultContentType;
876
+ }
877
+ }
878
+ }
879
+ async getErrorSchemaOrThrowBaseException(errorIdentifier, defaultNamespace, response, dataObject, metadata, getErrorSchema) {
880
+ let errorName = errorIdentifier;
881
+ if (errorIdentifier.includes("#")) {
882
+ [, errorName] = errorIdentifier.split("#");
883
+ }
884
+ const errorMetadata = {
885
+ $metadata: metadata,
886
+ $fault: response.statusCode < 500 ? "client" : "server"
887
+ };
888
+ if (!this.errorRegistry) {
889
+ throw new Error("@aws-sdk/core/protocols - error handler not initialized.");
890
+ }
891
+ try {
892
+ const errorSchema = getErrorSchema?.(this.errorRegistry, errorName) ?? this.errorRegistry.getSchema(errorIdentifier);
893
+ return { errorSchema, errorMetadata };
894
+ } catch (e) {
895
+ dataObject.message = dataObject.message ?? dataObject.Message ?? "UnknownError";
896
+ const synthetic = this.errorRegistry;
897
+ const baseExceptionSchema = synthetic.getBaseException();
898
+ if (baseExceptionSchema) {
899
+ const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema) ?? Error;
900
+ throw this.decorateServiceException(Object.assign(new ErrorCtor({ name: errorName }), errorMetadata), dataObject);
901
+ }
902
+ const d = dataObject;
903
+ const message = d?.message ?? d?.Message ?? d?.Error?.Message ?? d?.Error?.message;
904
+ throw this.decorateServiceException(Object.assign(new Error(message), {
905
+ name: errorName
906
+ }, errorMetadata), dataObject);
907
+ }
908
+ }
909
+ compose(composite, errorIdentifier, defaultNamespace) {
910
+ let namespace = defaultNamespace;
911
+ if (errorIdentifier.includes("#")) {
912
+ [namespace] = errorIdentifier.split("#");
913
+ }
914
+ const staticRegistry = TypeRegistry.for(namespace);
915
+ const defaultSyntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + defaultNamespace);
916
+ composite.copyFrom(staticRegistry);
917
+ composite.copyFrom(defaultSyntheticRegistry);
918
+ this.errorRegistry = composite;
919
+ }
920
+ decorateServiceException(exception, additions = {}) {
921
+ if (this.queryCompat) {
922
+ const msg = exception.Message ?? additions.Message;
923
+ const error = decorateServiceException(exception, additions);
924
+ if (msg) {
925
+ error.message = msg;
926
+ }
927
+ const errorObj = error.Error ?? {};
928
+ errorObj.Type = error.Error?.Type;
929
+ errorObj.Code = error.Error?.Code;
930
+ errorObj.Message = error.Error?.message ?? error.Error?.Message ?? msg;
931
+ error.Error = errorObj;
932
+ const reqId = error.$metadata.requestId;
933
+ if (reqId) {
934
+ error.RequestId = reqId;
935
+ }
936
+ return error;
937
+ }
938
+ return decorateServiceException(exception, additions);
939
+ }
940
+ setQueryCompatError(output, response) {
941
+ const queryErrorHeader = response.headers?.["x-amzn-query-error"];
942
+ if (output !== void 0 && queryErrorHeader != null) {
943
+ const [Code, Type] = queryErrorHeader.split(";");
944
+ const keys = Object.keys(output);
945
+ const Error2 = {
946
+ Code,
947
+ Type
948
+ };
949
+ output.Code = Code;
950
+ output.Type = Type;
951
+ for (let i = 0; i < keys.length; i++) {
952
+ const k = keys[i];
953
+ Error2[k === "message" ? "Message" : k] = output[k];
954
+ }
955
+ delete Error2.__type;
956
+ output.Error = Error2;
957
+ }
958
+ }
959
+ queryCompatOutput(queryCompatErrorData, errorData) {
960
+ if (queryCompatErrorData.Error) {
961
+ errorData.Error = queryCompatErrorData.Error;
962
+ }
963
+ if (queryCompatErrorData.Type) {
964
+ errorData.Type = queryCompatErrorData.Type;
965
+ }
966
+ if (queryCompatErrorData.Code) {
967
+ errorData.Code = queryCompatErrorData.Code;
968
+ }
969
+ }
970
+ findQueryCompatibleError(registry, errorName) {
971
+ try {
972
+ return registry.getSchema(errorName);
973
+ } catch (e) {
974
+ return registry.find((schema) => NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName);
975
+ }
976
+ }
977
+ };
978
+
979
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/ConfigurableSerdeContext.js
980
+ var SerdeContextConfig = class {
981
+ serdeContext;
982
+ setSerdeContext(serdeContext) {
983
+ this.serdeContext = serdeContext;
984
+ }
985
+ };
986
+
987
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/UnionSerde.js
988
+ var UnionSerde = class {
989
+ from;
990
+ to;
991
+ keys;
992
+ constructor(from, to) {
993
+ this.from = from;
994
+ this.to = to;
995
+ const keys = Object.keys(this.from);
996
+ const set = new Set(keys);
997
+ set.delete("__type");
998
+ this.keys = set;
999
+ }
1000
+ mark(key) {
1001
+ this.keys.delete(key);
1002
+ }
1003
+ hasUnknown() {
1004
+ return this.keys.size === 1 && Object.keys(this.to).length === 0;
1005
+ }
1006
+ writeUnknown() {
1007
+ if (this.hasUnknown()) {
1008
+ const k = this.keys.values().next().value;
1009
+ const v = this.from[k];
1010
+ this.to.$unknown = [k, v];
1011
+ }
1012
+ }
1013
+ };
1014
+
1015
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReviver.js
1016
+ function jsonReviver(key, value, context) {
1017
+ if (context?.source) {
1018
+ const numericString = context.source;
1019
+ if (typeof value === "number") {
1020
+ if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER || numericString !== String(value)) {
1021
+ const isFractional = numericString.includes(".");
1022
+ if (isFractional) {
1023
+ return new NumericValue(numericString, "bigDecimal");
1024
+ } else {
1025
+ return BigInt(numericString);
1026
+ }
1027
+ }
1028
+ }
1029
+ }
1030
+ return value;
1031
+ }
1032
+
1033
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/common.js
1034
+ var collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => (context?.utf8Encoder ?? toUtf8)(body));
1035
+
1036
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/parseJsonBody.js
1037
+ var parseJsonBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
1038
+ if (encoded.length) {
1039
+ try {
1040
+ return JSON.parse(encoded);
1041
+ } catch (e) {
1042
+ if (e?.name === "SyntaxError") {
1043
+ Object.defineProperty(e, "$responseBodyText", {
1044
+ value: encoded
1045
+ });
1046
+ }
1047
+ throw e;
1048
+ }
1049
+ }
1050
+ return {};
1051
+ });
1052
+ var findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
1053
+ var sanitizeErrorCode = (rawValue) => {
1054
+ let cleanValue = rawValue;
1055
+ if (typeof cleanValue === "number") {
1056
+ cleanValue = cleanValue.toString();
1057
+ }
1058
+ if (cleanValue.indexOf(",") >= 0) {
1059
+ cleanValue = cleanValue.split(",")[0];
1060
+ }
1061
+ if (cleanValue.indexOf(":") >= 0) {
1062
+ cleanValue = cleanValue.split(":")[0];
1063
+ }
1064
+ if (cleanValue.indexOf("#") >= 0) {
1065
+ cleanValue = cleanValue.split("#")[1];
1066
+ }
1067
+ return cleanValue;
1068
+ };
1069
+ var loadRestJsonErrorCode = (output, data) => {
1070
+ return loadErrorCode(output, data, ["header", "code", "type"]);
1071
+ };
1072
+ var loadErrorCode = ({ headers }, data, order) => {
1073
+ while (order.length > 0) {
1074
+ const location = order.shift();
1075
+ switch (location) {
1076
+ case "header":
1077
+ const headerKey = findKey(headers ?? {}, "x-amzn-errortype");
1078
+ if (headerKey !== void 0) {
1079
+ return sanitizeErrorCode(headers[headerKey]);
1080
+ }
1081
+ break;
1082
+ case "code":
1083
+ const codeKey = findKey(data ?? {}, "code");
1084
+ if (codeKey && data[codeKey] !== void 0) {
1085
+ return sanitizeErrorCode(data[codeKey]);
1086
+ }
1087
+ break;
1088
+ case "type":
1089
+ if (data?.__type !== void 0) {
1090
+ return sanitizeErrorCode(data.__type);
1091
+ }
1092
+ break;
1093
+ }
1094
+ }
1095
+ };
1096
+
1097
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeDeserializer.js
1098
+ var JsonShapeDeserializer = class extends SerdeContextConfig {
1099
+ settings;
1100
+ constructor(settings) {
1101
+ super();
1102
+ this.settings = settings;
1103
+ }
1104
+ async read(schema, data) {
1105
+ return this._read(schema, typeof data === "string" ? JSON.parse(data, jsonReviver) : await parseJsonBody(data, this.serdeContext));
1106
+ }
1107
+ readObject(schema, data) {
1108
+ return this._read(schema, data);
1109
+ }
1110
+ _read(schema, value) {
1111
+ const isObject = value !== null && typeof value === "object";
1112
+ const ns = NormalizedSchema.of(schema);
1113
+ if (isObject) {
1114
+ if (ns.isStructSchema()) {
1115
+ const record = value;
1116
+ const union = ns.isUnionSchema();
1117
+ const out = {};
1118
+ let nameMap = void 0;
1119
+ const { jsonName } = this.settings;
1120
+ if (jsonName) {
1121
+ nameMap = {};
1122
+ }
1123
+ let unionSerde;
1124
+ if (union) {
1125
+ unionSerde = new UnionSerde(record, out);
1126
+ }
1127
+ for (const [memberName, memberSchema] of ns.structIterator()) {
1128
+ let fromKey = memberName;
1129
+ if (jsonName) {
1130
+ fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
1131
+ nameMap[fromKey] = memberName;
1132
+ }
1133
+ if (union) {
1134
+ unionSerde.mark(fromKey);
1135
+ }
1136
+ if (record[fromKey] != null) {
1137
+ out[memberName] = this._read(memberSchema, record[fromKey]);
1138
+ }
1139
+ }
1140
+ if (union) {
1141
+ unionSerde.writeUnknown();
1142
+ } else if (typeof record.__type === "string") {
1143
+ for (const k in record) {
1144
+ const v = record[k];
1145
+ const t = jsonName ? nameMap[k] ?? k : k;
1146
+ if (!(t in out)) {
1147
+ out[t] = v;
1148
+ }
1149
+ }
1150
+ }
1151
+ return out;
1152
+ }
1153
+ if (Array.isArray(value) && ns.isListSchema()) {
1154
+ const listMember = ns.getValueSchema();
1155
+ const out = [];
1156
+ for (const item of value) {
1157
+ out.push(this._read(listMember, item));
1158
+ }
1159
+ return out;
1160
+ }
1161
+ if (ns.isMapSchema()) {
1162
+ const mapMember = ns.getValueSchema();
1163
+ const out = {};
1164
+ for (const _k in value) {
1165
+ out[_k] = this._read(mapMember, value[_k]);
1166
+ }
1167
+ return out;
1168
+ }
1169
+ }
1170
+ if (ns.isBlobSchema() && typeof value === "string") {
1171
+ return fromBase64(value);
1172
+ }
1173
+ const mediaType = ns.getMergedTraits().mediaType;
1174
+ if (ns.isStringSchema() && typeof value === "string" && mediaType) {
1175
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
1176
+ if (isJson) {
1177
+ return LazyJsonString.from(value);
1178
+ }
1179
+ return value;
1180
+ }
1181
+ if (ns.isTimestampSchema() && value != null) {
1182
+ const format = determineTimestampFormat(ns, this.settings);
1183
+ switch (format) {
1184
+ case 5:
1185
+ return parseRfc3339DateTimeWithOffset(value);
1186
+ case 6:
1187
+ return parseRfc7231DateTime(value);
1188
+ case 7:
1189
+ return parseEpochTimestamp(value);
1190
+ default:
1191
+ console.warn("Missing timestamp format, parsing value with Date constructor:", value);
1192
+ return new Date(value);
1193
+ }
1194
+ }
1195
+ if (ns.isBigIntegerSchema() && (typeof value === "number" || typeof value === "string")) {
1196
+ return BigInt(value);
1197
+ }
1198
+ if (ns.isBigDecimalSchema() && value != void 0) {
1199
+ if (value instanceof NumericValue) {
1200
+ return value;
1201
+ }
1202
+ const untyped = value;
1203
+ if (untyped.type === "bigDecimal" && "string" in untyped) {
1204
+ return new NumericValue(untyped.string, untyped.type);
1205
+ }
1206
+ return new NumericValue(String(value), "bigDecimal");
1207
+ }
1208
+ if (ns.isNumericSchema() && typeof value === "string") {
1209
+ switch (value) {
1210
+ case "Infinity":
1211
+ return Infinity;
1212
+ case "-Infinity":
1213
+ return -Infinity;
1214
+ case "NaN":
1215
+ return NaN;
1216
+ }
1217
+ return value;
1218
+ }
1219
+ if (ns.isDocumentSchema()) {
1220
+ if (isObject) {
1221
+ const out = Array.isArray(value) ? [] : {};
1222
+ for (const k in value) {
1223
+ const v = value[k];
1224
+ if (v instanceof NumericValue) {
1225
+ out[k] = v;
1226
+ } else {
1227
+ out[k] = this._read(ns, v);
1228
+ }
1229
+ }
1230
+ return out;
1231
+ } else {
1232
+ return structuredClone(value);
1233
+ }
1234
+ }
1235
+ return value;
1236
+ }
1237
+ };
1238
+
1239
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js
1240
+ var NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
1241
+ var JsonReplacer = class {
1242
+ values = /* @__PURE__ */ new Map();
1243
+ counter = 0;
1244
+ stage = 0;
1245
+ createReplacer() {
1246
+ if (this.stage === 1) {
1247
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
1248
+ }
1249
+ if (this.stage === 2) {
1250
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
1251
+ }
1252
+ this.stage = 1;
1253
+ return (key, value) => {
1254
+ if (value instanceof NumericValue) {
1255
+ const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
1256
+ this.values.set(`"${v}"`, value.string);
1257
+ return v;
1258
+ }
1259
+ if (typeof value === "bigint") {
1260
+ const s = value.toString();
1261
+ const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s;
1262
+ this.values.set(`"${v}"`, s);
1263
+ return v;
1264
+ }
1265
+ return value;
1266
+ };
1267
+ }
1268
+ replaceInJson(json) {
1269
+ if (this.stage === 0) {
1270
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
1271
+ }
1272
+ if (this.stage === 2) {
1273
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
1274
+ }
1275
+ this.stage = 2;
1276
+ if (this.counter === 0) {
1277
+ return json;
1278
+ }
1279
+ for (const [key, value] of this.values) {
1280
+ json = json.replace(key, value);
1281
+ }
1282
+ return json;
1283
+ }
1284
+ };
1285
+
1286
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeSerializer.js
1287
+ var JsonShapeSerializer = class extends SerdeContextConfig {
1288
+ settings;
1289
+ buffer;
1290
+ useReplacer = false;
1291
+ rootSchema;
1292
+ constructor(settings) {
1293
+ super();
1294
+ this.settings = settings;
1295
+ }
1296
+ write(schema, value) {
1297
+ this.rootSchema = NormalizedSchema.of(schema);
1298
+ this.buffer = this._write(this.rootSchema, value);
1299
+ }
1300
+ flush() {
1301
+ const { rootSchema, useReplacer } = this;
1302
+ this.rootSchema = void 0;
1303
+ this.useReplacer = false;
1304
+ if (rootSchema?.isStructSchema() || rootSchema?.isDocumentSchema()) {
1305
+ if (!useReplacer) {
1306
+ return JSON.stringify(this.buffer);
1307
+ }
1308
+ const replacer = new JsonReplacer();
1309
+ return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
1310
+ }
1311
+ return this.buffer;
1312
+ }
1313
+ writeDiscriminatedDocument(schema, value) {
1314
+ this.write(schema, value);
1315
+ if (typeof this.buffer === "object") {
1316
+ this.buffer.__type = NormalizedSchema.of(schema).getName(true);
1317
+ }
1318
+ }
1319
+ _write(schema, value, container) {
1320
+ const isObject = value !== null && typeof value === "object";
1321
+ const ns = NormalizedSchema.of(schema);
1322
+ if (isObject) {
1323
+ if (ns.isStructSchema()) {
1324
+ const record = value;
1325
+ const out = {};
1326
+ const { jsonName } = this.settings;
1327
+ let nameMap = void 0;
1328
+ if (jsonName) {
1329
+ nameMap = {};
1330
+ }
1331
+ let outCount = 0;
1332
+ for (const [memberName, memberSchema] of ns.structIterator()) {
1333
+ const serializableValue = this._write(memberSchema, record[memberName], ns);
1334
+ if (serializableValue !== void 0) {
1335
+ let targetKey = memberName;
1336
+ if (jsonName) {
1337
+ targetKey = memberSchema.getMergedTraits().jsonName ?? memberName;
1338
+ nameMap[memberName] = targetKey;
1339
+ }
1340
+ out[targetKey] = serializableValue;
1341
+ outCount++;
1342
+ }
1343
+ }
1344
+ if (ns.isUnionSchema() && outCount === 0) {
1345
+ const { $unknown } = record;
1346
+ if (Array.isArray($unknown)) {
1347
+ const [k, v] = $unknown;
1348
+ out[k] = this._write(15, v);
1349
+ }
1350
+ } else if (typeof record.__type === "string") {
1351
+ for (const k in record) {
1352
+ const v = record[k];
1353
+ const targetKey = jsonName ? nameMap[k] ?? k : k;
1354
+ if (!(targetKey in out)) {
1355
+ out[targetKey] = this._write(15, v);
1356
+ }
1357
+ }
1358
+ }
1359
+ return out;
1360
+ }
1361
+ if (Array.isArray(value) && ns.isListSchema()) {
1362
+ const listMember = ns.getValueSchema();
1363
+ const out = [];
1364
+ const sparse = !!ns.getMergedTraits().sparse;
1365
+ for (const item of value) {
1366
+ if (sparse || item != null) {
1367
+ out.push(this._write(listMember, item));
1368
+ }
1369
+ }
1370
+ return out;
1371
+ }
1372
+ if (ns.isMapSchema()) {
1373
+ const mapMember = ns.getValueSchema();
1374
+ const out = {};
1375
+ const sparse = !!ns.getMergedTraits().sparse;
1376
+ for (const _k in value) {
1377
+ const _v = value[_k];
1378
+ if (sparse || _v != null) {
1379
+ out[_k] = this._write(mapMember, _v);
1380
+ }
1381
+ }
1382
+ return out;
1383
+ }
1384
+ if (value instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
1385
+ if (ns === this.rootSchema) {
1386
+ return value;
1387
+ }
1388
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value);
1389
+ }
1390
+ if (value instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
1391
+ const format = determineTimestampFormat(ns, this.settings);
1392
+ switch (format) {
1393
+ case 5:
1394
+ return value.toISOString().replace(".000Z", "Z");
1395
+ case 6:
1396
+ return dateToUtcString(value);
1397
+ case 7:
1398
+ return value.getTime() / 1e3;
1399
+ default:
1400
+ console.warn("Missing timestamp format, using epoch seconds", value);
1401
+ return value.getTime() / 1e3;
1402
+ }
1403
+ }
1404
+ if (value instanceof NumericValue) {
1405
+ this.useReplacer = true;
1406
+ }
1407
+ }
1408
+ if (value === null && container?.isStructSchema()) {
1409
+ return void 0;
1410
+ }
1411
+ if (ns.isStringSchema()) {
1412
+ if (typeof value === "undefined" && ns.isIdempotencyToken()) {
1413
+ return generateIdempotencyToken();
1414
+ }
1415
+ const mediaType = ns.getMergedTraits().mediaType;
1416
+ if (value != null && mediaType) {
1417
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
1418
+ if (isJson) {
1419
+ return LazyJsonString.from(value);
1420
+ }
1421
+ }
1422
+ return value;
1423
+ }
1424
+ if (typeof value === "number" && ns.isNumericSchema()) {
1425
+ if (Math.abs(value) === Infinity || isNaN(value)) {
1426
+ return String(value);
1427
+ }
1428
+ return value;
1429
+ }
1430
+ if (typeof value === "string" && ns.isBlobSchema()) {
1431
+ if (ns === this.rootSchema) {
1432
+ return value;
1433
+ }
1434
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value);
1435
+ }
1436
+ if (typeof value === "bigint") {
1437
+ this.useReplacer = true;
1438
+ }
1439
+ if (ns.isDocumentSchema()) {
1440
+ if (isObject) {
1441
+ const out = Array.isArray(value) ? [] : {};
1442
+ for (const k in value) {
1443
+ const v = value[k];
1444
+ if (v instanceof NumericValue) {
1445
+ this.useReplacer = true;
1446
+ out[k] = v;
1447
+ } else {
1448
+ out[k] = this._write(ns, v);
1449
+ }
1450
+ }
1451
+ return out;
1452
+ } else {
1453
+ return structuredClone(value);
1454
+ }
1455
+ }
1456
+ return value;
1457
+ }
1458
+ };
1459
+
1460
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonCodec.js
1461
+ var JsonCodec = class extends SerdeContextConfig {
1462
+ settings;
1463
+ constructor(settings) {
1464
+ super();
1465
+ this.settings = settings;
1466
+ }
1467
+ createSerializer() {
1468
+ const serializer = new JsonShapeSerializer(this.settings);
1469
+ serializer.setSerdeContext(this.serdeContext);
1470
+ return serializer;
1471
+ }
1472
+ createDeserializer() {
1473
+ const deserializer = new JsonShapeDeserializer(this.settings);
1474
+ deserializer.setSerdeContext(this.serdeContext);
1475
+ return deserializer;
1476
+ }
1477
+ };
1478
+
1479
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js
1480
+ var AwsRestJsonProtocol = class extends HttpBindingProtocol {
1481
+ serializer;
1482
+ deserializer;
1483
+ codec;
1484
+ mixin = new ProtocolLib();
1485
+ constructor({ defaultNamespace, errorTypeRegistries }) {
1486
+ super({
1487
+ defaultNamespace,
1488
+ errorTypeRegistries
1489
+ });
1490
+ const settings = {
1491
+ timestampFormat: {
1492
+ useTrait: true,
1493
+ default: 7
1494
+ },
1495
+ httpBindings: true,
1496
+ jsonName: true
1497
+ };
1498
+ this.codec = new JsonCodec(settings);
1499
+ this.serializer = new HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
1500
+ this.deserializer = new HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
1501
+ }
1502
+ getShapeId() {
1503
+ return "aws.protocols#restJson1";
1504
+ }
1505
+ getPayloadCodec() {
1506
+ return this.codec;
1507
+ }
1508
+ setSerdeContext(serdeContext) {
1509
+ this.codec.setSerdeContext(serdeContext);
1510
+ super.setSerdeContext(serdeContext);
1511
+ }
1512
+ async serializeRequest(operationSchema, input, context) {
1513
+ const request = await super.serializeRequest(operationSchema, input, context);
1514
+ const inputSchema = NormalizedSchema.of(operationSchema.input);
1515
+ if (!request.headers["content-type"]) {
1516
+ const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
1517
+ if (contentType) {
1518
+ request.headers["content-type"] = contentType;
1519
+ }
1520
+ }
1521
+ if (request.body == null && request.headers["content-type"] === this.getDefaultContentType()) {
1522
+ request.body = "{}";
1523
+ }
1524
+ return request;
1525
+ }
1526
+ async deserializeResponse(operationSchema, context, response) {
1527
+ const output = await super.deserializeResponse(operationSchema, context, response);
1528
+ const outputSchema = NormalizedSchema.of(operationSchema.output);
1529
+ for (const [name, member] of outputSchema.structIterator()) {
1530
+ if (member.getMemberTraits().httpPayload && !(name in output)) {
1531
+ output[name] = null;
1532
+ }
1533
+ }
1534
+ return output;
1535
+ }
1536
+ async handleError(operationSchema, context, response, dataObject, metadata) {
1537
+ const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
1538
+ this.mixin.compose(this.compositeErrorRegistry, errorIdentifier, this.options.defaultNamespace);
1539
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
1540
+ const ns = NormalizedSchema.of(errorSchema);
1541
+ const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
1542
+ const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
1543
+ const exception = new ErrorCtor({});
1544
+ await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
1545
+ const output = {};
1546
+ const errorDeserializer = this.codec.createDeserializer();
1547
+ for (const [name, member] of ns.structIterator()) {
1548
+ const target = member.getMergedTraits().jsonName ?? name;
1549
+ output[name] = errorDeserializer.readObject(member, dataObject[target]);
1550
+ }
1551
+ throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
1552
+ $fault: ns.getMergedTraits().error,
1553
+ message
1554
+ }, output), dataObject);
1555
+ }
1556
+ getDefaultContentType() {
1557
+ return "application/json";
1558
+ }
1559
+ };
1560
+
1561
+ // ../../node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js
1562
+ function parseXML(xml) {
1563
+ const state = new AwsXmlParser(xml);
1564
+ return state.parse();
1565
+ }
1566
+ var AwsXmlParser = class _AwsXmlParser {
1567
+ x;
1568
+ i = 0;
1569
+ z;
1570
+ constructor(x) {
1571
+ this.x = x;
1572
+ this.x = x.replace(/\r\n?/g, "\n");
1573
+ this.z = this.x.length;
1574
+ }
1575
+ parse() {
1576
+ const p = this;
1577
+ const { z } = p;
1578
+ while (p.i < z) {
1579
+ p.trim();
1580
+ if (p.i >= z) {
1581
+ break;
1582
+ }
1583
+ if (p.isNext("<?")) {
1584
+ p.readTo("?>");
1585
+ p.trim();
1586
+ } else if (p.isNext("<!--")) {
1587
+ p.readTo("-->");
1588
+ p.trim();
1589
+ } else if (p.isNext("<!DOCTYPE", false)) {
1590
+ p.skipDoctype();
1591
+ p.trim();
1592
+ } else if (p.x[p.i] === "<") {
1593
+ const root = p.parseTag();
1594
+ return { [root.tag]: root.value };
1595
+ } else {
1596
+ throw new Error("@aws-sdk XML parse error: unexpected content.");
1597
+ }
1598
+ }
1599
+ throw new Error("@aws-sdk XML parse error: no root element.");
1600
+ }
1601
+ isNext(s, caseSensitive = true) {
1602
+ const p = this;
1603
+ if (caseSensitive) {
1604
+ return p.x.startsWith(s, p.i);
1605
+ }
1606
+ return p.x.toLowerCase().startsWith(s.toLowerCase(), p.i);
1607
+ }
1608
+ readTo(stop) {
1609
+ const p = this;
1610
+ const _i = p.x.indexOf(stop, p.i);
1611
+ if (_i === -1) {
1612
+ throw new Error(`@aws-sdk XML parse error: expected "${stop}" not found.`);
1613
+ }
1614
+ const result = p.x.slice(p.i, _i);
1615
+ p.i = _i + stop.length;
1616
+ return result;
1617
+ }
1618
+ trim() {
1619
+ const p = this;
1620
+ while (p.i < p.z && " \r\n".includes(p.x[p.i])) {
1621
+ ++p.i;
1622
+ }
1623
+ }
1624
+ readAttrValue() {
1625
+ const p = this;
1626
+ const quote = p.x[p.i];
1627
+ ++p.i;
1628
+ let value = "";
1629
+ while (p.i < p.z && p.x[p.i] !== quote) {
1630
+ value += p.x[p.i++];
1631
+ }
1632
+ ++p.i;
1633
+ return p.decodeEntities(value);
1634
+ }
1635
+ parseTag() {
1636
+ const p = this;
1637
+ ++p.i;
1638
+ let tag = "";
1639
+ while (p.i < p.z && !" \r\n>/".includes(p.x[p.i])) {
1640
+ tag += p.x[p.i++];
1641
+ }
1642
+ let hasAttrs = false;
1643
+ const attrs = /* @__PURE__ */ Object.create(null);
1644
+ while (p.i < p.z) {
1645
+ p.trim();
1646
+ if (">/".includes(p.x[p.i])) {
1647
+ break;
1648
+ }
1649
+ let name = "";
1650
+ while (p.i < p.z && !"= \r\n>/?".includes(p.x[p.i])) {
1651
+ name += p.x[p.i++];
1652
+ }
1653
+ p.trim();
1654
+ if (p.x[p.i] !== "=") {
1655
+ break;
1656
+ }
1657
+ ++p.i;
1658
+ p.trim();
1659
+ attrs[name] = p.readAttrValue();
1660
+ hasAttrs = true;
1661
+ }
1662
+ if (p.i >= p.z) {
1663
+ throw new Error("@aws-sdk XML parse error: unexpected end of input.");
1664
+ }
1665
+ if (p.x[p.i] === "/") {
1666
+ ++p.i;
1667
+ if (p.i >= p.z || p.x[p.i] !== ">") {
1668
+ throw new Error("@aws-sdk XML parse error: expected > at the end of self-closing tag.");
1669
+ }
1670
+ ++p.i;
1671
+ Object.setPrototypeOf(attrs, Object.prototype);
1672
+ return { tag, value: hasAttrs ? attrs : "" };
1673
+ }
1674
+ if (p.x[p.i] !== ">") {
1675
+ throw new Error("@aws-sdk XML parse error: expected > at the end of opening tag.");
1676
+ }
1677
+ ++p.i;
1678
+ const textParts = [];
1679
+ const childTags = [];
1680
+ let hasElementChild = false;
1681
+ while (p.i < p.z) {
1682
+ if (p.isNext("</")) {
1683
+ break;
1684
+ }
1685
+ if (p.x[p.i] === "<") {
1686
+ if (p.isNext("<!--")) {
1687
+ p.readTo("-->");
1688
+ } else if (p.isNext("<![CDATA[")) {
1689
+ p.i += 9;
1690
+ textParts.push(p.readTo("]]>"));
1691
+ } else if (p.isNext("<?")) {
1692
+ p.readTo("?>");
1693
+ } else {
1694
+ hasElementChild = true;
1695
+ childTags.push(p.parseTag());
1696
+ }
1697
+ } else {
1698
+ let text = "";
1699
+ while (p.i < p.z && p.x[p.i] !== "<") {
1700
+ text += p.x[p.i++];
1701
+ }
1702
+ textParts.push(p.decodeEntities(text));
1703
+ }
1704
+ }
1705
+ if (!p.isNext("</")) {
1706
+ throw new Error(`@aws-sdk XML parse error: missing closing tag </${tag}>.`);
1707
+ }
1708
+ p.i += 2;
1709
+ const closeTag = p.readTo(">").trim();
1710
+ if (closeTag !== tag) {
1711
+ throw new Error(`@aws-sdk XML parse error: mismatched tags <${tag}> and </${closeTag}>.`);
1712
+ }
1713
+ if (!hasAttrs && textParts.length === 0 && !hasElementChild) {
1714
+ return { tag, value: "" };
1715
+ }
1716
+ if (!hasAttrs && !hasElementChild) {
1717
+ const text = textParts.length === 1 ? textParts[0] : textParts.join("");
1718
+ if (text.trim() === "" && text.includes("\n")) {
1719
+ return { tag, value: "" };
1720
+ }
1721
+ return { tag, value: text };
1722
+ }
1723
+ const obj = /* @__PURE__ */ Object.create(null);
1724
+ for (const text of textParts) {
1725
+ if (text.trim() === "" && text.includes("\n")) {
1726
+ continue;
1727
+ }
1728
+ obj["#text"] = "#text" in obj ? obj["#text"] + text : text;
1729
+ }
1730
+ for (const child of childTags) {
1731
+ if (child.tag in obj) {
1732
+ if (Array.isArray(obj[child.tag])) {
1733
+ obj[child.tag].push(child.value);
1734
+ } else {
1735
+ obj[child.tag] = [obj[child.tag], child.value];
1736
+ }
1737
+ } else {
1738
+ obj[child.tag] = child.value;
1739
+ }
1740
+ }
1741
+ for (const [k, v] of Object.entries(attrs)) {
1742
+ obj[k] = v;
1743
+ }
1744
+ Object.setPrototypeOf(obj, Object.prototype);
1745
+ return { tag, value: obj };
1746
+ }
1747
+ static ENTITIES = {
1748
+ amp: "&",
1749
+ lt: "<",
1750
+ gt: ">",
1751
+ quot: '"',
1752
+ apos: "'"
1753
+ };
1754
+ skipDoctype() {
1755
+ const p = this;
1756
+ p.i += 9;
1757
+ let depth = 0;
1758
+ while (p.i < p.z) {
1759
+ const c = p.x[p.i];
1760
+ if (c === "[") {
1761
+ ++depth;
1762
+ } else if (c === "]") {
1763
+ --depth;
1764
+ } else if (c === ">" && depth === 0) {
1765
+ ++p.i;
1766
+ return;
1767
+ }
1768
+ ++p.i;
1769
+ }
1770
+ throw new Error("@aws-sdk XML parse error: unclosed DOCTYPE.");
1771
+ }
1772
+ decodeEntities(s) {
1773
+ return s.replace(/&(?:#x([0-9a-fA-F]{1,6})|#(\d{1,7})|([a-zA-Z][a-zA-Z0-9]{0,30}));/g, (_, hex, dec, named) => {
1774
+ if (hex) {
1775
+ return String.fromCharCode(parseInt(hex, 16));
1776
+ }
1777
+ if (dec) {
1778
+ return String.fromCharCode(parseInt(dec, 10));
1779
+ }
1780
+ return _AwsXmlParser.ENTITIES[named] ?? "";
1781
+ });
1782
+ }
1783
+ };
1784
+
1785
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js
1786
+ var XmlShapeDeserializer = class extends SerdeContextConfig {
1787
+ settings;
1788
+ stringDeserializer;
1789
+ constructor(settings) {
1790
+ super();
1791
+ this.settings = settings;
1792
+ this.stringDeserializer = new FromStringShapeDeserializer(settings);
1793
+ }
1794
+ setSerdeContext(serdeContext) {
1795
+ this.serdeContext = serdeContext;
1796
+ this.stringDeserializer.setSerdeContext(serdeContext);
1797
+ }
1798
+ read(schema, bytes, key) {
1799
+ const ns = NormalizedSchema.of(schema);
1800
+ const memberSchemas = ns.getMemberSchemas();
1801
+ const isEventPayload = ns.isStructSchema() && ns.isMemberSchema() && !!Object.values(memberSchemas).find((memberNs) => {
1802
+ return !!memberNs.getMemberTraits().eventPayload;
1803
+ });
1804
+ if (isEventPayload) {
1805
+ const output = {};
1806
+ const memberName = Object.keys(memberSchemas)[0];
1807
+ const eventMemberSchema = memberSchemas[memberName];
1808
+ if (eventMemberSchema.isBlobSchema()) {
1809
+ output[memberName] = bytes;
1810
+ } else {
1811
+ output[memberName] = this.read(memberSchemas[memberName], bytes);
1812
+ }
1813
+ return output;
1814
+ }
1815
+ const xmlString = (this.serdeContext?.utf8Encoder ?? toUtf8)(bytes);
1816
+ const parsedObject = this.parseXml(xmlString);
1817
+ return this.readSchema(schema, key ? parsedObject[key] : parsedObject);
1818
+ }
1819
+ readSchema(_schema, value) {
1820
+ const ns = NormalizedSchema.of(_schema);
1821
+ if (ns.isUnitSchema()) {
1822
+ return;
1823
+ }
1824
+ const traits = ns.getMergedTraits();
1825
+ if (ns.isListSchema() && !Array.isArray(value)) {
1826
+ return this.readSchema(ns, [value]);
1827
+ }
1828
+ if (value == null) {
1829
+ return value;
1830
+ }
1831
+ if (typeof value === "object") {
1832
+ const flat = !!traits.xmlFlattened;
1833
+ if (ns.isListSchema()) {
1834
+ const listValue = ns.getValueSchema();
1835
+ const buffer2 = [];
1836
+ const sourceKey = listValue.getMergedTraits().xmlName ?? "member";
1837
+ const source = flat ? value : (value[0] ?? value)[sourceKey];
1838
+ if (source == null) {
1839
+ return buffer2;
1840
+ }
1841
+ const sourceArray = Array.isArray(source) ? source : [source];
1842
+ for (const v of sourceArray) {
1843
+ buffer2.push(this.readSchema(listValue, v));
1844
+ }
1845
+ return buffer2;
1846
+ }
1847
+ const buffer = {};
1848
+ if (ns.isMapSchema()) {
1849
+ const keyNs = ns.getKeySchema();
1850
+ const memberNs = ns.getValueSchema();
1851
+ let entries;
1852
+ if (flat) {
1853
+ entries = Array.isArray(value) ? value : [value];
1854
+ } else {
1855
+ entries = Array.isArray(value.entry) ? value.entry : [value.entry];
1856
+ }
1857
+ const keyProperty = keyNs.getMergedTraits().xmlName ?? "key";
1858
+ const valueProperty = memberNs.getMergedTraits().xmlName ?? "value";
1859
+ for (const entry of entries) {
1860
+ const key = entry[keyProperty];
1861
+ const value2 = entry[valueProperty];
1862
+ buffer[key] = this.readSchema(memberNs, value2);
1863
+ }
1864
+ return buffer;
1865
+ }
1866
+ if (ns.isStructSchema()) {
1867
+ const union = ns.isUnionSchema();
1868
+ let unionSerde;
1869
+ if (union) {
1870
+ unionSerde = new UnionSerde(value, buffer);
1871
+ }
1872
+ for (const [memberName, memberSchema] of ns.structIterator()) {
1873
+ const memberTraits = memberSchema.getMergedTraits();
1874
+ const xmlObjectKey = !memberTraits.httpPayload ? memberSchema.getMemberTraits().xmlName ?? memberName : memberTraits.xmlName ?? memberSchema.getName();
1875
+ if (union) {
1876
+ unionSerde.mark(xmlObjectKey);
1877
+ }
1878
+ if (value[xmlObjectKey] != null) {
1879
+ buffer[memberName] = this.readSchema(memberSchema, value[xmlObjectKey]);
1880
+ }
1881
+ }
1882
+ if (union) {
1883
+ unionSerde.writeUnknown();
1884
+ }
1885
+ return buffer;
1886
+ }
1887
+ if (ns.isDocumentSchema()) {
1888
+ return value;
1889
+ }
1890
+ throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
1891
+ }
1892
+ if (ns.isListSchema()) {
1893
+ return [];
1894
+ }
1895
+ if (ns.isMapSchema() || ns.isStructSchema()) {
1896
+ return {};
1897
+ }
1898
+ return this.stringDeserializer.read(ns, value);
1899
+ }
1900
+ parseXml(xml) {
1901
+ if (xml.length) {
1902
+ let parsedObj;
1903
+ try {
1904
+ parsedObj = parseXML(xml);
1905
+ } catch (e) {
1906
+ if (e && typeof e === "object") {
1907
+ Object.defineProperty(e, "$responseBodyText", {
1908
+ value: xml
1909
+ });
1910
+ }
1911
+ throw e;
1912
+ }
1913
+ const textNodeName = "#text";
1914
+ const key = Object.keys(parsedObj)[0];
1915
+ const parsedObjToReturn = parsedObj[key];
1916
+ if (parsedObjToReturn[textNodeName]) {
1917
+ parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
1918
+ delete parsedObjToReturn[textNodeName];
1919
+ }
1920
+ return getValueFromTextNode(parsedObjToReturn);
1921
+ }
1922
+ return {};
1923
+ }
1924
+ };
1925
+
1926
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/QueryShapeSerializer.js
1927
+ var QueryShapeSerializer = class extends SerdeContextConfig {
1928
+ settings;
1929
+ buffer;
1930
+ constructor(settings) {
1931
+ super();
1932
+ this.settings = settings;
1933
+ }
1934
+ write(schema, value, prefix = "") {
1935
+ if (this.buffer === void 0) {
1936
+ this.buffer = "";
1937
+ }
1938
+ const ns = NormalizedSchema.of(schema);
1939
+ if (prefix && !prefix.endsWith(".")) {
1940
+ prefix += ".";
1941
+ }
1942
+ if (ns.isBlobSchema()) {
1943
+ if (typeof value === "string" || value instanceof Uint8Array) {
1944
+ this.writeKey(prefix);
1945
+ this.writeValue((this.serdeContext?.base64Encoder ?? toBase64)(value));
1946
+ }
1947
+ } else if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isStringSchema()) {
1948
+ if (value != null) {
1949
+ this.writeKey(prefix);
1950
+ this.writeValue(String(value));
1951
+ } else if (ns.isIdempotencyToken()) {
1952
+ this.writeKey(prefix);
1953
+ this.writeValue(generateIdempotencyToken());
1954
+ }
1955
+ } else if (ns.isBigIntegerSchema()) {
1956
+ if (value != null) {
1957
+ this.writeKey(prefix);
1958
+ this.writeValue(String(value));
1959
+ }
1960
+ } else if (ns.isBigDecimalSchema()) {
1961
+ if (value != null) {
1962
+ this.writeKey(prefix);
1963
+ this.writeValue(value instanceof NumericValue ? value.string : String(value));
1964
+ }
1965
+ } else if (ns.isTimestampSchema()) {
1966
+ if (value instanceof Date) {
1967
+ this.writeKey(prefix);
1968
+ const format = determineTimestampFormat(ns, this.settings);
1969
+ switch (format) {
1970
+ case 5:
1971
+ this.writeValue(value.toISOString().replace(".000Z", "Z"));
1972
+ break;
1973
+ case 6:
1974
+ this.writeValue(dateToUtcString(value));
1975
+ break;
1976
+ case 7:
1977
+ this.writeValue(String(value.getTime() / 1e3));
1978
+ break;
1979
+ }
1980
+ }
1981
+ } else if (ns.isDocumentSchema()) {
1982
+ if (Array.isArray(value)) {
1983
+ this.write(64 | 15, value, prefix);
1984
+ } else if (value instanceof Date) {
1985
+ this.write(4, value, prefix);
1986
+ } else if (value instanceof Uint8Array) {
1987
+ this.write(21, value, prefix);
1988
+ } else if (value && typeof value === "object") {
1989
+ this.write(128 | 15, value, prefix);
1990
+ } else {
1991
+ this.writeKey(prefix);
1992
+ this.writeValue(String(value));
1993
+ }
1994
+ } else if (ns.isListSchema()) {
1995
+ if (Array.isArray(value)) {
1996
+ if (value.length === 0) {
1997
+ if (this.settings.serializeEmptyLists) {
1998
+ this.writeKey(prefix);
1999
+ this.writeValue("");
2000
+ }
2001
+ } else {
2002
+ const member = ns.getValueSchema();
2003
+ const flat = this.settings.flattenLists || ns.getMergedTraits().xmlFlattened;
2004
+ let i = 1;
2005
+ for (const item of value) {
2006
+ if (item == null) {
2007
+ continue;
2008
+ }
2009
+ const traits = member.getMergedTraits();
2010
+ const suffix = this.getKey("member", traits.xmlName, traits.ec2QueryName);
2011
+ const key = flat ? `${prefix}${i}` : `${prefix}${suffix}.${i}`;
2012
+ this.write(member, item, key);
2013
+ ++i;
2014
+ }
2015
+ }
2016
+ }
2017
+ } else if (ns.isMapSchema()) {
2018
+ if (value && typeof value === "object") {
2019
+ const keySchema = ns.getKeySchema();
2020
+ const memberSchema = ns.getValueSchema();
2021
+ const flat = ns.getMergedTraits().xmlFlattened;
2022
+ let i = 1;
2023
+ for (const k in value) {
2024
+ const v = value[k];
2025
+ if (v == null) {
2026
+ continue;
2027
+ }
2028
+ const keyTraits = keySchema.getMergedTraits();
2029
+ const keySuffix = this.getKey("key", keyTraits.xmlName, keyTraits.ec2QueryName);
2030
+ const key = flat ? `${prefix}${i}.${keySuffix}` : `${prefix}entry.${i}.${keySuffix}`;
2031
+ const valTraits = memberSchema.getMergedTraits();
2032
+ const valueSuffix = this.getKey("value", valTraits.xmlName, valTraits.ec2QueryName);
2033
+ const valueKey = flat ? `${prefix}${i}.${valueSuffix}` : `${prefix}entry.${i}.${valueSuffix}`;
2034
+ this.write(keySchema, k, key);
2035
+ this.write(memberSchema, v, valueKey);
2036
+ ++i;
2037
+ }
2038
+ }
2039
+ } else if (ns.isStructSchema()) {
2040
+ if (value && typeof value === "object") {
2041
+ let didWriteMember = false;
2042
+ for (const [memberName, member] of ns.structIterator()) {
2043
+ if (value[memberName] == null && !member.isIdempotencyToken()) {
2044
+ continue;
2045
+ }
2046
+ const traits = member.getMergedTraits();
2047
+ const suffix = this.getKey(memberName, traits.xmlName, traits.ec2QueryName, "struct");
2048
+ const key = `${prefix}${suffix}`;
2049
+ this.write(member, value[memberName], key);
2050
+ didWriteMember = true;
2051
+ }
2052
+ if (!didWriteMember && ns.isUnionSchema()) {
2053
+ const { $unknown } = value;
2054
+ if (Array.isArray($unknown)) {
2055
+ const [k, v] = $unknown;
2056
+ const key = `${prefix}${k}`;
2057
+ this.write(15, v, key);
2058
+ }
2059
+ }
2060
+ }
2061
+ } else if (ns.isUnitSchema()) {
2062
+ } else {
2063
+ throw new Error(`@aws-sdk/core/protocols - QuerySerializer unrecognized schema type ${ns.getName(true)}`);
2064
+ }
2065
+ }
2066
+ flush() {
2067
+ if (this.buffer === void 0) {
2068
+ throw new Error("@aws-sdk/core/protocols - QuerySerializer cannot flush with nothing written to buffer.");
2069
+ }
2070
+ const str = this.buffer;
2071
+ delete this.buffer;
2072
+ return str;
2073
+ }
2074
+ getKey(memberName, xmlName, ec2QueryName, keySource) {
2075
+ const { ec2, capitalizeKeys } = this.settings;
2076
+ if (ec2 && ec2QueryName) {
2077
+ return ec2QueryName;
2078
+ }
2079
+ const key = xmlName ?? memberName;
2080
+ if (capitalizeKeys && keySource === "struct") {
2081
+ return key[0].toUpperCase() + key.slice(1);
2082
+ }
2083
+ return key;
2084
+ }
2085
+ writeKey(key) {
2086
+ if (key.endsWith(".")) {
2087
+ key = key.slice(0, key.length - 1);
2088
+ }
2089
+ this.buffer += `&${extendedEncodeURIComponent(key)}=`;
2090
+ }
2091
+ writeValue(value) {
2092
+ this.buffer += extendedEncodeURIComponent(value);
2093
+ }
2094
+ };
2095
+
2096
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js
2097
+ var AwsQueryProtocol = class extends RpcProtocol {
2098
+ options;
2099
+ serializer;
2100
+ deserializer;
2101
+ mixin = new ProtocolLib();
2102
+ constructor(options) {
2103
+ super({
2104
+ defaultNamespace: options.defaultNamespace,
2105
+ errorTypeRegistries: options.errorTypeRegistries
2106
+ });
2107
+ this.options = options;
2108
+ const settings = {
2109
+ timestampFormat: {
2110
+ useTrait: true,
2111
+ default: 5
2112
+ },
2113
+ httpBindings: false,
2114
+ xmlNamespace: options.xmlNamespace,
2115
+ serviceNamespace: options.defaultNamespace,
2116
+ serializeEmptyLists: true
2117
+ };
2118
+ this.serializer = new QueryShapeSerializer(settings);
2119
+ this.deserializer = new XmlShapeDeserializer(settings);
2120
+ }
2121
+ getShapeId() {
2122
+ return "aws.protocols#awsQuery";
2123
+ }
2124
+ setSerdeContext(serdeContext) {
2125
+ this.serializer.setSerdeContext(serdeContext);
2126
+ this.deserializer.setSerdeContext(serdeContext);
2127
+ }
2128
+ getPayloadCodec() {
2129
+ throw new Error("AWSQuery protocol has no payload codec.");
2130
+ }
2131
+ async serializeRequest(operationSchema, input, context) {
2132
+ const request = await super.serializeRequest(operationSchema, input, context);
2133
+ if (!request.path.endsWith("/")) {
2134
+ request.path += "/";
2135
+ }
2136
+ request.headers["content-type"] = "application/x-www-form-urlencoded";
2137
+ if (deref(operationSchema.input) === "unit" || !request.body) {
2138
+ request.body = "";
2139
+ }
2140
+ const action = operationSchema.name.split("#")[1] ?? operationSchema.name;
2141
+ request.body = `Action=${action}&Version=${this.options.version}` + request.body;
2142
+ if (request.body.endsWith("&")) {
2143
+ request.body = request.body.slice(-1);
2144
+ }
2145
+ return request;
2146
+ }
2147
+ async deserializeResponse(operationSchema, context, response) {
2148
+ const deserializer = this.deserializer;
2149
+ const ns = NormalizedSchema.of(operationSchema.output);
2150
+ const dataObject = {};
2151
+ if (response.statusCode >= 300) {
2152
+ const bytes2 = await collectBody(response.body, context);
2153
+ if (bytes2.byteLength > 0) {
2154
+ Object.assign(dataObject, await deserializer.read(15, bytes2));
2155
+ }
2156
+ await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
2157
+ }
2158
+ for (const header in response.headers) {
2159
+ const value = response.headers[header];
2160
+ delete response.headers[header];
2161
+ response.headers[header.toLowerCase()] = value;
2162
+ }
2163
+ const shortName = operationSchema.name.split("#")[1] ?? operationSchema.name;
2164
+ const awsQueryResultKey = ns.isStructSchema() && this.useNestedResult() ? shortName + "Result" : void 0;
2165
+ const bytes = await collectBody(response.body, context);
2166
+ if (bytes.byteLength > 0) {
2167
+ Object.assign(dataObject, await deserializer.read(ns, bytes, awsQueryResultKey));
2168
+ }
2169
+ dataObject.$metadata = this.deserializeMetadata(response);
2170
+ return dataObject;
2171
+ }
2172
+ useNestedResult() {
2173
+ return true;
2174
+ }
2175
+ async handleError(operationSchema, context, response, dataObject, metadata) {
2176
+ const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
2177
+ this.mixin.compose(this.compositeErrorRegistry, errorIdentifier, this.options.defaultNamespace);
2178
+ const errorData = this.loadQueryError(dataObject) ?? {};
2179
+ const message = this.loadQueryErrorMessage(dataObject);
2180
+ errorData.message = message;
2181
+ errorData.Error = {
2182
+ Type: errorData.Type,
2183
+ Code: errorData.Code,
2184
+ Message: message
2185
+ };
2186
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
2187
+ const ns = NormalizedSchema.of(errorSchema);
2188
+ const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
2189
+ const exception = new ErrorCtor({});
2190
+ const output = {
2191
+ Type: errorData.Error.Type,
2192
+ Code: errorData.Error.Code,
2193
+ Error: errorData.Error
2194
+ };
2195
+ for (const [name, member] of ns.structIterator()) {
2196
+ const target = member.getMergedTraits().xmlName ?? name;
2197
+ const value = errorData[target] ?? dataObject[target];
2198
+ output[name] = this.deserializer.readSchema(member, value);
2199
+ }
2200
+ throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
2201
+ $fault: ns.getMergedTraits().error,
2202
+ message
2203
+ }, output), dataObject);
2204
+ }
2205
+ loadQueryErrorCode(output, data) {
2206
+ const code = (data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error)?.Code;
2207
+ if (code !== void 0) {
2208
+ return code;
2209
+ }
2210
+ if (output.statusCode == 404) {
2211
+ return "NotFound";
2212
+ }
2213
+ }
2214
+ loadQueryError(data) {
2215
+ return data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error;
2216
+ }
2217
+ loadQueryErrorMessage(data) {
2218
+ const errorData = this.loadQueryError(data);
2219
+ return errorData?.message ?? errorData?.Message ?? data.message ?? data.Message ?? "Unknown";
2220
+ }
2221
+ getDefaultContentType() {
2222
+ return "application/x-www-form-urlencoded";
2223
+ }
2224
+ };
2225
+
2226
+ export {
2227
+ AwsSdkSigV4Signer,
2228
+ AwsSdkSigV4ASigner,
2229
+ NODE_AUTH_SCHEME_PREFERENCE_OPTIONS,
2230
+ resolveAwsSdkSigV4AConfig,
2231
+ NODE_SIGV4A_CONFIG_OPTIONS,
2232
+ SignatureV4,
2233
+ signatureV4aContainer,
2234
+ resolveAwsSdkSigV4Config,
2235
+ AwsRestJsonProtocol,
2236
+ AwsQueryProtocol
2237
+ };
2238
+ //# sourceMappingURL=chunk-TTCF2MVW.js.map