@witnium-tech/witniumchain 0.2.0 → 0.3.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 +12 -12
- package/README.md.bak +160 -0
- package/dist/index.d.mts +27 -27
- package/dist/index.d.ts +27 -27
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,11 +10,11 @@ management.
|
|
|
10
10
|
auth modes selectable on a single client. Thread 4 of Phase C will layer
|
|
11
11
|
three higher-level clients on top:
|
|
12
12
|
|
|
13
|
-
- `
|
|
13
|
+
- `WitniumchainClient` (end-user) — wraps signup, login, subscriptions,
|
|
14
14
|
delegated-key one-call provisioning, account management.
|
|
15
|
-
- `
|
|
15
|
+
- `WitniumchainOrgClient` (org admin) — wraps user provisioning, Stripe
|
|
16
16
|
Connect onboarding.
|
|
17
|
-
- `
|
|
17
|
+
- `WitniumchainAdminClient` (sysadmin) — wraps org lifecycle, key
|
|
18
18
|
rotation, credit adjustment.
|
|
19
19
|
|
|
20
20
|
For now, this shell client is what's published. Every type comes from the
|
|
@@ -50,9 +50,9 @@ Public routes need no credential (`/v1/auth/{signup,verify,login,…}`,
|
|
|
50
50
|
### End-user signup + login
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
import {
|
|
53
|
+
import { WitniumchainClient } from '@witnium-tech/witniumchain';
|
|
54
54
|
|
|
55
|
-
const client = new
|
|
55
|
+
const client = new WitniumchainClient({
|
|
56
56
|
baseUrl: 'https://auth.witniumchain.com',
|
|
57
57
|
});
|
|
58
58
|
|
|
@@ -68,7 +68,7 @@ await client.login({ email: 'alice@example.com', password: '…' });
|
|
|
68
68
|
### Org admin — create a user
|
|
69
69
|
|
|
70
70
|
```ts
|
|
71
|
-
const org = new
|
|
71
|
+
const org = new WitniumchainClient({
|
|
72
72
|
baseUrl: 'https://auth.witniumchain.com',
|
|
73
73
|
orgApiKey: 'wcorg_live_…',
|
|
74
74
|
});
|
|
@@ -83,7 +83,7 @@ const { userId, provisioningToken } = await org.createOrgUser({
|
|
|
83
83
|
### Sysadmin — create an organisation
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
const sys = new
|
|
86
|
+
const sys = new WitniumchainClient({
|
|
87
87
|
baseUrl: 'https://auth.witniumchain.com',
|
|
88
88
|
adminToken: process.env.ACCOUNTS_ADMIN_TOKEN!,
|
|
89
89
|
});
|
|
@@ -100,7 +100,7 @@ const { organization, apiKey } = await sys.createOrganization({
|
|
|
100
100
|
### OAuth API — delegated-key + sign
|
|
101
101
|
|
|
102
102
|
```ts
|
|
103
|
-
const api = new
|
|
103
|
+
const api = new WitniumchainClient({
|
|
104
104
|
baseUrl: 'https://auth.witniumchain.com',
|
|
105
105
|
accessToken: bearerJwt,
|
|
106
106
|
});
|
|
@@ -120,7 +120,7 @@ const { signature } = await api.sign(
|
|
|
120
120
|
### SDK signed-request (witness propose/sign/finalize)
|
|
121
121
|
|
|
122
122
|
```ts
|
|
123
|
-
const sdk = new
|
|
123
|
+
const sdk = new WitniumchainClient({
|
|
124
124
|
baseUrl: 'https://auth.witniumchain.com',
|
|
125
125
|
signedRequest: {
|
|
126
126
|
publicKeyHex: 'abcd…64-chars…',
|
|
@@ -140,15 +140,15 @@ const intent = await sdk.proposeWitness('0x…', {
|
|
|
140
140
|
|
|
141
141
|
## Errors
|
|
142
142
|
|
|
143
|
-
All non-2xx responses surface as `
|
|
143
|
+
All non-2xx responses surface as `WitniumchainApiError`:
|
|
144
144
|
|
|
145
145
|
```ts
|
|
146
|
-
import {
|
|
146
|
+
import { WitniumchainApiError } from '@witnium-tech/witniumchain';
|
|
147
147
|
|
|
148
148
|
try {
|
|
149
149
|
await client.createOrgUser({ email: 'taken@example.com' });
|
|
150
150
|
} catch (err) {
|
|
151
|
-
if (err instanceof
|
|
151
|
+
if (err instanceof WitniumchainApiError) {
|
|
152
152
|
console.error(err.status, err.errorLabel, err.message);
|
|
153
153
|
// err.body holds the raw parsed body for advanced inspection.
|
|
154
154
|
}
|
package/README.md.bak
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# @witnium-tech/witniumchain
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the WitniumChain accounts service — identity, billing,
|
|
4
|
+
organisation administration, OAuth sessions, and delegated-signing-key
|
|
5
|
+
management.
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
**v0.1 — low-level "shell" client.** One method per OpenAPI route, five
|
|
10
|
+
auth modes selectable on a single client. Thread 4 of Phase C will layer
|
|
11
|
+
three higher-level clients on top:
|
|
12
|
+
|
|
13
|
+
- `WitniumAccountsClient` (end-user) — wraps signup, login, subscriptions,
|
|
14
|
+
delegated-key one-call provisioning, account management.
|
|
15
|
+
- `WitniumAccountsOrgClient` (org admin) — wraps user provisioning, Stripe
|
|
16
|
+
Connect onboarding.
|
|
17
|
+
- `WitniumAccountsAdminClient` (sysadmin) — wraps org lifecycle, key
|
|
18
|
+
rotation, credit adjustment.
|
|
19
|
+
|
|
20
|
+
For now, this shell client is what's published. Every type comes from the
|
|
21
|
+
OpenAPI spec via `openapi-typescript`; a CI drift test in the parent repo
|
|
22
|
+
gates regeneration on every change.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @witnium-tech/witniumchain
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Auth model
|
|
31
|
+
|
|
32
|
+
The accounts service accepts five distinct credentials. Configure whichever
|
|
33
|
+
you need on the client; methods that require a credential you didn't supply
|
|
34
|
+
throw at call time.
|
|
35
|
+
|
|
36
|
+
| Credential | Header / Cookie | Used by |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `sessionCookie` | `Cookie: wac_session=…` | `/v1/auth/logout`, `/v1/account/*`, `/v1/billing/*`, `/v1/keys/*`, `/v1/contracts/{pause,unpause}`, `/v1/oauth/sessions*` |
|
|
39
|
+
| `accessToken` | `Authorization: Bearer <JWT>` | `/v1/users/me/delegated-keys/*`, `/v1/sign` |
|
|
40
|
+
| `orgApiKey` | `Authorization: Bearer wcorg_live_…` | `/v1/orgs/me/*` |
|
|
41
|
+
| `adminToken` | `Authorization: Bearer <ADMIN_TOKEN>` | `/v1/admin/*` |
|
|
42
|
+
| `signedRequest` | `X-Witnium-Key/Timestamp/Signature` | `/v1/contracts/{addr}/witnesses/{propose,sign,finalize,revoke}` |
|
|
43
|
+
|
|
44
|
+
Public routes need no credential (`/v1/auth/{signup,verify,login,…}`,
|
|
45
|
+
`/v1/contracts/provision`, `GET /v1/contracts/{addr}/witnesses/{id}`,
|
|
46
|
+
`/health/*`).
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
### End-user signup + login
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { WitniumAccountsClient } from '@witnium-tech/witniumchain';
|
|
54
|
+
|
|
55
|
+
const client = new WitniumAccountsClient({
|
|
56
|
+
baseUrl: 'https://auth.witniumchain.com',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await client.signup({ email: 'alice@example.com', password: 'correct horse battery staple' });
|
|
60
|
+
// User clicks email link, lands on /verify?token=…
|
|
61
|
+
const { provisioningToken } = await client.verifyEmail('the-token-from-the-link');
|
|
62
|
+
|
|
63
|
+
// Then login (sets the wac_session cookie in a browser; in Node, capture
|
|
64
|
+
// from response headers and pass back via `sessionCookie`).
|
|
65
|
+
await client.login({ email: 'alice@example.com', password: '…' });
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Org admin — create a user
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const org = new WitniumAccountsClient({
|
|
72
|
+
baseUrl: 'https://auth.witniumchain.com',
|
|
73
|
+
orgApiKey: 'wcorg_live_…',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const { userId, provisioningToken } = await org.createOrgUser({
|
|
77
|
+
email: 'bob@customer.example.com',
|
|
78
|
+
});
|
|
79
|
+
// Forward `provisioningToken` to Bob — he calls /v1/contracts/provision
|
|
80
|
+
// with locally-generated owner + signing keypairs.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Sysadmin — create an organisation
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const sys = new WitniumAccountsClient({
|
|
87
|
+
baseUrl: 'https://auth.witniumchain.com',
|
|
88
|
+
adminToken: process.env.ACCOUNTS_ADMIN_TOKEN!,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const { organization, apiKey } = await sys.createOrganization({
|
|
92
|
+
name: 'Acme Inc.',
|
|
93
|
+
email: 'ops@acme.example.com',
|
|
94
|
+
accountType: 'metered',
|
|
95
|
+
signupGrantAmount: 100,
|
|
96
|
+
});
|
|
97
|
+
// `apiKey` is shown ONCE — store it now.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### OAuth API — delegated-key + sign
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const api = new WitniumAccountsClient({
|
|
104
|
+
baseUrl: 'https://auth.witniumchain.com',
|
|
105
|
+
accessToken: bearerJwt,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const prepared = await api.prepareDelegatedKey({ contractAddress: '0x…' });
|
|
109
|
+
// Sign prepared.messageToSign with your owner key locally:
|
|
110
|
+
const ownerSignature = await myOwnerSigner.sign(prepared.messageToSign);
|
|
111
|
+
|
|
112
|
+
const submitted = await api.submitDelegatedKey(prepared.id, { ownerSignature });
|
|
113
|
+
// submitted.confirmed === true once the addSigningKey tx mines (~10–15 s).
|
|
114
|
+
|
|
115
|
+
const { signature } = await api.sign(
|
|
116
|
+
{ delegatedKeyId: prepared.id, payload: 'deadbeef…' },
|
|
117
|
+
);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### SDK signed-request (witness propose/sign/finalize)
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const sdk = new WitniumAccountsClient({
|
|
124
|
+
baseUrl: 'https://auth.witniumchain.com',
|
|
125
|
+
signedRequest: {
|
|
126
|
+
publicKeyHex: 'abcd…64-chars…',
|
|
127
|
+
sign: async (canonicalMessage) => {
|
|
128
|
+
// Sign with your Ed25519 key — e.g. via @noble/ed25519 or a KMS.
|
|
129
|
+
// Return the 128-char hex signature.
|
|
130
|
+
return await myEd25519Sign(canonicalMessage);
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const intent = await sdk.proposeWitness('0x…', {
|
|
136
|
+
dataId: '…64-hex…',
|
|
137
|
+
requiredSigners: ['…signer-pubkey…'],
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Errors
|
|
142
|
+
|
|
143
|
+
All non-2xx responses surface as `WitniumAccountsApiError`:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { WitniumAccountsApiError } from '@witnium-tech/witniumchain';
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
await client.createOrgUser({ email: 'taken@example.com' });
|
|
150
|
+
} catch (err) {
|
|
151
|
+
if (err instanceof WitniumAccountsApiError) {
|
|
152
|
+
console.error(err.status, err.errorLabel, err.message);
|
|
153
|
+
// err.body holds the raw parsed body for advanced inspection.
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT.
|
package/dist/index.d.mts
CHANGED
|
@@ -5306,12 +5306,12 @@ type HealthLiveResponse = Res<'/health/live', 'get'>;
|
|
|
5306
5306
|
type HealthReadyResponse = Res<'/health/ready', 'get'>;
|
|
5307
5307
|
|
|
5308
5308
|
/**
|
|
5309
|
-
*
|
|
5309
|
+
* WitniumchainClient — typed HTTP client for the WitniumChain accounts API.
|
|
5310
5310
|
*
|
|
5311
5311
|
* This is the v1 "shell" client: one low-level method per OpenAPI route.
|
|
5312
5312
|
* Thread 4 (per docs/PLAN-PHASE-C-HARDEN-SURFACES.md) will layer three
|
|
5313
|
-
* higher-level clients on top — `
|
|
5314
|
-
* `
|
|
5313
|
+
* higher-level clients on top — `WitniumchainClient` (end-user),
|
|
5314
|
+
* `WitniumchainOrgClient` (org admin), `WitniumchainAdminClient`
|
|
5315
5315
|
* (sysadmin) — with ergonomic helpers for signup, subscriptions,
|
|
5316
5316
|
* delegated-key provisioning, Stripe Connect onboarding, etc.
|
|
5317
5317
|
*
|
|
@@ -5347,7 +5347,7 @@ interface SignedRequestSigner {
|
|
|
5347
5347
|
sign: (canonicalMessage: string) => Promise<string>;
|
|
5348
5348
|
}
|
|
5349
5349
|
/**
|
|
5350
|
-
* Owner-Ed25519 signer used by {@link
|
|
5350
|
+
* Owner-Ed25519 signer used by {@link WitniumchainClient.delegatedKeys.provision}.
|
|
5351
5351
|
*
|
|
5352
5352
|
* Structurally identical to {@link SignedRequestSigner} — both are
|
|
5353
5353
|
* `{ publicKeyHex, sign(message) }` — but kept as a distinct type so the
|
|
@@ -5402,7 +5402,7 @@ interface ProvisionDelegatedKeyResult {
|
|
|
5402
5402
|
/** Block number, populated once `confirmed === true`. */
|
|
5403
5403
|
blockNumber?: number;
|
|
5404
5404
|
}
|
|
5405
|
-
interface
|
|
5405
|
+
interface WitniumchainClientConfig {
|
|
5406
5406
|
/** Base URL, e.g. `https://auth.witniumchain.com`. Trailing slash optional. */
|
|
5407
5407
|
baseUrl: string;
|
|
5408
5408
|
/** Session cookie value (the `wac_session` cookie's body, not the full header). */
|
|
@@ -5420,7 +5420,7 @@ interface WitniumAccountsClientConfig {
|
|
|
5420
5420
|
/** Alternate fetch implementation (e.g. for tests). Default `globalThis.fetch`. */
|
|
5421
5421
|
fetch?: typeof fetch;
|
|
5422
5422
|
}
|
|
5423
|
-
declare class
|
|
5423
|
+
declare class WitniumchainClient {
|
|
5424
5424
|
private readonly baseUrl;
|
|
5425
5425
|
private readonly cfg;
|
|
5426
5426
|
private readonly timeout;
|
|
@@ -5433,7 +5433,7 @@ declare class WitniumAccountsClient {
|
|
|
5433
5433
|
readonly keys: SigningKeys;
|
|
5434
5434
|
/** OAuth session management. Accessed as `client.oauth.sessions.*`. */
|
|
5435
5435
|
readonly oauth: OauthNamespace;
|
|
5436
|
-
constructor(config:
|
|
5436
|
+
constructor(config: WitniumchainClientConfig);
|
|
5437
5437
|
/**
|
|
5438
5438
|
* Convenience alias for {@link getAccount} — returns the authenticated
|
|
5439
5439
|
* user's profile, the org they belong to, and their signing keys.
|
|
@@ -5493,7 +5493,7 @@ declare class WitniumAccountsClient {
|
|
|
5493
5493
|
/** `client.subscriptions.*` — Stripe Checkout + portal + credit ledger. */
|
|
5494
5494
|
declare class Subscriptions {
|
|
5495
5495
|
private readonly client;
|
|
5496
|
-
constructor(client:
|
|
5496
|
+
constructor(client: WitniumchainClient);
|
|
5497
5497
|
/**
|
|
5498
5498
|
* Start a Stripe Checkout session for the supplied price. Returns the
|
|
5499
5499
|
* hosted Checkout URL; redirect the user to it. Stripe's
|
|
@@ -5512,7 +5512,7 @@ declare class Subscriptions {
|
|
|
5512
5512
|
/** `client.delegatedKeys.*` — list, one-call provision, and revoke. */
|
|
5513
5513
|
declare class DelegatedKeys {
|
|
5514
5514
|
private readonly client;
|
|
5515
|
-
constructor(client:
|
|
5515
|
+
constructor(client: WitniumchainClient);
|
|
5516
5516
|
/** List the caller's delegated keys, optionally filtered by contract or active flag. */
|
|
5517
5517
|
list(query?: {
|
|
5518
5518
|
contractAddress?: string;
|
|
@@ -5524,7 +5524,7 @@ declare class DelegatedKeys {
|
|
|
5524
5524
|
* budget elapses). The server mints the delegated key in Vault; the caller
|
|
5525
5525
|
* never sees its private key.
|
|
5526
5526
|
*
|
|
5527
|
-
* Failure modes that surface as thrown {@link
|
|
5527
|
+
* Failure modes that surface as thrown {@link WitniumchainApiError}:
|
|
5528
5528
|
* - 409 from prepare → an active key already exists for this contract;
|
|
5529
5529
|
* caller must revoke the existing one first.
|
|
5530
5530
|
* - 400 from submit → ownerSignature didn't verify against the prepared
|
|
@@ -5546,7 +5546,7 @@ declare class DelegatedKeys {
|
|
|
5546
5546
|
}
|
|
5547
5547
|
/**
|
|
5548
5548
|
* `client.keys.*` — owner signing-key management (add / revoke + a list
|
|
5549
|
-
* helper derived from {@link
|
|
5549
|
+
* helper derived from {@link WitniumchainClient.getAccount}).
|
|
5550
5550
|
*
|
|
5551
5551
|
* Distinct from {@link DelegatedKeys} — those are Vault-held keys minted by
|
|
5552
5552
|
* the server for delegated signing. The methods here manage the owner's own
|
|
@@ -5554,11 +5554,11 @@ declare class DelegatedKeys {
|
|
|
5554
5554
|
*/
|
|
5555
5555
|
declare class SigningKeys {
|
|
5556
5556
|
private readonly client;
|
|
5557
|
-
constructor(client:
|
|
5557
|
+
constructor(client: WitniumchainClient);
|
|
5558
5558
|
/**
|
|
5559
5559
|
* The signing keys attached to the calling user's contract. There is no
|
|
5560
5560
|
* dedicated list endpoint; this method calls {@link
|
|
5561
|
-
*
|
|
5561
|
+
* WitniumchainClient.getAccount} and returns the `signingKeys` slice.
|
|
5562
5562
|
*/
|
|
5563
5563
|
list(): Promise<AccountResponse['signingKeys']>;
|
|
5564
5564
|
add(body: AddSigningKeyRequest): Promise<AddSigningKeyResponse>;
|
|
@@ -5567,17 +5567,17 @@ declare class SigningKeys {
|
|
|
5567
5567
|
/** `client.oauth.sessions.*` — list and revoke active OAuth sessions. */
|
|
5568
5568
|
declare class OauthNamespace {
|
|
5569
5569
|
readonly sessions: OauthSessions;
|
|
5570
|
-
constructor(client:
|
|
5570
|
+
constructor(client: WitniumchainClient);
|
|
5571
5571
|
}
|
|
5572
5572
|
declare class OauthSessions {
|
|
5573
5573
|
private readonly client;
|
|
5574
|
-
constructor(client:
|
|
5574
|
+
constructor(client: WitniumchainClient);
|
|
5575
5575
|
list(): Promise<ListOauthSessionsResponse>;
|
|
5576
5576
|
revoke(jti: string): Promise<void>;
|
|
5577
5577
|
revokeAll(): Promise<void>;
|
|
5578
5578
|
}
|
|
5579
5579
|
|
|
5580
|
-
interface
|
|
5580
|
+
interface WitniumchainAdminClientConfig {
|
|
5581
5581
|
/** Base URL, e.g. `https://auth.witniumchain.com`. Trailing slash optional. */
|
|
5582
5582
|
baseUrl: string;
|
|
5583
5583
|
/** System-admin token (`Authorization: Bearer <ADMIN_TOKEN>`). */
|
|
@@ -5588,9 +5588,9 @@ interface WitniumAccountsAdminClientConfig {
|
|
|
5588
5588
|
fetch?: typeof fetch;
|
|
5589
5589
|
}
|
|
5590
5590
|
type AccountType = 'metered' | 'unlimited';
|
|
5591
|
-
declare class
|
|
5591
|
+
declare class WitniumchainAdminClient {
|
|
5592
5592
|
private readonly inner;
|
|
5593
|
-
constructor(config:
|
|
5593
|
+
constructor(config: WitniumchainAdminClientConfig);
|
|
5594
5594
|
/**
|
|
5595
5595
|
* Mint a new organisation. The returned `apiKey` is shown ONCE — the server
|
|
5596
5596
|
* only retains its SHA-256 hash. Persist it before the response leaves
|
|
@@ -5622,21 +5622,21 @@ declare class WitniumAccountsAdminClient {
|
|
|
5622
5622
|
}
|
|
5623
5623
|
|
|
5624
5624
|
/**
|
|
5625
|
-
*
|
|
5625
|
+
* WitniumchainOrgClient — org-admin facade over the accounts API.
|
|
5626
5626
|
*
|
|
5627
5627
|
* Wraps the three `/v1/orgs/me/*` routes that org admins use to read their
|
|
5628
5628
|
* own org profile and manage their users. This is the client B2B2C apps and
|
|
5629
5629
|
* customer-admin dashboards consume — auth is the `wcorg_live_…` API key
|
|
5630
|
-
* minted via `
|
|
5630
|
+
* minted via `WitniumchainAdminClient.createOrganization` or returned by
|
|
5631
5631
|
* a subsequent `rotateApiKey`.
|
|
5632
5632
|
*
|
|
5633
5633
|
* The surface is intentionally minimal — the underlying API only exposes
|
|
5634
5634
|
* profile read + user create + user list. Anything more powerful (provision
|
|
5635
5635
|
* credits, change account type, verify email) requires the sysadmin
|
|
5636
|
-
* `AdminToken` and therefore lives on `
|
|
5636
|
+
* `AdminToken` and therefore lives on `WitniumchainAdminClient`.
|
|
5637
5637
|
*/
|
|
5638
5638
|
|
|
5639
|
-
interface
|
|
5639
|
+
interface WitniumchainOrgClientConfig {
|
|
5640
5640
|
/** Base URL, e.g. `https://auth.witniumchain.com`. Trailing slash optional. */
|
|
5641
5641
|
baseUrl: string;
|
|
5642
5642
|
/** Organisation API key (`wcorg_live_…`). */
|
|
@@ -5646,11 +5646,11 @@ interface WitniumAccountsOrgClientConfig {
|
|
|
5646
5646
|
/** Alternate fetch implementation (e.g. for tests). Default `globalThis.fetch`. */
|
|
5647
5647
|
fetch?: typeof fetch;
|
|
5648
5648
|
}
|
|
5649
|
-
declare class
|
|
5649
|
+
declare class WitniumchainOrgClient {
|
|
5650
5650
|
private readonly inner;
|
|
5651
5651
|
/** User-management namespace — `client.users.create/list`. */
|
|
5652
5652
|
readonly users: OrgUsers;
|
|
5653
|
-
constructor(config:
|
|
5653
|
+
constructor(config: WitniumchainOrgClientConfig);
|
|
5654
5654
|
/**
|
|
5655
5655
|
* The org's own profile — name, email, account type, cached credit
|
|
5656
5656
|
* balance (null for `unlimited` accounts), and the `isPersonal` flag.
|
|
@@ -5663,7 +5663,7 @@ declare class WitniumAccountsOrgClient {
|
|
|
5663
5663
|
/** `client.users.*` — create + list users in the org. */
|
|
5664
5664
|
declare class OrgUsers {
|
|
5665
5665
|
private readonly inner;
|
|
5666
|
-
constructor(inner:
|
|
5666
|
+
constructor(inner: WitniumchainClient);
|
|
5667
5667
|
/**
|
|
5668
5668
|
* Provision a new user inside the org. Requires the org's email to have
|
|
5669
5669
|
* been verified (sysadmin gate) — otherwise the server returns 403.
|
|
@@ -5681,7 +5681,7 @@ declare class OrgUsers {
|
|
|
5681
5681
|
* shapes are forwarded as `body`; the more useful fields are surfaced as
|
|
5682
5682
|
* top-level properties.
|
|
5683
5683
|
*/
|
|
5684
|
-
declare class
|
|
5684
|
+
declare class WitniumchainApiError extends Error {
|
|
5685
5685
|
readonly status: number;
|
|
5686
5686
|
readonly errorLabel: string | undefined;
|
|
5687
5687
|
readonly body: unknown;
|
|
@@ -5693,4 +5693,4 @@ declare class WitniumAccountsApiError extends Error {
|
|
|
5693
5693
|
});
|
|
5694
5694
|
}
|
|
5695
5695
|
|
|
5696
|
-
export { type AccountResponse, type AccountType, type AddSigningKeyRequest, type AddSigningKeyResponse, type AdjustCreditsRequest, type AdjustCreditsResponse, type CheckoutRequest, type CheckoutResponse, type CreateOrganizationRequest, type CreateOrganizationResponse, type CreateUserRequest, type CreateUserResponse, DelegatedKeys, type FinalizeWitnessResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetWitnessResponse, type HealthLiveResponse, type HealthReadyResponse, type LedgerResponse, type ListDelegatedKeysResponse, type ListOauthSessionsResponse, type ListUsersResponse, type LoginRequest, type LoginResponse, type LogoutResponse, OauthNamespace, OauthSessions, OrgUsers, type OwnerSigner, type PauseRequest, type PauseResponse, type PortalResponse, type PrepareDelegatedKeyRequest, type PreparedDelegatedKeyResponse, type ProposeWitnessRequest, type ProposeWitnessResponse, type ProvisionContractRequest, type ProvisionContractResponse, type ProvisionDelegatedKeyArgs, type ProvisionDelegatedKeyResult, type PublicOrgResponse, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDelegatedKeyResponse, type RevokeSigningKeyRequest, type RevokeSigningKeyResponse, type RevokeWitnessRequest, type RevokeWitnessResponse, type RotateApiKeyResponse, type SetAccountTypeRequest, type SetAccountTypeResponse, type SignRequest, type SignResponse, type SignWitnessRequest, type SignWitnessResponse, type SignedRequestSigner, SigningKeys, type SignupRequest, type SignupResponse, type SubmitDelegatedKeyRequest, type SubmitDelegatedKeyResponse, Subscriptions, type UnpauseRequest, type UnpauseResponse, type VerifyEmailResponse, type VerifyOrganizationResponse,
|
|
5696
|
+
export { type AccountResponse, type AccountType, type AddSigningKeyRequest, type AddSigningKeyResponse, type AdjustCreditsRequest, type AdjustCreditsResponse, type CheckoutRequest, type CheckoutResponse, type CreateOrganizationRequest, type CreateOrganizationResponse, type CreateUserRequest, type CreateUserResponse, DelegatedKeys, type FinalizeWitnessResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetWitnessResponse, type HealthLiveResponse, type HealthReadyResponse, type LedgerResponse, type ListDelegatedKeysResponse, type ListOauthSessionsResponse, type ListUsersResponse, type LoginRequest, type LoginResponse, type LogoutResponse, OauthNamespace, OauthSessions, OrgUsers, type OwnerSigner, type PauseRequest, type PauseResponse, type PortalResponse, type PrepareDelegatedKeyRequest, type PreparedDelegatedKeyResponse, type ProposeWitnessRequest, type ProposeWitnessResponse, type ProvisionContractRequest, type ProvisionContractResponse, type ProvisionDelegatedKeyArgs, type ProvisionDelegatedKeyResult, type PublicOrgResponse, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDelegatedKeyResponse, type RevokeSigningKeyRequest, type RevokeSigningKeyResponse, type RevokeWitnessRequest, type RevokeWitnessResponse, type RotateApiKeyResponse, type SetAccountTypeRequest, type SetAccountTypeResponse, type SignRequest, type SignResponse, type SignWitnessRequest, type SignWitnessResponse, type SignedRequestSigner, SigningKeys, type SignupRequest, type SignupResponse, type SubmitDelegatedKeyRequest, type SubmitDelegatedKeyResponse, Subscriptions, type UnpauseRequest, type UnpauseResponse, type VerifyEmailResponse, type VerifyOrganizationResponse, WitniumchainAdminClient, type WitniumchainAdminClientConfig, WitniumchainApiError, WitniumchainClient, type WitniumchainClientConfig, WitniumchainOrgClient, type WitniumchainOrgClientConfig, type paths };
|
package/dist/index.d.ts
CHANGED
|
@@ -5306,12 +5306,12 @@ type HealthLiveResponse = Res<'/health/live', 'get'>;
|
|
|
5306
5306
|
type HealthReadyResponse = Res<'/health/ready', 'get'>;
|
|
5307
5307
|
|
|
5308
5308
|
/**
|
|
5309
|
-
*
|
|
5309
|
+
* WitniumchainClient — typed HTTP client for the WitniumChain accounts API.
|
|
5310
5310
|
*
|
|
5311
5311
|
* This is the v1 "shell" client: one low-level method per OpenAPI route.
|
|
5312
5312
|
* Thread 4 (per docs/PLAN-PHASE-C-HARDEN-SURFACES.md) will layer three
|
|
5313
|
-
* higher-level clients on top — `
|
|
5314
|
-
* `
|
|
5313
|
+
* higher-level clients on top — `WitniumchainClient` (end-user),
|
|
5314
|
+
* `WitniumchainOrgClient` (org admin), `WitniumchainAdminClient`
|
|
5315
5315
|
* (sysadmin) — with ergonomic helpers for signup, subscriptions,
|
|
5316
5316
|
* delegated-key provisioning, Stripe Connect onboarding, etc.
|
|
5317
5317
|
*
|
|
@@ -5347,7 +5347,7 @@ interface SignedRequestSigner {
|
|
|
5347
5347
|
sign: (canonicalMessage: string) => Promise<string>;
|
|
5348
5348
|
}
|
|
5349
5349
|
/**
|
|
5350
|
-
* Owner-Ed25519 signer used by {@link
|
|
5350
|
+
* Owner-Ed25519 signer used by {@link WitniumchainClient.delegatedKeys.provision}.
|
|
5351
5351
|
*
|
|
5352
5352
|
* Structurally identical to {@link SignedRequestSigner} — both are
|
|
5353
5353
|
* `{ publicKeyHex, sign(message) }` — but kept as a distinct type so the
|
|
@@ -5402,7 +5402,7 @@ interface ProvisionDelegatedKeyResult {
|
|
|
5402
5402
|
/** Block number, populated once `confirmed === true`. */
|
|
5403
5403
|
blockNumber?: number;
|
|
5404
5404
|
}
|
|
5405
|
-
interface
|
|
5405
|
+
interface WitniumchainClientConfig {
|
|
5406
5406
|
/** Base URL, e.g. `https://auth.witniumchain.com`. Trailing slash optional. */
|
|
5407
5407
|
baseUrl: string;
|
|
5408
5408
|
/** Session cookie value (the `wac_session` cookie's body, not the full header). */
|
|
@@ -5420,7 +5420,7 @@ interface WitniumAccountsClientConfig {
|
|
|
5420
5420
|
/** Alternate fetch implementation (e.g. for tests). Default `globalThis.fetch`. */
|
|
5421
5421
|
fetch?: typeof fetch;
|
|
5422
5422
|
}
|
|
5423
|
-
declare class
|
|
5423
|
+
declare class WitniumchainClient {
|
|
5424
5424
|
private readonly baseUrl;
|
|
5425
5425
|
private readonly cfg;
|
|
5426
5426
|
private readonly timeout;
|
|
@@ -5433,7 +5433,7 @@ declare class WitniumAccountsClient {
|
|
|
5433
5433
|
readonly keys: SigningKeys;
|
|
5434
5434
|
/** OAuth session management. Accessed as `client.oauth.sessions.*`. */
|
|
5435
5435
|
readonly oauth: OauthNamespace;
|
|
5436
|
-
constructor(config:
|
|
5436
|
+
constructor(config: WitniumchainClientConfig);
|
|
5437
5437
|
/**
|
|
5438
5438
|
* Convenience alias for {@link getAccount} — returns the authenticated
|
|
5439
5439
|
* user's profile, the org they belong to, and their signing keys.
|
|
@@ -5493,7 +5493,7 @@ declare class WitniumAccountsClient {
|
|
|
5493
5493
|
/** `client.subscriptions.*` — Stripe Checkout + portal + credit ledger. */
|
|
5494
5494
|
declare class Subscriptions {
|
|
5495
5495
|
private readonly client;
|
|
5496
|
-
constructor(client:
|
|
5496
|
+
constructor(client: WitniumchainClient);
|
|
5497
5497
|
/**
|
|
5498
5498
|
* Start a Stripe Checkout session for the supplied price. Returns the
|
|
5499
5499
|
* hosted Checkout URL; redirect the user to it. Stripe's
|
|
@@ -5512,7 +5512,7 @@ declare class Subscriptions {
|
|
|
5512
5512
|
/** `client.delegatedKeys.*` — list, one-call provision, and revoke. */
|
|
5513
5513
|
declare class DelegatedKeys {
|
|
5514
5514
|
private readonly client;
|
|
5515
|
-
constructor(client:
|
|
5515
|
+
constructor(client: WitniumchainClient);
|
|
5516
5516
|
/** List the caller's delegated keys, optionally filtered by contract or active flag. */
|
|
5517
5517
|
list(query?: {
|
|
5518
5518
|
contractAddress?: string;
|
|
@@ -5524,7 +5524,7 @@ declare class DelegatedKeys {
|
|
|
5524
5524
|
* budget elapses). The server mints the delegated key in Vault; the caller
|
|
5525
5525
|
* never sees its private key.
|
|
5526
5526
|
*
|
|
5527
|
-
* Failure modes that surface as thrown {@link
|
|
5527
|
+
* Failure modes that surface as thrown {@link WitniumchainApiError}:
|
|
5528
5528
|
* - 409 from prepare → an active key already exists for this contract;
|
|
5529
5529
|
* caller must revoke the existing one first.
|
|
5530
5530
|
* - 400 from submit → ownerSignature didn't verify against the prepared
|
|
@@ -5546,7 +5546,7 @@ declare class DelegatedKeys {
|
|
|
5546
5546
|
}
|
|
5547
5547
|
/**
|
|
5548
5548
|
* `client.keys.*` — owner signing-key management (add / revoke + a list
|
|
5549
|
-
* helper derived from {@link
|
|
5549
|
+
* helper derived from {@link WitniumchainClient.getAccount}).
|
|
5550
5550
|
*
|
|
5551
5551
|
* Distinct from {@link DelegatedKeys} — those are Vault-held keys minted by
|
|
5552
5552
|
* the server for delegated signing. The methods here manage the owner's own
|
|
@@ -5554,11 +5554,11 @@ declare class DelegatedKeys {
|
|
|
5554
5554
|
*/
|
|
5555
5555
|
declare class SigningKeys {
|
|
5556
5556
|
private readonly client;
|
|
5557
|
-
constructor(client:
|
|
5557
|
+
constructor(client: WitniumchainClient);
|
|
5558
5558
|
/**
|
|
5559
5559
|
* The signing keys attached to the calling user's contract. There is no
|
|
5560
5560
|
* dedicated list endpoint; this method calls {@link
|
|
5561
|
-
*
|
|
5561
|
+
* WitniumchainClient.getAccount} and returns the `signingKeys` slice.
|
|
5562
5562
|
*/
|
|
5563
5563
|
list(): Promise<AccountResponse['signingKeys']>;
|
|
5564
5564
|
add(body: AddSigningKeyRequest): Promise<AddSigningKeyResponse>;
|
|
@@ -5567,17 +5567,17 @@ declare class SigningKeys {
|
|
|
5567
5567
|
/** `client.oauth.sessions.*` — list and revoke active OAuth sessions. */
|
|
5568
5568
|
declare class OauthNamespace {
|
|
5569
5569
|
readonly sessions: OauthSessions;
|
|
5570
|
-
constructor(client:
|
|
5570
|
+
constructor(client: WitniumchainClient);
|
|
5571
5571
|
}
|
|
5572
5572
|
declare class OauthSessions {
|
|
5573
5573
|
private readonly client;
|
|
5574
|
-
constructor(client:
|
|
5574
|
+
constructor(client: WitniumchainClient);
|
|
5575
5575
|
list(): Promise<ListOauthSessionsResponse>;
|
|
5576
5576
|
revoke(jti: string): Promise<void>;
|
|
5577
5577
|
revokeAll(): Promise<void>;
|
|
5578
5578
|
}
|
|
5579
5579
|
|
|
5580
|
-
interface
|
|
5580
|
+
interface WitniumchainAdminClientConfig {
|
|
5581
5581
|
/** Base URL, e.g. `https://auth.witniumchain.com`. Trailing slash optional. */
|
|
5582
5582
|
baseUrl: string;
|
|
5583
5583
|
/** System-admin token (`Authorization: Bearer <ADMIN_TOKEN>`). */
|
|
@@ -5588,9 +5588,9 @@ interface WitniumAccountsAdminClientConfig {
|
|
|
5588
5588
|
fetch?: typeof fetch;
|
|
5589
5589
|
}
|
|
5590
5590
|
type AccountType = 'metered' | 'unlimited';
|
|
5591
|
-
declare class
|
|
5591
|
+
declare class WitniumchainAdminClient {
|
|
5592
5592
|
private readonly inner;
|
|
5593
|
-
constructor(config:
|
|
5593
|
+
constructor(config: WitniumchainAdminClientConfig);
|
|
5594
5594
|
/**
|
|
5595
5595
|
* Mint a new organisation. The returned `apiKey` is shown ONCE — the server
|
|
5596
5596
|
* only retains its SHA-256 hash. Persist it before the response leaves
|
|
@@ -5622,21 +5622,21 @@ declare class WitniumAccountsAdminClient {
|
|
|
5622
5622
|
}
|
|
5623
5623
|
|
|
5624
5624
|
/**
|
|
5625
|
-
*
|
|
5625
|
+
* WitniumchainOrgClient — org-admin facade over the accounts API.
|
|
5626
5626
|
*
|
|
5627
5627
|
* Wraps the three `/v1/orgs/me/*` routes that org admins use to read their
|
|
5628
5628
|
* own org profile and manage their users. This is the client B2B2C apps and
|
|
5629
5629
|
* customer-admin dashboards consume — auth is the `wcorg_live_…` API key
|
|
5630
|
-
* minted via `
|
|
5630
|
+
* minted via `WitniumchainAdminClient.createOrganization` or returned by
|
|
5631
5631
|
* a subsequent `rotateApiKey`.
|
|
5632
5632
|
*
|
|
5633
5633
|
* The surface is intentionally minimal — the underlying API only exposes
|
|
5634
5634
|
* profile read + user create + user list. Anything more powerful (provision
|
|
5635
5635
|
* credits, change account type, verify email) requires the sysadmin
|
|
5636
|
-
* `AdminToken` and therefore lives on `
|
|
5636
|
+
* `AdminToken` and therefore lives on `WitniumchainAdminClient`.
|
|
5637
5637
|
*/
|
|
5638
5638
|
|
|
5639
|
-
interface
|
|
5639
|
+
interface WitniumchainOrgClientConfig {
|
|
5640
5640
|
/** Base URL, e.g. `https://auth.witniumchain.com`. Trailing slash optional. */
|
|
5641
5641
|
baseUrl: string;
|
|
5642
5642
|
/** Organisation API key (`wcorg_live_…`). */
|
|
@@ -5646,11 +5646,11 @@ interface WitniumAccountsOrgClientConfig {
|
|
|
5646
5646
|
/** Alternate fetch implementation (e.g. for tests). Default `globalThis.fetch`. */
|
|
5647
5647
|
fetch?: typeof fetch;
|
|
5648
5648
|
}
|
|
5649
|
-
declare class
|
|
5649
|
+
declare class WitniumchainOrgClient {
|
|
5650
5650
|
private readonly inner;
|
|
5651
5651
|
/** User-management namespace — `client.users.create/list`. */
|
|
5652
5652
|
readonly users: OrgUsers;
|
|
5653
|
-
constructor(config:
|
|
5653
|
+
constructor(config: WitniumchainOrgClientConfig);
|
|
5654
5654
|
/**
|
|
5655
5655
|
* The org's own profile — name, email, account type, cached credit
|
|
5656
5656
|
* balance (null for `unlimited` accounts), and the `isPersonal` flag.
|
|
@@ -5663,7 +5663,7 @@ declare class WitniumAccountsOrgClient {
|
|
|
5663
5663
|
/** `client.users.*` — create + list users in the org. */
|
|
5664
5664
|
declare class OrgUsers {
|
|
5665
5665
|
private readonly inner;
|
|
5666
|
-
constructor(inner:
|
|
5666
|
+
constructor(inner: WitniumchainClient);
|
|
5667
5667
|
/**
|
|
5668
5668
|
* Provision a new user inside the org. Requires the org's email to have
|
|
5669
5669
|
* been verified (sysadmin gate) — otherwise the server returns 403.
|
|
@@ -5681,7 +5681,7 @@ declare class OrgUsers {
|
|
|
5681
5681
|
* shapes are forwarded as `body`; the more useful fields are surfaced as
|
|
5682
5682
|
* top-level properties.
|
|
5683
5683
|
*/
|
|
5684
|
-
declare class
|
|
5684
|
+
declare class WitniumchainApiError extends Error {
|
|
5685
5685
|
readonly status: number;
|
|
5686
5686
|
readonly errorLabel: string | undefined;
|
|
5687
5687
|
readonly body: unknown;
|
|
@@ -5693,4 +5693,4 @@ declare class WitniumAccountsApiError extends Error {
|
|
|
5693
5693
|
});
|
|
5694
5694
|
}
|
|
5695
5695
|
|
|
5696
|
-
export { type AccountResponse, type AccountType, type AddSigningKeyRequest, type AddSigningKeyResponse, type AdjustCreditsRequest, type AdjustCreditsResponse, type CheckoutRequest, type CheckoutResponse, type CreateOrganizationRequest, type CreateOrganizationResponse, type CreateUserRequest, type CreateUserResponse, DelegatedKeys, type FinalizeWitnessResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetWitnessResponse, type HealthLiveResponse, type HealthReadyResponse, type LedgerResponse, type ListDelegatedKeysResponse, type ListOauthSessionsResponse, type ListUsersResponse, type LoginRequest, type LoginResponse, type LogoutResponse, OauthNamespace, OauthSessions, OrgUsers, type OwnerSigner, type PauseRequest, type PauseResponse, type PortalResponse, type PrepareDelegatedKeyRequest, type PreparedDelegatedKeyResponse, type ProposeWitnessRequest, type ProposeWitnessResponse, type ProvisionContractRequest, type ProvisionContractResponse, type ProvisionDelegatedKeyArgs, type ProvisionDelegatedKeyResult, type PublicOrgResponse, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDelegatedKeyResponse, type RevokeSigningKeyRequest, type RevokeSigningKeyResponse, type RevokeWitnessRequest, type RevokeWitnessResponse, type RotateApiKeyResponse, type SetAccountTypeRequest, type SetAccountTypeResponse, type SignRequest, type SignResponse, type SignWitnessRequest, type SignWitnessResponse, type SignedRequestSigner, SigningKeys, type SignupRequest, type SignupResponse, type SubmitDelegatedKeyRequest, type SubmitDelegatedKeyResponse, Subscriptions, type UnpauseRequest, type UnpauseResponse, type VerifyEmailResponse, type VerifyOrganizationResponse,
|
|
5696
|
+
export { type AccountResponse, type AccountType, type AddSigningKeyRequest, type AddSigningKeyResponse, type AdjustCreditsRequest, type AdjustCreditsResponse, type CheckoutRequest, type CheckoutResponse, type CreateOrganizationRequest, type CreateOrganizationResponse, type CreateUserRequest, type CreateUserResponse, DelegatedKeys, type FinalizeWitnessResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetWitnessResponse, type HealthLiveResponse, type HealthReadyResponse, type LedgerResponse, type ListDelegatedKeysResponse, type ListOauthSessionsResponse, type ListUsersResponse, type LoginRequest, type LoginResponse, type LogoutResponse, OauthNamespace, OauthSessions, OrgUsers, type OwnerSigner, type PauseRequest, type PauseResponse, type PortalResponse, type PrepareDelegatedKeyRequest, type PreparedDelegatedKeyResponse, type ProposeWitnessRequest, type ProposeWitnessResponse, type ProvisionContractRequest, type ProvisionContractResponse, type ProvisionDelegatedKeyArgs, type ProvisionDelegatedKeyResult, type PublicOrgResponse, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDelegatedKeyResponse, type RevokeSigningKeyRequest, type RevokeSigningKeyResponse, type RevokeWitnessRequest, type RevokeWitnessResponse, type RotateApiKeyResponse, type SetAccountTypeRequest, type SetAccountTypeResponse, type SignRequest, type SignResponse, type SignWitnessRequest, type SignWitnessResponse, type SignedRequestSigner, SigningKeys, type SignupRequest, type SignupResponse, type SubmitDelegatedKeyRequest, type SubmitDelegatedKeyResponse, Subscriptions, type UnpauseRequest, type UnpauseResponse, type VerifyEmailResponse, type VerifyOrganizationResponse, WitniumchainAdminClient, type WitniumchainAdminClientConfig, WitniumchainApiError, WitniumchainClient, type WitniumchainClientConfig, WitniumchainOrgClient, type WitniumchainOrgClientConfig, type paths };
|