@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/dist/auth.js
DELETED
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SDK_USER_AGENT,
|
|
3
|
-
createCookieStoreFetch,
|
|
4
|
-
makeCookieStore
|
|
5
|
-
} from "./chunk-kddq0nmb.js";
|
|
6
|
-
import {
|
|
7
|
-
normalizeDalpBaseUrl,
|
|
8
|
-
secret,
|
|
9
|
-
unwrapSecret
|
|
10
|
-
} from "./chunk-h12fatty.js";
|
|
11
|
-
import {
|
|
12
|
-
createDalpSdkConfigurationError
|
|
13
|
-
} from "./chunk-y0d2c7kp.js";
|
|
14
|
-
|
|
15
|
-
// src/auth/live.ts
|
|
16
|
-
import { apiKeyClient } from "@better-auth/api-key/client";
|
|
17
|
-
import { passkeyClient } from "@better-auth/passkey/client";
|
|
18
|
-
import { createAuthClient as createBetterAuthClient } from "better-auth/client";
|
|
19
|
-
import {
|
|
20
|
-
adminClient,
|
|
21
|
-
customSessionClient,
|
|
22
|
-
deviceAuthorizationClient,
|
|
23
|
-
inferAdditionalFields,
|
|
24
|
-
organizationClient,
|
|
25
|
-
twoFactorClient
|
|
26
|
-
} from "better-auth/client/plugins";
|
|
27
|
-
|
|
28
|
-
// src/auth/client.ts
|
|
29
|
-
class AuthConfigError extends Error {
|
|
30
|
-
constructor(field, requirement) {
|
|
31
|
-
super(`\`${field}\` ${requirement}`);
|
|
32
|
-
this.name = "AuthConfigError";
|
|
33
|
-
}
|
|
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
|
-
}
|
|
125
|
-
async function decodeDalpAuthClientConfig(input) {
|
|
126
|
-
try {
|
|
127
|
-
return decodeAuthConfig(input);
|
|
128
|
-
} catch (error) {
|
|
129
|
-
throw createDalpSdkConfigurationError({
|
|
130
|
-
message: "DALP SDK: auth client configuration is invalid.",
|
|
131
|
-
why: "The auth client received a malformed URL, credential, header map, fetch seam, or cookie store.",
|
|
132
|
-
fix: "Pass one credential source, an HTTP(S) URL, and valid fetch and cookie-store seams.",
|
|
133
|
-
cause: error
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/auth/permissions.ts
|
|
139
|
-
import { createAccessControl } from "better-auth/plugins/access";
|
|
140
|
-
import { adminAc, defaultStatements as adminDefaultStatements } from "better-auth/plugins/admin/access";
|
|
141
|
-
import {
|
|
142
|
-
memberAc,
|
|
143
|
-
defaultStatements as organizationDefaultStatements,
|
|
144
|
-
ownerAc
|
|
145
|
-
} from "better-auth/plugins/organization/access";
|
|
146
|
-
var dalPermissions = {
|
|
147
|
-
organization: ["update", "delete", "list"],
|
|
148
|
-
setting: ["read", "list", "upsert", "remove", "set-global-theme"],
|
|
149
|
-
system: ["read", "list", "create"],
|
|
150
|
-
exchangeRates: ["read", "list"]
|
|
151
|
-
};
|
|
152
|
-
var customPermissions = {
|
|
153
|
-
...adminDefaultStatements,
|
|
154
|
-
...organizationDefaultStatements,
|
|
155
|
-
...dalPermissions
|
|
156
|
-
};
|
|
157
|
-
var narrowAccessControl = createAccessControl(customPermissions);
|
|
158
|
-
var accessControl = createAccessControl({
|
|
159
|
-
...adminDefaultStatements,
|
|
160
|
-
...organizationDefaultStatements,
|
|
161
|
-
...dalPermissions
|
|
162
|
-
});
|
|
163
|
-
var adminRole = narrowAccessControl.newRole({
|
|
164
|
-
...adminAc.statements,
|
|
165
|
-
...ownerAc.statements,
|
|
166
|
-
organization: ["update", "delete", "list"],
|
|
167
|
-
setting: ["read", "list", "upsert", "remove", "set-global-theme"],
|
|
168
|
-
system: ["read", "list", "create"],
|
|
169
|
-
exchangeRates: ["read", "list"]
|
|
170
|
-
});
|
|
171
|
-
var ownerRole = narrowAccessControl.newRole({
|
|
172
|
-
...ownerAc.statements,
|
|
173
|
-
user: ["list", "get", "update"],
|
|
174
|
-
setting: ["read", "list", "upsert", "remove"],
|
|
175
|
-
system: ["read", "list", "create"],
|
|
176
|
-
exchangeRates: ["read", "list"]
|
|
177
|
-
});
|
|
178
|
-
var memberRole = narrowAccessControl.newRole({
|
|
179
|
-
...memberAc.statements,
|
|
180
|
-
setting: ["read", "list"],
|
|
181
|
-
system: ["read", "list"],
|
|
182
|
-
exchangeRates: ["read", "list"]
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// src/auth/wallet-plugins.ts
|
|
186
|
-
import { defineErrorCodes } from "better-auth";
|
|
187
|
-
var WALLET_PINCODE_ERROR_CODES = defineErrorCodes({
|
|
188
|
-
WALLET_PINCODE_ALREADY_SET: "Wallet pincode already set",
|
|
189
|
-
WALLET_PINCODE_ALREADY_REMOVED: "Wallet pincode already removed",
|
|
190
|
-
WALLET_PINCODE_PASSWORD_REQUIRED: "Password is required",
|
|
191
|
-
WALLET_PINCODE_INVALID_PASSWORD: "Invalid password"
|
|
192
|
-
});
|
|
193
|
-
var WALLET_TWO_FACTOR_ERROR_CODES = defineErrorCodes({
|
|
194
|
-
WALLET_TWO_FACTOR_PASSWORD_REQUIRED: "Password is required",
|
|
195
|
-
WALLET_TWO_FACTOR_INVALID_PASSWORD: "Invalid password",
|
|
196
|
-
WALLET_TWO_FACTOR_INVALID_CODE: "Invalid two factor code"
|
|
197
|
-
});
|
|
198
|
-
var WALLET_SECRET_CODES_ERROR_CODES = defineErrorCodes({
|
|
199
|
-
WALLET_SECRET_CODES_PASSWORD_REQUIRED: "Password is required",
|
|
200
|
-
WALLET_SECRET_CODES_INVALID_PASSWORD: "Invalid password",
|
|
201
|
-
WALLET_SECRET_CODES_VERIFICATION_MISMATCH: "Secret codes verification mismatch"
|
|
202
|
-
});
|
|
203
|
-
var walletPincodeClient = () => ({
|
|
204
|
-
id: "wallet-pincode",
|
|
205
|
-
$InferServerPlugin: {
|
|
206
|
-
id: "wallet-pincode",
|
|
207
|
-
$ERROR_CODES: WALLET_PINCODE_ERROR_CODES,
|
|
208
|
-
endpoints: {}
|
|
209
|
-
},
|
|
210
|
-
$ERROR_CODES: WALLET_PINCODE_ERROR_CODES,
|
|
211
|
-
pathMethods: {
|
|
212
|
-
"/wallet/pincode/enable": "POST",
|
|
213
|
-
"/wallet/pincode/disable": "POST",
|
|
214
|
-
"/wallet/pincode/update": "POST",
|
|
215
|
-
"/wallet/pincode/reset": "POST"
|
|
216
|
-
},
|
|
217
|
-
atomListeners: [
|
|
218
|
-
{
|
|
219
|
-
matcher: (path) => path.startsWith("/wallet/pincode/"),
|
|
220
|
-
signal: "$sessionSignal"
|
|
221
|
-
}
|
|
222
|
-
]
|
|
223
|
-
});
|
|
224
|
-
var walletTwoFactorClient = () => ({
|
|
225
|
-
id: "wallet-two-factor",
|
|
226
|
-
$InferServerPlugin: {
|
|
227
|
-
id: "wallet-two-factor",
|
|
228
|
-
$ERROR_CODES: WALLET_TWO_FACTOR_ERROR_CODES,
|
|
229
|
-
endpoints: {}
|
|
230
|
-
},
|
|
231
|
-
$ERROR_CODES: WALLET_TWO_FACTOR_ERROR_CODES,
|
|
232
|
-
pathMethods: {
|
|
233
|
-
"/wallet/two-factor/enable": "POST",
|
|
234
|
-
"/wallet/two-factor/disable": "POST",
|
|
235
|
-
"/wallet/two-factor/verify": "POST"
|
|
236
|
-
},
|
|
237
|
-
atomListeners: [
|
|
238
|
-
{
|
|
239
|
-
matcher: (path) => path.startsWith("/wallet/two-factor/"),
|
|
240
|
-
signal: "$sessionSignal"
|
|
241
|
-
}
|
|
242
|
-
]
|
|
243
|
-
});
|
|
244
|
-
var walletSecretCodesClient = () => ({
|
|
245
|
-
id: "wallet-secret-codes",
|
|
246
|
-
$InferServerPlugin: {
|
|
247
|
-
id: "wallet-secret-codes",
|
|
248
|
-
$ERROR_CODES: WALLET_SECRET_CODES_ERROR_CODES,
|
|
249
|
-
endpoints: {}
|
|
250
|
-
},
|
|
251
|
-
$ERROR_CODES: WALLET_SECRET_CODES_ERROR_CODES,
|
|
252
|
-
pathMethods: {
|
|
253
|
-
"/wallet/secret-codes/generate": "POST",
|
|
254
|
-
"/wallet/secret-codes/confirm": "POST"
|
|
255
|
-
},
|
|
256
|
-
atomListeners: [
|
|
257
|
-
{
|
|
258
|
-
matcher: (path) => path.startsWith("/wallet/secret-codes/"),
|
|
259
|
-
signal: "$sessionSignal"
|
|
260
|
-
}
|
|
261
|
-
]
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// src/auth/live.ts
|
|
265
|
-
var reservedHeaders = new Set(["x-api-key", "authorization", "cookie"]);
|
|
266
|
-
function authHeaders(config) {
|
|
267
|
-
const headers = { "User-Agent": SDK_USER_AGENT };
|
|
268
|
-
for (const [name, value] of Object.entries(config.headers ?? {})) {
|
|
269
|
-
if (!reservedHeaders.has(name.toLowerCase())) {
|
|
270
|
-
headers[name] = value;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (config.apiKey !== undefined) {
|
|
274
|
-
headers["x-api-key"] = unwrapSecret(config.apiKey);
|
|
275
|
-
}
|
|
276
|
-
if (config.sessionToken !== undefined) {
|
|
277
|
-
const token = unwrapSecret(config.sessionToken);
|
|
278
|
-
headers.authorization = token.toLowerCase().startsWith("bearer ") ? token : `Bearer ${token}`;
|
|
279
|
-
}
|
|
280
|
-
if (config.organizationId !== undefined) {
|
|
281
|
-
headers["x-organization-id"] = config.organizationId;
|
|
282
|
-
}
|
|
283
|
-
return headers;
|
|
284
|
-
}
|
|
285
|
-
function createConfiguredBetterAuthClient(config, cookieStore) {
|
|
286
|
-
return createBetterAuthClient({
|
|
287
|
-
baseURL: `${normalizeDalpBaseUrl(config.url)}/api/auth`,
|
|
288
|
-
fetchOptions: {
|
|
289
|
-
headers: authHeaders(config),
|
|
290
|
-
customFetchImpl: createCookieStoreFetch(cookieStore, config.fetch),
|
|
291
|
-
credentials: "include"
|
|
292
|
-
},
|
|
293
|
-
plugins: [
|
|
294
|
-
customSessionClient(),
|
|
295
|
-
inferAdditionalFields(),
|
|
296
|
-
adminClient({ ac: accessControl, roles: { admin: adminRole, owner: ownerRole, member: memberRole } }),
|
|
297
|
-
apiKeyClient(),
|
|
298
|
-
passkeyClient(),
|
|
299
|
-
walletPincodeClient(),
|
|
300
|
-
walletTwoFactorClient(),
|
|
301
|
-
walletSecretCodesClient(),
|
|
302
|
-
twoFactorClient({ onTwoFactorRedirect() {} }),
|
|
303
|
-
deviceAuthorizationClient(),
|
|
304
|
-
organizationClient({ ac: accessControl, roles: { owner: ownerRole, member: memberRole } })
|
|
305
|
-
]
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
async function createDalpAuthClient(input) {
|
|
309
|
-
const config = await decodeDalpAuthClientConfig(input);
|
|
310
|
-
const cookieStore = config.cookieStore ?? makeCookieStore();
|
|
311
|
-
if (config.cookie !== undefined) {
|
|
312
|
-
cookieStore.setCookieHeader(unwrapSecret(config.cookie));
|
|
313
|
-
}
|
|
314
|
-
const credentialCount = [config.apiKey, config.sessionToken, cookieStore.isEmpty() ? undefined : true].filter(Boolean).length;
|
|
315
|
-
if (credentialCount > 1) {
|
|
316
|
-
throw createDalpSdkConfigurationError({
|
|
317
|
-
message: "DALP SDK: configure only one auth credential source.",
|
|
318
|
-
why: "The auth client received multiple credential types.",
|
|
319
|
-
fix: "Use an API key, bearer token, or cookie store, not a combination."
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
return createConfiguredBetterAuthClient(config, cookieStore);
|
|
323
|
-
}
|
|
324
|
-
var makeDalpAuthClient = createDalpAuthClient;
|
|
325
|
-
export {
|
|
326
|
-
createDalpAuthClient,
|
|
327
|
-
decodeDalpAuthClientConfig,
|
|
328
|
-
makeDalpAuthClient
|
|
329
|
-
};
|
package/dist/bundler.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDalpClient
|
|
3
|
-
} from "./chunk-tmk1f2yb.js";
|
|
4
|
-
import"./chunk-f4t1bm86.js";
|
|
5
|
-
import"./chunk-def7rqy6.js";
|
|
6
|
-
import"./chunk-fjnq61hj.js";
|
|
7
|
-
import"./chunk-9k284df4.js";
|
|
8
|
-
import"./chunk-h12fatty.js";
|
|
9
|
-
import"./chunk-y0d2c7kp.js";
|
|
10
|
-
|
|
11
|
-
// src/bundler.ts
|
|
12
|
-
import { getAddress, hexToBigInt, isHex } from "viem";
|
|
13
|
-
var responseData = (result) => {
|
|
14
|
-
const body = result !== null && typeof result === "object" ? Reflect.get(result, "data") : undefined;
|
|
15
|
-
const unwrapped = body ?? result;
|
|
16
|
-
return unwrapped !== null && typeof unwrapped === "object" ? unwrapped : {};
|
|
17
|
-
};
|
|
18
|
-
var requireHex = (value, field) => {
|
|
19
|
-
if (typeof value !== "string" || !isHex(value)) {
|
|
20
|
-
throw new TypeError(`DALP bundler response: ${field} must be an Ethereum hex value.`);
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
function createDalpBundlerClient(config) {
|
|
25
|
-
const client = createDalpClient({
|
|
26
|
-
baseUrl: config.url,
|
|
27
|
-
apiKey: config.apiKey,
|
|
28
|
-
context: { organizationId: config.organizationId },
|
|
29
|
-
fetch: config.fetch,
|
|
30
|
-
runtime: "server"
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
async sendUserOperation(operation, entryPoint) {
|
|
34
|
-
const result = await client.execute("transactions/bundler/sendUserOperation", {
|
|
35
|
-
userOperation: operation,
|
|
36
|
-
entryPoint
|
|
37
|
-
});
|
|
38
|
-
return requireHex(responseData(result)["userOperationHash"], "userOperationHash");
|
|
39
|
-
},
|
|
40
|
-
async estimateUserOperationGas(operation, entryPoint) {
|
|
41
|
-
const result = await client.execute("transactions/bundler/estimateUserOperationGas", {
|
|
42
|
-
userOperation: operation,
|
|
43
|
-
entryPoint
|
|
44
|
-
});
|
|
45
|
-
const data = responseData(result);
|
|
46
|
-
return {
|
|
47
|
-
preVerificationGas: requireHex(data["preVerificationGas"], "preVerificationGas"),
|
|
48
|
-
verificationGasLimit: requireHex(data["verificationGasLimit"], "verificationGasLimit"),
|
|
49
|
-
callGasLimit: requireHex(data["callGasLimit"], "callGasLimit"),
|
|
50
|
-
...data["paymasterVerificationGasLimit"] === undefined ? {} : {
|
|
51
|
-
paymasterVerificationGasLimit: requireHex(data["paymasterVerificationGasLimit"], "paymasterVerificationGasLimit")
|
|
52
|
-
},
|
|
53
|
-
...data["paymasterPostOpGasLimit"] === undefined ? {} : { paymasterPostOpGasLimit: requireHex(data["paymasterPostOpGasLimit"], "paymasterPostOpGasLimit") }
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
async getUserOperationByHash(hash) {
|
|
57
|
-
const result = await client.execute("transactions/bundler/getUserOperationByHash", { userOperationHash: hash });
|
|
58
|
-
return responseData(result);
|
|
59
|
-
},
|
|
60
|
-
async getUserOperationReceipt(hash) {
|
|
61
|
-
const result = await client.execute("transactions/bundler/getUserOperationReceipt", { userOperationHash: hash });
|
|
62
|
-
return responseData(result);
|
|
63
|
-
},
|
|
64
|
-
async getSupportedEntryPoints() {
|
|
65
|
-
const result = await client.execute("transactions/bundler/getSupportedEntryPoints");
|
|
66
|
-
const entryPoints = responseData(result)["entryPoints"];
|
|
67
|
-
if (!Array.isArray(entryPoints)) {
|
|
68
|
-
throw new TypeError("DALP bundler response: entryPoints must be an array.");
|
|
69
|
-
}
|
|
70
|
-
return entryPoints.map((entryPoint) => {
|
|
71
|
-
if (typeof entryPoint !== "string") {
|
|
72
|
-
throw new TypeError("DALP bundler response: each entry point must be a string address.");
|
|
73
|
-
}
|
|
74
|
-
return getAddress(entryPoint);
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
async getChainId() {
|
|
78
|
-
const result = await client.execute("transactions/bundler/getChainId");
|
|
79
|
-
return hexToBigInt(requireHex(responseData(result)["chainId"], "chainId"));
|
|
80
|
-
},
|
|
81
|
-
async getPaymasterStubData(operation, entryPoint) {
|
|
82
|
-
const result = await client.execute("transactions/bundler/getPaymasterStubData", {
|
|
83
|
-
userOperation: operation,
|
|
84
|
-
entryPoint
|
|
85
|
-
});
|
|
86
|
-
return responseData(result);
|
|
87
|
-
},
|
|
88
|
-
async getPaymasterData(operation, entryPoint) {
|
|
89
|
-
const result = await client.execute("transactions/bundler/getPaymasterData", {
|
|
90
|
-
userOperation: operation,
|
|
91
|
-
entryPoint
|
|
92
|
-
});
|
|
93
|
-
return responseData(result);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export {
|
|
98
|
-
createDalpBundlerClient
|
|
99
|
-
};
|