@certen.io/sdk 0.9.0 → 0.11.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 (170) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/README.md +111 -0
  3. package/dist/address.d.ts +12 -0
  4. package/dist/address.d.ts.map +1 -0
  5. package/dist/address.js +48 -0
  6. package/dist/address.js.map +1 -0
  7. package/dist/agent.d.ts +8 -0
  8. package/dist/agent.d.ts.map +1 -1
  9. package/dist/agent.js +12 -0
  10. package/dist/agent.js.map +1 -1
  11. package/dist/browser.d.ts +47 -0
  12. package/dist/browser.d.ts.map +1 -0
  13. package/dist/browser.js +55 -0
  14. package/dist/browser.js.map +1 -0
  15. package/dist/bytes.d.ts +14 -0
  16. package/dist/bytes.d.ts.map +1 -0
  17. package/dist/bytes.js +47 -0
  18. package/dist/bytes.js.map +1 -0
  19. package/dist/chains.d.ts +218 -0
  20. package/dist/chains.d.ts.map +1 -0
  21. package/dist/chains.js +295 -0
  22. package/dist/chains.js.map +1 -0
  23. package/dist/client.d.ts +17 -2
  24. package/dist/client.d.ts.map +1 -1
  25. package/dist/client.js +54 -8
  26. package/dist/client.js.map +1 -1
  27. package/dist/defaults.d.ts +3 -0
  28. package/dist/defaults.d.ts.map +1 -0
  29. package/dist/defaults.js +3 -0
  30. package/dist/defaults.js.map +1 -0
  31. package/dist/doctor.d.ts +10 -1
  32. package/dist/doctor.d.ts.map +1 -1
  33. package/dist/doctor.js +42 -27
  34. package/dist/doctor.js.map +1 -1
  35. package/dist/effect.d.ts +99 -0
  36. package/dist/effect.d.ts.map +1 -0
  37. package/dist/effect.js +139 -0
  38. package/dist/effect.js.map +1 -0
  39. package/dist/error-codes.d.ts.map +1 -1
  40. package/dist/error-codes.js +17 -0
  41. package/dist/error-codes.js.map +1 -1
  42. package/dist/errors.d.ts +76 -0
  43. package/dist/errors.d.ts.map +1 -1
  44. package/dist/errors.js +108 -0
  45. package/dist/errors.js.map +1 -1
  46. package/dist/evm-rpc.d.ts +55 -0
  47. package/dist/evm-rpc.d.ts.map +1 -0
  48. package/dist/evm-rpc.js +126 -0
  49. package/dist/evm-rpc.js.map +1 -0
  50. package/dist/execution-proof.d.ts.map +1 -1
  51. package/dist/execution-proof.js +2 -1
  52. package/dist/execution-proof.js.map +1 -1
  53. package/dist/funding.d.ts +214 -6
  54. package/dist/funding.d.ts.map +1 -1
  55. package/dist/funding.js +251 -29
  56. package/dist/funding.js.map +1 -1
  57. package/dist/header-fields.d.ts +68 -0
  58. package/dist/header-fields.d.ts.map +1 -0
  59. package/dist/header-fields.js +147 -0
  60. package/dist/header-fields.js.map +1 -0
  61. package/dist/index.d.ts +9 -17
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +11 -26
  64. package/dist/index.js.map +1 -1
  65. package/dist/intent-states.d.ts +75 -0
  66. package/dist/intent-states.d.ts.map +1 -0
  67. package/dist/intent-states.js +66 -0
  68. package/dist/intent-states.js.map +1 -0
  69. package/dist/internal.d.ts +18 -0
  70. package/dist/internal.d.ts.map +1 -1
  71. package/dist/internal.js +44 -0
  72. package/dist/internal.js.map +1 -1
  73. package/dist/key-page.d.ts +67 -0
  74. package/dist/key-page.d.ts.map +1 -0
  75. package/dist/key-page.js +154 -0
  76. package/dist/key-page.js.map +1 -0
  77. package/dist/origin.d.ts +19 -0
  78. package/dist/origin.d.ts.map +1 -0
  79. package/dist/origin.js +80 -0
  80. package/dist/origin.js.map +1 -0
  81. package/dist/random.d.ts +27 -0
  82. package/dist/random.d.ts.map +1 -0
  83. package/dist/random.js +30 -0
  84. package/dist/random.js.map +1 -0
  85. package/dist/readiness.d.ts +133 -0
  86. package/dist/readiness.d.ts.map +1 -0
  87. package/dist/readiness.js +467 -0
  88. package/dist/readiness.js.map +1 -0
  89. package/dist/reason-codes.d.ts +15 -0
  90. package/dist/reason-codes.d.ts.map +1 -0
  91. package/dist/reason-codes.js +30 -0
  92. package/dist/reason-codes.js.map +1 -0
  93. package/dist/receipt.d.ts +233 -0
  94. package/dist/receipt.d.ts.map +1 -0
  95. package/dist/receipt.js +318 -0
  96. package/dist/receipt.js.map +1 -0
  97. package/dist/resources/admin.d.ts +5 -2
  98. package/dist/resources/admin.d.ts.map +1 -1
  99. package/dist/resources/admin.js +8 -3
  100. package/dist/resources/admin.js.map +1 -1
  101. package/dist/resources/billing.d.ts.map +1 -1
  102. package/dist/resources/billing.js +5 -4
  103. package/dist/resources/billing.js.map +1 -1
  104. package/dist/resources/chains.d.ts +10 -0
  105. package/dist/resources/chains.d.ts.map +1 -1
  106. package/dist/resources/chains.js +15 -1
  107. package/dist/resources/chains.js.map +1 -1
  108. package/dist/resources/device.d.ts.map +1 -1
  109. package/dist/resources/device.js +2 -1
  110. package/dist/resources/device.js.map +1 -1
  111. package/dist/resources/execute.d.ts +110 -4
  112. package/dist/resources/execute.d.ts.map +1 -1
  113. package/dist/resources/execute.js +207 -35
  114. package/dist/resources/execute.js.map +1 -1
  115. package/dist/resources/governance.js +3 -3
  116. package/dist/resources/governance.js.map +1 -1
  117. package/dist/resources/identity.js +5 -5
  118. package/dist/resources/identity.js.map +1 -1
  119. package/dist/resources/oauth-clients.d.ts.map +1 -1
  120. package/dist/resources/oauth-clients.js +3 -2
  121. package/dist/resources/oauth-clients.js.map +1 -1
  122. package/dist/resources/proof.d.ts +10 -2
  123. package/dist/resources/proof.d.ts.map +1 -1
  124. package/dist/resources/proof.js +33 -11
  125. package/dist/resources/proof.js.map +1 -1
  126. package/dist/resources/registration-tokens.d.ts.map +1 -1
  127. package/dist/resources/registration-tokens.js +2 -1
  128. package/dist/resources/registration-tokens.js.map +1 -1
  129. package/dist/resources/sign.js +2 -2
  130. package/dist/resources/sign.js.map +1 -1
  131. package/dist/resources/transaction.d.ts.map +1 -1
  132. package/dist/resources/transaction.js +7 -3
  133. package/dist/resources/transaction.js.map +1 -1
  134. package/dist/resources/transparency.d.ts.map +1 -1
  135. package/dist/resources/transparency.js +3 -2
  136. package/dist/resources/transparency.js.map +1 -1
  137. package/dist/resources/webhooks.d.ts +5 -3
  138. package/dist/resources/webhooks.d.ts.map +1 -1
  139. package/dist/resources/webhooks.js +12 -8
  140. package/dist/resources/webhooks.js.map +1 -1
  141. package/dist/sha256.d.ts +10 -0
  142. package/dist/sha256.d.ts.map +1 -0
  143. package/dist/sha256.js +71 -0
  144. package/dist/sha256.js.map +1 -0
  145. package/dist/share-target.d.ts +10 -0
  146. package/dist/share-target.d.ts.map +1 -0
  147. package/dist/share-target.js +25 -0
  148. package/dist/share-target.js.map +1 -0
  149. package/dist/shared-proof.d.ts +1 -5
  150. package/dist/shared-proof.d.ts.map +1 -1
  151. package/dist/shared-proof.js +27 -21
  152. package/dist/shared-proof.js.map +1 -1
  153. package/dist/signing-check.d.ts +66 -0
  154. package/dist/signing-check.d.ts.map +1 -0
  155. package/dist/signing-check.js +171 -0
  156. package/dist/signing-check.js.map +1 -0
  157. package/dist/types.d.ts +139 -0
  158. package/dist/types.d.ts.map +1 -1
  159. package/dist/verify-receipt.d.ts.map +1 -1
  160. package/dist/verify-receipt.js +68 -28
  161. package/dist/verify-receipt.js.map +1 -1
  162. package/dist/verify.d.ts +206 -0
  163. package/dist/verify.d.ts.map +1 -0
  164. package/dist/verify.js +369 -0
  165. package/dist/verify.js.map +1 -0
  166. package/dist/version.d.ts +2 -0
  167. package/dist/version.d.ts.map +1 -0
  168. package/dist/version.js +4 -0
  169. package/dist/version.js.map +1 -0
  170. package/package.json +25 -7
package/dist/verify.js ADDED
@@ -0,0 +1,369 @@
1
+ /**
2
+ * `@certen.io/sdk/verify`: verify a CERTEN proof instead of trusting a flag in it.
3
+ *
4
+ * A separate entry point, so the API client does not pull in the verifier (and its Accumulate encoder). It needs the
5
+ * optional peer `@certen.io/proof-verify`; without it the import fails at once, naming the package.
6
+ *
7
+ * `verifyBundle` takes a proof bundle (or the proof v2 portable document itself) and returns one verdict per layer:
8
+ *
9
+ * - the Accumulate side (trust base, L1-L4, G0, G1, the validator set, govRoot v3) is checked from the portable document
10
+ * `@certen.io/proof-verify` understands, and
11
+ * - the execution outcome (S6) from the bundle's own execution component, with the destination chain's block header
12
+ * when the caller supplies it.
13
+ *
14
+ * Nothing here reads a `verified` field of a bundle as a verdict. The bundle's own statements are returned under
15
+ * `bundleStatements`, labelled as what the validators claimed, so a caller can show them and can see they were not used.
16
+ */
17
+ import { decodeSharedBundle } from './shared-proof.js';
18
+ import { noEvidence, verifyProofDocument, PORTABLE_FORMAT, COVERED_STATEMENTS, NOT_COVERED_STATEMENTS, } from '@certen.io/proof-verify';
19
+ import { checkAgainstHeader, executionComponentOf, verifyExecutionProof } from './execution-proof.js';
20
+ import { CertenError } from './errors.js';
21
+ import { checkEvmRpcEndpoint, readEvmBlockHeader } from './evm-rpc.js';
22
+ import { checkNativeTransferEffect } from './effect.js';
23
+ import { intentOutcome } from './intent-states.js';
24
+ import { assembleReceipt } from './receipt.js';
25
+ export * from '@certen.io/proof-verify';
26
+ /** Why a live proof has no portable document: the gateway route that serves it is not there (RB7b-F30). */
27
+ export const PROOF_V2_EVIDENCE_NOT_SERVED = 'PROOF_V2_EVIDENCE_NOT_SERVED';
28
+ function summarise(v) {
29
+ return {
30
+ ok: v.ok, chainId: v.chainId, txHash: v.txHash, blockNumber: v.blockNumber, ...(v.blockHash ? { blockHash: v.blockHash } : {}), receiptsRoot: v.receiptsRoot,
31
+ transactionIndex: v.transactionIndex, ...(v.receipt ? { status: v.receipt.status } : {}), logs: v.receipt?.logs ?? [],
32
+ ...(v.expectedLogFound !== undefined ? { expectedLogFound: v.expectedLogFound } : {}), caveats: v.caveats, ...(v.error ? { error: v.error } : {}),
33
+ };
34
+ }
35
+ /** The portable document in whatever the caller has: the document itself, or a bundle that embeds it as `proof_v2`. */
36
+ export function portableDocumentOf(input) {
37
+ const o = input && typeof input === 'object' ? input : null;
38
+ if (!o)
39
+ return null;
40
+ if (o.format === PORTABLE_FORMAT)
41
+ return o;
42
+ const inner = (o.bundle && typeof o.bundle === 'object' ? o.bundle : o).proof_v2;
43
+ return inner && typeof inner === 'object' ? inner : null;
44
+ }
45
+ export function verifyBundle(input, opts = {}) {
46
+ const doc = portableDocumentOf(input);
47
+ const base = doc
48
+ ? verifyProofDocument(doc, opts)
49
+ : noEvidence(`${PROOF_V2_EVIDENCE_NOT_SERVED}: the input carries no proof v2 portable document, so the Accumulate side cannot be checked here`);
50
+ const component = executionComponentOf(input);
51
+ let execution = null;
52
+ let headerCheck = null;
53
+ let outcome;
54
+ const outcomeBase = { id: 'outcome', statement: 'S6', title: 'The execution on the destination chain' };
55
+ if (!component) {
56
+ outcome = { ...outcomeBase, verdict: 'not_checked', evidence: {}, reason: 'the bundle carries no execution proof (component 5); read the destination chain' };
57
+ }
58
+ else {
59
+ const raw = verifyExecutionProof(component, opts.expect);
60
+ if (opts.header && raw.ok)
61
+ headerCheck = checkAgainstHeader(raw, opts.header);
62
+ execution = summarise(raw);
63
+ const evidence = { chainId: raw.chainId, transaction: raw.txHash, block: raw.blockNumber, receiptsRoot: raw.receiptsRoot, status: raw.receipt?.status, expectedEventFound: raw.expectedLogFound ?? null, headerChecked: headerCheck?.ok ?? null };
64
+ if (!raw.ok)
65
+ outcome = { ...outcomeBase, verdict: 'failed', evidence, reason: raw.error ?? 'the receipt does not verify' };
66
+ else if (raw.expectedLogFound === false)
67
+ outcome = { ...outcomeBase, verdict: 'failed', evidence, reason: 'the expected event is not in the receipt' };
68
+ else if (headerCheck && !headerCheck.ok)
69
+ outcome = { ...outcomeBase, verdict: 'failed', evidence, reason: `the block header from your RPC disagrees: ${headerCheck.reasons.join('; ')}` };
70
+ else if (!headerCheck)
71
+ outcome = { ...outcomeBase, verdict: 'not_checked', evidence, reason: 'the receipt is in the bundle\'s receipts root, which is still the validators\' statement until it is compared with a block header from your own RPC' };
72
+ else
73
+ outcome = { ...outcomeBase, verdict: 'verified', evidence };
74
+ }
75
+ const layers = base.layers.map((l) => (l.id === 'outcome' ? outcome : l));
76
+ const inScope = layers.filter((l) => l.verdict !== 'not_in_document');
77
+ const anyFailed = inScope.some((l) => l.verdict === 'failed');
78
+ const allVerified = inScope.every((l) => l.verdict === 'verified');
79
+ const overall = !doc && !component ? 'no_evidence' : anyFailed ? 'failed' : allVerified ? 'verified' : 'partial';
80
+ const verified = overall === 'verified';
81
+ const failedLayer = layers.find((l) => l.verdict === 'failed');
82
+ const bundle = (input && typeof input === 'object' ? (input.bundle ?? input) : {});
83
+ const chained = bundle.proof_components?.['3_chained_proof'];
84
+ return {
85
+ ...base,
86
+ overall,
87
+ independent: verified,
88
+ layers,
89
+ covers: verified ? [...COVERED_STATEMENTS, 'S6'] : [],
90
+ notCovered: verified ? NOT_COVERED_STATEMENTS.filter((s) => s !== 'S6') : [...COVERED_STATEMENTS, ...NOT_COVERED_STATEMENTS],
91
+ ...(failedLayer ? { failure: { layer: failedLayer.id, message: failedLayer.reason ?? 'failed' } } : {}),
92
+ execution,
93
+ headerCheck,
94
+ bundleStatements: { verified: bundle.verified, chainedProofVerified: chained?.verified },
95
+ evidenceFound: Boolean(doc),
96
+ };
97
+ }
98
+ // ── fetching the evidence for a live target ─────────────────────────────────────────────────────────
99
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
100
+ const HEX64 = /^(0x)?[0-9a-f]{64}$/i;
101
+ /**
102
+ * Fetch what a verifier needs for an intent id, a proof id or an Accumulate transaction hash: the bundle, the portable
103
+ * document, and (for information only) the gateway's receipt. A missing document is returned as `notServed`, never thrown, and
104
+ * never replaced by anything the gateway merely asserts.
105
+ */
106
+ export async function loadProofEvidence(client, target,
107
+ /** The intent, when the caller has just read it (a wait ends holding one): the target is then not read a second time. */
108
+ known) {
109
+ let proofId;
110
+ let txHash;
111
+ if (HEX64.test(target)) {
112
+ txHash = target.replace(/^0x/, '');
113
+ }
114
+ else if (UUID.test(target)) {
115
+ try {
116
+ const intent = known ?? (await client.transaction.get(target));
117
+ proofId = intent.proof_id || undefined;
118
+ txHash = intent.accum_tx_hash?.match(/([a-f0-9]{64})/i)?.[1];
119
+ }
120
+ catch (err) {
121
+ if (err instanceof CertenError && err.status === 404)
122
+ proofId = target; // not an intent: a proof id
123
+ else
124
+ throw err;
125
+ }
126
+ }
127
+ else {
128
+ throw new CertenError(`"${target}" is not a proof id, an intent id, or a transaction hash. Pass a UUID or a 64-character hex hash.`, 0, 'INVALID_PROOF_TARGET');
129
+ }
130
+ if (!proofId && !txHash) {
131
+ throw new CertenError(`Nothing to verify for ${target}: it has neither a proof id nor an Accumulate transaction hash.`, 0, 'NOTHING_TO_VERIFY');
132
+ }
133
+ let bundle = null;
134
+ let bundleError = null;
135
+ let portable = null;
136
+ let notServed = null;
137
+ if (proofId) {
138
+ try {
139
+ const raw = await client.proof.bundle(proofId);
140
+ // The bytes decide, not the content type: the gateway serves a JSON bundle as application/octet-stream (it streams whatever the
141
+ // proof service stored), and a bundle can be gzip-compressed. Refusing on the header would drop the execution component from a bundle
142
+ // that has one, and report an outcome layer as unchecked for the wrong reason.
143
+ const parsed = decodeSharedBundle({ data: Array.from(raw.data) });
144
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
145
+ bundle = parsed;
146
+ else
147
+ bundleError = `the gateway served the bundle as ${raw.contentType}, and its bytes are not a JSON proof bundle this tool can read`;
148
+ }
149
+ catch (err) {
150
+ if (!(err instanceof CertenError) || err.status < 400)
151
+ throw err; // the bundle may be unavailable; the document is asked for separately
152
+ bundleError = `the bundle could not be fetched (${err.status})`;
153
+ }
154
+ try {
155
+ portable = await client.proof.portable(proofId);
156
+ }
157
+ catch (err) {
158
+ if (!(err instanceof CertenError))
159
+ throw err;
160
+ if (err.code === PROOF_V2_EVIDENCE_NOT_SERVED)
161
+ notServed = { code: err.code, reason: err.message };
162
+ else if (err.status >= 500)
163
+ notServed = { code: 'PROOF_SERVICE_UNAVAILABLE', reason: `the proof service answered ${err.status}, so no proof v2 document could be fetched (that is not the same as there being none)` };
164
+ else
165
+ throw err;
166
+ }
167
+ }
168
+ else {
169
+ notServed = { code: PROOF_V2_EVIDENCE_NOT_SERVED, reason: 'this transaction has no proof id, so the gateway holds no proof v2 document for it' };
170
+ }
171
+ let gateway = null;
172
+ if (txHash) {
173
+ try {
174
+ gateway = await client.proof.receipt(txHash);
175
+ }
176
+ catch {
177
+ gateway = null;
178
+ }
179
+ }
180
+ return { bundle, bundleError, portable, notServed, gateway };
181
+ }
182
+ /** The input verifyBundle takes for loaded evidence. */
183
+ export function bundleInputOf(e) {
184
+ return e.portable ? { ...(e.bundle ?? {}), proof_v2: e.portable } : e.bundle;
185
+ }
186
+ const HEX32 = /^0x[0-9a-fA-F]{64}$/;
187
+ const HEX_QUANTITY = /^0x[0-9a-fA-F]+$/;
188
+ const DECIMAL = /^\d+$/;
189
+ /**
190
+ * Check a block header a CALLER hands in (it fetched it from its own node), and keep only what is compared.
191
+ *
192
+ * `verifyBundle` compares whatever fields the header has and finds no disagreement in the ones it lacks, so `{}` - or a bare block number,
193
+ * which the bundle itself supplied - is "a comparison" that compared nothing, and the execution layer read VERIFIED. A header is a
194
+ * comparison only if it carries the receipts root the proof commits to; the hash and the number are checked too when present, and a
195
+ * malformed one is refused rather than ignored, because half a header is not something to trust the other half of.
196
+ *
197
+ * Throws `INVALID_HEADER` (status 0: nothing was sent). The message names the field, never the value.
198
+ */
199
+ export function assertComparableHeader(header) {
200
+ const bad = (why) => {
201
+ throw new CertenError(`certen: the block header cannot be compared with the proof: ${why}`, 0, 'INVALID_HEADER');
202
+ };
203
+ if (header === null || typeof header !== 'object' || Array.isArray(header)) {
204
+ return bad('a header is an object { receiptsRoot, hash?, number? } fetched from your own node.');
205
+ }
206
+ const h = header;
207
+ if (h.receiptsRoot === undefined || h.receiptsRoot === null || h.receiptsRoot === '') {
208
+ return bad('it has no receiptsRoot, so nothing in it could disagree with the proof (a block number alone is something the bundle already states). Pass the block\'s receiptsRoot.');
209
+ }
210
+ if (typeof h.receiptsRoot !== 'string' || !HEX32.test(h.receiptsRoot)) {
211
+ return bad('receiptsRoot is not 32 bytes of 0x-prefixed hex.');
212
+ }
213
+ const out = { receiptsRoot: h.receiptsRoot };
214
+ if (h.hash !== undefined && h.hash !== null) {
215
+ if (typeof h.hash !== 'string' || !HEX32.test(h.hash))
216
+ return bad('hash is not 32 bytes of 0x-prefixed hex.');
217
+ out.hash = h.hash;
218
+ }
219
+ if (h.number !== undefined && h.number !== null) {
220
+ const n = h.number;
221
+ const text = typeof n === 'number' ? String(n) : n;
222
+ const ok = typeof text === 'string' && (HEX_QUANTITY.test(text) || DECIMAL.test(text)) && Number.isSafeInteger(Number(text));
223
+ if (!ok)
224
+ return bad('number is not a non-negative block number (hex such as 0x2c4a0b7, or decimal).');
225
+ out.number = text;
226
+ }
227
+ return out;
228
+ }
229
+ /**
230
+ * Verify evidence that has been loaded (from the gateway, a file or a share link), with the caller's own node closing the execution layer.
231
+ *
232
+ * This is the part of `certen proof verify` that used to live inline in the CLI: fetch the header of the block the bundle says the action ran
233
+ * in, from a node the caller named, and hand it to `verifyBundle`, which compares the receipts root and block hash. It is here so the CLI's
234
+ * `proof verify`, `send`, `watch` and `receipt` cannot disagree about what a header check means.
235
+ *
236
+ * It does NOT ask the node which chain it is on: the comparison of block hash and receipts root fails for another chain's block, which is
237
+ * `failed` with the reason. A node that cannot be reached throws (`EVM_RPC_UNREADABLE`), and so does one that has no such block or sends no
238
+ * receipts root (`EVM_RPC_NO_BLOCK`): a person who asked for an independent check must not be handed a result that quietly lacks it, and
239
+ * "the node compared nothing" is never "the node agrees".
240
+ */
241
+ export async function verifyEvidence(evidence, options = {}) {
242
+ if (options.header !== undefined && options.rpc) {
243
+ throw new CertenError('certen: give a block header or a node to fetch one from, not both: which one decided the execution layer would be a guess.', 0, 'CONFLICTING_OPTIONS');
244
+ }
245
+ const component = evidence.bundle ? executionComponentOf(evidence.bundle) : null;
246
+ let header;
247
+ // A header the caller fetched is checked before anything else, so a header that compares nothing fails loudly rather than passing quietly.
248
+ const supplied = options.header !== undefined ? assertComparableHeader(options.header) : undefined;
249
+ if (supplied)
250
+ header = supplied;
251
+ if (options.rpc && component) {
252
+ const first = verifyExecutionProof(component, options.expect);
253
+ if (first.ok) {
254
+ const node = { rpc: options.rpc, fetch: options.fetch, timeoutMs: options.timeoutMs };
255
+ header = await readEvmBlockHeader(node, first.blockNumber);
256
+ // A node with no such block, or one that sends a header without the receipts root, has compared NOTHING. The old fallback handed
257
+ // `verifyBundle` a bare `{ number }`, which `checkAgainstHeader` passes (the number matches what was asked), so a node that did not
258
+ // have the block made the execution layer read VERIFIED. It is an error instead: not "the proof disagrees" (a pruned or lagging node
259
+ // says nothing about the proof) and never a pass. Only the host is named: the URL can carry the node's key.
260
+ if (!header || !header.receiptsRoot) {
261
+ const { host } = checkEvmRpcEndpoint(options.rpc);
262
+ throw new CertenError(header
263
+ ? `certen: the node at ${host} sent the header of block ${first.blockNumber} without a receipts root, so nothing could be compared with the proof.`
264
+ : `certen: the node at ${host} has no block ${first.blockNumber} (it may be pruned, lagging or on another network), so nothing could be compared with the proof.`, 0, 'EVM_RPC_NO_BLOCK', { details: { host, block: first.blockNumber } });
265
+ }
266
+ }
267
+ }
268
+ const v = verifyBundle(bundleInputOf(evidence), { expect: options.expect, header, expectGovRoot: options.expectGovRoot });
269
+ // "Consulted" means a header was actually COMPARED: a header handed in for a proof with no execution component compared nothing.
270
+ return Object.assign(v, { nodeConsulted: header !== undefined && v.headerCheck !== null });
271
+ }
272
+ /**
273
+ * Everything known about one intent, in one record: what happened, the ids to keep, whether the proof holds, and whether the value arrived.
274
+ *
275
+ * The steps, each of which may fail without failing the receipt (a gap is data, and is named in `gaps`):
276
+ * 1. read the intent (unless the caller just did);
277
+ * 2. if it completed, load its proof evidence and verify it HERE with `verifyBundle`, never taking a flag in the bundle as a verdict;
278
+ * 3. with a node of the caller's, compare the proof's block header and read the recipient's balance;
279
+ * 4. assemble the record (`assembleReceipt`, pure).
280
+ *
281
+ * It reads and verifies; it signs and sends nothing. A proof that cannot be fetched is `unavailable`, which is a gap and not a verdict.
282
+ */
283
+ export async function buildReceipt(client, intentId, options = {}) {
284
+ // A header handed in is judged before the first request: a header that compares nothing, or one given beside a node, is a mistake to be
285
+ // told about, and must not be turned into a "gap" that reads as the node having failed.
286
+ if (options.header !== undefined) {
287
+ if (options.rpc) {
288
+ throw new CertenError('certen: give a block header or a node to fetch one from, not both: which one decided the execution layer would be a guess.', 0, 'CONFLICTING_OPTIONS');
289
+ }
290
+ assertComparableHeader(options.header);
291
+ }
292
+ const transaction = options.transaction ?? (await client.transaction.get(intentId));
293
+ const outcome = intentOutcome(transaction);
294
+ const request = options.request ?? options.previous?.request ?? null;
295
+ let proof = null;
296
+ let verification = null;
297
+ if (outcome.outcome === 'completed') {
298
+ let evidence = null;
299
+ let unavailable = null;
300
+ try {
301
+ evidence = await loadProofEvidence(client, intentId, transaction);
302
+ }
303
+ catch (err) {
304
+ if (!(err instanceof CertenError))
305
+ throw err;
306
+ unavailable = err.message.replace(/^certen: /, '');
307
+ }
308
+ // The proof service answering 5xx is "unavailable", which is not "there is none": `loadProofEvidence` reports it as not served, and reading
309
+ // that as NO EVIDENCE would tell someone their proof does not exist when the service had a bad moment (and would skip the retry).
310
+ if (evidence && !evidence.bundle && !evidence.portable && evidence.notServed?.code === 'PROOF_SERVICE_UNAVAILABLE') {
311
+ unavailable = evidence.notServed.reason;
312
+ evidence = null;
313
+ }
314
+ if (evidence) {
315
+ let nodeError = null;
316
+ try {
317
+ verification = await verifyEvidence(evidence, { rpc: options.rpc, header: options.header, expect: options.expect, fetch: options.fetch, timeoutMs: options.timeoutMs });
318
+ }
319
+ catch (err) {
320
+ // The node was asked for and could not be used. The proof is still checked, without it, and the gap names why.
321
+ if (!(err instanceof CertenError))
322
+ throw err;
323
+ nodeError = err.message.replace(/^certen: /, '');
324
+ verification = await verifyEvidence(evidence, { expect: options.expect });
325
+ }
326
+ proof = {
327
+ verification, notServed: evidence.notServed, bundleError: evidence.bundleError, nodeConsulted: verification.nodeConsulted, nodeError,
328
+ };
329
+ }
330
+ else {
331
+ proof = { verification: null, unavailable };
332
+ }
333
+ }
334
+ // The effect, once there is something to compare. A transfer is judged from the recipient's side with the caller's node; a call by the
335
+ // event it was told to expect.
336
+ let effect = null;
337
+ if (request?.kind === 'transfer' && request.amount && request.to) {
338
+ effect = outcome.outcome === 'completed'
339
+ ? await checkNativeTransferEffect({
340
+ chain: request.chain, recipient: request.to, amount: request.amount, rpc: options.effectRpc ?? options.rpc,
341
+ atBlock: verification?.execution?.ok ? verification.execution.blockNumber : undefined,
342
+ before: options.snapshot ?? options.previous?.recipient_snapshot ?? undefined,
343
+ sender: options.sender, fetch: options.fetch, timeoutMs: options.timeoutMs,
344
+ })
345
+ : { kind: 'native_transfer', state: 'unchecked', amount: request.amount, detail: 'Not checked yet: the transfer has not completed.' };
346
+ }
347
+ else if (request?.kind === 'contract_call' && options.expect && outcome.outcome === 'completed') {
348
+ const found = verification?.execution?.expectedLogFound ?? null;
349
+ effect = {
350
+ kind: 'contract_call', state: found === true ? 'confirmed' : found === false ? 'not_observed' : 'unchecked',
351
+ detail: found === true ? 'The expected event is in the proof\'s receipt.' : found === false ? 'The expected event is NOT in the proof\'s receipt.' : 'The expected event could not be looked for: the proof carries no execution receipt.',
352
+ expected_event: { found },
353
+ };
354
+ }
355
+ let registry = options.registry ?? null;
356
+ if (registry === null && options.registry === undefined) {
357
+ try {
358
+ registry = await client.chains.list();
359
+ }
360
+ catch {
361
+ registry = null;
362
+ }
363
+ }
364
+ return assembleReceipt({
365
+ intentId, transaction, request, signedWith: options.signedWith, gateway: options.gateway, registry, proof, effect,
366
+ snapshot: options.snapshot, previous: options.previous, now: options.now,
367
+ });
368
+ }
369
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mB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K,IAAI,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACxD,IAAI,CAAC;YAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,QAAQ,GAAG,IAAI,CAAC;QAAC,CAAC;IAC3E,CAAC;IAED,OAAO,eAAe,CAAC;QACrB,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM;QACjH,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG;KACzE,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const SDK_VERSION = "0.11.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ // GENERATED by scripts/build-package.mjs from package.json. Do not edit: the build rewrites it, and packages/sdk/test/version.test.ts
2
+ // fails if it ever disagrees with package.json.
3
+ export const SDK_VERSION = '0.11.0';
4
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,sIAAsI;AACtI,gDAAgD;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certen.io/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "TypeScript client for the CERTEN Gateway API — proof-gated cross-chain execution on Accumulate",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,16 +23,26 @@
23
23
  "url": "https://github.com/certenIO/certen-sdk/issues"
24
24
  },
25
25
  "engines": {
26
- "node": ">=18"
26
+ "node": ">=22"
27
27
  },
28
28
  "main": "dist/index.js",
29
29
  "types": "dist/index.d.ts",
30
- "//exports": "Explicit map so a consumer on modern resolution gets the types; main/types stay for older toolchains.",
30
+ "//exports": "types first. The `browser` condition (webpack, Vite, esbuild, rollup choose it for a browser build) gets the browser-safe entry, which leaves out CertenAgent/ed25519Signer (node:crypto) and fetchSharedProof/decodeSharedBundle (node:zlib); Node gets the full entry. `./browser` names the portable entry explicitly. main/types stay for older toolchains.",
31
31
  "exports": {
32
32
  ".": {
33
33
  "types": "./dist/index.d.ts",
34
+ "browser": "./dist/browser.js",
34
35
  "import": "./dist/index.js",
35
36
  "default": "./dist/index.js"
37
+ },
38
+ "./browser": {
39
+ "types": "./dist/browser.d.ts",
40
+ "default": "./dist/browser.js"
41
+ },
42
+ "./package.json": "./package.json",
43
+ "./verify": {
44
+ "types": "./dist/verify.d.ts",
45
+ "default": "./dist/verify.js"
36
46
  }
37
47
  },
38
48
  "//files": "Only the build output and docs. src/ and test/ stay in the repo — declarationMap + sourceMap already give consumers navigable types, so shipping sources doubles the tarball for nothing.",
@@ -57,12 +67,20 @@
57
67
  "access": "public"
58
68
  },
59
69
  "dependencies": {
60
- "axios": "^1.7.0"
70
+ "axios": "^1.20.0"
61
71
  },
62
72
  "devDependencies": {
73
+ "@types/node": "^22.0.0",
63
74
  "typescript": "^5.5.0",
64
- "vitest": "^1.6.1",
65
- "@types/node": "^22.0.0"
75
+ "vitest": "^5.0.3"
66
76
  },
67
- "//publishConfig": "Provenance is passed as --provenance by .github/workflows/release.yml. Setting it here instead would break every publish outside CI with an error that does not explain itself."
77
+ "//publishConfig": "Provenance is passed as --provenance by .github/workflows/release.yml. Setting it here instead would break every publish outside CI with an error that does not explain itself.",
78
+ "peerDependencies": {
79
+ "@certen.io/proof-verify": "^0.1.0"
80
+ },
81
+ "peerDependenciesMeta": {
82
+ "@certen.io/proof-verify": {
83
+ "optional": true
84
+ }
85
+ }
68
86
  }