@settlemint/dalp-sdk 3.1.5-main.32670705612 → 3.1.5-release.32679963579

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.
Files changed (109) hide show
  1. package/README.md +177 -111
  2. package/dist/{auth/permissions.d.ts → auth-permissions.d.ts} +2 -1
  3. package/dist/auth-permissions.d.ts.map +1 -0
  4. package/dist/{auth/wallet-plugins.d.ts → auth-wallet-plugins.d.ts} +5 -69
  5. package/dist/auth-wallet-plugins.d.ts.map +1 -0
  6. package/dist/auth.d.ts +115 -22
  7. package/dist/auth.d.ts.map +1 -0
  8. package/dist/bundler.d.ts +207 -17
  9. package/dist/bundler.d.ts.map +1 -0
  10. package/dist/chunk-xm8h1dzh.js +33 -0
  11. package/dist/client.d.ts +19 -0
  12. package/dist/client.d.ts.map +1 -0
  13. package/dist/contract-errors.d.ts +4156 -0
  14. package/dist/contract-errors.d.ts.map +1 -0
  15. package/dist/contract.d.ts +17 -0
  16. package/dist/contract.d.ts.map +1 -0
  17. package/dist/cookie-store.d.ts +10 -0
  18. package/dist/cookie-store.d.ts.map +1 -0
  19. package/dist/dapi-errors.d.ts +650 -0
  20. package/dist/dapi-errors.d.ts.map +1 -0
  21. package/dist/errors.d.ts +633 -0
  22. package/dist/errors.d.ts.map +1 -0
  23. package/dist/index.d.ts +40 -23
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +96013 -208
  26. package/dist/platform.d.ts +41 -0
  27. package/dist/platform.d.ts.map +1 -0
  28. package/dist/plugins/index.d.ts +13 -0
  29. package/dist/plugins/index.d.ts.map +1 -0
  30. package/dist/plugins/index.js +10 -0
  31. package/dist/sdk-error.d.ts +74 -0
  32. package/dist/sdk-error.d.ts.map +1 -0
  33. package/dist/serializers.d.ts +41 -0
  34. package/dist/serializers.d.ts.map +1 -0
  35. package/dist/types.d.ts +104 -57
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/url.d.ts +1 -0
  38. package/dist/url.d.ts.map +1 -0
  39. package/dist/verify-webhook.d.ts +28 -17
  40. package/dist/verify-webhook.d.ts.map +1 -0
  41. package/dist/version.d.ts +1 -0
  42. package/dist/version.d.ts.map +1 -0
  43. package/dist/wait-for-transaction.d.ts +86 -37
  44. package/dist/wait-for-transaction.d.ts.map +1 -0
  45. package/dist/webhook-events.d.ts +26 -43
  46. package/dist/webhook-events.d.ts.map +1 -0
  47. package/package.json +29 -91
  48. package/dist/auth/client.d.ts +0 -99
  49. package/dist/auth/live.d.ts +0 -4366
  50. package/dist/auth.js +0 -248
  51. package/dist/bundler.js +0 -111
  52. package/dist/chunk-6zx7kn5t.js +0 -40273
  53. package/dist/chunk-cy9b59s6.js +0 -503
  54. package/dist/chunk-h12fatty.js +0 -63
  55. package/dist/chunk-k14jpms5.js +0 -249
  56. package/dist/chunk-r0vsftj4.js +0 -102
  57. package/dist/chunk-w21k7p99.js +0 -843
  58. package/dist/chunk-wx236z2x.js +0 -12300
  59. package/dist/chunk-y0d2c7kp.js +0 -54
  60. package/dist/client/conditional-request.d.ts +0 -16
  61. package/dist/client/factory.d.ts +0 -39
  62. package/dist/client/query-serializer.d.ts +0 -2
  63. package/dist/client/request-compression.d.ts +0 -47
  64. package/dist/client/ssr-fetch.d.ts +0 -12
  65. package/dist/errors/api-error.d.ts +0 -29
  66. package/dist/errors/find-current-error.d.ts +0 -8
  67. package/dist/errors/sdk-error.d.ts +0 -47
  68. package/dist/errors/sdk-error.js +0 -8
  69. package/dist/generated/@tanstack/react-query.gen.d.ts +0 -18693
  70. package/dist/generated/client/client.gen.d.ts +0 -2
  71. package/dist/generated/client/index.d.ts +0 -10
  72. package/dist/generated/client/types.gen.d.ts +0 -120
  73. package/dist/generated/client/utils.gen.d.ts +0 -37
  74. package/dist/generated/client.gen.d.ts +0 -12
  75. package/dist/generated/core/auth.gen.d.ts +0 -25
  76. package/dist/generated/core/bodySerializer.gen.d.ts +0 -25
  77. package/dist/generated/core/params.gen.d.ts +0 -43
  78. package/dist/generated/core/pathSerializer.gen.d.ts +0 -33
  79. package/dist/generated/core/queryKeySerializer.gen.d.ts +0 -18
  80. package/dist/generated/core/serverSentEvents.gen.d.ts +0 -71
  81. package/dist/generated/core/types.gen.d.ts +0 -83
  82. package/dist/generated/core/utils.gen.d.ts +0 -19
  83. package/dist/generated/index.d.ts +0 -2
  84. package/dist/generated/sdk.gen.d.ts +0 -4883
  85. package/dist/generated/transformers.gen.d.ts +0 -40
  86. package/dist/generated/types.gen.d.ts +0 -121889
  87. package/dist/generated/zod.gen.d.ts +0 -163107
  88. package/dist/operations.d.ts +0 -12
  89. package/dist/operations.js +0 -1635
  90. package/dist/react-query.d.ts +0 -11
  91. package/dist/react-query.js +0 -15315
  92. package/dist/readonly-deep.d.ts +0 -12
  93. package/dist/runtime-exports.d.ts +0 -20
  94. package/dist/runtime-exports.js +0 -16
  95. package/dist/scalars/big-decimal.d.ts +0 -12
  96. package/dist/scalars/ethereum-address.d.ts +0 -8
  97. package/dist/scalars/exchange-rates.d.ts +0 -36
  98. package/dist/scalars/index.d.ts +0 -15
  99. package/dist/scalars/index.js +0 -35
  100. package/dist/scalars/organization-id.d.ts +0 -8
  101. package/dist/schemas.d.ts +0 -10
  102. package/dist/schemas.js +0 -11070
  103. package/dist/secret.d.ts +0 -14
  104. package/dist/sign-webhook-receipt.d.ts +0 -76
  105. package/dist/sign-webhook-receipt.js +0 -26
  106. package/dist/transport/cookie-store.d.ts +0 -9
  107. package/dist/transport/sse-lifecycle.d.ts +0 -44
  108. package/dist/verify-webhook.js +0 -8
  109. package/dist/wait-for-transaction.js +0 -112
package/README.md CHANGED
@@ -1,140 +1,206 @@
1
- # DALP SDK
2
-
3
- The DALP SDK is a Promise-based client generated from the canonical v2 OpenAPI
4
- declaration ([Hey API](https://heyapi.dev/)), validated at runtime with
5
- [zod](https://zod.dev/). It is Effect-free: no `Effect` values, no branded
6
- Effect Schema identifiers on the wire.
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>&nbsp;&nbsp;&bull;&nbsp;&nbsp;</span>
19
+ <a href="https://www.npmjs.com/package/@settlemint/dalp-sdk">NPM</a>
20
+ <span>&nbsp;&nbsp;&bull;&nbsp;&nbsp;</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
+ ```
7
38
 
8
- ## Client
39
+ ## Quick Start
9
40
 
10
- ```ts
41
+ ```typescript
11
42
  import { createDalpClient } from "@settlemint/dalp-sdk";
12
43
 
13
44
  const dalp = createDalpClient({
14
- baseUrl: "https://dalp.example.com",
45
+ url: "https://dalp.example.com",
15
46
  apiKey: "sm_dalp_...",
47
+ organizationId: "org_...", // optional, for multi-org setups
16
48
  });
17
49
 
18
- const tokens = await dalp.token.list({ query: {} }, { signal });
50
+ // Every method is fully typed with auto-complete
51
+ const tokens = await dalp.token.list({ query: {} });
52
+ const system = await dalp.system.read({});
19
53
  ```
20
54
 
21
- `createDalpClient` owns shared transport policy once: the credential mechanism
22
- (session cookie in the browser and on SSR, or an `X-Api-Key` header for
23
- server/CLI callers — never both from the same runtime), organization headers,
24
- idempotency keys, `Prefer`, conditional `If-None-Match` / ETag reuse, custom fetch
25
- injection, and abort propagation. See the "Credential ownership matrix" JSDoc
26
- on `createDalpClient` in `src/client/factory.ts` for which runtime may use
27
- which credential.
55
+ ## Auth Client
28
56
 
29
- Response decoding is strict: every generated operation parses its response
30
- against the declared zod schema and throws on a mismatch.
57
+ Use `createDalpAuthClient` for Better Auth operations such as sign-up, session listing, organization management, API
58
+ keys, device authorization, and wallet verification setup.
31
59
 
32
- ### Conditional requests and ETags
60
+ ```typescript
61
+ import { createDalpAuthClient } from "@settlemint/dalp-sdk";
33
62
 
34
- `createDalpClient` installs `If-None-Match` / 304 interceptors that reuse a
35
- held body when the server returns a matching ETag. Server ETags must be
36
- **strong content digests** computed **after authorization** inside the
37
- requester's partition. The dapi response cache guarantees this: it hashes the
38
- serialized body after the request-context middleware has authenticated the
39
- session. Version-stamp ETags (generation counters, watermarks, table versions)
40
- are forbidden for conditional-request adopters — a stamp can collide across
41
- tenants or lag a body change.
63
+ const auth = createDalpAuthClient({
64
+ url: "https://dalp.example.com",
65
+ apiKey: "sm_dalp_...",
66
+ organizationId: "org_...",
67
+ });
42
68
 
43
- Identity changes that do not ride this client (browser sign-out, organization
44
- switch) must call `clearConditionalRequestStore(client)` so a later GET cannot
45
- send another session's `If-None-Match`.
69
+ const apiKeys = await auth.apiKey.list();
70
+ ```
46
71
 
47
- ```ts
48
- import { clearConditionalRequestStore, createDalpClient } from "@settlemint/dalp-sdk";
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.
49
74
 
50
- clearConditionalRequestStore(dalp);
51
- ```
75
+ ```typescript
76
+ import { createDalpPlatformClient } from "@settlemint/dalp-sdk";
52
77
 
53
- ## Generated operations
78
+ const platform = createDalpPlatformClient({
79
+ url: "https://dalp.example.com",
80
+ });
81
+
82
+ await platform.auth.signUp.email({
83
+ email: "user@example.com",
84
+ password: "Password123!",
85
+ name: "Example User",
86
+ });
54
87
 
55
- ```ts
56
- import { createClient } from "@settlemint/dalp-sdk/operations";
88
+ const sessionCookie = platform.cookieStore.header;
57
89
  ```
58
90
 
59
- `./operations` re-exports the generated v2 operation functions and generated
60
- client primitives (585 operations) on their own subpath, so a consumer who
61
- only signs webhooks or builds a client never loads that module. Pair it with
62
- `createDalpClient` from the package root.
63
-
64
- ## Scalars
65
-
66
- Custom wire formats — BigDecimal amounts, EVM addresses, and the
67
- `OrganizationId` entity brand — are not expressed structurally in the
68
- generated OpenAPI spec (it carries no `format:`/`x-` extension for them), so
69
- each has a hand-maintained wrapper under `src/scalars/`:
70
- `big-decimal.ts`, `ethereum-address.ts`, `exchange-rates.ts`,
71
- `organization-id.ts`. `OrganizationId` is the only entity ID branded
72
- end-to-end across the platform (see `AGENTS.md`); every other identifier
73
- crossing this SDK's boundary is a plain string. `tools/scripts/src/check-sdk-scalar-coverage.ts`
74
- gates new generated scalar-shaped symbols against a curated allowlist so a
75
- spec change that introduces a new custom scalar fails the build instead of
76
- shipping unwrapped.
77
-
78
- ## React Query
79
-
80
- ```ts
81
- import { tokenListOptions } from "@settlemint/dalp-sdk/react-query";
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" });
82
117
  ```
83
118
 
84
- `./react-query` re-exports the generated TanStack Query option factories
85
- (`queryOptions`, `infiniteOptions`, `mutationOptions`) — spread into your own
86
- hooks; the generator emits no hooks itself. This is the only module that
87
- imports `@tanstack/react-query`, so that peer dependency stays optional for
88
- non-React consumers.
119
+ ```typescript
120
+ // Enable wallet pincode protection
121
+ await auth.wallet.pincode.enable({ pincode: "1234", password: "..." });
122
+ ```
89
123
 
90
- ## Auth
124
+ ## Configuration
91
125
 
92
- ```ts
93
- import { createDalpAuthClient } from "@settlemint/dalp-sdk/auth";
94
- ```
126
+ ```typescript
127
+ import { createDalpClient } from "@settlemint/dalp-sdk";
128
+
129
+ const dalp = createDalpClient({
130
+ // Required
131
+ url: "https://dalp.example.com",
95
132
 
96
- The generated SDK already exposes every auth REST operation; `./auth` covers
97
- what a REST call cannot express — the session/cookie state machine, plugin
98
- actions that must run in the browser (`passkeyClient` drives the WebAuthn
99
- ceremony through `navigator.credentials`), and the access-control model that
100
- evaluates a permission locally instead of round-tripping `has-permission`. Off
101
- the package root because it costs roughly 70 KiB of Better Auth a
102
- pure-operations consumer should not pay.
133
+ // Required for authenticated routes
134
+ apiKey: "sm_dalp_...",
103
135
 
104
- ## Bundler and paymaster
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
+ });
144
+ ```
105
145
 
106
- ```ts
107
- import { createDalpBundlerClient } from "@settlemint/dalp-sdk/bundler";
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";
108
190
  ```
109
191
 
110
- `createDalpBundlerClient` retains the eight established ERC-4337 method names
111
- while calling the generated v2 REST resources underneath. The SDK accepts
112
- EntryPoint v0.9 `viem` shapes and returns the corresponding typed values.
113
-
114
- ## Webhooks and transaction wait
115
-
116
- - `./verify-webhook` — verify an inbound webhook signature.
117
- - `./sign-webhook-receipt` — sign a webhook delivery receipt (Node-only).
118
- - `./wait-for-transaction` — bounded poll for on-chain transaction settlement;
119
- calls a generated operation and so inherits the generated validator
120
- module's full weight.
121
-
122
- ## Package root
123
-
124
- The package root (`@settlemint/dalp-sdk`) stays deliberately small — the
125
- client factory, its config and errors, cookie-store transport, SSE lifecycle
126
- handling, and SDK version constants — so a consumer
127
- who only needs to call operations never pays for auth, bundler, react-query,
128
- or webhook code. See the `@module` doc at the top of `src/index.ts` for the
129
- current weight breakdown per subpath.
130
-
131
- ## Migrating from the Effect client
132
-
133
- Prior major versions exposed an `Effect`-returning client
134
- (`makeDalpEffectClient`, `makeDalpApiLayer`, `DalpEffectClient`) alongside the
135
- Promise client. That dual surface, the `contracts/` schema re-exports, and
136
- `makeDalpPlatformClient`/`waitForTransactionEffect` are removed — see
137
- `CHANGELOG.md` and the
138
- [v2 migration guide](../docs/content/docs/api-reference/reference/v2-migration.mdx).
139
- No published consumer depended on the Effect surface, so this ships without a
140
- major version bump.
192
+ ## Security
193
+
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
198
+
199
+ ## Errors
200
+
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.
203
+
204
+ ## License
205
+
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/dapi/auth/src/utils/permissions.ts, kit/sdk/src/auth/live.ts
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
- export type StripLeadingSlash<T extends string> = T extends `/${infer Rest}` ? Rest : never;
148
- export type WalletPluginPathMethodKeys = keyof ReturnType<typeof walletPincodeClient>["pathMethods"] | keyof ReturnType<typeof walletTwoFactorClient>["pathMethods"] | keyof ReturnType<typeof walletSecretCodesClient>["pathMethods"];
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
- * The DALP Better Auth client, on its own subpath.
3
- *
4
- * The generated SDK already exposes every auth REST operation, so nothing here
5
- * exists to reach an endpoint. This surface exists for the parts a REST call
6
- * cannot express: the session and cookie state machine, the plugin actions that
7
- * run in the browser rather than over HTTP — `passkeyClient` drives the WebAuthn
8
- * ceremony through `navigator.credentials` — and the access-control model that
9
- * evaluates a permission locally instead of round-tripping `has-permission`.
10
- *
11
- * It is held off the package root because it costs roughly 70 KiB of Better
12
- * Auth that a consumer who only calls operations should never pay.
13
- *
14
- * @module
15
- */
16
- export { createDalpAuthClient, makeDalpAuthClient } from "./auth/live.ts";
17
- export type { DalpAuthClient } from "./auth/live.ts";
18
- export { decodeDalpAuthClientConfig } from "./auth/client.ts";
19
- export type { DalpAuthClientConfig,
20
- /** @deprecated Prefer `DalpAuthClient` — this is the typed operation surface, not a separate client. */
21
- DalpCliAuthClient, DalpAuthError, DalpAuthOperation, DalpAuthResult, DalpOrganizationMember, DalpOrganizationMembersQuery, DecodedDalpAuthClientConfig, } from "./auth/client.ts";
22
- export type { WalletAuthEndpointPath } from "./auth/wallet-plugins.ts";
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,CAAC;IAExB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,KAAK,CAAC,E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