cborg 4.5.8 → 5.0.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/.github/dependabot.yml +4 -0
- package/.github/workflows/test-and-release.yml +2 -4
- package/CHANGELOG.md +50 -0
- package/README.md +213 -9
- package/cborg.js +5 -4
- package/example-extended.js +122 -0
- package/interface.ts +15 -3
- package/lib/0uint.js +2 -2
- package/lib/1negint.js +2 -2
- package/lib/2bytes.js +2 -2
- package/lib/3string.js +2 -2
- package/lib/4array.js +2 -2
- package/lib/5map.js +2 -2
- package/lib/6tag.js +2 -2
- package/lib/7float.js +5 -4
- package/lib/decode.js +94 -4
- package/lib/encode.js +7 -7
- package/lib/extended/extended.js +250 -0
- package/lib/json/decode.js +2 -2
- package/lib/json/encode.js +3 -3
- package/lib/jump.js +1 -1
- package/lib/length.js +3 -3
- package/lib/taglib.js +452 -0
- package/package.json +21 -17
- package/test/common.js +2 -1
- package/test/test-6tag.js +2 -1
- package/test/test-cbor-vectors.js +14 -6
- package/test/test-extended-vectors.js +293 -0
- package/test/test-extended.js +684 -0
- package/test/test-taglib.js +634 -0
- package/tsconfig.json +7 -11
- package/types/cborg.d.ts +8 -4
- package/types/cborg.d.ts.map +1 -1
- package/types/interface.d.ts +14 -3
- package/types/interface.d.ts.map +1 -1
- package/types/lib/0uint.d.ts +4 -4
- package/types/lib/0uint.d.ts.map +1 -1
- package/types/lib/1negint.d.ts +4 -4
- package/types/lib/1negint.d.ts.map +1 -1
- package/types/lib/2bytes.d.ts +2 -2
- package/types/lib/2bytes.d.ts.map +1 -1
- package/types/lib/3string.d.ts +2 -2
- package/types/lib/3string.d.ts.map +1 -1
- package/types/lib/4array.d.ts +2 -2
- package/types/lib/4array.d.ts.map +1 -1
- package/types/lib/5map.d.ts +2 -2
- package/types/lib/5map.d.ts.map +1 -1
- package/types/lib/6tag.d.ts +4 -4
- package/types/lib/6tag.d.ts.map +1 -1
- package/types/lib/7float.d.ts +6 -6
- package/types/lib/7float.d.ts.map +1 -1
- package/types/lib/byte-utils.d.ts +5 -2
- package/types/lib/byte-utils.d.ts.map +1 -1
- package/types/lib/decode.d.ts +4 -3
- package/types/lib/decode.d.ts.map +1 -1
- package/types/lib/encode.d.ts +8 -8
- package/types/lib/encode.d.ts.map +1 -1
- package/types/lib/extended/extended.d.ts +78 -0
- package/types/lib/extended/extended.d.ts.map +1 -0
- package/types/lib/json/decode.d.ts +5 -5
- package/types/lib/json/decode.d.ts.map +1 -1
- package/types/lib/json/encode.d.ts +3 -3
- package/types/lib/json/encode.d.ts.map +1 -1
- package/types/lib/jump.d.ts +1 -1
- package/types/lib/jump.d.ts.map +1 -1
- package/types/lib/length.d.ts +3 -3
- package/types/lib/length.d.ts.map +1 -1
- package/types/lib/taglib.d.ts +143 -0
- package/types/lib/taglib.d.ts.map +1 -0
- package/types/tsconfig.tsbuildinfo +1 -1
- package/taglib.js +0 -73
- package/types/taglib.d.ts +0 -18
- package/types/taglib.d.ts.map +0 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode a positive bignum from bytes (Tag 2)
|
|
3
|
+
* @param {import('../interface.js').TagDecodeControl} decode
|
|
4
|
+
* @returns {bigint}
|
|
5
|
+
*/
|
|
6
|
+
export function bigIntDecoder(decode: import("../interface.js").TagDecodeControl): bigint;
|
|
7
|
+
/**
|
|
8
|
+
* Encode a BigInt, only using tags for values outside 64-bit range (IPLD compatible)
|
|
9
|
+
* @param {bigint} obj
|
|
10
|
+
* @returns {Token[]|null}
|
|
11
|
+
*/
|
|
12
|
+
export function bigIntEncoder(obj: bigint): Token[] | null;
|
|
13
|
+
/**
|
|
14
|
+
* Encode a BigInt, always using tags 2/3 (for extended mode, full round-trip fidelity)
|
|
15
|
+
* @param {bigint} obj
|
|
16
|
+
* @returns {Token[]}
|
|
17
|
+
*/
|
|
18
|
+
export function structBigIntEncoder(obj: bigint): Token[];
|
|
19
|
+
/**
|
|
20
|
+
* Decode a negative bignum from bytes (Tag 3)
|
|
21
|
+
* @param {import('../interface.js').TagDecodeControl} decode
|
|
22
|
+
* @returns {bigint}
|
|
23
|
+
*/
|
|
24
|
+
export function bigNegIntDecoder(decode: import("../interface.js").TagDecodeControl): bigint;
|
|
25
|
+
/**
|
|
26
|
+
* Encode a Date as Tag 1 (epoch seconds as float)
|
|
27
|
+
* @param {Date} date
|
|
28
|
+
* @returns {Token[]}
|
|
29
|
+
*/
|
|
30
|
+
export function dateEncoder(date: Date): Token[];
|
|
31
|
+
/**
|
|
32
|
+
* Decode Tag 1 (epoch seconds) to a Date
|
|
33
|
+
* @param {import('../interface.js').TagDecodeControl} decode
|
|
34
|
+
* @returns {Date}
|
|
35
|
+
*/
|
|
36
|
+
export function dateDecoder(decode: import("../interface.js").TagDecodeControl): Date;
|
|
37
|
+
/**
|
|
38
|
+
* Encode a RegExp as Tag 21066
|
|
39
|
+
* @param {RegExp} re
|
|
40
|
+
* @returns {Token[]}
|
|
41
|
+
*/
|
|
42
|
+
export function regExpEncoder(re: RegExp): Token[];
|
|
43
|
+
/**
|
|
44
|
+
* Decode Tag 21066 to a RegExp
|
|
45
|
+
* @param {import('../interface.js').TagDecodeControl} decode
|
|
46
|
+
* @returns {RegExp}
|
|
47
|
+
*/
|
|
48
|
+
export function regExpDecoder(decode: import("../interface.js").TagDecodeControl): RegExp;
|
|
49
|
+
/**
|
|
50
|
+
* Encode a Set as Tag 258 + array
|
|
51
|
+
* This is a typeEncoder, receives (obj, typ, options, refStack)
|
|
52
|
+
* @param {Set<any>} set
|
|
53
|
+
* @param {string} _typ
|
|
54
|
+
* @param {import('../interface.js').EncodeOptions} options
|
|
55
|
+
* @param {import('../interface.js').Reference} [refStack]
|
|
56
|
+
* @returns {import('../interface.js').TokenOrNestedTokens[]}
|
|
57
|
+
*/
|
|
58
|
+
export function setEncoder(set: Set<any>, _typ: string, options: import("../interface.js").EncodeOptions, refStack?: import("../interface.js").Reference): import("../interface.js").TokenOrNestedTokens[];
|
|
59
|
+
/**
|
|
60
|
+
* Decode Tag 258 to a Set
|
|
61
|
+
* @param {import('../interface.js').TagDecodeControl} decode
|
|
62
|
+
* @returns {Set<any>}
|
|
63
|
+
*/
|
|
64
|
+
export function setDecoder(decode: import("../interface.js").TagDecodeControl): Set<any>;
|
|
65
|
+
/**
|
|
66
|
+
* Encode a Map as Tag 259 + CBOR map
|
|
67
|
+
* This is a typeEncoder, receives (obj, typ, options, refStack)
|
|
68
|
+
* @param {Map<any, any>} map
|
|
69
|
+
* @param {string} _typ
|
|
70
|
+
* @param {import('../interface.js').EncodeOptions} options
|
|
71
|
+
* @param {import('../interface.js').Reference} [refStack]
|
|
72
|
+
* @returns {import('../interface.js').TokenOrNestedTokens[]}
|
|
73
|
+
*/
|
|
74
|
+
export function mapEncoder(map: Map<any, any>, _typ: string, options: import("../interface.js").EncodeOptions, refStack?: import("../interface.js").Reference): import("../interface.js").TokenOrNestedTokens[];
|
|
75
|
+
/**
|
|
76
|
+
* Decode Tag 259 to a Map
|
|
77
|
+
* Uses decode.entries() to preserve key types (integers, etc.) regardless of useMaps setting
|
|
78
|
+
* @param {import('../interface.js').TagDecodeControl} decode
|
|
79
|
+
* @returns {Map<any, any>}
|
|
80
|
+
*/
|
|
81
|
+
export function mapDecoder(decode: import("../interface.js").TagDecodeControl): Map<any, any>;
|
|
82
|
+
/**
|
|
83
|
+
* Encode an Error as Tag 27: [className, message]
|
|
84
|
+
* @param {Error} err
|
|
85
|
+
* @returns {Token[]}
|
|
86
|
+
*/
|
|
87
|
+
export function errorEncoder(err: Error): Token[];
|
|
88
|
+
/**
|
|
89
|
+
* Decode Tag 27 to an Error (or Error subclass)
|
|
90
|
+
* @param {import('../interface.js').TagDecodeControl} decode
|
|
91
|
+
* @returns {Error}
|
|
92
|
+
*/
|
|
93
|
+
export function errorDecoder(decode: import("../interface.js").TagDecodeControl): Error;
|
|
94
|
+
/**
|
|
95
|
+
* Encode a number, preserving -0 as a float
|
|
96
|
+
* Use this as a typeEncoder for 'number' to preserve -0 fidelity
|
|
97
|
+
* @param {number} num
|
|
98
|
+
* @returns {Token[] | null}
|
|
99
|
+
*/
|
|
100
|
+
export function negativeZeroEncoder(num: number): Token[] | null;
|
|
101
|
+
export const TAG_DATE_STRING: 0;
|
|
102
|
+
export const TAG_DATE_EPOCH: 1;
|
|
103
|
+
export const TAG_BIGINT_POS: 2;
|
|
104
|
+
export const TAG_BIGINT_NEG: 3;
|
|
105
|
+
export const TAG_UINT8_ARRAY: 64;
|
|
106
|
+
export const TAG_UINT8_CLAMPED_ARRAY: 68;
|
|
107
|
+
export const TAG_INT8_ARRAY: 72;
|
|
108
|
+
export const TAG_UINT16_ARRAY_LE: 69;
|
|
109
|
+
export const TAG_UINT32_ARRAY_LE: 70;
|
|
110
|
+
export const TAG_BIGUINT64_ARRAY_LE: 71;
|
|
111
|
+
export const TAG_INT16_ARRAY_LE: 77;
|
|
112
|
+
export const TAG_INT32_ARRAY_LE: 78;
|
|
113
|
+
export const TAG_BIGINT64_ARRAY_LE: 79;
|
|
114
|
+
export const TAG_FLOAT32_ARRAY_LE: 85;
|
|
115
|
+
export const TAG_FLOAT64_ARRAY_LE: 86;
|
|
116
|
+
export const TAG_OBJECT_CLASS: 27;
|
|
117
|
+
export const TAG_SET: 258;
|
|
118
|
+
export const TAG_MAP: 259;
|
|
119
|
+
export const TAG_REGEXP: 21066;
|
|
120
|
+
export const uint8ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
121
|
+
export const uint8ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Uint8Array<ArrayBuffer>;
|
|
122
|
+
export const uint8ClampedArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
123
|
+
export const uint8ClampedArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Uint8ClampedArray<ArrayBuffer>;
|
|
124
|
+
export const int8ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
125
|
+
export const int8ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Int8Array<ArrayBuffer>;
|
|
126
|
+
export const uint16ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
127
|
+
export const uint16ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Uint16Array<ArrayBuffer>;
|
|
128
|
+
export const uint32ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
129
|
+
export const uint32ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Uint32Array<ArrayBuffer>;
|
|
130
|
+
export const bigUint64ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
131
|
+
export const bigUint64ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => BigUint64Array<ArrayBuffer>;
|
|
132
|
+
export const int16ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
133
|
+
export const int16ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Int16Array<ArrayBuffer>;
|
|
134
|
+
export const int32ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
135
|
+
export const int32ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Int32Array<ArrayBuffer>;
|
|
136
|
+
export const bigInt64ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
137
|
+
export const bigInt64ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => BigInt64Array<ArrayBuffer>;
|
|
138
|
+
export const float32ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
139
|
+
export const float32ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Float32Array<ArrayBuffer>;
|
|
140
|
+
export const float64ArrayEncoder: (arr: ArrayBufferView) => Token[];
|
|
141
|
+
export const float64ArrayDecoder: (decode: import("../interface.js").TagDecodeControl) => Float64Array<ArrayBuffer>;
|
|
142
|
+
import { Token } from '../cborg.js';
|
|
143
|
+
//# sourceMappingURL=taglib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taglib.d.ts","sourceRoot":"","sources":["../../lib/taglib.js"],"names":[],"mappings":"AA4DA;;;;GAIG;A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,EAAE,CAsC8B;AAC5E,yCArDsB,OAAO,iBAAiB,EAAE,gBAAgB,6BAqDI;AAGpE,sCA1CmB,eAAe,KAAK,KAAK,EAAE,CA0C8B;AAC5E,yCAzDsB,OAAO,iBAAiB,EAAE,gBAAgB,6BAyDI;AAGpE,yCA9CmB,eAAe,KAAK,KAAK,EAAE,CA8CoC;AAClF,4CA7DsB,OAAO,iBAAiB,EAAE,gBAAgB,gCA6DU;AAG1E,wCAlDmB,eAAe,KAAK,KAAK,EAAE,CAkDkC;AAChF,2CAjEsB,OAAO,iBAAiB,EAAE,gBAAgB,+BAiEQ;AAGxE,wCAtDmB,eAAe,KAAK,KAAK,EAAE,CAsDkC;AAChF,2CArEsB,OAAO,iBAAiB,EAAE,gBAAgB,+BAqEQ;sBA3X5C,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../cborg.js","../
|
|
1
|
+
{"root":["../cborg.js","../interface.ts","../lib/0uint.js","../lib/1negint.js","../lib/2bytes.js","../lib/3string.js","../lib/4array.js","../lib/5map.js","../lib/6tag.js","../lib/7float.js","../lib/bl.js","../lib/byte-utils.js","../lib/common.js","../lib/decode.js","../lib/diagnostic.js","../lib/diagnostic_test.js","../lib/encode.js","../lib/is.js","../lib/jump.js","../lib/length.js","../lib/taglib.js","../lib/token.js","../lib/extended/extended.js","../lib/json/decode.js","../lib/json/encode.js","../lib/json/json.js"],"version":"6.0.2"}
|
package/taglib.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Token, Type } from './cborg.js'
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
A collection of some standard CBOR tags.
|
|
5
|
-
|
|
6
|
-
There are no tags included by default in the cborg encoder or decoder, you have
|
|
7
|
-
to include them by passing options. `typeEncoders` for encode() and `tags` for
|
|
8
|
-
decode().
|
|
9
|
-
|
|
10
|
-
The encoders here can be included with these options (see the tests for how this
|
|
11
|
-
can be done), or as examples for writing additional tags. Additional standard
|
|
12
|
-
(and reasonable) tags may be added here by pull request.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/* TAG(2) Bignums https://tools.ietf.org/html/rfc8949#section-3.4.3 */
|
|
16
|
-
const neg1b = BigInt(-1)
|
|
17
|
-
const pos1b = BigInt(1)
|
|
18
|
-
const zerob = BigInt(0)
|
|
19
|
-
// const twob = BigInt(2)
|
|
20
|
-
const eightb = BigInt(8)
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @param {Uint8Array} bytes
|
|
24
|
-
* @returns {bigint}
|
|
25
|
-
*/
|
|
26
|
-
export function bigIntDecoder (bytes) {
|
|
27
|
-
// TODO: assert that `bytes` is a `Uint8Array`
|
|
28
|
-
let bi = zerob
|
|
29
|
-
for (let ii = 0; ii < bytes.length; ii++) {
|
|
30
|
-
bi = (bi << eightb) + BigInt(bytes[ii])
|
|
31
|
-
}
|
|
32
|
-
return bi
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param {bigint} bi
|
|
37
|
-
* @returns {Uint8Array}
|
|
38
|
-
*/
|
|
39
|
-
function fromBigInt (bi) {
|
|
40
|
-
const buf = []
|
|
41
|
-
while (bi > 0) {
|
|
42
|
-
buf.unshift(Number(bi) & 0xff)
|
|
43
|
-
bi >>= eightb
|
|
44
|
-
}
|
|
45
|
-
return Uint8Array.from(buf)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// assuming that we're receiving a BigInt here, it should be registered for
|
|
49
|
-
// type 'bigint' for this to work.
|
|
50
|
-
const maxSafeBigInt = BigInt('18446744073709551615') // (twob ** BigInt(64)) - pos1b
|
|
51
|
-
const minSafeBigInt = BigInt('-18446744073709551616') // neg1b * (twob ** BigInt(64))
|
|
52
|
-
/**
|
|
53
|
-
* @param {bigint} obj
|
|
54
|
-
* @returns {Token[]|null}
|
|
55
|
-
*/
|
|
56
|
-
export function bigIntEncoder (obj) {
|
|
57
|
-
if (obj >= minSafeBigInt && obj <= maxSafeBigInt) {
|
|
58
|
-
return null // null = do it the standard way
|
|
59
|
-
}
|
|
60
|
-
return [
|
|
61
|
-
new Token(Type.tag, obj >= zerob ? 2 : 3),
|
|
62
|
-
new Token(Type.bytes, fromBigInt(obj >= zerob ? obj : obj * neg1b - pos1b))
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* TAG(3) Negative Bignums https://tools.ietf.org/html/rfc8949#section-3.4.3
|
|
68
|
-
* @param {Uint8Array} bytes
|
|
69
|
-
* @returns {bigint}
|
|
70
|
-
*/
|
|
71
|
-
export function bigNegIntDecoder (bytes) {
|
|
72
|
-
return neg1b - bigIntDecoder(bytes)
|
|
73
|
-
}
|
package/types/taglib.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {Uint8Array} bytes
|
|
3
|
-
* @returns {bigint}
|
|
4
|
-
*/
|
|
5
|
-
export function bigIntDecoder(bytes: Uint8Array): bigint;
|
|
6
|
-
/**
|
|
7
|
-
* @param {bigint} obj
|
|
8
|
-
* @returns {Token[]|null}
|
|
9
|
-
*/
|
|
10
|
-
export function bigIntEncoder(obj: bigint): Token[] | null;
|
|
11
|
-
/**
|
|
12
|
-
* TAG(3) Negative Bignums https://tools.ietf.org/html/rfc8949#section-3.4.3
|
|
13
|
-
* @param {Uint8Array} bytes
|
|
14
|
-
* @returns {bigint}
|
|
15
|
-
*/
|
|
16
|
-
export function bigNegIntDecoder(bytes: Uint8Array): bigint;
|
|
17
|
-
import { Token } from './cborg.js';
|
|
18
|
-
//# sourceMappingURL=taglib.d.ts.map
|
package/types/taglib.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"taglib.d.ts","sourceRoot":"","sources":["../taglib.js"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,qCAHW,UAAU,GACR,MAAM,CASlB;AAmBD;;;GAGG;AACH,mCAHW,MAAM,GACJ,KAAK,EAAE,GAAC,IAAI,CAUxB;AAED;;;;GAIG;AACH,wCAHW,UAAU,GACR,MAAM,CAIlB;sBAxE2B,YAAY"}
|