@cdk8s/awscdk-resolver 0.0.145 → 0.0.147
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/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +6 -6
- package/node_modules/@aws-sdk/client-sso/package.json +3 -3
- package/node_modules/@aws-sdk/client-sso-oidc/package.json +5 -5
- package/node_modules/@aws-sdk/client-sts/dist-cjs/index.js +8 -2
- package/node_modules/@aws-sdk/client-sts/dist-es/defaultStsRoleAssumers.js +7 -2
- package/node_modules/@aws-sdk/client-sts/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
- package/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/util-endpoints/dist-es/lib/aws/parseArn.js +1 -3
- package/node_modules/@aws-sdk/util-endpoints/package.json +1 -1
- package/node_modules/@smithy/core/cbor.js +6 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +707 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-decode.js +391 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-encode.js +181 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-types.js +20 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor.js +15 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/index.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +82 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-decode.d.ts +17 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-encode.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-types.d.ts +40 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor.d.ts +26 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/index.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/parseCborBody.d.ts +29 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/cbor-decode.d.ts +17 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/cbor-encode.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/cbor-types.d.ts +43 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/cbor.d.ts +26 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/index.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/parseCborBody.d.ts +29 -0
- package/node_modules/@smithy/core/package.json +17 -5
- package/node_modules/@smithy/middleware-retry/package.json +2 -2
- package/node_modules/@smithy/smithy-client/dist-cjs/index.js +2 -0
- package/node_modules/@smithy/smithy-client/dist-es/date-utils.js +3 -0
- package/node_modules/@smithy/smithy-client/dist-types/serde-json.d.ts +2 -0
- package/node_modules/@smithy/smithy-client/dist-types/ts3.4/serde-json.d.ts +2 -0
- package/node_modules/@smithy/smithy-client/package.json +1 -1
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/package.json +4 -4
@@ -0,0 +1,707 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
|
19
|
+
// src/submodules/cbor/index.ts
|
20
|
+
var cbor_exports = {};
|
21
|
+
__export(cbor_exports, {
|
22
|
+
buildHttpRpcRequest: () => buildHttpRpcRequest,
|
23
|
+
cbor: () => cbor,
|
24
|
+
checkCborResponse: () => checkCborResponse,
|
25
|
+
dateToTag: () => dateToTag,
|
26
|
+
loadSmithyRpcV2CborErrorCode: () => loadSmithyRpcV2CborErrorCode,
|
27
|
+
parseCborBody: () => parseCborBody,
|
28
|
+
parseCborErrorBody: () => parseCborErrorBody
|
29
|
+
});
|
30
|
+
module.exports = __toCommonJS(cbor_exports);
|
31
|
+
|
32
|
+
// src/submodules/cbor/cbor-decode.ts
|
33
|
+
var import_util_utf8 = require("@smithy/util-utf8");
|
34
|
+
|
35
|
+
// src/submodules/cbor/cbor-types.ts
|
36
|
+
var majorUint64 = 0;
|
37
|
+
var majorNegativeInt64 = 1;
|
38
|
+
var majorUnstructuredByteString = 2;
|
39
|
+
var majorUtf8String = 3;
|
40
|
+
var majorList = 4;
|
41
|
+
var majorMap = 5;
|
42
|
+
var majorTag = 6;
|
43
|
+
var majorSpecial = 7;
|
44
|
+
var specialFalse = 20;
|
45
|
+
var specialTrue = 21;
|
46
|
+
var specialNull = 22;
|
47
|
+
var specialUndefined = 23;
|
48
|
+
var extendedOneByte = 24;
|
49
|
+
var extendedFloat16 = 25;
|
50
|
+
var extendedFloat32 = 26;
|
51
|
+
var extendedFloat64 = 27;
|
52
|
+
var minorIndefinite = 31;
|
53
|
+
function alloc(size) {
|
54
|
+
return typeof Buffer !== "undefined" ? Buffer.alloc(size) : new Uint8Array(size);
|
55
|
+
}
|
56
|
+
|
57
|
+
// src/submodules/cbor/cbor-decode.ts
|
58
|
+
var USE_TEXT_DECODER = typeof TextDecoder !== "undefined";
|
59
|
+
var USE_BUFFER = typeof Buffer !== "undefined";
|
60
|
+
var payload = alloc(0);
|
61
|
+
var dataView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
|
62
|
+
var textDecoder = USE_TEXT_DECODER ? new TextDecoder() : null;
|
63
|
+
var _offset = 0;
|
64
|
+
function setPayload(bytes) {
|
65
|
+
payload = bytes;
|
66
|
+
dataView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
|
67
|
+
}
|
68
|
+
function decode(at, to) {
|
69
|
+
if (at >= to) {
|
70
|
+
throw new Error("unexpected end of (decode) payload.");
|
71
|
+
}
|
72
|
+
const major = (payload[at] & 224) >> 5;
|
73
|
+
const minor = payload[at] & 31;
|
74
|
+
switch (major) {
|
75
|
+
case majorUint64:
|
76
|
+
case majorNegativeInt64:
|
77
|
+
case majorTag:
|
78
|
+
let unsignedInt;
|
79
|
+
let offset;
|
80
|
+
if (minor < 24) {
|
81
|
+
unsignedInt = minor;
|
82
|
+
offset = 1;
|
83
|
+
} else {
|
84
|
+
switch (minor) {
|
85
|
+
case extendedOneByte:
|
86
|
+
case extendedFloat16:
|
87
|
+
case extendedFloat32:
|
88
|
+
case extendedFloat64:
|
89
|
+
const countLength = minorValueToArgumentLength[minor];
|
90
|
+
const countOffset = countLength + 1;
|
91
|
+
offset = countOffset;
|
92
|
+
if (to - at < countOffset) {
|
93
|
+
throw new Error(`countLength ${countLength} greater than remaining buf len.`);
|
94
|
+
}
|
95
|
+
const countIndex = at + 1;
|
96
|
+
if (countLength === 1) {
|
97
|
+
unsignedInt = payload[countIndex];
|
98
|
+
} else if (countLength === 2) {
|
99
|
+
unsignedInt = dataView.getUint16(countIndex);
|
100
|
+
} else if (countLength === 4) {
|
101
|
+
unsignedInt = dataView.getUint32(countIndex);
|
102
|
+
} else {
|
103
|
+
unsignedInt = dataView.getBigUint64(countIndex);
|
104
|
+
}
|
105
|
+
break;
|
106
|
+
default:
|
107
|
+
throw new Error(`unexpected minor value ${minor}.`);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
if (major === majorUint64) {
|
111
|
+
_offset = offset;
|
112
|
+
return castBigInt(unsignedInt);
|
113
|
+
} else if (major === majorNegativeInt64) {
|
114
|
+
let negativeInt;
|
115
|
+
if (typeof unsignedInt === "bigint") {
|
116
|
+
negativeInt = BigInt(-1) - unsignedInt;
|
117
|
+
} else {
|
118
|
+
negativeInt = -1 - unsignedInt;
|
119
|
+
}
|
120
|
+
_offset = offset;
|
121
|
+
return castBigInt(negativeInt);
|
122
|
+
} else {
|
123
|
+
const value = decode(at + offset, to);
|
124
|
+
const valueOffset = _offset;
|
125
|
+
_offset = offset + valueOffset;
|
126
|
+
return { tag: castBigInt(unsignedInt), value };
|
127
|
+
}
|
128
|
+
case majorUtf8String:
|
129
|
+
case majorMap:
|
130
|
+
case majorList:
|
131
|
+
case majorUnstructuredByteString:
|
132
|
+
if (minor === minorIndefinite) {
|
133
|
+
switch (major) {
|
134
|
+
case majorUtf8String:
|
135
|
+
return decodeUtf8StringIndefinite(at, to);
|
136
|
+
case majorMap:
|
137
|
+
return decodeMapIndefinite(at, to);
|
138
|
+
case majorList:
|
139
|
+
return decodeListIndefinite(at, to);
|
140
|
+
case majorUnstructuredByteString:
|
141
|
+
return decodeUnstructuredByteStringIndefinite(at, to);
|
142
|
+
}
|
143
|
+
} else {
|
144
|
+
switch (major) {
|
145
|
+
case majorUtf8String:
|
146
|
+
return decodeUtf8String(at, to);
|
147
|
+
case majorMap:
|
148
|
+
return decodeMap(at, to);
|
149
|
+
case majorList:
|
150
|
+
return decodeList(at, to);
|
151
|
+
case majorUnstructuredByteString:
|
152
|
+
return decodeUnstructuredByteString(at, to);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
default:
|
156
|
+
return decodeSpecial(at, to);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
function bytesToUtf8(bytes, at, to) {
|
160
|
+
var _a;
|
161
|
+
if (USE_BUFFER && ((_a = bytes.constructor) == null ? void 0 : _a.name) === "Buffer") {
|
162
|
+
return bytes.toString("utf-8", at, to);
|
163
|
+
}
|
164
|
+
if (textDecoder) {
|
165
|
+
return textDecoder.decode(bytes.subarray(at, to));
|
166
|
+
}
|
167
|
+
return (0, import_util_utf8.toUtf8)(bytes.subarray(at, to));
|
168
|
+
}
|
169
|
+
function demote(bigInteger) {
|
170
|
+
const num = Number(bigInteger);
|
171
|
+
if (num < Number.MIN_SAFE_INTEGER || Number.MAX_SAFE_INTEGER < num) {
|
172
|
+
console.warn(new Error(`@smithy/core/cbor - truncating BigInt(${bigInteger}) to ${num} with loss of precision.`));
|
173
|
+
}
|
174
|
+
return num;
|
175
|
+
}
|
176
|
+
var minorValueToArgumentLength = {
|
177
|
+
[extendedOneByte]: 1,
|
178
|
+
[extendedFloat16]: 2,
|
179
|
+
[extendedFloat32]: 4,
|
180
|
+
[extendedFloat64]: 8
|
181
|
+
};
|
182
|
+
function bytesToFloat16(a, b) {
|
183
|
+
const sign = a >> 7;
|
184
|
+
const exponent = (a & 124) >> 2;
|
185
|
+
const fraction = (a & 3) << 8 | b;
|
186
|
+
const scalar = sign === 0 ? 1 : -1;
|
187
|
+
let exponentComponent;
|
188
|
+
let summation;
|
189
|
+
if (exponent === 0) {
|
190
|
+
if (fraction === 0) {
|
191
|
+
return 0;
|
192
|
+
} else {
|
193
|
+
exponentComponent = Math.pow(2, 1 - 15);
|
194
|
+
summation = 0;
|
195
|
+
}
|
196
|
+
} else if (exponent === 31) {
|
197
|
+
if (fraction === 0) {
|
198
|
+
return scalar * Infinity;
|
199
|
+
} else {
|
200
|
+
return NaN;
|
201
|
+
}
|
202
|
+
} else {
|
203
|
+
exponentComponent = Math.pow(2, exponent - 15);
|
204
|
+
summation = 1;
|
205
|
+
}
|
206
|
+
summation += fraction / 1024;
|
207
|
+
return scalar * (exponentComponent * summation);
|
208
|
+
}
|
209
|
+
function decodeCount(at, to) {
|
210
|
+
const minor = payload[at] & 31;
|
211
|
+
if (minor < 24) {
|
212
|
+
_offset = 1;
|
213
|
+
return minor;
|
214
|
+
}
|
215
|
+
if (minor === extendedOneByte || minor === extendedFloat16 || minor === extendedFloat32 || minor === extendedFloat64) {
|
216
|
+
const countLength = minorValueToArgumentLength[minor];
|
217
|
+
_offset = countLength + 1;
|
218
|
+
if (to - at < _offset) {
|
219
|
+
throw new Error(`countLength ${countLength} greater than remaining buf len.`);
|
220
|
+
}
|
221
|
+
const countIndex = at + 1;
|
222
|
+
if (countLength === 1) {
|
223
|
+
return payload[countIndex];
|
224
|
+
} else if (countLength === 2) {
|
225
|
+
return dataView.getUint16(countIndex);
|
226
|
+
} else if (countLength === 4) {
|
227
|
+
return dataView.getUint32(countIndex);
|
228
|
+
}
|
229
|
+
return demote(dataView.getBigUint64(countIndex));
|
230
|
+
}
|
231
|
+
throw new Error(`unexpected minor value ${minor}.`);
|
232
|
+
}
|
233
|
+
function decodeUtf8String(at, to) {
|
234
|
+
const length = decodeCount(at, to);
|
235
|
+
const offset = _offset;
|
236
|
+
at += offset;
|
237
|
+
if (to - at < length) {
|
238
|
+
throw new Error(`string len ${length} greater than remaining buf len.`);
|
239
|
+
}
|
240
|
+
const value = bytesToUtf8(payload, at, at + length);
|
241
|
+
_offset = offset + length;
|
242
|
+
return value;
|
243
|
+
}
|
244
|
+
function decodeUtf8StringIndefinite(at, to) {
|
245
|
+
at += 1;
|
246
|
+
const vector = [];
|
247
|
+
for (const base = at; at < to; ) {
|
248
|
+
if (payload[at] === 255) {
|
249
|
+
const data2 = alloc(vector.length);
|
250
|
+
data2.set(vector, 0);
|
251
|
+
_offset = at - base + 2;
|
252
|
+
return bytesToUtf8(data2, 0, data2.length);
|
253
|
+
}
|
254
|
+
const major = (payload[at] & 224) >> 5;
|
255
|
+
const minor = payload[at] & 31;
|
256
|
+
if (major !== majorUtf8String) {
|
257
|
+
throw new Error(`unexpected major type ${major} in indefinite string.`);
|
258
|
+
}
|
259
|
+
if (minor === minorIndefinite) {
|
260
|
+
throw new Error("nested indefinite string.");
|
261
|
+
}
|
262
|
+
const bytes = decodeUnstructuredByteString(at, to);
|
263
|
+
const length = _offset;
|
264
|
+
at += length;
|
265
|
+
for (let i = 0; i < bytes.length; ++i) {
|
266
|
+
vector.push(bytes[i]);
|
267
|
+
}
|
268
|
+
}
|
269
|
+
throw new Error("expected break marker.");
|
270
|
+
}
|
271
|
+
function decodeUnstructuredByteString(at, to) {
|
272
|
+
const length = decodeCount(at, to);
|
273
|
+
const offset = _offset;
|
274
|
+
at += offset;
|
275
|
+
if (to - at < length) {
|
276
|
+
throw new Error(`unstructured byte string len ${length} greater than remaining buf len.`);
|
277
|
+
}
|
278
|
+
const value = payload.subarray(at, at + length);
|
279
|
+
_offset = offset + length;
|
280
|
+
return value;
|
281
|
+
}
|
282
|
+
function decodeUnstructuredByteStringIndefinite(at, to) {
|
283
|
+
at += 1;
|
284
|
+
const vector = [];
|
285
|
+
for (const base = at; at < to; ) {
|
286
|
+
if (payload[at] === 255) {
|
287
|
+
const data2 = alloc(vector.length);
|
288
|
+
data2.set(vector, 0);
|
289
|
+
_offset = at - base + 2;
|
290
|
+
return data2;
|
291
|
+
}
|
292
|
+
const major = (payload[at] & 224) >> 5;
|
293
|
+
const minor = payload[at] & 31;
|
294
|
+
if (major !== majorUnstructuredByteString) {
|
295
|
+
throw new Error(`unexpected major type ${major} in indefinite string.`);
|
296
|
+
}
|
297
|
+
if (minor === minorIndefinite) {
|
298
|
+
throw new Error("nested indefinite string.");
|
299
|
+
}
|
300
|
+
const bytes = decodeUnstructuredByteString(at, to);
|
301
|
+
const length = _offset;
|
302
|
+
at += length;
|
303
|
+
for (let i = 0; i < bytes.length; ++i) {
|
304
|
+
vector.push(bytes[i]);
|
305
|
+
}
|
306
|
+
}
|
307
|
+
throw new Error("expected break marker.");
|
308
|
+
}
|
309
|
+
function decodeList(at, to) {
|
310
|
+
const listDataLength = decodeCount(at, to);
|
311
|
+
const offset = _offset;
|
312
|
+
at += offset;
|
313
|
+
const base = at;
|
314
|
+
const list = Array(listDataLength);
|
315
|
+
for (let i = 0; i < listDataLength; ++i) {
|
316
|
+
const item = decode(at, to);
|
317
|
+
const itemOffset = _offset;
|
318
|
+
list[i] = item;
|
319
|
+
at += itemOffset;
|
320
|
+
}
|
321
|
+
_offset = offset + (at - base);
|
322
|
+
return list;
|
323
|
+
}
|
324
|
+
function decodeListIndefinite(at, to) {
|
325
|
+
at += 1;
|
326
|
+
const list = [];
|
327
|
+
for (const base = at; at < to; ) {
|
328
|
+
if (payload[at] === 255) {
|
329
|
+
_offset = at - base + 2;
|
330
|
+
return list;
|
331
|
+
}
|
332
|
+
const item = decode(at, to);
|
333
|
+
const n = _offset;
|
334
|
+
at += n;
|
335
|
+
list.push(item);
|
336
|
+
}
|
337
|
+
throw new Error("expected break marker.");
|
338
|
+
}
|
339
|
+
function decodeMap(at, to) {
|
340
|
+
const mapDataLength = decodeCount(at, to);
|
341
|
+
const offset = _offset;
|
342
|
+
at += offset;
|
343
|
+
const base = at;
|
344
|
+
const map = {};
|
345
|
+
for (let i = 0; i < mapDataLength; ++i) {
|
346
|
+
if (at >= to) {
|
347
|
+
throw new Error("unexpected end of map payload.");
|
348
|
+
}
|
349
|
+
const major = (payload[at] & 224) >> 5;
|
350
|
+
if (major !== majorUtf8String) {
|
351
|
+
throw new Error(`unexpected major type ${major} for map key at index ${at}.`);
|
352
|
+
}
|
353
|
+
const key = decode(at, to);
|
354
|
+
at += _offset;
|
355
|
+
const value = decode(at, to);
|
356
|
+
at += _offset;
|
357
|
+
map[key] = value;
|
358
|
+
}
|
359
|
+
_offset = offset + (at - base);
|
360
|
+
return map;
|
361
|
+
}
|
362
|
+
function decodeMapIndefinite(at, to) {
|
363
|
+
at += 1;
|
364
|
+
const base = at;
|
365
|
+
const map = {};
|
366
|
+
for (; at < to; ) {
|
367
|
+
if (at >= to) {
|
368
|
+
throw new Error("unexpected end of map payload.");
|
369
|
+
}
|
370
|
+
if (payload[at] === 255) {
|
371
|
+
_offset = at - base + 2;
|
372
|
+
return map;
|
373
|
+
}
|
374
|
+
const major = (payload[at] & 224) >> 5;
|
375
|
+
if (major !== majorUtf8String) {
|
376
|
+
throw new Error(`unexpected major type ${major} for map key.`);
|
377
|
+
}
|
378
|
+
const key = decode(at, to);
|
379
|
+
at += _offset;
|
380
|
+
const value = decode(at, to);
|
381
|
+
at += _offset;
|
382
|
+
map[key] = value;
|
383
|
+
}
|
384
|
+
throw new Error("expected break marker.");
|
385
|
+
}
|
386
|
+
function decodeSpecial(at, to) {
|
387
|
+
const minor = payload[at] & 31;
|
388
|
+
switch (minor) {
|
389
|
+
case specialTrue:
|
390
|
+
case specialFalse:
|
391
|
+
_offset = 1;
|
392
|
+
return minor === specialTrue;
|
393
|
+
case specialNull:
|
394
|
+
_offset = 1;
|
395
|
+
return null;
|
396
|
+
case specialUndefined:
|
397
|
+
_offset = 1;
|
398
|
+
return null;
|
399
|
+
case extendedFloat16:
|
400
|
+
if (to - at < 3) {
|
401
|
+
throw new Error("incomplete float16 at end of buf.");
|
402
|
+
}
|
403
|
+
_offset = 3;
|
404
|
+
return bytesToFloat16(payload[at + 1], payload[at + 2]);
|
405
|
+
case extendedFloat32:
|
406
|
+
if (to - at < 5) {
|
407
|
+
throw new Error("incomplete float32 at end of buf.");
|
408
|
+
}
|
409
|
+
_offset = 5;
|
410
|
+
return dataView.getFloat32(at + 1);
|
411
|
+
case extendedFloat64:
|
412
|
+
if (to - at < 9) {
|
413
|
+
throw new Error("incomplete float64 at end of buf.");
|
414
|
+
}
|
415
|
+
_offset = 9;
|
416
|
+
return dataView.getFloat64(at + 1);
|
417
|
+
default:
|
418
|
+
throw new Error(`unexpected minor value ${minor}.`);
|
419
|
+
}
|
420
|
+
}
|
421
|
+
function castBigInt(bigInt) {
|
422
|
+
if (typeof bigInt === "number") {
|
423
|
+
return bigInt;
|
424
|
+
}
|
425
|
+
const num = Number(bigInt);
|
426
|
+
if (Number.MIN_SAFE_INTEGER <= num && num <= Number.MAX_SAFE_INTEGER) {
|
427
|
+
return num;
|
428
|
+
}
|
429
|
+
return bigInt;
|
430
|
+
}
|
431
|
+
|
432
|
+
// src/submodules/cbor/cbor-encode.ts
|
433
|
+
var import_util_utf82 = require("@smithy/util-utf8");
|
434
|
+
var USE_BUFFER2 = typeof Buffer !== "undefined";
|
435
|
+
var initialSize = 2048;
|
436
|
+
var data = alloc(initialSize);
|
437
|
+
var dataView2 = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
438
|
+
var cursor = 0;
|
439
|
+
function ensureSpace(bytes) {
|
440
|
+
const remaining = data.byteLength - cursor;
|
441
|
+
if (remaining < bytes) {
|
442
|
+
if (cursor < 16e6) {
|
443
|
+
resize(Math.max(data.byteLength * 4, data.byteLength + bytes));
|
444
|
+
} else {
|
445
|
+
resize(data.byteLength + bytes + 16e6);
|
446
|
+
}
|
447
|
+
}
|
448
|
+
}
|
449
|
+
function toUint8Array() {
|
450
|
+
const out = alloc(cursor);
|
451
|
+
out.set(data.subarray(0, cursor), 0);
|
452
|
+
cursor = 0;
|
453
|
+
return out;
|
454
|
+
}
|
455
|
+
function resize(size) {
|
456
|
+
const old = data;
|
457
|
+
data = alloc(size);
|
458
|
+
if (old) {
|
459
|
+
if (old.copy) {
|
460
|
+
old.copy(data, 0, 0, old.byteLength);
|
461
|
+
} else {
|
462
|
+
data.set(old, 0);
|
463
|
+
}
|
464
|
+
}
|
465
|
+
dataView2 = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
466
|
+
}
|
467
|
+
function encodeHeader(major, value) {
|
468
|
+
if (value < 24) {
|
469
|
+
data[cursor++] = major << 5 | value;
|
470
|
+
} else if (value < 1 << 8) {
|
471
|
+
data[cursor++] = major << 5 | 24;
|
472
|
+
data[cursor++] = value;
|
473
|
+
} else if (value < 1 << 16) {
|
474
|
+
data[cursor++] = major << 5 | extendedFloat16;
|
475
|
+
dataView2.setUint16(cursor, value);
|
476
|
+
cursor += 2;
|
477
|
+
} else if (value < 2 ** 32) {
|
478
|
+
data[cursor++] = major << 5 | extendedFloat32;
|
479
|
+
dataView2.setUint32(cursor, value);
|
480
|
+
cursor += 4;
|
481
|
+
} else {
|
482
|
+
data[cursor++] = major << 5 | extendedFloat64;
|
483
|
+
dataView2.setBigUint64(cursor, typeof value === "bigint" ? value : BigInt(value));
|
484
|
+
cursor += 8;
|
485
|
+
}
|
486
|
+
}
|
487
|
+
function encode(_input) {
|
488
|
+
var _a;
|
489
|
+
const encodeStack = [_input];
|
490
|
+
while (encodeStack.length) {
|
491
|
+
const input = encodeStack.pop();
|
492
|
+
ensureSpace(typeof input === "string" ? input.length * 4 : 64);
|
493
|
+
if (typeof input === "string") {
|
494
|
+
if (USE_BUFFER2) {
|
495
|
+
encodeHeader(majorUtf8String, Buffer.byteLength(input));
|
496
|
+
cursor += data.write(input, cursor);
|
497
|
+
} else {
|
498
|
+
const bytes = (0, import_util_utf82.fromUtf8)(input);
|
499
|
+
encodeHeader(majorUtf8String, bytes.byteLength);
|
500
|
+
data.set(bytes, cursor);
|
501
|
+
cursor += bytes.byteLength;
|
502
|
+
}
|
503
|
+
continue;
|
504
|
+
} else if (typeof input === "number") {
|
505
|
+
if (Number.isInteger(input)) {
|
506
|
+
const nonNegative = input >= 0;
|
507
|
+
const major = nonNegative ? majorUint64 : majorNegativeInt64;
|
508
|
+
const value = nonNegative ? input : -input - 1;
|
509
|
+
if (value < 24) {
|
510
|
+
data[cursor++] = major << 5 | value;
|
511
|
+
} else if (value < 256) {
|
512
|
+
data[cursor++] = major << 5 | 24;
|
513
|
+
data[cursor++] = value;
|
514
|
+
} else if (value < 65536) {
|
515
|
+
data[cursor++] = major << 5 | extendedFloat16;
|
516
|
+
data[cursor++] = value >> 8;
|
517
|
+
data[cursor++] = value;
|
518
|
+
} else if (value < 4294967296) {
|
519
|
+
data[cursor++] = major << 5 | extendedFloat32;
|
520
|
+
dataView2.setUint32(cursor, value);
|
521
|
+
cursor += 4;
|
522
|
+
} else {
|
523
|
+
data[cursor++] = major << 5 | extendedFloat64;
|
524
|
+
dataView2.setBigUint64(cursor, BigInt(value));
|
525
|
+
cursor += 8;
|
526
|
+
}
|
527
|
+
continue;
|
528
|
+
}
|
529
|
+
data[cursor++] = majorSpecial << 5 | extendedFloat64;
|
530
|
+
dataView2.setFloat64(cursor, input);
|
531
|
+
cursor += 8;
|
532
|
+
continue;
|
533
|
+
} else if (typeof input === "bigint") {
|
534
|
+
const nonNegative = input >= 0;
|
535
|
+
const major = nonNegative ? majorUint64 : majorNegativeInt64;
|
536
|
+
const value = nonNegative ? input : -input - BigInt(1);
|
537
|
+
const n = Number(value);
|
538
|
+
if (n < 24) {
|
539
|
+
data[cursor++] = major << 5 | n;
|
540
|
+
} else if (n < 256) {
|
541
|
+
data[cursor++] = major << 5 | 24;
|
542
|
+
data[cursor++] = n;
|
543
|
+
} else if (n < 65536) {
|
544
|
+
data[cursor++] = major << 5 | extendedFloat16;
|
545
|
+
data[cursor++] = n >> 8;
|
546
|
+
data[cursor++] = n & 255;
|
547
|
+
} else if (n < 4294967296) {
|
548
|
+
data[cursor++] = major << 5 | extendedFloat32;
|
549
|
+
dataView2.setUint32(cursor, n);
|
550
|
+
cursor += 4;
|
551
|
+
} else {
|
552
|
+
data[cursor++] = major << 5 | extendedFloat64;
|
553
|
+
dataView2.setBigUint64(cursor, value);
|
554
|
+
cursor += 8;
|
555
|
+
}
|
556
|
+
continue;
|
557
|
+
} else if (input === null) {
|
558
|
+
data[cursor++] = majorSpecial << 5 | specialNull;
|
559
|
+
continue;
|
560
|
+
} else if (typeof input === "boolean") {
|
561
|
+
data[cursor++] = majorSpecial << 5 | (input ? specialTrue : specialFalse);
|
562
|
+
continue;
|
563
|
+
} else if (typeof input === "undefined") {
|
564
|
+
throw new Error("@smithy/core/cbor: client may not serialize undefined value.");
|
565
|
+
} else if (Array.isArray(input)) {
|
566
|
+
for (let i = input.length - 1; i >= 0; --i) {
|
567
|
+
encodeStack.push(input[i]);
|
568
|
+
}
|
569
|
+
encodeHeader(majorList, input.length);
|
570
|
+
continue;
|
571
|
+
} else if (typeof input.byteLength === "number") {
|
572
|
+
ensureSpace(input.length * 2);
|
573
|
+
encodeHeader(majorUnstructuredByteString, input.length);
|
574
|
+
data.set(input, cursor);
|
575
|
+
cursor += input.byteLength;
|
576
|
+
continue;
|
577
|
+
} else if (typeof input === "object") {
|
578
|
+
const keys = Object.keys(input);
|
579
|
+
for (let i = keys.length - 1; i >= 0; --i) {
|
580
|
+
const key = keys[i];
|
581
|
+
encodeStack.push(input[key]);
|
582
|
+
encodeStack.push(key);
|
583
|
+
}
|
584
|
+
encodeHeader(majorMap, keys.length);
|
585
|
+
continue;
|
586
|
+
}
|
587
|
+
throw new Error(`data type ${((_a = input == null ? void 0 : input.constructor) == null ? void 0 : _a.name) ?? typeof input} not compatible for encoding.`);
|
588
|
+
}
|
589
|
+
}
|
590
|
+
|
591
|
+
// src/submodules/cbor/cbor.ts
|
592
|
+
var cbor = {
|
593
|
+
deserialize(payload2) {
|
594
|
+
setPayload(payload2);
|
595
|
+
return decode(0, payload2.length);
|
596
|
+
},
|
597
|
+
serialize(input) {
|
598
|
+
encode(input);
|
599
|
+
return toUint8Array();
|
600
|
+
},
|
601
|
+
/**
|
602
|
+
* @public
|
603
|
+
* @param size - byte length to allocate.
|
604
|
+
*
|
605
|
+
* This may be used to garbage collect the CBOR
|
606
|
+
* shared encoding buffer space,
|
607
|
+
* e.g. resizeEncodingBuffer(0);
|
608
|
+
*
|
609
|
+
* This may also be used to pre-allocate more space for
|
610
|
+
* CBOR encoding, e.g. resizeEncodingBuffer(100_000_000);
|
611
|
+
*/
|
612
|
+
resizeEncodingBuffer(size) {
|
613
|
+
resize(size);
|
614
|
+
}
|
615
|
+
};
|
616
|
+
|
617
|
+
// src/submodules/cbor/parseCborBody.ts
|
618
|
+
var import_protocol_http = require("@smithy/protocol-http");
|
619
|
+
var import_smithy_client = require("@smithy/smithy-client");
|
620
|
+
var import_util_body_length_browser = require("@smithy/util-body-length-browser");
|
621
|
+
var parseCborBody = (streamBody, context) => {
|
622
|
+
return (0, import_smithy_client.collectBody)(streamBody, context).then(async (bytes) => {
|
623
|
+
if (bytes.length) {
|
624
|
+
try {
|
625
|
+
return cbor.deserialize(bytes);
|
626
|
+
} catch (e) {
|
627
|
+
Object.defineProperty(e, "$responseBodyText", {
|
628
|
+
value: context.utf8Encoder(bytes)
|
629
|
+
});
|
630
|
+
throw e;
|
631
|
+
}
|
632
|
+
}
|
633
|
+
return {};
|
634
|
+
});
|
635
|
+
};
|
636
|
+
var dateToTag = (date) => {
|
637
|
+
return {
|
638
|
+
tag: 1,
|
639
|
+
value: date.getTime() / 1e3
|
640
|
+
};
|
641
|
+
};
|
642
|
+
var parseCborErrorBody = async (errorBody, context) => {
|
643
|
+
const value = await parseCborBody(errorBody, context);
|
644
|
+
value.message = value.message ?? value.Message;
|
645
|
+
return value;
|
646
|
+
};
|
647
|
+
var loadSmithyRpcV2CborErrorCode = (output, data2) => {
|
648
|
+
const sanitizeErrorCode = (rawValue) => {
|
649
|
+
let cleanValue = rawValue;
|
650
|
+
if (typeof cleanValue === "number") {
|
651
|
+
cleanValue = cleanValue.toString();
|
652
|
+
}
|
653
|
+
if (cleanValue.indexOf(",") >= 0) {
|
654
|
+
cleanValue = cleanValue.split(",")[0];
|
655
|
+
}
|
656
|
+
if (cleanValue.indexOf(":") >= 0) {
|
657
|
+
cleanValue = cleanValue.split(":")[0];
|
658
|
+
}
|
659
|
+
if (cleanValue.indexOf("#") >= 0) {
|
660
|
+
cleanValue = cleanValue.split("#")[1];
|
661
|
+
}
|
662
|
+
return cleanValue;
|
663
|
+
};
|
664
|
+
if (data2["__type"] !== void 0) {
|
665
|
+
return sanitizeErrorCode(data2["__type"]);
|
666
|
+
}
|
667
|
+
if (data2.code !== void 0) {
|
668
|
+
return sanitizeErrorCode(data2.code);
|
669
|
+
}
|
670
|
+
};
|
671
|
+
var checkCborResponse = (response) => {
|
672
|
+
if (String(response.headers["smithy-protocol"]).toLowerCase() !== "rpc-v2-cbor") {
|
673
|
+
throw new Error("Malformed RPCv2 CBOR response, status: " + response.statusCode);
|
674
|
+
}
|
675
|
+
};
|
676
|
+
var buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
|
677
|
+
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
|
678
|
+
const contents = {
|
679
|
+
protocol,
|
680
|
+
hostname,
|
681
|
+
port,
|
682
|
+
method: "POST",
|
683
|
+
path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
|
684
|
+
headers
|
685
|
+
};
|
686
|
+
if (resolvedHostname !== void 0) {
|
687
|
+
contents.hostname = resolvedHostname;
|
688
|
+
}
|
689
|
+
if (body !== void 0) {
|
690
|
+
contents.body = body;
|
691
|
+
try {
|
692
|
+
contents.headers["content-length"] = String((0, import_util_body_length_browser.calculateBodyLength)(body));
|
693
|
+
} catch (e) {
|
694
|
+
}
|
695
|
+
}
|
696
|
+
return new import_protocol_http.HttpRequest(contents);
|
697
|
+
};
|
698
|
+
// Annotate the CommonJS export names for ESM import in node:
|
699
|
+
0 && (module.exports = {
|
700
|
+
buildHttpRpcRequest,
|
701
|
+
cbor,
|
702
|
+
checkCborResponse,
|
703
|
+
dateToTag,
|
704
|
+
loadSmithyRpcV2CborErrorCode,
|
705
|
+
parseCborBody,
|
706
|
+
parseCborErrorBody
|
707
|
+
});
|