@settlemint/dalp-sdk 3.1.18-main.33807531377 → 3.1.18
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 +169 -154
- package/dist/{auth/permissions.d.ts → auth-permissions.d.ts} +2 -1
- package/dist/auth-permissions.d.ts.map +1 -0
- package/dist/{auth/wallet-plugins.d.ts → auth-wallet-plugins.d.ts} +5 -69
- package/dist/auth-wallet-plugins.d.ts.map +1 -0
- package/dist/auth.d.ts +115 -22
- package/dist/auth.d.ts.map +1 -0
- package/dist/bundler.d.ts +207 -14
- package/dist/bundler.d.ts.map +1 -0
- package/dist/chunk-xm8h1dzh.js +33 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/contract-errors.d.ts +4156 -0
- package/dist/contract-errors.d.ts.map +1 -0
- package/dist/contract.d.ts +17 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/cookie-store.d.ts +10 -0
- package/dist/cookie-store.d.ts.map +1 -0
- package/dist/dapi-errors.d.ts +650 -0
- package/dist/dapi-errors.d.ts.map +1 -0
- package/dist/errors.d.ts +633 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +40 -28
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96109 -131
- package/dist/platform.d.ts +41 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +13 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +10 -0
- package/dist/sdk-error.d.ts +74 -0
- package/dist/sdk-error.d.ts.map +1 -0
- package/dist/serializers.d.ts +41 -0
- package/dist/serializers.d.ts.map +1 -0
- package/dist/types.d.ts +102 -65
- package/dist/types.d.ts.map +1 -0
- package/dist/url.d.ts +1 -0
- package/dist/url.d.ts.map +1 -0
- package/dist/verify-webhook.d.ts +28 -17
- package/dist/verify-webhook.d.ts.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/wait-for-transaction.d.ts +81 -54
- package/dist/wait-for-transaction.d.ts.map +1 -0
- package/dist/webhook-events.d.ts +27 -44
- package/dist/webhook-events.d.ts.map +1 -0
- package/package.json +30 -103
- package/dist/auth/client.d.ts +0 -113
- package/dist/auth/live.d.ts +0 -4366
- package/dist/auth.js +0 -329
- package/dist/bundler.js +0 -99
- package/dist/chunk-9k284df4.js +0 -4
- package/dist/chunk-def7rqy6.js +0 -946
- package/dist/chunk-f4t1bm86.js +0 -67
- package/dist/chunk-fjnq61hj.js +0 -11
- package/dist/chunk-h12fatty.js +0 -63
- package/dist/chunk-kddq0nmb.js +0 -260
- package/dist/chunk-r0vsftj4.js +0 -102
- package/dist/chunk-tmk1f2yb.js +0 -33
- package/dist/chunk-y0d2c7kp.js +0 -54
- package/dist/client/conditional-request.d.ts +0 -30
- package/dist/client/factory.d.ts +0 -14
- package/dist/client/query-serializer.d.ts +0 -2
- package/dist/client/request-compression.d.ts +0 -47
- package/dist/client/ssr-fetch.d.ts +0 -12
- package/dist/effect.d.ts +0 -69
- package/dist/effect.js +0 -82
- package/dist/errors/api-error.d.ts +0 -29
- package/dist/errors/find-current-error.d.ts +0 -8
- package/dist/errors/sdk-error.d.ts +0 -52
- package/dist/errors/sdk-error.js +0 -8
- package/dist/generated/api-types.d.ts +0 -41271
- package/dist/generated/response-scalars.d.ts +0 -9
- package/dist/generated/routes.d.ts +0 -12
- package/dist/proxy/builder.d.ts +0 -47
- package/dist/proxy/client.d.ts +0 -32
- package/dist/proxy/fetch-executor.d.ts +0 -28
- package/dist/proxy/flat-args.d.ts +0 -51
- package/dist/proxy/settlement.d.ts +0 -67
- package/dist/proxy/sse.d.ts +0 -54
- package/dist/proxy/tanstack.d.ts +0 -27
- package/dist/proxy/transport.d.ts +0 -73
- package/dist/react-query.d.ts +0 -16
- package/dist/react-query.js +0 -13
- package/dist/readonly-deep.d.ts +0 -12
- package/dist/reads-as-funding-paused.d.ts +0 -20
- package/dist/routes/index.d.ts +0 -20
- package/dist/routes/index.js +0 -10
- package/dist/routes/types.d.ts +0 -51
- package/dist/runtime-exports.d.ts +0 -20
- package/dist/runtime-exports.js +0 -16
- package/dist/scalars/big-decimal.d.ts +0 -16
- package/dist/scalars/ethereum-address.d.ts +0 -20
- package/dist/scalars/exchange-rates.d.ts +0 -27
- package/dist/scalars/index.d.ts +0 -18
- package/dist/scalars/index.js +0 -86
- package/dist/scalars/organization-id.d.ts +0 -20
- package/dist/secret.d.ts +0 -14
- package/dist/sign-webhook-receipt.d.ts +0 -76
- package/dist/sign-webhook-receipt.js +0 -26
- package/dist/transport/cookie-store.d.ts +0 -9
- package/dist/transport/sse-lifecycle.d.ts +0 -44
- package/dist/verify-webhook.js +0 -8
- package/dist/wait-for-transaction.js +0 -120
package/README.md
CHANGED
|
@@ -1,191 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://github.com/settlemint/sdk/blob/main/logo.svg" width="200px" align="center" alt="SettleMint logo" />
|
|
3
|
+
<h1 align="center">DALP SDK</h1>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="https://settlemint.com">https://settlemint.com</a>
|
|
6
|
+
<br/>
|
|
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
|
+
```
|
|
12
38
|
|
|
13
|
-
##
|
|
39
|
+
## Quick Start
|
|
14
40
|
|
|
15
|
-
```
|
|
41
|
+
```typescript
|
|
16
42
|
import { createDalpClient } from "@settlemint/dalp-sdk";
|
|
17
43
|
|
|
18
44
|
const dalp = createDalpClient({
|
|
19
|
-
|
|
45
|
+
url: "https://dalp.example.com",
|
|
20
46
|
apiKey: "sm_dalp_...",
|
|
47
|
+
organizationId: "org_...", // optional, for multi-org setups
|
|
21
48
|
});
|
|
22
49
|
|
|
23
|
-
|
|
50
|
+
// Every method is fully typed with auto-complete
|
|
51
|
+
const tokens = await dalp.token.list({ query: {} });
|
|
52
|
+
const system = await dalp.system.read({});
|
|
24
53
|
```
|
|
25
54
|
|
|
26
|
-
|
|
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.
|
|
55
|
+
## Auth Client
|
|
31
56
|
|
|
32
|
-
`
|
|
33
|
-
|
|
34
|
-
`executor`, `chainId`, `selectedSigners`, `idempotencyKey`), conditional
|
|
35
|
-
`If-None-Match` reuse, custom fetch injection, the settlement bound, and abort
|
|
36
|
-
propagation.
|
|
57
|
+
Use `createDalpAuthClient` for Better Auth operations such as sign-up, session listing, organization management, API
|
|
58
|
+
keys, device authorization, and wallet verification setup.
|
|
37
59
|
|
|
38
|
-
|
|
39
|
-
|
|
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.
|
|
60
|
+
```typescript
|
|
61
|
+
import { createDalpAuthClient } from "@settlemint/dalp-sdk";
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
const auth = createDalpAuthClient({
|
|
64
|
+
url: "https://dalp.example.com",
|
|
65
|
+
apiKey: "sm_dalp_...",
|
|
66
|
+
organizationId: "org_...",
|
|
67
|
+
});
|
|
48
68
|
|
|
49
|
-
|
|
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();
|
|
69
|
+
const apiKeys = await auth.apiKey.list();
|
|
89
70
|
```
|
|
90
71
|
|
|
91
|
-
|
|
72
|
+
For Node-side session flows, use the platform client. It keeps Better Auth cookies in an SDK-owned store and exposes the
|
|
73
|
+
DAPI client and auth client together.
|
|
92
74
|
|
|
93
|
-
```
|
|
94
|
-
import {
|
|
75
|
+
```typescript
|
|
76
|
+
import { createDalpPlatformClient } from "@settlemint/dalp-sdk";
|
|
95
77
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
The same routes, returning `Effect` values that fail with `DalpRequestError`
|
|
101
|
-
rather than throwing. `execute` is typed by route id here too.
|
|
78
|
+
const platform = createDalpPlatformClient({
|
|
79
|
+
url: "https://dalp.example.com",
|
|
80
|
+
});
|
|
102
81
|
|
|
103
|
-
|
|
82
|
+
await platform.auth.signUp.email({
|
|
83
|
+
email: "user@example.com",
|
|
84
|
+
password: "Password123!",
|
|
85
|
+
name: "Example User",
|
|
86
|
+
});
|
|
104
87
|
|
|
105
|
-
|
|
106
|
-
import { routeIds, routeTable } from "@settlemint/dalp-sdk/routes";
|
|
88
|
+
const sessionCookie = platform.cookieStore.header;
|
|
107
89
|
```
|
|
108
90
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
91
|
+
### Auth Namespaces
|
|
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" });
|
|
119
117
|
```
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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";
|
|
119
|
+
```typescript
|
|
120
|
+
// Enable wallet pincode protection
|
|
121
|
+
await auth.wallet.pincode.enable({ pincode: "1234", password: "..." });
|
|
148
122
|
```
|
|
149
123
|
|
|
150
|
-
|
|
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.
|
|
124
|
+
## Configuration
|
|
157
125
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
package imports zod at runtime.
|
|
126
|
+
```typescript
|
|
127
|
+
import { createDalpClient } from "@settlemint/dalp-sdk";
|
|
161
128
|
|
|
162
|
-
|
|
129
|
+
const dalp = createDalpClient({
|
|
130
|
+
// Required
|
|
131
|
+
url: "https://dalp.example.com",
|
|
163
132
|
|
|
164
|
-
|
|
165
|
-
|
|
133
|
+
// Required for authenticated routes
|
|
134
|
+
apiKey: "sm_dalp_...",
|
|
135
|
+
|
|
136
|
+
// Optional
|
|
137
|
+
organizationId: "org_...", // multi-org scoping
|
|
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
144
|
```
|
|
167
145
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
146
|
+
## API Namespaces
|
|
147
|
+
|
|
148
|
+
| Namespace | Description |
|
|
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
|
+
```
|
|
171
191
|
|
|
172
|
-
##
|
|
192
|
+
## Security
|
|
173
193
|
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
-
-
|
|
177
|
-
|
|
178
|
-
through the client already waits.
|
|
194
|
+
- **API key authentication** — issued via the DALP dashboard (Settings → API Keys) or via `dalp login`
|
|
195
|
+
- Public routes can be called without an API key; authenticated routes still require one
|
|
196
|
+
- Security headers (`x-api-key`, `x-organization-id`) cannot be overridden by custom headers
|
|
197
|
+
- Client-side request validation can be enabled to catch schema violations early
|
|
179
198
|
|
|
180
|
-
##
|
|
199
|
+
## Errors
|
|
181
200
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
calls routes never pays for auth, bundler, TanStack Query, or webhook code.
|
|
201
|
+
DAPI errors thrown by the SDK use `DalpSdkError` and include `message`, `why`, `fix`, `status`, `retryable`, and the
|
|
202
|
+
public DAPI error id when the server returns one.
|
|
185
203
|
|
|
186
|
-
##
|
|
204
|
+
## License
|
|
187
205
|
|
|
188
|
-
|
|
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.
|
|
206
|
+
This project is licensed under the **SettleMint Commercial Customer Source License**. See the LICENSE file included in the package for full terms.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Client-side Better Auth access-control metadata for DALP auth clients.
|
|
3
3
|
*
|
|
4
|
-
* Related: packages/
|
|
4
|
+
* Related: packages/dalp/auth/src/utils/permissions.ts, kit/sdk/src/auth.ts
|
|
5
5
|
*
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
@@ -10,3 +10,4 @@ export declare const accessControl: AccessControl;
|
|
|
10
10
|
export declare const adminRole: Role;
|
|
11
11
|
export declare const ownerRole: Role;
|
|
12
12
|
export declare const memberRole: Role;
|
|
13
|
+
//# sourceMappingURL=auth-permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-permissions.d.ts","sourceRoot":"","sources":["../src/auth-permissions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,IAAI,EAAuB,MAAM,4BAA4B,CAAC;AAuBhG,eAAO,MAAM,aAAa,EAAE,aAI1B,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,IAOtB,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,IAMtB,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,IAKvB,CAAC"}
|
|
@@ -1,69 +1,3 @@
|
|
|
1
|
-
import type { DalpAuthResult } from "./client.ts";
|
|
2
|
-
export type WalletAuthOperation<TInput, TData> = (input: TInput, options?: unknown) => Promise<DalpAuthResult<TData>>;
|
|
3
|
-
/** Typed client actions supplied by the three DALP wallet-auth plugins. */
|
|
4
|
-
export interface DalpWalletAuthClient {
|
|
5
|
-
readonly wallet: {
|
|
6
|
-
readonly pincode: {
|
|
7
|
-
readonly enable: WalletAuthOperation<{
|
|
8
|
-
readonly pincode: string;
|
|
9
|
-
readonly password?: string;
|
|
10
|
-
}, {
|
|
11
|
-
readonly success: boolean;
|
|
12
|
-
}>;
|
|
13
|
-
readonly update: WalletAuthOperation<{
|
|
14
|
-
readonly newPincode: string;
|
|
15
|
-
readonly password: string;
|
|
16
|
-
}, {
|
|
17
|
-
readonly success: boolean;
|
|
18
|
-
}>;
|
|
19
|
-
readonly disable: WalletAuthOperation<{
|
|
20
|
-
readonly password: string;
|
|
21
|
-
}, {
|
|
22
|
-
readonly success: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
readonly reset: WalletAuthOperation<{
|
|
25
|
-
readonly newPincode: string;
|
|
26
|
-
readonly recoveryCode: string;
|
|
27
|
-
}, {
|
|
28
|
-
readonly success: boolean;
|
|
29
|
-
readonly recoveryCodes?: ReadonlyArray<string>;
|
|
30
|
-
}>;
|
|
31
|
-
};
|
|
32
|
-
readonly twoFactor: {
|
|
33
|
-
readonly enable: WalletAuthOperation<{
|
|
34
|
-
readonly issuer?: string;
|
|
35
|
-
readonly password?: string;
|
|
36
|
-
}, {
|
|
37
|
-
readonly totpURI: string;
|
|
38
|
-
}>;
|
|
39
|
-
readonly verify: WalletAuthOperation<{
|
|
40
|
-
readonly code: string;
|
|
41
|
-
}, {
|
|
42
|
-
readonly status: boolean;
|
|
43
|
-
}>;
|
|
44
|
-
readonly disable: WalletAuthOperation<{
|
|
45
|
-
readonly password: string;
|
|
46
|
-
}, {
|
|
47
|
-
readonly status: boolean;
|
|
48
|
-
}>;
|
|
49
|
-
};
|
|
50
|
-
readonly secretCodes: {
|
|
51
|
-
readonly generate: WalletAuthOperation<{
|
|
52
|
-
readonly password?: string;
|
|
53
|
-
}, {
|
|
54
|
-
readonly rotated: boolean;
|
|
55
|
-
readonly secretCodes: ReadonlyArray<string>;
|
|
56
|
-
readonly verificationId: string;
|
|
57
|
-
}>;
|
|
58
|
-
readonly confirm: WalletAuthOperation<{
|
|
59
|
-
readonly stored: boolean;
|
|
60
|
-
readonly verificationId: string;
|
|
61
|
-
}, {
|
|
62
|
-
readonly success: boolean;
|
|
63
|
-
}>;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
1
|
export declare const walletPincodeClient: () => {
|
|
68
2
|
id: "wallet-pincode";
|
|
69
3
|
$InferServerPlugin: {
|
|
@@ -144,7 +78,9 @@ export declare const walletSecretCodesClient: () => {
|
|
|
144
78
|
signal: "$sessionSignal";
|
|
145
79
|
}[];
|
|
146
80
|
};
|
|
147
|
-
|
|
148
|
-
|
|
81
|
+
type StripLeadingSlash<T extends string> = T extends `/${infer Rest}` ? Rest : never;
|
|
82
|
+
type WalletPluginPathMethodKeys = keyof ReturnType<typeof walletPincodeClient>["pathMethods"] | keyof ReturnType<typeof walletTwoFactorClient>["pathMethods"] | keyof ReturnType<typeof walletSecretCodesClient>["pathMethods"];
|
|
149
83
|
/** CLI coverage keys for DALP wallet Better Auth plugin endpoints (no leading slash). */
|
|
150
|
-
export type WalletAuthEndpointPath = StripLeadingSlash<WalletPluginPathMethodKeys>;
|
|
84
|
+
export type WalletAuthEndpointPath = StripLeadingSlash<WalletPluginPathMethodKeys & string>;
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=auth-wallet-plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-wallet-plugins.d.ts","sourceRoot":"","sources":["../src/auth-wallet-plugins.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBK,CAAC;AAEtC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;CAoBG,CAAC;AAEtC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;CAmBC,CAAC;AAEtC,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,EAAE,GAAG,IAAI,GAAG,KAAK,CAAC;AAErF,KAAK,0BAA0B,GAC3B,MAAM,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,aAAa,CAAC,GAC3D,MAAM,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,aAAa,CAAC,GAC7D,MAAM,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC,aAAa,CAAC,CAAC;AAEpE,yFAAyF;AACzF,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,0BAA0B,GAAG,MAAM,CAAC,CAAC"}
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,22 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { DalpCookieStore } from "./cookie-store.js";
|
|
2
|
+
export interface DalpAuthClientConfig {
|
|
3
|
+
/** Base URL of the DALP API (e.g., `"https://dalp.example.com"`). */
|
|
4
|
+
url: string;
|
|
5
|
+
/** API key used for Better Auth API-key-authenticated operations. */
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/** Better Auth session token sent as an Authorization bearer token. */
|
|
8
|
+
sessionToken?: string;
|
|
9
|
+
/** Cookie header value for explicit Node/browser-session handoff. */
|
|
10
|
+
cookie?: string;
|
|
11
|
+
/** Cookie store for Node-side session persistence across Better Auth calls. */
|
|
12
|
+
cookieStore?: DalpCookieStore;
|
|
13
|
+
/**
|
|
14
|
+
* Organization ID for multi-tenant setups.
|
|
15
|
+
* Sent as `x-organization-id` when provided.
|
|
16
|
+
*/
|
|
17
|
+
organizationId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Additional headers merged into every Better Auth request.
|
|
20
|
+
* Can override defaults like `User-Agent` but cannot override configured security headers.
|
|
21
|
+
*/
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Custom `fetch` implementation.
|
|
25
|
+
* Use this to inject logging, proxy configuration, or test doubles.
|
|
26
|
+
*/
|
|
27
|
+
fetch?: typeof globalThis.fetch;
|
|
28
|
+
}
|
|
29
|
+
export interface DalpAuthError {
|
|
30
|
+
code?: string;
|
|
31
|
+
message?: string;
|
|
32
|
+
status?: number;
|
|
33
|
+
statusText?: string;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface DalpAuthResult<TData = unknown, TError = DalpAuthError> {
|
|
37
|
+
data: TData | null;
|
|
38
|
+
error: TError | null;
|
|
39
|
+
}
|
|
40
|
+
export type DalpAuthOperation<TInput = Record<string, unknown>, TData = unknown> = (input?: TInput, options?: unknown) => Promise<DalpAuthResult<TData>>;
|
|
41
|
+
export interface DalpAuthClient {
|
|
42
|
+
signIn: Record<string, DalpAuthOperation> & {
|
|
43
|
+
email: DalpAuthOperation;
|
|
44
|
+
};
|
|
45
|
+
signUp: Record<string, DalpAuthOperation> & {
|
|
46
|
+
email: DalpAuthOperation;
|
|
47
|
+
};
|
|
48
|
+
getSession: DalpAuthOperation;
|
|
49
|
+
listSessions: DalpAuthOperation;
|
|
50
|
+
revokeSession: DalpAuthOperation;
|
|
51
|
+
revokeOtherSessions: DalpAuthOperation;
|
|
52
|
+
apiKey: Record<string, DalpAuthOperation> & {
|
|
53
|
+
create: DalpAuthOperation;
|
|
54
|
+
list: DalpAuthOperation;
|
|
55
|
+
delete: DalpAuthOperation;
|
|
56
|
+
};
|
|
57
|
+
organization: Record<string, DalpAuthOperation> & {
|
|
58
|
+
create: DalpAuthOperation;
|
|
59
|
+
list: DalpAuthOperation;
|
|
60
|
+
setActive: DalpAuthOperation;
|
|
61
|
+
inviteMember: DalpAuthOperation;
|
|
62
|
+
acceptInvitation: DalpAuthOperation;
|
|
63
|
+
listMembers: DalpAuthOperation;
|
|
64
|
+
addMember: DalpAuthOperation;
|
|
65
|
+
removeMember: DalpAuthOperation;
|
|
66
|
+
};
|
|
67
|
+
admin: Record<string, DalpAuthOperation> & {
|
|
68
|
+
listUsers: DalpAuthOperation;
|
|
69
|
+
createUser: DalpAuthOperation;
|
|
70
|
+
removeUser: DalpAuthOperation;
|
|
71
|
+
setRole: DalpAuthOperation;
|
|
72
|
+
};
|
|
73
|
+
device: Record<string, DalpAuthOperation> & {
|
|
74
|
+
code: DalpAuthOperation;
|
|
75
|
+
token: DalpAuthOperation;
|
|
76
|
+
approve: DalpAuthOperation;
|
|
77
|
+
deny: DalpAuthOperation;
|
|
78
|
+
};
|
|
79
|
+
passkey: Record<string, DalpAuthOperation>;
|
|
80
|
+
twoFactor: Record<string, DalpAuthOperation> & {
|
|
81
|
+
enable: DalpAuthOperation;
|
|
82
|
+
disable: DalpAuthOperation;
|
|
83
|
+
verifyTotp: DalpAuthOperation;
|
|
84
|
+
verifyBackupCode: DalpAuthOperation;
|
|
85
|
+
generateBackupCodes: DalpAuthOperation;
|
|
86
|
+
};
|
|
87
|
+
wallet: {
|
|
88
|
+
pincode: {
|
|
89
|
+
enable: DalpAuthOperation;
|
|
90
|
+
disable: DalpAuthOperation;
|
|
91
|
+
update: DalpAuthOperation;
|
|
92
|
+
reset: DalpAuthOperation;
|
|
93
|
+
};
|
|
94
|
+
twoFactor: {
|
|
95
|
+
enable: DalpAuthOperation;
|
|
96
|
+
disable: DalpAuthOperation;
|
|
97
|
+
verify: DalpAuthOperation;
|
|
98
|
+
};
|
|
99
|
+
secretCodes: {
|
|
100
|
+
generate: DalpAuthOperation;
|
|
101
|
+
confirm: DalpAuthOperation;
|
|
102
|
+
};
|
|
103
|
+
passkey: {
|
|
104
|
+
register: DalpAuthOperation;
|
|
105
|
+
complete: DalpAuthOperation;
|
|
106
|
+
disable: DalpAuthOperation;
|
|
107
|
+
challenge: DalpAuthOperation;
|
|
108
|
+
verify: DalpAuthOperation;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
$fetch: (path: string, options?: Record<string, unknown>) => Promise<unknown>;
|
|
112
|
+
$ERROR_CODES: Record<string, unknown>;
|
|
113
|
+
}
|
|
114
|
+
export declare function createDalpAuthClient(config: DalpAuthClientConfig): DalpAuthClient;
|
|
115
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAoBA,OAAO,EAA0B,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAK5E,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,GAAG,EAAE,MAAM,CAAC;IAEZ,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAA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