@settlemint/dalp-sdk 3.1.10 → 3.1.11-main.33556892334
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 +111 -177
- package/dist/auth/client.d.ts +115 -0
- package/dist/auth/live.d.ts +4366 -0
- package/dist/{auth-permissions.d.ts → auth/permissions.d.ts} +1 -2
- package/dist/{auth-wallet-plugins.d.ts → auth/wallet-plugins.d.ts} +69 -5
- package/dist/auth.d.ts +22 -115
- package/dist/auth.js +248 -0
- package/dist/bundler.d.ts +17 -207
- package/dist/bundler.js +111 -0
- package/dist/chunk-63xjs3xe.js +45725 -0
- package/dist/chunk-cy9b59s6.js +503 -0
- package/dist/chunk-h12fatty.js +63 -0
- package/dist/chunk-nac758dt.js +14542 -0
- package/dist/chunk-q8bjy1aa.js +255 -0
- package/dist/chunk-r0vsftj4.js +102 -0
- package/dist/chunk-w21k7p99.js +843 -0
- package/dist/chunk-y0d2c7kp.js +54 -0
- package/dist/client/conditional-request.d.ts +16 -0
- package/dist/client/factory.d.ts +39 -0
- package/dist/client/query-serializer.d.ts +2 -0
- package/dist/client/request-compression.d.ts +47 -0
- package/dist/client/ssr-fetch.d.ts +12 -0
- package/dist/errors/api-error.d.ts +29 -0
- package/dist/errors/find-current-error.d.ts +8 -0
- package/dist/errors/sdk-error.d.ts +52 -0
- package/dist/errors/sdk-error.js +8 -0
- package/dist/generated/@tanstack/react-query.gen.d.ts +17380 -0
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/index.d.ts +10 -0
- package/dist/generated/client/types.gen.d.ts +120 -0
- package/dist/generated/client/utils.gen.d.ts +37 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/core/auth.gen.d.ts +25 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/types.gen.d.ts +83 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/sdk.gen.d.ts +5214 -0
- package/dist/generated/types.gen.d.ts +137282 -0
- package/dist/generated/zod.gen.d.ts +181286 -0
- package/dist/index.d.ts +23 -40
- package/dist/index.js +208 -96098
- package/dist/operations.d.ts +12 -0
- package/dist/operations.js +1747 -0
- package/dist/react-query.d.ts +11 -0
- package/dist/react-query.js +16485 -0
- package/dist/readonly-deep.d.ts +12 -0
- package/dist/runtime-exports.d.ts +20 -0
- package/dist/runtime-exports.js +16 -0
- package/dist/scalars/big-decimal.d.ts +16 -0
- package/dist/scalars/ethereum-address.d.ts +8 -0
- package/dist/scalars/exchange-rates.d.ts +36 -0
- package/dist/scalars/index.d.ts +15 -0
- package/dist/scalars/index.js +39 -0
- package/dist/scalars/organization-id.d.ts +8 -0
- package/dist/schemas.d.ts +10 -0
- package/dist/schemas.js +12040 -0
- package/dist/secret.d.ts +14 -0
- package/dist/sign-webhook-receipt.d.ts +76 -0
- package/dist/sign-webhook-receipt.js +26 -0
- package/dist/transport/cookie-store.d.ts +9 -0
- package/dist/transport/sse-lifecycle.d.ts +44 -0
- package/dist/types.d.ts +67 -102
- package/dist/url.d.ts +0 -1
- package/dist/verify-webhook.d.ts +17 -28
- package/dist/verify-webhook.js +8 -0
- package/dist/version.d.ts +0 -1
- package/dist/wait-for-transaction.d.ts +40 -86
- package/dist/wait-for-transaction.js +112 -0
- package/dist/webhook-events.d.ts +44 -27
- package/package.json +98 -30
- package/dist/auth-permissions.d.ts.map +0 -1
- package/dist/auth-wallet-plugins.d.ts.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/bundler.d.ts.map +0 -1
- package/dist/chunk-xm8h1dzh.js +0 -33
- package/dist/client.d.ts +0 -19
- package/dist/client.d.ts.map +0 -1
- package/dist/contract-errors.d.ts +0 -4156
- package/dist/contract-errors.d.ts.map +0 -1
- package/dist/contract.d.ts +0 -17
- package/dist/contract.d.ts.map +0 -1
- package/dist/cookie-store.d.ts +0 -10
- package/dist/cookie-store.d.ts.map +0 -1
- package/dist/dapi-errors.d.ts +0 -650
- package/dist/dapi-errors.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -633
- package/dist/errors.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/platform.d.ts +0 -41
- package/dist/platform.d.ts.map +0 -1
- package/dist/plugins/index.d.ts +0 -13
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -10
- package/dist/sdk-error.d.ts +0 -74
- package/dist/sdk-error.d.ts.map +0 -1
- package/dist/serializers.d.ts +0 -41
- package/dist/serializers.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/url.d.ts.map +0 -1
- package/dist/verify-webhook.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/wait-for-transaction.d.ts.map +0 -1
- package/dist/webhook-events.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,206 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Fully typed TypeScript SDK for the Digital Asset Lifecycle Platform API.
|
|
8
|
-
</p>
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
<p align="center">
|
|
12
|
-
<a href="https://www.npmjs.com/package/@settlemint/dalp-sdk" rel="nofollow"><img src="https://img.shields.io/npm/v/@settlemint/dalp-sdk" alt="npm version"></a>
|
|
13
|
-
<a href="https://www.npmjs.com/package/@settlemint/dalp-sdk" rel="nofollow"><img src="https://img.shields.io/npm/dw/@settlemint/dalp-sdk" alt="npm downloads"></a>
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
<div align="center">
|
|
17
|
-
<a href="https://settlemint.com">Website</a>
|
|
18
|
-
<span> • </span>
|
|
19
|
-
<a href="https://www.npmjs.com/package/@settlemint/dalp-sdk">NPM</a>
|
|
20
|
-
<span> • </span>
|
|
21
|
-
<a href="mailto:support@settlemint.com">Support</a>
|
|
22
|
-
<br />
|
|
23
|
-
</div>
|
|
24
|
-
|
|
25
|
-
## About
|
|
26
|
-
|
|
27
|
-
The DALP SDK provides a fully typed client for the Digital Asset Lifecycle Platform API. Built on [oRPC](https://orpc.unnoq.com/) with contract-first types, it gives you auto-complete for every API namespace — tokens, identities, compliance, transactions, and more.
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# npm
|
|
33
|
-
npm install @settlemint/dalp-sdk
|
|
34
|
-
|
|
35
|
-
# bun
|
|
36
|
-
bun add @settlemint/dalp-sdk
|
|
37
|
-
```
|
|
1
|
+
# DALP SDK
|
|
2
|
+
|
|
3
|
+
The DALP SDK is a Promise-based client generated from the canonical v2 OpenAPI
|
|
4
|
+
declaration ([Hey API](https://heyapi.dev/)), validated at runtime with
|
|
5
|
+
[zod](https://zod.dev/). It is Effect-free: no `Effect` values, no branded
|
|
6
|
+
Effect Schema identifiers on the wire.
|
|
38
7
|
|
|
39
|
-
##
|
|
8
|
+
## Client
|
|
40
9
|
|
|
41
|
-
```
|
|
10
|
+
```ts
|
|
42
11
|
import { createDalpClient } from "@settlemint/dalp-sdk";
|
|
43
12
|
|
|
44
13
|
const dalp = createDalpClient({
|
|
45
|
-
|
|
14
|
+
baseUrl: "https://dalp.example.com",
|
|
46
15
|
apiKey: "sm_dalp_...",
|
|
47
|
-
organizationId: "org_...", // optional, for multi-org setups
|
|
48
16
|
});
|
|
49
17
|
|
|
50
|
-
|
|
51
|
-
const tokens = await dalp.token.list({ query: {} });
|
|
52
|
-
const system = await dalp.system.read({});
|
|
18
|
+
const tokens = await dalp.token.list({ query: {} }, { signal });
|
|
53
19
|
```
|
|
54
20
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
keys,
|
|
21
|
+
`createDalpClient` owns shared transport policy once: the credential mechanism
|
|
22
|
+
(session cookie in the browser and on SSR, or an `X-Api-Key` header for
|
|
23
|
+
server/CLI callers — never both from the same runtime), organization headers,
|
|
24
|
+
idempotency keys, `Prefer`, conditional `If-None-Match` / ETag reuse, custom fetch
|
|
25
|
+
injection, and abort propagation. See the "Credential ownership matrix" JSDoc
|
|
26
|
+
on `createDalpClient` in `src/client/factory.ts` for which runtime may use
|
|
27
|
+
which credential.
|
|
59
28
|
|
|
60
|
-
|
|
61
|
-
|
|
29
|
+
Response decoding is strict: every generated operation parses its response
|
|
30
|
+
against the declared zod schema and throws on a mismatch.
|
|
62
31
|
|
|
63
|
-
|
|
64
|
-
url: "https://dalp.example.com",
|
|
65
|
-
apiKey: "sm_dalp_...",
|
|
66
|
-
organizationId: "org_...",
|
|
67
|
-
});
|
|
32
|
+
### Conditional requests and ETags
|
|
68
33
|
|
|
69
|
-
|
|
70
|
-
|
|
34
|
+
`createDalpClient` installs `If-None-Match` / 304 interceptors that reuse a
|
|
35
|
+
held body when the server returns a matching ETag. Server ETags must be
|
|
36
|
+
**strong content digests** computed **after authorization** inside the
|
|
37
|
+
requester's partition. The dapi response cache guarantees this: it hashes the
|
|
38
|
+
serialized body after the request-context middleware has authenticated the
|
|
39
|
+
session. Version-stamp ETags (generation counters, watermarks, table versions)
|
|
40
|
+
are forbidden for conditional-request adopters — a stamp can collide across
|
|
41
|
+
tenants or lag a body change.
|
|
71
42
|
|
|
72
|
-
|
|
73
|
-
|
|
43
|
+
Identity changes that do not ride this client (browser sign-out, organization
|
|
44
|
+
switch) must call `clearConditionalRequestStore(client)` so a later GET cannot
|
|
45
|
+
send another session's `If-None-Match`.
|
|
74
46
|
|
|
75
|
-
```
|
|
76
|
-
import {
|
|
47
|
+
```ts
|
|
48
|
+
import { clearConditionalRequestStore, createDalpClient } from "@settlemint/dalp-sdk";
|
|
77
49
|
|
|
78
|
-
|
|
79
|
-
url: "https://dalp.example.com",
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
await platform.auth.signUp.email({
|
|
83
|
-
email: "user@example.com",
|
|
84
|
-
password: "Password123!",
|
|
85
|
-
name: "Example User",
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const sessionCookie = platform.cookieStore.header;
|
|
50
|
+
clearConditionalRequestStore(dalp);
|
|
89
51
|
```
|
|
90
52
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
All namespaces below are fully typed on `DalpAuthClient` — every operation has auto-complete and a typed return value.
|
|
94
|
-
|
|
95
|
-
| Namespace | Operations | Description |
|
|
96
|
-
| --------------------- | ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
97
|
-
| `signIn` | `email` | Sign in with email and password |
|
|
98
|
-
| `signUp` | `email` | Register a new account |
|
|
99
|
-
| `getSession` | — | Fetch the current session |
|
|
100
|
-
| `listSessions` | — | List all active sessions |
|
|
101
|
-
| `revokeSession` | — | Revoke a specific session |
|
|
102
|
-
| `revokeOtherSessions` | — | Revoke all sessions except the current one |
|
|
103
|
-
| `apiKey` | `create`, `list`, `delete` | Manage API keys |
|
|
104
|
-
| `organization` | `create`, `list`, `setActive`, `inviteMember`, `acceptInvitation`, `listMembers`, `addMember`, `removeMember` | Manage organizations and membership |
|
|
105
|
-
| `admin` | `listUsers`, `createUser`, `removeUser`, `setRole` | Administrative user management |
|
|
106
|
-
| `device` | `code`, `token`, `approve`, `deny` | Device authorization flow |
|
|
107
|
-
| `twoFactor` | `enable`, `disable`, `verifyTotp`, `verifyBackupCode`, `generateBackupCodes` | Account-level TOTP two-factor authentication |
|
|
108
|
-
| `wallet.pincode` | `enable`, `disable`, `update`, `reset` | Wallet pincode protection |
|
|
109
|
-
| `wallet.twoFactor` | `enable`, `disable`, `verify` | Wallet two-factor verification |
|
|
110
|
-
| `wallet.secretCodes` | `generate`, `confirm` | Wallet secret (recovery) codes |
|
|
111
|
-
| `passkey` | — | Account-level passkey registration (browser/WebAuthn only) |
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
// Enable account-level 2FA and verify a TOTP code
|
|
115
|
-
await auth.twoFactor.enable({ password: "..." });
|
|
116
|
-
await auth.twoFactor.verifyTotp({ code: "123456" });
|
|
117
|
-
```
|
|
53
|
+
## Generated operations
|
|
118
54
|
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
await auth.wallet.pincode.enable({ pincode: "1234", password: "..." });
|
|
55
|
+
```ts
|
|
56
|
+
import { createClient } from "@settlemint/dalp-sdk/operations";
|
|
122
57
|
```
|
|
123
58
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
59
|
+
`./operations` re-exports the generated v2 operation functions and generated
|
|
60
|
+
client primitives (585 operations) on their own subpath, so a consumer who
|
|
61
|
+
only signs webhooks or builds a client never loads that module. Pair it with
|
|
62
|
+
`createDalpClient` from the package root.
|
|
63
|
+
|
|
64
|
+
## Scalars
|
|
65
|
+
|
|
66
|
+
Custom wire formats — BigDecimal amounts, EVM addresses, and the
|
|
67
|
+
`OrganizationId` entity brand — are not expressed structurally in the
|
|
68
|
+
generated OpenAPI spec (it carries no `format:`/`x-` extension for them), so
|
|
69
|
+
each has a hand-maintained wrapper under `src/scalars/`:
|
|
70
|
+
`big-decimal.ts`, `ethereum-address.ts`, `exchange-rates.ts`,
|
|
71
|
+
`organization-id.ts`. `OrganizationId` is the only entity ID branded
|
|
72
|
+
end-to-end across the platform (see `AGENTS.md`); every other identifier
|
|
73
|
+
crossing this SDK's boundary is a plain string. `tools/scripts/src/check-sdk-scalar-coverage.ts`
|
|
74
|
+
gates new generated scalar-shaped symbols against a curated allowlist so a
|
|
75
|
+
spec change that introduces a new custom scalar fails the build instead of
|
|
76
|
+
shipping unwrapped.
|
|
77
|
+
|
|
78
|
+
## React Query
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { tokenListOptions } from "@settlemint/dalp-sdk/react-query";
|
|
144
82
|
```
|
|
145
83
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
| `actions` | Manage actions |
|
|
152
|
-
| `addons` | Manage addons |
|
|
153
|
-
| `admin` | Administrative operations |
|
|
154
|
-
| `contacts` | Manage contacts |
|
|
155
|
-
| `exchangeRates` | View exchange rates |
|
|
156
|
-
| `externalToken` | Manage external tokens |
|
|
157
|
-
| `identityRecovery` | Recover lost identities |
|
|
158
|
-
| `monitoring` | Platform monitoring |
|
|
159
|
-
| `search` | Search across the platform |
|
|
160
|
-
| `settings` | Platform settings |
|
|
161
|
-
| `system` | System administration |
|
|
162
|
-
| `token` | Manage security tokens |
|
|
163
|
-
| `transaction` | View transactions |
|
|
164
|
-
| `user` | Manage platform users |
|
|
165
|
-
|
|
166
|
-
## Endpoint Coverage
|
|
167
|
-
|
|
168
|
-
The SDK covers 100% of the v2 REST API: it is generated from the same oRPC contract that the server implements, and a
|
|
169
|
-
CI check (`bun run check:sdk-coverage`) diffs every mounted API route against the contract on every change. Endpoints
|
|
170
|
-
intentionally outside the SDK contract are named in a committed allowlist with a reason each, in these categories:
|
|
171
|
-
|
|
172
|
-
- **v1-frozen** — the deliberately frozen v1 REST surface
|
|
173
|
-
- **internal-ops** — health probes, CSP report sink, theme CSS, static manifests
|
|
174
|
-
- **webhook-receiver** — provider webhook receivers (DFNS, Ripple, compliance providers)
|
|
175
|
-
- **better-auth** — auth plumbing, covered by the SDK auth client instead
|
|
176
|
-
- **docs / asset-delivery / bundler / orpc-mount** — API docs pages, binary asset delivery, the ERC-4337 bundler
|
|
177
|
-
JSON-RPC passthrough (covered by the SDK bundler client), and the oRPC transport mounts themselves
|
|
178
|
-
|
|
179
|
-
## Subpath Exports
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
// Main entry — client factory, error codes, serializers
|
|
183
|
-
import { createDalpAuthClient, createDalpClient, createDalpPlatformClient } from "@settlemint/dalp-sdk";
|
|
184
|
-
|
|
185
|
-
// Type-only — for function signatures without runtime code
|
|
186
|
-
import type { DalpClient, DalpClientConfig } from "@settlemint/dalp-sdk/types";
|
|
187
|
-
|
|
188
|
-
// Plugins — optional oRPC link plugins for advanced usage
|
|
189
|
-
import { BatchLinkPlugin, RequestValidationPlugin } from "@settlemint/dalp-sdk/plugins";
|
|
190
|
-
```
|
|
84
|
+
`./react-query` re-exports the generated TanStack Query option factories
|
|
85
|
+
(`queryOptions`, `infiniteOptions`, `mutationOptions`) — spread into your own
|
|
86
|
+
hooks; the generator emits no hooks itself. This is the only module that
|
|
87
|
+
imports `@tanstack/react-query`, so that peer dependency stays optional for
|
|
88
|
+
non-React consumers.
|
|
191
89
|
|
|
192
|
-
##
|
|
90
|
+
## Auth
|
|
193
91
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
- Client-side request validation can be enabled to catch schema violations early
|
|
92
|
+
```ts
|
|
93
|
+
import { createDalpAuthClient } from "@settlemint/dalp-sdk/auth";
|
|
94
|
+
```
|
|
198
95
|
|
|
199
|
-
|
|
96
|
+
The generated SDK already exposes every auth REST operation; `./auth` covers
|
|
97
|
+
what a REST call cannot express — the session/cookie state machine, plugin
|
|
98
|
+
actions that must run in the browser (`passkeyClient` drives the WebAuthn
|
|
99
|
+
ceremony through `navigator.credentials`), and the access-control model that
|
|
100
|
+
evaluates a permission locally instead of round-tripping `has-permission`. Off
|
|
101
|
+
the package root because it costs roughly 70 KiB of Better Auth a
|
|
102
|
+
pure-operations consumer should not pay.
|
|
200
103
|
|
|
201
|
-
|
|
202
|
-
public DAPI error id when the server returns one.
|
|
104
|
+
## Bundler and paymaster
|
|
203
105
|
|
|
204
|
-
|
|
106
|
+
```ts
|
|
107
|
+
import { createDalpBundlerClient } from "@settlemint/dalp-sdk/bundler";
|
|
108
|
+
```
|
|
205
109
|
|
|
206
|
-
|
|
110
|
+
`createDalpBundlerClient` retains the eight established ERC-4337 method names
|
|
111
|
+
while calling the generated v2 REST resources underneath. The SDK accepts
|
|
112
|
+
EntryPoint v0.9 `viem` shapes and returns the corresponding typed values.
|
|
113
|
+
|
|
114
|
+
## Webhooks and transaction wait
|
|
115
|
+
|
|
116
|
+
- `./verify-webhook` — verify an inbound webhook signature.
|
|
117
|
+
- `./sign-webhook-receipt` — sign a webhook delivery receipt (Node-only).
|
|
118
|
+
- `./wait-for-transaction` — bounded poll for on-chain transaction settlement;
|
|
119
|
+
calls a generated operation and so inherits the generated validator
|
|
120
|
+
module's full weight.
|
|
121
|
+
|
|
122
|
+
## Package root
|
|
123
|
+
|
|
124
|
+
The package root (`@settlemint/dalp-sdk`) stays deliberately small — the
|
|
125
|
+
client factory, its config and errors, cookie-store transport, SSE lifecycle
|
|
126
|
+
handling, and SDK version constants — so a consumer
|
|
127
|
+
who only needs to call operations never pays for auth, bundler, react-query,
|
|
128
|
+
or webhook code. See the `@module` doc at the top of `src/index.ts` for the
|
|
129
|
+
current weight breakdown per subpath.
|
|
130
|
+
|
|
131
|
+
## Migrating from the Effect client
|
|
132
|
+
|
|
133
|
+
Prior major versions exposed an `Effect`-returning client
|
|
134
|
+
(`makeDalpEffectClient`, `makeDalpApiLayer`, `DalpEffectClient`) alongside the
|
|
135
|
+
Promise client. That dual surface, the `contracts/` schema re-exports, and
|
|
136
|
+
`makeDalpPlatformClient`/`waitForTransactionEffect` are removed — see
|
|
137
|
+
`CHANGELOG.md` and the
|
|
138
|
+
[v2 migration guide](../docs/content/docs/api-reference/reference/v2-migration.mdx).
|
|
139
|
+
No published consumer depended on the Effect surface, so this ships without a
|
|
140
|
+
major version bump.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { DalpFetch } from "../client/ssr-fetch.ts";
|
|
2
|
+
import type { AuthGetApiKeyListResponse, AuthGetOrganizationListResponse, AuthPostApiKeyCreateData, AuthPostApiKeyCreateResponse, AuthPostApiKeyDeleteData, AuthPostApiKeyDeleteResponse, AuthPostDeviceApproveData, AuthPostDeviceApproveResponse, AuthPostDeviceDenyData, AuthPostDeviceDenyResponse, AuthPostOrganizationAcceptInvitationData, AuthPostOrganizationAcceptInvitationResponse, AuthPostOrganizationCreateData, AuthPostOrganizationCreateResponse, AuthPostOrganizationRemoveMemberData, AuthPostOrganizationRemoveMemberResponse, AuthPostRevokeOtherSessionsResponse, AuthPostRevokeSessionData, AuthPostRevokeSessionResponse, AuthPostTwoFactorDisableData, AuthPostTwoFactorDisableResponse, AuthPostTwoFactorEnableData, AuthPostTwoFactorEnableResponse, AuthPostTwoFactorGenerateBackupCodesData, AuthPostTwoFactorGenerateBackupCodesResponse, AuthPostTwoFactorVerifyBackupCodeData, AuthPostTwoFactorVerifyBackupCodeResponse, AuthPostTwoFactorVerifyTotpData, AuthPostTwoFactorVerifyTotpResponse, CreateOrganizationInvitationData, CreateOrganizationInvitationResponse, GetSessionResponse, ListUserSessionsResponse, Member, SetActiveOrganizationData, SetActiveOrganizationResponse } from "../generated/types.gen.ts";
|
|
3
|
+
import { Secret } from "../secret.ts";
|
|
4
|
+
import type { CookieStoreShape } from "../transport/cookie-store.ts";
|
|
5
|
+
export interface DalpAuthClientConfig {
|
|
6
|
+
readonly url: string;
|
|
7
|
+
readonly apiKey?: string;
|
|
8
|
+
readonly sessionToken?: string;
|
|
9
|
+
readonly cookie?: string;
|
|
10
|
+
readonly cookieStore?: CookieStoreShape;
|
|
11
|
+
readonly organizationId?: string;
|
|
12
|
+
readonly headers?: Record<string, string>;
|
|
13
|
+
readonly fetch?: DalpFetch;
|
|
14
|
+
}
|
|
15
|
+
export interface DecodedDalpAuthClientConfig extends Omit<DalpAuthClientConfig, "apiKey" | "sessionToken" | "cookie"> {
|
|
16
|
+
readonly apiKey?: Secret;
|
|
17
|
+
readonly sessionToken?: Secret;
|
|
18
|
+
readonly cookie?: Secret;
|
|
19
|
+
}
|
|
20
|
+
export interface DalpAuthError {
|
|
21
|
+
readonly code?: string;
|
|
22
|
+
readonly message?: string;
|
|
23
|
+
readonly status?: number;
|
|
24
|
+
readonly statusText?: string;
|
|
25
|
+
readonly [key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface DalpAuthResult<TData = unknown, TError = DalpAuthError> {
|
|
28
|
+
readonly data: TData | null;
|
|
29
|
+
readonly error: TError | null;
|
|
30
|
+
}
|
|
31
|
+
export type DalpAuthOperation<TInput, TData = unknown> = (input?: TInput, options?: unknown) => Promise<DalpAuthResult<TData>>;
|
|
32
|
+
export type DalpRequiredAuthOperation<TInput, TData> = (input: TInput, options?: unknown) => Promise<DalpAuthResult<TData>>;
|
|
33
|
+
export type DalpNoInputAuthOperation<TData> = (options?: unknown) => Promise<DalpAuthResult<TData>>;
|
|
34
|
+
export type RequestBody<TData extends {
|
|
35
|
+
readonly body?: unknown;
|
|
36
|
+
}> = NonNullable<TData["body"]>;
|
|
37
|
+
export interface DalpOrganizationMember extends Member {
|
|
38
|
+
readonly user: {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly email: string;
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly image?: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface DalpOrganizationMembersQuery {
|
|
46
|
+
readonly limit?: string | number;
|
|
47
|
+
readonly offset?: string | number;
|
|
48
|
+
readonly sortBy?: string;
|
|
49
|
+
readonly sortDirection?: "asc" | "desc";
|
|
50
|
+
readonly filterField?: string;
|
|
51
|
+
readonly filterValue?: string | number | boolean | ReadonlyArray<string> | ReadonlyArray<number>;
|
|
52
|
+
readonly filterOperator?: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with";
|
|
53
|
+
readonly organizationId?: string;
|
|
54
|
+
readonly organizationSlug?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Invitation row from Better Auth `listInvitations` / `listUserInvitations`. */
|
|
57
|
+
export interface DalpOrganizationInvitation {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly organizationId: string;
|
|
60
|
+
readonly email: string;
|
|
61
|
+
readonly role?: string;
|
|
62
|
+
readonly status: string;
|
|
63
|
+
readonly expiresAt: string | Date;
|
|
64
|
+
}
|
|
65
|
+
export interface DalpOrganizationInvitationsQuery {
|
|
66
|
+
readonly organizationId?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Stable Better Auth operation types composed into `DalpAuthClient`.
|
|
70
|
+
*
|
|
71
|
+
* This is not a separate runtime client — `createDalpAuthClient` returns
|
|
72
|
+
* `DalpAuthClient`, which also includes wallet plugins. Keep this interface as
|
|
73
|
+
* the typed non-wallet surface so inference stays explicit; do not construct it.
|
|
74
|
+
*/
|
|
75
|
+
export interface DalpCliAuthClient {
|
|
76
|
+
readonly getSession: DalpNoInputAuthOperation<GetSessionResponse>;
|
|
77
|
+
readonly listSessions: DalpNoInputAuthOperation<ListUserSessionsResponse>;
|
|
78
|
+
readonly revokeSession: DalpRequiredAuthOperation<RequestBody<AuthPostRevokeSessionData>, AuthPostRevokeSessionResponse>;
|
|
79
|
+
readonly revokeOtherSessions: DalpNoInputAuthOperation<AuthPostRevokeOtherSessionsResponse>;
|
|
80
|
+
readonly apiKey: {
|
|
81
|
+
readonly list: DalpNoInputAuthOperation<AuthGetApiKeyListResponse>;
|
|
82
|
+
readonly create: DalpRequiredAuthOperation<RequestBody<AuthPostApiKeyCreateData>, AuthPostApiKeyCreateResponse>;
|
|
83
|
+
readonly delete: DalpRequiredAuthOperation<RequestBody<AuthPostApiKeyDeleteData>, AuthPostApiKeyDeleteResponse>;
|
|
84
|
+
};
|
|
85
|
+
readonly organization: {
|
|
86
|
+
readonly list: DalpNoInputAuthOperation<AuthGetOrganizationListResponse>;
|
|
87
|
+
readonly setActive: DalpRequiredAuthOperation<RequestBody<SetActiveOrganizationData>, SetActiveOrganizationResponse>;
|
|
88
|
+
readonly create: DalpRequiredAuthOperation<RequestBody<AuthPostOrganizationCreateData>, AuthPostOrganizationCreateResponse>;
|
|
89
|
+
readonly inviteMember: DalpRequiredAuthOperation<RequestBody<CreateOrganizationInvitationData>, CreateOrganizationInvitationResponse>;
|
|
90
|
+
readonly removeMember: DalpRequiredAuthOperation<RequestBody<AuthPostOrganizationRemoveMemberData>, AuthPostOrganizationRemoveMemberResponse>;
|
|
91
|
+
readonly acceptInvitation: DalpRequiredAuthOperation<RequestBody<AuthPostOrganizationAcceptInvitationData>, AuthPostOrganizationAcceptInvitationResponse>;
|
|
92
|
+
readonly listMembers: DalpRequiredAuthOperation<{
|
|
93
|
+
readonly query?: DalpOrganizationMembersQuery;
|
|
94
|
+
}, {
|
|
95
|
+
readonly members: ReadonlyArray<DalpOrganizationMember>;
|
|
96
|
+
readonly total: number;
|
|
97
|
+
}>;
|
|
98
|
+
readonly listInvitations: DalpAuthOperation<{
|
|
99
|
+
readonly query?: DalpOrganizationInvitationsQuery;
|
|
100
|
+
}, ReadonlyArray<DalpOrganizationInvitation>>;
|
|
101
|
+
readonly listUserInvitations: DalpNoInputAuthOperation<ReadonlyArray<DalpOrganizationInvitation>>;
|
|
102
|
+
};
|
|
103
|
+
readonly twoFactor: {
|
|
104
|
+
readonly enable: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorEnableData>, AuthPostTwoFactorEnableResponse>;
|
|
105
|
+
readonly disable: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorDisableData>, AuthPostTwoFactorDisableResponse>;
|
|
106
|
+
readonly verifyTotp: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorVerifyTotpData>, AuthPostTwoFactorVerifyTotpResponse>;
|
|
107
|
+
readonly verifyBackupCode: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorVerifyBackupCodeData>, AuthPostTwoFactorVerifyBackupCodeResponse>;
|
|
108
|
+
readonly generateBackupCodes: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorGenerateBackupCodesData>, AuthPostTwoFactorGenerateBackupCodesResponse>;
|
|
109
|
+
};
|
|
110
|
+
readonly device: {
|
|
111
|
+
readonly approve: DalpRequiredAuthOperation<RequestBody<AuthPostDeviceApproveData>, AuthPostDeviceApproveResponse>;
|
|
112
|
+
readonly deny: DalpRequiredAuthOperation<RequestBody<AuthPostDeviceDenyData>, AuthPostDeviceDenyResponse>;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export declare function decodeDalpAuthClientConfig(input: DalpAuthClientConfig): Promise<DecodedDalpAuthClientConfig>;
|