@certen.io/sdk 0.5.0 → 0.7.1

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