@ocap/types 1.30.25 → 1.31.0

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.
@@ -49,6 +49,47 @@ export interface IAccountConfig extends Omit<TAccountConfig, 'pk' | 'balance'> {
49
49
  export interface ITxGasConfig extends Omit<TTxGasConfig, 'minStake' | 'maxStake'> {
50
50
  minStake: number;
51
51
  maxStake: number;
52
+ /** Max tx size (bytes) eligible for the Stake-for-Gas waiver (default 4096) */
53
+ maxFreeGasTxSize?: number;
54
+ /** Max state ops eligible for the Stake-for-Gas waiver (default 6) */
55
+ maxFreeGasStateOps?: number;
56
+ enforceSponsor3DEligibility?: boolean;
57
+ /** Burst quota sliding window in ms (default 60000) */
58
+ burstWindowMs?: number;
59
+ /** Burst quota: tx per window per sender before stake multiple (default 10) */
60
+ baseBurstAllowance?: number;
61
+ }
62
+
63
+ /**
64
+ * Gas security guard configuration (`transaction.security`).
65
+ * Outcomes of executed txs never depend on these process-local counters; they only drive pre-queue admission.
66
+ */
67
+ export interface ITxSecurityConfig {
68
+ /** Master switch (default true) */
69
+ enabled?: boolean;
70
+ /** Strike-based expiring admission cooldown (default true) */
71
+ throttle?: boolean;
72
+ /** Per-sender burst quota enforced at admission; never reprices gas (default true) */
73
+ burstEscalation?: boolean;
74
+ /** Experimental auto-slash inside a queued tx's own write set (default false) */
75
+ autoSlash?: boolean;
76
+ /** Process-local gas pass nullifier registry (default false, non-deterministic across processes) */
77
+ gasPassNullifierCheck?: boolean;
78
+ strikeOnAllErrors?: boolean;
79
+ /** Admission rejects above baseBurstAllowance x stakeMultiple x this (default 6) */
80
+ burstRejectMultiple?: number;
81
+ /** Aggregate per-delegatee cap across principals = hard limit x this (default 20) */
82
+ delegatedBurstMultiple?: number;
83
+ strikeWindowMs?: number;
84
+ warningThreshold?: number;
85
+ throttleThreshold?: number;
86
+ slashThreshold?: number;
87
+ throttleCooldownMs?: number;
88
+ gasPassEpochSeconds?: number;
89
+ fishermanBountyBps?: number;
90
+ fishermanAddress?: string;
91
+ /** Addresses never struck, throttled or burst-limited (operator infrastructure allowlist) */
92
+ exemptActors?: string[];
52
93
  }
53
94
 
54
95
  /**
@@ -75,8 +116,9 @@ export interface ITransactionConfig extends Omit<TTransactionConfig, 'txFee' | '
75
116
  delegate: TDelegateConfig;
76
117
  supportedTxs: string[];
77
118
  multiSignV2Txs: string[];
78
- /** Optional activation height for unsignedTxHash deduplication (default: 0, always active) */
79
- unsignedTxHashDedupHeight?: number;
119
+ /** Post-execution write-set ceiling (entries) */
120
+ maxWriteSetSize?: number;
121
+ security?: ITxSecurityConfig;
80
122
  }
81
123
 
82
124
  /**
@@ -67,6 +67,7 @@ export type {
67
67
  IAccountConfig,
68
68
  ITxGasConfig,
69
69
  ITxStakeConfig,
70
+ ITxSecurityConfig,
70
71
  ITransactionConfig,
71
72
  ITokenConfig,
72
73
  IVaultsConfig,
@@ -270,6 +271,8 @@ export type {
270
271
  ISignedTransactionInput,
271
272
  // Storage interface
272
273
  ILedgerStorage,
274
+ EntryHashVersion,
275
+ IEntryHashPolicy,
273
276
  // Main interface
274
277
  ILedger,
275
278
  // Factory interface
@@ -42,7 +42,11 @@ export interface ILedgerEntry {
42
42
  /** Chain DID this entry belongs to */
43
43
  chainId: string;
44
44
 
45
- /** hash(sequence + txRaw) for Merkle Tree leaf */
45
+ /**
46
+ * Versioned hash of (sequence, txRaw, stateCommitHash) for the Merkle Tree leaf.
47
+ * v1 (legacy, <= 1.30.26): sha256(seq || txRaw || stateCommitHash); v2: length-prefixed framing.
48
+ * The version is a function of `sequence` (see IEntryHashPolicy), never stored per entry.
49
+ */
46
50
  entryHash: string;
47
51
 
48
52
  /** Transaction verification context (passkey, gasStakeHeaders, etc.) */
@@ -261,10 +265,27 @@ export interface ISignedTransactionInput {
261
265
  // Storage Interface
262
266
  // ============================================================================
263
267
 
268
+ /** Entry hash format version. 1 = legacy concatenation, 2 = length-prefixed framing. */
269
+ export type EntryHashVersion = 1 | 2;
270
+
271
+ /**
272
+ * Per-chain entry hash policy. Entries with `sequence >= v2From` are hashed with v2, earlier ones with v1.
273
+ * `v2From = Infinity` means the chain is still fully legacy (v2 not activated).
274
+ */
275
+ export interface IEntryHashPolicy {
276
+ readonly v2From: number;
277
+ versionFor(sequence: number): EntryHashVersion;
278
+ /** Re-derive the policy from stored data (after bulk imports / reset). */
279
+ resolve?(storage: ILedgerStorage): Promise<unknown>;
280
+ }
281
+
264
282
  /**
265
283
  * Storage adapter interface - SQLite/Dolt implement this
266
284
  */
267
285
  export interface ILedgerStorage {
286
+ /** Entry hash policy used by this storage for append/finalize (optional; absent = v2 everywhere). */
287
+ getEntryHashPolicy?(): IEntryHashPolicy;
288
+
268
289
  // Entry operations
269
290
  appendEntries(entries: ILedgerEntry[]): Promise<void>;
270
291
 
@@ -395,7 +416,8 @@ export interface IVerifyTxInclusionParams {
395
416
  txHash?: string;
396
417
 
397
418
  /** Ledger entry returned by getLedgerEntry */
398
- entry: Pick<ILedgerEntry, 'sequence' | 'hash' | 'txRaw' | 'entryHash' | 'stateCommitHash' | 'finalized'>;
419
+ entry: Pick<ILedgerEntry, 'sequence' | 'hash' | 'txRaw' | 'entryHash' | 'stateCommitHash' | 'finalized'> &
420
+ Partial<Pick<ILedgerEntry, 'from' | 'nonce' | 'pk' | 'signature' | 'tx' | 'txType' | 'chainId'>>;
399
421
 
400
422
  /** Merkle inclusion proof returned by getMerkleProof */
401
423
  proof: IMerkleProof;
@@ -429,6 +451,28 @@ export interface IVerifyTxInclusionParams {
429
451
  */
430
452
  verifyTxRawHash?: boolean;
431
453
 
454
+ /**
455
+ * Controls verification of decoded entry fields (`entry.tx`, `from`, `pk`, `nonce`, `signature`,
456
+ * `txType`, `chainId`) against `entry.txRaw` (#1139).
457
+ * - `undefined` (default): automatically decodes `txRaw` when it is an OCAP wire transaction
458
+ * (CBOR/Protobuf) or a canonical JSON payload (`EmbeddedLedger`/`WalletLedger`) and rejects any
459
+ * mismatch on present `entry` fields.
460
+ * - `true`: strictly requires `txRaw` to be decodable and rejects if decoding fails or any present
461
+ * field mismatches.
462
+ * - `false`: skips decoded-field comparison.
463
+ */
464
+ verifyDecodedEntry?: boolean;
465
+
466
+ /**
467
+ * Entry hash versioning (#1337). Entries with `sequence >= entryHashV2From` must be v2
468
+ * (length-prefixed) and earlier ones v1 (legacy, <= 1.30.26). When omitted the verifier accepts
469
+ * either format (v2 first, then legacy v1), which keeps historical proofs verifying.
470
+ */
471
+ entryHashV2From?: number;
472
+
473
+ /** Set false to refuse legacy v1 entry hashes when `entryHashV2From` is unknown (default true). */
474
+ allowLegacyEntryHash?: boolean;
475
+
432
476
  /** Optional k-of-n witness cosigning threshold (default 0) */
433
477
  witnessQuorum?: number;
434
478
 
@@ -442,13 +486,14 @@ export interface IVerifyTxInclusionParams {
442
486
  /**
443
487
  * Result of `verifyTxInclusion`.
444
488
  *
445
- * Only `txRaw` is authenticated: `entryHash` covers `sequence`, `txRaw` and `stateCommitHash`, not
446
- * `entry.tx`, `from`, `pk`, `nonce` or `signature`. A `verified: true` result says nothing about those
447
- * fields. Decode the verified `txRaw` yourself; never read `entry.tx` directly (#1139).
489
+ * When `txRaw` is an OCAP wire transaction (CBOR/Protobuf) or canonical JSON payload, `verifyTxInclusion`
490
+ * decodes `txRaw`, verifies any present `entry.tx`, `from`, `pk`, `nonce`, `signature`, `txType`, and
491
+ * `chainId` fields against the decoded payload (#1139), and exposes the verified payload on `decodedTx`.
448
492
  */
449
493
  export interface IVerifyTxInclusionResult {
450
494
  verified: boolean;
451
495
  reason?: string;
496
+ decodedTx?: Record<string, unknown>;
452
497
  }
453
498
 
454
499
  /**
@@ -213,6 +213,16 @@ export interface IDelegationTokenLimit {
213
213
  txSent?: number;
214
214
  lastTx?: number;
215
215
  spentAllowance?: string;
216
+ maxPerTx?: string;
217
+ windowLimit?: string;
218
+ windowSeconds?: number;
219
+ windowStart?: number;
220
+ windowSpent?: string;
221
+ coSignAllowance?: string;
222
+ coSignRequired?: boolean;
223
+ requirePinnedPayee?: boolean;
224
+ notifyBeforeDebit?: boolean;
225
+ notifyLeadSeconds?: number;
216
226
  }
217
227
 
218
228
  /** Asset limit in delegation ops */
@@ -230,6 +240,7 @@ export interface IDelegationAssetLimit {
230
240
  export interface IDelegationOpLimit {
231
241
  tokens?: IDelegationTokenLimit[];
232
242
  assets?: IDelegationAssetLimit[];
243
+ unlimited?: boolean;
233
244
  }
234
245
 
235
246
  /** Delegation ops: typeUrl -> operation with limits */
package/lib/type_pb.d.ts CHANGED
@@ -459,6 +459,16 @@ export type TTokenLimit = {
459
459
  lastTx: number,
460
460
  decimal: number,
461
461
  symbol: string,
462
+ maxPerTx?: string,
463
+ windowLimit?: string,
464
+ windowSeconds?: number,
465
+ windowStart?: number,
466
+ windowSpent?: string,
467
+ coSignAllowance?: string,
468
+ coSignRequired?: boolean,
469
+ requirePinnedPayee?: boolean,
470
+ notifyBeforeDebit?: boolean,
471
+ notifyLeadSeconds?: number,
462
472
  }
463
473
 
464
474
  export type TAssetLimit = {
@@ -474,6 +484,7 @@ export type TAssetLimit = {
474
484
  export type TDelegateLimit = {
475
485
  tokens: Array<TTokenLimit>,
476
486
  assets: Array<TAssetLimit>,
487
+ unlimited?: boolean,
477
488
  }
478
489
 
479
490
  export type TCurveConfig = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocap/types",
3
- "version": "1.30.25",
3
+ "version": "1.31.0",
4
4
  "description": "Typescript definitions generated from protobuf",
5
5
  "keywords": [
6
6
  "ocap",