@smithy/core 3.24.0 → 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/schema/index.js +12 -0
- package/dist-cjs/submodules/serde/index.browser.js +163 -210
- package/dist-cjs/submodules/serde/index.js +220 -122
- package/dist-cjs/submodules/serde/index.native.js +163 -210
- package/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +1 -1
- package/dist-es/submodules/schema/TypeRegistry.js +12 -0
- package/dist-es/submodules/serde/index.browser.js +16 -9
- package/dist-es/submodules/serde/index.js +14 -7
- package/dist-es/submodules/serde/index.native.js +14 -5
- 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-es/submodules/serde/uuid/v4.js +30 -29
- package/dist-types/pagination/createPaginator.d.ts +2 -2
- package/dist-types/request-builder/requestBuilder.d.ts +2 -1
- package/dist-types/setFeature.d.ts +3 -3
- package/dist-types/submodules/cbor/cbor-decode.d.ts +4 -3
- package/dist-types/submodules/cbor/cbor-types.d.ts +4 -4
- package/dist-types/submodules/cbor/cbor.d.ts +3 -4
- package/dist-types/submodules/checksum/chunked-blob-reader/chunked-blob-reader.d.ts +2 -1
- package/dist-types/submodules/client/smithy-client/client.d.ts +2 -5
- package/dist-types/submodules/client/smithy-client/default-error-handler.d.ts +2 -2
- package/dist-types/submodules/client/smithy-client/emitWarningIfUnsupportedVersion.d.ts +1 -2
- package/dist-types/submodules/client/smithy-client/exceptions.d.ts +2 -2
- package/dist-types/submodules/client/smithy-client/extensions/defaultExtensionConfiguration.d.ts +7 -7
- package/dist-types/submodules/client/smithy-client/get-array-if-single-item.d.ts +2 -2
- package/dist-types/submodules/client/smithy-client/get-value-from-text-node.d.ts +2 -2
- package/dist-types/submodules/client/smithy-client/object-mapping.d.ts +22 -21
- package/dist-types/submodules/client/smithy-client/ser-utils.d.ts +1 -2
- package/dist-types/submodules/client/smithy-client/serde-json.d.ts +1 -3
- package/dist-types/submodules/client/util-waiter/utils/validate.d.ts +2 -2
- package/dist-types/submodules/config/config-resolver/endpointsConfig/resolveEndpointsConfig.d.ts +2 -2
- package/dist-types/submodules/config/property-provider/CredentialsProviderError.d.ts +2 -3
- package/dist-types/submodules/config/property-provider/ProviderError.d.ts +2 -3
- package/dist-types/submodules/config/property-provider/TokenProviderError.d.ts +2 -3
- package/dist-types/submodules/config/property-provider/chain.d.ts +2 -3
- package/dist-types/submodules/config/shared-ini-file-loader/getSSOTokenFromFile.d.ts +2 -1
- package/dist-types/submodules/endpoints/middleware-endpoint/resolveEndpointConfig.d.ts +6 -5
- package/dist-types/submodules/endpoints/util-endpoints/cache/EndpointCache.d.ts +2 -2
- package/dist-types/submodules/endpoints/util-endpoints/getEndpointUrlConfig.d.ts +2 -1
- package/dist-types/submodules/protocols/collect-stream-body.d.ts +2 -2
- package/dist-types/submodules/protocols/extended-encode-uri-component.d.ts +2 -2
- package/dist-types/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +4 -4
- package/dist-types/submodules/protocols/protocol-http/httpHandler.d.ts +2 -5
- package/dist-types/submodules/protocols/requestBuilder.d.ts +2 -1
- package/dist-types/submodules/retry/util-retry/constants.d.ts +4 -4
- package/dist-types/submodules/serde/date-utils.d.ts +7 -19
- package/dist-types/submodules/serde/index.browser.d.ts +15 -9
- package/dist-types/submodules/serde/index.d.ts +11 -7
- package/dist-types/submodules/serde/index.native.d.ts +9 -5
- package/dist-types/submodules/serde/lazy-json.d.ts +4 -6
- package/dist-types/submodules/serde/parse-utils.d.ts +31 -51
- package/dist-types/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +3 -12
- package/dist-types/submodules/serde/split-every.d.ts +1 -2
- package/dist-types/submodules/serde/util-stream/blob/Uint8ArrayBlobAdapter.d.ts +8 -12
- package/dist-types/submodules/serde/util-stream/createBufferedReadable.browser.d.ts +2 -1
- package/dist-types/submodules/serde/util-stream/createBufferedReadable.d.ts +2 -1
- package/dist-types/submodules/serde/util-stream/stream-collector.browser.d.ts +2 -1
- package/dist-types/submodules/serde/util-utf8/toUint8Array.browser.d.ts +4 -0
- package/dist-types/submodules/serde/uuid/v4.d.ts +12 -7
- package/dist-types/util-identity-and-auth/memoizeIdentityProvider.d.ts +2 -1
- package/package.json +1 -1
- package/dist-es/submodules/serde/generateIdempotencyToken.js +0 -2
- package/dist-es/submodules/serde/uuid/randomUUID.js +0 -3
- package/dist-types/submodules/serde/generateIdempotencyToken.d.ts +0 -2
- package/dist-types/submodules/serde/uuid/randomUUID.d.ts +0 -1
|
@@ -1,11 +1,125 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var node_crypto = require('node:crypto');
|
|
3
4
|
var node_fs = require('node:fs');
|
|
4
5
|
var protocols = require('@smithy/core/protocols');
|
|
5
6
|
var endpoints = require('@smithy/core/endpoints');
|
|
6
|
-
var node_crypto = require('node:crypto');
|
|
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
|
+
|
|
90
|
+
const decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
91
|
+
function bindV4(getRandomValues) {
|
|
92
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
93
|
+
return () => crypto.randomUUID();
|
|
94
|
+
}
|
|
95
|
+
return () => {
|
|
96
|
+
const rnds = new Uint8Array(16);
|
|
97
|
+
getRandomValues(rnds);
|
|
98
|
+
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
99
|
+
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
100
|
+
return (decimalToHex[rnds[0]] +
|
|
101
|
+
decimalToHex[rnds[1]] +
|
|
102
|
+
decimalToHex[rnds[2]] +
|
|
103
|
+
decimalToHex[rnds[3]] +
|
|
104
|
+
"-" +
|
|
105
|
+
decimalToHex[rnds[4]] +
|
|
106
|
+
decimalToHex[rnds[5]] +
|
|
107
|
+
"-" +
|
|
108
|
+
decimalToHex[rnds[6]] +
|
|
109
|
+
decimalToHex[rnds[7]] +
|
|
110
|
+
"-" +
|
|
111
|
+
decimalToHex[rnds[8]] +
|
|
112
|
+
decimalToHex[rnds[9]] +
|
|
113
|
+
"-" +
|
|
114
|
+
decimalToHex[rnds[10]] +
|
|
115
|
+
decimalToHex[rnds[11]] +
|
|
116
|
+
decimalToHex[rnds[12]] +
|
|
117
|
+
decimalToHex[rnds[13]] +
|
|
118
|
+
decimalToHex[rnds[14]] +
|
|
119
|
+
decimalToHex[rnds[15]]);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
9
123
|
const copyDocumentWithTransform = (source, schemaRef, transform = (_) => _) => source;
|
|
10
124
|
|
|
11
125
|
const parseBoolean = (value) => {
|
|
@@ -432,41 +546,6 @@ const stripLeadingZeroes = (value) => {
|
|
|
432
546
|
return value.slice(idx);
|
|
433
547
|
};
|
|
434
548
|
|
|
435
|
-
const randomUUID = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function"
|
|
436
|
-
? crypto.randomUUID.bind(crypto)
|
|
437
|
-
: undefined;
|
|
438
|
-
|
|
439
|
-
const decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
440
|
-
const v4 = () => {
|
|
441
|
-
if (randomUUID) {
|
|
442
|
-
return randomUUID();
|
|
443
|
-
}
|
|
444
|
-
const rnds = new Uint8Array(16);
|
|
445
|
-
crypto.getRandomValues(rnds);
|
|
446
|
-
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
447
|
-
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
448
|
-
return (decimalToHex[rnds[0]] +
|
|
449
|
-
decimalToHex[rnds[1]] +
|
|
450
|
-
decimalToHex[rnds[2]] +
|
|
451
|
-
decimalToHex[rnds[3]] +
|
|
452
|
-
"-" +
|
|
453
|
-
decimalToHex[rnds[4]] +
|
|
454
|
-
decimalToHex[rnds[5]] +
|
|
455
|
-
"-" +
|
|
456
|
-
decimalToHex[rnds[6]] +
|
|
457
|
-
decimalToHex[rnds[7]] +
|
|
458
|
-
"-" +
|
|
459
|
-
decimalToHex[rnds[8]] +
|
|
460
|
-
decimalToHex[rnds[9]] +
|
|
461
|
-
"-" +
|
|
462
|
-
decimalToHex[rnds[10]] +
|
|
463
|
-
decimalToHex[rnds[11]] +
|
|
464
|
-
decimalToHex[rnds[12]] +
|
|
465
|
-
decimalToHex[rnds[13]] +
|
|
466
|
-
decimalToHex[rnds[14]] +
|
|
467
|
-
decimalToHex[rnds[15]]);
|
|
468
|
-
};
|
|
469
|
-
|
|
470
549
|
const LazyJsonString = function LazyJsonString(val) {
|
|
471
550
|
const str = Object.assign(new String(val), {
|
|
472
551
|
deserializeJSON() {
|
|
@@ -726,53 +805,6 @@ function toHex(bytes) {
|
|
|
726
805
|
return out;
|
|
727
806
|
}
|
|
728
807
|
|
|
729
|
-
const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) ||
|
|
730
|
-
Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
731
|
-
|
|
732
|
-
const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => {
|
|
733
|
-
if (!isArrayBuffer(input)) {
|
|
734
|
-
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
|
|
735
|
-
}
|
|
736
|
-
return Buffer.from(input, offset, length);
|
|
737
|
-
};
|
|
738
|
-
const fromString = (input, encoding) => {
|
|
739
|
-
if (typeof input !== "string") {
|
|
740
|
-
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
|
741
|
-
}
|
|
742
|
-
return encoding ? Buffer.from(input, encoding) : Buffer.from(input);
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
746
|
-
const fromBase64 = (input) => {
|
|
747
|
-
if ((input.length * 3) % 4 !== 0) {
|
|
748
|
-
throw new TypeError(`Incorrect padding on base64 string.`);
|
|
749
|
-
}
|
|
750
|
-
if (!BASE64_REGEX.exec(input)) {
|
|
751
|
-
throw new TypeError(`Invalid base64 string.`);
|
|
752
|
-
}
|
|
753
|
-
const buffer = fromString(input, "base64");
|
|
754
|
-
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
const fromUtf8 = (input) => {
|
|
758
|
-
const buf = fromString(input, "utf8");
|
|
759
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
const toBase64 = (_input) => {
|
|
763
|
-
let input;
|
|
764
|
-
if (typeof _input === "string") {
|
|
765
|
-
input = fromUtf8(_input);
|
|
766
|
-
}
|
|
767
|
-
else {
|
|
768
|
-
input = _input;
|
|
769
|
-
}
|
|
770
|
-
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
771
|
-
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
772
|
-
}
|
|
773
|
-
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
|
774
|
-
};
|
|
775
|
-
|
|
776
808
|
const calculateBodyLength = (body) => {
|
|
777
809
|
if (!body) {
|
|
778
810
|
return 0;
|
|
@@ -802,7 +834,7 @@ const calculateBodyLength = (body) => {
|
|
|
802
834
|
|
|
803
835
|
const toUint8Array = (data) => {
|
|
804
836
|
if (typeof data === "string") {
|
|
805
|
-
return fromUtf8(data);
|
|
837
|
+
return fromUtf8$1(data);
|
|
806
838
|
}
|
|
807
839
|
if (ArrayBuffer.isView(data)) {
|
|
808
840
|
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
@@ -810,16 +842,6 @@ const toUint8Array = (data) => {
|
|
|
810
842
|
return new Uint8Array(data);
|
|
811
843
|
};
|
|
812
844
|
|
|
813
|
-
const toUtf8 = (input) => {
|
|
814
|
-
if (typeof input === "string") {
|
|
815
|
-
return input;
|
|
816
|
-
}
|
|
817
|
-
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
818
|
-
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
819
|
-
}
|
|
820
|
-
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8");
|
|
821
|
-
};
|
|
822
|
-
|
|
823
845
|
const deserializerMiddleware = (options, deserializer) => (next, context) => async (args) => {
|
|
824
846
|
const { response } = await next(args);
|
|
825
847
|
try {
|
|
@@ -948,28 +970,6 @@ function castSourceData(toCast, encoding) {
|
|
|
948
970
|
return fromArrayBuffer(toCast);
|
|
949
971
|
}
|
|
950
972
|
|
|
951
|
-
class Uint8ArrayBlobAdapter extends Uint8Array {
|
|
952
|
-
static fromString(source, encoding = "utf-8") {
|
|
953
|
-
if (typeof source === "string") {
|
|
954
|
-
if (encoding === "base64") {
|
|
955
|
-
return Uint8ArrayBlobAdapter.mutate(fromBase64(source));
|
|
956
|
-
}
|
|
957
|
-
return Uint8ArrayBlobAdapter.mutate(fromUtf8(source));
|
|
958
|
-
}
|
|
959
|
-
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
|
|
960
|
-
}
|
|
961
|
-
static mutate(source) {
|
|
962
|
-
Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype);
|
|
963
|
-
return source;
|
|
964
|
-
}
|
|
965
|
-
transformToString(encoding = "utf-8") {
|
|
966
|
-
if (encoding === "base64") {
|
|
967
|
-
return toBase64(this);
|
|
968
|
-
}
|
|
969
|
-
return toUtf8(this);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
|
|
973
973
|
let ChecksumStream$1 = class ChecksumStream extends node_stream.Duplex {
|
|
974
974
|
expectedChecksum;
|
|
975
975
|
checksumSourceLocation;
|
|
@@ -985,7 +985,7 @@ let ChecksumStream$1 = class ChecksumStream extends node_stream.Duplex {
|
|
|
985
985
|
else {
|
|
986
986
|
throw new Error(`@smithy/util-stream: unsupported source type ${source?.constructor?.name ?? source} in ChecksumStream.`);
|
|
987
987
|
}
|
|
988
|
-
this.base64Encoder = base64Encoder ?? toBase64;
|
|
988
|
+
this.base64Encoder = base64Encoder ?? toBase64$1;
|
|
989
989
|
this.expectedChecksum = expectedChecksum;
|
|
990
990
|
this.checksum = checksum;
|
|
991
991
|
this.checksumSourceLocation = checksumSourceLocation;
|
|
@@ -1035,6 +1035,52 @@ const isBlob = (blob) => {
|
|
|
1035
1035
|
return typeof Blob === "function" && (blob?.constructor?.name === Blob.name || blob instanceof Blob);
|
|
1036
1036
|
};
|
|
1037
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
|
+
|
|
1038
1084
|
const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function () { };
|
|
1039
1085
|
class ChecksumStream extends ReadableStreamRef {
|
|
1040
1086
|
}
|
|
@@ -1392,6 +1438,52 @@ let Collector$1 = class Collector extends node_stream.Writable {
|
|
|
1392
1438
|
}
|
|
1393
1439
|
};
|
|
1394
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
|
+
|
|
1395
1487
|
const streamCollector$1 = async (stream) => {
|
|
1396
1488
|
if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") {
|
|
1397
1489
|
if (Blob.prototype.arrayBuffer !== undefined) {
|
|
@@ -1619,6 +1711,12 @@ async function splitStream(stream) {
|
|
|
1619
1711
|
return [stream1, stream2];
|
|
1620
1712
|
}
|
|
1621
1713
|
|
|
1714
|
+
class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8$1, fromUtf8$1, toBase64$1, fromBase64$1) {
|
|
1715
|
+
}
|
|
1716
|
+
const _getRandomValues = node_crypto.getRandomValues;
|
|
1717
|
+
const v4 = bindV4(_getRandomValues);
|
|
1718
|
+
const generateIdempotencyToken = v4;
|
|
1719
|
+
|
|
1622
1720
|
exports.ChecksumStream = ChecksumStream$1;
|
|
1623
1721
|
exports.Hash = Hash;
|
|
1624
1722
|
exports.LazyJsonString = LazyJsonString;
|
|
@@ -1647,11 +1745,11 @@ exports.expectShort = expectShort;
|
|
|
1647
1745
|
exports.expectString = expectString;
|
|
1648
1746
|
exports.expectUnion = expectUnion;
|
|
1649
1747
|
exports.fromArrayBuffer = fromArrayBuffer;
|
|
1650
|
-
exports.fromBase64 = fromBase64;
|
|
1748
|
+
exports.fromBase64 = fromBase64$1;
|
|
1651
1749
|
exports.fromHex = fromHex;
|
|
1652
1750
|
exports.fromString = fromString;
|
|
1653
|
-
exports.fromUtf8 = fromUtf8;
|
|
1654
|
-
exports.generateIdempotencyToken =
|
|
1751
|
+
exports.fromUtf8 = fromUtf8$1;
|
|
1752
|
+
exports.generateIdempotencyToken = generateIdempotencyToken;
|
|
1655
1753
|
exports.getAwsChunkedEncodingStream = getAwsChunkedEncodingStream;
|
|
1656
1754
|
exports.getSerdePlugin = getSerdePlugin;
|
|
1657
1755
|
exports.handleFloat = handleFloat;
|
|
@@ -1684,8 +1782,8 @@ exports.strictParseInt = strictParseInt;
|
|
|
1684
1782
|
exports.strictParseInt32 = strictParseInt32;
|
|
1685
1783
|
exports.strictParseLong = strictParseLong;
|
|
1686
1784
|
exports.strictParseShort = strictParseShort;
|
|
1687
|
-
exports.toBase64 = toBase64;
|
|
1785
|
+
exports.toBase64 = toBase64$1;
|
|
1688
1786
|
exports.toHex = toHex;
|
|
1689
1787
|
exports.toUint8Array = toUint8Array;
|
|
1690
|
-
exports.toUtf8 = toUtf8;
|
|
1788
|
+
exports.toUtf8 = toUtf8$1;
|
|
1691
1789
|
exports.v4 = v4;
|