@settlemint/dalp-sdk 3.1.18 → 3.1.19-main.34482536277
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 +156 -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 +21 -205
- package/dist/bundler.js +97 -0
- package/dist/chunk-09prmw53.js +4 -0
- package/dist/chunk-d0295j58.js +33 -0
- package/dist/chunk-j4sxrfzz.js +54 -0
- package/dist/chunk-qvtjb3dz.js +102 -0
- package/dist/chunk-rb8k4w3q.js +67 -0
- package/dist/chunk-shp8v4ws.js +913 -0
- package/dist/chunk-sk9nc2q3.js +10 -0
- package/dist/chunk-xp3fx2yt.js +63 -0
- package/dist/chunk-ybqqdgrd.js +260 -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 +78 -0
- package/dist/effect.js +87 -0
- package/dist/errors/api-error.d.ts +33 -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 +56950 -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 +127 -96109
- package/dist/proxy/builder.d.ts +47 -0
- package/dist/proxy/client.d.ts +32 -0
- package/dist/proxy/fetch-executor.d.ts +30 -0
- package/dist/proxy/flat-args.d.ts +52 -0
- package/dist/proxy/sse.d.ts +75 -0
- package/dist/proxy/tanstack.d.ts +27 -0
- package/dist/proxy/transport.d.ts +74 -0
- package/dist/react-query.d.ts +16 -0
- package/dist/react-query.js +12 -0
- package/dist/readonly-deep.d.ts +12 -0
- package/dist/reads-as-funding-paused.d.ts +20 -0
- package/dist/reads-as-indexer-rebuild.d.ts +14 -0
- package/dist/routes/index.d.ts +20 -0
- package/dist/routes/index.js +10 -0
- package/dist/routes/types.d.ts +57 -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 +69 -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 +66 -79
- package/dist/wait-for-transaction.js +142 -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,193 @@
|
|
|
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 carries a `Prefer` header derived from
|
|
57
|
+
`settlementTimeoutMs`: undefined asks for `wait=15`, zero or less asks for
|
|
58
|
+
`respond-async`, anything else asks for `wait=<seconds>`, clamped to the
|
|
59
|
+
platform's 5 to 99 second range. `settlementTimeoutMs` sets that bound per
|
|
60
|
+
client, and a call may override it.
|
|
61
|
+
|
|
62
|
+
The platform does the waiting, not the client. When the write settles inside
|
|
63
|
+
the wait, the call returns the route's HTTP 200 resource. When it does not, the
|
|
64
|
+
call returns the declared HTTP 202 handle unchanged: a transaction write's
|
|
65
|
+
`{ transactionId, status, statusUrl }`, or a custody write's `{ requestId,
|
|
66
|
+
state, statusUrl }`. The client never polls a status URL on your behalf.
|
|
67
|
+
|
|
68
|
+
Pass a transaction id to `waitForTransaction` to follow it to a terminal
|
|
69
|
+
state. A write the funding gate parks on an operator payment reads as still
|
|
70
|
+
queued for as long as the ask is open: the status row carries it as
|
|
71
|
+
`activeRequirement`, and `waitForTransaction` restarts its own timeout on every
|
|
72
|
+
status that reports one, so the wait it runs outlasts the pause. A caller that
|
|
73
|
+
cannot wait that long ends the wait through `signal`, or passes
|
|
74
|
+
`holdWhilePaused: false` to end on the first parked status instead. A custody
|
|
75
|
+
handle has no equivalent helper: follow `statusUrl` yourself.
|
|
76
|
+
|
|
77
|
+
### Conditional requests and ETags
|
|
78
|
+
|
|
79
|
+
The client reuses a held body when the server answers a matching ETag with 304.
|
|
80
|
+
Server ETags must be **strong content digests** computed **after
|
|
81
|
+
authorization** inside the requester's partition. Version-stamp ETags
|
|
82
|
+
(generation counters, watermarks, table versions) are forbidden for conditional
|
|
83
|
+
request adopters: a stamp can collide across tenants or lag a body change.
|
|
84
|
+
|
|
85
|
+
Identity changes that do not ride this client (browser sign-out, organization
|
|
86
|
+
switch) must clear the held bodies, so a later GET cannot send another
|
|
87
|
+
session's `If-None-Match`.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
dalp.conditionalRequests.clear();
|
|
91
|
+
```
|
|
74
92
|
|
|
75
|
-
|
|
76
|
-
import { createDalpPlatformClient } from "@settlemint/dalp-sdk";
|
|
93
|
+
## Effect
|
|
77
94
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
95
|
+
```ts
|
|
96
|
+
import { createDalpEffectClient } from "@settlemint/dalp-sdk/effect";
|
|
81
97
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
password: "Password123!",
|
|
85
|
-
name: "Example User",
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const sessionCookie = platform.cookieStore.header;
|
|
98
|
+
const dalp = createDalpEffectClient({ baseUrl, apiKey });
|
|
99
|
+
const tokens = yield * dalp.api.token.list({ limit: 25 });
|
|
89
100
|
```
|
|
90
101
|
|
|
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" });
|
|
102
|
+
The same routes, returning `Effect` values that fail with `DalpRequestError`
|
|
103
|
+
rather than throwing. `execute` is typed by route id here too.
|
|
104
|
+
|
|
105
|
+
## The route table
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { routeIds, routeTable } from "@settlemint/dalp-sdk/routes";
|
|
117
109
|
```
|
|
118
110
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
`./routes` publishes the generated table both interpreters dispatch through:
|
|
112
|
+
every v2 route's id, method, path template, statuses, and traits. It carries no
|
|
113
|
+
client and no Effect, so a tool that only needs to know what the platform
|
|
114
|
+
serves loads this rather than a client.
|
|
115
|
+
|
|
116
|
+
## TanStack Query
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const options = dalp.api.token.list.queryOptions({ limit: 25 });
|
|
120
|
+
const transfer = dalp.api.token.transfer.mutationOptions();
|
|
122
121
|
```
|
|
123
122
|
|
|
124
|
-
|
|
123
|
+
Every read node carries `queryOptions`; every write node carries
|
|
124
|
+
`mutationOptions`. They are plain objects in the shapes TanStack
|
|
125
|
+
Query expects, so nothing forces you into that library and nothing stops you
|
|
126
|
+
using something else.
|
|
127
|
+
|
|
128
|
+
Cache keys are derived from route identity plus canonicalized input, so two
|
|
129
|
+
callers passing the same parameters in a different key order share one entry.
|
|
130
|
+
`./react-query` exports `queryKeyFor` and `canonicalize` for building a
|
|
131
|
+
matching invalidation filter, and `UI_SETTLEMENT_TIMEOUT_MS`, the bound the
|
|
132
|
+
mutation factories default to.
|
|
133
|
+
|
|
134
|
+
## Scalars
|
|
135
|
+
|
|
136
|
+
Custom wire formats (BigDecimal amounts, EVM addresses, and the
|
|
137
|
+
`OrganizationId` entity brand) are not expressed structurally in the generated
|
|
138
|
+
OpenAPI document, so `./scalars` carries a decoder for each:
|
|
139
|
+
`decodeBigDecimal`, `decodeEthereumAddress`, `decodeOrganizationId`, and the
|
|
140
|
+
exchange-rate response transformer. The route table names which fields carry a
|
|
141
|
+
scalar, keyed by dotted path, so a consumer applies a decoder where the
|
|
142
|
+
declaration says one lives rather than guessing from a field name.
|
|
143
|
+
`OrganizationId` is the only entity id branded end to end across the platform;
|
|
144
|
+
every other identifier crossing this boundary is a plain string.
|
|
145
|
+
|
|
146
|
+
## Auth
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { createDalpAuthClient } from "@settlemint/dalp-sdk/auth";
|
|
150
|
+
```
|
|
125
151
|
|
|
126
|
-
|
|
127
|
-
|
|
152
|
+
The route surface already carries every auth REST route. `./auth` covers what a
|
|
153
|
+
REST call cannot express: the session and cookie state machine, plugin actions
|
|
154
|
+
that must run in the browser (`passkeyClient` drives the WebAuthn ceremony
|
|
155
|
+
through `navigator.credentials`), and the access-control model that evaluates a
|
|
156
|
+
permission locally instead of round-tripping. It sits off the package root
|
|
157
|
+
because it costs roughly 70 KiB of Better Auth that a consumer who only calls
|
|
158
|
+
routes should not pay.
|
|
128
159
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
160
|
+
Better Auth's client types reference zod, so `zod` is an optional peer
|
|
161
|
+
dependency: install it if you use `./auth`, skip it otherwise. No code in this
|
|
162
|
+
package imports zod at runtime.
|
|
132
163
|
|
|
133
|
-
|
|
134
|
-
apiKey: "sm_dalp_...",
|
|
164
|
+
## Bundler and paymaster
|
|
135
165
|
|
|
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
|
-
});
|
|
166
|
+
```ts
|
|
167
|
+
import { createDalpBundlerClient } from "@settlemint/dalp-sdk/bundler";
|
|
144
168
|
```
|
|
145
169
|
|
|
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
|
-
```
|
|
170
|
+
`createDalpBundlerClient` keeps the eight established ERC-4337 method names
|
|
171
|
+
while calling the v2 REST resources underneath. It accepts EntryPoint v0.9
|
|
172
|
+
`viem` shapes and returns the corresponding typed values.
|
|
191
173
|
|
|
192
|
-
##
|
|
174
|
+
## Webhooks and transaction wait
|
|
193
175
|
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
|
|
176
|
+
- `./verify-webhook` verifies an inbound webhook signature.
|
|
177
|
+
- `./sign-webhook-receipt` signs a webhook delivery receipt (Node only).
|
|
178
|
+
- `./wait-for-transaction` is a bounded poll to a terminal state, for a
|
|
179
|
+
transaction id from any source, including the 202 handle a client write
|
|
180
|
+
returns when the platform's wait runs out.
|
|
198
181
|
|
|
199
|
-
##
|
|
182
|
+
## Package root
|
|
200
183
|
|
|
201
|
-
|
|
202
|
-
|
|
184
|
+
The root stays small: the client factory, its options and errors, cookie-store
|
|
185
|
+
transport, and the version constants. A consumer who only
|
|
186
|
+
calls routes never pays for auth, bundler, TanStack Query, or webhook code.
|
|
203
187
|
|
|
204
|
-
##
|
|
188
|
+
## Documentation
|
|
205
189
|
|
|
206
|
-
|
|
190
|
+
The integrator guide lives under Developer reference in the platform docs:
|
|
191
|
+
install and credentials, calling routes, mutations and settlement, streaming,
|
|
192
|
+
TanStack Query, server rendering in TanStack Start and Next.js, and the Effect
|
|
193
|
+
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>;
|