@certen.io/sdk 0.3.0 → 0.3.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 (3) hide show
  1. package/CHANGELOG.md +139 -127
  2. package/README.md +119 -117
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,127 +1,139 @@
1
- # Changelog — @certen.io/sdk
2
-
3
- ## 0.3.0 — response types now describe what the API actually returns
4
-
5
- **Breaking, at the type level only. No runtime behavior changed.**
6
-
7
- Every response interface was camelCase (`intentId`, `signingData.dataToSign`, `adiUrl`,
8
- `creditBalance`). The API is snake_case, and the resources do `return data` with no transformation —
9
- so every one of those declared fields was `undefined` at runtime while TypeScript insisted it was a
10
- `string`. The failure was silent in the worst way: code compiled, ran, and produced `undefined`
11
- somewhere far from the cause.
12
-
13
- `execute.*` was never affected. It was written against real responses and reads snake_case directly,
14
- which is why the one flow that had been exercised end-to-end worked while the typed resources did not.
15
-
16
- If you were already compensating with `as any` or reading snake_case at runtime, your code was
17
- correct and keeps working — you can now delete the casts. If you were trusting the types, your code
18
- was silently broken and will now fail to compile, which is the point.
19
-
20
- ### Changed — all response types are snake_case
21
-
22
- `IdentityResponse` · `TransactionResponse` · `GovernanceResponse` · `SignResponse` ·
23
- `PortfolioResponse` · `PendingActionsResponse` · `OrgResponse` · `ApiKeyResponse` ·
24
- `ApiKeyListItem` · `AuditLogEntry` · `UsageSummaryResponse` · `ChainAccount` · `ChainBalance` ·
25
- `PortfolioIdentity` · `PendingAction`.
26
-
27
- ### Changed — `create` and `get` no longer share a type
28
-
29
- `POST /v1/transaction` and `GET /v1/transaction/{id}` return different shapes, and one
30
- `TransactionResponse` covering both hid it. Same for governance.
31
-
32
- - `transaction.create` → **`CreateTransactionResponse`** (`intent_id`, `signing_data`, `submit_url`, `idempotent`)
33
- - `transaction.get` → `TransactionResponse` (`accum_tx_hash`, `proof`, timestamps)
34
- - `transaction.submitSignature` → **`SubmitSignatureResponse`**
35
- - `transaction.list` → **`ListTransactionsResponse`**. It declared `{ transactions, pagination }`; the endpoint returns `{ transactions, limit, offset }` and has no pagination object.
36
- - `governance.create` → **`CreateGovernanceResponse`**, `governance.submitSignature` → **`SubmitGovernanceSignatureResponse`**
37
- - `sign.submitSignature` → **`SubmitSignSignatureResponse`**
38
- - `identity.retire` → **`DeleteIdentityResponse`**
39
-
40
- ### Changed — `SigningData` split in two
41
-
42
- The two endpoints that return signing data carry the bytes under **different names**, and a single
43
- shared type is what let that go unnoticed:
44
-
45
- - **`IntentSigningData`** (`POST /v1/transaction`) — the bytes are in **`hash_to_sign`**
46
- - **`SignRequestSigningData`** (`POST /v1/sign`) — the bytes are in **`data_for_signature`**
47
-
48
- Both mean the same thing: sign the RAW BYTES of that hex. Do not hash it again; do not sign its
49
- ASCII. `execute.*` handles the distinction for you.
50
-
51
- ### Added
52
-
53
- - `Identity` and `DeleteIdentityResponse` types; `can_sign` and `error_message` on `Identity`.
54
- `can_sign` derives from the on-chain key page, not the provisioning state machine, so it can read
55
- `true` while `status` is still `creating` — check both.
56
- - `user_has_signed`, `required_signatures`, `is_ready`, `identity_url` on `PendingAction`, and
57
- `stats` on `PendingActionsResponse`.
58
- - **`test/response-shape.test.ts`** — pins every declared response type against the gateway's own
59
- OpenAPI response schemas. The existing contract test only ever checked the REQUEST direction,
60
- which is precisely why this drifted. Verified to fail when a camelCase key is reintroduced.
61
- - **`scripts/build-contract-fixture.mjs`** — regenerates the contract fixture from the live spec.
62
- The old fixture was hand-shaped and captured no responses at all; the test file said "then
63
- regenerate the fixture" without saying how.
64
-
65
- ## 0.2.0 — first published version
66
-
67
- **0.1.0 was never published.** Three of its methods could not work against the live API. They were found
68
- while preparing the package for release, by comparing what the SDK sends against the gateway's own OpenAPI
69
- spec. Nothing in the existing test suite could have caught them: those tests exercise retry, idempotency,
70
- and error mapping against a local mock that accepts any body, and a mock answering 200 to anything will
71
- never tell you the request was wrong.
72
-
73
- ### Fixed — methods that could not work
74
-
75
- - **`transaction.create` sent no `intent`.** It sent a flat `{ type, to, amount, token, chain, memo }` body.
76
- `POST /v1/transaction` requires `identity_id` and `intent`, and accepts none of those six fields — so every
77
- call returned 400. Now takes `{ identityId, intent, contractAddresses?, proofClass?, signerKeyPage?,
78
- signerPublicKey?, idempotencyKey? }`, matching the API, including multi-leg and `contractCall` intents.
79
- - **`governance.create` omitted both required fields.** It sent `{ identity_id, operation_type, payload }`;
80
- the API requires `identity` (the ADI, not a uuid) and `operations` (an **array**, so several changes are
81
- authorized under one quorum). Every call returned 400.
82
- - **`identity.list` called a route that does not exist.** `GET /v1/identities` returns 404 — the gateway has
83
- no plural collection route. **Removed** rather than shipped as a dead method. Track the ids you create.
84
-
85
- ### Fixed — silent no-ops
86
-
87
- - **`identity.create` no longer sends `webhook_url`.** `POST /v1/identity` does not accept it, and Fastify
88
- strips unknown properties, so the option did nothing while appearing to work. Set it via `identity.update()`,
89
- which does accept it. `create` now also supports `signingMode`, `signingProvider`, and `idempotencyKey`.
90
- - **`identity.get` no longer sends an `include` query parameter.** The route takes none; it was ignored.
91
-
92
- ### Added
93
-
94
- - **`identity.retire(id)`** — `DELETE /v1/identity/{id}`, which frees the org's identity quota. Soft delete
95
- inside Certen only: the on-chain ADI, key book, and key page are untouched.
96
- - **`DEFAULT_BASE_URL` is exported**, and the base URL now resolves `options.baseUrl` → `$CERTEN_API_URL` →
97
- `https://gateway.kompendium.co`. The previous default was `https://api.certen.io`, which resolves — to the
98
- Certen marketing site. A client built without an explicit `baseUrl` returned HTML for every call.
99
- - **`test/contract.test.ts`** — validates the request every method produces against a vendored snapshot of
100
- the gateway's OpenAPI spec: path exists, method exists, required fields present, no field the endpoint
101
- would strip. This is the guard that would have caught all of the above. Refresh it with the command at the
102
- bottom of this file when the API changes.
103
- - Publish metadata: `files`, `exports`, `engines`, repository, keywords, `prepack` build, README, LICENSE.
104
-
105
- ### Changed
106
-
107
- - `license` corrected to **MIT**. `package.json` claimed Apache-2.0 while `LICENSE` is MIT.
108
-
109
- ## Also fixed, in the gateway
110
-
111
- Six routes — `/v1/transactions`, `/v1/pending`, `/v1/portfolio`, `/v1/admin/usage`, `/v1/admin/audit-log`,
112
- and `/v1/admin/webhooks/deliveries` — read query parameters but declared no `querystring` schema, so
113
- `@fastify/swagger` emitted no `parameters` and the spec reported that they took none.
114
-
115
- The routes worked. The damage was to everyone reading the spec instead of the source: a client generated
116
- from it had no paging at all, and `/v1/pending` silently lost the `identity` and `category` filters a signer
117
- needs to find its own work. All six now declare their parameters, guarded on both sides —
118
- `test/integration/openapi-snapshot.test.ts` in the gateway, and `test/contract.test.ts` here.
119
-
120
- Refresh this package's contract fixture after an API change, from the gateway root:
121
-
122
- ```bash
123
- REGEN_SDK_CONTRACT=1 npx vitest run test/integration/openapi-snapshot.test.ts
124
- ```
125
-
126
- The fixture is generated from `buildServer()` rather than from the deployed gateway on purpose: the SDK
127
- must be tested against the code it ships beside, not against whatever happens to be live.
1
+ # Changelog — @certen.io/sdk
2
+
3
+ ## 0.3.1 — documentation links that work off GitHub
4
+
5
+ No code changes.
6
+
7
+ The README linked its guides with repository-relative paths (`../../docs/guides/...`). Those resolve
8
+ on GitHub and are **dead on the npm package page**, which renders the README standalone and where
9
+ `docs/` is not part of the tarball. Every guide link a reader followed from npm 404'd. They now point
10
+ at <https://docs.kompendium.co>, which publishes the same guides.
11
+
12
+ Also adds the documentation and API-key links to the top of the README, and corrects a link to the
13
+ policy signer that pointed at a GitHub org that does not exist.
14
+
15
+ ## 0.3.0 — response types now describe what the API actually returns
16
+
17
+ **Breaking, at the type level only. No runtime behavior changed.**
18
+
19
+ Every response interface was camelCase (`intentId`, `signingData.dataToSign`, `adiUrl`,
20
+ `creditBalance`). The API is snake_case, and the resources do `return data` with no transformation —
21
+ so every one of those declared fields was `undefined` at runtime while TypeScript insisted it was a
22
+ `string`. The failure was silent in the worst way: code compiled, ran, and produced `undefined`
23
+ somewhere far from the cause.
24
+
25
+ `execute.*` was never affected. It was written against real responses and reads snake_case directly,
26
+ which is why the one flow that had been exercised end-to-end worked while the typed resources did not.
27
+
28
+ If you were already compensating with `as any` or reading snake_case at runtime, your code was
29
+ correct and keeps working — you can now delete the casts. If you were trusting the types, your code
30
+ was silently broken and will now fail to compile, which is the point.
31
+
32
+ ### Changed — all response types are snake_case
33
+
34
+ `IdentityResponse` · `TransactionResponse` · `GovernanceResponse` · `SignResponse` ·
35
+ `PortfolioResponse` · `PendingActionsResponse` · `OrgResponse` · `ApiKeyResponse` ·
36
+ `ApiKeyListItem` · `AuditLogEntry` · `UsageSummaryResponse` · `ChainAccount` · `ChainBalance` ·
37
+ `PortfolioIdentity` · `PendingAction`.
38
+
39
+ ### Changed — `create` and `get` no longer share a type
40
+
41
+ `POST /v1/transaction` and `GET /v1/transaction/{id}` return different shapes, and one
42
+ `TransactionResponse` covering both hid it. Same for governance.
43
+
44
+ - `transaction.create` → **`CreateTransactionResponse`** (`intent_id`, `signing_data`, `submit_url`, `idempotent`)
45
+ - `transaction.get` → `TransactionResponse` (`accum_tx_hash`, `proof`, timestamps)
46
+ - `transaction.submitSignature` → **`SubmitSignatureResponse`**
47
+ - `transaction.list` → **`ListTransactionsResponse`**. It declared `{ transactions, pagination }`; the endpoint returns `{ transactions, limit, offset }` and has no pagination object.
48
+ - `governance.create` → **`CreateGovernanceResponse`**, `governance.submitSignature` → **`SubmitGovernanceSignatureResponse`**
49
+ - `sign.submitSignature` → **`SubmitSignSignatureResponse`**
50
+ - `identity.retire` → **`DeleteIdentityResponse`**
51
+
52
+ ### Changed — `SigningData` split in two
53
+
54
+ The two endpoints that return signing data carry the bytes under **different names**, and a single
55
+ shared type is what let that go unnoticed:
56
+
57
+ - **`IntentSigningData`** (`POST /v1/transaction`) — the bytes are in **`hash_to_sign`**
58
+ - **`SignRequestSigningData`** (`POST /v1/sign`) — the bytes are in **`data_for_signature`**
59
+
60
+ Both mean the same thing: sign the RAW BYTES of that hex. Do not hash it again; do not sign its
61
+ ASCII. `execute.*` handles the distinction for you.
62
+
63
+ ### Added
64
+
65
+ - `Identity` and `DeleteIdentityResponse` types; `can_sign` and `error_message` on `Identity`.
66
+ `can_sign` derives from the on-chain key page, not the provisioning state machine, so it can read
67
+ `true` while `status` is still `creating` — check both.
68
+ - `user_has_signed`, `required_signatures`, `is_ready`, `identity_url` on `PendingAction`, and
69
+ `stats` on `PendingActionsResponse`.
70
+ - **`test/response-shape.test.ts`** — pins every declared response type against the gateway's own
71
+ OpenAPI response schemas. The existing contract test only ever checked the REQUEST direction,
72
+ which is precisely why this drifted. Verified to fail when a camelCase key is reintroduced.
73
+ - **`scripts/build-contract-fixture.mjs`** — regenerates the contract fixture from the live spec.
74
+ The old fixture was hand-shaped and captured no responses at all; the test file said "then
75
+ regenerate the fixture" without saying how.
76
+
77
+ ## 0.2.0 — first published version
78
+
79
+ **0.1.0 was never published.** Three of its methods could not work against the live API. They were found
80
+ while preparing the package for release, by comparing what the SDK sends against the gateway's own OpenAPI
81
+ spec. Nothing in the existing test suite could have caught them: those tests exercise retry, idempotency,
82
+ and error mapping against a local mock that accepts any body, and a mock answering 200 to anything will
83
+ never tell you the request was wrong.
84
+
85
+ ### Fixed — methods that could not work
86
+
87
+ - **`transaction.create` sent no `intent`.** It sent a flat `{ type, to, amount, token, chain, memo }` body.
88
+ `POST /v1/transaction` requires `identity_id` and `intent`, and accepts none of those six fields — so every
89
+ call returned 400. Now takes `{ identityId, intent, contractAddresses?, proofClass?, signerKeyPage?,
90
+ signerPublicKey?, idempotencyKey? }`, matching the API, including multi-leg and `contractCall` intents.
91
+ - **`governance.create` omitted both required fields.** It sent `{ identity_id, operation_type, payload }`;
92
+ the API requires `identity` (the ADI, not a uuid) and `operations` (an **array**, so several changes are
93
+ authorized under one quorum). Every call returned 400.
94
+ - **`identity.list` called a route that does not exist.** `GET /v1/identities` returns 404 — the gateway has
95
+ no plural collection route. **Removed** rather than shipped as a dead method. Track the ids you create.
96
+
97
+ ### Fixed — silent no-ops
98
+
99
+ - **`identity.create` no longer sends `webhook_url`.** `POST /v1/identity` does not accept it, and Fastify
100
+ strips unknown properties, so the option did nothing while appearing to work. Set it via `identity.update()`,
101
+ which does accept it. `create` now also supports `signingMode`, `signingProvider`, and `idempotencyKey`.
102
+ - **`identity.get` no longer sends an `include` query parameter.** The route takes none; it was ignored.
103
+
104
+ ### Added
105
+
106
+ - **`identity.retire(id)`** — `DELETE /v1/identity/{id}`, which frees the org's identity quota. Soft delete
107
+ inside Certen only: the on-chain ADI, key book, and key page are untouched.
108
+ - **`DEFAULT_BASE_URL` is exported**, and the base URL now resolves `options.baseUrl` → `$CERTEN_API_URL` →
109
+ `https://gateway.kompendium.co`. The previous default was `https://api.certen.io`, which resolves — to the
110
+ Certen marketing site. A client built without an explicit `baseUrl` returned HTML for every call.
111
+ - **`test/contract.test.ts`** — validates the request every method produces against a vendored snapshot of
112
+ the gateway's OpenAPI spec: path exists, method exists, required fields present, no field the endpoint
113
+ would strip. This is the guard that would have caught all of the above. Refresh it with the command at the
114
+ bottom of this file when the API changes.
115
+ - Publish metadata: `files`, `exports`, `engines`, repository, keywords, `prepack` build, README, LICENSE.
116
+
117
+ ### Changed
118
+
119
+ - `license` corrected to **MIT**. `package.json` claimed Apache-2.0 while `LICENSE` is MIT.
120
+
121
+ ## Also fixed, in the gateway
122
+
123
+ Six routes — `/v1/transactions`, `/v1/pending`, `/v1/portfolio`, `/v1/admin/usage`, `/v1/admin/audit-log`,
124
+ and `/v1/admin/webhooks/deliveries` — read query parameters but declared no `querystring` schema, so
125
+ `@fastify/swagger` emitted no `parameters` and the spec reported that they took none.
126
+
127
+ The routes worked. The damage was to everyone reading the spec instead of the source: a client generated
128
+ from it had no paging at all, and `/v1/pending` silently lost the `identity` and `category` filters a signer
129
+ needs to find its own work. All six now declare their parameters, guarded on both sides —
130
+ `test/integration/openapi-snapshot.test.ts` in the gateway, and `test/contract.test.ts` here.
131
+
132
+ Refresh this package's contract fixture after an API change, from the gateway root:
133
+
134
+ ```bash
135
+ REGEN_SDK_CONTRACT=1 npx vitest run test/integration/openapi-snapshot.test.ts
136
+ ```
137
+
138
+ The fixture is generated from `buildServer()` rather than from the deployed gateway on purpose: the SDK
139
+ must be tested against the code it ships beside, not against whatever happens to be live.
package/README.md CHANGED
@@ -1,117 +1,119 @@
1
- # @certen.io/sdk
2
-
3
- TypeScript client for the [CERTEN Gateway](https://gateway.kompendium.co/reference) — proof-gated
4
- cross-chain execution on Accumulate.
5
-
6
- ```bash
7
- npm install @certen.io/sdk
8
- ```
9
-
10
- ```ts
11
- import { CertenClient } from '@certen.io/sdk';
12
-
13
- const certen = new CertenClient({ apiKey: process.env.CERTEN_API_KEY! });
14
-
15
- const { intent_id, signing_data, submit_url } = await certen.transaction.create({
16
- identity_id: identityId,
17
- intent: {
18
- fromChain: 'accumulate',
19
- toChain: 'ethereum-sepolia',
20
- fromAddress: 'acc://your-org.acme',
21
- toAddress: '0xBe00…9251',
22
- amount: '4000',
23
- tokenSymbol: 'ETH',
24
- },
25
- });
26
-
27
- // You hold the key. Sign the bytes the gateway hands you.
28
- const signature = sign(signing_data.hash_to_sign);
29
- await certen.transaction.submitSignature(intent_id, { signature, public_key: publicKey });
30
- ```
31
-
32
- **Your key never leaves your process.** The gateway computes what must be signed and you decide whether to
33
- sign it. That is the supported posture for anything carrying value — see
34
- [the external-signing guide](../../docs/guides/external-signing.md).
35
-
36
- ---
37
-
38
- ## Configuration
39
-
40
- ```ts
41
- new CertenClient({
42
- apiKey: 'ck_live_…', // required
43
- baseUrl: 'https://…', // optional — see precedence below
44
- maxRetries: 3, // default 3
45
- baseBackoffMs: 250,
46
- maxBackoffMs: 8_000,
47
- autoIdempotencyKey: true, // default: every POST gets one
48
- });
49
- ```
50
-
51
- **Base URL precedence:** `options.baseUrl` → `$CERTEN_API_URL` → `https://gateway.kompendium.co`. The env var
52
- is there so a deployment can be retargeted at staging or a self-hosted gateway without a code change.
53
-
54
- ## What it does for you
55
-
56
- **Automatic idempotency on POSTs.** Every POST gets a generated `Idempotency-Key` so a retried network error
57
- is safe to replay. This matters more than it sounds: without one, a timeout is indistinguishable from success,
58
- and a blind retry can open a second intent or burn identity quota. Opt out per-client with
59
- `autoIdempotencyKey: false`, or per-route with `noAutoIdempotencyRoutes`.
60
-
61
- **Retries with backoff, and rate-limit awareness.** Transient failures retry with exponential backoff. On a
62
- `429` the client remembers the reset window and pre-emptively waits rather than hammering.
63
-
64
- **Typed errors.** Catch the class you care about instead of matching on status codes:
65
-
66
- ```ts
67
- import { CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError } from '@certen.io/sdk';
68
-
69
- try {
70
- await certen.identity.create({ … });
71
- } catch (e) {
72
- if (e instanceof CertenBadRequestError) { /* your request — fix and retry */ }
73
- if (e instanceof CertenRateLimitError) { /* back off; e carries the reset */ }
74
- if (e instanceof CertenAuthError) { /* key is wrong, revoked, or lacks the scope */ }
75
- if (e instanceof CertenServerError) { /* gateway or downstream — safe to retry */ }
76
- }
77
- ```
78
-
79
- **Pagination helpers.** `paginate` and `paginateWithTotal` iterate a paged endpoint as an async generator.
80
-
81
- ## Resources
82
-
83
- | | |
84
- |---|---|
85
- | `certen.identity` | `create` · `get` · `update` · `retire` |
86
- | `certen.transaction` | `create` · `submitSignature` · `get` · `list` |
87
- | `certen.sign` | `create` · `submitSignature` |
88
- | `certen.governance` | `create` · `submitSignature` · `get` |
89
- | `certen.pending` | `list` |
90
- | `certen.portfolio` | `get` |
91
- | `certen.admin` | `createOrg` · `createApiKey` · `listApiKeys` · `revokeApiKey` · `rotateApiKey` · `getAuditLog` · `getUsage` |
92
-
93
- The gateway serves ~80 endpoints; this covers the integration surface. For anything else, the
94
- [live spec](https://gateway.kompendium.co/docs/json) is authoritative and the client's `request` path will
95
- carry it.
96
-
97
- ## Three things to know
98
-
99
- **Identity creation is asynchronous.** `identity.create` resolves with a `202`-shaped result and provisioning
100
- continues. Poll `identity.get` until the status is terminal, and check `can_sign` before building on it.
101
-
102
- **A proof cycle takes ~60–110 seconds.** Real validator work, not a tunable delay. Do not wrap it in a 30s
103
- timeout.
104
-
105
- **`vote` is `approve` | `reject` | `abstain`** — a lowercase string, not a number, and not `accept`.
106
-
107
- ## Guides
108
-
109
- - [Onboard an identity](../../docs/guides/onboard-an-identity.md)
110
- - [Sign while holding your own key](../../docs/guides/external-signing.md)
111
- - [Proof-gate a contract call](../../docs/guides/proof-gated-contract-call.md)
112
- - [M-of-N panels](../../docs/guides/multisig-panel.md)
113
- - [Verify a proof](../../docs/guides/verify-a-proof.md)
114
-
115
- ## License
116
-
117
- MIT
1
+ # @certen.io/sdk
2
+
3
+ TypeScript client for the [CERTEN Gateway](https://gateway.kompendium.co/reference) — proof-gated
4
+ cross-chain execution on Accumulate.
5
+
6
+ **Docs: <https://docs.kompendium.co>** · **Get an API key: <https://gateway.kompendium.co/portal>**
7
+
8
+ ```bash
9
+ npm install @certen.io/sdk
10
+ ```
11
+
12
+ ```ts
13
+ import { CertenClient } from '@certen.io/sdk';
14
+
15
+ const certen = new CertenClient({ apiKey: process.env.CERTEN_API_KEY! });
16
+
17
+ const { intent_id, signing_data, submit_url } = await certen.transaction.create({
18
+ identity_id: identityId,
19
+ intent: {
20
+ fromChain: 'accumulate',
21
+ toChain: 'ethereum-sepolia',
22
+ fromAddress: 'acc://your-org.acme',
23
+ toAddress: '0xBe00…9251',
24
+ amount: '4000',
25
+ tokenSymbol: 'ETH',
26
+ },
27
+ });
28
+
29
+ // You hold the key. Sign the bytes the gateway hands you.
30
+ const signature = sign(signing_data.hash_to_sign);
31
+ await certen.transaction.submitSignature(intent_id, { signature, public_key: publicKey });
32
+ ```
33
+
34
+ **Your key never leaves your process.** The gateway computes what must be signed and you decide whether to
35
+ sign it. That is the supported posture for anything carrying value — see
36
+ [the external-signing guide](https://docs.kompendium.co/external-signing.html).
37
+
38
+ ---
39
+
40
+ ## Configuration
41
+
42
+ ```ts
43
+ new CertenClient({
44
+ apiKey: 'ck_live_…', // required
45
+ baseUrl: 'https://…', // optional — see precedence below
46
+ maxRetries: 3, // default 3
47
+ baseBackoffMs: 250,
48
+ maxBackoffMs: 8_000,
49
+ autoIdempotencyKey: true, // default: every POST gets one
50
+ });
51
+ ```
52
+
53
+ **Base URL precedence:** `options.baseUrl` → `$CERTEN_API_URL` → `https://gateway.kompendium.co`. The env var
54
+ is there so a deployment can be retargeted at staging or a self-hosted gateway without a code change.
55
+
56
+ ## What it does for you
57
+
58
+ **Automatic idempotency on POSTs.** Every POST gets a generated `Idempotency-Key` so a retried network error
59
+ is safe to replay. This matters more than it sounds: without one, a timeout is indistinguishable from success,
60
+ and a blind retry can open a second intent or burn identity quota. Opt out per-client with
61
+ `autoIdempotencyKey: false`, or per-route with `noAutoIdempotencyRoutes`.
62
+
63
+ **Retries with backoff, and rate-limit awareness.** Transient failures retry with exponential backoff. On a
64
+ `429` the client remembers the reset window and pre-emptively waits rather than hammering.
65
+
66
+ **Typed errors.** Catch the class you care about instead of matching on status codes:
67
+
68
+ ```ts
69
+ import { CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError } from '@certen.io/sdk';
70
+
71
+ try {
72
+ await certen.identity.create({ … });
73
+ } catch (e) {
74
+ if (e instanceof CertenBadRequestError) { /* your request — fix and retry */ }
75
+ if (e instanceof CertenRateLimitError) { /* back off; e carries the reset */ }
76
+ if (e instanceof CertenAuthError) { /* key is wrong, revoked, or lacks the scope */ }
77
+ if (e instanceof CertenServerError) { /* gateway or downstream — safe to retry */ }
78
+ }
79
+ ```
80
+
81
+ **Pagination helpers.** `paginate` and `paginateWithTotal` iterate a paged endpoint as an async generator.
82
+
83
+ ## Resources
84
+
85
+ | | |
86
+ |---|---|
87
+ | `certen.identity` | `create` · `get` · `update` · `retire` |
88
+ | `certen.transaction` | `create` · `submitSignature` · `get` · `list` |
89
+ | `certen.sign` | `create` · `submitSignature` |
90
+ | `certen.governance` | `create` · `submitSignature` · `get` |
91
+ | `certen.pending` | `list` |
92
+ | `certen.portfolio` | `get` |
93
+ | `certen.admin` | `createOrg` · `createApiKey` · `listApiKeys` · `revokeApiKey` · `rotateApiKey` · `getAuditLog` · `getUsage` |
94
+
95
+ The gateway serves ~80 endpoints; this covers the integration surface. For anything else, the
96
+ [live spec](https://gateway.kompendium.co/docs/json) is authoritative and the client's `request` path will
97
+ carry it.
98
+
99
+ ## Three things to know
100
+
101
+ **Identity creation is asynchronous.** `identity.create` resolves with a `202`-shaped result and provisioning
102
+ continues. Poll `identity.get` until the status is terminal, and check `can_sign` before building on it.
103
+
104
+ **A proof cycle takes ~60–110 seconds.** Real validator work, not a tunable delay. Do not wrap it in a 30s
105
+ timeout.
106
+
107
+ **`vote` is `approve` | `reject` | `abstain`** — a lowercase string, not a number, and not `accept`.
108
+
109
+ ## Guides
110
+
111
+ - [Onboard an identity](https://docs.kompendium.co/onboard-an-identity.html)
112
+ - [Sign while holding your own key](https://docs.kompendium.co/external-signing.html)
113
+ - [Proof-gate a contract call](https://docs.kompendium.co/proof-gated-contract-call.html)
114
+ - [M-of-N panels](https://docs.kompendium.co/multisig-panel.html)
115
+ - [Verify a proof](https://docs.kompendium.co/verify-a-proof.html)
116
+
117
+ ## License
118
+
119
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certen.io/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "TypeScript client for the CERTEN Gateway API \u2014 proof-gated cross-chain execution on Accumulate",
5
5
  "license": "MIT",
6
6
  "type": "module",