@smithy/core
Advanced tools
| import { fromUtf8 } from "./fromUtf8.browser"; | ||
| export const toUint8Array = (data) => { | ||
| if (typeof data === "string") { | ||
| return fromUtf8(data); | ||
| } | ||
| if (ArrayBuffer.isView(data)) { | ||
| return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT); | ||
| } | ||
| return new Uint8Array(data); | ||
| }; |
| /** | ||
| * @internal | ||
| */ | ||
| export declare const toUint8Array: (data: string | ArrayBuffer | ArrayBufferView) => Uint8Array; |
@@ -1083,3 +1083,3 @@ 'use strict'; | ||
| const message = dataObject.message ?? dataObject.Message ?? "Unknown"; | ||
| const exception = new ErrorCtor(message); | ||
| const exception = new ErrorCtor({}); | ||
| const output = {}; | ||
@@ -1086,0 +1086,0 @@ for (const [name, member] of ns.structIterator()) { |
@@ -6,2 +6,118 @@ 'use strict'; | ||
| const chars = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`; | ||
| const alphabetByEncoding = Object.entries(chars).reduce((acc, [i, c]) => { | ||
| acc[c] = Number(i); | ||
| return acc; | ||
| }, {}); | ||
| const alphabetByValue = chars.split(""); | ||
| const bitsPerLetter = 6; | ||
| const bitsPerByte = 8; | ||
| const maxLetterValue = 0b111111; | ||
| const fromBase64 = (input) => { | ||
| let totalByteLength = (input.length / 4) * 3; | ||
| if (input.slice(-2) === "==") { | ||
| totalByteLength -= 2; | ||
| } | ||
| else if (input.slice(-1) === "=") { | ||
| totalByteLength--; | ||
| } | ||
| const out = new ArrayBuffer(totalByteLength); | ||
| const dataView = new DataView(out); | ||
| for (let i = 0; i < input.length; i += 4) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = i + 3; j <= limit; j++) { | ||
| if (input[j] !== "=") { | ||
| if (!(input[j] in alphabetByEncoding)) { | ||
| throw new TypeError(`Invalid character ${input[j]} in base64 string.`); | ||
| } | ||
| bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter); | ||
| bitLength += bitsPerLetter; | ||
| } | ||
| else { | ||
| bits >>= bitsPerLetter; | ||
| } | ||
| } | ||
| const chunkOffset = (i / 4) * 3; | ||
| bits >>= bitLength % bitsPerByte; | ||
| const byteLength = Math.floor(bitLength / bitsPerByte); | ||
| for (let k = 0; k < byteLength; k++) { | ||
| const offset = (byteLength - k - 1) * bitsPerByte; | ||
| dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset); | ||
| } | ||
| } | ||
| return new Uint8Array(out); | ||
| }; | ||
| const fromUtf8 = (input) => new TextEncoder().encode(input); | ||
| function toBase64(_input) { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| const isArrayLike = typeof input === "object" && typeof input.length === "number"; | ||
| const isUint8Array = typeof input === "object" && | ||
| typeof input.byteOffset === "number" && | ||
| typeof input.byteLength === "number"; | ||
| if (!isArrayLike && !isUint8Array) { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| let str = ""; | ||
| for (let i = 0; i < input.length; i += 3) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) { | ||
| bits |= input[j] << ((limit - j - 1) * bitsPerByte); | ||
| bitLength += bitsPerByte; | ||
| } | ||
| const bitClusterCount = Math.ceil(bitLength / bitsPerLetter); | ||
| bits <<= bitClusterCount * bitsPerLetter - bitLength; | ||
| for (let k = 1; k <= bitClusterCount; k++) { | ||
| const offset = (bitClusterCount - k) * bitsPerLetter; | ||
| str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset]; | ||
| } | ||
| str += "==".slice(0, 4 - bitClusterCount); | ||
| } | ||
| return str; | ||
| } | ||
| function bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| return class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| static fromString(source, encoding = "utf-8") { | ||
| if (typeof source === "string") { | ||
| if (encoding === "base64") { | ||
| return Uint8ArrayBlobAdapter.mutate(fromBase64(source)); | ||
| } | ||
| return Uint8ArrayBlobAdapter.mutate(fromUtf8(source)); | ||
| } | ||
| throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
| } | ||
| static mutate(source) { | ||
| Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
| return source; | ||
| } | ||
| transformToString(encoding = "utf-8") { | ||
| if (encoding === "base64") { | ||
| return toBase64(this); | ||
| } | ||
| return toUtf8(this); | ||
| } | ||
| }; | ||
| } | ||
| const toUtf8 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return new TextDecoder("utf-8").decode(input); | ||
| }; | ||
| const decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0")); | ||
@@ -725,103 +841,2 @@ function bindV4(getRandomValues) { | ||
| const chars = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`; | ||
| const alphabetByEncoding = Object.entries(chars).reduce((acc, [i, c]) => { | ||
| acc[c] = Number(i); | ||
| return acc; | ||
| }, {}); | ||
| const alphabetByValue = chars.split(""); | ||
| const bitsPerLetter = 6; | ||
| const bitsPerByte = 8; | ||
| const maxLetterValue = 0b111111; | ||
| const fromBase64$1 = (input) => { | ||
| let totalByteLength = (input.length / 4) * 3; | ||
| if (input.slice(-2) === "==") { | ||
| totalByteLength -= 2; | ||
| } | ||
| else if (input.slice(-1) === "=") { | ||
| totalByteLength--; | ||
| } | ||
| const out = new ArrayBuffer(totalByteLength); | ||
| const dataView = new DataView(out); | ||
| for (let i = 0; i < input.length; i += 4) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = i + 3; j <= limit; j++) { | ||
| if (input[j] !== "=") { | ||
| if (!(input[j] in alphabetByEncoding)) { | ||
| throw new TypeError(`Invalid character ${input[j]} in base64 string.`); | ||
| } | ||
| bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter); | ||
| bitLength += bitsPerLetter; | ||
| } | ||
| else { | ||
| bits >>= bitsPerLetter; | ||
| } | ||
| } | ||
| const chunkOffset = (i / 4) * 3; | ||
| bits >>= bitLength % bitsPerByte; | ||
| const byteLength = Math.floor(bitLength / bitsPerByte); | ||
| for (let k = 0; k < byteLength; k++) { | ||
| const offset = (byteLength - k - 1) * bitsPerByte; | ||
| dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset); | ||
| } | ||
| } | ||
| return new Uint8Array(out); | ||
| }; | ||
| const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) || | ||
| Object.prototype.toString.call(arg) === "[object ArrayBuffer]"; | ||
| const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => { | ||
| if (!isArrayBuffer(input)) { | ||
| throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`); | ||
| } | ||
| return Buffer.from(input, offset, length); | ||
| }; | ||
| const fromString = (input, encoding) => { | ||
| if (typeof input !== "string") { | ||
| throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`); | ||
| } | ||
| return encoding ? Buffer.from(input, encoding) : Buffer.from(input); | ||
| }; | ||
| const fromUtf8$1 = (input) => { | ||
| const buf = fromString(input, "utf8"); | ||
| return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT); | ||
| }; | ||
| function toBase64$1(_input) { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8$1(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| const isArrayLike = typeof input === "object" && typeof input.length === "number"; | ||
| const isUint8Array = typeof input === "object" && | ||
| typeof input.byteOffset === "number" && | ||
| typeof input.byteLength === "number"; | ||
| if (!isArrayLike && !isUint8Array) { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| let str = ""; | ||
| for (let i = 0; i < input.length; i += 3) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) { | ||
| bits |= input[j] << ((limit - j - 1) * bitsPerByte); | ||
| bitLength += bitsPerByte; | ||
| } | ||
| const bitClusterCount = Math.ceil(bitLength / bitsPerLetter); | ||
| bits <<= bitClusterCount * bitsPerLetter - bitLength; | ||
| for (let k = 1; k <= bitClusterCount; k++) { | ||
| const offset = (bitClusterCount - k) * bitsPerLetter; | ||
| str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset]; | ||
| } | ||
| str += "==".slice(0, 4 - bitClusterCount); | ||
| } | ||
| return str; | ||
| } | ||
| const TEXT_ENCODER = typeof TextEncoder == "function" ? new TextEncoder() : null; | ||
@@ -854,7 +869,5 @@ const calculateBodyLength = (body) => { | ||
| const fromUtf8 = (input) => new TextEncoder().encode(input); | ||
| const toUint8Array = (data) => { | ||
| if (typeof data === "string") { | ||
| return fromUtf8$1(data); | ||
| return fromUtf8(data); | ||
| } | ||
@@ -867,11 +880,4 @@ if (ArrayBuffer.isView(data)) { | ||
| const toUtf8$1 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return new TextDecoder("utf-8").decode(input); | ||
| }; | ||
| const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) || | ||
| Object.prototype.toString.call(arg) === "[object ArrayBuffer]"; | ||
@@ -972,60 +978,2 @@ const deserializerMiddleware = (options, deserializer) => (next, context) => async (args) => { | ||
| const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/; | ||
| const fromBase64 = (input) => { | ||
| if ((input.length * 3) % 4 !== 0) { | ||
| throw new TypeError(`Incorrect padding on base64 string.`); | ||
| } | ||
| if (!BASE64_REGEX.exec(input)) { | ||
| throw new TypeError(`Invalid base64 string.`); | ||
| } | ||
| const buffer = fromString(input, "base64"); | ||
| return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength); | ||
| }; | ||
| const toBase64 = (_input) => { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8$1(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64"); | ||
| }; | ||
| const toUtf8 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8"); | ||
| }; | ||
| class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| static fromString(source, encoding = "utf-8") { | ||
| if (typeof source === "string") { | ||
| if (encoding === "base64") { | ||
| return Uint8ArrayBlobAdapter.mutate(fromBase64(source)); | ||
| } | ||
| return Uint8ArrayBlobAdapter.mutate(fromUtf8$1(source)); | ||
| } | ||
| throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
| } | ||
| static mutate(source) { | ||
| Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
| return source; | ||
| } | ||
| transformToString(encoding = "utf-8") { | ||
| if (encoding === "base64") { | ||
| return toBase64(this); | ||
| } | ||
| return toUtf8(this); | ||
| } | ||
| } | ||
| const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function () { }; | ||
@@ -1384,3 +1332,7 @@ class ChecksumStream extends ReadableStreamRef { | ||
| const no = Symbol.for("node-only"); | ||
| const fromArrayBuffer = no; | ||
| const fromString = no; | ||
| const Hash = no; | ||
| class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| } | ||
| const _getRandomValues = (array) => crypto.getRandomValues(array); | ||
@@ -1418,3 +1370,3 @@ const v4 = bindV4(_getRandomValues); | ||
| exports.fromArrayBuffer = fromArrayBuffer; | ||
| exports.fromBase64 = fromBase64$1; | ||
| exports.fromBase64 = fromBase64; | ||
| exports.fromHex = fromHex; | ||
@@ -1456,6 +1408,6 @@ exports.fromString = fromString; | ||
| exports.strictParseShort = strictParseShort; | ||
| exports.toBase64 = toBase64$1; | ||
| exports.toBase64 = toBase64; | ||
| exports.toHex = toHex; | ||
| exports.toUint8Array = toUint8Array; | ||
| exports.toUtf8 = toUtf8$1; | ||
| exports.toUtf8 = toUtf8; | ||
| exports.v4 = v4; |
@@ -9,2 +9,83 @@ 'use strict'; | ||
| const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) || | ||
| Object.prototype.toString.call(arg) === "[object ArrayBuffer]"; | ||
| const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => { | ||
| if (!isArrayBuffer(input)) { | ||
| throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`); | ||
| } | ||
| return Buffer.from(input, offset, length); | ||
| }; | ||
| const fromString = (input, encoding) => { | ||
| if (typeof input !== "string") { | ||
| throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`); | ||
| } | ||
| return encoding ? Buffer.from(input, encoding) : Buffer.from(input); | ||
| }; | ||
| const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/; | ||
| const fromBase64$1 = (input) => { | ||
| if ((input.length * 3) % 4 !== 0) { | ||
| throw new TypeError(`Incorrect padding on base64 string.`); | ||
| } | ||
| if (!BASE64_REGEX.exec(input)) { | ||
| throw new TypeError(`Invalid base64 string.`); | ||
| } | ||
| const buffer = fromString(input, "base64"); | ||
| return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength); | ||
| }; | ||
| const fromUtf8$1 = (input) => { | ||
| const buf = fromString(input, "utf8"); | ||
| return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT); | ||
| }; | ||
| const toBase64$1 = (_input) => { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8$1(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64"); | ||
| }; | ||
| function bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| return class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| static fromString(source, encoding = "utf-8") { | ||
| if (typeof source === "string") { | ||
| if (encoding === "base64") { | ||
| return Uint8ArrayBlobAdapter.mutate(fromBase64(source)); | ||
| } | ||
| return Uint8ArrayBlobAdapter.mutate(fromUtf8(source)); | ||
| } | ||
| throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
| } | ||
| static mutate(source) { | ||
| Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
| return source; | ||
| } | ||
| transformToString(encoding = "utf-8") { | ||
| if (encoding === "base64") { | ||
| return toBase64(this); | ||
| } | ||
| return toUtf8(this); | ||
| } | ||
| }; | ||
| } | ||
| const toUtf8$1 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8"); | ||
| }; | ||
| const decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0")); | ||
@@ -728,49 +809,2 @@ function bindV4(getRandomValues) { | ||
| const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) || | ||
| Object.prototype.toString.call(arg) === "[object ArrayBuffer]"; | ||
| const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => { | ||
| if (!isArrayBuffer(input)) { | ||
| throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`); | ||
| } | ||
| return Buffer.from(input, offset, length); | ||
| }; | ||
| const fromString = (input, encoding) => { | ||
| if (typeof input !== "string") { | ||
| throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`); | ||
| } | ||
| return encoding ? Buffer.from(input, encoding) : Buffer.from(input); | ||
| }; | ||
| const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/; | ||
| const fromBase64 = (input) => { | ||
| if ((input.length * 3) % 4 !== 0) { | ||
| throw new TypeError(`Incorrect padding on base64 string.`); | ||
| } | ||
| if (!BASE64_REGEX.exec(input)) { | ||
| throw new TypeError(`Invalid base64 string.`); | ||
| } | ||
| const buffer = fromString(input, "base64"); | ||
| return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength); | ||
| }; | ||
| const fromUtf8 = (input) => { | ||
| const buf = fromString(input, "utf8"); | ||
| return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT); | ||
| }; | ||
| const toBase64 = (_input) => { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64"); | ||
| }; | ||
| const calculateBodyLength = (body) => { | ||
@@ -805,3 +839,3 @@ if (!body) { | ||
| if (typeof data === "string") { | ||
| return fromUtf8(data); | ||
| return fromUtf8$1(data); | ||
| } | ||
@@ -814,12 +848,2 @@ if (ArrayBuffer.isView(data)) { | ||
| const toUtf8 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8"); | ||
| }; | ||
| const deserializerMiddleware = (options, deserializer) => (next, context) => async (args) => { | ||
@@ -953,24 +977,2 @@ const { response } = await next(args); | ||
| class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| static fromString(source, encoding = "utf-8") { | ||
| if (typeof source === "string") { | ||
| if (encoding === "base64") { | ||
| return Uint8ArrayBlobAdapter.mutate(fromBase64(source)); | ||
| } | ||
| return Uint8ArrayBlobAdapter.mutate(fromUtf8(source)); | ||
| } | ||
| throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
| } | ||
| static mutate(source) { | ||
| Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
| return source; | ||
| } | ||
| transformToString(encoding = "utf-8") { | ||
| if (encoding === "base64") { | ||
| return toBase64(this); | ||
| } | ||
| return toUtf8(this); | ||
| } | ||
| } | ||
| let ChecksumStream$1 = class ChecksumStream extends node_stream.Duplex { | ||
@@ -991,3 +993,3 @@ expectedChecksum; | ||
| } | ||
| this.base64Encoder = base64Encoder ?? toBase64; | ||
| this.base64Encoder = base64Encoder ?? toBase64$1; | ||
| this.expectedChecksum = expectedChecksum; | ||
@@ -1042,2 +1044,48 @@ this.checksum = checksum; | ||
| const fromUtf8 = (input) => new TextEncoder().encode(input); | ||
| const chars = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`; | ||
| const alphabetByEncoding = Object.entries(chars).reduce((acc, [i, c]) => { | ||
| acc[c] = Number(i); | ||
| return acc; | ||
| }, {}); | ||
| const alphabetByValue = chars.split(""); | ||
| const bitsPerLetter = 6; | ||
| const bitsPerByte = 8; | ||
| const maxLetterValue = 0b111111; | ||
| function toBase64(_input) { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| const isArrayLike = typeof input === "object" && typeof input.length === "number"; | ||
| const isUint8Array = typeof input === "object" && | ||
| typeof input.byteOffset === "number" && | ||
| typeof input.byteLength === "number"; | ||
| if (!isArrayLike && !isUint8Array) { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| let str = ""; | ||
| for (let i = 0; i < input.length; i += 3) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) { | ||
| bits |= input[j] << ((limit - j - 1) * bitsPerByte); | ||
| bitLength += bitsPerByte; | ||
| } | ||
| const bitClusterCount = Math.ceil(bitLength / bitsPerLetter); | ||
| bits <<= bitClusterCount * bitsPerLetter - bitLength; | ||
| for (let k = 1; k <= bitClusterCount; k++) { | ||
| const offset = (bitClusterCount - k) * bitsPerLetter; | ||
| str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset]; | ||
| } | ||
| str += "==".slice(0, 4 - bitClusterCount); | ||
| } | ||
| return str; | ||
| } | ||
| const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function () { }; | ||
@@ -1400,2 +1448,48 @@ class ChecksumStream extends ReadableStreamRef { | ||
| const toUtf8 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return new TextDecoder("utf-8").decode(input); | ||
| }; | ||
| const fromBase64 = (input) => { | ||
| let totalByteLength = (input.length / 4) * 3; | ||
| if (input.slice(-2) === "==") { | ||
| totalByteLength -= 2; | ||
| } | ||
| else if (input.slice(-1) === "=") { | ||
| totalByteLength--; | ||
| } | ||
| const out = new ArrayBuffer(totalByteLength); | ||
| const dataView = new DataView(out); | ||
| for (let i = 0; i < input.length; i += 4) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = i + 3; j <= limit; j++) { | ||
| if (input[j] !== "=") { | ||
| if (!(input[j] in alphabetByEncoding)) { | ||
| throw new TypeError(`Invalid character ${input[j]} in base64 string.`); | ||
| } | ||
| bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter); | ||
| bitLength += bitsPerLetter; | ||
| } | ||
| else { | ||
| bits >>= bitsPerLetter; | ||
| } | ||
| } | ||
| const chunkOffset = (i / 4) * 3; | ||
| bits >>= bitLength % bitsPerByte; | ||
| const byteLength = Math.floor(bitLength / bitsPerByte); | ||
| for (let k = 0; k < byteLength; k++) { | ||
| const offset = (byteLength - k - 1) * bitsPerByte; | ||
| dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset); | ||
| } | ||
| } | ||
| return new Uint8Array(out); | ||
| }; | ||
| const streamCollector$1 = async (stream) => { | ||
@@ -1628,2 +1722,4 @@ if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") { | ||
| class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8$1, fromUtf8$1, toBase64$1, fromBase64$1) { | ||
| } | ||
| const _getRandomValues = node_crypto.getRandomValues; | ||
@@ -1661,6 +1757,6 @@ const v4 = bindV4(_getRandomValues); | ||
| exports.fromArrayBuffer = fromArrayBuffer; | ||
| exports.fromBase64 = fromBase64; | ||
| exports.fromBase64 = fromBase64$1; | ||
| exports.fromHex = fromHex; | ||
| exports.fromString = fromString; | ||
| exports.fromUtf8 = fromUtf8; | ||
| exports.fromUtf8 = fromUtf8$1; | ||
| exports.generateIdempotencyToken = generateIdempotencyToken; | ||
@@ -1699,6 +1795,6 @@ exports.getAwsChunkedEncodingStream = getAwsChunkedEncodingStream; | ||
| exports.strictParseShort = strictParseShort; | ||
| exports.toBase64 = toBase64; | ||
| exports.toBase64 = toBase64$1; | ||
| exports.toHex = toHex; | ||
| exports.toUint8Array = toUint8Array; | ||
| exports.toUtf8 = toUtf8; | ||
| exports.toUtf8 = toUtf8$1; | ||
| exports.v4 = v4; |
@@ -6,2 +6,118 @@ 'use strict'; | ||
| const chars = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`; | ||
| const alphabetByEncoding = Object.entries(chars).reduce((acc, [i, c]) => { | ||
| acc[c] = Number(i); | ||
| return acc; | ||
| }, {}); | ||
| const alphabetByValue = chars.split(""); | ||
| const bitsPerLetter = 6; | ||
| const bitsPerByte = 8; | ||
| const maxLetterValue = 0b111111; | ||
| const fromBase64 = (input) => { | ||
| let totalByteLength = (input.length / 4) * 3; | ||
| if (input.slice(-2) === "==") { | ||
| totalByteLength -= 2; | ||
| } | ||
| else if (input.slice(-1) === "=") { | ||
| totalByteLength--; | ||
| } | ||
| const out = new ArrayBuffer(totalByteLength); | ||
| const dataView = new DataView(out); | ||
| for (let i = 0; i < input.length; i += 4) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = i + 3; j <= limit; j++) { | ||
| if (input[j] !== "=") { | ||
| if (!(input[j] in alphabetByEncoding)) { | ||
| throw new TypeError(`Invalid character ${input[j]} in base64 string.`); | ||
| } | ||
| bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter); | ||
| bitLength += bitsPerLetter; | ||
| } | ||
| else { | ||
| bits >>= bitsPerLetter; | ||
| } | ||
| } | ||
| const chunkOffset = (i / 4) * 3; | ||
| bits >>= bitLength % bitsPerByte; | ||
| const byteLength = Math.floor(bitLength / bitsPerByte); | ||
| for (let k = 0; k < byteLength; k++) { | ||
| const offset = (byteLength - k - 1) * bitsPerByte; | ||
| dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset); | ||
| } | ||
| } | ||
| return new Uint8Array(out); | ||
| }; | ||
| const fromUtf8 = (input) => new TextEncoder().encode(input); | ||
| function toBase64(_input) { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| const isArrayLike = typeof input === "object" && typeof input.length === "number"; | ||
| const isUint8Array = typeof input === "object" && | ||
| typeof input.byteOffset === "number" && | ||
| typeof input.byteLength === "number"; | ||
| if (!isArrayLike && !isUint8Array) { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| let str = ""; | ||
| for (let i = 0; i < input.length; i += 3) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) { | ||
| bits |= input[j] << ((limit - j - 1) * bitsPerByte); | ||
| bitLength += bitsPerByte; | ||
| } | ||
| const bitClusterCount = Math.ceil(bitLength / bitsPerLetter); | ||
| bits <<= bitClusterCount * bitsPerLetter - bitLength; | ||
| for (let k = 1; k <= bitClusterCount; k++) { | ||
| const offset = (bitClusterCount - k) * bitsPerLetter; | ||
| str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset]; | ||
| } | ||
| str += "==".slice(0, 4 - bitClusterCount); | ||
| } | ||
| return str; | ||
| } | ||
| function bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| return class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| static fromString(source, encoding = "utf-8") { | ||
| if (typeof source === "string") { | ||
| if (encoding === "base64") { | ||
| return Uint8ArrayBlobAdapter.mutate(fromBase64(source)); | ||
| } | ||
| return Uint8ArrayBlobAdapter.mutate(fromUtf8(source)); | ||
| } | ||
| throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
| } | ||
| static mutate(source) { | ||
| Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
| return source; | ||
| } | ||
| transformToString(encoding = "utf-8") { | ||
| if (encoding === "base64") { | ||
| return toBase64(this); | ||
| } | ||
| return toUtf8(this); | ||
| } | ||
| }; | ||
| } | ||
| const toUtf8 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return new TextDecoder("utf-8").decode(input); | ||
| }; | ||
| const decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0")); | ||
@@ -725,103 +841,2 @@ function bindV4(getRandomValues) { | ||
| const chars = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`; | ||
| const alphabetByEncoding = Object.entries(chars).reduce((acc, [i, c]) => { | ||
| acc[c] = Number(i); | ||
| return acc; | ||
| }, {}); | ||
| const alphabetByValue = chars.split(""); | ||
| const bitsPerLetter = 6; | ||
| const bitsPerByte = 8; | ||
| const maxLetterValue = 0b111111; | ||
| const fromBase64$1 = (input) => { | ||
| let totalByteLength = (input.length / 4) * 3; | ||
| if (input.slice(-2) === "==") { | ||
| totalByteLength -= 2; | ||
| } | ||
| else if (input.slice(-1) === "=") { | ||
| totalByteLength--; | ||
| } | ||
| const out = new ArrayBuffer(totalByteLength); | ||
| const dataView = new DataView(out); | ||
| for (let i = 0; i < input.length; i += 4) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = i + 3; j <= limit; j++) { | ||
| if (input[j] !== "=") { | ||
| if (!(input[j] in alphabetByEncoding)) { | ||
| throw new TypeError(`Invalid character ${input[j]} in base64 string.`); | ||
| } | ||
| bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter); | ||
| bitLength += bitsPerLetter; | ||
| } | ||
| else { | ||
| bits >>= bitsPerLetter; | ||
| } | ||
| } | ||
| const chunkOffset = (i / 4) * 3; | ||
| bits >>= bitLength % bitsPerByte; | ||
| const byteLength = Math.floor(bitLength / bitsPerByte); | ||
| for (let k = 0; k < byteLength; k++) { | ||
| const offset = (byteLength - k - 1) * bitsPerByte; | ||
| dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset); | ||
| } | ||
| } | ||
| return new Uint8Array(out); | ||
| }; | ||
| const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) || | ||
| Object.prototype.toString.call(arg) === "[object ArrayBuffer]"; | ||
| const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => { | ||
| if (!isArrayBuffer(input)) { | ||
| throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`); | ||
| } | ||
| return Buffer.from(input, offset, length); | ||
| }; | ||
| const fromString = (input, encoding) => { | ||
| if (typeof input !== "string") { | ||
| throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`); | ||
| } | ||
| return encoding ? Buffer.from(input, encoding) : Buffer.from(input); | ||
| }; | ||
| const fromUtf8$1 = (input) => { | ||
| const buf = fromString(input, "utf8"); | ||
| return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT); | ||
| }; | ||
| function toBase64$1(_input) { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8$1(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| const isArrayLike = typeof input === "object" && typeof input.length === "number"; | ||
| const isUint8Array = typeof input === "object" && | ||
| typeof input.byteOffset === "number" && | ||
| typeof input.byteLength === "number"; | ||
| if (!isArrayLike && !isUint8Array) { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| let str = ""; | ||
| for (let i = 0; i < input.length; i += 3) { | ||
| let bits = 0; | ||
| let bitLength = 0; | ||
| for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) { | ||
| bits |= input[j] << ((limit - j - 1) * bitsPerByte); | ||
| bitLength += bitsPerByte; | ||
| } | ||
| const bitClusterCount = Math.ceil(bitLength / bitsPerLetter); | ||
| bits <<= bitClusterCount * bitsPerLetter - bitLength; | ||
| for (let k = 1; k <= bitClusterCount; k++) { | ||
| const offset = (bitClusterCount - k) * bitsPerLetter; | ||
| str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset]; | ||
| } | ||
| str += "==".slice(0, 4 - bitClusterCount); | ||
| } | ||
| return str; | ||
| } | ||
| const TEXT_ENCODER = typeof TextEncoder == "function" ? new TextEncoder() : null; | ||
@@ -854,7 +869,5 @@ const calculateBodyLength = (body) => { | ||
| const fromUtf8 = (input) => new TextEncoder().encode(input); | ||
| const toUint8Array = (data) => { | ||
| if (typeof data === "string") { | ||
| return fromUtf8$1(data); | ||
| return fromUtf8(data); | ||
| } | ||
@@ -867,11 +880,4 @@ if (ArrayBuffer.isView(data)) { | ||
| const toUtf8$1 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return new TextDecoder("utf-8").decode(input); | ||
| }; | ||
| const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) || | ||
| Object.prototype.toString.call(arg) === "[object ArrayBuffer]"; | ||
@@ -972,60 +978,2 @@ const deserializerMiddleware = (options, deserializer) => (next, context) => async (args) => { | ||
| const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/; | ||
| const fromBase64 = (input) => { | ||
| if ((input.length * 3) % 4 !== 0) { | ||
| throw new TypeError(`Incorrect padding on base64 string.`); | ||
| } | ||
| if (!BASE64_REGEX.exec(input)) { | ||
| throw new TypeError(`Invalid base64 string.`); | ||
| } | ||
| const buffer = fromString(input, "base64"); | ||
| return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength); | ||
| }; | ||
| const toBase64 = (_input) => { | ||
| let input; | ||
| if (typeof _input === "string") { | ||
| input = fromUtf8$1(_input); | ||
| } | ||
| else { | ||
| input = _input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64"); | ||
| }; | ||
| const toUtf8 = (input) => { | ||
| if (typeof input === "string") { | ||
| return input; | ||
| } | ||
| if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
| throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
| } | ||
| return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8"); | ||
| }; | ||
| class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| static fromString(source, encoding = "utf-8") { | ||
| if (typeof source === "string") { | ||
| if (encoding === "base64") { | ||
| return Uint8ArrayBlobAdapter.mutate(fromBase64(source)); | ||
| } | ||
| return Uint8ArrayBlobAdapter.mutate(fromUtf8$1(source)); | ||
| } | ||
| throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
| } | ||
| static mutate(source) { | ||
| Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
| return source; | ||
| } | ||
| transformToString(encoding = "utf-8") { | ||
| if (encoding === "base64") { | ||
| return toBase64(this); | ||
| } | ||
| return toUtf8(this); | ||
| } | ||
| } | ||
| const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function () { }; | ||
@@ -1384,3 +1332,7 @@ class ChecksumStream extends ReadableStreamRef { | ||
| const no = Symbol.for("node-only"); | ||
| const fromArrayBuffer = no; | ||
| const fromString = no; | ||
| const Hash = no; | ||
| class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| } | ||
| const _getRandomValues = (array) => crypto.getRandomValues(array); | ||
@@ -1418,3 +1370,3 @@ const v4 = bindV4(_getRandomValues); | ||
| exports.fromArrayBuffer = fromArrayBuffer; | ||
| exports.fromBase64 = fromBase64$1; | ||
| exports.fromBase64 = fromBase64; | ||
| exports.fromHex = fromHex; | ||
@@ -1456,6 +1408,6 @@ exports.fromString = fromString; | ||
| exports.strictParseShort = strictParseShort; | ||
| exports.toBase64 = toBase64$1; | ||
| exports.toBase64 = toBase64; | ||
| exports.toHex = toHex; | ||
| exports.toUint8Array = toUint8Array; | ||
| exports.toUtf8 = toUtf8$1; | ||
| exports.toUtf8 = toUtf8; | ||
| exports.v4 = v4; |
@@ -86,3 +86,3 @@ import { getSmithyContext } from "@smithy/core/client"; | ||
| const message = dataObject.message ?? dataObject.Message ?? "Unknown"; | ||
| const exception = new ErrorCtor(message); | ||
| const exception = new ErrorCtor({}); | ||
| const output = {}; | ||
@@ -89,0 +89,0 @@ for (const [name, member] of ns.structIterator()) { |
@@ -0,1 +1,6 @@ | ||
| import { fromBase64 } from "./util-base64/fromBase64.browser"; | ||
| import { toBase64 } from "./util-base64/toBase64.browser"; | ||
| import { bindUint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| import { fromUtf8 } from "./util-utf8/fromUtf8.browser"; | ||
| import { toUtf8 } from "./util-utf8/toUtf8.browser"; | ||
| import { bindV4 } from "./uuid/v4"; | ||
@@ -13,9 +18,8 @@ const no = Symbol.for("node-only"); | ||
| export { fromHex, toHex } from "./util-hex-encoding/hex-encoding"; | ||
| export { fromBase64 } from "./util-base64/fromBase64.browser"; | ||
| export { toBase64 } from "./util-base64/toBase64.browser"; | ||
| export { toBase64, fromBase64 }; | ||
| export { calculateBodyLength } from "./util-body-length/calculateBodyLength.browser"; | ||
| export { fromUtf8 } from "./util-utf8/fromUtf8.browser"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array"; | ||
| export { toUtf8 } from "./util-utf8/toUtf8.browser"; | ||
| export { fromArrayBuffer, fromString } from "./util-buffer-from/buffer-from"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array.browser"; | ||
| export { toUtf8, fromUtf8 }; | ||
| export const fromArrayBuffer = no; | ||
| export const fromString = no; | ||
| export { isArrayBuffer } from "./is-array-buffer/is-array-buffer"; | ||
@@ -26,3 +30,4 @@ export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware"; | ||
| export const Hash = no; | ||
| export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| export class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| } | ||
| export { ChecksumStream } from "./util-stream/checksum/ChecksumStream.browser"; | ||
@@ -29,0 +34,0 @@ export { createChecksumStream } from "./util-stream/checksum/createChecksumStream.browser"; |
| import { getRandomValues } from "node:crypto"; | ||
| import { fromBase64 } from "./util-base64/fromBase64"; | ||
| import { toBase64 } from "./util-base64/toBase64"; | ||
| import { bindUint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| import { fromUtf8 } from "./util-utf8/fromUtf8"; | ||
| import { toUtf8 } from "./util-utf8/toUtf8"; | ||
| import { bindV4 } from "./uuid/v4"; | ||
@@ -13,8 +18,6 @@ export { copyDocumentWithTransform } from "./copyDocumentWithTransform"; | ||
| export { fromHex, toHex } from "./util-hex-encoding/hex-encoding"; | ||
| export { fromBase64 } from "./util-base64/fromBase64"; | ||
| export { toBase64 } from "./util-base64/toBase64"; | ||
| export { toBase64, fromBase64 }; | ||
| export { calculateBodyLength } from "./util-body-length/calculateBodyLength"; | ||
| export { fromUtf8 } from "./util-utf8/fromUtf8"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array"; | ||
| export { toUtf8 } from "./util-utf8/toUtf8"; | ||
| export { toUtf8, fromUtf8 }; | ||
| export { fromArrayBuffer, fromString } from "./util-buffer-from/buffer-from"; | ||
@@ -26,3 +29,4 @@ export { isArrayBuffer } from "./is-array-buffer/is-array-buffer"; | ||
| export { Hash } from "./hash-node/hash-node"; | ||
| export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| export class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| } | ||
| export { ChecksumStream } from "./util-stream/checksum/ChecksumStream"; | ||
@@ -29,0 +33,0 @@ export { createChecksumStream } from "./util-stream/checksum/createChecksumStream"; |
@@ -0,1 +1,6 @@ | ||
| import { fromBase64 } from "./util-base64/fromBase64.browser"; | ||
| import { toBase64 } from "./util-base64/toBase64.browser"; | ||
| import { bindUint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| import { fromUtf8 } from "./util-utf8/fromUtf8.browser"; | ||
| import { toUtf8 } from "./util-utf8/toUtf8.browser"; | ||
| import { bindV4 } from "./uuid/v4"; | ||
@@ -17,5 +22,6 @@ const no = Symbol.for("node-only"); | ||
| export { fromUtf8 } from "./util-utf8/fromUtf8.browser"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array.browser"; | ||
| export { toUtf8 } from "./util-utf8/toUtf8.browser"; | ||
| export { fromArrayBuffer, fromString } from "./util-buffer-from/buffer-from"; | ||
| export const fromArrayBuffer = no; | ||
| export const fromString = no; | ||
| export { isArrayBuffer } from "./is-array-buffer/is-array-buffer"; | ||
@@ -26,3 +32,4 @@ export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware"; | ||
| export const Hash = no; | ||
| export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| export class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| } | ||
| export { ChecksumStream } from "./util-stream/checksum/ChecksumStream.browser"; | ||
@@ -29,0 +36,0 @@ export { createChecksumStream } from "./util-stream/checksum/createChecksumStream.browser"; |
@@ -1,2 +0,2 @@ | ||
| import { fromUtf8 } from "../util-utf8/fromUtf8"; | ||
| import { fromUtf8 } from "../util-utf8/fromUtf8.browser"; | ||
| import { alphabetByValue, bitsPerByte, bitsPerLetter, maxLetterValue } from "./constants-for-browser"; | ||
@@ -3,0 +3,0 @@ export function toBase64(_input) { |
@@ -1,25 +0,23 @@ | ||
| import { fromBase64 } from "../../util-base64/fromBase64"; | ||
| import { toBase64 } from "../../util-base64/toBase64"; | ||
| import { fromUtf8 } from "../../util-utf8/fromUtf8"; | ||
| import { toUtf8 } from "../../util-utf8/toUtf8"; | ||
| export class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| static fromString(source, encoding = "utf-8") { | ||
| if (typeof source === "string") { | ||
| export function bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) { | ||
| return class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| static fromString(source, encoding = "utf-8") { | ||
| if (typeof source === "string") { | ||
| if (encoding === "base64") { | ||
| return Uint8ArrayBlobAdapter.mutate(fromBase64(source)); | ||
| } | ||
| return Uint8ArrayBlobAdapter.mutate(fromUtf8(source)); | ||
| } | ||
| throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
| } | ||
| static mutate(source) { | ||
| Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
| return source; | ||
| } | ||
| transformToString(encoding = "utf-8") { | ||
| if (encoding === "base64") { | ||
| return Uint8ArrayBlobAdapter.mutate(fromBase64(source)); | ||
| return toBase64(this); | ||
| } | ||
| return Uint8ArrayBlobAdapter.mutate(fromUtf8(source)); | ||
| return toUtf8(this); | ||
| } | ||
| throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
| } | ||
| static mutate(source) { | ||
| Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
| return source; | ||
| } | ||
| transformToString(encoding = "utf-8") { | ||
| if (encoding === "base64") { | ||
| return toBase64(this); | ||
| } | ||
| return toUtf8(this); | ||
| } | ||
| }; | ||
| } |
@@ -1,2 +0,2 @@ | ||
| import { toBase64 } from "../../util-base64/toBase64"; | ||
| import { toBase64 } from "../../util-base64/toBase64.browser"; | ||
| import { isReadableStream } from "../stream-type-check"; | ||
@@ -3,0 +3,0 @@ import { ChecksumStream } from "./ChecksumStream.browser"; |
@@ -1,4 +0,4 @@ | ||
| import { toBase64 } from "../util-base64/toBase64"; | ||
| import { toBase64 } from "../util-base64/toBase64.browser"; | ||
| import { toHex } from "../util-hex-encoding/hex-encoding"; | ||
| import { toUtf8 } from "../util-utf8/toUtf8"; | ||
| import { toUtf8 } from "../util-utf8/toUtf8.browser"; | ||
| import { streamCollector } from "./stream-collector.browser"; | ||
@@ -5,0 +5,0 @@ import { isReadableStream } from "./stream-type-check"; |
@@ -1,2 +0,2 @@ | ||
| import { fromBase64 } from "../util-base64/fromBase64"; | ||
| import { fromBase64 } from "../util-base64/fromBase64.browser"; | ||
| export const streamCollector = async (stream) => { | ||
@@ -3,0 +3,0 @@ if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") { |
@@ -0,1 +1,5 @@ | ||
| import { fromBase64 } from "./util-base64/fromBase64.browser"; | ||
| import { toBase64 } from "./util-base64/toBase64.browser"; | ||
| import { fromUtf8 } from "./util-utf8/fromUtf8.browser"; | ||
| import { toUtf8 } from "./util-utf8/toUtf8.browser"; | ||
| export { copyDocumentWithTransform } from "./copyDocumentWithTransform"; | ||
@@ -11,9 +15,9 @@ export { dateToUtcString, parseRfc3339DateTime, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, parseEpochTimestamp, } from "./date-utils"; | ||
| export { fromHex, toHex } from "./util-hex-encoding/hex-encoding"; | ||
| export { fromBase64 } from "./util-base64/fromBase64.browser"; | ||
| export { toBase64 } from "./util-base64/toBase64.browser"; | ||
| export { toBase64, fromBase64 }; | ||
| export { calculateBodyLength } from "./util-body-length/calculateBodyLength.browser"; | ||
| export { fromUtf8 } from "./util-utf8/fromUtf8.browser"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array"; | ||
| export { toUtf8 } from "./util-utf8/toUtf8.browser"; | ||
| export { fromArrayBuffer, fromString, type StringEncoding } from "./util-buffer-from/buffer-from"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array.browser"; | ||
| export { toUtf8, fromUtf8 }; | ||
| export { type StringEncoding } from "./util-buffer-from/buffer-from"; | ||
| export declare const fromArrayBuffer: symbol; | ||
| export declare const fromString: symbol; | ||
| export { isArrayBuffer } from "./is-array-buffer/is-array-buffer"; | ||
@@ -24,3 +28,5 @@ export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware"; | ||
| export declare const Hash: symbol; | ||
| export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| declare const Uint8ArrayBlobAdapter_base: import("./util-stream/blob/Uint8ArrayBlobAdapter").Uint8ArrayBlobAdapterConstructor; | ||
| export declare class Uint8ArrayBlobAdapter extends Uint8ArrayBlobAdapter_base { | ||
| } | ||
| export { ChecksumStream, type ChecksumStreamInit } from "./util-stream/checksum/ChecksumStream.browser"; | ||
@@ -27,0 +33,0 @@ export { createChecksumStream } from "./util-stream/checksum/createChecksumStream.browser"; |
@@ -0,1 +1,5 @@ | ||
| import { fromBase64 } from "./util-base64/fromBase64"; | ||
| import { toBase64 } from "./util-base64/toBase64"; | ||
| import { fromUtf8 } from "./util-utf8/fromUtf8"; | ||
| import { toUtf8 } from "./util-utf8/toUtf8"; | ||
| export { copyDocumentWithTransform } from "./copyDocumentWithTransform"; | ||
@@ -11,8 +15,6 @@ export { dateToUtcString, parseRfc3339DateTime, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, parseEpochTimestamp, } from "./date-utils"; | ||
| export { fromHex, toHex } from "./util-hex-encoding/hex-encoding"; | ||
| export { fromBase64 } from "./util-base64/fromBase64"; | ||
| export { toBase64 } from "./util-base64/toBase64"; | ||
| export { toBase64, fromBase64 }; | ||
| export { calculateBodyLength } from "./util-body-length/calculateBodyLength"; | ||
| export { fromUtf8 } from "./util-utf8/fromUtf8"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array"; | ||
| export { toUtf8 } from "./util-utf8/toUtf8"; | ||
| export { toUtf8, fromUtf8 }; | ||
| export { fromArrayBuffer, fromString, type StringEncoding } from "./util-buffer-from/buffer-from"; | ||
@@ -24,3 +26,5 @@ export { isArrayBuffer } from "./is-array-buffer/is-array-buffer"; | ||
| export { Hash } from "./hash-node/hash-node"; | ||
| export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| declare const Uint8ArrayBlobAdapter_base: import("./util-stream/blob/Uint8ArrayBlobAdapter").Uint8ArrayBlobAdapterConstructor; | ||
| export declare class Uint8ArrayBlobAdapter extends Uint8ArrayBlobAdapter_base { | ||
| } | ||
| export { ChecksumStream, type ChecksumStreamInit } from "./util-stream/checksum/ChecksumStream"; | ||
@@ -27,0 +31,0 @@ export { createChecksumStream } from "./util-stream/checksum/createChecksumStream"; |
@@ -15,5 +15,7 @@ export { copyDocumentWithTransform } from "./copyDocumentWithTransform"; | ||
| export { fromUtf8 } from "./util-utf8/fromUtf8.browser"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array"; | ||
| export { toUint8Array } from "./util-utf8/toUint8Array.browser"; | ||
| export { toUtf8 } from "./util-utf8/toUtf8.browser"; | ||
| export { fromArrayBuffer, fromString, type StringEncoding } from "./util-buffer-from/buffer-from"; | ||
| export { type StringEncoding } from "./util-buffer-from/buffer-from"; | ||
| export declare const fromArrayBuffer: symbol; | ||
| export declare const fromString: symbol; | ||
| export { isArrayBuffer } from "./is-array-buffer/is-array-buffer"; | ||
@@ -24,3 +26,5 @@ export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware"; | ||
| export declare const Hash: symbol; | ||
| export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter"; | ||
| declare const Uint8ArrayBlobAdapter_base: import("./util-stream/blob/Uint8ArrayBlobAdapter").Uint8ArrayBlobAdapterConstructor; | ||
| export declare class Uint8ArrayBlobAdapter extends Uint8ArrayBlobAdapter_base { | ||
| } | ||
| export { ChecksumStream, type ChecksumStreamInit } from "./util-stream/checksum/ChecksumStream.browser"; | ||
@@ -27,0 +31,0 @@ export { createChecksumStream } from "./util-stream/checksum/createChecksumStream.browser"; |
@@ -0,1 +1,2 @@ | ||
| import type { Decoder, Encoder } from "@smithy/types"; | ||
| /** | ||
@@ -5,15 +6,4 @@ * Adapter for conversions of the native Uint8Array type. | ||
| */ | ||
| export declare class Uint8ArrayBlobAdapter extends Uint8Array { | ||
| export interface IUint8ArrayBlobAdapter extends Uint8Array { | ||
| /** | ||
| * @param source - such as a string or Stream. | ||
| * @param encoding - utf-8 or base64. | ||
| * @returns a new Uint8ArrayBlobAdapter extending Uint8Array. | ||
| */ | ||
| static fromString(source: string, encoding?: string): Uint8ArrayBlobAdapter; | ||
| /** | ||
| * @param source - Uint8Array to be mutated. | ||
| * @returns the same Uint8Array but with prototype switched to Uint8ArrayBlobAdapter. | ||
| */ | ||
| static mutate(source: Uint8Array): Uint8ArrayBlobAdapter; | ||
| /** | ||
| * @param encoding - default 'utf-8'. | ||
@@ -24,1 +14,7 @@ * @returns the blob as string. | ||
| } | ||
| export interface Uint8ArrayBlobAdapterConstructor { | ||
| new (...args: any): IUint8ArrayBlobAdapter; | ||
| fromString(source: string, encoding?: string): IUint8ArrayBlobAdapter; | ||
| mutate(source: Uint8Array): IUint8ArrayBlobAdapter; | ||
| } | ||
| export declare function bindUint8ArrayBlobAdapter(toUtf8: Encoder, fromUtf8: Decoder, toBase64: Encoder, fromBase64: Decoder): Uint8ArrayBlobAdapterConstructor; |
+1
-1
| { | ||
| "name": "@smithy/core", | ||
| "version": "3.24.1", | ||
| "version": "3.24.2", | ||
| "scripts": { | ||
@@ -5,0 +5,0 @@ "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1338802
0.14%747
0.27%33185
0.13%0
-100%