@settlemint/dalp-sdk 3.1.25 → 3.1.26-main.37113215468
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 +239 -172
- package/dist/auth/client.d.ts +103 -0
- package/dist/auth/invite-step-up.d.ts +2 -0
- package/dist/auth/live.d.ts +47 -0
- package/dist/auth/native-passkey.d.ts +9 -0
- package/dist/{auth-permissions.d.ts → auth/permissions.d.ts} +0 -8
- package/dist/{auth-wallet-plugins.d.ts → auth/wallet-plugins.d.ts} +68 -6
- package/dist/auth-surface.d.ts +2 -0
- package/dist/auth.d.ts +8 -115
- package/dist/auth.js +525 -0
- package/dist/chunk-16xvy8xj.js +271 -0
- package/dist/chunk-4f4kjtt0.js +149 -0
- package/dist/chunk-b03ycwb7.js +68 -0
- package/dist/chunk-ghgcmyhk.js +5 -0
- package/dist/chunk-h241xecg.js +1625 -0
- package/dist/chunk-hqz56e6q.js +4 -0
- package/dist/chunk-k3ntysxx.js +57 -0
- package/dist/chunk-pjjrxre1.js +36 -0
- package/dist/chunk-qvtjb3dz.js +102 -0
- package/dist/chunk-w361dpdk.js +5 -0
- package/dist/client/conditional-request.d.ts +8 -0
- package/dist/client/factory.d.ts +4 -0
- package/dist/client/query-serializer.d.ts +1 -0
- package/dist/client/request-compression.d.ts +12 -0
- package/dist/client/ssr-fetch.d.ts +10 -0
- package/dist/client/step-up-challenge.d.ts +10 -0
- package/dist/effect.d.ts +38 -0
- package/dist/effect.js +87 -0
- package/dist/errors/api-error.d.ts +35 -0
- package/dist/errors/error-codes.d.ts +21 -0
- package/dist/errors/find-current-error.d.ts +2 -0
- package/dist/errors/sdk-error.d.ts +52 -0
- package/dist/errors/sdk-error.js +8 -0
- package/dist/generated/api-types.d.ts +69961 -0
- package/dist/generated/console-routes.d.ts +12 -0
- package/dist/generated/error-catalog.d.ts +9 -0
- package/dist/generated/error-codes.d.ts +9 -0
- package/dist/generated/response-scalars.d.ts +9 -0
- package/dist/generated/response-schemas.d.ts +9 -0
- package/dist/generated/route-error-codes.d.ts +9 -0
- package/dist/generated/routes.d.ts +12 -0
- package/dist/index.d.ts +28 -45
- package/dist/index.js +150 -96216
- package/dist/proxy/builder.d.ts +17 -0
- package/dist/proxy/client-core.d.ts +28 -0
- package/dist/proxy/client.d.ts +5 -0
- package/dist/proxy/fetch-executor.d.ts +6 -0
- package/dist/proxy/flat-args.d.ts +24 -0
- package/dist/proxy/response-decode.d.ts +37 -0
- package/dist/proxy/sse.d.ts +11 -0
- package/dist/proxy/step-up-challenge.d.ts +4 -0
- package/dist/proxy/tanstack.d.ts +6 -0
- package/dist/proxy/transport.d.ts +63 -0
- package/dist/react-query.d.ts +2 -0
- package/dist/react-query.js +12 -0
- package/dist/readonly-deep.d.ts +3 -0
- package/dist/routes/console.d.ts +14 -0
- package/dist/routes/console.js +25 -0
- package/dist/routes/index.d.ts +4 -0
- package/dist/routes/index.js +10 -0
- package/dist/routes/types.d.ts +72 -0
- package/dist/runtime-exports.d.ts +4 -0
- package/dist/runtime-exports.js +16 -0
- package/dist/runtime.d.ts +11 -0
- package/dist/scalars/big-decimal.d.ts +4 -0
- package/dist/scalars/ethereum-address.d.ts +5 -0
- package/dist/scalars/exchange-rates.d.ts +13 -0
- package/dist/scalars/index.d.ts +10 -0
- package/dist/scalars/index.js +102 -0
- package/dist/scalars/organization-id.d.ts +5 -0
- package/dist/scalars/token-decimals.d.ts +4 -0
- package/dist/secret.d.ts +12 -0
- package/dist/sign-webhook-receipt.d.ts +16 -0
- package/dist/sign-webhook-receipt.js +26 -0
- package/dist/transport/cookie-store.d.ts +9 -0
- package/dist/transport/sse-lifecycle.d.ts +24 -0
- package/dist/types.d.ts +37 -114
- package/dist/url.d.ts +0 -1
- package/dist/verify-webhook.d.ts +17 -28
- package/dist/verify-webhook.js +8 -0
- package/dist/version.d.ts +0 -3
- package/dist/wait-for-transaction.d.ts +44 -86
- package/dist/wait-for-transaction.js +151 -0
- package/dist/webhook-events.d.ts +543 -33
- package/package.json +110 -34
- package/dist/api-types.generated.d.ts +0 -14160
- package/dist/api-types.generated.d.ts.map +0 -1
- package/dist/auth-permissions.d.ts.map +0 -1
- package/dist/auth-wallet-plugins.d.ts.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/bundler.d.ts +0 -217
- package/dist/bundler.d.ts.map +0 -1
- package/dist/chunk-xm8h1dzh.js +0 -33
- package/dist/client.d.ts +0 -19
- package/dist/client.d.ts.map +0 -1
- package/dist/contract-errors.d.ts +0 -4156
- package/dist/contract-errors.d.ts.map +0 -1
- package/dist/contract.d.ts +0 -22
- package/dist/contract.d.ts.map +0 -1
- package/dist/cookie-store.d.ts +0 -10
- package/dist/cookie-store.d.ts.map +0 -1
- package/dist/dapi-errors.d.ts +0 -654
- package/dist/dapi-errors.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -637
- package/dist/errors.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/platform.d.ts +0 -41
- package/dist/platform.d.ts.map +0 -1
- package/dist/plugins/index.d.ts +0 -13
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -10
- package/dist/sdk-error.d.ts +0 -74
- package/dist/sdk-error.d.ts.map +0 -1
- package/dist/serializers.d.ts +0 -41
- package/dist/serializers.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/url.d.ts.map +0 -1
- package/dist/verify-webhook.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.generated.d.ts +0 -8
- package/dist/version.generated.d.ts.map +0 -1
- package/dist/wait-for-transaction.d.ts.map +0 -1
- package/dist/webhook-events.d.ts.map +0 -1
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import {
|
|
2
|
+
keepBufferingMarker
|
|
3
|
+
} from "./chunk-4f4kjtt0.js";
|
|
4
|
+
|
|
5
|
+
// src/transport/cookie-store.ts
|
|
6
|
+
var parseCookieHeader = (header) => {
|
|
7
|
+
const cookies = new Map;
|
|
8
|
+
for (const part of header.split(";")) {
|
|
9
|
+
const pair = part.trim();
|
|
10
|
+
const separator = pair.indexOf("=");
|
|
11
|
+
if (separator > 0) {
|
|
12
|
+
cookies.set(pair.slice(0, separator), pair);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return cookies;
|
|
16
|
+
};
|
|
17
|
+
var isCookieDeletion = (setCookie, now = Date.now()) => {
|
|
18
|
+
if (/\bmax-age\s*=\s*-?0+\b/iu.test(setCookie) || /\bmax-age\s*=\s*-\d+\b/iu.test(setCookie)) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const expires = /\bexpires\s*=\s*([^;]+)/iu.exec(setCookie)?.[1];
|
|
22
|
+
if (expires === undefined) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const parsed = Date.parse(expires.trim());
|
|
26
|
+
return !Number.isNaN(parsed) && parsed <= now;
|
|
27
|
+
};
|
|
28
|
+
function makeCookieStore2(initialHeader = "") {
|
|
29
|
+
const cookies = parseCookieHeader(initialHeader);
|
|
30
|
+
return {
|
|
31
|
+
header: () => [...cookies.values()].join("; "),
|
|
32
|
+
isEmpty: () => cookies.size === 0,
|
|
33
|
+
setCookieHeader: (header) => {
|
|
34
|
+
cookies.clear();
|
|
35
|
+
for (const [name, pair] of parseCookieHeader(header)) {
|
|
36
|
+
cookies.set(name, pair);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
storeSetCookieHeaders: (headers) => {
|
|
40
|
+
for (const setCookie of headers) {
|
|
41
|
+
const pair = setCookie.split(";", 1)[0]?.trim() ?? "";
|
|
42
|
+
const separator = pair.indexOf("=");
|
|
43
|
+
if (separator <= 0) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const name = pair.slice(0, separator);
|
|
47
|
+
if (isCookieDeletion(setCookie)) {
|
|
48
|
+
cookies.delete(name);
|
|
49
|
+
} else {
|
|
50
|
+
cookies.set(name, pair);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
var getSetCookieHeaders = (headers) => {
|
|
57
|
+
const { getSetCookie } = headers;
|
|
58
|
+
if (getSetCookie !== undefined) {
|
|
59
|
+
return getSetCookie.call(headers);
|
|
60
|
+
}
|
|
61
|
+
const value = headers.get("set-cookie");
|
|
62
|
+
return value === null ? [] : splitCombinedSetCookie(value);
|
|
63
|
+
};
|
|
64
|
+
var splitCombinedSetCookie = (value) => {
|
|
65
|
+
const cookies = [];
|
|
66
|
+
const lowered = value.toLowerCase();
|
|
67
|
+
let start = 0;
|
|
68
|
+
let inExpires = false;
|
|
69
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
70
|
+
if (lowered.startsWith("expires=", index)) {
|
|
71
|
+
inExpires = true;
|
|
72
|
+
}
|
|
73
|
+
const character = value[index];
|
|
74
|
+
if (character === ";") {
|
|
75
|
+
inExpires = false;
|
|
76
|
+
}
|
|
77
|
+
if (character !== "," || inExpires) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const next = value.slice(index + 1);
|
|
81
|
+
if (!/^\s*[\w!#$%&'*+\-.^`|~]+=/u.test(next)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
cookies.push(value.slice(start, index).trim());
|
|
85
|
+
start = index + 1;
|
|
86
|
+
}
|
|
87
|
+
const finalCookie = value.slice(start).trim();
|
|
88
|
+
if (finalCookie.length > 0) {
|
|
89
|
+
cookies.push(finalCookie);
|
|
90
|
+
}
|
|
91
|
+
return cookies;
|
|
92
|
+
};
|
|
93
|
+
function createCookieStoreFetch2(cookieStore, fetchImpl = globalThis.fetch) {
|
|
94
|
+
const cookieStoreFetch = async (input, init) => {
|
|
95
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
96
|
+
if (!cookieStore.isEmpty() && !headers.has("cookie")) {
|
|
97
|
+
headers.set("cookie", cookieStore.header());
|
|
98
|
+
}
|
|
99
|
+
const response = await fetchImpl(input, { ...init, headers });
|
|
100
|
+
if (response.status < 500) {
|
|
101
|
+
cookieStore.storeSetCookieHeaders(getSetCookieHeaders(response.headers));
|
|
102
|
+
}
|
|
103
|
+
return response;
|
|
104
|
+
};
|
|
105
|
+
return keepBufferingMarker(fetchImpl, cookieStoreFetch);
|
|
106
|
+
}
|
|
107
|
+
// package.json
|
|
108
|
+
var package_default = {
|
|
109
|
+
name: "@settlemint/dalp-sdk",
|
|
110
|
+
version: "3.1.26-main.37113215468",
|
|
111
|
+
private: false,
|
|
112
|
+
description: "Fully typed SDK for the DALP tokenization platform API",
|
|
113
|
+
homepage: "https://settlemint.com",
|
|
114
|
+
bugs: {
|
|
115
|
+
email: "support@settlemint.com"
|
|
116
|
+
},
|
|
117
|
+
license: "SEE LICENSE IN LICENSE",
|
|
118
|
+
author: {
|
|
119
|
+
name: "SettleMint",
|
|
120
|
+
email: "support@settlemint.com",
|
|
121
|
+
url: "https://settlemint.com"
|
|
122
|
+
},
|
|
123
|
+
files: [
|
|
124
|
+
"dist",
|
|
125
|
+
"README.md",
|
|
126
|
+
"LICENSE"
|
|
127
|
+
],
|
|
128
|
+
type: "module",
|
|
129
|
+
sideEffects: [
|
|
130
|
+
"./src/**"
|
|
131
|
+
],
|
|
132
|
+
exports: {
|
|
133
|
+
"./package.json": "./package.json",
|
|
134
|
+
"./runtime-exports": {
|
|
135
|
+
types: "./dist/runtime-exports.d.ts",
|
|
136
|
+
import: "./dist/runtime-exports.js",
|
|
137
|
+
default: "./dist/runtime-exports.js"
|
|
138
|
+
},
|
|
139
|
+
".": {
|
|
140
|
+
types: "./dist/index.d.ts",
|
|
141
|
+
import: "./dist/index.js",
|
|
142
|
+
default: "./dist/index.js"
|
|
143
|
+
},
|
|
144
|
+
"./types": {
|
|
145
|
+
types: "./dist/types.d.ts",
|
|
146
|
+
import: "./dist/types.js",
|
|
147
|
+
default: "./dist/types.js"
|
|
148
|
+
},
|
|
149
|
+
"./scalars": {
|
|
150
|
+
types: "./dist/scalars/index.d.ts",
|
|
151
|
+
import: "./dist/scalars/index.js",
|
|
152
|
+
default: "./dist/scalars/index.js"
|
|
153
|
+
},
|
|
154
|
+
"./react-query": {
|
|
155
|
+
types: "./dist/react-query.d.ts",
|
|
156
|
+
import: "./dist/react-query.js",
|
|
157
|
+
default: "./dist/react-query.js"
|
|
158
|
+
},
|
|
159
|
+
"./auth": {
|
|
160
|
+
types: "./dist/auth.d.ts",
|
|
161
|
+
import: "./dist/auth.js",
|
|
162
|
+
default: "./dist/auth.js"
|
|
163
|
+
},
|
|
164
|
+
"./verify-webhook": {
|
|
165
|
+
types: "./dist/verify-webhook.d.ts",
|
|
166
|
+
import: "./dist/verify-webhook.js",
|
|
167
|
+
default: "./dist/verify-webhook.js"
|
|
168
|
+
},
|
|
169
|
+
"./wait-for-transaction": {
|
|
170
|
+
types: "./dist/wait-for-transaction.d.ts",
|
|
171
|
+
import: "./dist/wait-for-transaction.js",
|
|
172
|
+
default: "./dist/wait-for-transaction.js"
|
|
173
|
+
},
|
|
174
|
+
"./sdk-error": {
|
|
175
|
+
types: "./dist/errors/sdk-error.d.ts",
|
|
176
|
+
import: "./dist/errors/sdk-error.js",
|
|
177
|
+
default: "./dist/errors/sdk-error.js"
|
|
178
|
+
},
|
|
179
|
+
"./sign-webhook-receipt": {
|
|
180
|
+
types: "./dist/sign-webhook-receipt.d.ts",
|
|
181
|
+
import: "./dist/sign-webhook-receipt.js",
|
|
182
|
+
default: "./dist/sign-webhook-receipt.js"
|
|
183
|
+
},
|
|
184
|
+
"./effect": {
|
|
185
|
+
types: "./dist/effect.d.ts",
|
|
186
|
+
import: "./dist/effect.js",
|
|
187
|
+
default: "./dist/effect.js"
|
|
188
|
+
},
|
|
189
|
+
"./routes": {
|
|
190
|
+
types: "./dist/routes/index.d.ts",
|
|
191
|
+
import: "./dist/routes/index.js",
|
|
192
|
+
default: "./dist/routes/index.js"
|
|
193
|
+
},
|
|
194
|
+
"./routes/console": {
|
|
195
|
+
types: "./dist/routes/console.d.ts",
|
|
196
|
+
import: "./dist/routes/console.js",
|
|
197
|
+
default: "./dist/routes/console.js"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
publishConfig: {
|
|
201
|
+
access: "public"
|
|
202
|
+
},
|
|
203
|
+
scripts: {
|
|
204
|
+
build: "taskguard sh -c 'bun scripts/build.ts && bun scripts/check-dts-portability.ts'",
|
|
205
|
+
codegen: "taskguard bun scripts/codegen.ts",
|
|
206
|
+
publint: "publint run --strict --pack bun",
|
|
207
|
+
attw: 'archive=$(bun pm pack --destination "$PWD" --quiet | tail -n 1) && attw "$archive" --profile esm-only; code=$?; rm -f "$archive"; exit $code',
|
|
208
|
+
publish: 'cp ../LICENSE . && bun run --cwd .. publish-if-absent "$PWD"',
|
|
209
|
+
prepack: "cp ../LICENSE .",
|
|
210
|
+
test: "taskguard bun --bun vitest run --config node_modules/@tools/vitest-config/vitest.config.mjs --configLoader native --project unit --testTimeout 30000 tests/unit",
|
|
211
|
+
"test:coverage": "taskguard bun --bun vitest run --config node_modules/@tools/vitest-config/vitest.config.mjs --configLoader native --project unit --testTimeout 30000 tests/unit --coverage",
|
|
212
|
+
lint: "taskguard oxlint --deny-warnings .",
|
|
213
|
+
typecheck: "taskguard sh -c 'tsc -p . && tsc --noEmit -p scripts/tsconfig.json && tsc -p tsconfig.generated-types.json'",
|
|
214
|
+
"check:dts-portability": "bun scripts/check-dts-portability.ts",
|
|
215
|
+
"check:auth-coverage": "bun scripts/check-auth-coverage.ts",
|
|
216
|
+
"codegen:webhook-events-sdk": "bun scripts/generate-webhook-events-sdk.ts"
|
|
217
|
+
},
|
|
218
|
+
dependencies: {
|
|
219
|
+
"@better-auth/api-key": "1.7.7",
|
|
220
|
+
"@better-auth/passkey": "1.7.7",
|
|
221
|
+
"@domains/webhooks-contract": "workspace:*",
|
|
222
|
+
"better-auth": "1.7.7",
|
|
223
|
+
"better-call": "1.4.0",
|
|
224
|
+
dnum: "2.17.0",
|
|
225
|
+
standardwebhooks: "1.1.1",
|
|
226
|
+
viem: "2.57.2"
|
|
227
|
+
},
|
|
228
|
+
devDependencies: {
|
|
229
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
230
|
+
"@domains/trading-venue-contract": "workspace:*",
|
|
231
|
+
"@kernel/evm": "workspace:*",
|
|
232
|
+
"@kernel/json": "workspace:*",
|
|
233
|
+
"@tanstack/react-query": "5.104.0",
|
|
234
|
+
"@tools/typescript-config": "workspace:*",
|
|
235
|
+
"@tools/vitest-config": "workspace:*",
|
|
236
|
+
"@types/bun": "1.4.2",
|
|
237
|
+
"@wire/http-contract": "workspace:*",
|
|
238
|
+
"abort-controller": "3.0.0",
|
|
239
|
+
effect: "4.0.0",
|
|
240
|
+
publint: "0.3.24",
|
|
241
|
+
typescript: "7.0.2",
|
|
242
|
+
vitest: "5.0.3",
|
|
243
|
+
"whatwg-fetch": "3.6.20",
|
|
244
|
+
zod: "4.6.5"
|
|
245
|
+
},
|
|
246
|
+
peerDependencies: {
|
|
247
|
+
"@tanstack/react-query": "^5.101.4",
|
|
248
|
+
effect: "^4.0.0",
|
|
249
|
+
zod: "^4.5.4"
|
|
250
|
+
},
|
|
251
|
+
peerDependenciesMeta: {
|
|
252
|
+
"@tanstack/react-query": {
|
|
253
|
+
optional: true
|
|
254
|
+
},
|
|
255
|
+
effect: {
|
|
256
|
+
optional: true
|
|
257
|
+
},
|
|
258
|
+
zod: {
|
|
259
|
+
optional: true
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
engines: {
|
|
263
|
+
node: ">=20"
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/version.ts
|
|
268
|
+
var SDK_VERSION2 = package_default.version;
|
|
269
|
+
var SDK_USER_AGENT2 = `DALP SDK v${SDK_VERSION2}`;
|
|
270
|
+
|
|
271
|
+
export { makeCookieStore2, createCookieStoreFetch2, SDK_VERSION2, SDK_USER_AGENT2 };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDalpSdkConfigurationError2
|
|
3
|
+
} from "./chunk-k3ntysxx.js";
|
|
4
|
+
|
|
5
|
+
// src/auth-surface.ts
|
|
6
|
+
var DALP_AUTH_SURFACE_HEADER2 = "X-Dalp-Auth-Surface";
|
|
7
|
+
|
|
8
|
+
// src/secret.ts
|
|
9
|
+
var SECRET_REDACTION_MARKER2 = "[REDACTED]";
|
|
10
|
+
var inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
11
|
+
var secretValue = new WeakMap;
|
|
12
|
+
|
|
13
|
+
class Secret2 {
|
|
14
|
+
constructor(value) {
|
|
15
|
+
secretValue.set(this, value);
|
|
16
|
+
Object.freeze(this);
|
|
17
|
+
}
|
|
18
|
+
static from(value) {
|
|
19
|
+
if (value.trim().length === 0) {
|
|
20
|
+
throw new TypeError("DALP SDK: a secret value must not be empty.");
|
|
21
|
+
}
|
|
22
|
+
return new Secret2(value);
|
|
23
|
+
}
|
|
24
|
+
toString() {
|
|
25
|
+
return SECRET_REDACTION_MARKER2;
|
|
26
|
+
}
|
|
27
|
+
toJSON() {
|
|
28
|
+
return SECRET_REDACTION_MARKER2;
|
|
29
|
+
}
|
|
30
|
+
[inspectSymbol]() {
|
|
31
|
+
return SECRET_REDACTION_MARKER2;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
var secret2 = (value) => Secret2.from(value);
|
|
35
|
+
var unwrapSecret = (value) => {
|
|
36
|
+
const raw = secretValue.get(value);
|
|
37
|
+
if (raw === undefined) {
|
|
38
|
+
throw new TypeError("DALP SDK: cannot unwrap an invalid secret value.");
|
|
39
|
+
}
|
|
40
|
+
return raw;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/url.ts
|
|
44
|
+
function normalizeDalpBaseUrl(url) {
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = new URL(url);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw createDalpSdkConfigurationError2({
|
|
50
|
+
message: `DALP SDK: invalid url "${url}". Provide a full URL including the protocol (e.g., "https://dalp.example.com").`,
|
|
51
|
+
why: "The SDK could not parse the configured DALP API URL.",
|
|
52
|
+
fix: 'Provide a full http:// or https:// URL, for example "https://dalp.example.com".',
|
|
53
|
+
cause: error
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
57
|
+
throw createDalpSdkConfigurationError2({
|
|
58
|
+
message: `DALP SDK: url must use https:// or http:// protocol, got "${parsed.protocol}".`,
|
|
59
|
+
why: `The SDK received a URL with the unsupported "${parsed.protocol}" protocol.`,
|
|
60
|
+
fix: 'Use a DALP API base URL that starts with "https://" or "http://".'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return `${parsed.origin}${parsed.pathname.replace(/\/+$/, "")}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/runtime.ts
|
|
67
|
+
var REACT_NATIVE_NAVIGATOR_PRODUCT = "ReactNative";
|
|
68
|
+
function detectDalpRuntime() {
|
|
69
|
+
if (Reflect.get(globalThis, "navigator") !== undefined && Reflect.get(navigator, "product") === REACT_NATIVE_NAVIGATOR_PRODUCT) {
|
|
70
|
+
return "react-native";
|
|
71
|
+
}
|
|
72
|
+
return globalThis.window === undefined ? "server" : "browser";
|
|
73
|
+
}
|
|
74
|
+
function runtimeCredentials(runtime) {
|
|
75
|
+
return runtime === "browser" ? "include" : "omit";
|
|
76
|
+
}
|
|
77
|
+
var WHATWG_FETCH_POLYFILL_FLAG = "polyfill";
|
|
78
|
+
function isBufferingFetch(fetchImpl) {
|
|
79
|
+
return typeof fetchImpl === "function" && Reflect.get(fetchImpl, WHATWG_FETCH_POLYFILL_FLAG) === true;
|
|
80
|
+
}
|
|
81
|
+
function keepBufferingMarker(wrapped, wrapper) {
|
|
82
|
+
return isBufferingFetch(wrapped) ? Object.assign(wrapper, { [WHATWG_FETCH_POLYFILL_FLAG]: true }) : wrapper;
|
|
83
|
+
}
|
|
84
|
+
function refuseBundledApiKey(runtime) {
|
|
85
|
+
if (runtime === "server") {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
throw createDalpSdkConfigurationError2({
|
|
89
|
+
message: `DALP SDK: API keys are server/CLI-only credentials and cannot configure a ${runtime} client.`,
|
|
90
|
+
why: "An API key placed in a browser or app bundle ships the credential to every visitor or device.",
|
|
91
|
+
fix: "Keep the API key on the server or CLI process; browser and app clients authenticate with the session cookie."
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ../kernel/json/src/step-up-payload-text.ts
|
|
96
|
+
var PROOF_FIELD = "walletVerification";
|
|
97
|
+
var isAbsent = (value) => value === undefined || typeof value === "function" || typeof value === "symbol";
|
|
98
|
+
var byKey = ([left], [right]) => {
|
|
99
|
+
if (left < right) {
|
|
100
|
+
return -1;
|
|
101
|
+
}
|
|
102
|
+
if (left > right) {
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
return 0;
|
|
106
|
+
};
|
|
107
|
+
var presentEntries = (fields, omitted) => {
|
|
108
|
+
const entries = [];
|
|
109
|
+
for (const [key, field] of fields) {
|
|
110
|
+
if (key !== omitted && !isAbsent(field)) {
|
|
111
|
+
entries.push([key, field]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return entries.toSorted(byKey);
|
|
115
|
+
};
|
|
116
|
+
var canonicalText = (value, omitted = null) => {
|
|
117
|
+
if (value === null || isAbsent(value)) {
|
|
118
|
+
return "null";
|
|
119
|
+
}
|
|
120
|
+
if (typeof value !== "object") {
|
|
121
|
+
return JSON.stringify(value);
|
|
122
|
+
}
|
|
123
|
+
if (Array.isArray(value)) {
|
|
124
|
+
return `[${value.map((item) => canonicalText(item)).join(",")}]`;
|
|
125
|
+
}
|
|
126
|
+
return `{${presentEntries(Object.entries(value), omitted).map(([key, field]) => `${JSON.stringify(key)}:${canonicalText(field)}`).join(",")}}`;
|
|
127
|
+
};
|
|
128
|
+
var stepUpPayloadText = (body) => canonicalText(body, PROOF_FIELD);
|
|
129
|
+
|
|
130
|
+
// src/client/step-up-challenge.ts
|
|
131
|
+
import { sha256, stringToBytes } from "viem/utils";
|
|
132
|
+
var STEP_UP_CHALLENGE_HEADER = "X-Step-Up-Challenge";
|
|
133
|
+
var WALLET_VERIFICATION_HEADER = "X-Wallet-Verification";
|
|
134
|
+
var STEP_UP_CHALLENGE_PATH = "/api/v2/step-up-challenges";
|
|
135
|
+
var PROOF_FIELD2 = "walletVerification";
|
|
136
|
+
var HEX_PREFIX = "0x";
|
|
137
|
+
function carriesWalletProof(body) {
|
|
138
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
const proof = Reflect.get(body, PROOF_FIELD2);
|
|
142
|
+
return proof !== null && proof !== undefined;
|
|
143
|
+
}
|
|
144
|
+
async function stepUpChallengeRequest(operation, target, body) {
|
|
145
|
+
const payloadDigest = sha256(stringToBytes(stepUpPayloadText(body))).slice(HEX_PREFIX.length);
|
|
146
|
+
return { operation, target, payloadDigest };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { DALP_AUTH_SURFACE_HEADER2, SECRET_REDACTION_MARKER2, Secret2, secret2, unwrapSecret, normalizeDalpBaseUrl, detectDalpRuntime, runtimeCredentials, isBufferingFetch, keepBufferingMarker, refuseBundledApiKey, STEP_UP_CHALLENGE_HEADER, WALLET_VERIFICATION_HEADER, STEP_UP_CHALLENGE_PATH, carriesWalletProof, stepUpChallengeRequest };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// src/proxy/builder.ts
|
|
2
|
+
var ROUTE_ID_DOT_OR_SLASH = /[./]/u;
|
|
3
|
+
function buildIndex(table) {
|
|
4
|
+
const root = { children: new Map };
|
|
5
|
+
for (const id of Object.keys(table.routes)) {
|
|
6
|
+
let cursor = root;
|
|
7
|
+
for (const segment of id.split(ROUTE_ID_DOT_OR_SLASH)) {
|
|
8
|
+
let next = cursor.children.get(segment);
|
|
9
|
+
if (next === undefined) {
|
|
10
|
+
next = { children: new Map };
|
|
11
|
+
cursor.children.set(segment, next);
|
|
12
|
+
}
|
|
13
|
+
cursor = next;
|
|
14
|
+
}
|
|
15
|
+
cursor.routeId = id;
|
|
16
|
+
}
|
|
17
|
+
return root;
|
|
18
|
+
}
|
|
19
|
+
function makeNode(node, table, executor, factories, cache) {
|
|
20
|
+
const cached = cache.get(node);
|
|
21
|
+
if (cached !== undefined) {
|
|
22
|
+
return cached;
|
|
23
|
+
}
|
|
24
|
+
const route = node.routeId === undefined ? undefined : table.routes[node.routeId];
|
|
25
|
+
const id = node.routeId;
|
|
26
|
+
const target = route === undefined || id === undefined ? {} : Object.assign((input, options) => executor(route, id, input, options), {
|
|
27
|
+
queryOptions: (input, options) => factories.queryOptions(route, id, input, options),
|
|
28
|
+
mutationOptions: (options) => factories.mutationOptions(route, id, options)
|
|
29
|
+
});
|
|
30
|
+
const proxy = new Proxy(target, {
|
|
31
|
+
get(base, property, receiver) {
|
|
32
|
+
if (typeof property !== "string") {
|
|
33
|
+
return Reflect.get(base, property, receiver);
|
|
34
|
+
}
|
|
35
|
+
if (Object.hasOwn(base, property) || property in Function.prototype) {
|
|
36
|
+
return Reflect.get(base, property, receiver);
|
|
37
|
+
}
|
|
38
|
+
const child = node.children.get(property);
|
|
39
|
+
return child === undefined ? undefined : makeNode(child, table, executor, factories, cache);
|
|
40
|
+
},
|
|
41
|
+
has(base, property) {
|
|
42
|
+
return typeof property === "string" && node.children.has(property) || Reflect.has(base, property);
|
|
43
|
+
},
|
|
44
|
+
ownKeys(base) {
|
|
45
|
+
return [...new Set([...Reflect.ownKeys(base), ...node.children.keys()])];
|
|
46
|
+
},
|
|
47
|
+
getOwnPropertyDescriptor(base, property) {
|
|
48
|
+
if (typeof property === "string" && node.children.has(property)) {
|
|
49
|
+
return {
|
|
50
|
+
configurable: true,
|
|
51
|
+
enumerable: true,
|
|
52
|
+
value: makeNode(node.children.get(property), table, executor, factories, cache)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return Reflect.getOwnPropertyDescriptor(base, property);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
cache.set(node, proxy);
|
|
59
|
+
return proxy;
|
|
60
|
+
}
|
|
61
|
+
function buildProxy(table, executor, factories) {
|
|
62
|
+
return makeNode(buildIndex(table), table, executor, factories, new Map);
|
|
63
|
+
}
|
|
64
|
+
function findRoute(table, id) {
|
|
65
|
+
return table.routes[id];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { buildProxy, findRoute };
|