@ocap/tx-pipeline 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.
Files changed (149) hide show
  1. package/esm/appchain-sovereign-hub.d.mts +160 -0
  2. package/esm/appchain-sovereign-hub.mjs +348 -0
  3. package/esm/arcvault-external-adapter.d.mts +166 -0
  4. package/esm/arcvault-external-adapter.mjs +376 -0
  5. package/esm/encrypted-nft-envelope.d.mts +172 -0
  6. package/esm/encrypted-nft-envelope.mjs +458 -0
  7. package/esm/evm-simplified-bridge.d.mts +1370 -0
  8. package/esm/evm-simplified-bridge.mjs +3875 -0
  9. package/esm/give-to-mint-karma.d.mts +472 -0
  10. package/esm/give-to-mint-karma.mjs +1057 -0
  11. package/esm/helpers/replay-guard.d.mts +15 -0
  12. package/esm/helpers/replay-guard.mjs +23 -0
  13. package/esm/index.d.mts +10 -5
  14. package/esm/index.mjs +14 -10
  15. package/esm/legacy-protocol-sunset.d.mts +251 -0
  16. package/esm/legacy-protocol-sunset.mjs +1519 -0
  17. package/esm/library.d.mts +16 -0
  18. package/esm/library.mjs +17 -0
  19. package/esm/native-abt-exchange.d.mts +2055 -0
  20. package/esm/native-abt-exchange.mjs +7250 -0
  21. package/esm/ofac-screening.d.mts +17 -0
  22. package/esm/ofac-screening.mjs +39 -0
  23. package/esm/pipes/anti-land-attack.mjs +1 -1
  24. package/esm/pipes/decode-itx.mjs +43 -4
  25. package/esm/pipes/decode-tx.d.mts +2 -3
  26. package/esm/pipes/decode-tx.mjs +53 -115
  27. package/esm/pipes/extract-signer.mjs +2 -2
  28. package/esm/pipes/extract-state.mjs +14 -3
  29. package/esm/pipes/post-execution-invariant-gate.d.mts +61 -0
  30. package/esm/pipes/post-execution-invariant-gate.mjs +789 -0
  31. package/esm/pipes/pre-flight-waf.d.mts +34 -0
  32. package/esm/pipes/pre-flight-waf.mjs +603 -0
  33. package/esm/pipes/take-state-snapshot.mjs +3 -2
  34. package/esm/pipes/update-owner.mjs +39 -4
  35. package/esm/pipes/verify-account-migration.mjs +14 -4
  36. package/esm/pipes/verify-blocked.mjs +1 -1
  37. package/esm/pipes/verify-delegation.d.mts +22 -3
  38. package/esm/pipes/verify-delegation.mjs +259 -36
  39. package/esm/pipes/verify-list-size.mjs +1 -1
  40. package/esm/pipes/verify-multisig-v2.mjs +15 -7
  41. package/esm/pipes/verify-multisig.mjs +15 -7
  42. package/esm/pipes/verify-sender.mjs +1 -1
  43. package/esm/pipes/verify-signature.mjs +35 -6
  44. package/esm/pipes/verify-signer.mjs +2 -2
  45. package/esm/pipes/verify-state-diff.mjs +3 -3
  46. package/esm/pipes/verify-token-access.mjs +1 -1
  47. package/esm/pipes/verify-token-balance.mjs +13 -5
  48. package/esm/pipes/verify-transferrable.d.mts +8 -1
  49. package/esm/pipes/verify-transferrable.mjs +3 -3
  50. package/esm/pipes/verify-tx-input.mjs +2 -2
  51. package/esm/pipes/verify-tx-size.mjs +46 -2
  52. package/esm/pipes/verify-tx.mjs +5 -7
  53. package/esm/pipes/verify-updater.mjs +1 -1
  54. package/esm/social-economy-factories.d.mts +346 -0
  55. package/esm/social-economy-factories.mjs +845 -0
  56. package/esm/super-suites-foundation.d.mts +513 -0
  57. package/esm/super-suites-foundation.mjs +1241 -0
  58. package/esm/transaction-block.d.mts +471 -0
  59. package/esm/transaction-block.mjs +1906 -0
  60. package/esm/uniswap-erc7683-solver.d.mts +201 -0
  61. package/esm/uniswap-erc7683-solver.mjs +321 -0
  62. package/esm/uniswap-lp-copilot.d.mts +113 -0
  63. package/esm/uniswap-lp-copilot.mjs +320 -0
  64. package/esm/uniswap-router.d.mts +335 -0
  65. package/esm/uniswap-router.mjs +578 -0
  66. package/esm/uniswap-token-factory-graduation.d.mts +187 -0
  67. package/esm/uniswap-token-factory-graduation.mjs +426 -0
  68. package/esm/uniswap-v4-hook.d.mts +173 -0
  69. package/esm/uniswap-v4-hook.mjs +517 -0
  70. package/lib/appchain-sovereign-hub.cjs +352 -0
  71. package/lib/appchain-sovereign-hub.d.cts +160 -0
  72. package/lib/arcvault-external-adapter.cjs +383 -0
  73. package/lib/arcvault-external-adapter.d.cts +166 -0
  74. package/lib/encrypted-nft-envelope.cjs +477 -0
  75. package/lib/encrypted-nft-envelope.d.cts +172 -0
  76. package/lib/evm-simplified-bridge.cjs +3943 -0
  77. package/lib/evm-simplified-bridge.d.cts +1370 -0
  78. package/lib/give-to-mint-karma.cjs +1084 -0
  79. package/lib/give-to-mint-karma.d.cts +472 -0
  80. package/lib/helpers/replay-guard.cjs +27 -0
  81. package/lib/helpers/replay-guard.d.cts +15 -0
  82. package/lib/index.cjs +49 -16
  83. package/lib/index.d.cts +10 -5
  84. package/lib/legacy-protocol-sunset.cjs +1543 -0
  85. package/lib/legacy-protocol-sunset.d.cts +251 -0
  86. package/lib/library.cjs +303 -0
  87. package/lib/library.d.cts +16 -0
  88. package/lib/native-abt-exchange.cjs +7322 -0
  89. package/lib/native-abt-exchange.d.cts +2055 -0
  90. package/lib/ofac-screening.cjs +42 -0
  91. package/lib/ofac-screening.d.cts +17 -0
  92. package/lib/pipes/anti-land-attack.cjs +2 -2
  93. package/lib/pipes/decode-itx.cjs +43 -4
  94. package/lib/pipes/decode-itx.d.cts +1 -1
  95. package/lib/pipes/decode-tx.cjs +52 -116
  96. package/lib/pipes/decode-tx.d.cts +3 -4
  97. package/lib/pipes/extract-signer.cjs +2 -2
  98. package/lib/pipes/extract-state.cjs +14 -3
  99. package/lib/pipes/post-execution-invariant-gate.cjs +800 -0
  100. package/lib/pipes/post-execution-invariant-gate.d.cts +61 -0
  101. package/lib/pipes/pre-flight-waf.cjs +616 -0
  102. package/lib/pipes/pre-flight-waf.d.cts +34 -0
  103. package/lib/pipes/take-state-snapshot.cjs +3 -2
  104. package/lib/pipes/update-owner.cjs +40 -5
  105. package/lib/pipes/update-owner.d.cts +1 -1
  106. package/lib/pipes/verify-account-migration.cjs +14 -4
  107. package/lib/pipes/verify-blocked.cjs +1 -1
  108. package/lib/pipes/verify-delegation.cjs +259 -36
  109. package/lib/pipes/verify-delegation.d.cts +22 -3
  110. package/lib/pipes/verify-list-size.cjs +1 -1
  111. package/lib/pipes/verify-multisig-v2.cjs +15 -7
  112. package/lib/pipes/verify-multisig.cjs +15 -7
  113. package/lib/pipes/verify-sender.cjs +1 -1
  114. package/lib/pipes/verify-service-fee.d.cts +1 -1
  115. package/lib/pipes/verify-signature.cjs +35 -6
  116. package/lib/pipes/verify-signature.d.cts +1 -1
  117. package/lib/pipes/verify-signer.cjs +2 -2
  118. package/lib/pipes/verify-state-diff.cjs +4 -4
  119. package/lib/pipes/verify-token-access.cjs +2 -2
  120. package/lib/pipes/verify-token-balance.cjs +13 -5
  121. package/lib/pipes/verify-transferrable.cjs +3 -3
  122. package/lib/pipes/verify-transferrable.d.cts +8 -1
  123. package/lib/pipes/verify-tx-input.cjs +3 -3
  124. package/lib/pipes/verify-tx-size.cjs +46 -2
  125. package/lib/pipes/verify-tx-size.d.cts +1 -1
  126. package/lib/pipes/verify-tx.cjs +6 -8
  127. package/lib/pipes/verify-tx.d.cts +1 -1
  128. package/lib/pipes/verify-updater.cjs +1 -1
  129. package/lib/social-economy-factories.cjs +852 -0
  130. package/lib/social-economy-factories.d.cts +346 -0
  131. package/lib/super-suites-foundation.cjs +1257 -0
  132. package/lib/super-suites-foundation.d.cts +513 -0
  133. package/lib/transaction-block.cjs +1941 -0
  134. package/lib/transaction-block.d.cts +471 -0
  135. package/lib/uniswap-erc7683-solver.cjs +327 -0
  136. package/lib/uniswap-erc7683-solver.d.cts +201 -0
  137. package/lib/uniswap-lp-copilot.cjs +328 -0
  138. package/lib/uniswap-lp-copilot.d.cts +113 -0
  139. package/lib/uniswap-router.cjs +593 -0
  140. package/lib/uniswap-router.d.cts +335 -0
  141. package/lib/uniswap-token-factory-graduation.cjs +431 -0
  142. package/lib/uniswap-token-factory-graduation.d.cts +187 -0
  143. package/lib/uniswap-v4-hook.cjs +527 -0
  144. package/lib/uniswap-v4-hook.d.cts +173 -0
  145. package/package.json +11 -10
  146. package/esm/helpers/dedup-height.d.mts +0 -16
  147. package/esm/helpers/dedup-height.mjs +0 -61
  148. package/lib/helpers/dedup-height.cjs +0 -72
  149. package/lib/helpers/dedup-height.d.cts +0 -16
@@ -0,0 +1,172 @@
1
+ //#region src/encrypted-nft-envelope.d.ts
2
+ declare const ENCRYPTED_NFT_SCHEMA_VERSION: "ocap.nft.encrypted.v1";
3
+ declare const MAX_ENCRYPTED_NFT_CIPHERTEXT_HEX_CHARS = 8192;
4
+ declare const MAX_ENCRYPTED_NFT_TAGS = 16;
5
+ declare const MAX_ENCRYPTED_NFT_TAG_LENGTH = 64;
6
+ declare const MAX_ENCRYPTED_NFT_CATEGORY_LENGTH = 64;
7
+ declare const MAX_ENCRYPTED_NFT_SUMMARY_LENGTH = 512;
8
+ declare const MAX_ENCRYPTED_NFT_URI_LENGTH = 512;
9
+ type EncryptedNftAlgorithm = 'X25519-XSalsa20-Poly1305' | 'ECIES-Secp256k1-AES256GCM' | 'OCAP-ECDH-HKDF-SHA256';
10
+ declare const VALID_ENCRYPTED_NFT_ALGORITHMS: Set<EncryptedNftAlgorithm>;
11
+ interface EncryptedNftPrivateMetadata {
12
+ /** Private full listing/asset title visible only to current owner after decryption */
13
+ title: string;
14
+ /** Optional detailed specification, prompt recipe, or workflow blueprint */
15
+ description?: string;
16
+ /** Optional AI prompt / workflow recipe or structured configuration */
17
+ recipePayload?: Record<string, unknown>;
18
+ /** Optional ArcSpace access token or signed delivery credential */
19
+ arcSpaceAccessCredential?: string;
20
+ /** Optional high-resolution preview or deliverable sub-path inside ArcSpace */
21
+ arcSpaceDeliverablePath?: string;
22
+ /** Optional custom key-value attributes visible only to the owner */
23
+ privateAttributes?: Record<string, string | number | boolean>;
24
+ }
25
+ interface EncryptedNftPublicDiscoveryHeader {
26
+ schemaVersion: typeof ENCRYPTED_NFT_SCHEMA_VERSION;
27
+ /** Public discovery category (e.g. 'AI_SKILL', 'PLAYWRIGHT_SCRAPER', 'TRANSLATION', 'VECTOR_ASSET') */
28
+ category: string;
29
+ /** Bounded public discovery tags (e.g. ['#AI-Skill', '#Playwright-Scraper']) */
30
+ tags: string[];
31
+ /** Safe public non-alpha summary displayed to external chain scanners */
32
+ publicSummary: string;
33
+ /** Canonical SHA-256 commitment of the decrypted plaintext metadata (`computeEncryptedNftPlaintextHash`) */
34
+ plaintextHash: string;
35
+ /** Canonical SHA-256 commitment of the 32-byte Content Encryption Key (`computeEncryptedNftCekCommitmentHash`) */
36
+ cekCommitmentHash: string;
37
+ /** Compressed 33-byte (66-hex) secp256k1 public key derived from `CEK` (`P_cek = cek * G`) for handover proof verification */
38
+ cekPublicKeyHex: string;
39
+ /** Optional pointer to the encrypted large payload stored in Creator/Holder ArcSpace (`arcspace://...`) */
40
+ arcSpaceUri?: string;
41
+ }
42
+ interface EncryptedNftOwnerCipherEnvelope {
43
+ alg: EncryptedNftAlgorithm;
44
+ /** Current owner DID authorized to decrypt this envelope */
45
+ ownerDid: string;
46
+ /** Normalized 33-byte (66-hex) compressed secp256k1 public key of the current owner */
47
+ recipientPk: string;
48
+ /** Normalized 33-byte (66-hex) compressed secp256k1 ephemeral public key used to wrap `encryptedCek` */
49
+ ephemeralPk: string;
50
+ /** 12-byte (24 hex chars) AES-256-GCM IV used for `ciphertextMetadata` */
51
+ nonce: string;
52
+ /** 32-byte (64 hex chars) wrapped Content Encryption Key (`CEK`) */
53
+ encryptedCek: string;
54
+ /** 16-byte (32 hex chars) authentication tag binding `(ownerDid, recipientPk, ephemeralPk, nonce, cekCommitmentHash)` */
55
+ cekWrapTag: string;
56
+ /** Hex-encoded AES-256-GCM ciphertext of canonical `EncryptedNftPrivateMetadata` */
57
+ ciphertextMetadata: string;
58
+ /** 16-byte (32 hex chars) AES-256-GCM authentication tag with `public` header bound as AAD */
59
+ ciphertextTag: string;
60
+ /** Cryptographic handover digest binding `cekCommitmentHash` and `handoverCount` */
61
+ handoverProofHash: string;
62
+ /** Secp256k1 digital signature over `handoverProofHash` signed by `CEK` (verified against `public.cekPublicKeyHex`) */
63
+ handoverSignature: string;
64
+ /** Monotonic handover counter (`0` on primary mint, incremented by `+1` on every secondary transfer) */
65
+ handoverCount: number;
66
+ }
67
+ interface EncryptedAssetEnvelope {
68
+ public: EncryptedNftPublicDiscoveryHeader;
69
+ encrypted: EncryptedNftOwnerCipherEnvelope;
70
+ }
71
+ interface SealEncryptedNftForOwnerInput {
72
+ ownerDid: string;
73
+ recipientPublicKeyHex: string;
74
+ category: string;
75
+ tags?: string[];
76
+ publicSummary: string;
77
+ arcSpaceUri?: string;
78
+ alg?: EncryptedNftAlgorithm;
79
+ privateMetadata: EncryptedNftPrivateMetadata;
80
+ /** Optional deterministic 32-byte hex CEK (generated via CSPRNG if omitted) */
81
+ cekHex?: string;
82
+ /** Optional deterministic 32-byte hex ephemeral secret key (generated via CSPRNG if omitted) */
83
+ ephemeralSecretKeyHex?: string;
84
+ /** Optional deterministic 12-byte hex AES-GCM nonce (generated via CSPRNG if omitted) */
85
+ nonceHex?: string;
86
+ ofacSanctionedSet?: ReadonlySet<string>;
87
+ }
88
+ interface OpenEncryptedNftAsOwnerInput {
89
+ envelope: EncryptedAssetEnvelope;
90
+ viewerDid: string;
91
+ ownerSecretKeyHex: string;
92
+ /** Actual current `asset.owner` from `statedb.asset` to enforce strict owner-only decryption */
93
+ currentAssetOwnerDid?: string;
94
+ }
95
+ interface OpenEncryptedNftAsOwnerResult {
96
+ ownerDid: string;
97
+ recipientPk: string;
98
+ cekHex: string;
99
+ plaintextHash: string;
100
+ cekCommitmentHash: string;
101
+ privateMetadata: EncryptedNftPrivateMetadata;
102
+ publicHeader: EncryptedNftPublicDiscoveryHeader;
103
+ }
104
+ interface RewrapEncryptedNftForNewOwnerInput {
105
+ envelope: EncryptedAssetEnvelope;
106
+ currentOwnerDid: string;
107
+ currentOwnerSecretKeyHex: string;
108
+ newOwnerDid: string;
109
+ newOwnerPublicKeyHex: string;
110
+ /** Optional deterministic 32-byte hex ephemeral secret key for re-wrapping */
111
+ ephemeralSecretKeyHex?: string;
112
+ ofacSanctionedSet?: ReadonlySet<string>;
113
+ }
114
+ interface VerifyEncryptedNftHandoverInput {
115
+ beforeEnvelope: EncryptedAssetEnvelope;
116
+ afterEnvelope: EncryptedAssetEnvelope;
117
+ expectedPreviousOwnerDid: string;
118
+ expectedNewOwnerDid: string;
119
+ expectedNewOwnerPublicKeyHex: string;
120
+ /**
121
+ * Optional buyer/new-owner secret key or re-wrap ephemeral secret key for interactive/atomic
122
+ * handover verification. When provided, `verifyEncryptedNftHandover` cryptographically unwraps
123
+ * `afterEnvelope.encrypted.encryptedCek` and verifies `computeEncryptedNftCekCommitmentHash(unwrappedCek) === afterEnvelope.public.cekCommitmentHash`,
124
+ * preventing a malicious seller from wrapping a garbage key while signing `handoverSignature` with the old `cekHex`.
125
+ */
126
+ newOwnerSecretKeyHex?: string;
127
+ ephemeralSecretKeyHex?: string;
128
+ }
129
+ declare function canonicalizeEncryptedNftMetadata(metadata: EncryptedNftPrivateMetadata): string;
130
+ /**
131
+ * Deterministic Owner Public Key derivation from a 32-byte hex secret key for `ocap.nft.encrypted.v1` envelopes.
132
+ * Uses `elliptic` `secp256k1` to derive the compressed 33-byte (66-hex) secp256k1 public key.
133
+ */
134
+ declare function deriveOwnerPublicKeyHexFromSecretKey(secretKeyHex: string): string;
135
+ declare function computeEncryptedNftPlaintextHash(metadata: EncryptedNftPrivateMetadata | string): string;
136
+ declare function computeEncryptedNftCekCommitmentHash(cekHex: string): string;
137
+ declare function computeEncryptedNftPublicHeaderAad(header: EncryptedNftPublicDiscoveryHeader): Buffer;
138
+ declare function validateEncryptedAssetEnvelope(envelope: unknown): EncryptedAssetEnvelope;
139
+ /**
140
+ * 1. Direct-to-Buyer Encrypted Mint / Primary SKU Purchase (`sealEncryptedNftForOwner`):
141
+ * - Encrypts `privateMetadata` under a 32-byte symmetric `CEK` using AES-256-GCM with `public` header bound as AAD;
142
+ * - Wraps `CEK` exclusively to `recipientPublicKeyHex` (`buyerPk`);
143
+ * - Commits `plaintextHash`, `cekCommitmentHash`, and `cekPublicKeyHex` in `public`.
144
+ */
145
+ declare function sealEncryptedNftForOwner(input: SealEncryptedNftForOwnerInput): EncryptedAssetEnvelope;
146
+ /**
147
+ * 2. DID Wallet / AI Agent Owner Auto-Decryption (`openEncryptedNftAsOwner`):
148
+ * - Verifies viewer is the current NFT owner (`viewerDid === envelope.encrypted.ownerDid` and `currentAssetOwnerDid`);
149
+ * - Unwraps `CEK` using `ownerSecretKeyHex` and verifies `cekCommitmentHash` and `cekPublicKeyHex`;
150
+ * - Decrypts `ciphertextMetadata` with AES-256-GCM + `public` header AAD and verifies `plaintextHash`.
151
+ */
152
+ declare function openEncryptedNftAsOwner(input: OpenEncryptedNftAsOwnerInput): OpenEncryptedNftAsOwnerResult;
153
+ /**
154
+ * 3. Secondary Market Transfer / Sale Key-Wrap Handover (`rewrapEncryptedNftForNewOwner`):
155
+ * - Decrypts and verifies the existing `CEK` and `ciphertextMetadata` with `currentOwnerSecretKeyHex`
156
+ * (preventing garbage-key swap attacks);
157
+ * - Re-wraps the exact same `CEK` to `newOwnerPublicKeyHex` without re-encrypting `ciphertextMetadata`
158
+ * or re-uploading `ArcSpace` blobs.
159
+ */
160
+ declare function rewrapEncryptedNftForNewOwner(input: RewrapEncryptedNftForNewOwnerInput): EncryptedAssetEnvelope;
161
+ /**
162
+ * Deterministic On-Chain Handover Verifier (`verifyEncryptedNftHandover`):
163
+ * - Verifies on-chain that a secondary transfer / sale handover:
164
+ * 1. Preserved `public` discovery headers (`plaintextHash`, `cekCommitmentHash`, `cekPublicKeyHex`, `arcSpaceUri`, `category`, `tags`, `publicSummary`) 100% unchanged;
165
+ * 2. Preserved `ciphertextMetadata`, `ciphertextTag`, and `nonce` 100% unchanged;
166
+ * 3. Transitioned `ownerDid` from `expectedPreviousOwnerDid` to `expectedNewOwnerDid` and bound `recipientPk = expectedNewOwnerPublicKeyHex`;
167
+ * 4. Incremented `handoverCount` by exactly `+1` with a valid `handoverProofHash` and `handoverSignature` verified against `public.cekPublicKeyHex`;
168
+ * 5. When `newOwnerSecretKeyHex` or `ephemeralSecretKeyHex` is provided (interactive/atomic buyer verification), unwraps `encryptedCek` and verifies `computeEncryptedNftCekCommitmentHash(unwrappedCek) === after.public.cekCommitmentHash`.
169
+ */
170
+ declare function verifyEncryptedNftHandover(input: VerifyEncryptedNftHandoverInput): boolean;
171
+ //#endregion
172
+ export { ENCRYPTED_NFT_SCHEMA_VERSION, EncryptedAssetEnvelope, EncryptedNftAlgorithm, EncryptedNftOwnerCipherEnvelope, EncryptedNftPrivateMetadata, EncryptedNftPublicDiscoveryHeader, MAX_ENCRYPTED_NFT_CATEGORY_LENGTH, MAX_ENCRYPTED_NFT_CIPHERTEXT_HEX_CHARS, MAX_ENCRYPTED_NFT_SUMMARY_LENGTH, MAX_ENCRYPTED_NFT_TAGS, MAX_ENCRYPTED_NFT_TAG_LENGTH, MAX_ENCRYPTED_NFT_URI_LENGTH, OpenEncryptedNftAsOwnerInput, OpenEncryptedNftAsOwnerResult, RewrapEncryptedNftForNewOwnerInput, SealEncryptedNftForOwnerInput, VALID_ENCRYPTED_NFT_ALGORITHMS, VerifyEncryptedNftHandoverInput, canonicalizeEncryptedNftMetadata, computeEncryptedNftCekCommitmentHash, computeEncryptedNftPlaintextHash, computeEncryptedNftPublicHeaderAad, deriveOwnerPublicKeyHexFromSecretKey, openEncryptedNftAsOwner, rewrapEncryptedNftForNewOwner, sealEncryptedNftForOwner, validateEncryptedAssetEnvelope, verifyEncryptedNftHandover };