@settlemint/dalp-sdk 3.1.11-main.33576239970 → 3.1.11-main.33590924340
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 +126 -84
- package/dist/auth/client.d.ts +2 -4
- package/dist/auth.js +97 -16
- package/dist/bundler.d.ts +0 -3
- package/dist/bundler.js +38 -51
- package/dist/chunk-42msy2x5.js +33 -0
- package/dist/chunk-apc9awed.js +4 -0
- package/dist/chunk-armnnx1b.js +904 -0
- package/dist/chunk-f4t1bm86.js +67 -0
- package/dist/{chunk-bz92thwh.js → chunk-mdegh3gh.js} +19 -14
- package/dist/client/conditional-request.d.ts +20 -6
- package/dist/client/factory.d.ts +10 -35
- package/dist/effect.d.ts +52 -0
- package/dist/effect.js +80 -0
- package/dist/generated/api-types.d.ts +33033 -0
- package/dist/generated/response-scalars.d.ts +9 -0
- package/dist/generated/routes.d.ts +12 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +18 -112
- package/dist/proxy/builder.d.ts +47 -0
- package/dist/proxy/client.d.ts +32 -0
- package/dist/proxy/fetch-executor.d.ts +28 -0
- package/dist/proxy/flat-args.d.ts +51 -0
- package/dist/proxy/settlement.d.ts +49 -0
- package/dist/proxy/sse.d.ts +32 -0
- package/dist/proxy/tanstack.d.ts +27 -0
- package/dist/proxy/transport.d.ts +65 -0
- package/dist/react-query.d.ts +11 -6
- package/dist/react-query.js +9 -16482
- package/dist/routes/index.d.ts +20 -0
- package/dist/routes/index.js +10 -0
- package/dist/routes/types.d.ts +40 -0
- package/dist/scalars/big-decimal.d.ts +10 -10
- package/dist/scalars/ethereum-address.d.ts +18 -6
- package/dist/scalars/exchange-rates.d.ts +24 -33
- package/dist/scalars/index.d.ts +11 -8
- package/dist/scalars/index.js +75 -28
- package/dist/scalars/organization-id.d.ts +18 -6
- package/dist/types.d.ts +7 -9
- package/dist/wait-for-transaction.d.ts +3 -3
- package/dist/wait-for-transaction.js +5 -15
- package/package.json +19 -14
- package/dist/chunk-cy9b59s6.js +0 -503
- package/dist/chunk-gxtczja0.js +0 -45693
- package/dist/chunk-w21k7p99.js +0 -843
- package/dist/chunk-y0cggmp9.js +0 -14542
- package/dist/generated/@tanstack/react-query.gen.d.ts +0 -17380
- package/dist/generated/client/client.gen.d.ts +0 -2
- package/dist/generated/client/index.d.ts +0 -10
- package/dist/generated/client/types.gen.d.ts +0 -120
- package/dist/generated/client/utils.gen.d.ts +0 -37
- package/dist/generated/client.gen.d.ts +0 -12
- package/dist/generated/core/auth.gen.d.ts +0 -25
- package/dist/generated/core/bodySerializer.gen.d.ts +0 -25
- package/dist/generated/core/params.gen.d.ts +0 -43
- package/dist/generated/core/pathSerializer.gen.d.ts +0 -33
- package/dist/generated/core/queryKeySerializer.gen.d.ts +0 -18
- package/dist/generated/core/serverSentEvents.gen.d.ts +0 -71
- package/dist/generated/core/types.gen.d.ts +0 -83
- package/dist/generated/core/utils.gen.d.ts +0 -19
- package/dist/generated/index.d.ts +0 -2
- package/dist/generated/sdk.gen.d.ts +0 -5214
- package/dist/generated/types.gen.d.ts +0 -137258
- package/dist/generated/zod.gen.d.ts +0 -181278
- package/dist/operations.d.ts +0 -12
- package/dist/operations.js +0 -1747
- package/dist/schemas.d.ts +0 -10
- package/dist/schemas.js +0 -12024
package/README.md
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# DALP SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
declaration
|
|
5
|
-
|
|
6
|
-
|
|
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.
|
|
7
12
|
|
|
8
13
|
## Client
|
|
9
14
|
|
|
@@ -15,77 +20,117 @@ const dalp = createDalpClient({
|
|
|
15
20
|
apiKey: "sm_dalp_...",
|
|
16
21
|
});
|
|
17
22
|
|
|
18
|
-
const tokens = await dalp.token.list({
|
|
23
|
+
const tokens = await dalp.api.token.list({ limit: 25 }, { signal });
|
|
24
|
+
```
|
|
25
|
+
|
|
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.
|
|
31
|
+
|
|
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.
|
|
37
|
+
|
|
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.
|
|
42
|
+
|
|
43
|
+
### Dispatch by route id
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const token = await dalp.execute("token/read", { assetId });
|
|
19
47
|
```
|
|
20
48
|
|
|
21
|
-
`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
which credential.
|
|
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
|
|
28
55
|
|
|
29
|
-
|
|
30
|
-
|
|
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.
|
|
31
65
|
|
|
32
66
|
### Conditional requests and ETags
|
|
33
67
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
**
|
|
37
|
-
|
|
38
|
-
|
|
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.
|
|
68
|
+
The client reuses a held body when the server answers a matching ETag with 304.
|
|
69
|
+
Server ETags must be **strong content digests** computed **after
|
|
70
|
+
authorization** inside the requester's partition. Version-stamp ETags
|
|
71
|
+
(generation counters, watermarks, table versions) are forbidden for conditional
|
|
72
|
+
request adopters: a stamp can collide across tenants or lag a body change.
|
|
42
73
|
|
|
43
74
|
Identity changes that do not ride this client (browser sign-out, organization
|
|
44
|
-
switch) must
|
|
45
|
-
|
|
75
|
+
switch) must clear the held bodies, so a later GET cannot send another
|
|
76
|
+
session's `If-None-Match`.
|
|
46
77
|
|
|
47
78
|
```ts
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
clearConditionalRequestStore(dalp);
|
|
79
|
+
dalp.conditionalRequests.clear();
|
|
51
80
|
```
|
|
52
81
|
|
|
53
|
-
##
|
|
82
|
+
## Effect
|
|
54
83
|
|
|
55
84
|
```ts
|
|
56
|
-
import {
|
|
85
|
+
import { createDalpEffectClient } from "@settlemint/dalp-sdk/effect";
|
|
86
|
+
|
|
87
|
+
const dalp = createDalpEffectClient({ baseUrl, apiKey });
|
|
88
|
+
const tokens = yield * dalp.api.token.list({ limit: 25 });
|
|
57
89
|
```
|
|
58
90
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
only signs webhooks or builds a client never loads that module. Pair it with
|
|
62
|
-
`createDalpClient` from the package root.
|
|
91
|
+
The same routes, returning `Effect` values that fail with `DalpRequestError`
|
|
92
|
+
rather than throwing. `execute` is typed by route id here too.
|
|
63
93
|
|
|
64
|
-
##
|
|
94
|
+
## The route table
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { routeIds, routeTable } from "@settlemint/dalp-sdk/routes";
|
|
98
|
+
```
|
|
65
99
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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.
|
|
100
|
+
`./routes` publishes the generated table both interpreters dispatch through:
|
|
101
|
+
every v2 route's id, method, path template, statuses, and traits. It carries no
|
|
102
|
+
client and no Effect, so a tool that only needs to know what the platform
|
|
103
|
+
serves loads this rather than a client.
|
|
77
104
|
|
|
78
|
-
##
|
|
105
|
+
## TanStack Query
|
|
79
106
|
|
|
80
107
|
```ts
|
|
81
|
-
|
|
108
|
+
const options = dalp.api.token.list.queryOptions({ limit: 25 });
|
|
109
|
+
const transfer = dalp.api.token.transfer.mutationOptions();
|
|
82
110
|
```
|
|
83
111
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
112
|
+
Every read node carries `queryOptions`; every write node carries
|
|
113
|
+
`mutationOptions`. They are plain objects in the shapes TanStack
|
|
114
|
+
Query expects, so nothing forces you into that library and nothing stops you
|
|
115
|
+
using something else.
|
|
116
|
+
|
|
117
|
+
Cache keys are derived from route identity plus canonicalized input, so two
|
|
118
|
+
callers passing the same parameters in a different key order share one entry.
|
|
119
|
+
`./react-query` exports `queryKeyFor` and `canonicalize` for building a
|
|
120
|
+
matching invalidation filter, and `UI_SETTLEMENT_TIMEOUT_MS`, the shorter bound
|
|
121
|
+
the mutation factories default to.
|
|
122
|
+
|
|
123
|
+
## Scalars
|
|
124
|
+
|
|
125
|
+
Custom wire formats (BigDecimal amounts, EVM addresses, and the
|
|
126
|
+
`OrganizationId` entity brand) are not expressed structurally in the generated
|
|
127
|
+
OpenAPI document, so `./scalars` carries a decoder for each:
|
|
128
|
+
`decodeBigDecimal`, `decodeEthereumAddress`, `decodeOrganizationId`, and the
|
|
129
|
+
exchange-rate response transformer. The route table names which fields carry a
|
|
130
|
+
scalar, keyed by dotted path, so a consumer applies a decoder where the
|
|
131
|
+
declaration says one lives rather than guessing from a field name.
|
|
132
|
+
`OrganizationId` is the only entity id branded end to end across the platform;
|
|
133
|
+
every other identifier crossing this boundary is a plain string.
|
|
89
134
|
|
|
90
135
|
## Auth
|
|
91
136
|
|
|
@@ -93,13 +138,17 @@ non-React consumers.
|
|
|
93
138
|
import { createDalpAuthClient } from "@settlemint/dalp-sdk/auth";
|
|
94
139
|
```
|
|
95
140
|
|
|
96
|
-
The
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
141
|
+
The route surface already carries every auth REST route. `./auth` covers what a
|
|
142
|
+
REST call cannot express: the session and cookie state machine, plugin actions
|
|
143
|
+
that must run in the browser (`passkeyClient` drives the WebAuthn ceremony
|
|
144
|
+
through `navigator.credentials`), and the access-control model that evaluates a
|
|
145
|
+
permission locally instead of round-tripping. It sits off the package root
|
|
146
|
+
because it costs roughly 70 KiB of Better Auth that a consumer who only calls
|
|
147
|
+
routes should not pay.
|
|
148
|
+
|
|
149
|
+
Better Auth's client types reference zod, so `zod` is an optional peer
|
|
150
|
+
dependency: install it if you use `./auth`, skip it otherwise. No code in this
|
|
151
|
+
package imports zod at runtime.
|
|
103
152
|
|
|
104
153
|
## Bundler and paymaster
|
|
105
154
|
|
|
@@ -107,34 +156,27 @@ pure-operations consumer should not pay.
|
|
|
107
156
|
import { createDalpBundlerClient } from "@settlemint/dalp-sdk/bundler";
|
|
108
157
|
```
|
|
109
158
|
|
|
110
|
-
`createDalpBundlerClient`
|
|
111
|
-
while calling the
|
|
112
|
-
|
|
159
|
+
`createDalpBundlerClient` keeps the eight established ERC-4337 method names
|
|
160
|
+
while calling the v2 REST resources underneath. It accepts EntryPoint v0.9
|
|
161
|
+
`viem` shapes and returns the corresponding typed values.
|
|
113
162
|
|
|
114
163
|
## Webhooks and transaction wait
|
|
115
164
|
|
|
116
|
-
- `./verify-webhook`
|
|
117
|
-
- `./sign-webhook-receipt`
|
|
118
|
-
- `./wait-for-transaction`
|
|
119
|
-
|
|
120
|
-
|
|
165
|
+
- `./verify-webhook` verifies an inbound webhook signature.
|
|
166
|
+
- `./sign-webhook-receipt` signs a webhook delivery receipt (Node only).
|
|
167
|
+
- `./wait-for-transaction` is a bounded poll for on-chain settlement, for a
|
|
168
|
+
transaction id you hold from somewhere other than a client call. A write made
|
|
169
|
+
through the client already waits.
|
|
121
170
|
|
|
122
171
|
## Package root
|
|
123
172
|
|
|
124
|
-
The
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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.
|
|
173
|
+
The root stays small: the client factory, its options and errors, cookie-store
|
|
174
|
+
transport, the settlement types, and the version constants. A consumer who only
|
|
175
|
+
calls routes never pays for auth, bundler, TanStack Query, or webhook code.
|
|
176
|
+
|
|
177
|
+
## Documentation
|
|
178
|
+
|
|
179
|
+
The integrator guide lives under Developer reference in the platform docs:
|
|
180
|
+
install and credentials, calling routes, mutations and settlement, streaming,
|
|
181
|
+
TanStack Query, server rendering in TanStack Start and Next.js, and the Effect
|
|
182
|
+
surface.
|
package/dist/auth/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DalpFetch } from "../client/ssr-fetch.ts";
|
|
2
|
-
import type { AuthGetApiKeyListResponse, AuthGetOrganizationListResponse, AuthPostApiKeyCreateData, AuthPostApiKeyCreateResponse, AuthPostApiKeyDeleteData, AuthPostApiKeyDeleteResponse, AuthPostDeviceApproveData, AuthPostDeviceApproveResponse, AuthPostDeviceDenyData, AuthPostDeviceDenyResponse, AuthPostOrganizationAcceptInvitationData, AuthPostOrganizationAcceptInvitationResponse, AuthPostOrganizationCreateData, AuthPostOrganizationCreateResponse, AuthPostOrganizationRemoveMemberData, AuthPostOrganizationRemoveMemberResponse, AuthPostRevokeOtherSessionsResponse, AuthPostRevokeSessionData, AuthPostRevokeSessionResponse, AuthPostTwoFactorDisableData, AuthPostTwoFactorDisableResponse, AuthPostTwoFactorEnableData, AuthPostTwoFactorEnableResponse, AuthPostTwoFactorGenerateBackupCodesData, AuthPostTwoFactorGenerateBackupCodesResponse, AuthPostTwoFactorVerifyBackupCodeData, AuthPostTwoFactorVerifyBackupCodeResponse, AuthPostTwoFactorVerifyTotpData, AuthPostTwoFactorVerifyTotpResponse, CreateOrganizationInvitationData, CreateOrganizationInvitationResponse, GetSessionResponse, ListUserSessionsResponse, Member, SetActiveOrganizationData, SetActiveOrganizationResponse } from "../generated/types.
|
|
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
3
|
import { Secret } from "../secret.ts";
|
|
4
4
|
import type { CookieStoreShape } from "../transport/cookie-store.ts";
|
|
5
5
|
export interface DalpAuthClientConfig {
|
|
@@ -31,9 +31,7 @@ export interface DalpAuthResult<TData = unknown, TError = DalpAuthError> {
|
|
|
31
31
|
export type DalpAuthOperation<TInput, TData = unknown> = (input?: TInput, options?: unknown) => Promise<DalpAuthResult<TData>>;
|
|
32
32
|
export type DalpRequiredAuthOperation<TInput, TData> = (input: TInput, options?: unknown) => Promise<DalpAuthResult<TData>>;
|
|
33
33
|
export type DalpNoInputAuthOperation<TData> = (options?: unknown) => Promise<DalpAuthResult<TData>>;
|
|
34
|
-
export type RequestBody<TData
|
|
35
|
-
readonly body?: unknown;
|
|
36
|
-
}> = NonNullable<TData["body"]>;
|
|
34
|
+
export type RequestBody<TData> = TData;
|
|
37
35
|
export interface DalpOrganizationMember extends Member {
|
|
38
36
|
readonly user: {
|
|
39
37
|
readonly id: string;
|
package/dist/auth.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SDK_USER_AGENT,
|
|
3
3
|
createCookieStoreFetch,
|
|
4
4
|
makeCookieStore
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-mdegh3gh.js";
|
|
6
6
|
import {
|
|
7
7
|
normalizeDalpBaseUrl,
|
|
8
8
|
secret,
|
|
@@ -26,24 +26,105 @@ import {
|
|
|
26
26
|
} from "better-auth/client/plugins";
|
|
27
27
|
|
|
28
28
|
// src/auth/client.ts
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
sessionToken: z.string().trim().min(1).transform(secret).optional(),
|
|
34
|
-
cookie: z.string().trim().min(1).transform(secret).optional(),
|
|
35
|
-
cookieStore: z.custom((value) => typeof value === "object" && value !== null && typeof value.header === "function" && typeof value.storeSetCookieHeaders === "function").optional(),
|
|
36
|
-
organizationId: z.string().trim().min(1).optional(),
|
|
37
|
-
headers: z.record(z.string(), z.string()).optional(),
|
|
38
|
-
fetch: z.custom((value) => typeof value === "function").optional()
|
|
39
|
-
}).superRefine((value, context) => {
|
|
40
|
-
if ([value.apiKey, value.sessionToken, value.cookie].filter(Boolean).length > 1) {
|
|
41
|
-
context.addIssue({ code: "custom", message: "configure only one auth credential source" });
|
|
29
|
+
class AuthConfigError extends Error {
|
|
30
|
+
constructor(field, requirement) {
|
|
31
|
+
super(`\`${field}\` ${requirement}`);
|
|
32
|
+
this.name = "AuthConfigError";
|
|
42
33
|
}
|
|
43
|
-
}
|
|
34
|
+
}
|
|
35
|
+
function optionalText(value, field) {
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (typeof value !== "string") {
|
|
40
|
+
return handleNonString(field);
|
|
41
|
+
}
|
|
42
|
+
const trimmed = value.trim();
|
|
43
|
+
if (trimmed.length === 0) {
|
|
44
|
+
throw new AuthConfigError(field, "must not be blank");
|
|
45
|
+
}
|
|
46
|
+
return trimmed;
|
|
47
|
+
}
|
|
48
|
+
function handleNonString(field) {
|
|
49
|
+
throw new AuthConfigError(field, "must be a string");
|
|
50
|
+
}
|
|
51
|
+
function requiredUrl(value) {
|
|
52
|
+
if (typeof value !== "string") {
|
|
53
|
+
return handleNonString("url");
|
|
54
|
+
}
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
parsed = new URL(value);
|
|
58
|
+
} catch {
|
|
59
|
+
throw new AuthConfigError("url", "must be a valid URL");
|
|
60
|
+
}
|
|
61
|
+
if (!["http:", "https:"].includes(parsed.protocol)) {
|
|
62
|
+
throw new AuthConfigError("url", "must use http or https");
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
function optionalHeaders(value) {
|
|
67
|
+
if (value === undefined) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
71
|
+
throw new AuthConfigError("headers", "must be an object of strings");
|
|
72
|
+
}
|
|
73
|
+
const headers = {};
|
|
74
|
+
for (const [name, header] of Object.entries(value)) {
|
|
75
|
+
if (typeof header !== "string") {
|
|
76
|
+
throw new AuthConfigError("headers", "must be an object of strings");
|
|
77
|
+
}
|
|
78
|
+
headers[name] = header;
|
|
79
|
+
}
|
|
80
|
+
return headers;
|
|
81
|
+
}
|
|
82
|
+
function optionalFetch(value) {
|
|
83
|
+
if (value === undefined) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (typeof value !== "function") {
|
|
87
|
+
throw new AuthConfigError("fetch", "must be a function");
|
|
88
|
+
}
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
function optionalCookieStore(value) {
|
|
92
|
+
if (value === undefined) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const store = value;
|
|
96
|
+
if (typeof value !== "object" || value === null || typeof store.header !== "function" || typeof store.storeSetCookieHeaders !== "function") {
|
|
97
|
+
throw new AuthConfigError("cookieStore", "must expose header and storeSetCookieHeaders");
|
|
98
|
+
}
|
|
99
|
+
return store;
|
|
100
|
+
}
|
|
101
|
+
function decodeAuthConfig(input) {
|
|
102
|
+
const raw = input;
|
|
103
|
+
const apiKey = optionalText(raw.apiKey, "apiKey");
|
|
104
|
+
const sessionToken = optionalText(raw.sessionToken, "sessionToken");
|
|
105
|
+
const cookie = optionalText(raw.cookie, "cookie");
|
|
106
|
+
if ([apiKey, sessionToken, cookie].filter((credential) => credential !== undefined).length > 1) {
|
|
107
|
+
throw new AuthConfigError("apiKey/sessionToken/cookie", "configure only one auth credential source");
|
|
108
|
+
}
|
|
109
|
+
const url = requiredUrl(raw.url);
|
|
110
|
+
const cookieStore = optionalCookieStore(raw.cookieStore);
|
|
111
|
+
const organizationId = optionalText(raw.organizationId, "organizationId");
|
|
112
|
+
const headers = optionalHeaders(raw.headers);
|
|
113
|
+
const configuredFetch = optionalFetch(raw.fetch);
|
|
114
|
+
return {
|
|
115
|
+
url,
|
|
116
|
+
...apiKey === undefined ? {} : { apiKey: secret(apiKey) },
|
|
117
|
+
...sessionToken === undefined ? {} : { sessionToken: secret(sessionToken) },
|
|
118
|
+
...cookie === undefined ? {} : { cookie: secret(cookie) },
|
|
119
|
+
...cookieStore === undefined ? {} : { cookieStore },
|
|
120
|
+
...organizationId === undefined ? {} : { organizationId },
|
|
121
|
+
...headers === undefined ? {} : { headers },
|
|
122
|
+
...configuredFetch === undefined ? {} : { fetch: configuredFetch }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
44
125
|
async function decodeDalpAuthClientConfig(input) {
|
|
45
126
|
try {
|
|
46
|
-
return
|
|
127
|
+
return decodeAuthConfig(input);
|
|
47
128
|
} catch (error) {
|
|
48
129
|
throw createDalpSdkConfigurationError({
|
|
49
130
|
message: "DALP SDK: auth client configuration is invalid.",
|
package/dist/bundler.d.ts
CHANGED
|
@@ -21,7 +21,4 @@ export interface DalpBundlerClient {
|
|
|
21
21
|
getPaymasterStubData(operation: ReadonlyDeep<DalpUserOperationRequest>, entryPoint: Address): Promise<unknown>;
|
|
22
22
|
getPaymasterData(operation: ReadonlyDeep<DalpUserOperationRequest>, entryPoint: Address): Promise<unknown>;
|
|
23
23
|
}
|
|
24
|
-
export type GeneratedEnvelope<T> = {
|
|
25
|
-
readonly data: T;
|
|
26
|
-
};
|
|
27
24
|
export declare function createDalpBundlerClient(config: DalpBundlerClientConfig): DalpBundlerClient;
|
package/dist/bundler.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDalpClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
v2TransactionsBundlerGetPaymasterData,
|
|
8
|
-
v2TransactionsBundlerGetPaymasterStubData,
|
|
9
|
-
v2TransactionsBundlerGetSupportedEntryPoints,
|
|
10
|
-
v2TransactionsBundlerGetUserOperationByHash,
|
|
11
|
-
v2TransactionsBundlerGetUserOperationReceipt,
|
|
12
|
-
v2TransactionsBundlerSendUserOperation
|
|
13
|
-
} from "./chunk-y0cggmp9.js";
|
|
14
|
-
import"./chunk-w21k7p99.js";
|
|
15
|
-
import"./chunk-gxtczja0.js";
|
|
3
|
+
} from "./chunk-42msy2x5.js";
|
|
4
|
+
import"./chunk-f4t1bm86.js";
|
|
5
|
+
import"./chunk-armnnx1b.js";
|
|
6
|
+
import"./chunk-apc9awed.js";
|
|
16
7
|
import"./chunk-h12fatty.js";
|
|
17
8
|
import"./chunk-y0d2c7kp.js";
|
|
18
9
|
|
|
19
10
|
// src/bundler.ts
|
|
20
11
|
import { getAddress, hexToBigInt, isHex } from "viem";
|
|
21
|
-
var responseData = (result) =>
|
|
12
|
+
var responseData = (result) => {
|
|
13
|
+
const body = result !== null && typeof result === "object" ? Reflect.get(result, "data") : undefined;
|
|
14
|
+
const unwrapped = body ?? result;
|
|
15
|
+
return unwrapped !== null && typeof unwrapped === "object" ? unwrapped : {};
|
|
16
|
+
};
|
|
22
17
|
var requireHex = (value, field) => {
|
|
23
18
|
if (typeof value !== "string" || !isHex(value)) {
|
|
24
19
|
throw new TypeError(`DALP bundler response: ${field} must be an Ethereum hex value.`);
|
|
@@ -35,49 +30,43 @@ function createDalpBundlerClient(config) {
|
|
|
35
30
|
});
|
|
36
31
|
return {
|
|
37
32
|
async sendUserOperation(operation, entryPoint) {
|
|
38
|
-
const result = await
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
throwOnError: true
|
|
33
|
+
const result = await client.execute("transactions/bundler/sendUserOperation", {
|
|
34
|
+
userOperation: operation,
|
|
35
|
+
entryPoint
|
|
42
36
|
});
|
|
43
|
-
return requireHex(responseData(result)
|
|
37
|
+
return requireHex(responseData(result)["userOperationHash"], "userOperationHash");
|
|
44
38
|
},
|
|
45
39
|
async estimateUserOperationGas(operation, entryPoint) {
|
|
46
|
-
const result = await
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
throwOnError: true
|
|
40
|
+
const result = await client.execute("transactions/bundler/estimateUserOperationGas", {
|
|
41
|
+
userOperation: operation,
|
|
42
|
+
entryPoint
|
|
50
43
|
});
|
|
51
44
|
const data = responseData(result);
|
|
52
45
|
return {
|
|
53
|
-
preVerificationGas: requireHex(data
|
|
54
|
-
verificationGasLimit: requireHex(data
|
|
55
|
-
callGasLimit: requireHex(data
|
|
56
|
-
...data
|
|
57
|
-
paymasterVerificationGasLimit: requireHex(data
|
|
46
|
+
preVerificationGas: requireHex(data["preVerificationGas"], "preVerificationGas"),
|
|
47
|
+
verificationGasLimit: requireHex(data["verificationGasLimit"], "verificationGasLimit"),
|
|
48
|
+
callGasLimit: requireHex(data["callGasLimit"], "callGasLimit"),
|
|
49
|
+
...data["paymasterVerificationGasLimit"] === undefined ? {} : {
|
|
50
|
+
paymasterVerificationGasLimit: requireHex(data["paymasterVerificationGasLimit"], "paymasterVerificationGasLimit")
|
|
58
51
|
},
|
|
59
|
-
...data
|
|
52
|
+
...data["paymasterPostOpGasLimit"] === undefined ? {} : { paymasterPostOpGasLimit: requireHex(data["paymasterPostOpGasLimit"], "paymasterPostOpGasLimit") }
|
|
60
53
|
};
|
|
61
54
|
},
|
|
62
55
|
async getUserOperationByHash(hash) {
|
|
63
|
-
const result = await
|
|
64
|
-
client,
|
|
65
|
-
path: { userOperationHash: hash },
|
|
66
|
-
throwOnError: true
|
|
67
|
-
});
|
|
56
|
+
const result = await client.execute("transactions/bundler/getUserOperationByHash", { userOperationHash: hash });
|
|
68
57
|
return responseData(result);
|
|
69
58
|
},
|
|
70
59
|
async getUserOperationReceipt(hash) {
|
|
71
|
-
const result = await
|
|
72
|
-
client,
|
|
73
|
-
path: { userOperationHash: hash },
|
|
74
|
-
throwOnError: true
|
|
75
|
-
});
|
|
60
|
+
const result = await client.execute("transactions/bundler/getUserOperationReceipt", { userOperationHash: hash });
|
|
76
61
|
return responseData(result);
|
|
77
62
|
},
|
|
78
63
|
async getSupportedEntryPoints() {
|
|
79
|
-
const result = await
|
|
80
|
-
|
|
64
|
+
const result = await client.execute("transactions/bundler/getSupportedEntryPoints");
|
|
65
|
+
const entryPoints = responseData(result)["entryPoints"];
|
|
66
|
+
if (!Array.isArray(entryPoints)) {
|
|
67
|
+
throw new TypeError("DALP bundler response: entryPoints must be an array.");
|
|
68
|
+
}
|
|
69
|
+
return entryPoints.map((entryPoint) => {
|
|
81
70
|
if (typeof entryPoint !== "string") {
|
|
82
71
|
throw new TypeError("DALP bundler response: each entry point must be a string address.");
|
|
83
72
|
}
|
|
@@ -85,22 +74,20 @@ function createDalpBundlerClient(config) {
|
|
|
85
74
|
});
|
|
86
75
|
},
|
|
87
76
|
async getChainId() {
|
|
88
|
-
const result = await
|
|
89
|
-
return hexToBigInt(requireHex(responseData(result)
|
|
77
|
+
const result = await client.execute("transactions/bundler/getChainId");
|
|
78
|
+
return hexToBigInt(requireHex(responseData(result)["chainId"], "chainId"));
|
|
90
79
|
},
|
|
91
80
|
async getPaymasterStubData(operation, entryPoint) {
|
|
92
|
-
const result = await
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
throwOnError: true
|
|
81
|
+
const result = await client.execute("transactions/bundler/getPaymasterStubData", {
|
|
82
|
+
userOperation: operation,
|
|
83
|
+
entryPoint
|
|
96
84
|
});
|
|
97
85
|
return responseData(result);
|
|
98
86
|
},
|
|
99
87
|
async getPaymasterData(operation, entryPoint) {
|
|
100
|
-
const result = await
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
throwOnError: true
|
|
88
|
+
const result = await client.execute("transactions/bundler/getPaymasterData", {
|
|
89
|
+
userOperation: operation,
|
|
90
|
+
entryPoint
|
|
104
91
|
});
|
|
105
92
|
return responseData(result);
|
|
106
93
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildProxy,
|
|
3
|
+
findRoute
|
|
4
|
+
} from "./chunk-f4t1bm86.js";
|
|
5
|
+
import {
|
|
6
|
+
createFetchExecutor,
|
|
7
|
+
createTanstackFactories,
|
|
8
|
+
createTransport,
|
|
9
|
+
sendRequest,
|
|
10
|
+
streamRequest
|
|
11
|
+
} from "./chunk-armnnx1b.js";
|
|
12
|
+
import {
|
|
13
|
+
data
|
|
14
|
+
} from "./chunk-apc9awed.js";
|
|
15
|
+
|
|
16
|
+
// src/proxy/client.ts
|
|
17
|
+
function createDalpClient(options) {
|
|
18
|
+
const transport = createTransport(options);
|
|
19
|
+
const api = buildProxy(data, createFetchExecutor(transport), createTanstackFactories(transport));
|
|
20
|
+
return {
|
|
21
|
+
api,
|
|
22
|
+
conditionalRequests: transport.conditionalRequests,
|
|
23
|
+
execute: async (routeId, input, callOptions) => {
|
|
24
|
+
const route = findRoute(data, routeId);
|
|
25
|
+
if (route === undefined) {
|
|
26
|
+
throw new TypeError(`Unknown DALP route \`${routeId}\``);
|
|
27
|
+
}
|
|
28
|
+
const result = route.serializer === "sse" ? streamRequest(transport, route, input, callOptions) : await sendRequest(transport, route, input, callOptions);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export { createDalpClient };
|