@smithy/core 2.3.2 → 2.4.1
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/cbor.js +6 -0
- package/dist-cjs/submodules/cbor/index.js +707 -0
- package/dist-es/submodules/cbor/cbor-decode.js +391 -0
- package/dist-es/submodules/cbor/cbor-encode.js +181 -0
- package/dist-es/submodules/cbor/cbor-types.js +20 -0
- package/dist-es/submodules/cbor/cbor.js +15 -0
- package/dist-es/submodules/cbor/index.js +2 -0
- package/dist-es/submodules/cbor/parseCborBody.js +82 -0
- package/dist-types/submodules/cbor/cbor-decode.d.ts +17 -0
- package/dist-types/submodules/cbor/cbor-encode.d.ts +9 -0
- package/dist-types/submodules/cbor/cbor-types.d.ts +40 -0
- package/dist-types/submodules/cbor/cbor.d.ts +26 -0
- package/dist-types/submodules/cbor/index.d.ts +2 -0
- package/dist-types/submodules/cbor/parseCborBody.d.ts +29 -0
- package/dist-types/ts3.4/submodules/cbor/cbor-decode.d.ts +17 -0
- package/dist-types/ts3.4/submodules/cbor/cbor-encode.d.ts +9 -0
- package/dist-types/ts3.4/submodules/cbor/cbor-types.d.ts +43 -0
- package/dist-types/ts3.4/submodules/cbor/cbor.d.ts +26 -0
- package/dist-types/ts3.4/submodules/cbor/index.d.ts +2 -0
- package/dist-types/ts3.4/submodules/cbor/parseCborBody.d.ts +29 -0
- package/package.json +22 -10
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CborValueType, Float32, Uint8, Uint32 } from "./cbor-types";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* @param bytes - to be set as the decode source.
|
|
5
|
+
*
|
|
6
|
+
* Sets the decode bytearray source and its data view.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setPayload(bytes: Uint8Array): void;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* Decodes the data between the two indices.
|
|
12
|
+
*/
|
|
13
|
+
export declare function decode(at: Uint32, to: Uint32): CborValueType;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function bytesToFloat16(a: Uint8, b: Uint8): Float32;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export type CborItemType = undefined | boolean | number | bigint | [CborUnstructuredByteStringType, Uint64] | string | CborTagType;
|
|
3
|
+
export type CborTagType = {
|
|
4
|
+
tag: Uint64 | number;
|
|
5
|
+
value: CborValueType;
|
|
6
|
+
};
|
|
7
|
+
export type CborUnstructuredByteStringType = Uint8Array;
|
|
8
|
+
export type CborListType<T = any> = Array<T>;
|
|
9
|
+
export type CborMapType<T = any> = Record<string, T>;
|
|
10
|
+
export type CborCollectionType<T = any> = CborMapType<T> | CborListType<T>;
|
|
11
|
+
export type CborValueType = CborItemType | CborCollectionType | any;
|
|
12
|
+
export type CborArgumentLength = 1 | 2 | 4 | 8;
|
|
13
|
+
export type CborArgumentLengthOffset = 1 | 2 | 3 | 5 | 9;
|
|
14
|
+
export type CborOffset = number;
|
|
15
|
+
export type Uint8 = number;
|
|
16
|
+
export type Uint32 = number;
|
|
17
|
+
export type Uint64 = bigint;
|
|
18
|
+
export type Float32 = number;
|
|
19
|
+
export type Int64 = bigint;
|
|
20
|
+
export type Float16Binary = number;
|
|
21
|
+
export type Float32Binary = number;
|
|
22
|
+
export type CborMajorType = typeof majorUint64 | typeof majorNegativeInt64 | typeof majorUnstructuredByteString | typeof majorUtf8String | typeof majorList | typeof majorMap | typeof majorTag | typeof majorSpecial;
|
|
23
|
+
export declare const majorUint64 = 0;
|
|
24
|
+
export declare const majorNegativeInt64 = 1;
|
|
25
|
+
export declare const majorUnstructuredByteString = 2;
|
|
26
|
+
export declare const majorUtf8String = 3;
|
|
27
|
+
export declare const majorList = 4;
|
|
28
|
+
export declare const majorMap = 5;
|
|
29
|
+
export declare const majorTag = 6;
|
|
30
|
+
export declare const majorSpecial = 7;
|
|
31
|
+
export declare const specialFalse = 20;
|
|
32
|
+
export declare const specialTrue = 21;
|
|
33
|
+
export declare const specialNull = 22;
|
|
34
|
+
export declare const specialUndefined = 23;
|
|
35
|
+
export declare const extendedOneByte = 24;
|
|
36
|
+
export declare const extendedFloat16 = 25;
|
|
37
|
+
export declare const extendedFloat32 = 26;
|
|
38
|
+
export declare const extendedFloat64 = 27;
|
|
39
|
+
export declare const minorIndefinite = 31;
|
|
40
|
+
export declare function alloc(size: number): Uint8Array | Buffer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This implementation is synchronous and only implements the parts of CBOR
|
|
3
|
+
* specification used by Smithy RPCv2 CBOR protocol.
|
|
4
|
+
*
|
|
5
|
+
* This cbor serde implementation is derived from AWS SDK for Go's implementation.
|
|
6
|
+
* @see https://github.com/aws/smithy-go/tree/main/encoding/cbor
|
|
7
|
+
*
|
|
8
|
+
* The cbor-x implementation was also instructional:
|
|
9
|
+
* @see https://github.com/kriszyp/cbor-x
|
|
10
|
+
*/
|
|
11
|
+
export declare const cbor: {
|
|
12
|
+
deserialize(payload: Uint8Array): any;
|
|
13
|
+
serialize(input: any): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
* @param size - byte length to allocate.
|
|
17
|
+
*
|
|
18
|
+
* This may be used to garbage collect the CBOR
|
|
19
|
+
* shared encoding buffer space,
|
|
20
|
+
* e.g. resizeEncodingBuffer(0);
|
|
21
|
+
*
|
|
22
|
+
* This may also be used to pre-allocate more space for
|
|
23
|
+
* CBOR encoding, e.g. resizeEncodingBuffer(100_000_000);
|
|
24
|
+
*/
|
|
25
|
+
resizeEncodingBuffer(size: number): void;
|
|
26
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HttpRequest as __HttpRequest } from "@smithy/protocol-http";
|
|
2
|
+
import { HeaderBag as __HeaderBag, HttpResponse, SerdeContext as __SerdeContext, SerdeContext } from "@smithy/types";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseCborBody: (streamBody: any, context: SerdeContext) => any;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const dateToTag: (date: Date) => {
|
|
11
|
+
tag: 1;
|
|
12
|
+
value: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseCborErrorBody: (errorBody: any, context: SerdeContext) => Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const loadSmithyRpcV2CborErrorCode: (output: HttpResponse, data: any) => string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare const checkCborResponse: (response: HttpResponse) => void;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare const buildHttpRpcRequest: (context: __SerdeContext, headers: __HeaderBag, path: string, resolvedHostname: string | undefined, body: any) => Promise<__HttpRequest>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CborValueType, Float32, Uint8, Uint32 } from "./cbor-types";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* @param bytes - to be set as the decode source.
|
|
5
|
+
*
|
|
6
|
+
* Sets the decode bytearray source and its data view.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setPayload(bytes: Uint8Array): void;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* Decodes the data between the two indices.
|
|
12
|
+
*/
|
|
13
|
+
export declare function decode(at: Uint32, to: Uint32): CborValueType;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function bytesToFloat16(a: Uint8, b: Uint8): Float32;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export type CborItemType = undefined | boolean | number | bigint | [
|
|
3
|
+
CborUnstructuredByteStringType,
|
|
4
|
+
Uint64
|
|
5
|
+
] | string | CborTagType;
|
|
6
|
+
export type CborTagType = {
|
|
7
|
+
tag: Uint64 | number;
|
|
8
|
+
value: CborValueType;
|
|
9
|
+
};
|
|
10
|
+
export type CborUnstructuredByteStringType = Uint8Array;
|
|
11
|
+
export type CborListType<T = any> = Array<T>;
|
|
12
|
+
export type CborMapType<T = any> = Record<string, T>;
|
|
13
|
+
export type CborCollectionType<T = any> = CborMapType<T> | CborListType<T>;
|
|
14
|
+
export type CborValueType = CborItemType | CborCollectionType | any;
|
|
15
|
+
export type CborArgumentLength = 1 | 2 | 4 | 8;
|
|
16
|
+
export type CborArgumentLengthOffset = 1 | 2 | 3 | 5 | 9;
|
|
17
|
+
export type CborOffset = number;
|
|
18
|
+
export type Uint8 = number;
|
|
19
|
+
export type Uint32 = number;
|
|
20
|
+
export type Uint64 = bigint;
|
|
21
|
+
export type Float32 = number;
|
|
22
|
+
export type Int64 = bigint;
|
|
23
|
+
export type Float16Binary = number;
|
|
24
|
+
export type Float32Binary = number;
|
|
25
|
+
export type CborMajorType = typeof majorUint64 | typeof majorNegativeInt64 | typeof majorUnstructuredByteString | typeof majorUtf8String | typeof majorList | typeof majorMap | typeof majorTag | typeof majorSpecial;
|
|
26
|
+
export declare const majorUint64 = 0;
|
|
27
|
+
export declare const majorNegativeInt64 = 1;
|
|
28
|
+
export declare const majorUnstructuredByteString = 2;
|
|
29
|
+
export declare const majorUtf8String = 3;
|
|
30
|
+
export declare const majorList = 4;
|
|
31
|
+
export declare const majorMap = 5;
|
|
32
|
+
export declare const majorTag = 6;
|
|
33
|
+
export declare const majorSpecial = 7;
|
|
34
|
+
export declare const specialFalse = 20;
|
|
35
|
+
export declare const specialTrue = 21;
|
|
36
|
+
export declare const specialNull = 22;
|
|
37
|
+
export declare const specialUndefined = 23;
|
|
38
|
+
export declare const extendedOneByte = 24;
|
|
39
|
+
export declare const extendedFloat16 = 25;
|
|
40
|
+
export declare const extendedFloat32 = 26;
|
|
41
|
+
export declare const extendedFloat64 = 27;
|
|
42
|
+
export declare const minorIndefinite = 31;
|
|
43
|
+
export declare function alloc(size: number): Uint8Array | Buffer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This implementation is synchronous and only implements the parts of CBOR
|
|
3
|
+
* specification used by Smithy RPCv2 CBOR protocol.
|
|
4
|
+
*
|
|
5
|
+
* This cbor serde implementation is derived from AWS SDK for Go's implementation.
|
|
6
|
+
* @see https://github.com/aws/smithy-go/tree/main/encoding/cbor
|
|
7
|
+
*
|
|
8
|
+
* The cbor-x implementation was also instructional:
|
|
9
|
+
* @see https://github.com/kriszyp/cbor-x
|
|
10
|
+
*/
|
|
11
|
+
export declare const cbor: {
|
|
12
|
+
deserialize(payload: Uint8Array): any;
|
|
13
|
+
serialize(input: any): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
* @param size - byte length to allocate.
|
|
17
|
+
*
|
|
18
|
+
* This may be used to garbage collect the CBOR
|
|
19
|
+
* shared encoding buffer space,
|
|
20
|
+
* e.g. resizeEncodingBuffer(0);
|
|
21
|
+
*
|
|
22
|
+
* This may also be used to pre-allocate more space for
|
|
23
|
+
* CBOR encoding, e.g. resizeEncodingBuffer(100_000_000);
|
|
24
|
+
*/
|
|
25
|
+
resizeEncodingBuffer(size: number): void;
|
|
26
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HttpRequest as __HttpRequest } from "@smithy/protocol-http";
|
|
2
|
+
import { HeaderBag as __HeaderBag, HttpResponse, SerdeContext as __SerdeContext, SerdeContext } from "@smithy/types";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseCborBody: (streamBody: any, context: SerdeContext) => any;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const dateToTag: (date: Date) => {
|
|
11
|
+
tag: 1;
|
|
12
|
+
value: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseCborErrorBody: (errorBody: any, context: SerdeContext) => Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const loadSmithyRpcV2CborErrorCode: (output: HttpResponse, data: any) => string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare const checkCborResponse: (response: HttpResponse) => void;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare const buildHttpRpcRequest: (context: __SerdeContext, headers: __HeaderBag, path: string, resolvedHostname: string | undefined, body: any) => Promise<__HttpRequest>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
6
6
|
"build:cjs": "node ../../scripts/inline core",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
|
|
12
12
|
"lint": "npx eslint -c ../../.eslintrc.js \"src/**/*.ts\" && node ./scripts/lint",
|
|
13
13
|
"format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"",
|
|
14
|
-
"test": "yarn g:jest"
|
|
14
|
+
"test": "yarn g:jest --maxWorkers=1",
|
|
15
|
+
"test:cbor:perf": "node ./scripts/cbor-perf.mjs"
|
|
15
16
|
},
|
|
16
17
|
"main": "./dist-cjs/index.js",
|
|
17
18
|
"module": "./dist-es/index.js",
|
|
@@ -29,6 +30,13 @@
|
|
|
29
30
|
"node": "./package.json",
|
|
30
31
|
"import": "./package.json",
|
|
31
32
|
"require": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"./cbor": {
|
|
35
|
+
"module": "./dist-es/submodules/cbor/index.js",
|
|
36
|
+
"node": "./dist-cjs/submodules/cbor/index.js",
|
|
37
|
+
"import": "./dist-es/submodules/cbor/index.js",
|
|
38
|
+
"require": "./dist-cjs/submodules/cbor/index.js",
|
|
39
|
+
"types": "./dist-types/submodules/cbor/index.d.ts"
|
|
32
40
|
}
|
|
33
41
|
},
|
|
34
42
|
"author": {
|
|
@@ -38,13 +46,15 @@
|
|
|
38
46
|
},
|
|
39
47
|
"license": "Apache-2.0",
|
|
40
48
|
"dependencies": {
|
|
41
|
-
"@smithy/middleware-endpoint": "^3.1.
|
|
42
|
-
"@smithy/middleware-retry": "^3.0.
|
|
43
|
-
"@smithy/middleware-serde": "^3.0.
|
|
44
|
-
"@smithy/protocol-http": "^4.1.
|
|
45
|
-
"@smithy/smithy-client": "^3.
|
|
46
|
-
"@smithy/types": "^3.
|
|
47
|
-
"@smithy/util-
|
|
49
|
+
"@smithy/middleware-endpoint": "^3.1.1",
|
|
50
|
+
"@smithy/middleware-retry": "^3.0.16",
|
|
51
|
+
"@smithy/middleware-serde": "^3.0.4",
|
|
52
|
+
"@smithy/protocol-http": "^4.1.1",
|
|
53
|
+
"@smithy/smithy-client": "^3.3.0",
|
|
54
|
+
"@smithy/types": "^3.4.0",
|
|
55
|
+
"@smithy/util-body-length-browser": "^3.0.0",
|
|
56
|
+
"@smithy/util-middleware": "^3.0.4",
|
|
57
|
+
"@smithy/util-utf8": "^3.0.0",
|
|
48
58
|
"tslib": "^2.6.2"
|
|
49
59
|
},
|
|
50
60
|
"engines": {
|
|
@@ -58,7 +68,8 @@
|
|
|
58
68
|
}
|
|
59
69
|
},
|
|
60
70
|
"files": [
|
|
61
|
-
"dist-*/**"
|
|
71
|
+
"dist-*/**",
|
|
72
|
+
"./cbor.js"
|
|
62
73
|
],
|
|
63
74
|
"homepage": "https://github.com/awslabs/smithy-typescript/tree/main/packages/core",
|
|
64
75
|
"repository": {
|
|
@@ -70,6 +81,7 @@
|
|
|
70
81
|
"@types/node": "^16.18.96",
|
|
71
82
|
"concurrently": "7.0.0",
|
|
72
83
|
"downlevel-dts": "0.10.1",
|
|
84
|
+
"json-bigint": "^1.0.0",
|
|
73
85
|
"rimraf": "3.0.2",
|
|
74
86
|
"typedoc": "0.23.23"
|
|
75
87
|
},
|