@smithy/core 3.24.1 → 3.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/submodules/cbor/index.js +1 -1
- package/dist-cjs/submodules/serde/index.browser.js +126 -174
- package/dist-cjs/submodules/serde/index.js +181 -85
- package/dist-cjs/submodules/serde/index.native.js +126 -174
- package/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +1 -1
- package/dist-es/submodules/serde/index.browser.js +12 -7
- package/dist-es/submodules/serde/index.js +9 -5
- package/dist-es/submodules/serde/index.native.js +10 -3
- package/dist-es/submodules/serde/util-base64/toBase64.browser.js +1 -1
- package/dist-es/submodules/serde/util-stream/blob/Uint8ArrayBlobAdapter.js +19 -21
- package/dist-es/submodules/serde/util-stream/checksum/createChecksumStream.browser.js +1 -1
- package/dist-es/submodules/serde/util-stream/sdk-stream-mixin.browser.js +2 -2
- package/dist-es/submodules/serde/util-stream/stream-collector.browser.js +1 -1
- package/dist-es/submodules/serde/util-utf8/toUint8Array.browser.js +10 -0
- package/dist-types/submodules/serde/index.browser.d.ts +13 -7
- package/dist-types/submodules/serde/index.d.ts +9 -5
- package/dist-types/submodules/serde/index.native.d.ts +7 -3
- package/dist-types/submodules/serde/util-stream/blob/Uint8ArrayBlobAdapter.d.ts +8 -12
- package/dist-types/submodules/serde/util-utf8/toUint8Array.browser.d.ts +4 -0
- package/package.json +1 -1
|
@@ -6,6 +6,87 @@ var protocols = require('@smithy/core/protocols');
|
|
|
6
6
|
var endpoints = require('@smithy/core/endpoints');
|
|
7
7
|
var node_stream = require('node:stream');
|
|
8
8
|
|
|
9
|
+
const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) ||
|
|
10
|
+
Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
11
|
+
|
|
12
|
+
const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => {
|
|
13
|
+
if (!isArrayBuffer(input)) {
|
|
14
|
+
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
|
|
15
|
+
}
|
|
16
|
+
return Buffer.from(input, offset, length);
|
|
17
|
+
};
|
|
18
|
+
const fromString = (input, encoding) => {
|
|
19
|
+
if (typeof input !== "string") {
|
|
20
|
+
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
|
21
|
+
}
|
|
22
|
+
return encoding ? Buffer.from(input, encoding) : Buffer.from(input);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
26
|
+
const fromBase64$1 = (input) => {
|
|
27
|
+
if ((input.length * 3) % 4 !== 0) {
|
|
28
|
+
throw new TypeError(`Incorrect padding on base64 string.`);
|
|
29
|
+
}
|
|
30
|
+
if (!BASE64_REGEX.exec(input)) {
|
|
31
|
+
throw new TypeError(`Invalid base64 string.`);
|
|
32
|
+
}
|
|
33
|
+
const buffer = fromString(input, "base64");
|
|
34
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const fromUtf8$1 = (input) => {
|
|
38
|
+
const buf = fromString(input, "utf8");
|
|
39
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const toBase64$1 = (_input) => {
|
|
43
|
+
let input;
|
|
44
|
+
if (typeof _input === "string") {
|
|
45
|
+
input = fromUtf8$1(_input);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
input = _input;
|
|
49
|
+
}
|
|
50
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
51
|
+
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
52
|
+
}
|
|
53
|
+
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) {
|
|
57
|
+
return class Uint8ArrayBlobAdapter extends Uint8Array {
|
|
58
|
+
static fromString(source, encoding = "utf-8") {
|
|
59
|
+
if (typeof source === "string") {
|
|
60
|
+
if (encoding === "base64") {
|
|
61
|
+
return Uint8ArrayBlobAdapter.mutate(fromBase64(source));
|
|
62
|
+
}
|
|
63
|
+
return Uint8ArrayBlobAdapter.mutate(fromUtf8(source));
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
|
|
66
|
+
}
|
|
67
|
+
static mutate(source) {
|
|
68
|
+
Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype);
|
|
69
|
+
return source;
|
|
70
|
+
}
|
|
71
|
+
transformToString(encoding = "utf-8") {
|
|
72
|
+
if (encoding === "base64") {
|
|
73
|
+
return toBase64(this);
|
|
74
|
+
}
|
|
75
|
+
return toUtf8(this);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const toUtf8$1 = (input) => {
|
|
81
|
+
if (typeof input === "string") {
|
|
82
|
+
return input;
|
|
83
|
+
}
|
|
84
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
85
|
+
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
86
|
+
}
|
|
87
|
+
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8");
|
|
88
|
+
};
|
|
89
|
+
|
|
9
90
|
const decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
10
91
|
function bindV4(getRandomValues) {
|
|
11
92
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -724,53 +805,6 @@ function toHex(bytes) {
|
|
|
724
805
|
return out;
|
|
725
806
|
}
|
|
726
807
|
|
|
727
|
-
const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) ||
|
|
728
|
-
Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
729
|
-
|
|
730
|
-
const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => {
|
|
731
|
-
if (!isArrayBuffer(input)) {
|
|
732
|
-
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
|
|
733
|
-
}
|
|
734
|
-
return Buffer.from(input, offset, length);
|
|
735
|
-
};
|
|
736
|
-
const fromString = (input, encoding) => {
|
|
737
|
-
if (typeof input !== "string") {
|
|
738
|
-
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
|
739
|
-
}
|
|
740
|
-
return encoding ? Buffer.from(input, encoding) : Buffer.from(input);
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
744
|
-
const fromBase64 = (input) => {
|
|
745
|
-
if ((input.length * 3) % 4 !== 0) {
|
|
746
|
-
throw new TypeError(`Incorrect padding on base64 string.`);
|
|
747
|
-
}
|
|
748
|
-
if (!BASE64_REGEX.exec(input)) {
|
|
749
|
-
throw new TypeError(`Invalid base64 string.`);
|
|
750
|
-
}
|
|
751
|
-
const buffer = fromString(input, "base64");
|
|
752
|
-
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
753
|
-
};
|
|
754
|
-
|
|
755
|
-
const fromUtf8 = (input) => {
|
|
756
|
-
const buf = fromString(input, "utf8");
|
|
757
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
758
|
-
};
|
|
759
|
-
|
|
760
|
-
const toBase64 = (_input) => {
|
|
761
|
-
let input;
|
|
762
|
-
if (typeof _input === "string") {
|
|
763
|
-
input = fromUtf8(_input);
|
|
764
|
-
}
|
|
765
|
-
else {
|
|
766
|
-
input = _input;
|
|
767
|
-
}
|
|
768
|
-
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
769
|
-
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
770
|
-
}
|
|
771
|
-
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
|
772
|
-
};
|
|
773
|
-
|
|
774
808
|
const calculateBodyLength = (body) => {
|
|
775
809
|
if (!body) {
|
|
776
810
|
return 0;
|
|
@@ -800,7 +834,7 @@ const calculateBodyLength = (body) => {
|
|
|
800
834
|
|
|
801
835
|
const toUint8Array = (data) => {
|
|
802
836
|
if (typeof data === "string") {
|
|
803
|
-
return fromUtf8(data);
|
|
837
|
+
return fromUtf8$1(data);
|
|
804
838
|
}
|
|
805
839
|
if (ArrayBuffer.isView(data)) {
|
|
806
840
|
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
@@ -808,16 +842,6 @@ const toUint8Array = (data) => {
|
|
|
808
842
|
return new Uint8Array(data);
|
|
809
843
|
};
|
|
810
844
|
|
|
811
|
-
const toUtf8 = (input) => {
|
|
812
|
-
if (typeof input === "string") {
|
|
813
|
-
return input;
|
|
814
|
-
}
|
|
815
|
-
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
816
|
-
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
817
|
-
}
|
|
818
|
-
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8");
|
|
819
|
-
};
|
|
820
|
-
|
|
821
845
|
const deserializerMiddleware = (options, deserializer) => (next, context) => async (args) => {
|
|
822
846
|
const { response } = await next(args);
|
|
823
847
|
try {
|
|
@@ -946,28 +970,6 @@ function castSourceData(toCast, encoding) {
|
|
|
946
970
|
return fromArrayBuffer(toCast);
|
|
947
971
|
}
|
|
948
972
|
|
|
949
|
-
class Uint8ArrayBlobAdapter extends Uint8Array {
|
|
950
|
-
static fromString(source, encoding = "utf-8") {
|
|
951
|
-
if (typeof source === "string") {
|
|
952
|
-
if (encoding === "base64") {
|
|
953
|
-
return Uint8ArrayBlobAdapter.mutate(fromBase64(source));
|
|
954
|
-
}
|
|
955
|
-
return Uint8ArrayBlobAdapter.mutate(fromUtf8(source));
|
|
956
|
-
}
|
|
957
|
-
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
|
|
958
|
-
}
|
|
959
|
-
static mutate(source) {
|
|
960
|
-
Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype);
|
|
961
|
-
return source;
|
|
962
|
-
}
|
|
963
|
-
transformToString(encoding = "utf-8") {
|
|
964
|
-
if (encoding === "base64") {
|
|
965
|
-
return toBase64(this);
|
|
966
|
-
}
|
|
967
|
-
return toUtf8(this);
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
|
|
971
973
|
let ChecksumStream$1 = class ChecksumStream extends node_stream.Duplex {
|
|
972
974
|
expectedChecksum;
|
|
973
975
|
checksumSourceLocation;
|
|
@@ -983,7 +985,7 @@ let ChecksumStream$1 = class ChecksumStream extends node_stream.Duplex {
|
|
|
983
985
|
else {
|
|
984
986
|
throw new Error(`@smithy/util-stream: unsupported source type ${source?.constructor?.name ?? source} in ChecksumStream.`);
|
|
985
987
|
}
|
|
986
|
-
this.base64Encoder = base64Encoder ?? toBase64;
|
|
988
|
+
this.base64Encoder = base64Encoder ?? toBase64$1;
|
|
987
989
|
this.expectedChecksum = expectedChecksum;
|
|
988
990
|
this.checksum = checksum;
|
|
989
991
|
this.checksumSourceLocation = checksumSourceLocation;
|
|
@@ -1033,6 +1035,52 @@ const isBlob = (blob) => {
|
|
|
1033
1035
|
return typeof Blob === "function" && (blob?.constructor?.name === Blob.name || blob instanceof Blob);
|
|
1034
1036
|
};
|
|
1035
1037
|
|
|
1038
|
+
const fromUtf8 = (input) => new TextEncoder().encode(input);
|
|
1039
|
+
|
|
1040
|
+
const chars = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;
|
|
1041
|
+
const alphabetByEncoding = Object.entries(chars).reduce((acc, [i, c]) => {
|
|
1042
|
+
acc[c] = Number(i);
|
|
1043
|
+
return acc;
|
|
1044
|
+
}, {});
|
|
1045
|
+
const alphabetByValue = chars.split("");
|
|
1046
|
+
const bitsPerLetter = 6;
|
|
1047
|
+
const bitsPerByte = 8;
|
|
1048
|
+
const maxLetterValue = 0b111111;
|
|
1049
|
+
|
|
1050
|
+
function toBase64(_input) {
|
|
1051
|
+
let input;
|
|
1052
|
+
if (typeof _input === "string") {
|
|
1053
|
+
input = fromUtf8(_input);
|
|
1054
|
+
}
|
|
1055
|
+
else {
|
|
1056
|
+
input = _input;
|
|
1057
|
+
}
|
|
1058
|
+
const isArrayLike = typeof input === "object" && typeof input.length === "number";
|
|
1059
|
+
const isUint8Array = typeof input === "object" &&
|
|
1060
|
+
typeof input.byteOffset === "number" &&
|
|
1061
|
+
typeof input.byteLength === "number";
|
|
1062
|
+
if (!isArrayLike && !isUint8Array) {
|
|
1063
|
+
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
1064
|
+
}
|
|
1065
|
+
let str = "";
|
|
1066
|
+
for (let i = 0; i < input.length; i += 3) {
|
|
1067
|
+
let bits = 0;
|
|
1068
|
+
let bitLength = 0;
|
|
1069
|
+
for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) {
|
|
1070
|
+
bits |= input[j] << ((limit - j - 1) * bitsPerByte);
|
|
1071
|
+
bitLength += bitsPerByte;
|
|
1072
|
+
}
|
|
1073
|
+
const bitClusterCount = Math.ceil(bitLength / bitsPerLetter);
|
|
1074
|
+
bits <<= bitClusterCount * bitsPerLetter - bitLength;
|
|
1075
|
+
for (let k = 1; k <= bitClusterCount; k++) {
|
|
1076
|
+
const offset = (bitClusterCount - k) * bitsPerLetter;
|
|
1077
|
+
str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset];
|
|
1078
|
+
}
|
|
1079
|
+
str += "==".slice(0, 4 - bitClusterCount);
|
|
1080
|
+
}
|
|
1081
|
+
return str;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1036
1084
|
const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function () { };
|
|
1037
1085
|
class ChecksumStream extends ReadableStreamRef {
|
|
1038
1086
|
}
|
|
@@ -1390,6 +1438,52 @@ let Collector$1 = class Collector extends node_stream.Writable {
|
|
|
1390
1438
|
}
|
|
1391
1439
|
};
|
|
1392
1440
|
|
|
1441
|
+
const toUtf8 = (input) => {
|
|
1442
|
+
if (typeof input === "string") {
|
|
1443
|
+
return input;
|
|
1444
|
+
}
|
|
1445
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
1446
|
+
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
1447
|
+
}
|
|
1448
|
+
return new TextDecoder("utf-8").decode(input);
|
|
1449
|
+
};
|
|
1450
|
+
|
|
1451
|
+
const fromBase64 = (input) => {
|
|
1452
|
+
let totalByteLength = (input.length / 4) * 3;
|
|
1453
|
+
if (input.slice(-2) === "==") {
|
|
1454
|
+
totalByteLength -= 2;
|
|
1455
|
+
}
|
|
1456
|
+
else if (input.slice(-1) === "=") {
|
|
1457
|
+
totalByteLength--;
|
|
1458
|
+
}
|
|
1459
|
+
const out = new ArrayBuffer(totalByteLength);
|
|
1460
|
+
const dataView = new DataView(out);
|
|
1461
|
+
for (let i = 0; i < input.length; i += 4) {
|
|
1462
|
+
let bits = 0;
|
|
1463
|
+
let bitLength = 0;
|
|
1464
|
+
for (let j = i, limit = i + 3; j <= limit; j++) {
|
|
1465
|
+
if (input[j] !== "=") {
|
|
1466
|
+
if (!(input[j] in alphabetByEncoding)) {
|
|
1467
|
+
throw new TypeError(`Invalid character ${input[j]} in base64 string.`);
|
|
1468
|
+
}
|
|
1469
|
+
bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter);
|
|
1470
|
+
bitLength += bitsPerLetter;
|
|
1471
|
+
}
|
|
1472
|
+
else {
|
|
1473
|
+
bits >>= bitsPerLetter;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
const chunkOffset = (i / 4) * 3;
|
|
1477
|
+
bits >>= bitLength % bitsPerByte;
|
|
1478
|
+
const byteLength = Math.floor(bitLength / bitsPerByte);
|
|
1479
|
+
for (let k = 0; k < byteLength; k++) {
|
|
1480
|
+
const offset = (byteLength - k - 1) * bitsPerByte;
|
|
1481
|
+
dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
return new Uint8Array(out);
|
|
1485
|
+
};
|
|
1486
|
+
|
|
1393
1487
|
const streamCollector$1 = async (stream) => {
|
|
1394
1488
|
if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") {
|
|
1395
1489
|
if (Blob.prototype.arrayBuffer !== undefined) {
|
|
@@ -1617,6 +1711,8 @@ async function splitStream(stream) {
|
|
|
1617
1711
|
return [stream1, stream2];
|
|
1618
1712
|
}
|
|
1619
1713
|
|
|
1714
|
+
class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8$1, fromUtf8$1, toBase64$1, fromBase64$1) {
|
|
1715
|
+
}
|
|
1620
1716
|
const _getRandomValues = node_crypto.getRandomValues;
|
|
1621
1717
|
const v4 = bindV4(_getRandomValues);
|
|
1622
1718
|
const generateIdempotencyToken = v4;
|
|
@@ -1649,10 +1745,10 @@ exports.expectShort = expectShort;
|
|
|
1649
1745
|
exports.expectString = expectString;
|
|
1650
1746
|
exports.expectUnion = expectUnion;
|
|
1651
1747
|
exports.fromArrayBuffer = fromArrayBuffer;
|
|
1652
|
-
exports.fromBase64 = fromBase64;
|
|
1748
|
+
exports.fromBase64 = fromBase64$1;
|
|
1653
1749
|
exports.fromHex = fromHex;
|
|
1654
1750
|
exports.fromString = fromString;
|
|
1655
|
-
exports.fromUtf8 = fromUtf8;
|
|
1751
|
+
exports.fromUtf8 = fromUtf8$1;
|
|
1656
1752
|
exports.generateIdempotencyToken = generateIdempotencyToken;
|
|
1657
1753
|
exports.getAwsChunkedEncodingStream = getAwsChunkedEncodingStream;
|
|
1658
1754
|
exports.getSerdePlugin = getSerdePlugin;
|
|
@@ -1686,8 +1782,8 @@ exports.strictParseInt = strictParseInt;
|
|
|
1686
1782
|
exports.strictParseInt32 = strictParseInt32;
|
|
1687
1783
|
exports.strictParseLong = strictParseLong;
|
|
1688
1784
|
exports.strictParseShort = strictParseShort;
|
|
1689
|
-
exports.toBase64 = toBase64;
|
|
1785
|
+
exports.toBase64 = toBase64$1;
|
|
1690
1786
|
exports.toHex = toHex;
|
|
1691
1787
|
exports.toUint8Array = toUint8Array;
|
|
1692
|
-
exports.toUtf8 = toUtf8;
|
|
1788
|
+
exports.toUtf8 = toUtf8$1;
|
|
1693
1789
|
exports.v4 = v4;
|
|
@@ -3,6 +3,122 @@
|
|
|
3
3
|
var protocols = require('@smithy/core/protocols');
|
|
4
4
|
var endpoints = require('@smithy/core/endpoints');
|
|
5
5
|
|
|
6
|
+
const chars = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;
|
|
7
|
+
const alphabetByEncoding = Object.entries(chars).reduce((acc, [i, c]) => {
|
|
8
|
+
acc[c] = Number(i);
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
const alphabetByValue = chars.split("");
|
|
12
|
+
const bitsPerLetter = 6;
|
|
13
|
+
const bitsPerByte = 8;
|
|
14
|
+
const maxLetterValue = 0b111111;
|
|
15
|
+
|
|
16
|
+
const fromBase64 = (input) => {
|
|
17
|
+
let totalByteLength = (input.length / 4) * 3;
|
|
18
|
+
if (input.slice(-2) === "==") {
|
|
19
|
+
totalByteLength -= 2;
|
|
20
|
+
}
|
|
21
|
+
else if (input.slice(-1) === "=") {
|
|
22
|
+
totalByteLength--;
|
|
23
|
+
}
|
|
24
|
+
const out = new ArrayBuffer(totalByteLength);
|
|
25
|
+
const dataView = new DataView(out);
|
|
26
|
+
for (let i = 0; i < input.length; i += 4) {
|
|
27
|
+
let bits = 0;
|
|
28
|
+
let bitLength = 0;
|
|
29
|
+
for (let j = i, limit = i + 3; j <= limit; j++) {
|
|
30
|
+
if (input[j] !== "=") {
|
|
31
|
+
if (!(input[j] in alphabetByEncoding)) {
|
|
32
|
+
throw new TypeError(`Invalid character ${input[j]} in base64 string.`);
|
|
33
|
+
}
|
|
34
|
+
bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter);
|
|
35
|
+
bitLength += bitsPerLetter;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
bits >>= bitsPerLetter;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const chunkOffset = (i / 4) * 3;
|
|
42
|
+
bits >>= bitLength % bitsPerByte;
|
|
43
|
+
const byteLength = Math.floor(bitLength / bitsPerByte);
|
|
44
|
+
for (let k = 0; k < byteLength; k++) {
|
|
45
|
+
const offset = (byteLength - k - 1) * bitsPerByte;
|
|
46
|
+
dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return new Uint8Array(out);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const fromUtf8 = (input) => new TextEncoder().encode(input);
|
|
53
|
+
|
|
54
|
+
function toBase64(_input) {
|
|
55
|
+
let input;
|
|
56
|
+
if (typeof _input === "string") {
|
|
57
|
+
input = fromUtf8(_input);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
input = _input;
|
|
61
|
+
}
|
|
62
|
+
const isArrayLike = typeof input === "object" && typeof input.length === "number";
|
|
63
|
+
const isUint8Array = typeof input === "object" &&
|
|
64
|
+
typeof input.byteOffset === "number" &&
|
|
65
|
+
typeof input.byteLength === "number";
|
|
66
|
+
if (!isArrayLike && !isUint8Array) {
|
|
67
|
+
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
68
|
+
}
|
|
69
|
+
let str = "";
|
|
70
|
+
for (let i = 0; i < input.length; i += 3) {
|
|
71
|
+
let bits = 0;
|
|
72
|
+
let bitLength = 0;
|
|
73
|
+
for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) {
|
|
74
|
+
bits |= input[j] << ((limit - j - 1) * bitsPerByte);
|
|
75
|
+
bitLength += bitsPerByte;
|
|
76
|
+
}
|
|
77
|
+
const bitClusterCount = Math.ceil(bitLength / bitsPerLetter);
|
|
78
|
+
bits <<= bitClusterCount * bitsPerLetter - bitLength;
|
|
79
|
+
for (let k = 1; k <= bitClusterCount; k++) {
|
|
80
|
+
const offset = (bitClusterCount - k) * bitsPerLetter;
|
|
81
|
+
str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset];
|
|
82
|
+
}
|
|
83
|
+
str += "==".slice(0, 4 - bitClusterCount);
|
|
84
|
+
}
|
|
85
|
+
return str;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) {
|
|
89
|
+
return class Uint8ArrayBlobAdapter extends Uint8Array {
|
|
90
|
+
static fromString(source, encoding = "utf-8") {
|
|
91
|
+
if (typeof source === "string") {
|
|
92
|
+
if (encoding === "base64") {
|
|
93
|
+
return Uint8ArrayBlobAdapter.mutate(fromBase64(source));
|
|
94
|
+
}
|
|
95
|
+
return Uint8ArrayBlobAdapter.mutate(fromUtf8(source));
|
|
96
|
+
}
|
|
97
|
+
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
|
|
98
|
+
}
|
|
99
|
+
static mutate(source) {
|
|
100
|
+
Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype);
|
|
101
|
+
return source;
|
|
102
|
+
}
|
|
103
|
+
transformToString(encoding = "utf-8") {
|
|
104
|
+
if (encoding === "base64") {
|
|
105
|
+
return toBase64(this);
|
|
106
|
+
}
|
|
107
|
+
return toUtf8(this);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const toUtf8 = (input) => {
|
|
113
|
+
if (typeof input === "string") {
|
|
114
|
+
return input;
|
|
115
|
+
}
|
|
116
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
117
|
+
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
118
|
+
}
|
|
119
|
+
return new TextDecoder("utf-8").decode(input);
|
|
120
|
+
};
|
|
121
|
+
|
|
6
122
|
const decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
7
123
|
function bindV4(getRandomValues) {
|
|
8
124
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -721,107 +837,6 @@ function toHex(bytes) {
|
|
|
721
837
|
return out;
|
|
722
838
|
}
|
|
723
839
|
|
|
724
|
-
const chars = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;
|
|
725
|
-
const alphabetByEncoding = Object.entries(chars).reduce((acc, [i, c]) => {
|
|
726
|
-
acc[c] = Number(i);
|
|
727
|
-
return acc;
|
|
728
|
-
}, {});
|
|
729
|
-
const alphabetByValue = chars.split("");
|
|
730
|
-
const bitsPerLetter = 6;
|
|
731
|
-
const bitsPerByte = 8;
|
|
732
|
-
const maxLetterValue = 0b111111;
|
|
733
|
-
|
|
734
|
-
const fromBase64$1 = (input) => {
|
|
735
|
-
let totalByteLength = (input.length / 4) * 3;
|
|
736
|
-
if (input.slice(-2) === "==") {
|
|
737
|
-
totalByteLength -= 2;
|
|
738
|
-
}
|
|
739
|
-
else if (input.slice(-1) === "=") {
|
|
740
|
-
totalByteLength--;
|
|
741
|
-
}
|
|
742
|
-
const out = new ArrayBuffer(totalByteLength);
|
|
743
|
-
const dataView = new DataView(out);
|
|
744
|
-
for (let i = 0; i < input.length; i += 4) {
|
|
745
|
-
let bits = 0;
|
|
746
|
-
let bitLength = 0;
|
|
747
|
-
for (let j = i, limit = i + 3; j <= limit; j++) {
|
|
748
|
-
if (input[j] !== "=") {
|
|
749
|
-
if (!(input[j] in alphabetByEncoding)) {
|
|
750
|
-
throw new TypeError(`Invalid character ${input[j]} in base64 string.`);
|
|
751
|
-
}
|
|
752
|
-
bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter);
|
|
753
|
-
bitLength += bitsPerLetter;
|
|
754
|
-
}
|
|
755
|
-
else {
|
|
756
|
-
bits >>= bitsPerLetter;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
const chunkOffset = (i / 4) * 3;
|
|
760
|
-
bits >>= bitLength % bitsPerByte;
|
|
761
|
-
const byteLength = Math.floor(bitLength / bitsPerByte);
|
|
762
|
-
for (let k = 0; k < byteLength; k++) {
|
|
763
|
-
const offset = (byteLength - k - 1) * bitsPerByte;
|
|
764
|
-
dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset);
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
return new Uint8Array(out);
|
|
768
|
-
};
|
|
769
|
-
|
|
770
|
-
const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) ||
|
|
771
|
-
Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
772
|
-
|
|
773
|
-
const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => {
|
|
774
|
-
if (!isArrayBuffer(input)) {
|
|
775
|
-
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
|
|
776
|
-
}
|
|
777
|
-
return Buffer.from(input, offset, length);
|
|
778
|
-
};
|
|
779
|
-
const fromString = (input, encoding) => {
|
|
780
|
-
if (typeof input !== "string") {
|
|
781
|
-
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
|
782
|
-
}
|
|
783
|
-
return encoding ? Buffer.from(input, encoding) : Buffer.from(input);
|
|
784
|
-
};
|
|
785
|
-
|
|
786
|
-
const fromUtf8$1 = (input) => {
|
|
787
|
-
const buf = fromString(input, "utf8");
|
|
788
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
789
|
-
};
|
|
790
|
-
|
|
791
|
-
function toBase64$1(_input) {
|
|
792
|
-
let input;
|
|
793
|
-
if (typeof _input === "string") {
|
|
794
|
-
input = fromUtf8$1(_input);
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
input = _input;
|
|
798
|
-
}
|
|
799
|
-
const isArrayLike = typeof input === "object" && typeof input.length === "number";
|
|
800
|
-
const isUint8Array = typeof input === "object" &&
|
|
801
|
-
typeof input.byteOffset === "number" &&
|
|
802
|
-
typeof input.byteLength === "number";
|
|
803
|
-
if (!isArrayLike && !isUint8Array) {
|
|
804
|
-
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
805
|
-
}
|
|
806
|
-
let str = "";
|
|
807
|
-
for (let i = 0; i < input.length; i += 3) {
|
|
808
|
-
let bits = 0;
|
|
809
|
-
let bitLength = 0;
|
|
810
|
-
for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) {
|
|
811
|
-
bits |= input[j] << ((limit - j - 1) * bitsPerByte);
|
|
812
|
-
bitLength += bitsPerByte;
|
|
813
|
-
}
|
|
814
|
-
const bitClusterCount = Math.ceil(bitLength / bitsPerLetter);
|
|
815
|
-
bits <<= bitClusterCount * bitsPerLetter - bitLength;
|
|
816
|
-
for (let k = 1; k <= bitClusterCount; k++) {
|
|
817
|
-
const offset = (bitClusterCount - k) * bitsPerLetter;
|
|
818
|
-
str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset];
|
|
819
|
-
}
|
|
820
|
-
str += "==".slice(0, 4 - bitClusterCount);
|
|
821
|
-
}
|
|
822
|
-
return str;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
840
|
const TEXT_ENCODER = typeof TextEncoder == "function" ? new TextEncoder() : null;
|
|
826
841
|
const calculateBodyLength = (body) => {
|
|
827
842
|
if (typeof body === "string") {
|
|
@@ -849,11 +864,9 @@ const calculateBodyLength = (body) => {
|
|
|
849
864
|
throw new Error(`Body Length computation failed for ${body}`);
|
|
850
865
|
};
|
|
851
866
|
|
|
852
|
-
const fromUtf8 = (input) => new TextEncoder().encode(input);
|
|
853
|
-
|
|
854
867
|
const toUint8Array = (data) => {
|
|
855
868
|
if (typeof data === "string") {
|
|
856
|
-
return fromUtf8
|
|
869
|
+
return fromUtf8(data);
|
|
857
870
|
}
|
|
858
871
|
if (ArrayBuffer.isView(data)) {
|
|
859
872
|
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
@@ -861,15 +874,8 @@ const toUint8Array = (data) => {
|
|
|
861
874
|
return new Uint8Array(data);
|
|
862
875
|
};
|
|
863
876
|
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
return input;
|
|
867
|
-
}
|
|
868
|
-
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
869
|
-
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
870
|
-
}
|
|
871
|
-
return new TextDecoder("utf-8").decode(input);
|
|
872
|
-
};
|
|
877
|
+
const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) ||
|
|
878
|
+
Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
873
879
|
|
|
874
880
|
const deserializerMiddleware = (options, deserializer) => (next, context) => async (args) => {
|
|
875
881
|
const { response } = await next(args);
|
|
@@ -965,64 +971,6 @@ function getSerdePlugin(config, serializer, deserializer) {
|
|
|
965
971
|
};
|
|
966
972
|
}
|
|
967
973
|
|
|
968
|
-
const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
969
|
-
const fromBase64 = (input) => {
|
|
970
|
-
if ((input.length * 3) % 4 !== 0) {
|
|
971
|
-
throw new TypeError(`Incorrect padding on base64 string.`);
|
|
972
|
-
}
|
|
973
|
-
if (!BASE64_REGEX.exec(input)) {
|
|
974
|
-
throw new TypeError(`Invalid base64 string.`);
|
|
975
|
-
}
|
|
976
|
-
const buffer = fromString(input, "base64");
|
|
977
|
-
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
978
|
-
};
|
|
979
|
-
|
|
980
|
-
const toBase64 = (_input) => {
|
|
981
|
-
let input;
|
|
982
|
-
if (typeof _input === "string") {
|
|
983
|
-
input = fromUtf8$1(_input);
|
|
984
|
-
}
|
|
985
|
-
else {
|
|
986
|
-
input = _input;
|
|
987
|
-
}
|
|
988
|
-
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
989
|
-
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
990
|
-
}
|
|
991
|
-
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
const toUtf8 = (input) => {
|
|
995
|
-
if (typeof input === "string") {
|
|
996
|
-
return input;
|
|
997
|
-
}
|
|
998
|
-
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
999
|
-
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
1000
|
-
}
|
|
1001
|
-
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8");
|
|
1002
|
-
};
|
|
1003
|
-
|
|
1004
|
-
class Uint8ArrayBlobAdapter extends Uint8Array {
|
|
1005
|
-
static fromString(source, encoding = "utf-8") {
|
|
1006
|
-
if (typeof source === "string") {
|
|
1007
|
-
if (encoding === "base64") {
|
|
1008
|
-
return Uint8ArrayBlobAdapter.mutate(fromBase64(source));
|
|
1009
|
-
}
|
|
1010
|
-
return Uint8ArrayBlobAdapter.mutate(fromUtf8$1(source));
|
|
1011
|
-
}
|
|
1012
|
-
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
|
|
1013
|
-
}
|
|
1014
|
-
static mutate(source) {
|
|
1015
|
-
Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype);
|
|
1016
|
-
return source;
|
|
1017
|
-
}
|
|
1018
|
-
transformToString(encoding = "utf-8") {
|
|
1019
|
-
if (encoding === "base64") {
|
|
1020
|
-
return toBase64(this);
|
|
1021
|
-
}
|
|
1022
|
-
return toUtf8(this);
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
974
|
const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function () { };
|
|
1027
975
|
class ChecksumStream extends ReadableStreamRef {
|
|
1028
976
|
}
|
|
@@ -1376,7 +1324,11 @@ async function splitStream(stream) {
|
|
|
1376
1324
|
}
|
|
1377
1325
|
|
|
1378
1326
|
const no = Symbol.for("node-only");
|
|
1327
|
+
const fromArrayBuffer = no;
|
|
1328
|
+
const fromString = no;
|
|
1379
1329
|
const Hash = no;
|
|
1330
|
+
class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) {
|
|
1331
|
+
}
|
|
1380
1332
|
const _getRandomValues = (array) => crypto.getRandomValues(array);
|
|
1381
1333
|
const v4 = bindV4(_getRandomValues);
|
|
1382
1334
|
const generateIdempotencyToken = v4;
|
|
@@ -1409,7 +1361,7 @@ exports.expectShort = expectShort;
|
|
|
1409
1361
|
exports.expectString = expectString;
|
|
1410
1362
|
exports.expectUnion = expectUnion;
|
|
1411
1363
|
exports.fromArrayBuffer = fromArrayBuffer;
|
|
1412
|
-
exports.fromBase64 = fromBase64
|
|
1364
|
+
exports.fromBase64 = fromBase64;
|
|
1413
1365
|
exports.fromHex = fromHex;
|
|
1414
1366
|
exports.fromString = fromString;
|
|
1415
1367
|
exports.fromUtf8 = fromUtf8;
|
|
@@ -1446,8 +1398,8 @@ exports.strictParseInt = strictParseInt;
|
|
|
1446
1398
|
exports.strictParseInt32 = strictParseInt32;
|
|
1447
1399
|
exports.strictParseLong = strictParseLong;
|
|
1448
1400
|
exports.strictParseShort = strictParseShort;
|
|
1449
|
-
exports.toBase64 = toBase64
|
|
1401
|
+
exports.toBase64 = toBase64;
|
|
1450
1402
|
exports.toHex = toHex;
|
|
1451
1403
|
exports.toUint8Array = toUint8Array;
|
|
1452
|
-
exports.toUtf8 = toUtf8
|
|
1404
|
+
exports.toUtf8 = toUtf8;
|
|
1453
1405
|
exports.v4 = v4;
|