@ocap/message 1.30.3 → 1.30.5
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/esm/canonical-cbor.d.mts +6 -0
- package/esm/canonical-cbor.mjs +401 -0
- package/esm/cbor.d.mts +8 -0
- package/esm/cbor.mjs +13 -0
- package/esm/{package.mjs → core/message/package.mjs} +12 -1
- package/esm/index.mjs +2 -6
- package/esm/message.mjs +30 -5
- package/esm/node_modules/cborg/cborg.mjs +6 -0
- package/esm/node_modules/cborg/lib/0uint.mjs +204 -0
- package/esm/node_modules/cborg/lib/1negint.mjs +91 -0
- package/esm/node_modules/cborg/lib/2bytes.mjs +120 -0
- package/esm/node_modules/cborg/lib/3string.mjs +103 -0
- package/esm/node_modules/cborg/lib/4array.mjs +100 -0
- package/esm/node_modules/cborg/lib/5map.mjs +100 -0
- package/esm/node_modules/cborg/lib/6tag.mjs +76 -0
- package/esm/node_modules/cborg/lib/7float.mjs +224 -0
- package/esm/node_modules/cborg/lib/bl.mjs +131 -0
- package/esm/node_modules/cborg/lib/byte-utils.mjs +104 -0
- package/esm/node_modules/cborg/lib/common.mjs +20 -0
- package/esm/node_modules/cborg/lib/decode.mjs +210 -0
- package/esm/node_modules/cborg/lib/encode.mjs +388 -0
- package/esm/node_modules/cborg/lib/is.mjs +59 -0
- package/esm/node_modules/cborg/lib/jump.mjs +154 -0
- package/esm/node_modules/cborg/lib/tagged.mjs +70 -0
- package/esm/node_modules/cborg/lib/token.mjs +73 -0
- package/esm/patch.mjs +1 -1
- package/esm/protobuf.d.mts +6 -0
- package/esm/protobuf.mjs +17 -0
- package/esm/provider-init-schema.d.mts +1 -0
- package/esm/provider-init-schema.mjs +22 -0
- package/esm/provider-init.d.mts +1 -0
- package/esm/provider-init.mjs +18 -0
- package/lib/canonical-cbor.cjs +404 -0
- package/lib/canonical-cbor.d.cts +6 -0
- package/lib/cbor.cjs +17 -0
- package/lib/cbor.d.cts +8 -0
- package/lib/{package.cjs → core/message/package.cjs} +12 -1
- package/lib/index.cjs +2 -8
- package/lib/message.cjs +30 -5
- package/lib/node_modules/cborg/cborg.cjs +4 -0
- package/lib/node_modules/cborg/lib/0uint.cjs +214 -0
- package/lib/node_modules/cborg/lib/1negint.cjs +95 -0
- package/lib/node_modules/cborg/lib/2bytes.cjs +125 -0
- package/lib/node_modules/cborg/lib/3string.cjs +108 -0
- package/lib/node_modules/cborg/lib/4array.cjs +106 -0
- package/lib/node_modules/cborg/lib/5map.cjs +106 -0
- package/lib/node_modules/cborg/lib/6tag.cjs +81 -0
- package/lib/node_modules/cborg/lib/7float.cjs +233 -0
- package/lib/node_modules/cborg/lib/bl.cjs +132 -0
- package/lib/node_modules/cborg/lib/byte-utils.cjs +111 -0
- package/lib/node_modules/cborg/lib/common.cjs +23 -0
- package/lib/node_modules/cborg/lib/decode.cjs +213 -0
- package/lib/node_modules/cborg/lib/encode.cjs +390 -0
- package/lib/node_modules/cborg/lib/is.cjs +60 -0
- package/lib/node_modules/cborg/lib/jump.cjs +156 -0
- package/lib/node_modules/cborg/lib/tagged.cjs +71 -0
- package/lib/node_modules/cborg/lib/token.cjs +75 -0
- package/lib/patch.cjs +1 -1
- package/lib/protobuf.cjs +18 -0
- package/lib/protobuf.d.cts +6 -0
- package/lib/provider-init-schema.cjs +23 -0
- package/lib/provider-init-schema.d.cts +1 -0
- package/lib/provider-init.cjs +19 -0
- package/lib/provider-init.d.cts +1 -0
- package/package.json +14 -3
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const require_token = require('./token.cjs');
|
|
2
|
+
const require_byte_utils = require('./byte-utils.cjs');
|
|
3
|
+
const require_common = require('./common.cjs');
|
|
4
|
+
const require_0uint = require('./0uint.cjs');
|
|
5
|
+
const require_1negint = require('./1negint.cjs');
|
|
6
|
+
const require_2bytes = require('./2bytes.cjs');
|
|
7
|
+
const require_3string = require('./3string.cjs');
|
|
8
|
+
const require_4array = require('./4array.cjs');
|
|
9
|
+
const require_5map = require('./5map.cjs');
|
|
10
|
+
const require_6tag = require('./6tag.cjs');
|
|
11
|
+
const require_7float = require('./7float.cjs');
|
|
12
|
+
|
|
13
|
+
//#region ../../node_modules/cborg/lib/jump.js
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @param {Uint8Array} data
|
|
19
|
+
* @param {number} pos
|
|
20
|
+
* @param {number} minor
|
|
21
|
+
*/
|
|
22
|
+
function invalidMinor(data, pos, minor) {
|
|
23
|
+
throw new Error(`${require_common.decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @param {string} msg
|
|
27
|
+
* @returns {()=>any}
|
|
28
|
+
*/
|
|
29
|
+
function errorer(msg) {
|
|
30
|
+
return () => {
|
|
31
|
+
throw new Error(`${require_common.decodeErrPrefix} ${msg}`);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** @type {((data:Uint8Array, pos:number, minor:number, options?:DecodeOptions) => any)[]} */
|
|
35
|
+
const jump = [];
|
|
36
|
+
for (let i = 0; i <= 23; i++) jump[i] = invalidMinor;
|
|
37
|
+
jump[24] = require_0uint.decodeUint8;
|
|
38
|
+
jump[25] = require_0uint.decodeUint16;
|
|
39
|
+
jump[26] = require_0uint.decodeUint32;
|
|
40
|
+
jump[27] = require_0uint.decodeUint64;
|
|
41
|
+
jump[28] = invalidMinor;
|
|
42
|
+
jump[29] = invalidMinor;
|
|
43
|
+
jump[30] = invalidMinor;
|
|
44
|
+
jump[31] = invalidMinor;
|
|
45
|
+
for (let i = 32; i <= 55; i++) jump[i] = invalidMinor;
|
|
46
|
+
jump[56] = require_1negint.decodeNegint8;
|
|
47
|
+
jump[57] = require_1negint.decodeNegint16;
|
|
48
|
+
jump[58] = require_1negint.decodeNegint32;
|
|
49
|
+
jump[59] = require_1negint.decodeNegint64;
|
|
50
|
+
jump[60] = invalidMinor;
|
|
51
|
+
jump[61] = invalidMinor;
|
|
52
|
+
jump[62] = invalidMinor;
|
|
53
|
+
jump[63] = invalidMinor;
|
|
54
|
+
for (let i = 64; i <= 87; i++) jump[i] = require_2bytes.decodeBytesCompact;
|
|
55
|
+
jump[88] = require_2bytes.decodeBytes8;
|
|
56
|
+
jump[89] = require_2bytes.decodeBytes16;
|
|
57
|
+
jump[90] = require_2bytes.decodeBytes32;
|
|
58
|
+
jump[91] = require_2bytes.decodeBytes64;
|
|
59
|
+
jump[92] = invalidMinor;
|
|
60
|
+
jump[93] = invalidMinor;
|
|
61
|
+
jump[94] = invalidMinor;
|
|
62
|
+
jump[95] = errorer("indefinite length bytes/strings are not supported");
|
|
63
|
+
for (let i = 96; i <= 119; i++) jump[i] = require_3string.decodeStringCompact;
|
|
64
|
+
jump[120] = require_3string.decodeString8;
|
|
65
|
+
jump[121] = require_3string.decodeString16;
|
|
66
|
+
jump[122] = require_3string.decodeString32;
|
|
67
|
+
jump[123] = require_3string.decodeString64;
|
|
68
|
+
jump[124] = invalidMinor;
|
|
69
|
+
jump[125] = invalidMinor;
|
|
70
|
+
jump[126] = invalidMinor;
|
|
71
|
+
jump[127] = errorer("indefinite length bytes/strings are not supported");
|
|
72
|
+
for (let i = 128; i <= 151; i++) jump[i] = require_4array.decodeArrayCompact;
|
|
73
|
+
jump[152] = require_4array.decodeArray8;
|
|
74
|
+
jump[153] = require_4array.decodeArray16;
|
|
75
|
+
jump[154] = require_4array.decodeArray32;
|
|
76
|
+
jump[155] = require_4array.decodeArray64;
|
|
77
|
+
jump[156] = invalidMinor;
|
|
78
|
+
jump[157] = invalidMinor;
|
|
79
|
+
jump[158] = invalidMinor;
|
|
80
|
+
jump[159] = require_4array.decodeArrayIndefinite;
|
|
81
|
+
for (let i = 160; i <= 183; i++) jump[i] = require_5map.decodeMapCompact;
|
|
82
|
+
jump[184] = require_5map.decodeMap8;
|
|
83
|
+
jump[185] = require_5map.decodeMap16;
|
|
84
|
+
jump[186] = require_5map.decodeMap32;
|
|
85
|
+
jump[187] = require_5map.decodeMap64;
|
|
86
|
+
jump[188] = invalidMinor;
|
|
87
|
+
jump[189] = invalidMinor;
|
|
88
|
+
jump[190] = invalidMinor;
|
|
89
|
+
jump[191] = require_5map.decodeMapIndefinite;
|
|
90
|
+
for (let i = 192; i <= 215; i++) jump[i] = require_6tag.decodeTagCompact;
|
|
91
|
+
jump[216] = require_6tag.decodeTag8;
|
|
92
|
+
jump[217] = require_6tag.decodeTag16;
|
|
93
|
+
jump[218] = require_6tag.decodeTag32;
|
|
94
|
+
jump[219] = require_6tag.decodeTag64;
|
|
95
|
+
jump[220] = invalidMinor;
|
|
96
|
+
jump[221] = invalidMinor;
|
|
97
|
+
jump[222] = invalidMinor;
|
|
98
|
+
jump[223] = invalidMinor;
|
|
99
|
+
for (let i = 224; i <= 243; i++) jump[i] = errorer("simple values are not supported");
|
|
100
|
+
jump[244] = invalidMinor;
|
|
101
|
+
jump[245] = invalidMinor;
|
|
102
|
+
jump[246] = invalidMinor;
|
|
103
|
+
jump[247] = require_7float.decodeUndefined;
|
|
104
|
+
jump[248] = errorer("simple values are not supported");
|
|
105
|
+
jump[249] = require_7float.decodeFloat16;
|
|
106
|
+
jump[250] = require_7float.decodeFloat32;
|
|
107
|
+
jump[251] = require_7float.decodeFloat64;
|
|
108
|
+
jump[252] = invalidMinor;
|
|
109
|
+
jump[253] = invalidMinor;
|
|
110
|
+
jump[254] = invalidMinor;
|
|
111
|
+
jump[255] = require_7float.decodeBreak;
|
|
112
|
+
/** @type {Token[]} */
|
|
113
|
+
const quick = [];
|
|
114
|
+
for (let i = 0; i < 24; i++) quick[i] = new require_token.Token(require_token.Type.uint, i, 1);
|
|
115
|
+
for (let i = -1; i >= -24; i--) quick[31 - i] = new require_token.Token(require_token.Type.negint, i, 1);
|
|
116
|
+
quick[64] = new require_token.Token(require_token.Type.bytes, new Uint8Array(0), 1);
|
|
117
|
+
quick[96] = new require_token.Token(require_token.Type.string, "", 1);
|
|
118
|
+
quick[128] = new require_token.Token(require_token.Type.array, 0, 1);
|
|
119
|
+
quick[160] = new require_token.Token(require_token.Type.map, 0, 1);
|
|
120
|
+
quick[244] = new require_token.Token(require_token.Type.false, false, 1);
|
|
121
|
+
quick[245] = new require_token.Token(require_token.Type.true, true, 1);
|
|
122
|
+
quick[246] = new require_token.Token(require_token.Type.null, null, 1);
|
|
123
|
+
/**
|
|
124
|
+
* @param {Token} token
|
|
125
|
+
* @returns {Uint8Array|undefined}
|
|
126
|
+
*/
|
|
127
|
+
function quickEncodeToken(token) {
|
|
128
|
+
switch (token.type) {
|
|
129
|
+
case require_token.Type.false: return require_byte_utils.fromArray([244]);
|
|
130
|
+
case require_token.Type.true: return require_byte_utils.fromArray([245]);
|
|
131
|
+
case require_token.Type.null: return require_byte_utils.fromArray([246]);
|
|
132
|
+
case require_token.Type.bytes:
|
|
133
|
+
if (!token.value.length) return require_byte_utils.fromArray([64]);
|
|
134
|
+
return;
|
|
135
|
+
case require_token.Type.string:
|
|
136
|
+
if (token.value === "") return require_byte_utils.fromArray([96]);
|
|
137
|
+
return;
|
|
138
|
+
case require_token.Type.array:
|
|
139
|
+
if (token.value === 0) return require_byte_utils.fromArray([128]);
|
|
140
|
+
/* c8 ignore next 2 */
|
|
141
|
+
return;
|
|
142
|
+
case require_token.Type.map:
|
|
143
|
+
if (token.value === 0) return require_byte_utils.fromArray([160]);
|
|
144
|
+
/* c8 ignore next 2 */
|
|
145
|
+
return;
|
|
146
|
+
case require_token.Type.uint:
|
|
147
|
+
if (token.value < 24) return require_byte_utils.fromArray([Number(token.value)]);
|
|
148
|
+
return;
|
|
149
|
+
case require_token.Type.negint: if (token.value >= -24) return require_byte_utils.fromArray([31 - Number(token.value)]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
exports.jump = jump;
|
|
155
|
+
exports.quick = quick;
|
|
156
|
+
exports.quickEncodeToken = quickEncodeToken;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../node_modules/cborg/lib/tagged.js
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('../interface.js').TagDecodeControl} TagDecodeControl
|
|
5
|
+
* @typedef {(decode: TagDecodeControl) => Tagged} TaggedTagDecoder
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A wrapper class for representing a CBOR tag with an arbitrary nested value.
|
|
9
|
+
*
|
|
10
|
+
* `Tagged` is a symmetric primitive: it can be passed to `encode()` to emit
|
|
11
|
+
* a CBOR tag header followed by the encoded form of `value`, and it can be
|
|
12
|
+
* returned from a tag decoder (via `Tagged.decoder(tag)` or `Tagged.preserve()`)
|
|
13
|
+
* to round-trip a tag through decode without losing the tag number.
|
|
14
|
+
*
|
|
15
|
+
* Use `Tagged` for one-off tag handling where defining a dedicated
|
|
16
|
+
* `typeEncoders` entry and tag decoder pair would be heavyweight, e.g. when
|
|
17
|
+
* wrapping a structure in a single application-specific tag (COSE, dCBOR
|
|
18
|
+
* envelopes, etc.).
|
|
19
|
+
*
|
|
20
|
+
* For systematic mapping of a JS type to a tag (e.g. CID -> tag 42), prefer
|
|
21
|
+
* a dedicated `typeEncoders` entry instead.
|
|
22
|
+
*/
|
|
23
|
+
var Tagged = class Tagged {
|
|
24
|
+
/**
|
|
25
|
+
* @param {number} tag - CBOR tag number, a non-negative integer
|
|
26
|
+
* @param {any} value - The value to be tagged; encoded recursively
|
|
27
|
+
*/
|
|
28
|
+
constructor(tag, value) {
|
|
29
|
+
if (typeof tag !== "number" || !Number.isInteger(tag) || tag < 0) throw new TypeError("Tagged: tag must be a non-negative integer");
|
|
30
|
+
this.tag = tag;
|
|
31
|
+
this.value = value;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build a tag decoder for use in `decode()`'s `tags` option that returns the
|
|
35
|
+
* decoded content wrapped in a `Tagged` instance, preserving the tag number
|
|
36
|
+
* for the caller to inspect.
|
|
37
|
+
*
|
|
38
|
+
* @param {number} tag - The CBOR tag number this decoder will be registered for
|
|
39
|
+
* @returns {TaggedTagDecoder}
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* import { decode, Tagged } from 'cborg'
|
|
43
|
+
* const value = decode(bytes, { tags: { 16: Tagged.decoder(16) } })
|
|
44
|
+
* // value instanceof Tagged; value.tag === 16
|
|
45
|
+
*/
|
|
46
|
+
static decoder(tag) {
|
|
47
|
+
return (decode) => new Tagged(tag, decode());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build a `tags` option for `decode()` that wraps each listed tag number in
|
|
51
|
+
* a `Tagged` instance, preserving those tags through decode without
|
|
52
|
+
* registering a dedicated decoder per tag.
|
|
53
|
+
*
|
|
54
|
+
* @param {...number} tagNumbers - One or more CBOR tag numbers to preserve
|
|
55
|
+
* @returns {{[tagNumber: number]: TaggedTagDecoder}}
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* import { decode, Tagged } from 'cborg'
|
|
59
|
+
* const value = decode(bytes, { tags: Tagged.preserve(16, 96) })
|
|
60
|
+
*/
|
|
61
|
+
static preserve(...tagNumbers) {
|
|
62
|
+
/** @type {{[tagNumber: number]: TaggedTagDecoder}} */
|
|
63
|
+
const tags = {};
|
|
64
|
+
for (const tag of tagNumbers) tags[tag] = Tagged.decoder(tag);
|
|
65
|
+
return tags;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
Object.defineProperty(Tagged.prototype, Symbol.toStringTag, { value: "Tagged" });
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
exports.Tagged = Tagged;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../node_modules/cborg/lib/token.js
|
|
3
|
+
var Type = class {
|
|
4
|
+
/**
|
|
5
|
+
* @param {number} major
|
|
6
|
+
* @param {string} name
|
|
7
|
+
* @param {boolean} terminal
|
|
8
|
+
*/
|
|
9
|
+
constructor(major, name, terminal) {
|
|
10
|
+
this.major = major;
|
|
11
|
+
this.majorEncoded = major << 5;
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.terminal = terminal;
|
|
14
|
+
}
|
|
15
|
+
/* c8 ignore next 3 */
|
|
16
|
+
toString() {
|
|
17
|
+
return `Type[${this.major}].${this.name}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @param {Type} typ
|
|
21
|
+
* @returns {number}
|
|
22
|
+
*/
|
|
23
|
+
compare(typ) {
|
|
24
|
+
/* c8 ignore next 1 */
|
|
25
|
+
return this.major < typ.major ? -1 : this.major > typ.major ? 1 : 0;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check equality between two Type instances. Safe to use across different
|
|
29
|
+
* copies of the Type class (e.g., when bundlers duplicate the module).
|
|
30
|
+
* (major, name) uniquely identifies a Type; terminal is implied by these.
|
|
31
|
+
* @param {Type} a
|
|
32
|
+
* @param {Type} b
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
static equals(a, b) {
|
|
36
|
+
return a === b || a.major === b.major && a.name === b.name;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
Type.uint = new Type(0, "uint", true);
|
|
40
|
+
Type.negint = new Type(1, "negint", true);
|
|
41
|
+
Type.bytes = new Type(2, "bytes", true);
|
|
42
|
+
Type.string = new Type(3, "string", true);
|
|
43
|
+
Type.array = new Type(4, "array", false);
|
|
44
|
+
Type.map = new Type(5, "map", false);
|
|
45
|
+
Type.tag = new Type(6, "tag", false);
|
|
46
|
+
Type.float = new Type(7, "float", true);
|
|
47
|
+
Type.false = new Type(7, "false", true);
|
|
48
|
+
Type.true = new Type(7, "true", true);
|
|
49
|
+
Type.null = new Type(7, "null", true);
|
|
50
|
+
Type.undefined = new Type(7, "undefined", true);
|
|
51
|
+
Type.break = new Type(7, "break", true);
|
|
52
|
+
var Token = class {
|
|
53
|
+
/**
|
|
54
|
+
* @param {Type} type
|
|
55
|
+
* @param {any} [value]
|
|
56
|
+
* @param {number} [encodedLength]
|
|
57
|
+
*/
|
|
58
|
+
constructor(type, value, encodedLength) {
|
|
59
|
+
this.type = type;
|
|
60
|
+
this.value = value;
|
|
61
|
+
this.encodedLength = encodedLength;
|
|
62
|
+
/** @type {Uint8Array|undefined} */
|
|
63
|
+
this.encodedBytes = void 0;
|
|
64
|
+
/** @type {Uint8Array|undefined} */
|
|
65
|
+
this.byteValue = void 0;
|
|
66
|
+
}
|
|
67
|
+
/* c8 ignore next 3 */
|
|
68
|
+
toString() {
|
|
69
|
+
return `Token[${this.type}].${this.value}`;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
exports.Token = Token;
|
|
75
|
+
exports.Type = Type;
|
package/lib/patch.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_package$1 = require('./package.cjs');
|
|
2
|
+
const require_package$1 = require('./core/message/package.cjs');
|
|
3
3
|
let assert = require("assert");
|
|
4
4
|
assert = require_rolldown_runtime.__toESM(assert);
|
|
5
5
|
let debug = require("debug");
|
package/lib/protobuf.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const require_provider = require('./provider.cjs');
|
|
2
|
+
require('./patch.cjs');
|
|
3
|
+
require('./provider-init.cjs');
|
|
4
|
+
const require_message = require('./message.cjs');
|
|
5
|
+
|
|
6
|
+
//#region src/protobuf.ts
|
|
7
|
+
function encodeTx(params) {
|
|
8
|
+
return require_message.createMessage("Transaction", params).serializeBinary();
|
|
9
|
+
}
|
|
10
|
+
function decodeTx(bytes) {
|
|
11
|
+
const desc = require_provider.getMessageType("Transaction");
|
|
12
|
+
if (!desc || typeof desc.fn?.deserializeBinary !== "function") throw new Error("@ocap/message/protobuf: Transaction runtime constructor is not registered");
|
|
13
|
+
return desc.fn.deserializeBinary(bytes).toObject();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.decodeTx = decodeTx;
|
|
18
|
+
exports.encodeTx = encodeTx;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_provider = require('./provider.cjs');
|
|
3
|
+
let _ocap_proto_schema = require("@ocap/proto/schema");
|
|
4
|
+
_ocap_proto_schema = require_rolldown_runtime.__toESM(_ocap_proto_schema);
|
|
5
|
+
|
|
6
|
+
//#region src/provider-init-schema.ts
|
|
7
|
+
/**
|
|
8
|
+
* Side-effect module: register the `@ocap/proto/schema` provider on the shared
|
|
9
|
+
* registry.
|
|
10
|
+
*
|
|
11
|
+
* Imported by the CBOR entry points (`encode-cbor.ts`, `decode-cbor.ts`) so
|
|
12
|
+
* the canonical encoder has field metadata without dragging the protobuf
|
|
13
|
+
* runtime (`*_pb.js`, `google-protobuf`) into the bundle. Protobuf entry
|
|
14
|
+
* points use `./provider-init` (runtime variant) instead.
|
|
15
|
+
*
|
|
16
|
+
* The schema provider is structurally compatible with ProtoProvider — it
|
|
17
|
+
* supplies `getMessageType(type).fields` but never `.fn`. Consumers that need
|
|
18
|
+
* a jspb constructor register the runtime provider in addition (or instead),
|
|
19
|
+
* and the shared registry's `withFn ?? withFields` fallback handles both.
|
|
20
|
+
*/
|
|
21
|
+
require_provider.addProvider(_ocap_proto_schema.default);
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_provider = require('./provider.cjs');
|
|
3
|
+
let _ocap_proto_runtime = require("@ocap/proto/runtime");
|
|
4
|
+
_ocap_proto_runtime = require_rolldown_runtime.__toESM(_ocap_proto_runtime);
|
|
5
|
+
|
|
6
|
+
//#region src/provider-init.ts
|
|
7
|
+
/**
|
|
8
|
+
* Side-effect module: register the `@ocap/proto/runtime` provider on the shared
|
|
9
|
+
* registry.
|
|
10
|
+
*
|
|
11
|
+
* Used by the protobuf subpath entry so `createMessage` can resolve jspb
|
|
12
|
+
* constructors. The CBOR entry does not import this file — instead the canonical
|
|
13
|
+
* encoder runs off `@ocap/proto/schema` directly (see `./canonical-cbor.ts`).
|
|
14
|
+
* That boundary is what lets bundlers drop the protobuf runtime from CBOR-only
|
|
15
|
+
* consumers (new Client SDK, Worker/Kernel builds).
|
|
16
|
+
*/
|
|
17
|
+
require_provider.addProvider(_ocap_proto_runtime.default);
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/message",
|
|
3
3
|
"description": "Utility functions to encode and decode message that can send to forge",
|
|
4
|
-
"version": "1.30.
|
|
4
|
+
"version": "1.30.5",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "wangshijun",
|
|
7
7
|
"email": "shijun@arcblock.io",
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ocap/proto": "1.30.
|
|
22
|
-
"@ocap/util": "1.30.
|
|
21
|
+
"@ocap/proto": "1.30.5",
|
|
22
|
+
"@ocap/util": "1.30.5",
|
|
23
|
+
"cborg": "^5.1.0",
|
|
23
24
|
"debug": "^4.4.3",
|
|
24
25
|
"google-protobuf": "3.21.0",
|
|
25
26
|
"lodash": "^4.17.23"
|
|
@@ -53,6 +54,16 @@
|
|
|
53
54
|
"module": "./esm/index.mjs",
|
|
54
55
|
"types": "./esm/index.d.mts",
|
|
55
56
|
"exports": {
|
|
57
|
+
"./cbor": {
|
|
58
|
+
"types": "./esm/cbor.d.mts",
|
|
59
|
+
"import": "./esm/cbor.mjs",
|
|
60
|
+
"default": "./lib/cbor.cjs"
|
|
61
|
+
},
|
|
62
|
+
"./protobuf": {
|
|
63
|
+
"types": "./esm/protobuf.d.mts",
|
|
64
|
+
"import": "./esm/protobuf.mjs",
|
|
65
|
+
"default": "./lib/protobuf.cjs"
|
|
66
|
+
},
|
|
56
67
|
".": {
|
|
57
68
|
"types": "./esm/index.d.mts",
|
|
58
69
|
"import": "./esm/index.mjs",
|