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