@witnium/witniumchain 0.28.2 → 0.30.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.
- package/README.md +30 -7
- package/dist/index.d.mts +9388 -4582
- package/dist/index.d.ts +9388 -4582
- package/dist/index.js +48 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ where each call belongs.
|
|
|
11
11
|
|
|
12
12
|
**v0.5 — adds OAuth 2.1 + PKCE login helpers** on top of the v0.4 surface:
|
|
13
13
|
|
|
14
|
-
-
|
|
14
|
+
- The accounts routes (five auth modes: session / OAuth / org / admin / signed)
|
|
15
15
|
- 9 chain-api read methods, routed to `chainBaseUrl`, reusing the same OAuth
|
|
16
16
|
`accessToken` (accounts mints tokens with `aud=https://api.witniumchain.com`,
|
|
17
17
|
so they're valid against both services unchanged)
|
|
@@ -63,14 +63,14 @@ throw at call time.
|
|
|
63
63
|
|
|
64
64
|
| Credential | Header / Cookie | Used by |
|
|
65
65
|
|---|---|---|
|
|
66
|
-
| `sessionCookie` | `Cookie: wac_session=…` | `/v1/auth/logout`, `/v1/account/*`, `/v1/
|
|
66
|
+
| `sessionCookie` | `Cookie: wac_session=…` | `/v1/auth/logout`, `/v1/account/*`, `/v1/orgs/me*`, `/v1/keys/*`, `/v1/contracts/{pause,unpause}`, `/v1/oauth/sessions*` |
|
|
67
67
|
| `accessToken` | `Authorization: Bearer <JWT>` | `/v1/users/me/delegated-keys/*`, `/v1/sign`, **all chain-api reads** |
|
|
68
|
-
| `apiKey` | `Authorization: Bearer wcak_…` | `/v1/sign`, `/v1/api-key`, v5 witness `propose`/`sign`/`finalize` (via `WitniumchainApiKeyClient`) |
|
|
68
|
+
| `apiKey` | `Authorization: Bearer wcak_live_…` / `wcak_sandbox_…` (or a pre-sandbox `wcak_…`) | `/v1/sign`, `/v1/api-key`, v5 witness `propose`/`sign`/`finalize` (via `WitniumchainApiKeyClient`) |
|
|
69
69
|
| `adminToken` | `Authorization: Bearer <ADMIN_TOKEN>` | `/v1/admin/*` |
|
|
70
70
|
| `signedRequest` | `X-Witnium-Key/Timestamp/Signature` | `/v1/contracts/{addr}/witnesses/{propose,sign,finalize,revoke}` |
|
|
71
71
|
|
|
72
72
|
**Session or token.** The accounts routes an OAuth client such as the
|
|
73
|
-
WitniumChain dashboard calls (`me`, the ledger,
|
|
73
|
+
WitniumChain dashboard calls (`me`, the ledger,
|
|
74
74
|
the dashboard key, signing-key requests, contract pause and resume, the
|
|
75
75
|
org's owner operations, self-custody setup and keys) take either credential.
|
|
76
76
|
A client holding an OAuth `accessToken` sends it as `Authorization: Bearer`
|
|
@@ -100,8 +100,8 @@ const client = new WitniumchainClient({
|
|
|
100
100
|
await client.proposeWitnessV5('0xabc', { ... });
|
|
101
101
|
|
|
102
102
|
// Reads of on-chain state → chain-api (chainBaseUrl)
|
|
103
|
-
const witness = await client.getWitnessV5('0xabc', witnessId);
|
|
104
|
-
const
|
|
103
|
+
const witness = await client.getWitnessV5('0xabc', witnessId); // public
|
|
104
|
+
const page = await client.listWitnessesV5('0xabc'); // the registry owner's (accessToken)
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
If you call a chain-api method without `chainBaseUrl` configured, the SDK
|
|
@@ -139,8 +139,9 @@ import { WitniumchainApiKeyClient } from '@witnium/witniumchain';
|
|
|
139
139
|
|
|
140
140
|
const server = new WitniumchainApiKeyClient({
|
|
141
141
|
baseUrl: 'https://auth.witniumchain.com',
|
|
142
|
-
apiKey: process.env.WITNIUM_API_KEY!, //
|
|
142
|
+
apiKey: process.env.WITNIUM_API_KEY!, // wcak_live_… or wcak_sandbox_…
|
|
143
143
|
});
|
|
144
|
+
server.environment; // 'live' or 'sandbox', from the key's prefix
|
|
144
145
|
|
|
145
146
|
const me = await server.me(); // its contract and signing key
|
|
146
147
|
const proposed = await server.proposeWitnessV5(me.contractAddress, {
|
|
@@ -156,6 +157,28 @@ if (proposed.outcome === 'created') {
|
|
|
156
157
|
}
|
|
157
158
|
```
|
|
158
159
|
|
|
160
|
+
#### Key formats: live and sandbox
|
|
161
|
+
|
|
162
|
+
| Format | Environment |
|
|
163
|
+
|---|---|
|
|
164
|
+
| `wcak_live_` + 64 lowercase hex | Live: witnesses are evidence, anchored on Ethereum mainnet. |
|
|
165
|
+
| `wcak_sandbox_` + 64 lowercase hex | Sandbox: free, rate-limited, anchored on Sepolia. Not evidence. Witness records expire after 90 days (reads then answer `410`); packs you already downloaded keep verifying as sandbox evidence. |
|
|
166
|
+
| `wcak_` + 64 lowercase hex | A live key issued before the sandbox. Works until accounts' announced cutoff; rotate it to a `wcak_live_` key. |
|
|
167
|
+
|
|
168
|
+
Both clients refuse any other format at construction. The base URL is the
|
|
169
|
+
same for both environments: accounts routes each request by its own record
|
|
170
|
+
of the key, and refuses a key whose prefix doesn't match that record. The
|
|
171
|
+
SDK reads the prefix only so you can check and log which environment you
|
|
172
|
+
are in (`client.environment`, `client.legacyKeyFormat`, or
|
|
173
|
+
`parseApiKey(key)`).
|
|
174
|
+
|
|
175
|
+
An API key is only ever sent to accounts. Chain-api reads (`chainBaseUrl`)
|
|
176
|
+
use an OAuth access token or are public, and the token's audience decides
|
|
177
|
+
which environment's chain-api accepts it.
|
|
178
|
+
|
|
179
|
+
The sandbox is not open yet. Until it is, accounts issues only live
|
|
180
|
+
keys.
|
|
181
|
+
|
|
159
182
|
### Witness scopes
|
|
160
183
|
|
|
161
184
|
A v5 propose runs in a **witness scope**: a scope holds at most one witness
|