@smithy/core 3.24.1 → 3.24.3

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.
@@ -83,7 +83,7 @@ export class SmithyRpcV2CborProtocol extends RpcProtocol {
83
83
  const ns = NormalizedSchema.of(errorSchema);
84
84
  const ErrorCtor = registry.getErrorCtor(errorSchema);
85
85
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
86
- const exception = new ErrorCtor(message);
86
+ const exception = new ErrorCtor({});
87
87
  const output = {};
88
88
  for (const [name, member] of ns.structIterator()) {
89
89
  output[name] = this.deserializer.readValue(member, dataObject[name]);
@@ -1,3 +1,8 @@
1
+ import { fromBase64 } from "./util-base64/fromBase64.browser";
2
+ import { toBase64 } from "./util-base64/toBase64.browser";
3
+ import { bindUint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
4
+ import { fromUtf8 } from "./util-utf8/fromUtf8.browser";
5
+ import { toUtf8 } from "./util-utf8/toUtf8.browser";
1
6
  import { bindV4 } from "./uuid/v4";
2
7
  const no = Symbol.for("node-only");
3
8
  export { copyDocumentWithTransform } from "./copyDocumentWithTransform";
@@ -10,19 +15,19 @@ export { splitEvery } from "./split-every";
10
15
  export { splitHeader } from "./split-header";
11
16
  export { NumericValue, nv } from "./value/NumericValue";
12
17
  export { fromHex, toHex } from "./util-hex-encoding/hex-encoding";
13
- export { fromBase64 } from "./util-base64/fromBase64.browser";
14
- export { toBase64 } from "./util-base64/toBase64.browser";
18
+ export { toBase64, fromBase64 };
15
19
  export { calculateBodyLength } from "./util-body-length/calculateBodyLength.browser";
16
- export { fromUtf8 } from "./util-utf8/fromUtf8.browser";
17
- export { toUint8Array } from "./util-utf8/toUint8Array";
18
- export { toUtf8 } from "./util-utf8/toUtf8.browser";
19
- export { fromArrayBuffer, fromString } from "./util-buffer-from/buffer-from";
20
+ export { toUint8Array } from "./util-utf8/toUint8Array.browser";
21
+ export { toUtf8, fromUtf8 };
22
+ export const fromArrayBuffer = no;
23
+ export const fromString = no;
20
24
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
21
25
  export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware";
22
26
  export { deserializerMiddlewareOption, serializerMiddlewareOption, getSerdePlugin, } from "./middleware-serde/serdePlugin";
23
27
  export { serializerMiddleware } from "./middleware-serde/serializerMiddleware";
24
28
  export const Hash = no;
25
- export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
29
+ export class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) {
30
+ }
26
31
  export { ChecksumStream } from "./util-stream/checksum/ChecksumStream.browser";
27
32
  export { createChecksumStream } from "./util-stream/checksum/createChecksumStream.browser";
28
33
  export { createBufferedReadable } from "./util-stream/createBufferedReadable.browser";
@@ -1,4 +1,9 @@
1
1
  import { getRandomValues } from "node:crypto";
2
+ import { fromBase64 } from "./util-base64/fromBase64";
3
+ import { toBase64 } from "./util-base64/toBase64";
4
+ import { bindUint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
5
+ import { fromUtf8 } from "./util-utf8/fromUtf8";
6
+ import { toUtf8 } from "./util-utf8/toUtf8";
2
7
  import { bindV4 } from "./uuid/v4";
3
8
  export { copyDocumentWithTransform } from "./copyDocumentWithTransform";
4
9
  export { dateToUtcString, parseRfc3339DateTime, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, parseEpochTimestamp, } from "./date-utils";
@@ -10,19 +15,18 @@ export { splitEvery } from "./split-every";
10
15
  export { splitHeader } from "./split-header";
11
16
  export { NumericValue, nv } from "./value/NumericValue";
12
17
  export { fromHex, toHex } from "./util-hex-encoding/hex-encoding";
13
- export { fromBase64 } from "./util-base64/fromBase64";
14
- export { toBase64 } from "./util-base64/toBase64";
18
+ export { toBase64, fromBase64 };
15
19
  export { calculateBodyLength } from "./util-body-length/calculateBodyLength";
16
- export { fromUtf8 } from "./util-utf8/fromUtf8";
17
20
  export { toUint8Array } from "./util-utf8/toUint8Array";
18
- export { toUtf8 } from "./util-utf8/toUtf8";
21
+ export { toUtf8, fromUtf8 };
19
22
  export { fromArrayBuffer, fromString } from "./util-buffer-from/buffer-from";
20
23
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
21
24
  export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware";
22
25
  export { deserializerMiddlewareOption, serializerMiddlewareOption, getSerdePlugin, } from "./middleware-serde/serdePlugin";
23
26
  export { serializerMiddleware } from "./middleware-serde/serializerMiddleware";
24
27
  export { Hash } from "./hash-node/hash-node";
25
- export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
28
+ export class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) {
29
+ }
26
30
  export { ChecksumStream } from "./util-stream/checksum/ChecksumStream";
27
31
  export { createChecksumStream } from "./util-stream/checksum/createChecksumStream";
28
32
  export { createBufferedReadable } from "./util-stream/createBufferedReadable";
@@ -1,3 +1,8 @@
1
+ import { fromBase64 } from "./util-base64/fromBase64.browser";
2
+ import { toBase64 } from "./util-base64/toBase64.browser";
3
+ import { bindUint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
4
+ import { fromUtf8 } from "./util-utf8/fromUtf8.browser";
5
+ import { toUtf8 } from "./util-utf8/toUtf8.browser";
1
6
  import { bindV4 } from "./uuid/v4";
2
7
  const no = Symbol.for("node-only");
3
8
  export { copyDocumentWithTransform } from "./copyDocumentWithTransform";
@@ -14,15 +19,17 @@ export { fromBase64 } from "./util-base64/fromBase64.browser";
14
19
  export { toBase64 } from "./util-base64/toBase64.browser";
15
20
  export { calculateBodyLength } from "./util-body-length/calculateBodyLength.browser";
16
21
  export { fromUtf8 } from "./util-utf8/fromUtf8.browser";
17
- export { toUint8Array } from "./util-utf8/toUint8Array";
22
+ export { toUint8Array } from "./util-utf8/toUint8Array.browser";
18
23
  export { toUtf8 } from "./util-utf8/toUtf8.browser";
19
- export { fromArrayBuffer, fromString } from "./util-buffer-from/buffer-from";
24
+ export const fromArrayBuffer = no;
25
+ export const fromString = no;
20
26
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
21
27
  export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware";
22
28
  export { deserializerMiddlewareOption, serializerMiddlewareOption, getSerdePlugin, } from "./middleware-serde/serdePlugin";
23
29
  export { serializerMiddleware } from "./middleware-serde/serializerMiddleware";
24
30
  export const Hash = no;
25
- export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
31
+ export class Uint8ArrayBlobAdapter extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) {
32
+ }
26
33
  export { ChecksumStream } from "./util-stream/checksum/ChecksumStream.browser";
27
34
  export { createChecksumStream } from "./util-stream/checksum/createChecksumStream.browser";
28
35
  export { createBufferedReadable } from "./util-stream/createBufferedReadable.browser";
@@ -1,4 +1,4 @@
1
- import { fromUtf8 } from "../util-utf8/fromUtf8";
1
+ import { fromUtf8 } from "../util-utf8/fromUtf8.browser";
2
2
  import { alphabetByValue, bitsPerByte, bitsPerLetter, maxLetterValue } from "./constants-for-browser";
3
3
  export function toBase64(_input) {
4
4
  let input;
@@ -1,25 +1,23 @@
1
- import { fromBase64 } from "../../util-base64/fromBase64";
2
- import { toBase64 } from "../../util-base64/toBase64";
3
- import { fromUtf8 } from "../../util-utf8/fromUtf8";
4
- import { toUtf8 } from "../../util-utf8/toUtf8";
5
- export class Uint8ArrayBlobAdapter extends Uint8Array {
6
- static fromString(source, encoding = "utf-8") {
7
- if (typeof source === "string") {
8
- if (encoding === "base64") {
9
- return Uint8ArrayBlobAdapter.mutate(fromBase64(source));
1
+ export function bindUint8ArrayBlobAdapter(toUtf8, fromUtf8, toBase64, fromBase64) {
2
+ return class Uint8ArrayBlobAdapter extends Uint8Array {
3
+ static fromString(source, encoding = "utf-8") {
4
+ if (typeof source === "string") {
5
+ if (encoding === "base64") {
6
+ return Uint8ArrayBlobAdapter.mutate(fromBase64(source));
7
+ }
8
+ return Uint8ArrayBlobAdapter.mutate(fromUtf8(source));
10
9
  }
11
- return Uint8ArrayBlobAdapter.mutate(fromUtf8(source));
10
+ throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
11
+ }
12
+ static mutate(source) {
13
+ Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype);
14
+ return source;
12
15
  }
13
- throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
14
- }
15
- static mutate(source) {
16
- Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype);
17
- return source;
18
- }
19
- transformToString(encoding = "utf-8") {
20
- if (encoding === "base64") {
21
- return toBase64(this);
16
+ transformToString(encoding = "utf-8") {
17
+ if (encoding === "base64") {
18
+ return toBase64(this);
19
+ }
20
+ return toUtf8(this);
22
21
  }
23
- return toUtf8(this);
24
- }
22
+ };
25
23
  }
@@ -1,4 +1,4 @@
1
- import { toBase64 } from "../../util-base64/toBase64";
1
+ import { toBase64 } from "../../util-base64/toBase64.browser";
2
2
  import { isReadableStream } from "../stream-type-check";
3
3
  import { ChecksumStream } from "./ChecksumStream.browser";
4
4
  export const createChecksumStream = ({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }) => {
@@ -1,6 +1,6 @@
1
- import { toBase64 } from "../util-base64/toBase64";
1
+ import { toBase64 } from "../util-base64/toBase64.browser";
2
2
  import { toHex } from "../util-hex-encoding/hex-encoding";
3
- import { toUtf8 } from "../util-utf8/toUtf8";
3
+ import { toUtf8 } from "../util-utf8/toUtf8.browser";
4
4
  import { streamCollector } from "./stream-collector.browser";
5
5
  import { isReadableStream } from "./stream-type-check";
6
6
  const ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
@@ -1,4 +1,4 @@
1
- import { fromBase64 } from "../util-base64/fromBase64";
1
+ import { fromBase64 } from "../util-base64/fromBase64.browser";
2
2
  export const streamCollector = async (stream) => {
3
3
  if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") {
4
4
  if (Blob.prototype.arrayBuffer !== undefined) {
@@ -0,0 +1,10 @@
1
+ import { fromUtf8 } from "./fromUtf8.browser";
2
+ export const toUint8Array = (data) => {
3
+ if (typeof data === "string") {
4
+ return fromUtf8(data);
5
+ }
6
+ if (ArrayBuffer.isView(data)) {
7
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
8
+ }
9
+ return new Uint8Array(data);
10
+ };
@@ -1,3 +1,7 @@
1
+ import { fromBase64 } from "./util-base64/fromBase64.browser";
2
+ import { toBase64 } from "./util-base64/toBase64.browser";
3
+ import { fromUtf8 } from "./util-utf8/fromUtf8.browser";
4
+ import { toUtf8 } from "./util-utf8/toUtf8.browser";
1
5
  export { copyDocumentWithTransform } from "./copyDocumentWithTransform";
2
6
  export { dateToUtcString, parseRfc3339DateTime, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, parseEpochTimestamp, } from "./date-utils";
3
7
  export { LazyJsonString, type AutomaticJsonStringConversion } from "./lazy-json";
@@ -8,19 +12,21 @@ export { splitEvery } from "./split-every";
8
12
  export { splitHeader } from "./split-header";
9
13
  export { NumericValue, nv, type NumericType } from "./value/NumericValue";
10
14
  export { fromHex, toHex } from "./util-hex-encoding/hex-encoding";
11
- export { fromBase64 } from "./util-base64/fromBase64.browser";
12
- export { toBase64 } from "./util-base64/toBase64.browser";
15
+ export { toBase64, fromBase64 };
13
16
  export { calculateBodyLength } from "./util-body-length/calculateBodyLength.browser";
14
- export { fromUtf8 } from "./util-utf8/fromUtf8.browser";
15
- export { toUint8Array } from "./util-utf8/toUint8Array";
16
- export { toUtf8 } from "./util-utf8/toUtf8.browser";
17
- export { fromArrayBuffer, fromString, type StringEncoding } from "./util-buffer-from/buffer-from";
17
+ export { toUint8Array } from "./util-utf8/toUint8Array.browser";
18
+ export { toUtf8, fromUtf8 };
19
+ export { type StringEncoding } from "./util-buffer-from/buffer-from";
20
+ export declare const fromArrayBuffer: symbol;
21
+ export declare const fromString: symbol;
18
22
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
19
23
  export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware";
20
24
  export { deserializerMiddlewareOption, serializerMiddlewareOption, getSerdePlugin, type V1OrV2Endpoint, } from "./middleware-serde/serdePlugin";
21
25
  export { serializerMiddleware } from "./middleware-serde/serializerMiddleware";
22
26
  export declare const Hash: symbol;
23
- export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
27
+ declare const Uint8ArrayBlobAdapter_base: import("./util-stream/blob/Uint8ArrayBlobAdapter").Uint8ArrayBlobAdapterConstructor;
28
+ export declare class Uint8ArrayBlobAdapter extends Uint8ArrayBlobAdapter_base {
29
+ }
24
30
  export { ChecksumStream, type ChecksumStreamInit } from "./util-stream/checksum/ChecksumStream.browser";
25
31
  export { createChecksumStream } from "./util-stream/checksum/createChecksumStream.browser";
26
32
  export { createBufferedReadable } from "./util-stream/createBufferedReadable.browser";
@@ -1,3 +1,7 @@
1
+ import { fromBase64 } from "./util-base64/fromBase64";
2
+ import { toBase64 } from "./util-base64/toBase64";
3
+ import { fromUtf8 } from "./util-utf8/fromUtf8";
4
+ import { toUtf8 } from "./util-utf8/toUtf8";
1
5
  export { copyDocumentWithTransform } from "./copyDocumentWithTransform";
2
6
  export { dateToUtcString, parseRfc3339DateTime, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, parseEpochTimestamp, } from "./date-utils";
3
7
  export { LazyJsonString, type AutomaticJsonStringConversion } from "./lazy-json";
@@ -8,19 +12,19 @@ export { splitEvery } from "./split-every";
8
12
  export { splitHeader } from "./split-header";
9
13
  export { NumericValue, nv, type NumericType } from "./value/NumericValue";
10
14
  export { fromHex, toHex } from "./util-hex-encoding/hex-encoding";
11
- export { fromBase64 } from "./util-base64/fromBase64";
12
- export { toBase64 } from "./util-base64/toBase64";
15
+ export { toBase64, fromBase64 };
13
16
  export { calculateBodyLength } from "./util-body-length/calculateBodyLength";
14
- export { fromUtf8 } from "./util-utf8/fromUtf8";
15
17
  export { toUint8Array } from "./util-utf8/toUint8Array";
16
- export { toUtf8 } from "./util-utf8/toUtf8";
18
+ export { toUtf8, fromUtf8 };
17
19
  export { fromArrayBuffer, fromString, type StringEncoding } from "./util-buffer-from/buffer-from";
18
20
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
19
21
  export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware";
20
22
  export { deserializerMiddlewareOption, serializerMiddlewareOption, getSerdePlugin, type V1OrV2Endpoint, } from "./middleware-serde/serdePlugin";
21
23
  export { serializerMiddleware } from "./middleware-serde/serializerMiddleware";
22
24
  export { Hash } from "./hash-node/hash-node";
23
- export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
25
+ declare const Uint8ArrayBlobAdapter_base: import("./util-stream/blob/Uint8ArrayBlobAdapter").Uint8ArrayBlobAdapterConstructor;
26
+ export declare class Uint8ArrayBlobAdapter extends Uint8ArrayBlobAdapter_base {
27
+ }
24
28
  export { ChecksumStream, type ChecksumStreamInit } from "./util-stream/checksum/ChecksumStream";
25
29
  export { createChecksumStream } from "./util-stream/checksum/createChecksumStream";
26
30
  export { createBufferedReadable } from "./util-stream/createBufferedReadable";
@@ -12,15 +12,19 @@ export { fromBase64 } from "./util-base64/fromBase64.browser";
12
12
  export { toBase64 } from "./util-base64/toBase64.browser";
13
13
  export { calculateBodyLength } from "./util-body-length/calculateBodyLength.browser";
14
14
  export { fromUtf8 } from "./util-utf8/fromUtf8.browser";
15
- export { toUint8Array } from "./util-utf8/toUint8Array";
15
+ export { toUint8Array } from "./util-utf8/toUint8Array.browser";
16
16
  export { toUtf8 } from "./util-utf8/toUtf8.browser";
17
- export { fromArrayBuffer, fromString, type StringEncoding } from "./util-buffer-from/buffer-from";
17
+ export { type StringEncoding } from "./util-buffer-from/buffer-from";
18
+ export declare const fromArrayBuffer: symbol;
19
+ export declare const fromString: symbol;
18
20
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
19
21
  export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware";
20
22
  export { deserializerMiddlewareOption, serializerMiddlewareOption, getSerdePlugin, type V1OrV2Endpoint, } from "./middleware-serde/serdePlugin";
21
23
  export { serializerMiddleware } from "./middleware-serde/serializerMiddleware";
22
24
  export declare const Hash: symbol;
23
- export { Uint8ArrayBlobAdapter } from "./util-stream/blob/Uint8ArrayBlobAdapter";
25
+ declare const Uint8ArrayBlobAdapter_base: import("./util-stream/blob/Uint8ArrayBlobAdapter").Uint8ArrayBlobAdapterConstructor;
26
+ export declare class Uint8ArrayBlobAdapter extends Uint8ArrayBlobAdapter_base {
27
+ }
24
28
  export { ChecksumStream, type ChecksumStreamInit } from "./util-stream/checksum/ChecksumStream.browser";
25
29
  export { createChecksumStream } from "./util-stream/checksum/createChecksumStream.browser";
26
30
  export { createBufferedReadable } from "./util-stream/createBufferedReadable.browser";
@@ -1,22 +1,18 @@
1
+ import type { Decoder, Encoder } from "@smithy/types";
1
2
  /**
2
3
  * Adapter for conversions of the native Uint8Array type.
3
4
  * @public
4
5
  */
5
- export declare class Uint8ArrayBlobAdapter extends Uint8Array {
6
- /**
7
- * @param source - such as a string or Stream.
8
- * @param encoding - utf-8 or base64.
9
- * @returns a new Uint8ArrayBlobAdapter extending Uint8Array.
10
- */
11
- static fromString(source: string, encoding?: string): Uint8ArrayBlobAdapter;
12
- /**
13
- * @param source - Uint8Array to be mutated.
14
- * @returns the same Uint8Array but with prototype switched to Uint8ArrayBlobAdapter.
15
- */
16
- static mutate(source: Uint8Array): Uint8ArrayBlobAdapter;
6
+ export interface IUint8ArrayBlobAdapter extends Uint8Array {
17
7
  /**
18
8
  * @param encoding - default 'utf-8'.
19
9
  * @returns the blob as string.
20
10
  */
21
11
  transformToString(encoding?: string): string;
22
12
  }
13
+ export interface Uint8ArrayBlobAdapterConstructor {
14
+ new (...args: any): IUint8ArrayBlobAdapter;
15
+ fromString(source: string, encoding?: string): IUint8ArrayBlobAdapter;
16
+ mutate(source: Uint8Array): IUint8ArrayBlobAdapter;
17
+ }
18
+ export declare function bindUint8ArrayBlobAdapter(toUtf8: Encoder, fromUtf8: Decoder, toBase64: Encoder, fromBase64: Decoder): Uint8ArrayBlobAdapterConstructor;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const toUint8Array: (data: string | ArrayBuffer | ArrayBufferView) => Uint8Array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.24.1",
3
+ "version": "3.24.3",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
6
6
  "build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline core",
@@ -162,7 +162,7 @@
162
162
  "sideEffects": false,
163
163
  "dependencies": {
164
164
  "@aws-crypto/crc32": "5.2.0",
165
- "@smithy/types": "^4.14.1",
165
+ "@smithy/types": "^4.14.2",
166
166
  "tslib": "^2.6.2"
167
167
  },
168
168
  "engines": {