@certen.io/sdk 0.4.0 → 0.7.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 (105) hide show
  1. package/CHANGELOG.md +874 -185
  2. package/README.md +133 -119
  3. package/dist/client.d.ts +99 -6
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +269 -20
  6. package/dist/client.js.map +1 -1
  7. package/dist/doctor.d.ts +53 -0
  8. package/dist/doctor.d.ts.map +1 -0
  9. package/dist/doctor.js +451 -0
  10. package/dist/doctor.js.map +1 -0
  11. package/dist/error-codes.d.ts +14 -0
  12. package/dist/error-codes.d.ts.map +1 -0
  13. package/dist/error-codes.js +55 -0
  14. package/dist/error-codes.js.map +1 -0
  15. package/dist/errors.d.ts +91 -1
  16. package/dist/errors.d.ts.map +1 -1
  17. package/dist/errors.js +130 -1
  18. package/dist/errors.js.map +1 -1
  19. package/dist/funding.d.ts +43 -0
  20. package/dist/funding.d.ts.map +1 -0
  21. package/dist/funding.js +116 -0
  22. package/dist/funding.js.map +1 -0
  23. package/dist/index.d.ts +10 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +18 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/oauth.d.ts +56 -0
  28. package/dist/oauth.d.ts.map +1 -0
  29. package/dist/oauth.js +68 -0
  30. package/dist/oauth.js.map +1 -0
  31. package/dist/registration.d.ts +33 -0
  32. package/dist/registration.d.ts.map +1 -0
  33. package/dist/registration.js +49 -0
  34. package/dist/registration.js.map +1 -0
  35. package/dist/resources/admin.d.ts +52 -1
  36. package/dist/resources/admin.d.ts.map +1 -1
  37. package/dist/resources/admin.js +55 -0
  38. package/dist/resources/admin.js.map +1 -1
  39. package/dist/resources/billing.d.ts +242 -0
  40. package/dist/resources/billing.d.ts.map +1 -0
  41. package/dist/resources/billing.js +376 -0
  42. package/dist/resources/billing.js.map +1 -0
  43. package/dist/resources/chains.d.ts +38 -0
  44. package/dist/resources/chains.d.ts.map +1 -0
  45. package/dist/resources/chains.js +46 -0
  46. package/dist/resources/chains.js.map +1 -0
  47. package/dist/resources/device.d.ts +43 -0
  48. package/dist/resources/device.d.ts.map +1 -0
  49. package/dist/resources/device.js +49 -0
  50. package/dist/resources/device.js.map +1 -0
  51. package/dist/resources/execute.d.ts +39 -1
  52. package/dist/resources/execute.d.ts.map +1 -1
  53. package/dist/resources/execute.js +41 -1
  54. package/dist/resources/execute.js.map +1 -1
  55. package/dist/resources/health.d.ts +34 -0
  56. package/dist/resources/health.d.ts.map +1 -0
  57. package/dist/resources/health.js +43 -0
  58. package/dist/resources/health.js.map +1 -0
  59. package/dist/resources/identity.d.ts +83 -2
  60. package/dist/resources/identity.d.ts.map +1 -1
  61. package/dist/resources/identity.js +154 -2
  62. package/dist/resources/identity.js.map +1 -1
  63. package/dist/resources/oauth-clients.d.ts +71 -0
  64. package/dist/resources/oauth-clients.d.ts.map +1 -0
  65. package/dist/resources/oauth-clients.js +75 -0
  66. package/dist/resources/oauth-clients.js.map +1 -0
  67. package/dist/resources/pending.d.ts +13 -1
  68. package/dist/resources/pending.d.ts.map +1 -1
  69. package/dist/resources/pending.js +15 -0
  70. package/dist/resources/pending.js.map +1 -1
  71. package/dist/resources/proof.d.ts +75 -0
  72. package/dist/resources/proof.d.ts.map +1 -0
  73. package/dist/resources/proof.js +103 -0
  74. package/dist/resources/proof.js.map +1 -0
  75. package/dist/resources/registration-tokens.d.ts +51 -0
  76. package/dist/resources/registration-tokens.d.ts.map +1 -0
  77. package/dist/resources/registration-tokens.js +54 -0
  78. package/dist/resources/registration-tokens.js.map +1 -0
  79. package/dist/resources/transaction.d.ts +20 -0
  80. package/dist/resources/transaction.d.ts.map +1 -1
  81. package/dist/resources/transaction.js +28 -0
  82. package/dist/resources/transaction.js.map +1 -1
  83. package/dist/resources/transparency.d.ts +68 -0
  84. package/dist/resources/transparency.d.ts.map +1 -0
  85. package/dist/resources/transparency.js +83 -0
  86. package/dist/resources/transparency.js.map +1 -0
  87. package/dist/resources/webhooks.d.ts +97 -0
  88. package/dist/resources/webhooks.d.ts.map +1 -0
  89. package/dist/resources/webhooks.js +112 -0
  90. package/dist/resources/webhooks.js.map +1 -0
  91. package/dist/self-signup.d.ts +66 -0
  92. package/dist/self-signup.d.ts.map +1 -0
  93. package/dist/self-signup.js +76 -0
  94. package/dist/self-signup.js.map +1 -0
  95. package/dist/shared-proof.d.ts +34 -0
  96. package/dist/shared-proof.d.ts.map +1 -0
  97. package/dist/shared-proof.js +78 -0
  98. package/dist/shared-proof.js.map +1 -0
  99. package/dist/types.d.ts +901 -24
  100. package/dist/types.d.ts.map +1 -1
  101. package/dist/verify-receipt.d.ts +32 -0
  102. package/dist/verify-receipt.d.ts.map +1 -0
  103. package/dist/verify-receipt.js +176 -0
  104. package/dist/verify-receipt.js.map +1 -0
  105. package/package.json +6 -5
@@ -0,0 +1,376 @@
1
+ import { paginate } from '../client.js';
2
+ import { verifyReceipt } from '../verify-receipt.js';
3
+ /**
4
+ * Balance, commitments, and adding funds.
5
+ *
6
+ * The two numbers here are easy to confuse and only one of them is safe to act
7
+ * on. `spendable_usd` is available balance plus any credit line. `remaining_usd`
8
+ * (from `obligations`) subtracts what pending intents will consume when they
9
+ * execute — and multi-signature intents can wait hours or weeks for quorum, so an
10
+ * account can hold a balance that is entirely committed and still be refused on
11
+ * its next call. Show or gate on `remaining_usd`.
12
+ *
13
+ * Funding has two attribution mechanisms and both are here.
14
+ * `openPayment` declares an exact amount to send, matched inside a TTL — it needs
15
+ * no registered wallet and suits a first deposit. `registerPayerAddress` records a
16
+ * wallet once so every future send from it credits automatically.
17
+ *
18
+ * The second used to be omitted, on the stated grounds that asserting an address
19
+ * belongs to your organization required a signed-in portal owner rather than a
20
+ * machine key. That was simply wrong — the endpoint authenticates with an API key
21
+ * carrying `billing:write` — and the omission mattered, because the gateway's own
22
+ * 402 names registering a sender as the recommended fix.
23
+ */
24
+ /**
25
+ * Whole seconds until an ISO instant, or null if there is nothing usable to measure.
26
+ *
27
+ * Floored, never rounded up: a quote with 900ms left must not report 1 second and invite a caller
28
+ * to act on it.
29
+ */
30
+ function secondsUntil(iso) {
31
+ if (typeof iso !== 'string')
32
+ return null;
33
+ const at = Date.parse(iso);
34
+ if (!Number.isFinite(at))
35
+ return null;
36
+ return Math.max(0, Math.floor((at - Date.now()) / 1000));
37
+ }
38
+ export class BillingResource {
39
+ http;
40
+ client;
41
+ /**
42
+ * `client` is the whole client, not just its HTTP handle, because verifying a receipt has to
43
+ * reach the transparency log as well as billing. It is captured, never dereferenced during
44
+ * construction — the client assigns its resources in sequence, so `transparency` does not exist
45
+ * yet at this point but always does by the time anything here runs.
46
+ */
47
+ constructor(http, client) {
48
+ this.http = http;
49
+ this.client = client;
50
+ }
51
+ /**
52
+ * Every priced operation and what it costs — one call, no guessing.
53
+ *
54
+ * `quote()` prices ONE sku on ONE chain and needs the sku name up front, which is the problem:
55
+ * the names are not guessable (`identity.provision`, not `identity.create`), and nothing listed
56
+ * them. Discovering the price of onboarding meant guessing a name, being refused, and guessing
57
+ * again.
58
+ *
59
+ * Use this to find the sku, then `quote()` to get a binding price for a specific piece of work.
60
+ * Requires `billing:read`.
61
+ */
62
+ async pricing() {
63
+ const { data } = await this.http.get('/v1/pricing');
64
+ return data;
65
+ }
66
+ /** Available, held, credit line, and spendable. Requires `billing:read`. */
67
+ async balance() {
68
+ const { data } = await this.http.get('/v1/billing/balance');
69
+ return data;
70
+ }
71
+ /**
72
+ * Price a piece of work before committing to it.
73
+ *
74
+ * Free, and the answer binds: pass the returned `id` as `quote_id` on the
75
+ * transaction and that is the price, regardless of what gas does in between.
76
+ * A quote is single-use and expires, so ask when you are ready to act.
77
+ *
78
+ * Worth checking `computation.gas_estimate_basis` on a cost-plus chain. A
79
+ * `class_thin` basis means the proof class has its own cost history but too
80
+ * little of it for the median to be stable — the number is indicative, and
81
+ * can move materially as more of that class executes.
82
+ */
83
+ async quote(params) {
84
+ const { data } = await this.http.post('/v1/quote', {
85
+ chain: params.chain,
86
+ proof_class: params.proofClass,
87
+ leg_count: params.legCount ?? 1,
88
+ sku: params.sku,
89
+ additional_chains: params.additionalChains,
90
+ });
91
+ return data;
92
+ }
93
+ /**
94
+ * Re-read a quote you already have.
95
+ *
96
+ * Quotes are single-use and expire, and there was no way to ask about one after it was issued —
97
+ * so a caller who priced some work, got interrupted, and came back had to either guess whether
98
+ * their quote was still good or throw it away and ask again. Guessing wrong means a 400 in the
99
+ * middle of a transaction; throwing it away means the price can move underneath them.
100
+ *
101
+ * `quote()` CREATES; this one READS. Requires `billing:read`.
102
+ */
103
+ async quoteById(id) {
104
+ const { data } = await this.http.get(`/v1/quote/${encodeURIComponent(id)}`);
105
+ // `seconds_remaining` is computed HERE rather than left to the caller.
106
+ //
107
+ // The question anyone reads a quote back to answer is "can I still use this?", and answering it
108
+ // from `expires_at` means parsing a timestamp and subtracting against a clock — three chances
109
+ // to get a timezone or a unit wrong, on a value that decides whether a submission is refused
110
+ // partway through the work. `null` when the gateway sent no expiry, which is not the same as
111
+ // zero and must not be mistaken for it.
112
+ return { ...data, seconds_remaining: secondsUntil(data?.expires_at) };
113
+ }
114
+ /**
115
+ * Pending intents and what they will cost — including `remaining_usd`, the
116
+ * amount that may actually be committed to new work.
117
+ */
118
+ async obligations() {
119
+ const { data } = await this.http.get('/v1/billing/obligations');
120
+ return data;
121
+ }
122
+ // ── Evidence ────────────────────────────────────────────────────────────────────────────────
123
+ //
124
+ // What was I charged, and can I prove it? These four endpoints existed on the gateway from the
125
+ // start and had no client surface at all — so the one question an enterprise finance or audit
126
+ // function actually asks could only be answered by hand-rolling HTTP. The evidence was there and
127
+ // unreachable, which for an auditor is the same as absent.
128
+ /**
129
+ * Every balance change, newest first. Requires `billing:read`.
130
+ *
131
+ * The append-only, double-entry record behind the balance: what moved, when, and why. Corrections
132
+ * appear as new REVERSING entries rather than edits, so the history is what happened.
133
+ *
134
+ * Use `ledgerAll()` to walk the whole thing.
135
+ */
136
+ async ledger(params = {}) {
137
+ const { data } = await this.http.get('/v1/billing/ledger', {
138
+ params: { limit: params.limit ?? 50, offset: params.offset ?? 0 },
139
+ });
140
+ return data;
141
+ }
142
+ /**
143
+ * Every ledger entry, paging automatically.
144
+ *
145
+ * ```ts
146
+ * for await (const entry of certen.billing.ledgerAll()) { ... }
147
+ * ```
148
+ *
149
+ * The endpoint returns no total and no `has_more`, so termination is inferred from a short page —
150
+ * which is why this belongs here once rather than in every caller that gets the condition subtly
151
+ * wrong and silently reports a partial ledger as complete.
152
+ */
153
+ ledgerAll(pageSize = 100) {
154
+ return paginate(async (limit, offset) => {
155
+ const page = await this.ledger({ limit, offset });
156
+ return { items: page.entries ?? [], hasMore: page.pagination?.has_more };
157
+ }, pageSize);
158
+ }
159
+ /** Signed receipts for every payment, charge, refund and adjustment. Requires `billing:read`. */
160
+ async receipts(params = {}) {
161
+ const { data } = await this.http.get('/v1/billing/receipts', {
162
+ params: { limit: params.limit ?? 50, offset: params.offset ?? 0 },
163
+ });
164
+ return data;
165
+ }
166
+ /** Every receipt, paging automatically. */
167
+ receiptsAll(pageSize = 100) {
168
+ return paginate(async (limit, offset) => {
169
+ const page = await this.receipts({ limit, offset });
170
+ return { items: page.receipts ?? [], hasMore: page.pagination?.has_more };
171
+ }, pageSize);
172
+ }
173
+ /**
174
+ * One receipt, with its signature, its computation inputs, and the gateway's own verification.
175
+ *
176
+ * `verification` is CERTEN checking CERTEN, which settles nothing by itself. What makes the
177
+ * receipt evidence is that every check in it is reproducible by you: verify `signature` against
178
+ * `verificationKeys()`, reproduce `digest` from `body`, and fetch `receiptProof()` to show the
179
+ * receipt is in a log that was anchored on Accumulate.
180
+ */
181
+ async receipt(id) {
182
+ const { data } = await this.http.get(`/v1/billing/receipts/${encodeURIComponent(id)}`);
183
+ return data;
184
+ }
185
+ /**
186
+ * The transparency-log inclusion proof for a receipt.
187
+ *
188
+ * **Store it alongside the receipt.** It remains valid forever against the tree head it names,
189
+ * and that head is pinned on Accumulate — so the proof outlives any cooperation from CERTEN,
190
+ * which is the entire point of it existing.
191
+ *
192
+ * Defaults to the newest ANCHORED head; a proof against an unanchored head is only as good as our
193
+ * word. Only receipts with `logged: true` have one — expect a 404 otherwise.
194
+ */
195
+ async receiptProof(id, params = {}) {
196
+ const { data } = await this.http.get(`/v1/billing/receipts/${encodeURIComponent(id)}/proof`, params.treeSize ? { params: { tree_size: params.treeSize } } : undefined);
197
+ return data;
198
+ }
199
+ /**
200
+ * The public keys receipts and tree heads are signed with.
201
+ *
202
+ * Deliberately unauthenticated on the gateway, and it should stay that way in your integration
203
+ * too: a verification key you can only obtain by asking us nicely could not settle a dispute
204
+ * with us.
205
+ */
206
+ async verificationKeys() {
207
+ const { data } = await this.http.get('/v1/billing/receipts/verification-key');
208
+ return data;
209
+ }
210
+ /**
211
+ * Check a receipt yourself, against independently published data.
212
+ *
213
+ * Recomputes the digest from the body, verifies the ed25519 signature against the PUBLISHED key
214
+ * set, recomputes the salted leaf, folds the RFC 6962 audit path, and compares the result with a
215
+ * signed tree head fetched separately — not with the root that travelled inside the proof, which
216
+ * would be comparing the proof with itself.
217
+ *
218
+ * Never throws for a failed check: `verified` is false and the reason is in `checks`. A check that
219
+ * could not be run is `skipped`, and `complete` goes false — a verifier that cannot reach the log
220
+ * must say so rather than imply a pass.
221
+ */
222
+ verifyReceipt(id) {
223
+ return verifyReceipt(this.client, id);
224
+ }
225
+ /**
226
+ * Register a wallet you pay from, so every future deposit from it credits automatically.
227
+ *
228
+ * This is the difference between funding once and funding repeatedly. `openPayment` opens a
229
+ * single-use intent matched on the EXACT amount within a TTL — right for a first deposit, and a
230
+ * step before every send thereafter. A registered address needs none of that: money arriving from
231
+ * it is attributed to this organization on sight.
232
+ *
233
+ * **The gateway's own 402 recommends doing this, and until now no client could.** Its `how_to_pay`
234
+ * block names `POST /v1/billing/deposit-addresses` as the recommended fix, while this SDK omitted
235
+ * it on the stated grounds that it needed a portal session rather than a machine key. That was
236
+ * wrong: the endpoint takes an API key with `billing:write`, which is exactly what an autonomous
237
+ * caller settling its own 402 is holding.
238
+ *
239
+ * An address belongs to ONE organization per chain. A duplicate is rejected rather than merged,
240
+ * because ambiguous attribution means crediting the wrong customer — expect a 409.
241
+ */
242
+ async registerPayerAddress(params) {
243
+ const { data } = await this.http.post('/v1/billing/deposit-addresses', {
244
+ chain: params.chain,
245
+ address: params.address,
246
+ ...(params.label ? { label: params.label } : {}),
247
+ });
248
+ return data;
249
+ }
250
+ /** Wallets registered for automatic attribution. Requires `billing:read`. */
251
+ async payerAddresses() {
252
+ const { data } = await this.http.get('/v1/billing/deposit-addresses');
253
+ return data;
254
+ }
255
+ /**
256
+ * Where to send stablecoin, optionally opening a single-use payment matched on
257
+ * the exact amount.
258
+ *
259
+ * Omit `amountUsd` to read the deposit address without opening anything — an
260
+ * intent for an unspecified amount could never be matched. Requires
261
+ * `billing:fund` (or `billing:write`).
262
+ */
263
+ async openPayment(params) {
264
+ const { data } = await this.http.post('/v1/billing/deposits', {
265
+ chain: params.chain,
266
+ ...(params.amountUsd ? { amount_usd: params.amountUsd } : {}),
267
+ });
268
+ return data;
269
+ }
270
+ /**
271
+ * Status of a payment you opened. Requires `billing:read`.
272
+ *
273
+ * Use this rather than watching the balance: a second deposit or a charge in the
274
+ * same window moves the balance too, so inferring from it reports the wrong
275
+ * payment as matched.
276
+ */
277
+ /**
278
+ * Payments the gateway has seen, most recent first.
279
+ *
280
+ * Distinct from a deposit INTENT. A payment can be credited without ever matching an intent —
281
+ * see `waitForPayment` — so this is the record that says whether money actually arrived.
282
+ */
283
+ async payments(params = {}) {
284
+ const { data } = await this.http.get('/v1/billing/payments', {
285
+ params: { limit: params.limit ?? 10 },
286
+ });
287
+ return data;
288
+ }
289
+ async payment(reference) {
290
+ const { data } = await this.http.get(`/v1/billing/deposits/${encodeURIComponent(reference)}`);
291
+ // The response IS the intent. It used to arrive under an `intent` key with nothing beside it,
292
+ // so the wrapper carried no information — the clearest case of the inconsistency the gateway's
293
+ // 2026-08 break removed.
294
+ return data;
295
+ }
296
+ /**
297
+ * Resolve once the payment is credited, or when it expires.
298
+ *
299
+ * Returns the terminal status rather than throwing on expiry — an expired
300
+ * payment is an ordinary outcome the caller should report, not an error. Only a
301
+ * genuine transport or auth failure throws.
302
+ *
303
+ * **It watches the payment feed as well as the intent, and that is not belt-and-braces.**
304
+ *
305
+ * It began as a workaround for a gateway bug: the gateway closed a deposit intent only when the
306
+ * payment had been attributed BY that intent, and since attribution tries a registered payer
307
+ * address first — and the funding flow registers the sender — a paid intent was never closed.
308
+ * Observed live: 1 USDC credited in seconds with `attribution: registered_address` while the
309
+ * intent sat `open` with `matched_at: null`, until it expired an hour later. Watching only the
310
+ * intent reported "not credited" on money that had already arrived. The gateway now closes the
311
+ * intent on credit regardless of how the org was identified.
312
+ *
313
+ * The feed watch stays, for two reasons that outlive that bug. The SDK is versioned separately
314
+ * and is regularly pointed at an older gateway, where the old behaviour is still live. And the
315
+ * intent can only ever report money that matched it: a deposit for the wrong amount, or one sent
316
+ * before the intent was opened, still credits the balance and still answers the caller's actual
317
+ * question — did my money arrive.
318
+ *
319
+ * On that path the returned status is synthesised with `status: 'matched'` and the credited
320
+ * payment's id, because from the caller's point of view the money arrived.
321
+ */
322
+ async waitForPayment(reference, opts = {}) {
323
+ const intervalMs = opts.intervalMs ?? 5_000;
324
+ const timeoutMs = opts.timeoutMs ?? 60 * 60 * 1_000;
325
+ const deadline = Date.now() + timeoutMs;
326
+ // Payments already credited before this wait started are not evidence for it. Anything at or
327
+ // after this instant is.
328
+ const since = Date.now();
329
+ for (;;) {
330
+ const status = await this.payment(reference);
331
+ opts.onPoll?.(status);
332
+ if (status.status !== 'open')
333
+ return status;
334
+ const credited = await this.creditedSince(since, status.amount_usd);
335
+ if (credited) {
336
+ const matched = {
337
+ ...status,
338
+ status: 'matched',
339
+ matched_at: credited.created_at ?? new Date().toISOString(),
340
+ payment_id: credited.id ?? null,
341
+ };
342
+ opts.onPoll?.(matched);
343
+ return matched;
344
+ }
345
+ if (new Date(status.expires_at).getTime() <= Date.now())
346
+ return status;
347
+ if (Date.now() >= deadline)
348
+ return status;
349
+ await new Promise((r) => setTimeout(r, intervalMs));
350
+ }
351
+ }
352
+ /**
353
+ * A credited payment of this amount that arrived after `since`, if there is one.
354
+ *
355
+ * Returns null on any failure: an unavailable payments feed must never turn a wait that would
356
+ * otherwise have succeeded into an error, and the intent poll above remains the primary signal.
357
+ */
358
+ async creditedSince(since, amountUsd) {
359
+ try {
360
+ const { payments } = await this.payments({ limit: 10 });
361
+ return (payments ?? []).find((p) => {
362
+ if (p.status !== 'credited')
363
+ return false;
364
+ if (String(p.amount_usd) !== String(amountUsd))
365
+ return false;
366
+ const at = Date.parse(String(p.created_at ?? ''));
367
+ // A missing timestamp cannot be placed in time, so it is not treated as evidence.
368
+ return Number.isFinite(at) && at >= since - 60_000;
369
+ }) ?? null;
370
+ }
371
+ catch {
372
+ return null;
373
+ }
374
+ }
375
+ }
376
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAqB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAoBrD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;;;GAKG;AACH,SAAS,YAAY,CAAC,GAAY;IAChC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAA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AAI,EAAE,IAAI,KAAK,GAAG,MAAM,CAAC;YACrD,CAAC,CAAC,IAAI,IAAI,CAAC;QACb,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,38 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import type { ChainsListResponse, ChainDetailResponse } from '../types.js';
3
+ /**
4
+ * The contract registry: which chains CERTEN is deployed on, and at what addresses.
5
+ *
6
+ * **These two endpoints are public.** They take no API key, by deliberate design on the gateway
7
+ * side — someone deciding whether to build on CERTEN needs to see the on-chain footprint before
8
+ * they have a credential, and an address already published on eight block explorers is not a
9
+ * secret worth gating. Calls made through this resource still carry the client's key header;
10
+ * the gateway simply does not require it.
11
+ *
12
+ * That property is what lets a CLI validate a chain name, or check that the gateway is alive,
13
+ * before the user has logged in to anything.
14
+ */
15
+ export declare class ChainsResource {
16
+ private http;
17
+ constructor(http: AxiosInstance);
18
+ /**
19
+ * Every network in the registry, with contract addresses and explorer links.
20
+ *
21
+ * `verifiedOnly` filters to networks whose contracts were all confirmed to carry bytecode via
22
+ * `eth_getCode`. Non-EVM entries are transcribed from validator configuration and are never
23
+ * independently verified, so they do not survive that filter — which is the honest behaviour,
24
+ * not an omission.
25
+ */
26
+ list(params?: {
27
+ family?: string;
28
+ verifiedOnly?: boolean;
29
+ }): Promise<ChainsListResponse>;
30
+ /**
31
+ * One network, by registry id (`base-sepolia`) or numeric EVM chain id (`84532`).
32
+ *
33
+ * Both spellings are accepted because integrators have whichever one their wallet or RPC config
34
+ * handed them, and making them translate is a step that buys nothing.
35
+ */
36
+ get(idOrChainId: string | number): Promise<ChainDetailResponse>;
37
+ }
38
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/resources/chains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE3E;;;;;;;;;;;GAWG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC;;;;;;;OAOG;IACG,IAAI,CAAC,MAAM,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAUjG;;;;;OAKG;IACG,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAItE"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The contract registry: which chains CERTEN is deployed on, and at what addresses.
3
+ *
4
+ * **These two endpoints are public.** They take no API key, by deliberate design on the gateway
5
+ * side — someone deciding whether to build on CERTEN needs to see the on-chain footprint before
6
+ * they have a credential, and an address already published on eight block explorers is not a
7
+ * secret worth gating. Calls made through this resource still carry the client's key header;
8
+ * the gateway simply does not require it.
9
+ *
10
+ * That property is what lets a CLI validate a chain name, or check that the gateway is alive,
11
+ * before the user has logged in to anything.
12
+ */
13
+ export class ChainsResource {
14
+ http;
15
+ constructor(http) {
16
+ this.http = http;
17
+ }
18
+ /**
19
+ * Every network in the registry, with contract addresses and explorer links.
20
+ *
21
+ * `verifiedOnly` filters to networks whose contracts were all confirmed to carry bytecode via
22
+ * `eth_getCode`. Non-EVM entries are transcribed from validator configuration and are never
23
+ * independently verified, so they do not survive that filter — which is the honest behaviour,
24
+ * not an omission.
25
+ */
26
+ async list(params = {}) {
27
+ const { data } = await this.http.get('/v1/chains', {
28
+ params: {
29
+ family: params.family,
30
+ verified_only: params.verifiedOnly,
31
+ },
32
+ });
33
+ return data;
34
+ }
35
+ /**
36
+ * One network, by registry id (`base-sepolia`) or numeric EVM chain id (`84532`).
37
+ *
38
+ * Both spellings are accepted because integrators have whichever one their wallet or RPC config
39
+ * handed them, and making them translate is a step that buys nothing.
40
+ */
41
+ async get(idOrChainId) {
42
+ const { data } = await this.http.get(`/v1/chains/${idOrChainId}`);
43
+ return data;
44
+ }
45
+ }
46
+ //# sourceMappingURL=chains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/resources/chains.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,SAAsD,EAAE;QACjE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE;YACjD,MAAM,EAAE;gBACN,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,aAAa,EAAE,MAAM,CAAC,YAAY;aACnC;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,WAA4B;QACpC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,WAAW,EAAE,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import type { DeviceAuthorization, DeviceAuthorizationStatus } from '../types.js';
3
+ /**
4
+ * The device authorization grant (RFC 8628), so a terminal can obtain its own API key.
5
+ *
6
+ * Without it, the first credential could only be minted in a browser and carried to a terminal by
7
+ * hand — several steps in another application, and a long-lived secret through a clipboard and
8
+ * usually into shell history.
9
+ *
10
+ * **`start` and `poll` take no API key**, by design: the caller has none yet, which is the entire
11
+ * point. Neither grants anything on its own. A started request belongs to no organization until a
12
+ * signed-in owner or admin approves it in the portal, and the key is minted only when the device
13
+ * collects it — once — using the 256-bit device code, which the gateway stores only as an HMAC.
14
+ *
15
+ * Approval and denial are **not** exposed here. They require a Firebase portal session, which a
16
+ * machine key deliberately cannot substitute for: the gateway answers 401 to an approval attempt
17
+ * carrying `X-API-Key`, so a leaked machine key cannot escalate itself into minting more keys.
18
+ * Putting those calls on this SDK would imply otherwise.
19
+ */
20
+ export declare class DeviceResource {
21
+ private http;
22
+ constructor(http: AxiosInstance);
23
+ /**
24
+ * Ask for a device code and the short user code a human types into the portal.
25
+ *
26
+ * `deviceName` is shown on the approval screen and becomes the minted key's name, so make it
27
+ * something the approver will recognise as the machine in front of them.
28
+ */
29
+ start(params?: {
30
+ deviceName?: string;
31
+ }): Promise<DeviceAuthorization>;
32
+ /**
33
+ * Ask whether it has been approved yet, and collect the key when it has.
34
+ *
35
+ * **The key is returned exactly once**, in the first response after approval; later calls report
36
+ * `claimed` and carry nothing. Store it before doing anything else with the result.
37
+ *
38
+ * Poll no faster than the `interval` seconds `start` returned. A `claimed` status on a code this
39
+ * process never collected means someone else did — worth surfacing loudly rather than retrying.
40
+ */
41
+ poll(deviceCode: string): Promise<DeviceAuthorizationStatus>;
42
+ }
43
+ //# sourceMappingURL=device.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/resources/device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAElF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC;;;;;OAKG;IACG,KAAK,CAAC,MAAM,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/E;;;;;;;;OAQG;IACG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAInE"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The device authorization grant (RFC 8628), so a terminal can obtain its own API key.
3
+ *
4
+ * Without it, the first credential could only be minted in a browser and carried to a terminal by
5
+ * hand — several steps in another application, and a long-lived secret through a clipboard and
6
+ * usually into shell history.
7
+ *
8
+ * **`start` and `poll` take no API key**, by design: the caller has none yet, which is the entire
9
+ * point. Neither grants anything on its own. A started request belongs to no organization until a
10
+ * signed-in owner or admin approves it in the portal, and the key is minted only when the device
11
+ * collects it — once — using the 256-bit device code, which the gateway stores only as an HMAC.
12
+ *
13
+ * Approval and denial are **not** exposed here. They require a Firebase portal session, which a
14
+ * machine key deliberately cannot substitute for: the gateway answers 401 to an approval attempt
15
+ * carrying `X-API-Key`, so a leaked machine key cannot escalate itself into minting more keys.
16
+ * Putting those calls on this SDK would imply otherwise.
17
+ */
18
+ export class DeviceResource {
19
+ http;
20
+ constructor(http) {
21
+ this.http = http;
22
+ }
23
+ /**
24
+ * Ask for a device code and the short user code a human types into the portal.
25
+ *
26
+ * `deviceName` is shown on the approval screen and becomes the minted key's name, so make it
27
+ * something the approver will recognise as the machine in front of them.
28
+ */
29
+ async start(params = {}) {
30
+ const { data } = await this.http.post('/v1/portal/device', {
31
+ device_name: params.deviceName,
32
+ });
33
+ return data;
34
+ }
35
+ /**
36
+ * Ask whether it has been approved yet, and collect the key when it has.
37
+ *
38
+ * **The key is returned exactly once**, in the first response after approval; later calls report
39
+ * `claimed` and carry nothing. Store it before doing anything else with the result.
40
+ *
41
+ * Poll no faster than the `interval` seconds `start` returned. A `claimed` status on a code this
42
+ * process never collected means someone else did — worth surfacing loudly rather than retrying.
43
+ */
44
+ async poll(deviceCode) {
45
+ const { data } = await this.http.get(`/v1/portal/device/${encodeURIComponent(deviceCode)}`);
46
+ return data;
47
+ }
48
+ }
49
+ //# sourceMappingURL=device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/resources/device.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAC,SAAkC,EAAE;QAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YACzD,WAAW,EAAE,MAAM,CAAC,UAAU;SAC/B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,CAAC,UAAkB;QAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAC5F,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import type { ContractCall, TransactionResponse } from '../types.js';
2
+ import type { ContractAddresses, ContractCall, ProofClass, TransactionResponse } from '../types.js';
3
3
  /**
4
4
  * The proof-gated execution flow, as one call instead of four.
5
5
  *
@@ -27,16 +27,47 @@ export interface ProofGatedCallParams {
27
27
  chain: string;
28
28
  chainId?: number;
29
29
  contractCall: ContractCall;
30
+ /**
31
+ * Override the CERTEN deployment addresses (anchor, abstractAccount, …). Omit unless you are
32
+ * pointing at a non-standard deployment — the gateway applies the correct defaults.
33
+ */
34
+ contractAddresses?: ContractAddresses;
30
35
  sign: SignFn;
31
36
  publicKey: string;
32
37
  /** Nominate a seat on the page. Defaults to `publicKey`. */
33
38
  signerPublicKey?: string;
34
39
  /** Nominate which page of the book signs, e.g. `acc://panel.acme/book/2`. */
35
40
  signerKeyPage?: string;
41
+ /**
42
+ * Schedule the proof cycle: `on_demand` (default, ~60–110s) or `on_cadence` (batched, cheaper,
43
+ * slower). It changes when the proof is produced, never what it proves.
44
+ */
45
+ proofClass?: ProofClass;
36
46
  idempotencyKey?: string;
47
+ /**
48
+ * Submit even if the abstract account is known to hold no gas.
49
+ *
50
+ * The guard refuses only on a POSITIVELY OBSERVED zero balance, because an intent that moves
51
+ * value from an empty account is accepted, signed, submitted, and then parks at `anchoring`
52
+ * forever with nothing reporting why. Set this when you are deliberately exercising that path.
53
+ */
54
+ skipFundingCheck?: boolean;
37
55
  }
38
56
  export interface TransferParams {
39
57
  identityId: string;
58
+ /**
59
+ * The signing identity's ADI, e.g. `acc://your-org.acme`.
60
+ *
61
+ * REQUIRED. Its absence is why this method never worked: the upstream native-transfer path reads
62
+ * `intent.adiUrl` with no null check, so an intent without one threw upstream and came back as a
63
+ * bodyless `502` — which reads as "the gateway is down", not "you omitted a field". See
64
+ * certenIO/accumulate-api-bridge#1.
65
+ *
66
+ * Requiring it is not a breaking change in practice: every call that omitted it failed, so there
67
+ * is no working code to break. It is the only one of the four fields that path needs which the
68
+ * caller must supply — `id`, `initiatedBy` and `timestamp` are generated below.
69
+ */
70
+ adiUrl: string;
40
71
  fromChain: string;
41
72
  toChain: string;
42
73
  fromAddress: string;
@@ -48,7 +79,14 @@ export interface TransferParams {
48
79
  publicKey: string;
49
80
  signerPublicKey?: string;
50
81
  signerKeyPage?: string;
82
+ /**
83
+ * Schedule the proof cycle: `on_demand` (default, ~60–110s) or `on_cadence` (batched, cheaper,
84
+ * slower). It changes when the proof is produced, never what it proves.
85
+ */
86
+ proofClass?: ProofClass;
51
87
  idempotencyKey?: string;
88
+ /** Submit even if the abstract account is known to hold no gas. See ProofGatedCallParams. */
89
+ skipFundingCheck?: boolean;
52
90
  }
53
91
  export interface OpenedIntent {
54
92
  intentId: string;