@ocap/proto 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/lib/index.d.ts CHANGED
@@ -1,481 +1,7 @@
1
- // Generate by [js2dts@0.3.3](https://github.com/whxaxes/js2dts#readme)
1
+ // `@ocap/proto` aggregate entry — DEPRECATED.
2
+ // Prefer `@ocap/proto/schema` (tree-shake friendly) or `@ocap/proto/runtime`
3
+ // (full protobuf runtime). Aggregate re-exports everything from runtime so
4
+ // existing consumers (`import forge from '@ocap/proto'`) keep working, but
5
+ // tree-shaking will not drop the protobuf runtime through this entry.
2
6
 
3
- declare const _Lib: object;
4
- export = _Lib;
5
-
6
- declare namespace Enums {
7
-
8
- export enum StatusCode {
9
- OK = 0,
10
- INVALID_NONCE = 1,
11
- INVALID_SIGNATURE = 2,
12
- INVALID_SENDER_STATE = 3,
13
- INVALID_RECEIVER_STATE = 4,
14
- INSUFFICIENT_DATA = 5,
15
- INSUFFICIENT_FUND = 6,
16
- INVALID_OWNER = 7,
17
- INVALID_TX = 8,
18
- UNSUPPORTED_TX = 9,
19
- EXPIRED_TX = 10,
20
- TOO_MANY_TXS = 11,
21
- INVALID_LOCK_STATUS = 12,
22
- INVALID_REQUEST = 13,
23
- INVALID_MONIKER = 16,
24
- INVALID_PASSPHRASE = 17,
25
- INVALID_MULTISIG = 20,
26
- INVALID_WALLET = 21,
27
- INVALID_CHAIN_ID = 22,
28
- CONSENSUS_RPC_ERROR = 24,
29
- STORAGE_RPC_ERROR = 25,
30
- NOENT = 26,
31
- ACCOUNT_MIGRATED = 27,
32
- RPC_CONNECTION_ERROR = 28,
33
- UNSUPPORTED_STAKE = 30,
34
- INSUFFICIENT_STAKE = 31,
35
- INVALID_STAKE_STATE = 32,
36
- EXPIRED_WALLET_TOKEN = 33,
37
- BANNED_UNSTAKE = 34,
38
- INVALID_ASSET = 35,
39
- INVALID_TX_SIZE = 36,
40
- INVALID_SIGNER_STATE = 37,
41
- INVALID_FORGE_STATE = 38,
42
- EXPIRED_ASSET = 39,
43
- UNTRANSFERRABLE_ASSET = 40,
44
- READONLY_ASSET = 41,
45
- CONSUMED_ASSET = 42,
46
- INVALID_DEPOSIT_VALUE = 43,
47
- EXCEED_DEPOSIT_CAP = 44,
48
- INVALID_DEPOSIT_TARGET = 45,
49
- INVALID_DEPOSITOR = 46,
50
- INVALID_WITHDRAWER = 47,
51
- INVALID_EXPIRY_DATE = 49,
52
- INVALID_CUSTODIAN = 51,
53
- INSUFFICIENT_GAS = 52,
54
- INVALID_SWAP = 53,
55
- INVALID_HASHKEY = 54,
56
- INVALID_DELEGATION = 55,
57
- INSUFFICIENT_DELEGATION = 56,
58
- INVALID_DELEGATION_RULE = 57,
59
- INVALID_DELEGATION_TYPE_URL = 58,
60
- SENDER_NOT_AUTHORIZED = 59,
61
- PROTOCOL_NOT_RUNNING = 60,
62
- PROTOCOL_NOT_PAUSED = 61,
63
- PROTOCOL_NOT_ACTIVATED = 62,
64
- INVALID_DEACTIVATION = 63,
65
- SENDER_WITHDRAW_ITEMS_FULL = 64,
66
- WITHDRAW_ITEM_MISSING = 65,
67
- INVALID_WITHDRAW_TX = 66,
68
- INVALID_CHAIN_TYPE = 67,
69
- INVALID_TIME = 68,
70
- INVALID_SUBSCRIBE = 69,
71
- INVALID_DID_TYPE = 70,
72
- INVALID_CANDIDATE_STATE = 71,
73
- VALIDATOR_NOT_FOUND = 72,
74
- VALIDATOR_NOT_CHANGED = 73,
75
- INVALID_FACTORY_STATE = 74,
76
- INVALID_FACTORY_PROPS = 75,
77
- INVALID_FACTORY_INPUT = 76,
78
- INVALID_TOKEN = 77,
79
- INVALID_ROLLUP = 78,
80
- INVALID_BLOCK = 79,
81
- FORBIDDEN = 403,
82
- INTERNAL = 500,
83
- TIMEOUT = 504,
84
- }
85
-
86
- export enum KeyType {
87
- ED25519 = 0,
88
- SECP256K1 = 1,
89
- ETHEREUM = 2,
90
- }
91
-
92
- export enum HashType {
93
- KECCAK = 0,
94
- SHA3 = 1,
95
- SHA2 = 2,
96
- KECCAK_384 = 6,
97
- SHA3_384 = 7,
98
- KECCAK_512 = 13,
99
- SHA3_512 = 14,
100
- }
101
-
102
- export enum EncodingType {
103
- BASE16 = 0,
104
- BASE58 = 1,
105
- }
106
-
107
- export enum RoleType {
108
- ROLE_ACCOUNT = 0,
109
- ROLE_NODE = 1,
110
- ROLE_DEVICE = 2,
111
- ROLE_APPLICATION = 3,
112
- ROLE_SMART_CONTRACT = 4,
113
- ROLE_BOT = 5,
114
- ROLE_ASSET = 6,
115
- ROLE_STAKE = 7,
116
- ROLE_VALIDATOR = 8,
117
- ROLE_GROUP = 9,
118
- ROLE_TX = 10,
119
- ROLE_TETHER = 11,
120
- ROLE_SWAP = 12,
121
- ROLE_DELEGATION = 13,
122
- ROLE_VC = 14,
123
- ROLE_BLOCKLET = 15,
124
- ROLE_STORE = 16,
125
- ROLE_TOKEN = 17,
126
- ROLE_FACTORY = 18,
127
- ROLE_ROLLUP = 19,
128
- ROLE_STORAGE = 20,
129
- ROLE_ANY = 63,
130
- }
131
-
132
- export enum UpgradeType {
133
- CONFIG_APP = 0,
134
- CONFIG_FORGE = 1,
135
- CONFIG_DFS = 2,
136
- CONFIG_CONSENSUS = 3,
137
- CONFIG_P2P = 4,
138
- EXE_APP = 10,
139
- EXE_FORGE = 11,
140
- EXE_DFS = 12,
141
- EXE_CONSENSUS = 13,
142
- EXE_P2P = 14,
143
- }
144
-
145
- export enum UpgradeAction {
146
- VERIFY = 0,
147
- BACKUP = 1,
148
- REPLACE = 2,
149
- RESTART_APP = 10,
150
- RESTART_DFS = 11,
151
- RESTART_CONSENSUS = 12,
152
- RESTART_P2P = 13,
153
- RESTART_FORGE = 14,
154
- ROLLBACK_IF_FAIL = 30,
155
- RESTART_ALL_IF_FAIL = 31,
156
- CRASH_IF_FAIL = 33,
157
- DROP_ADDRESS_BOOK = 50,
158
- }
159
-
160
- export enum StateType {
161
- STATE_ACCOUNT = 0,
162
- STATE_ASSET = 1,
163
- STATE_CHANNEL = 2,
164
- STATE_FORGE = 3,
165
- STATE_STAKE = 4,
166
- }
167
-
168
- export enum StakeType {
169
- STAKE_NODE = 0,
170
- STAKE_USER = 1,
171
- STAKE_ASSET = 2,
172
- STAKE_CHAIN = 3,
173
- }
174
-
175
- export enum ProtocolStatus {
176
- RUNNING = 0,
177
- PAUSED = 1,
178
- TERMINATED = 2,
179
- }
180
-
181
- export enum TokenFactoryStatus {
182
- TOKEN_FACTORY_ACTIVE = 0,
183
- TOKEN_FACTORY_PAUSED = 1,
184
- }
185
-
186
- export enum Direction {
187
- MUTUAL = 0,
188
- ONE_WAY = 1,
189
- UNION = 2,
190
- }
191
-
192
- export enum Validity {
193
- BOTH = 0,
194
- VALID = 1,
195
- INVALID = 2,
196
- }
197
-
198
- export enum TokenFlowDirection {
199
- IN = 0,
200
- OUT = 1,
201
- }
202
-
203
- export enum SupportedTxs {
204
- 0 = AccountMigrateTx,
205
- 1 = AcquireAssetV2Tx,
206
- 2 = AcquireAssetV3Tx,
207
- 3 = BurnTokenTx,
208
- 4 = ClaimBlockRewardTx,
209
- 5 = ClaimStakeTx,
210
- 6 = CloseRollupTx,
211
- 7 = ConsumeAssetTx,
212
- 8 = CreateAssetTx,
213
- 9 = CreateFactoryTx,
214
- 10 = CreateRollupBlockTx,
215
- 11 = CreateRollupTx,
216
- 12 = CreateTokenFactoryTx,
217
- 13 = CreateTokenTx,
218
- 14 = DeclareTx,
219
- 15 = DelegateTx,
220
- 16 = DepositTokenV2Tx,
221
- 17 = ExchangeTx,
222
- 18 = ExchangeV2Tx,
223
- 19 = JoinRollupTx,
224
- 20 = LeaveRollupTx,
225
- 21 = MigrateRollupTx,
226
- 22 = MintAssetTx,
227
- 23 = MintTokenTx,
228
- 24 = PauseRollupTx,
229
- 25 = ResumeRollupTx,
230
- 26 = ReturnStakeTx,
231
- 27 = RevokeDelegateTx,
232
- 28 = RevokeStakeTx,
233
- 29 = SlashStakeTx,
234
- 30 = StakeTx,
235
- 31 = TransferTx,
236
- 32 = TransferV2Tx,
237
- 33 = TransferV3Tx,
238
- 34 = UpdateAssetTx,
239
- 35 = UpdateRollupTx,
240
- 36 = UpdateTokenFactoryTx,
241
- 37 = UpgradeNodeTx,
242
- 38 = WithdrawTokenV2Tx,
243
- }
244
-
245
- export enum SupportedStakes {
246
-
247
- }
248
-
249
- export interface main {
250
- StatusCode: typeof Enums.StatusCode;
251
- KeyType: typeof Enums.KeyType;
252
- HashType: typeof Enums.HashType;
253
- EncodingType: typeof Enums.EncodingType;
254
- RoleType: typeof Enums.RoleType;
255
- UpgradeType: typeof Enums.UpgradeType;
256
- UpgradeAction: typeof Enums.UpgradeAction;
257
- StateType: typeof Enums.StateType;
258
- StakeType: typeof Enums.StakeType;
259
- ProtocolStatus: typeof Enums.ProtocolStatus;
260
- TokenFactoryStatus: typeof Enums.TokenFactoryStatus;
261
- Direction: typeof Enums.Direction;
262
- Validity: typeof Enums.Validity;
263
- TokenFlowDirection: typeof Enums.TokenFlowDirection;
264
- SupportedTxs: typeof Enums.SupportedTxs;
265
- SupportedStakes: typeof Enums.SupportedStakes;
266
- }
267
- }
268
- declare namespace Messages {
269
-
270
- export enum StatusCode {
271
- 0 = OK,
272
- 1 = INVALID_NONCE,
273
- 2 = INVALID_SIGNATURE,
274
- 3 = INVALID_SENDER_STATE,
275
- 4 = INVALID_RECEIVER_STATE,
276
- 5 = INSUFFICIENT_DATA,
277
- 6 = INSUFFICIENT_FUND,
278
- 7 = INVALID_OWNER,
279
- 8 = INVALID_TX,
280
- 9 = UNSUPPORTED_TX,
281
- 10 = EXPIRED_TX,
282
- 11 = TOO_MANY_TXS,
283
- 12 = INVALID_LOCK_STATUS,
284
- 13 = INVALID_REQUEST,
285
- 16 = INVALID_MONIKER,
286
- 17 = INVALID_PASSPHRASE,
287
- 20 = INVALID_MULTISIG,
288
- 21 = INVALID_WALLET,
289
- 22 = INVALID_CHAIN_ID,
290
- 24 = CONSENSUS_RPC_ERROR,
291
- 25 = STORAGE_RPC_ERROR,
292
- 26 = NOENT,
293
- 27 = ACCOUNT_MIGRATED,
294
- 28 = RPC_CONNECTION_ERROR,
295
- 30 = UNSUPPORTED_STAKE,
296
- 31 = INSUFFICIENT_STAKE,
297
- 32 = INVALID_STAKE_STATE,
298
- 33 = EXPIRED_WALLET_TOKEN,
299
- 34 = BANNED_UNSTAKE,
300
- 35 = INVALID_ASSET,
301
- 36 = INVALID_TX_SIZE,
302
- 37 = INVALID_SIGNER_STATE,
303
- 38 = INVALID_FORGE_STATE,
304
- 39 = EXPIRED_ASSET,
305
- 40 = UNTRANSFERRABLE_ASSET,
306
- 41 = READONLY_ASSET,
307
- 42 = CONSUMED_ASSET,
308
- 43 = INVALID_DEPOSIT_VALUE,
309
- 44 = EXCEED_DEPOSIT_CAP,
310
- 45 = INVALID_DEPOSIT_TARGET,
311
- 46 = INVALID_DEPOSITOR,
312
- 47 = INVALID_WITHDRAWER,
313
- 49 = INVALID_EXPIRY_DATE,
314
- 51 = INVALID_CUSTODIAN,
315
- 52 = INSUFFICIENT_GAS,
316
- 53 = INVALID_SWAP,
317
- 54 = INVALID_HASHKEY,
318
- 55 = INVALID_DELEGATION,
319
- 56 = INSUFFICIENT_DELEGATION,
320
- 57 = INVALID_DELEGATION_RULE,
321
- 58 = INVALID_DELEGATION_TYPE_URL,
322
- 59 = SENDER_NOT_AUTHORIZED,
323
- 60 = PROTOCOL_NOT_RUNNING,
324
- 61 = PROTOCOL_NOT_PAUSED,
325
- 62 = PROTOCOL_NOT_ACTIVATED,
326
- 63 = INVALID_DEACTIVATION,
327
- 64 = SENDER_WITHDRAW_ITEMS_FULL,
328
- 65 = WITHDRAW_ITEM_MISSING,
329
- 66 = INVALID_WITHDRAW_TX,
330
- 67 = INVALID_CHAIN_TYPE,
331
- 68 = INVALID_TIME,
332
- 69 = INVALID_SUBSCRIBE,
333
- 70 = INVALID_DID_TYPE,
334
- 71 = INVALID_CANDIDATE_STATE,
335
- 72 = VALIDATOR_NOT_FOUND,
336
- 73 = VALIDATOR_NOT_CHANGED,
337
- 74 = INVALID_FACTORY_STATE,
338
- 75 = INVALID_FACTORY_PROPS,
339
- 76 = INVALID_FACTORY_INPUT,
340
- 77 = INVALID_TOKEN,
341
- 78 = INVALID_ROLLUP,
342
- 79 = INVALID_BLOCK,
343
- 403 = FORBIDDEN,
344
- 500 = INTERNAL,
345
- 504 = TIMEOUT,
346
- }
347
-
348
- export enum KeyType {
349
- 0 = ED25519,
350
- 1 = SECP256K1,
351
- 2 = ETHEREUM,
352
- }
353
-
354
- export enum HashType {
355
- 0 = KECCAK,
356
- 1 = SHA3,
357
- 2 = SHA2,
358
- 6 = KECCAK_384,
359
- 7 = SHA3_384,
360
- 13 = KECCAK_512,
361
- 14 = SHA3_512,
362
- }
363
-
364
- export enum EncodingType {
365
- 0 = BASE16,
366
- 1 = BASE58,
367
- }
368
-
369
- export enum RoleType {
370
- 0 = ROLE_ACCOUNT,
371
- 1 = ROLE_NODE,
372
- 2 = ROLE_DEVICE,
373
- 3 = ROLE_APPLICATION,
374
- 4 = ROLE_SMART_CONTRACT,
375
- 5 = ROLE_BOT,
376
- 6 = ROLE_ASSET,
377
- 7 = ROLE_STAKE,
378
- 8 = ROLE_VALIDATOR,
379
- 9 = ROLE_GROUP,
380
- 10 = ROLE_TX,
381
- 11 = ROLE_TETHER,
382
- 12 = ROLE_SWAP,
383
- 13 = ROLE_DELEGATION,
384
- 14 = ROLE_VC,
385
- 15 = ROLE_BLOCKLET,
386
- 16 = ROLE_STORE,
387
- 17 = ROLE_TOKEN,
388
- 18 = ROLE_FACTORY,
389
- 19 = ROLE_ROLLUP,
390
- 20 = ROLE_STORAGE,
391
- 63 = ROLE_ANY,
392
- }
393
-
394
- export enum UpgradeType {
395
- 0 = CONFIG_APP,
396
- 1 = CONFIG_FORGE,
397
- 2 = CONFIG_DFS,
398
- 3 = CONFIG_CONSENSUS,
399
- 4 = CONFIG_P2P,
400
- 10 = EXE_APP,
401
- 11 = EXE_FORGE,
402
- 12 = EXE_DFS,
403
- 13 = EXE_CONSENSUS,
404
- 14 = EXE_P2P,
405
- }
406
-
407
- export enum UpgradeAction {
408
- 0 = VERIFY,
409
- 1 = BACKUP,
410
- 2 = REPLACE,
411
- 10 = RESTART_APP,
412
- 11 = RESTART_DFS,
413
- 12 = RESTART_CONSENSUS,
414
- 13 = RESTART_P2P,
415
- 14 = RESTART_FORGE,
416
- 30 = ROLLBACK_IF_FAIL,
417
- 31 = RESTART_ALL_IF_FAIL,
418
- 33 = CRASH_IF_FAIL,
419
- 50 = DROP_ADDRESS_BOOK,
420
- }
421
-
422
- export enum StateType {
423
- 0 = STATE_ACCOUNT,
424
- 1 = STATE_ASSET,
425
- 2 = STATE_CHANNEL,
426
- 3 = STATE_FORGE,
427
- 4 = STATE_STAKE,
428
- }
429
-
430
- export enum StakeType {
431
- 0 = STAKE_NODE,
432
- 1 = STAKE_USER,
433
- 2 = STAKE_ASSET,
434
- 3 = STAKE_CHAIN,
435
- }
436
-
437
- export enum ProtocolStatus {
438
- 0 = RUNNING,
439
- 1 = PAUSED,
440
- 2 = TERMINATED,
441
- }
442
-
443
- export enum TokenFactoryStatus {
444
- 0 = TOKEN_FACTORY_ACTIVE,
445
- 1 = TOKEN_FACTORY_PAUSED,
446
- }
447
-
448
- export enum Direction {
449
- 0 = MUTUAL,
450
- 1 = ONE_WAY,
451
- 2 = UNION,
452
- }
453
-
454
- export enum Validity {
455
- 0 = BOTH,
456
- 1 = VALID,
457
- 2 = INVALID,
458
- }
459
-
460
- export enum TokenFlowDirection {
461
- 0 = IN,
462
- 1 = OUT,
463
- }
464
-
465
- export interface main {
466
- StatusCode: typeof Messages.StatusCode;
467
- KeyType: typeof Messages.KeyType;
468
- HashType: typeof Messages.HashType;
469
- EncodingType: typeof Messages.EncodingType;
470
- RoleType: typeof Messages.RoleType;
471
- UpgradeType: typeof Messages.UpgradeType;
472
- UpgradeAction: typeof Messages.UpgradeAction;
473
- StateType: typeof Messages.StateType;
474
- StakeType: typeof Messages.StakeType;
475
- ProtocolStatus: typeof Messages.ProtocolStatus;
476
- TokenFactoryStatus: typeof Messages.TokenFactoryStatus;
477
- Direction: typeof Messages.Direction;
478
- Validity: typeof Messages.Validity;
479
- TokenFlowDirection: typeof Messages.TokenFlowDirection;
480
- }
481
- }
7
+ export * from './runtime';
package/lib/index.js CHANGED
@@ -1,5 +1,18 @@
1
- const proto = require('./proto');
2
- const provider = require('./provider');
3
- const json = require('./gen/spec.json');
1
+ /**
2
+ * `@ocap/proto` aggregate entry — DEPRECATED.
3
+ *
4
+ * Retained for backwards compatibility. New code should import the explicit
5
+ * subpath it needs:
6
+ *
7
+ * - Tree-shake-sensitive (CBOR path, Client SDK): `@ocap/proto/schema`
8
+ * - Chain side / protobuf runtime: `@ocap/proto/runtime`
9
+ *
10
+ * Importing the aggregate entry forces the full protobuf runtime into the
11
+ * bundle (~1 MB of `*_pb.js` + `google-protobuf`). Subpath imports let
12
+ * bundlers drop the runtime for CBOR-only consumers.
13
+ *
14
+ * @module @ocap/proto
15
+ * @deprecated Use `@ocap/proto/schema` or `@ocap/proto/runtime`.
16
+ */
4
17
 
5
- module.exports = provider(proto, json);
18
+ module.exports = require('./runtime');
package/lib/provider.js CHANGED
@@ -8,9 +8,16 @@
8
8
  * const { enums, fromTypeUrl, toTypeUrl } = ocapProto;
9
9
  */
10
10
 
11
- const get = require('lodash/get');
12
11
  const debug = require('debug')(require('../package.json').name);
13
12
 
13
+ // Dotted-path lookup. Replaces lodash/get so the runtime stays off lodash;
14
+ // callers pass `vendor.Version` / `google.protobuf.Any` style keys.
15
+ const getByPath = (obj, path) => {
16
+ if (!obj || !path) return undefined;
17
+ if (Object.prototype.hasOwnProperty.call(obj, path)) return obj[path];
18
+ return path.split('.').reduce((o, k) => (o == null ? o : o[k]), obj);
19
+ };
20
+
14
21
  /**
15
22
  * Generate type provider from types map and json spec
16
23
  *
@@ -120,9 +127,9 @@ module.exports = function createProvider(proto, json, urls = {}) {
120
127
  * @returns {object}
121
128
  */
122
129
  function getMessageType(type) {
123
- const { fields, oneofs } = get(spec, type) || get(spec, `vendor.${type}`) || {};
130
+ const { fields, oneofs } = getByPath(spec, type) || getByPath(spec, `vendor.${type}`) || {};
124
131
  return {
125
- fn: get(types, type) || get(vendorTypes, type) || get(vendorTypes, type.split('.').pop()),
132
+ fn: getByPath(types, type) || getByPath(vendorTypes, type) || vendorTypes[type.split('.').pop()],
126
133
  fields,
127
134
  oneofs,
128
135
  };
@@ -141,7 +148,7 @@ module.exports = function createProvider(proto, json, urls = {}) {
141
148
  * @returns {string}
142
149
  */
143
150
  function toTypeUrl(type) {
144
- return get(typeUrls, type) || type;
151
+ return typeUrls[type] || type;
145
152
  }
146
153
 
147
154
  /**
@@ -0,0 +1,26 @@
1
+ // `@ocap/proto/runtime` — full protobuf runtime declarations.
2
+ // Exposes jspb constructors via `getMessageType(type).fn`; use
3
+ // `@ocap/proto/schema` for tree-shake-sensitive (CBOR-only) consumers.
4
+
5
+ declare const forgeTypes: Record<string, unknown>;
6
+ export const vendorTypes: Record<string, unknown>;
7
+ export { forgeTypes as types };
8
+
9
+ export interface MessageTypeResult {
10
+ fn?: new () => unknown;
11
+ fields?: Record<string, unknown>;
12
+ oneofs?: Record<string, unknown>;
13
+ }
14
+
15
+ export const enums: Record<string, Record<string, number>>;
16
+ export const messages: Record<string, Record<number, string>>;
17
+ export const typeUrls: Record<string, string>;
18
+ export const transactions: string[];
19
+ export const multiSignTxs: string[];
20
+ export const multiSignV2Txs: string[];
21
+ export const stakes: string[];
22
+
23
+ export function getMessageType(type: string): MessageTypeResult;
24
+ export function compactSpec(object: Record<string, unknown>): Record<string, unknown>;
25
+ export function toTypeUrl(type: string): string;
26
+ export function fromTypeUrl(url: string): string;
package/lib/runtime.js ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * `@ocap/proto/runtime` — full protobuf runtime entry.
3
+ *
4
+ * Pulls in every generated `*_pb.js` constructor so callers get
5
+ * `getMessageType(type).fn` returning the jspb class. This is what the chain
6
+ * side, `@ocap/message/protobuf`, and legacy `@ocap/proto` consumers need.
7
+ *
8
+ * Tree-shake-sensitive callers (new Client SDK CBOR path) should import from
9
+ * `@ocap/proto/schema` instead — that subpath never requires `*_pb.js` and
10
+ * therefore never drags `google-protobuf` into the bundle.
11
+ *
12
+ * @module @ocap/proto/runtime
13
+ */
14
+
15
+ const enumPb = require('./gen/enum_pb.js');
16
+ const txPb = require('./gen/tx_pb.js');
17
+ const typePb = require('./gen/type_pb.js');
18
+ const vendorPb = require('./gen/vendor_pb.js');
19
+ const createProvider = require('./provider');
20
+ // Runtime path needs the full schema (core + rpc) because `@ocap/message`
21
+ // createMessage/formatMessage traverse Request/Response fields too. Merge the
22
+ // two partitions under `ocap.nested` — they share no keys by construction
23
+ // (enforced by tools/split-spec.js).
24
+ //
25
+ // `structuredClone` is mandatory because `createProvider → compactSpec`
26
+ // mutates its input. Node caches JSON requires, so whichever entry (schema or
27
+ // runtime) loads second would otherwise see the first's mutation and produce
28
+ // garbage field lookups. `spec.rpc.json` is private to runtime but cloned
29
+ // for symmetry and cheap insurance.
30
+ const specCore = structuredClone(require('./gen/spec.core.json'));
31
+ const specRpc = structuredClone(require('./gen/spec.rpc.json'));
32
+
33
+ const spec = {
34
+ options: specCore.options,
35
+ nested: {
36
+ ocap: {
37
+ nested: Object.assign({}, specCore.nested.ocap.nested, specRpc.nested.ocap.nested),
38
+ },
39
+ google: specCore.nested.google,
40
+ vendor: specCore.nested.vendor,
41
+ },
42
+ };
43
+
44
+ const types = Object.assign({}, enumPb, txPb, typePb);
45
+ const vendorTypes = Object.assign({}, vendorPb);
46
+
47
+ const runtime = createProvider({ types, vendorTypes }, spec);
48
+
49
+ module.exports = Object.assign({}, runtime, { types, vendorTypes });