@settlemint/dalp-sdk 3.1.15 → 3.1.16-main.33750953986
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 +154 -169
- package/dist/auth/client.d.ts +113 -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 +329 -0
- package/dist/bundler.d.ts +14 -207
- package/dist/bundler.js +99 -0
- package/dist/chunk-0m709wz4.js +4 -0
- package/dist/chunk-akbjkbyt.js +260 -0
- package/dist/chunk-def7rqy6.js +946 -0
- package/dist/chunk-f4t1bm86.js +67 -0
- package/dist/chunk-fjnq61hj.js +11 -0
- package/dist/chunk-h12fatty.js +63 -0
- package/dist/chunk-n0b075da.js +33 -0
- package/dist/chunk-r0vsftj4.js +102 -0
- package/dist/chunk-y0d2c7kp.js +54 -0
- package/dist/client/conditional-request.d.ts +30 -0
- package/dist/client/factory.d.ts +14 -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/effect.d.ts +69 -0
- package/dist/effect.js +82 -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/api-types.d.ts +41238 -0
- package/dist/generated/response-scalars.d.ts +9 -0
- package/dist/generated/routes.d.ts +12 -0
- package/dist/index.d.ts +28 -40
- package/dist/index.js +131 -96108
- package/dist/proxy/builder.d.ts +47 -0
- package/dist/proxy/client.d.ts +32 -0
- package/dist/proxy/fetch-executor.d.ts +28 -0
- package/dist/proxy/flat-args.d.ts +51 -0
- package/dist/proxy/settlement.d.ts +67 -0
- package/dist/proxy/sse.d.ts +54 -0
- package/dist/proxy/tanstack.d.ts +27 -0
- package/dist/proxy/transport.d.ts +73 -0
- package/dist/react-query.d.ts +16 -0
- package/dist/react-query.js +13 -0
- package/dist/readonly-deep.d.ts +12 -0
- package/dist/reads-as-funding-paused.d.ts +20 -0
- package/dist/routes/index.d.ts +20 -0
- package/dist/routes/index.js +10 -0
- package/dist/routes/types.d.ts +51 -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 +20 -0
- package/dist/scalars/exchange-rates.d.ts +27 -0
- package/dist/scalars/index.d.ts +18 -0
- package/dist/scalars/index.js +86 -0
- package/dist/scalars/organization-id.d.ts +20 -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 +65 -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 +54 -81
- package/dist/wait-for-transaction.js +120 -0
- package/dist/webhook-events.d.ts +44 -27
- package/package.json +103 -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,191 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
One typed client for the Platform API v2, derived from the platform's own route
|
|
4
|
+
declaration. Calls are namespaced (`dalp.api.token.transfer(...)`), a queue
|
|
5
|
+
backed write resolves once the chain has settled, and TanStack Query factories
|
|
6
|
+
sit on the same nodes as the calls. The package ships no runtime schema
|
|
7
|
+
library: the types are compile time only.
|
|
8
|
+
|
|
9
|
+
Two interpreters over one route table. The package root returns promises. The
|
|
10
|
+
`./effect` subpath returns Effect values with a typed failure channel. Neither
|
|
11
|
+
pulls the other in, and a build gate keeps the root free of Effect.
|
|
38
12
|
|
|
39
|
-
##
|
|
13
|
+
## Client
|
|
40
14
|
|
|
41
|
-
```
|
|
15
|
+
```ts
|
|
42
16
|
import { createDalpClient } from "@settlemint/dalp-sdk";
|
|
43
17
|
|
|
44
18
|
const dalp = createDalpClient({
|
|
45
|
-
|
|
19
|
+
baseUrl: "https://dalp.example.com",
|
|
46
20
|
apiKey: "sm_dalp_...",
|
|
47
|
-
organizationId: "org_...", // optional, for multi-org setups
|
|
48
21
|
});
|
|
49
22
|
|
|
50
|
-
|
|
51
|
-
const tokens = await dalp.token.list({ query: {} });
|
|
52
|
-
const system = await dalp.system.read({});
|
|
23
|
+
const tokens = await dalp.api.token.list({ limit: 25 }, { signal });
|
|
53
24
|
```
|
|
54
25
|
|
|
55
|
-
|
|
26
|
+
A call takes one flat object. The route table says which of its keys are path
|
|
27
|
+
parameters and which are query or body fields, so a call site names what it
|
|
28
|
+
means and never restates the transport. The build refuses any route whose path
|
|
29
|
+
parameter would collide with a body or query key, which is what makes the
|
|
30
|
+
merge safe.
|
|
56
31
|
|
|
57
|
-
|
|
58
|
-
|
|
32
|
+
`createDalpClient` owns the shared transport policy once: the credential
|
|
33
|
+
mechanism, the acting-context headers (`organizationId`, `participant`,
|
|
34
|
+
`executor`, `chainId`, `selectedSigners`, `idempotencyKey`), conditional
|
|
35
|
+
`If-None-Match` reuse, custom fetch injection, the settlement bound, and abort
|
|
36
|
+
propagation.
|
|
59
37
|
|
|
60
|
-
|
|
61
|
-
|
|
38
|
+
**An API key cannot reach a browser.** `createDalpClient` throws at
|
|
39
|
+
construction when a key is passed with `runtime: "browser"`, rather than at the
|
|
40
|
+
first request. A key carries the full authority of the identity it belongs to.
|
|
41
|
+
In a browser the client authenticates with the session cookie instead.
|
|
62
42
|
|
|
63
|
-
|
|
64
|
-
url: "https://dalp.example.com",
|
|
65
|
-
apiKey: "sm_dalp_...",
|
|
66
|
-
organizationId: "org_...",
|
|
67
|
-
});
|
|
43
|
+
### Dispatch by route id
|
|
68
44
|
|
|
69
|
-
|
|
45
|
+
```ts
|
|
46
|
+
const token = await dalp.execute("token/read", { assetId });
|
|
70
47
|
```
|
|
71
48
|
|
|
72
|
-
|
|
73
|
-
|
|
49
|
+
`execute` is typed against the id through the `DalpRouteTypes` registry, so a
|
|
50
|
+
command surface built from route ids keeps the same request and response types
|
|
51
|
+
the namespaced tree gives a call site. The CLI, the end-to-end harness, and the
|
|
52
|
+
demo scripts are all built on it.
|
|
53
|
+
|
|
54
|
+
### Settlement
|
|
55
|
+
|
|
56
|
+
A queue-backed write resolves with the settled record, not with the platform's
|
|
57
|
+
acceptance. The platform answers such a route either with the settled body or
|
|
58
|
+
with a handle to poll, and the client follows the handle so no caller writes
|
|
59
|
+
that loop.
|
|
60
|
+
|
|
61
|
+
A wait that runs out raises `SettlementTimeoutError` carrying the transaction
|
|
62
|
+
id and the status URL. That is not a failed write: the transaction is still on
|
|
63
|
+
its way to a block, and resubmitting is a second transfer. `settlementTimeoutMs`
|
|
64
|
+
sets the bound per client, and a call may override it.
|
|
65
|
+
|
|
66
|
+
A write the funding gate parks on an operator payment is stopped, not slow. The
|
|
67
|
+
status row carries the open ask as `activeRequirement`, and every read that
|
|
68
|
+
reports one restarts the bound, so the wait outlasts the pause and resolves
|
|
69
|
+
with the settled record once the ask is paid. When an ask lapses unpaid the
|
|
70
|
+
platform fails the request, and that failure is what the client reports. A
|
|
71
|
+
caller that cannot wait that long ends the wait through `signal`, and
|
|
72
|
+
`waitForTransaction` takes `holdWhilePaused: false` to end on the first parked
|
|
73
|
+
status with reason `funding-paused` instead.
|
|
74
|
+
|
|
75
|
+
### Conditional requests and ETags
|
|
76
|
+
|
|
77
|
+
The client reuses a held body when the server answers a matching ETag with 304.
|
|
78
|
+
Server ETags must be **strong content digests** computed **after
|
|
79
|
+
authorization** inside the requester's partition. Version-stamp ETags
|
|
80
|
+
(generation counters, watermarks, table versions) are forbidden for conditional
|
|
81
|
+
request adopters: a stamp can collide across tenants or lag a body change.
|
|
82
|
+
|
|
83
|
+
Identity changes that do not ride this client (browser sign-out, organization
|
|
84
|
+
switch) must clear the held bodies, so a later GET cannot send another
|
|
85
|
+
session's `If-None-Match`.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
dalp.conditionalRequests.clear();
|
|
89
|
+
```
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
import { createDalpPlatformClient } from "@settlemint/dalp-sdk";
|
|
91
|
+
## Effect
|
|
77
92
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
93
|
+
```ts
|
|
94
|
+
import { createDalpEffectClient } from "@settlemint/dalp-sdk/effect";
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
password: "Password123!",
|
|
85
|
-
name: "Example User",
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const sessionCookie = platform.cookieStore.header;
|
|
96
|
+
const dalp = createDalpEffectClient({ baseUrl, apiKey });
|
|
97
|
+
const tokens = yield * dalp.api.token.list({ limit: 25 });
|
|
89
98
|
```
|
|
90
99
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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" });
|
|
100
|
+
The same routes, returning `Effect` values that fail with `DalpRequestError`
|
|
101
|
+
rather than throwing. `execute` is typed by route id here too.
|
|
102
|
+
|
|
103
|
+
## The route table
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { routeIds, routeTable } from "@settlemint/dalp-sdk/routes";
|
|
117
107
|
```
|
|
118
108
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
109
|
+
`./routes` publishes the generated table both interpreters dispatch through:
|
|
110
|
+
every v2 route's id, method, path template, statuses, and traits. It carries no
|
|
111
|
+
client and no Effect, so a tool that only needs to know what the platform
|
|
112
|
+
serves loads this rather than a client.
|
|
113
|
+
|
|
114
|
+
## TanStack Query
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
const options = dalp.api.token.list.queryOptions({ limit: 25 });
|
|
118
|
+
const transfer = dalp.api.token.transfer.mutationOptions();
|
|
122
119
|
```
|
|
123
120
|
|
|
124
|
-
|
|
121
|
+
Every read node carries `queryOptions`; every write node carries
|
|
122
|
+
`mutationOptions`. They are plain objects in the shapes TanStack
|
|
123
|
+
Query expects, so nothing forces you into that library and nothing stops you
|
|
124
|
+
using something else.
|
|
125
|
+
|
|
126
|
+
Cache keys are derived from route identity plus canonicalized input, so two
|
|
127
|
+
callers passing the same parameters in a different key order share one entry.
|
|
128
|
+
`./react-query` exports `queryKeyFor` and `canonicalize` for building a
|
|
129
|
+
matching invalidation filter, and `UI_SETTLEMENT_TIMEOUT_MS`, the shorter bound
|
|
130
|
+
the mutation factories default to.
|
|
131
|
+
|
|
132
|
+
## Scalars
|
|
133
|
+
|
|
134
|
+
Custom wire formats (BigDecimal amounts, EVM addresses, and the
|
|
135
|
+
`OrganizationId` entity brand) are not expressed structurally in the generated
|
|
136
|
+
OpenAPI document, so `./scalars` carries a decoder for each:
|
|
137
|
+
`decodeBigDecimal`, `decodeEthereumAddress`, `decodeOrganizationId`, and the
|
|
138
|
+
exchange-rate response transformer. The route table names which fields carry a
|
|
139
|
+
scalar, keyed by dotted path, so a consumer applies a decoder where the
|
|
140
|
+
declaration says one lives rather than guessing from a field name.
|
|
141
|
+
`OrganizationId` is the only entity id branded end to end across the platform;
|
|
142
|
+
every other identifier crossing this boundary is a plain string.
|
|
143
|
+
|
|
144
|
+
## Auth
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { createDalpAuthClient } from "@settlemint/dalp-sdk/auth";
|
|
148
|
+
```
|
|
125
149
|
|
|
126
|
-
|
|
127
|
-
|
|
150
|
+
The route surface already carries every auth REST route. `./auth` covers what a
|
|
151
|
+
REST call cannot express: the session and cookie state machine, plugin actions
|
|
152
|
+
that must run in the browser (`passkeyClient` drives the WebAuthn ceremony
|
|
153
|
+
through `navigator.credentials`), and the access-control model that evaluates a
|
|
154
|
+
permission locally instead of round-tripping. It sits off the package root
|
|
155
|
+
because it costs roughly 70 KiB of Better Auth that a consumer who only calls
|
|
156
|
+
routes should not pay.
|
|
128
157
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
158
|
+
Better Auth's client types reference zod, so `zod` is an optional peer
|
|
159
|
+
dependency: install it if you use `./auth`, skip it otherwise. No code in this
|
|
160
|
+
package imports zod at runtime.
|
|
132
161
|
|
|
133
|
-
|
|
134
|
-
apiKey: "sm_dalp_...",
|
|
162
|
+
## Bundler and paymaster
|
|
135
163
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
headers: { "User-Agent": "MyApp" }, // override default headers
|
|
139
|
-
idempotencyKey: "req_abc123", // ⚠️ sent on EVERY request — use only for single-mutation clients
|
|
140
|
-
requestValidation: false, // validate requests client-side (default: false)
|
|
141
|
-
responseValidation: false, // validate responses client-side (default: false)
|
|
142
|
-
fetch: customFetch, // custom fetch implementation
|
|
143
|
-
});
|
|
164
|
+
```ts
|
|
165
|
+
import { createDalpBundlerClient } from "@settlemint/dalp-sdk/bundler";
|
|
144
166
|
```
|
|
145
167
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
| ------------------ | -------------------------- |
|
|
150
|
-
| `account` | Manage accounts |
|
|
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
|
-
```
|
|
168
|
+
`createDalpBundlerClient` keeps the eight established ERC-4337 method names
|
|
169
|
+
while calling the v2 REST resources underneath. It accepts EntryPoint v0.9
|
|
170
|
+
`viem` shapes and returns the corresponding typed values.
|
|
191
171
|
|
|
192
|
-
##
|
|
172
|
+
## Webhooks and transaction wait
|
|
193
173
|
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
|
|
174
|
+
- `./verify-webhook` verifies an inbound webhook signature.
|
|
175
|
+
- `./sign-webhook-receipt` signs a webhook delivery receipt (Node only).
|
|
176
|
+
- `./wait-for-transaction` is a bounded poll for on-chain settlement, for a
|
|
177
|
+
transaction id you hold from somewhere other than a client call. A write made
|
|
178
|
+
through the client already waits.
|
|
198
179
|
|
|
199
|
-
##
|
|
180
|
+
## Package root
|
|
200
181
|
|
|
201
|
-
|
|
202
|
-
|
|
182
|
+
The root stays small: the client factory, its options and errors, cookie-store
|
|
183
|
+
transport, the settlement types, and the version constants. A consumer who only
|
|
184
|
+
calls routes never pays for auth, bundler, TanStack Query, or webhook code.
|
|
203
185
|
|
|
204
|
-
##
|
|
186
|
+
## Documentation
|
|
205
187
|
|
|
206
|
-
|
|
188
|
+
The integrator guide lives under Developer reference in the platform docs:
|
|
189
|
+
install and credentials, calling routes, mutations and settlement, streaming,
|
|
190
|
+
TanStack Query, server rendering in TanStack Start and Next.js, and the Effect
|
|
191
|
+
surface.
|
|
@@ -0,0 +1,113 @@
|
|
|
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/api-types.d.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> = TData;
|
|
35
|
+
export interface DalpOrganizationMember extends Member {
|
|
36
|
+
readonly user: {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly email: string;
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly image?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface DalpOrganizationMembersQuery {
|
|
44
|
+
readonly limit?: string | number;
|
|
45
|
+
readonly offset?: string | number;
|
|
46
|
+
readonly sortBy?: string;
|
|
47
|
+
readonly sortDirection?: "asc" | "desc";
|
|
48
|
+
readonly filterField?: string;
|
|
49
|
+
readonly filterValue?: string | number | boolean | ReadonlyArray<string> | ReadonlyArray<number>;
|
|
50
|
+
readonly filterOperator?: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with";
|
|
51
|
+
readonly organizationId?: string;
|
|
52
|
+
readonly organizationSlug?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Invitation row from Better Auth `listInvitations` / `listUserInvitations`. */
|
|
55
|
+
export interface DalpOrganizationInvitation {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly organizationId: string;
|
|
58
|
+
readonly email: string;
|
|
59
|
+
readonly role?: string;
|
|
60
|
+
readonly status: string;
|
|
61
|
+
readonly expiresAt: string | Date;
|
|
62
|
+
}
|
|
63
|
+
export interface DalpOrganizationInvitationsQuery {
|
|
64
|
+
readonly organizationId?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Stable Better Auth operation types composed into `DalpAuthClient`.
|
|
68
|
+
*
|
|
69
|
+
* This is not a separate runtime client — `createDalpAuthClient` returns
|
|
70
|
+
* `DalpAuthClient`, which also includes wallet plugins. Keep this interface as
|
|
71
|
+
* the typed non-wallet surface so inference stays explicit; do not construct it.
|
|
72
|
+
*/
|
|
73
|
+
export interface DalpCliAuthClient {
|
|
74
|
+
readonly getSession: DalpNoInputAuthOperation<GetSessionResponse>;
|
|
75
|
+
readonly listSessions: DalpNoInputAuthOperation<ListUserSessionsResponse>;
|
|
76
|
+
readonly revokeSession: DalpRequiredAuthOperation<RequestBody<AuthPostRevokeSessionData>, AuthPostRevokeSessionResponse>;
|
|
77
|
+
readonly revokeOtherSessions: DalpNoInputAuthOperation<AuthPostRevokeOtherSessionsResponse>;
|
|
78
|
+
readonly apiKey: {
|
|
79
|
+
readonly list: DalpNoInputAuthOperation<AuthGetApiKeyListResponse>;
|
|
80
|
+
readonly create: DalpRequiredAuthOperation<RequestBody<AuthPostApiKeyCreateData>, AuthPostApiKeyCreateResponse>;
|
|
81
|
+
readonly delete: DalpRequiredAuthOperation<RequestBody<AuthPostApiKeyDeleteData>, AuthPostApiKeyDeleteResponse>;
|
|
82
|
+
};
|
|
83
|
+
readonly organization: {
|
|
84
|
+
readonly list: DalpNoInputAuthOperation<AuthGetOrganizationListResponse>;
|
|
85
|
+
readonly setActive: DalpRequiredAuthOperation<RequestBody<SetActiveOrganizationData>, SetActiveOrganizationResponse>;
|
|
86
|
+
readonly create: DalpRequiredAuthOperation<RequestBody<AuthPostOrganizationCreateData>, AuthPostOrganizationCreateResponse>;
|
|
87
|
+
readonly inviteMember: DalpRequiredAuthOperation<RequestBody<CreateOrganizationInvitationData>, CreateOrganizationInvitationResponse>;
|
|
88
|
+
readonly removeMember: DalpRequiredAuthOperation<RequestBody<AuthPostOrganizationRemoveMemberData>, AuthPostOrganizationRemoveMemberResponse>;
|
|
89
|
+
readonly acceptInvitation: DalpRequiredAuthOperation<RequestBody<AuthPostOrganizationAcceptInvitationData>, AuthPostOrganizationAcceptInvitationResponse>;
|
|
90
|
+
readonly listMembers: DalpRequiredAuthOperation<{
|
|
91
|
+
readonly query?: DalpOrganizationMembersQuery;
|
|
92
|
+
}, {
|
|
93
|
+
readonly members: ReadonlyArray<DalpOrganizationMember>;
|
|
94
|
+
readonly total: number;
|
|
95
|
+
}>;
|
|
96
|
+
readonly listInvitations: DalpAuthOperation<{
|
|
97
|
+
readonly query?: DalpOrganizationInvitationsQuery;
|
|
98
|
+
}, ReadonlyArray<DalpOrganizationInvitation>>;
|
|
99
|
+
readonly listUserInvitations: DalpNoInputAuthOperation<ReadonlyArray<DalpOrganizationInvitation>>;
|
|
100
|
+
};
|
|
101
|
+
readonly twoFactor: {
|
|
102
|
+
readonly enable: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorEnableData>, AuthPostTwoFactorEnableResponse>;
|
|
103
|
+
readonly disable: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorDisableData>, AuthPostTwoFactorDisableResponse>;
|
|
104
|
+
readonly verifyTotp: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorVerifyTotpData>, AuthPostTwoFactorVerifyTotpResponse>;
|
|
105
|
+
readonly verifyBackupCode: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorVerifyBackupCodeData>, AuthPostTwoFactorVerifyBackupCodeResponse>;
|
|
106
|
+
readonly generateBackupCodes: DalpRequiredAuthOperation<RequestBody<AuthPostTwoFactorGenerateBackupCodesData>, AuthPostTwoFactorGenerateBackupCodesResponse>;
|
|
107
|
+
};
|
|
108
|
+
readonly device: {
|
|
109
|
+
readonly approve: DalpRequiredAuthOperation<RequestBody<AuthPostDeviceApproveData>, AuthPostDeviceApproveResponse>;
|
|
110
|
+
readonly deny: DalpRequiredAuthOperation<RequestBody<AuthPostDeviceDenyData>, AuthPostDeviceDenyResponse>;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export declare function decodeDalpAuthClientConfig(input: DalpAuthClientConfig): Promise<DecodedDalpAuthClientConfig>;
|