@certen.io/sdk 0.5.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 +576 -0
  2. package/README.md +133 -119
  3. package/dist/client.d.ts +96 -6
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +258 -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 +13 -1
  16. package/dist/errors.d.ts.map +1 -1
  17. package/dist/errors.js +18 -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 +8 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +17 -0
  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 +198 -19
  40. package/dist/resources/billing.d.ts.map +1 -1
  41. package/dist/resources/billing.js +297 -7
  42. package/dist/resources/billing.js.map +1 -1
  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 +10 -0
  52. package/dist/resources/execute.d.ts.map +1 -1
  53. package/dist/resources/execute.js +18 -0
  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 +790 -19
  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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,581 @@
1
1
  # Changelog — @certen.io/sdk
2
2
 
3
+ ## 0.7.0 — one response shape, and nulls that stay null
4
+
5
+ **Breaking.** Requires a gateway from 2026-08 or later. An older gateway sends the previous shape and
6
+ this version will not read it; 0.6.0 and a current gateway are likewise incompatible. Upgrade both.
7
+ ### Added — `selfSignup`: an organization from a keypair, with nobody in the loop
8
+
9
+ CERTEN is non-custodial, and every route to an organization still required a human — ours in an
10
+ approvals queue, theirs in a browser, or an existing customer handing over a registration token.
11
+ That made CERTEN a friction point in the one flow where it should be invisible.
12
+
13
+ The anchor is now an Ed25519 keypair: free to create, impossible for us to hold, needs no inbox and
14
+ no browser, and a credential the caller needs anyway since every CERTEN identity is an Ed25519 key.
15
+ One step does two jobs.
16
+
17
+ ```ts
18
+ const { org, api_key } = await selfSignup({
19
+ publicKey: myPublicKeyHex,
20
+ sign: (nonceHex) => signWithMyKey(nonceHex), // detached ed25519 over the nonce BYTES
21
+ });
22
+ ```
23
+
24
+ `sign` is a callback rather than a key parameter, deliberately: the private half never reaches this
25
+ SDK. `requestSignupChallenge` and `completeSignup` are exported for callers driving the two steps
26
+ themselves.
27
+
28
+ Challenge-response, because one step is not enough — a caller signing something they chose proves
29
+ possession at a moment of their choosing and can be replayed forever. The nonce is server-issued,
30
+ single-use, short-lived, and optionally bound to the key at issue time so an observer cannot race to
31
+ answer it. **It is consumed whether or not the signature verified**, so a retry needs a fresh
32
+ challenge; a nonce that survived a failed check would be an oracle. One key provisions one
33
+ organization, ever.
34
+
35
+ ### Added — `redeemRegistrationToken`, `client.registrationTokens`
36
+
37
+ An organization could only be born in a browser. Creation happened inside the Firebase login
38
+ exchange, so a platform could not provision its customers, a CI job could not create a scratch org,
39
+ and an agent could not take its first step — every automated path stopped and waited for a person.
40
+
41
+ A human still decides an org may exist; the decision and the provisioning no longer have to happen
42
+ at the same keyboard. An owner mints a token with `client.registrationTokens.mint()` (scope
43
+ `org:invite`), and whatever holds it calls `redeemRegistrationToken(token)` once to get a new
44
+ organization and its first API key.
45
+
46
+ `redeem` is standalone rather than a client method, for the same reason as `fetchOAuthToken`: the
47
+ caller has no credential, and obtaining one is the entire purpose.
48
+
49
+ What the new org will be — its plan, and what its first key may do — is fixed by the MINTER. A
50
+ redeemer able to choose those would be choosing what someone else is billed for. Operator and
51
+ wildcard scopes cannot be granted this way, and neither can `org:invite` itself, so one decision
52
+ cannot become an unbounded tree of organizations.
53
+
54
+ Single-use and claimed atomically, so a race cannot produce two organizations; expiring; revocable
55
+ until redeemed. Unknown, expired, revoked and already-spent tokens are all reported identically, and
56
+ the SDK says so in the error rather than letting a bare 404 read as a wrong URL.
57
+
58
+ ### Added — machine authentication end to end
59
+
60
+ With this and client-credentials auth, the whole first-run journey now runs unattended: redeem a
61
+ token, get a key, create an identity, pay, prove the work. That path had never been testable without
62
+ a human in the middle, which is why the one journey every customer walks was the one with no
63
+ automated coverage.
64
+
65
+ ### Changed — `billing.quoteById` returns `seconds_remaining`
66
+
67
+ It returned `status` and `expires_at` and left the caller to parse a timestamp and subtract against a
68
+ clock — on the value that decides whether a submission is refused partway through the work. The
69
+ seconds are computed here instead. `null` when the gateway sent no expiry, which is not the same as
70
+ zero and must not be read as it.
71
+
72
+ ### Fixed — a gateway older than the client now says so
73
+
74
+ `certen pricing` against production answered `Error [NOT_FOUND]: Not Found`. The command is
75
+ advertised in the CLI's own `--help`, and the message gave no way to tell whether the key lacked
76
+ access, the resource was missing, or — the actual cause — `GET /v1/pricing` was not deployed yet.
77
+
78
+ Both cases are 404s, but they are cleanly distinguishable: an unmatched route carries no `code` and
79
+ a `Route GET:/v1/x not found` message, while every handler-raised 404 carries a `code`. An unmatched
80
+ route now raises `ENDPOINT_NOT_ON_GATEWAY`, naming the method and path and saying the deployment is
81
+ behind this client.
82
+
83
+ Clients and the gateway deploy separately, so this is not an edge case — it is the state of things
84
+ during every release window.
85
+
86
+ ### Fixed — `webhooks.deliveries` documented a scope that did not work
87
+
88
+ This method said it required `webhook:read`. It did not: `GET /v1/webhooks/deliveries` was missed
89
+ when the webhook group moved off `admin:*` and still demanded an admin scope, so a key holding
90
+ `webhook:read` could list endpoints and fetch one delivery by id, and could not list deliveries at
91
+ all — the one thing the group exists for.
92
+
93
+ The same off-by-one gave `POST /v1/admin/org` a `webhook:write` alternative, letting a key scoped to
94
+ webhooks create organizations. Both are fixed in the gateway, and both are now enforced by tests
95
+ rather than remembered. Requires the 2026-08 gateway.
96
+
97
+ ### Added — `identity.retrieveMnemonic`
98
+
99
+ The most dangerous gap on the surface. Creating an identity with `signing_mode: "provider"` never
100
+ returns the mnemonic inline — it returns a `mnemonic_retrieval.url` whose token is consumed
101
+ atomically on first read and expires in about ten minutes. Nothing in this SDK could issue that
102
+ request, so a caller who did not hand-roll HTTP lost the seed permanently, on the one flow where
103
+ CERTEN generates the key material.
104
+
105
+ Takes the URL from the create response, or an id and token separately. `parseMnemonicTarget` is
106
+ exported for anyone who needs to split it themselves.
107
+
108
+ `createAndWait` now carries `mnemonic_retrieval` through instead of discarding it — but it is a
109
+ safety net, not the path: that call may wait five minutes against a token that lives ten. For
110
+ provider mode, `create()`, collect, then poll.
111
+
112
+ ### Added — `client.oauthClients`
113
+
114
+ Tokens could be obtained and revoked from code; the client that issues them could only be created by
115
+ a human in the portal. So an integration could authenticate itself and not provision itself.
116
+
117
+ `list`, `create`, `remove`, `rotateSecret`.
118
+
119
+ **The operations moved from `/v1/admin/oauth-clients` to `/v1/oauth-clients`**, with the new
120
+ `oauth:read` alongside `oauth:write`. Same misfiling webhooks had: the rows are org-scoped and the
121
+ create route already refused to cross orgs without admin scope, so this was always a customer
122
+ capability wearing an operator's path. Listing your own clients also required a WRITE scope, which
123
+ it no longer does. Existing `admin:*` keys still work.
124
+
125
+ ### Added — `admin.errors`
126
+
127
+ The error catalogue was published on the gateway and then had no client method for a release, so the
128
+ codes stayed exactly as discoverable as before — by provoking them. Reads from the LIVE gateway,
129
+ which is the point: the vendored `spec/errors.json` is only as current as this release, and a
130
+ deployment ahead of it raises codes the local copy has never seen.
131
+
132
+ ### Added — `billing.quoteById`
133
+
134
+ A quote could be issued and never read back. Someone who priced work, was interrupted, and returned
135
+ had to guess whether their quote was still good or burn it and let the price move. `quote()` creates;
136
+ this reads. Returns `status` alongside `expires_at`, which are the two ways a quote stops being
137
+ usable.
138
+
139
+ ### Added — `fetchOAuthToken`, `refreshOAuthToken`, `revokeOAuthToken`
140
+
141
+ The whole OAuth2 token lifecycle was unreachable. A service using client credentials could obtain a
142
+ token only by hand-rolling HTTP, and could not give one back at all — so the response to a suspected
143
+ leak was to open a browser.
144
+
145
+ Standalone functions rather than client methods, for the same reason as `fetchSharedProof`: both
146
+ endpoints carry their credential in the BODY and need no API key. A service using OAuth holds a
147
+ client id and secret, so routing these through a constructor demanding `apiKey` would ask for the
148
+ one credential such a caller does not have.
149
+
150
+ Two behaviours worth knowing, both documented on the functions. A refresh token is single-use, and
151
+ replaying a spent one revokes its entire descendant chain — deliberate theft detection, so store the
152
+ new pair before doing anything else. And revocation deliberately never reveals whether a token
153
+ existed: success means "not valid now", not "was valid before".
154
+
155
+ ### Added — `client.webhooks`
156
+
157
+ CERTEN has pushed events all along, with a delivery queue, a retry policy and a published
158
+ signature-verification guide. None of it had a client surface, so an endpoint could be registered
159
+ nowhere and a failed delivery could be neither seen nor retried — the worst shape for a push
160
+ mechanism, because a dropped delivery and an event that never fired look identical from outside.
161
+
162
+ `list`, `register`, `update`, `remove`, `rotateSecret`, `verify`, `deliveries`, `deliveriesAll`,
163
+ `delivery`, `redeliver`.
164
+
165
+ **The operations moved from `/v1/admin/webhooks/*` to `/v1/webhooks/*`**, and from `admin:write` to
166
+ the new `webhook:read` / `webhook:write`. The data was always org-scoped — every endpoint belongs to
167
+ the calling organization — so both the path and the scope overstated what this is: reaching your own
168
+ webhooks required a scope that also grants revoking every API key in the organization, attributing
169
+ payments and publishing price books. Existing `admin:*` keys still work.
170
+
171
+ ### Fixed — `isRetryable` was wrong for two codes, in both directions
172
+
173
+ HTTP status alone decides retryability correctly almost everywhere, and gets exactly two cases
174
+ backwards. Both are now decided by the code:
175
+
176
+ - `IDEMPOTENCY_KEY_IN_FLIGHT` is a 409, which reads as "do not retry" — but it means an identical
177
+ request is already running, and retrying the SAME key is the correct response. It was being
178
+ treated as terminal, failing a request that would have succeeded moments later.
179
+ - `PLAN_QUOTA_EXCEEDED` is a 429, which reads as "back off and retry" — but it is a quota for the
180
+ billing period, not a rate. Backing off never clears it, so the retries were spent for nothing.
181
+
182
+ ### Added — 12 more error codes documented
183
+
184
+ The catalogue described 9 of the 40 codes the gateway can raise, and the gaps were the ones a client
185
+ most needs: `PAYMENT_REQUIRED`, `INSUFFICIENT_BALANCE`, `COMMITMENT_EXCEEDED`, `QUOTE_EXPIRED`,
186
+ `QUOTE_MISMATCH`, both idempotency codes, `SHARE_NO_LONGER_VALID`, and the throttles.
187
+
188
+ The gateway now publishes its catalogue at `GET /v1/errors`, and it is vendored here as
189
+ `spec/errors.json` exactly as the OpenAPI document is. A test relates the two: this SDK may not
190
+ document a code the gateway cannot raise, and the two may not disagree about status or
191
+ retryability. Previously they were unrelated lists, free to drift the moment either side changed.
192
+
193
+ ### Fixed — the client-side rate-limit throttle, which had never worked and could hang a caller
194
+
195
+ Two bugs in the same few lines, found while making retries honour `Retry-After`.
196
+
197
+ `x-ratelimit-reset` is SECONDS REMAINING, not a Unix timestamp — the gateway sends `56` for a
198
+ 60-second window. The SDK computed `Number(reset) * 1000`, producing an instant in 1970, so the
199
+ guard that waits for the window never fired. The throttle has never run.
200
+
201
+ Correcting the arithmetic alone would have been far worse than the bug: `reset` comes back on EVERY
202
+ response, so a corrected-but-unconditional version would sleep the full remaining window before
203
+ every request — turning a 60/min limit into roughly one request a minute. It now engages only once
204
+ `x-ratelimit-remaining` reaches zero.
205
+
206
+ Separately, that wait had no ceiling. A 429 carrying `Retry-After: 3600` parked the next request for
207
+ an hour inside the HTTP client, ignoring both `maxBackoffMs` and the per-request timeout, with no
208
+ way out. It is now capped at `maxBackoffMs`.
209
+
210
+ ### Changed — retries honour `Retry-After`
211
+
212
+ Exponential backoff is a guess made without information; `Retry-After` is the gateway stating when
213
+ the window reopens. Retrying earlier cannot succeed, and each early attempt still counts against the
214
+ limit. The header wins when present, capped at `maxBackoffMs` and jittered.
215
+
216
+ ### Changed — `error.details` carries the gateway's per-field validation entries
217
+
218
+ They arrived only on `body` before, which is not where anyone looks, so a tool rendering
219
+ `error.details` showed nothing for the one error class where per-field structure is most useful.
220
+ `retryAfter` keeps its place alongside.
221
+
222
+ ### Added — `client.me()`
223
+
224
+ Who this credential is and what it may do, in one call: the organization (with its name), the
225
+ GRANTED scopes, and the key or the signed-in user depending on which credential was sent.
226
+
227
+ `GET /v1/me` accepted only a portal session until now, so a machine holding an API key could learn
228
+ neither its organization nor its own permissions — the two things anyone needs immediately after
229
+ minting a key. Clients resorted to probing endpoints and reading the 403s to guess.
230
+
231
+ Check `scopes` before starting a flow rather than after. A missing scope otherwise surfaces as a 403
232
+ partway through, by which point some of the work may already have happened.
233
+
234
+ ### Changed — `identity.get()` takes `include`, and `createAndWait()` stops paying for data it discards
235
+
236
+ `GET /v1/identity/{id}` enriches with `governance`, `balances` and `pending` by default. Each is a
237
+ live query: governance and balances hit the network, and **balances runs once per linked chain**.
238
+ The parameter controlling this was neither in the OpenAPI document nor exposed here, so nobody could
239
+ opt out.
240
+
241
+ `createAndWait()` was the worst case. It polls every 3 seconds for up to 90 — around thirty rounds —
242
+ and reads exactly two fields, `status` and `can_sign`, both of which the gateway computes BEFORE any
243
+ enrichment runs. Every poll was fetching governance, per-chain balances and pending counts and
244
+ throwing them away. It now polls with `include: []` and does one enriched read at the end, so what
245
+ it returns is unchanged.
246
+
247
+ `identity.get(id, { include: [...] })` exposes the choice. Omitting the option omits the parameter
248
+ entirely, keeping the gateway default — sending `include=` and sending nothing are different
249
+ requests, and conflating them would strip enrichments from every ordinary read.
250
+
251
+ **This needs the matching gateway fix to do anything.** `?include=` arrives as an empty string,
252
+ which the route treated as falsy and turned back into the full default — so the one spelling that
253
+ reads as "give me nothing" was the spelling that fetched everything. Against a gateway older than
254
+ that fix, `include: []` is simply ignored rather than harmful.
255
+
256
+ ### Changed — `transaction.listAll()` also stops on `has_more`
257
+
258
+ Every paged list on the gateway now publishes `pagination.has_more`, including `/v1/transactions`,
259
+ which previously echoed `limit` and `offset` with no way to tell the last page from a full one.
260
+ `listAll()` uses it and falls back to short-page inference against an older gateway.
261
+
262
+ ### Changed — `paginate()` stops on `has_more` instead of guessing
263
+
264
+ The gateway now returns `pagination: { limit, offset, has_more, returned }` on the ledger, receipts
265
+ and payments lists. Eleven list endpoints paged three different ways and six reported nothing at
266
+ all, so walking one meant inferring the end from a short page.
267
+
268
+ That inference is wrong in one specific case, and it fails silently: **a final page that lands
269
+ exactly on the page size is indistinguishable from a full one.** So the walk either stops a page
270
+ early — reporting a partial ledger as complete, which for a reconciliation is worse than an error —
271
+ or spends an extra request discovering an empty page.
272
+
273
+ `paginate()`, `ledgerAll()` and `receiptsAll()` use `has_more` when it is present and fall back to
274
+ short-page inference when it is not, since the SDK is regularly pointed at an older gateway. A
275
+ server that reports `has_more: true` while returning no rows now terminates the loop rather than
276
+ spinning forever — a hang in an unattended script being worse than a wrong answer.
277
+
278
+ ### Changed — `doctor()` distinguishes an entitlement outage from a component outage
279
+
280
+ The gateway now reports `entitlement_unpublished` and `entitlement_expired` as not-ready. When no
281
+ valid entitlement epoch is published, validators refuse EVERY intent on the fleet — an outage that
282
+ stops execution of work that already exists, as opposed to a dry sponsor, which stops identity
283
+ creation silently behind a 202. The two need different responses, so `doctor()` names them
284
+ differently instead of printing a reason token.
285
+
286
+ ### Added — `fetchSharedProof()`, for the person a share link is FOR
287
+
288
+ The SDK could create a share, list shares and revoke a share — every operation for the sender — and
289
+ had nothing at all for the recipient, who is the reason the feature exists.
290
+
291
+ `fetchSharedProof(link)` is a standalone export, not a client method, and that is the point: the
292
+ endpoint takes no API key because "requiring a Certen credential to verify a Certen proof would
293
+ defeat the purpose", and putting the only client-side way to redeem behind a constructor that
294
+ demands an `apiKey` would have reimposed exactly that requirement.
295
+
296
+ Pass the link as received. The origin comes from the link itself — a proof shared from one
297
+ deployment is never fetched from another, where the token means nothing and the resulting 404 would
298
+ read as "this proof never existed". A bare token works too, with `baseUrl`.
299
+
300
+ A 410 is surfaced distinctly from a 404: the link WAS real and is now revoked, expired, or out of
301
+ views, so the recipient is told to ask for a fresh one rather than that the proof does not exist.
302
+ `proof.shared(link)` is the equivalent for a caller who already holds a client.
303
+
304
+ ### Added — `client.health.ready()`, and a `doctor()` check that tells a CERTEN outage from your setup
305
+
306
+ `doctor()` proved the gateway was there with `GET /v1/chains`. That is a static registry read: it
307
+ keeps returning 200 while the database, the api-bridge, the proof service or Accumulate are down. So
308
+ a CERTEN-side outage and a broken local setup produced the same report — "gateway reachable: ok" —
309
+ and sent the reader hunting through their own configuration for a fault that was never theirs.
310
+
311
+ The new `platform ready` check reads the public readiness probe and names what is down, with a fix
312
+ that says explicitly there is nothing on your side to change.
313
+
314
+ The case that earns the round trip is `sponsor_below_floor`: when the onboarding sponsor runs dry,
315
+ identity creation returns 202 and then **never completes** — every visible signal says it worked.
316
+ Nothing else in the report could see it. A low-but-serving sponsor is a `warn` and does not fail the
317
+ run, because failing on it would train people to ignore the check.
318
+
319
+ `health.ready()` does NOT throw on 503. A not-ready answer IS the answer and carries the reasons;
320
+ turning it into an exception would discard the only useful part. It needs no API key, so a caller
321
+ whose credential is being rejected can still find out whether the platform is the problem.
322
+
323
+ ### Changed — `createAndWait()` uses the cadence the gateway publishes
324
+
325
+ `POST /v1/identity` now returns a `polling` block: when to make the FIRST request, how often after
326
+ that, the typical total, and which statuses are terminal. It was a `status_url` and nothing else,
327
+ so every client invented a cadence — this one polled every 3 seconds starting immediately, against
328
+ an operation that is a chain of anchored Accumulate transactions and cannot complete in under a
329
+ minute. Roughly twenty requests spent before anything could possibly have changed.
330
+
331
+ An explicit `intervalMs` still overrides it completely, a gateway that sends no `polling` block
332
+ falls back to the previous numbers, and the published first-poll delay is clamped to the caller
333
+ timeout so a long advertised delay can never overshoot a short budget.
334
+
335
+ ### Added — `client.transparency` and `billing.verifyReceipt()`
336
+
337
+ The transparency log had no client surface, which made the receipts unverifiable in practice. A
338
+ receipt's own instructions say to check its folded root against the signed head at that tree size —
339
+ and `/v1/transparency/heads/{treeSize}` was unreachable, so the instruction could not be followed
340
+ without hand-rolling HTTP. A verification procedure nobody can run is not a verification procedure.
341
+
342
+ `client.transparency` exposes `log()`, `heads()`, `head(treeSize)`, `consistency(first, second)`,
343
+ `priceBooks()` and `fx(id)`. None require an API key, deliberately: evidence obtainable only by
344
+ asking CERTEN could not settle a dispute with CERTEN.
345
+
346
+ `billing.verifyReceipt(id)` runs the whole procedure and returns a per-check report — digest
347
+ recomputed from the body, ed25519 signature checked against the PUBLISHED key set, salted leaf
348
+ recomputed, audit path folded and compared against a head fetched **separately**. Comparing the
349
+ proof with the `root_hash` that travelled inside it would prove nothing; the independent fetch is
350
+ the check.
351
+
352
+ It never throws for a failed check, and a check it could not run is `skipped` — which leaves both
353
+ `verified` and `complete` false. "I could not check" and "it checks out" are the two answers a
354
+ dispute must never confuse, so an unreachable log can never produce a pass.
355
+
356
+ Verified against a real signed receipt on a running gateway: digest, signature, inclusion and root
357
+ all reproduce; the anchor check correctly reports `skipped` when no anchored head covers the receipt
358
+ yet.
359
+
360
+ ### Added — the evidence trail: `ledger`, `receipts`, `receipt`, `receiptProof`, `verificationKeys`
361
+
362
+ "What was I charged, and can I prove it?" The gateway has answered this from the start — an
363
+ append-only double-entry ledger, ed25519-signed receipts, RFC 6962 inclusion proofs against
364
+ Accumulate-anchored tree heads — and none of it had a client surface. For an audit or finance
365
+ function, evidence reachable only by hand-rolling HTTP may as well not exist.
366
+
367
+ - `ledger()` / `ledgerAll()` — every balance change, newest first. Corrections are new REVERSING
368
+ entries, never edits.
369
+ - `receipts()` / `receiptsAll()` — each carries `signed` and `logged`; `logged` is what decides
370
+ whether a proof can be fetched at all.
371
+ - `receipt(id)` — signature, computation inputs, and the gateway's own `verification` block.
372
+ - `receiptProof(id)` — the inclusion proof. **Store it with the receipt**: it stays valid forever
373
+ against a head pinned on Accumulate, so the evidence outlives CERTEN's cooperation.
374
+ - `verificationKeys()` — the public keys, so a signature can be checked without trusting the
375
+ response that carried it.
376
+
377
+ Read `covering_head`, not `head`, when asking whether a receipt is anchored. `head` is the head at
378
+ that tree size and may not itself be anchored, while a later anchored root still commits to the
379
+ leaf — so `head.anchor_status` reads "unanchored" for every receipt between anchors.
380
+
381
+ Verified against a real signed receipt from a running gateway using only what these methods return:
382
+ the digest recomputes from `body`, the ed25519 signature verifies against the published key, the
383
+ salted leaf hash matches, and the six-node audit path folds to `root_hash`. Nothing from the
384
+ gateway's own `verification` block was used — that block is CERTEN checking CERTEN, and its worth
385
+ is only that every check in it is reproducible, which is now what the SDK makes possible.
386
+
387
+ The list endpoints report no total and no `has_more`, so `ledgerAll()` and `receiptsAll()` infer
388
+ termination from a short page. That lives here once rather than in every caller that gets it subtly
389
+ wrong and reports a partial ledger as complete.
390
+
391
+ ### Added — `billing.registerPayerAddress()` and `billing.payerAddresses()`
392
+
393
+ Register the wallet you pay from once, and every future deposit from it credits automatically — no
394
+ payment intent, no exact-amount matching, no expiry.
395
+
396
+ **The gateway's own 402 recommended this and no client could do it.** The PAYMENT_REQUIRED body
397
+ names `POST /v1/billing/deposit-addresses` under `how_to_pay.register_sender`, while this SDK
398
+ omitted it on the stated grounds that it required a signed-in portal owner rather than a machine
399
+ key. That was wrong — the endpoint authenticates with an API key carrying `billing:write`, which is
400
+ exactly what an autonomous caller settling its own refusal is holding. The advice in the refusal
401
+ pointed at a raw endpoint the reader had to call by hand.
402
+
403
+ An address belongs to ONE organization per chain; a duplicate is rejected with a 409 rather than
404
+ merged, because ambiguous attribution would credit the wrong customer.
405
+
406
+ ### Changed — affordability is one call, and `doctor()` drops a round trip
407
+
408
+ `BalanceResponse` now carries `remaining_usd`, `pending_intents` and `uncovered_usd`. **Gate on
409
+ `remaining_usd`.** `spendable_usd` ignores work already committed, and CERTEN charges a
410
+ multi-signature intent when quorum is reached — which can be weeks after it was opened — so an
411
+ account can show a healthy spendable balance that is entirely spoken for and still be refused.
412
+
413
+ Reading the safe number used to require a second request to `/v1/billing/obligations`. `doctor()`
414
+ made exactly that call for exactly that one field; it no longer does, taking it from **5 round trips
415
+ to 4**. `obligations()` stays, and is still the way to see WHICH intents claimed the balance.
416
+
417
+ The fields are optional in the type because an older gateway does not send them. Clients fall back
418
+ to `obligations()` when `remaining_usd` is absent rather than treating `spendable_usd` as safe.
419
+
420
+ ### Added — `billing.pricing()`, so prices stop having to be guessed
421
+
422
+ `quote()` prices ONE sku on ONE chain and needs the sku name up front. Nothing published those
423
+ names, and they are not guessable: it is `identity.provision`, not `identity.create`. Finding out
424
+ what onboarding cost meant guessing a name, reading the refusal, and guessing again.
425
+
426
+ `billing.pricing()` returns the whole catalogue in one call — every sku, every chain, and the
427
+ `price_book_version` and `price_book_hash` that quotes and receipts also carry, so a price seen here
428
+ can be traced through to the charge.
429
+
430
+ Read `mode` before reporting a number. `flat` means `platform_fee_usd` is the whole charge; `quoted`
431
+ means gas is measured at execution and added, so the figure is a floor. `max_charge_usd` is `null`
432
+ when uncapped and stays null — it is not flattened to a string or a zero.
433
+
434
+ Requires a gateway with `GET /v1/pricing` (2026-08 or later).
435
+
436
+ ### Changed — `doctor()` asks the gateway one question once, and overlaps the rest
437
+
438
+ Measured against the live gateway before and after: **6 round trips to 5**, and **~1570ms to ~1195ms**
439
+ of wall time.
440
+
441
+ The credential check proved the key by reading the balance and then discarded the answer, so the
442
+ balance check fetched it again — two of six round trips spent asking one question twice. And the
443
+ remaining reads (portfolio, obligations, recent intents) answer unrelated questions but were awaited
444
+ one after another, so the command cost their sum.
445
+
446
+ They now run concurrently and the probe's balance is reused. The checks are still reported in the
447
+ same order with the same verdicts — only the I/O overlaps.
448
+
449
+ This is the command someone runs when they are already stuck, which is the worst moment to spend
450
+ latency on nothing.
451
+
452
+ ### Added — `listAll()` iterators that need no adapter
453
+
454
+ ```ts
455
+ for await (const tx of certen.transaction.listAll()) { … }
456
+ for await (const action of certen.pending.listAll({ identity })) { … }
457
+ for await (const { item, index, total } of certen.admin.auditLogAll({ from })) { … }
458
+ ```
459
+
460
+ `paginate` has been exported since 0.2.0 and composed with nothing this SDK ships: it takes a
461
+ callback returning `{ items }`, and no method returns that shape — `list()` returns
462
+ `{ transactions }`, `shares()` returns `{ shares }`. Using it meant hand-writing the adapter it
463
+ should have contained, in every caller:
464
+
465
+ ```ts
466
+ paginate((limit, offset) =>
467
+ certen.transaction.list({ limit, offset }).then((r) => ({ items: r.transactions })))
468
+ ```
469
+
470
+ An exported helper that cannot be used as shipped is worse than none, because it reads as a solved
471
+ problem. `paginate` and `paginateWithTotal` remain exported for endpoints the SDK does not model and
472
+ for paginating your own API.
473
+
474
+ `auditLogAll` yields `{ item, index, total }` rather than bare entries — that endpoint returns a real
475
+ total, and an audit export is long enough to want a progress line and long enough that a silent
476
+ early stop matters.
477
+
478
+ ### Breaking — identity and deposit responses are no longer wrapped
479
+
480
+ The gateway used to nest the resource under a single key on some endpoints and return it bare on
481
+ others, with no rule distinguishing them. Four operations were the odd ones out and have been
482
+ flattened.
483
+
484
+ ```ts
485
+ // before
486
+ const { identity } = await client.identity.get(id);
487
+ identity.can_sign;
488
+
489
+ // after — the response IS the identity, with its sub-resources beside it
490
+ const identity = await client.identity.get(id);
491
+ identity.can_sign;
492
+ identity.governance; // unchanged: a joined sub-resource stays named
493
+ ```
494
+
495
+ Affects `identity.create()`, `identity.get()`, `identity.update()`, `billing.payment()` and
496
+ `admin.createOrg()`. `IdentityResponse` now `extends Identity`, so an `IdentityResponse` is usable
497
+ anywhere an `Identity` was. `OrgResponse` carries `id` / `name` / `plan` / `created_at` directly.
498
+
499
+ `createAndWait()` and `execute.*` are unaffected — they return the same values as before.
500
+
501
+ The change is breaking, and was taken deliberately while there are no external integrators. The
502
+ alternatives were to break real callers later or to carry both shapes indefinitely. See the
503
+ gateway's `docs/api-conventions.md`.
504
+
505
+ ### Fixed — a field with no value is `null`, not `""`
506
+
507
+ `proof_id`, `proof_bundle_url`, `accum_tx_hash` and `error_message` were typed `string` and arrived
508
+ as `""` when the gateway had no value. The gateway declared them `type: 'string'`, and its serializer
509
+ coerces a null to an empty string rather than rejecting it — so `proof_id` was `""` on all 205
510
+ intents in the production table, meaning every transaction response ever served.
511
+
512
+ `""` is falsy, so `if (tx.proof_id)` happened to work. `tx.proof_id != null` did not: it is **true**
513
+ for `""`, and that caller went on to request a proof by empty id. Worse for `error_message`, where a
514
+ completed transaction reported an error message that was merely empty rather than absent.
515
+
516
+ These are now `string | null` and the gateway sends a real null.
517
+
518
+ ### Fixed — `can_sign: null` is no longer reported as `false`
519
+
520
+ `can_sign` is three-valued: `true`, `false`, and `null` meaning *the on-chain key page could not be
521
+ read*. The gateway declared it `type: 'boolean'`, and the serializer turned that null into `false` —
522
+ collapsing "we could not check" into "this identity cannot sign".
523
+
524
+ It rounded down rather than up, so nobody was told they could sign when they could not. What was
525
+ lost is the distinction: "definitively cannot sign, repair with `identity.update({ publicKey })`"
526
+ and "we could not check, retry" have different fixes, and callers were shown the first when the
527
+ truth was the second.
528
+
529
+ ### Changed — `waitForPayment` no longer depends on watching the payments feed
530
+
531
+ The gateway now closes a deposit intent when its payment credits, however the payer was identified.
532
+ The feed watch is kept — the SDK is versioned independently and may be pointed at an older gateway,
533
+ and a deposit for the wrong amount still credits your balance without ever matching the intent.
534
+
535
+ ## 0.6.0 — diagnosis, proofs, device authorization, and a guard that refuses to strand your money
536
+
537
+ ### Added — `client.doctor()`
538
+
539
+ An ordered list of checks that **never throws for a failed check** — a diagnosis that cannot report
540
+ a broken setup is useless. Read `report.ok` and the per-check status. It catches, in order: gateway
541
+ unreachable, a credential rejected (401) or merely unscoped (403), no active identity, an abstract
542
+ account with no gas, a balance entirely committed to pending intents, an expired trial, and intents
543
+ that anchored but never executed.
544
+
545
+ The check list is the same length however far the run got, so a skipped check is visibly skipped
546
+ rather than absent. `CREDENTIALLED_CHECKS` is exported for callers that need to mark the same set.
547
+
548
+ ### Added — `client.proof`, `client.chains`, `client.device`
549
+
550
+ `proof` covers the artifact, the bundle, custody, share links, and the Accumulate merkle receipt.
551
+ **A 5xx from the proof-service does not mean the proof is missing** — that service and Accumulate
552
+ fail independently, and the receipt keeps working when the proof-service does not.
553
+
554
+ `chains` is the public contract registry and needs no API key, which makes it usable before a
555
+ credential exists. `device` is the RFC 8628 device authorization grant, so a terminal can obtain its
556
+ own key without a human copying a secret.
557
+
558
+ ### Added — `identity.createAndWait()`
559
+
560
+ `create()` returns 202 and provisioning continues, so its response says nothing about whether the
561
+ identity works. This waits for `status` terminal AND `can_sign === true`, and distinguishes all
562
+ three values of `can_sign`: `false` is a failure, `null` is UNKNOWN and never rounds up to ready,
563
+ and a timeout is neither success nor failure.
564
+
565
+ ### Behavioural change — `execute.transfer` and `execute.contractCall` refuse an unfunded account
566
+
567
+ An intent that moves value from an empty abstract account is accepted, signed and submitted — every
568
+ call returns success — and then parks at `anchoring` forever, because the execution leg cannot run
569
+ on chain. Nothing in any API response says so.
570
+
571
+ Both methods now check first and throw `CertenUnfundedAccountError` before submitting. **The check
572
+ refuses only on a positively observed zero balance**: if the balance cannot be read, the intent
573
+ proceeds, because a guard that blocked on missing data would break real work every time the
574
+ portfolio view lagged. Opt out with `skipFundingCheck: true`.
575
+
576
+ It also normalizes the two spellings the gateway uses for a chain id — `GET /v1/portfolio` returns a
577
+ slug on some chain accounts and a numeric EVM id on others, in the same response.
578
+
3
579
  ## 0.5.0 — balance, funding, and a 402 that carries its own fix
4
580
 
5
581
  ### Added — `client.billing`