@witnium/witniumchain 0.27.0 → 0.28.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.
- package/README.md +29 -3
- package/dist/index.d.mts +1912 -465
- package/dist/index.d.ts +1912 -465
- package/dist/index.js +83 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,17 @@ throw at call time.
|
|
|
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
|
+
**Session or token.** The accounts routes an OAuth client such as the
|
|
73
|
+
WitniumChain dashboard calls (`me`, the ledger, billing checkout and portal,
|
|
74
|
+
the dashboard key, signing-key requests, contract pause and resume, the
|
|
75
|
+
org's owner operations, self-custody setup and keys) take either credential.
|
|
76
|
+
A client holding an OAuth `accessToken` sends it as `Authorization: Bearer`
|
|
77
|
+
with `credentials: 'omit'`, so no cookie is needed or sent; a client without
|
|
78
|
+
one (the account app) keeps its `wac_session` cookie, also when it has
|
|
79
|
+
minted a token from that session. Listing the team takes either too
|
|
80
|
+
(read-only); changes to the team or the org, API keys, OAuth sessions and
|
|
81
|
+
account security stay cookie-only.
|
|
82
|
+
|
|
72
83
|
Public routes need no credential (`/v1/auth/{signup,verify,login,…}`,
|
|
73
84
|
`/v1/contracts/provision`, `GET /v1/contracts/{addr}/witnesses/{id}`,
|
|
74
85
|
`/health/*`).
|
|
@@ -189,9 +200,11 @@ try {
|
|
|
189
200
|
```
|
|
190
201
|
|
|
191
202
|
Without a `scope`, the SDK generates 32 random bytes before the request
|
|
192
|
-
(`randomWitnessScope()`)
|
|
193
|
-
`
|
|
194
|
-
|
|
203
|
+
(`randomWitnessScope()`) and returns them as `scope` in the result and in
|
|
204
|
+
every `WitnessProposeError`. The SDK does not retry a failed propose for you
|
|
205
|
+
(its only resend is after a token refresh, with the same scope): to retry,
|
|
206
|
+
call `proposeWitnessV5` again with `err.scope`. Store the scope before you
|
|
207
|
+
rely on a retry: it is what makes the retry safe.
|
|
195
208
|
|
|
196
209
|
The details of a repeat must match: the same scope and `dataId` with another
|
|
197
210
|
`userTimestamp`, `revealAfter` or `drandRound` is a 409
|
|
@@ -275,8 +288,21 @@ const { keys } = await client.listDelegatedKeys();
|
|
|
275
288
|
|
|
276
289
|
// 4. Sign-out clears in-memory tokens.
|
|
277
290
|
client.signOut();
|
|
291
|
+
|
|
292
|
+
// Or end the session at the issuer too (RP-initiated logout). Needs the ID
|
|
293
|
+
// token from step 2, so ask for the `openid` scope.
|
|
294
|
+
const { logoutUrl } = await client.beginOAuthLogout({
|
|
295
|
+
postLogoutRedirectUri: 'https://your-app.example/signed-out',
|
|
296
|
+
});
|
|
297
|
+
window.location.assign(logoutUrl);
|
|
278
298
|
```
|
|
279
299
|
|
|
300
|
+
Step-up before a sensitive action: `beginOAuthLogin({ redirectUri, maxAge: 0 })`
|
|
301
|
+
makes the issuer re-authenticate the user; the new tokens carry a fresh
|
|
302
|
+
`auth_time`. `prompt: 'none'` asks for a token without any UI (renewal from
|
|
303
|
+
the issuer's session) and comes back with `error=login_required` when the
|
|
304
|
+
user has to sign in.
|
|
305
|
+
|
|
280
306
|
### OAuth API — delegated-key + sign
|
|
281
307
|
|
|
282
308
|
```ts
|