@settlemint/dalp-sdk 3.1.17 → 3.1.18-main.33796544973
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 +154 -169
- package/dist/auth/client.d.ts +113 -0
- package/dist/auth/live.d.ts +4366 -0
- package/dist/{auth-permissions.d.ts → auth/permissions.d.ts} +1 -2
- package/dist/{auth-wallet-plugins.d.ts → auth/wallet-plugins.d.ts} +69 -5
- package/dist/auth.d.ts +22 -115
- package/dist/auth.js +329 -0
- package/dist/bundler.d.ts +14 -207
- package/dist/bundler.js +99 -0
- package/dist/chunk-18qmk0m7.js +4 -0
- package/dist/chunk-def7rqy6.js +946 -0
- package/dist/chunk-f4t1bm86.js +67 -0
- package/dist/chunk-fjnq61hj.js +11 -0
- package/dist/chunk-h12fatty.js +63 -0
- package/dist/chunk-r0vsftj4.js +102 -0
- package/dist/chunk-rzmr29dq.js +260 -0
- package/dist/chunk-x0z79vz6.js +33 -0
- package/dist/chunk-y0d2c7kp.js +54 -0
- package/dist/client/conditional-request.d.ts +30 -0
- package/dist/client/factory.d.ts +14 -0
- package/dist/client/query-serializer.d.ts +2 -0
- package/dist/client/request-compression.d.ts +47 -0
- package/dist/client/ssr-fetch.d.ts +12 -0
- package/dist/effect.d.ts +69 -0
- package/dist/effect.js +82 -0
- package/dist/errors/api-error.d.ts +29 -0
- package/dist/errors/find-current-error.d.ts +8 -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 +41271 -0
- package/dist/generated/response-scalars.d.ts +9 -0
- package/dist/generated/routes.d.ts +12 -0
- package/dist/index.d.ts +28 -40
- package/dist/index.js +131 -96109
- 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 +67 -0
- package/dist/proxy/sse.d.ts +54 -0
- package/dist/proxy/tanstack.d.ts +27 -0
- package/dist/proxy/transport.d.ts +73 -0
- package/dist/react-query.d.ts +16 -0
- package/dist/react-query.js +13 -0
- package/dist/readonly-deep.d.ts +12 -0
- package/dist/reads-as-funding-paused.d.ts +20 -0
- package/dist/routes/index.d.ts +20 -0
- package/dist/routes/index.js +10 -0
- package/dist/routes/types.d.ts +51 -0
- package/dist/runtime-exports.d.ts +20 -0
- package/dist/runtime-exports.js +16 -0
- package/dist/scalars/big-decimal.d.ts +16 -0
- package/dist/scalars/ethereum-address.d.ts +20 -0
- package/dist/scalars/exchange-rates.d.ts +27 -0
- package/dist/scalars/index.d.ts +18 -0
- package/dist/scalars/index.js +86 -0
- package/dist/scalars/organization-id.d.ts +20 -0
- package/dist/secret.d.ts +14 -0
- package/dist/sign-webhook-receipt.d.ts +76 -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 +44 -0
- package/dist/types.d.ts +65 -102
- 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 -1
- package/dist/wait-for-transaction.d.ts +54 -81
- package/dist/wait-for-transaction.js +120 -0
- package/dist/webhook-events.d.ts +44 -27
- package/package.json +103 -30
- 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.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 -17
- 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 -650
- package/dist/dapi-errors.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -633
- 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/wait-for-transaction.d.ts.map +0 -1
- package/dist/webhook-events.d.ts.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/proxy/builder.ts
|
|
2
|
+
function buildIndex(table) {
|
|
3
|
+
const root = { children: new Map };
|
|
4
|
+
for (const id of Object.keys(table.routes)) {
|
|
5
|
+
let cursor = root;
|
|
6
|
+
for (const segment of id.split("/")) {
|
|
7
|
+
let next = cursor.children.get(segment);
|
|
8
|
+
if (next === undefined) {
|
|
9
|
+
next = { children: new Map };
|
|
10
|
+
cursor.children.set(segment, next);
|
|
11
|
+
}
|
|
12
|
+
cursor = next;
|
|
13
|
+
}
|
|
14
|
+
cursor.routeId = id;
|
|
15
|
+
}
|
|
16
|
+
return root;
|
|
17
|
+
}
|
|
18
|
+
function makeNode(node, table, executor, factories, cache) {
|
|
19
|
+
const cached = cache.get(node);
|
|
20
|
+
if (cached !== undefined) {
|
|
21
|
+
return cached;
|
|
22
|
+
}
|
|
23
|
+
const route = node.routeId === undefined ? undefined : table.routes[node.routeId];
|
|
24
|
+
const id = node.routeId;
|
|
25
|
+
const target = route === undefined || id === undefined ? {} : Object.assign((input, options) => executor(route, id, input, options), {
|
|
26
|
+
queryOptions: (input, options) => factories.queryOptions(route, id, input, options),
|
|
27
|
+
mutationOptions: (options) => factories.mutationOptions(route, id, options)
|
|
28
|
+
});
|
|
29
|
+
const proxy = new Proxy(target, {
|
|
30
|
+
get(base, property, receiver) {
|
|
31
|
+
if (typeof property !== "string") {
|
|
32
|
+
return Reflect.get(base, property, receiver);
|
|
33
|
+
}
|
|
34
|
+
if (Object.hasOwn(base, property) || property in Function.prototype) {
|
|
35
|
+
return Reflect.get(base, property, receiver);
|
|
36
|
+
}
|
|
37
|
+
const child = node.children.get(property);
|
|
38
|
+
return child === undefined ? undefined : makeNode(child, table, executor, factories, cache);
|
|
39
|
+
},
|
|
40
|
+
has(base, property) {
|
|
41
|
+
return typeof property === "string" && node.children.has(property) || Reflect.has(base, property);
|
|
42
|
+
},
|
|
43
|
+
ownKeys(base) {
|
|
44
|
+
return [...new Set([...Reflect.ownKeys(base), ...node.children.keys()])];
|
|
45
|
+
},
|
|
46
|
+
getOwnPropertyDescriptor(base, property) {
|
|
47
|
+
if (typeof property === "string" && node.children.has(property)) {
|
|
48
|
+
return {
|
|
49
|
+
configurable: true,
|
|
50
|
+
enumerable: true,
|
|
51
|
+
value: makeNode(node.children.get(property), table, executor, factories, cache)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return Reflect.getOwnPropertyDescriptor(base, property);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
cache.set(node, proxy);
|
|
58
|
+
return proxy;
|
|
59
|
+
}
|
|
60
|
+
function buildProxy(table, executor, factories) {
|
|
61
|
+
return makeNode(buildIndex(table), table, executor, factories, new Map);
|
|
62
|
+
}
|
|
63
|
+
function findRoute(table, id) {
|
|
64
|
+
return table.routes[id];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { buildProxy, findRoute };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/reads-as-funding-paused.ts
|
|
2
|
+
function readsAsFundingPaused(status) {
|
|
3
|
+
if (status === null || typeof status !== "object") {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const requirement = Reflect.get(status, "activeRequirement");
|
|
7
|
+
return requirement !== undefined && requirement !== null;
|
|
8
|
+
}
|
|
9
|
+
var PAUSED_POLL_INTERVAL_MAX_MS = 30000;
|
|
10
|
+
|
|
11
|
+
export { readsAsFundingPaused, PAUSED_POLL_INTERVAL_MAX_MS };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDalpSdkConfigurationError
|
|
3
|
+
} from "./chunk-y0d2c7kp.js";
|
|
4
|
+
|
|
5
|
+
// src/secret.ts
|
|
6
|
+
var SECRET_REDACTION_MARKER = "[REDACTED]";
|
|
7
|
+
var inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
8
|
+
var secretValue = new WeakMap;
|
|
9
|
+
|
|
10
|
+
class Secret {
|
|
11
|
+
constructor(value) {
|
|
12
|
+
secretValue.set(this, value);
|
|
13
|
+
Object.freeze(this);
|
|
14
|
+
}
|
|
15
|
+
static from(value) {
|
|
16
|
+
if (value.trim().length === 0) {
|
|
17
|
+
throw new TypeError("DALP SDK: a secret value must not be empty.");
|
|
18
|
+
}
|
|
19
|
+
return new Secret(value);
|
|
20
|
+
}
|
|
21
|
+
toString() {
|
|
22
|
+
return SECRET_REDACTION_MARKER;
|
|
23
|
+
}
|
|
24
|
+
toJSON() {
|
|
25
|
+
return SECRET_REDACTION_MARKER;
|
|
26
|
+
}
|
|
27
|
+
[inspectSymbol]() {
|
|
28
|
+
return SECRET_REDACTION_MARKER;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var secret = (value) => Secret.from(value);
|
|
32
|
+
var unwrapSecret = (value) => {
|
|
33
|
+
const raw = secretValue.get(value);
|
|
34
|
+
if (raw === undefined) {
|
|
35
|
+
throw new TypeError("DALP SDK: cannot unwrap an invalid secret value.");
|
|
36
|
+
}
|
|
37
|
+
return raw;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/url.ts
|
|
41
|
+
function normalizeDalpBaseUrl(url) {
|
|
42
|
+
let parsed;
|
|
43
|
+
try {
|
|
44
|
+
parsed = new URL(url);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw createDalpSdkConfigurationError({
|
|
47
|
+
message: `DALP SDK: invalid url "${url}". Provide a full URL including the protocol (e.g., "https://dalp.example.com").`,
|
|
48
|
+
why: "The SDK could not parse the configured DALP API URL.",
|
|
49
|
+
fix: 'Provide a full http:// or https:// URL, for example "https://dalp.example.com".',
|
|
50
|
+
cause: error
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
54
|
+
throw createDalpSdkConfigurationError({
|
|
55
|
+
message: `DALP SDK: url must use https:// or http:// protocol, got "${parsed.protocol}".`,
|
|
56
|
+
why: `The SDK received a URL with the unsupported "${parsed.protocol}" protocol.`,
|
|
57
|
+
fix: 'Use a DALP API base URL that starts with "https://" or "http://".'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return `${parsed.origin}${parsed.pathname.replace(/\/+$/, "")}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { SECRET_REDACTION_MARKER, Secret, secret, unwrapSecret, normalizeDalpBaseUrl };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/verify-webhook.ts
|
|
2
|
+
import { Webhook as StandardWebhook } from "standardwebhooks";
|
|
3
|
+
var DEFAULT_TIMESTAMP_TOLERANCE_SECONDS = 5 * 60;
|
|
4
|
+
function toStandardWebhookSecret(secret) {
|
|
5
|
+
return secret.replace(/^dalp_whsk_/u, "");
|
|
6
|
+
}
|
|
7
|
+
async function verifyWebhook(input) {
|
|
8
|
+
const headers = normalizeHeaders(input.headers);
|
|
9
|
+
const nowMillis = input.now instanceof Date ? input.now.getTime() : input.now ?? Date.now();
|
|
10
|
+
const tolerance = input.timestampToleranceSeconds ?? DEFAULT_TIMESTAMP_TOLERANCE_SECONDS;
|
|
11
|
+
if (!hasFiniteTimestamp(headers) || isOutsideTimestampTolerance(headers, nowMillis, tolerance)) {
|
|
12
|
+
return { ok: false, code: "TIMESTAMP_SKEW" };
|
|
13
|
+
}
|
|
14
|
+
const rawText = typeof input.rawBody === "string" ? input.rawBody : new TextDecoder().decode(input.rawBody);
|
|
15
|
+
const eventId = headers["webhook-id"];
|
|
16
|
+
if (eventId !== undefined && await input.replayStore?.has(eventId) === true) {
|
|
17
|
+
return { ok: false, code: "REPLAYED_EVENT" };
|
|
18
|
+
}
|
|
19
|
+
let sawMalformedBody = false;
|
|
20
|
+
let sawReplayStoreFailure = false;
|
|
21
|
+
for (const candidate of Array.isArray(input.secret) ? input.secret : [input.secret]) {
|
|
22
|
+
if (!matchesSignature(candidate, rawText, headers)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
let event;
|
|
26
|
+
try {
|
|
27
|
+
event = JSON.parse(rawText);
|
|
28
|
+
} catch {
|
|
29
|
+
sawMalformedBody = true;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (eventId !== undefined && input.replayStore !== undefined) {
|
|
33
|
+
try {
|
|
34
|
+
await input.replayStore.add(eventId);
|
|
35
|
+
} catch {
|
|
36
|
+
sawReplayStoreFailure = true;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { ok: true, event };
|
|
41
|
+
}
|
|
42
|
+
if (sawReplayStoreFailure) {
|
|
43
|
+
return { ok: false, code: "REPLAY_STORE_FAILURE" };
|
|
44
|
+
}
|
|
45
|
+
if (sawMalformedBody) {
|
|
46
|
+
return { ok: false, code: "MALFORMED_BODY" };
|
|
47
|
+
}
|
|
48
|
+
return { ok: false, code: classifySignatureFailure(rawText, headers) };
|
|
49
|
+
}
|
|
50
|
+
function matchesSignature(secret, rawBody, headers) {
|
|
51
|
+
const eventId = headers["webhook-id"];
|
|
52
|
+
const timestamp = Number(headers["webhook-timestamp"]);
|
|
53
|
+
const signatures = headers["webhook-signature"];
|
|
54
|
+
if (eventId === undefined || !Number.isFinite(timestamp) || signatures === undefined) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const expected = new StandardWebhook(toStandardWebhookSecret(secret)).sign(eventId, new Date(timestamp * 1000), rawBody);
|
|
58
|
+
return signatures.split(" ").some((signature) => {
|
|
59
|
+
const left = new TextEncoder().encode(signature);
|
|
60
|
+
const right = new TextEncoder().encode(expected);
|
|
61
|
+
if (left.byteLength !== right.byteLength) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
let difference = 0;
|
|
65
|
+
for (let index = 0;index < left.byteLength; index += 1) {
|
|
66
|
+
difference |= (left[index] ?? 0) ^ (right[index] ?? 0);
|
|
67
|
+
}
|
|
68
|
+
return difference === 0;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function normalizeHeaders(input) {
|
|
72
|
+
if (input instanceof Headers) {
|
|
73
|
+
return Object.fromEntries(input.entries());
|
|
74
|
+
}
|
|
75
|
+
const headers = {};
|
|
76
|
+
for (const [key, value] of Object.entries(input)) {
|
|
77
|
+
if (value !== undefined) {
|
|
78
|
+
headers[key.toLowerCase()] = typeof value === "string" ? value : value.join(",");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return headers;
|
|
82
|
+
}
|
|
83
|
+
function hasFiniteTimestamp(headers) {
|
|
84
|
+
return Number.isFinite(Number(headers["webhook-timestamp"]));
|
|
85
|
+
}
|
|
86
|
+
function isOutsideTimestampTolerance(headers, nowMillis, toleranceSeconds) {
|
|
87
|
+
const timestamp = Number(headers["webhook-timestamp"]);
|
|
88
|
+
return Number.isFinite(timestamp) && Math.abs(nowMillis / 1000 - timestamp) > toleranceSeconds;
|
|
89
|
+
}
|
|
90
|
+
function classifySignatureFailure(rawBody, headers) {
|
|
91
|
+
try {
|
|
92
|
+
const parsed = JSON.parse(rawBody);
|
|
93
|
+
if (typeof parsed.evt_id !== "string" || parsed.evt_id !== headers["webhook-id"]) {
|
|
94
|
+
return "BODY_HASH_MISMATCH";
|
|
95
|
+
}
|
|
96
|
+
} catch {
|
|
97
|
+
return "BODY_HASH_MISMATCH";
|
|
98
|
+
}
|
|
99
|
+
return "SECRET_MISMATCH";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { toStandardWebhookSecret, verifyWebhook };
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// src/transport/cookie-store.ts
|
|
2
|
+
var parseCookieHeader = (header) => {
|
|
3
|
+
const cookies = new Map;
|
|
4
|
+
for (const part of header.split(";")) {
|
|
5
|
+
const pair = part.trim();
|
|
6
|
+
const separator = pair.indexOf("=");
|
|
7
|
+
if (separator > 0) {
|
|
8
|
+
cookies.set(pair.slice(0, separator), pair);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return cookies;
|
|
12
|
+
};
|
|
13
|
+
var isCookieDeletion = (setCookie, now = Date.now()) => {
|
|
14
|
+
if (/\bmax-age\s*=\s*-?0+\b/iu.test(setCookie) || /\bmax-age\s*=\s*-\d+\b/iu.test(setCookie)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const expires = /\bexpires\s*=\s*([^;]+)/iu.exec(setCookie)?.[1];
|
|
18
|
+
if (expires === undefined) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const parsed = Date.parse(expires.trim());
|
|
22
|
+
return !Number.isNaN(parsed) && parsed <= now;
|
|
23
|
+
};
|
|
24
|
+
function makeCookieStore(initialHeader = "") {
|
|
25
|
+
const cookies = parseCookieHeader(initialHeader);
|
|
26
|
+
return {
|
|
27
|
+
header: () => [...cookies.values()].join("; "),
|
|
28
|
+
isEmpty: () => cookies.size === 0,
|
|
29
|
+
setCookieHeader: (header) => {
|
|
30
|
+
cookies.clear();
|
|
31
|
+
for (const [name, pair] of parseCookieHeader(header)) {
|
|
32
|
+
cookies.set(name, pair);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
storeSetCookieHeaders: (headers) => {
|
|
36
|
+
for (const setCookie of headers) {
|
|
37
|
+
const pair = setCookie.split(";", 1)[0]?.trim() ?? "";
|
|
38
|
+
const separator = pair.indexOf("=");
|
|
39
|
+
if (separator <= 0) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const name = pair.slice(0, separator);
|
|
43
|
+
if (isCookieDeletion(setCookie)) {
|
|
44
|
+
cookies.delete(name);
|
|
45
|
+
} else {
|
|
46
|
+
cookies.set(name, pair);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var getSetCookieHeaders = (headers) => {
|
|
53
|
+
const { getSetCookie } = headers;
|
|
54
|
+
if (getSetCookie !== undefined) {
|
|
55
|
+
return getSetCookie.call(headers);
|
|
56
|
+
}
|
|
57
|
+
const value = headers.get("set-cookie");
|
|
58
|
+
return value === null ? [] : splitCombinedSetCookie(value);
|
|
59
|
+
};
|
|
60
|
+
var splitCombinedSetCookie = (value) => {
|
|
61
|
+
const cookies = [];
|
|
62
|
+
const lowered = value.toLowerCase();
|
|
63
|
+
let start = 0;
|
|
64
|
+
let inExpires = false;
|
|
65
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
66
|
+
if (lowered.startsWith("expires=", index)) {
|
|
67
|
+
inExpires = true;
|
|
68
|
+
}
|
|
69
|
+
const character = value[index];
|
|
70
|
+
if (character === ";") {
|
|
71
|
+
inExpires = false;
|
|
72
|
+
}
|
|
73
|
+
if (character !== "," || inExpires) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const next = value.slice(index + 1);
|
|
77
|
+
if (!/^\s*[\w!#$%&'*+\-.^`|~]+=/u.test(next)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
cookies.push(value.slice(start, index).trim());
|
|
81
|
+
start = index + 1;
|
|
82
|
+
}
|
|
83
|
+
const finalCookie = value.slice(start).trim();
|
|
84
|
+
if (finalCookie.length > 0) {
|
|
85
|
+
cookies.push(finalCookie);
|
|
86
|
+
}
|
|
87
|
+
return cookies;
|
|
88
|
+
};
|
|
89
|
+
function createCookieStoreFetch(cookieStore, fetchImpl = globalThis.fetch) {
|
|
90
|
+
return async (input, init) => {
|
|
91
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
92
|
+
if (!cookieStore.isEmpty() && !headers.has("cookie")) {
|
|
93
|
+
headers.set("cookie", cookieStore.header());
|
|
94
|
+
}
|
|
95
|
+
const response = await fetchImpl(input, { ...init, headers });
|
|
96
|
+
if (response.status < 500) {
|
|
97
|
+
cookieStore.storeSetCookieHeaders(getSetCookieHeaders(response.headers));
|
|
98
|
+
}
|
|
99
|
+
return response;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// package.json
|
|
103
|
+
var package_default = {
|
|
104
|
+
name: "@settlemint/dalp-sdk",
|
|
105
|
+
version: "3.1.18-main.33796544973",
|
|
106
|
+
private: false,
|
|
107
|
+
description: "Fully typed SDK for the DALP tokenization platform API",
|
|
108
|
+
homepage: "https://settlemint.com",
|
|
109
|
+
bugs: {
|
|
110
|
+
email: "support@settlemint.com"
|
|
111
|
+
},
|
|
112
|
+
license: "SEE LICENSE IN LICENSE",
|
|
113
|
+
author: {
|
|
114
|
+
name: "SettleMint",
|
|
115
|
+
email: "support@settlemint.com",
|
|
116
|
+
url: "https://settlemint.com"
|
|
117
|
+
},
|
|
118
|
+
files: [
|
|
119
|
+
"dist",
|
|
120
|
+
"README.md",
|
|
121
|
+
"LICENSE"
|
|
122
|
+
],
|
|
123
|
+
type: "module",
|
|
124
|
+
sideEffects: [
|
|
125
|
+
"./src/**"
|
|
126
|
+
],
|
|
127
|
+
exports: {
|
|
128
|
+
"./package.json": "./package.json",
|
|
129
|
+
"./runtime-exports": {
|
|
130
|
+
types: "./dist/runtime-exports.d.ts",
|
|
131
|
+
import: "./dist/runtime-exports.js",
|
|
132
|
+
default: "./dist/runtime-exports.js"
|
|
133
|
+
},
|
|
134
|
+
".": {
|
|
135
|
+
types: "./dist/index.d.ts",
|
|
136
|
+
import: "./dist/index.js",
|
|
137
|
+
default: "./dist/index.js"
|
|
138
|
+
},
|
|
139
|
+
"./types": {
|
|
140
|
+
types: "./dist/types.d.ts",
|
|
141
|
+
import: "./dist/types.js",
|
|
142
|
+
default: "./dist/types.js"
|
|
143
|
+
},
|
|
144
|
+
"./scalars": {
|
|
145
|
+
types: "./dist/scalars/index.d.ts",
|
|
146
|
+
import: "./dist/scalars/index.js",
|
|
147
|
+
default: "./dist/scalars/index.js"
|
|
148
|
+
},
|
|
149
|
+
"./react-query": {
|
|
150
|
+
types: "./dist/react-query.d.ts",
|
|
151
|
+
import: "./dist/react-query.js",
|
|
152
|
+
default: "./dist/react-query.js"
|
|
153
|
+
},
|
|
154
|
+
"./auth": {
|
|
155
|
+
types: "./dist/auth.d.ts",
|
|
156
|
+
import: "./dist/auth.js",
|
|
157
|
+
default: "./dist/auth.js"
|
|
158
|
+
},
|
|
159
|
+
"./bundler": {
|
|
160
|
+
types: "./dist/bundler.d.ts",
|
|
161
|
+
import: "./dist/bundler.js",
|
|
162
|
+
default: "./dist/bundler.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
|
+
},
|
|
195
|
+
publishConfig: {
|
|
196
|
+
access: "public"
|
|
197
|
+
},
|
|
198
|
+
scripts: {
|
|
199
|
+
build: "bun scripts/build.ts && bun scripts/check-dts-portability.ts && bun scripts/ensure-dist.ts --check",
|
|
200
|
+
"ensure-dist": "bun scripts/ensure-dist.ts",
|
|
201
|
+
codegen: "bun scripts/codegen.ts",
|
|
202
|
+
publint: "publint run --strict --pack bun",
|
|
203
|
+
attw: 'archive=$(bun pm pack --destination "$PWD" --quiet | tail -n 1) && attw "$archive" --profile esm-only; code=$?; rm -f "$archive"; exit $code',
|
|
204
|
+
publish: "cp ../../LICENSE . && bun publish --tolerate-republish --ignore-scripts --tag ${TAG:-latest} --access public",
|
|
205
|
+
prepack: "cp ../../LICENSE .",
|
|
206
|
+
test: "bun test --timeout 30000 tests/unit",
|
|
207
|
+
"test:coverage": "bun test --timeout 30000 --coverage --coverage-reporter=lcov --coverage-reporter=text tests/unit",
|
|
208
|
+
lint: "oxfmt --check .",
|
|
209
|
+
typecheck: "oxlint --deny-warnings . && tsc --noEmit -p scripts/tsconfig.json",
|
|
210
|
+
"check:zero-effect": "bun scripts/check-zero-effect.ts",
|
|
211
|
+
"check:dts-portability": "bun scripts/check-dts-portability.ts",
|
|
212
|
+
"check:auth-coverage": "bun scripts/check-auth-coverage.ts",
|
|
213
|
+
"codegen:webhook-events-sdk": "bun scripts/generate-webhook-events-sdk.ts"
|
|
214
|
+
},
|
|
215
|
+
dependencies: {
|
|
216
|
+
"@better-auth/api-key": "1.7.2",
|
|
217
|
+
"@better-auth/passkey": "1.7.2",
|
|
218
|
+
"better-auth": "1.7.2",
|
|
219
|
+
"better-call": "1.4.0",
|
|
220
|
+
dnum: "2.17.0",
|
|
221
|
+
standardwebhooks: "1.1.1",
|
|
222
|
+
viem: "2.56.1"
|
|
223
|
+
},
|
|
224
|
+
devDependencies: {
|
|
225
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
226
|
+
"@core/schema": "workspace:*",
|
|
227
|
+
"@tanstack/react-query": "5.102.8",
|
|
228
|
+
"@tools/typescript-config": "workspace:*",
|
|
229
|
+
"@types/bun": "catalog:toolchain",
|
|
230
|
+
effect: "catalog:effect",
|
|
231
|
+
publint: "0.3.24",
|
|
232
|
+
typescript: "7.0.2",
|
|
233
|
+
zod: "4.5.4"
|
|
234
|
+
},
|
|
235
|
+
peerDependencies: {
|
|
236
|
+
"@tanstack/react-query": "^5.101.4",
|
|
237
|
+
effect: "^4.0.0-rc.112",
|
|
238
|
+
zod: "^4.5.4"
|
|
239
|
+
},
|
|
240
|
+
peerDependenciesMeta: {
|
|
241
|
+
"@tanstack/react-query": {
|
|
242
|
+
optional: true
|
|
243
|
+
},
|
|
244
|
+
effect: {
|
|
245
|
+
optional: true
|
|
246
|
+
},
|
|
247
|
+
zod: {
|
|
248
|
+
optional: true
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
engines: {
|
|
252
|
+
node: ">=20"
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// src/version.ts
|
|
257
|
+
var SDK_VERSION = package_default.version;
|
|
258
|
+
var SDK_USER_AGENT = `DALP SDK v${SDK_VERSION}`;
|
|
259
|
+
|
|
260
|
+
export { makeCookieStore, createCookieStoreFetch, SDK_VERSION, SDK_USER_AGENT };
|
|
@@ -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-def7rqy6.js";
|
|
12
|
+
import {
|
|
13
|
+
data
|
|
14
|
+
} from "./chunk-18qmk0m7.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 };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/errors/sdk-error.ts
|
|
2
|
+
var DALP_SDK_ERROR_CODE = "DALP_SDK_ERROR";
|
|
3
|
+
var DALP_SDK_ERROR_CATEGORY = "sdk.configuration";
|
|
4
|
+
|
|
5
|
+
class DalpSdkError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
category;
|
|
8
|
+
status;
|
|
9
|
+
retryable;
|
|
10
|
+
why;
|
|
11
|
+
fix;
|
|
12
|
+
details;
|
|
13
|
+
retryAfterSeconds;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options.message, { cause: options.cause });
|
|
16
|
+
this.name = "DalpSdkError";
|
|
17
|
+
this.code = options.code ?? DALP_SDK_ERROR_CODE;
|
|
18
|
+
this.category = options.category;
|
|
19
|
+
this.status = options.status;
|
|
20
|
+
this.retryable = options.retryable;
|
|
21
|
+
this.why = options.why;
|
|
22
|
+
this.fix = options.fix;
|
|
23
|
+
this.details = options.details;
|
|
24
|
+
this.retryAfterSeconds = options.retryAfterSeconds;
|
|
25
|
+
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
return {
|
|
28
|
+
name: "DalpSdkError",
|
|
29
|
+
code: this.code,
|
|
30
|
+
category: this.category,
|
|
31
|
+
retryable: this.retryable,
|
|
32
|
+
message: this.message,
|
|
33
|
+
why: this.why,
|
|
34
|
+
fix: this.fix,
|
|
35
|
+
...this.status === undefined ? {} : { status: this.status },
|
|
36
|
+
...this.details === undefined ? {} : { details: this.details },
|
|
37
|
+
...this.retryAfterSeconds === undefined ? {} : { retryAfterSeconds: this.retryAfterSeconds }
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function createDalpSdkConfigurationError(input) {
|
|
42
|
+
return new DalpSdkError({
|
|
43
|
+
code: DALP_SDK_ERROR_CODE,
|
|
44
|
+
category: DALP_SDK_ERROR_CATEGORY,
|
|
45
|
+
status: 400,
|
|
46
|
+
retryable: false,
|
|
47
|
+
message: input.message,
|
|
48
|
+
why: input.why,
|
|
49
|
+
fix: input.fix,
|
|
50
|
+
cause: input.cause
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { DalpSdkError, createDalpSdkConfigurationError };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conditional GET, as a fetch decorator.
|
|
3
|
+
*
|
|
4
|
+
* The policy is unchanged from the interceptor pair this replaces: hold the
|
|
5
|
+
* ETag and body of a successful GET, send `If-None-Match` on the next one, and
|
|
6
|
+
* serve the held body on a 304. Only the attachment point moved, from a
|
|
7
|
+
* generated client's interceptor list to the fetch the transport already wraps
|
|
8
|
+
* for compression and SSR.
|
|
9
|
+
*/
|
|
10
|
+
import type { DalpFetch } from "./ssr-fetch.ts";
|
|
11
|
+
/** Handle a caller holds so it can clear the store on sign-out or org switch. */
|
|
12
|
+
export interface ConditionalRequestStore {
|
|
13
|
+
readonly clear: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Wrap `fetch` with the If-None-Match / 304 rewrite pair for conditional GET.
|
|
17
|
+
*
|
|
18
|
+
* Server ETags must be strong content digests computed after authorization
|
|
19
|
+
* inside the requester's partition. The dapi response cache guarantees this:
|
|
20
|
+
* `encodeResponseCacheEntry` sets `etag` to the SHA-256 of the serialized
|
|
21
|
+
* body after the request-context middleware has authenticated the session.
|
|
22
|
+
* Version-stamp ETags (generation counters, watermarks, table versions) are
|
|
23
|
+
* forbidden for conditional-request adopters: a stamp can collide across
|
|
24
|
+
* tenants or lag a body change and would let this store serve another
|
|
25
|
+
* partition's bytes as a 200.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withConditionalRequests(base: DalpFetch): {
|
|
28
|
+
fetch: DalpFetch;
|
|
29
|
+
store: ConditionalRequestStore;
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The client factory.
|
|
3
|
+
*
|
|
4
|
+
* The transport policy this used to assemble around the generated client now
|
|
5
|
+
* lives in `../proxy/transport.ts`, which both interpreters share. This module
|
|
6
|
+
* stays as the published entry point's seam so a consumer's import path did not
|
|
7
|
+
* move with the internals.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
export { createDalpClient, type DalpClient } from "../proxy/client.ts";
|
|
12
|
+
export { createDalpContextHeaders } from "../proxy/transport.ts";
|
|
13
|
+
export type { CreateDalpClientOptions, DalpClientContext, DalpSsrOptions, Transport } from "../proxy/transport.ts";
|
|
14
|
+
export type { DalpFetch } from "./ssr-fetch.ts";
|