@settlemint/dalp-sdk 3.1.33-release.42636987002 → 3.2.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +3 -157
  2. package/README.md +276 -169
  3. package/dist/auth/client.d.ts +114 -0
  4. package/dist/auth/invite-step-up.d.ts +2 -0
  5. package/dist/auth/live.d.ts +47 -0
  6. package/dist/auth/native-passkey.d.ts +8 -0
  7. package/dist/{auth-permissions.d.ts → auth/permissions.d.ts} +0 -8
  8. package/dist/auth/wallet-plugins.d.ts +196 -0
  9. package/dist/auth-surface.d.ts +2 -0
  10. package/dist/auth.d.ts +8 -115
  11. package/dist/auth.js +540 -0
  12. package/dist/chunk-6hckdbwt.js +600 -0
  13. package/dist/chunk-7mvx7xq8.js +4 -0
  14. package/dist/chunk-b03ycwb7.js +68 -0
  15. package/dist/chunk-crtb9edj.js +29 -0
  16. package/dist/chunk-g5j1xky8.js +99 -0
  17. package/dist/chunk-grdfnbwd.js +1529 -0
  18. package/dist/chunk-j43gfc9p.js +5 -0
  19. package/dist/chunk-k3ntysxx.js +57 -0
  20. package/dist/chunk-ptwkww6j.js +38 -0
  21. package/dist/chunk-qncpzave.js +185 -0
  22. package/dist/chunk-t8v94nvb.js +5 -0
  23. package/dist/chunk-xnarraj7.js +339 -0
  24. package/dist/client/conditional-request.d.ts +8 -0
  25. package/dist/client/factory.d.ts +4 -0
  26. package/dist/client/query-serializer.d.ts +1 -0
  27. package/dist/client/request-compression.d.ts +12 -0
  28. package/dist/client/ssr-fetch.d.ts +10 -0
  29. package/dist/client/step-up-challenge.d.ts +10 -0
  30. package/dist/effect.d.ts +39 -0
  31. package/dist/effect.js +110 -0
  32. package/dist/errors/api-error.d.ts +35 -0
  33. package/dist/errors/error-codes.d.ts +18 -0
  34. package/dist/errors/find-current-error.d.ts +2 -0
  35. package/dist/errors/public-error.d.ts +3 -0
  36. package/dist/errors/public-error.js +9 -0
  37. package/dist/errors/sdk-error.d.ts +52 -0
  38. package/dist/errors/sdk-error.js +8 -0
  39. package/dist/generated/api-types.d.ts +104535 -0
  40. package/dist/generated/api-types.ts +111921 -0
  41. package/dist/generated/console-routes.d.ts +12 -0
  42. package/dist/generated/error-catalog.d.ts +9 -0
  43. package/dist/generated/error-codes.d.ts +9 -0
  44. package/dist/generated/response-scalars.d.ts +9 -0
  45. package/dist/generated/response-schemas.d.ts +9 -0
  46. package/dist/generated/route-error-codes.d.ts +9 -0
  47. package/dist/generated/routes.d.ts +12 -0
  48. package/dist/index.d.ts +28 -45
  49. package/dist/index.js +159 -94522
  50. package/dist/proxy/builder.d.ts +17 -0
  51. package/dist/proxy/client-core.d.ts +36 -0
  52. package/dist/proxy/client.d.ts +5 -0
  53. package/dist/proxy/fetch-executor.d.ts +7 -0
  54. package/dist/proxy/flat-args.d.ts +24 -0
  55. package/dist/proxy/response-decode.d.ts +38 -0
  56. package/dist/proxy/sse.d.ts +11 -0
  57. package/dist/proxy/step-up-challenge.d.ts +4 -0
  58. package/dist/proxy/tanstack.d.ts +6 -0
  59. package/dist/proxy/transport.d.ts +76 -0
  60. package/dist/react-query.d.ts +2 -0
  61. package/dist/react-query.js +14 -0
  62. package/dist/routes/cli-command.d.ts +17 -0
  63. package/dist/routes/console.d.ts +14 -0
  64. package/dist/routes/console.js +27 -0
  65. package/dist/routes/index.d.ts +6 -0
  66. package/dist/routes/index.js +122 -0
  67. package/dist/routes/types.d.ts +73 -0
  68. package/dist/runtime-exports.d.ts +4 -0
  69. package/dist/runtime-exports.js +38 -0
  70. package/dist/runtime.d.ts +8 -0
  71. package/dist/scalars/big-decimal.d.ts +22 -0
  72. package/dist/scalars/big-int.d.ts +3 -0
  73. package/dist/scalars/dalp-scalars.d.ts +28 -0
  74. package/dist/scalars/ethereum-address.d.ts +3 -0
  75. package/dist/scalars/exchange-rates.d.ts +13 -0
  76. package/dist/scalars/index.d.ts +14 -0
  77. package/dist/scalars/index.js +236 -0
  78. package/dist/scalars/organization-id.d.ts +5 -0
  79. package/dist/scalars/token-decimals.d.ts +4 -0
  80. package/dist/secret.d.ts +12 -0
  81. package/dist/server-proxy.d.ts +39 -0
  82. package/dist/server-proxy.js +186 -0
  83. package/dist/sign-webhook-receipt.d.ts +16 -0
  84. package/dist/sign-webhook-receipt.js +26 -0
  85. package/dist/transport/cookie-store.d.ts +9 -0
  86. package/dist/transport/sse-lifecycle.d.ts +24 -0
  87. package/dist/types.d.ts +38 -114
  88. package/dist/url.d.ts +0 -1
  89. package/dist/verify-webhook.d.ts +18 -28
  90. package/dist/verify-webhook.js +8 -0
  91. package/dist/version.d.ts +0 -3
  92. package/dist/wait-for-transaction.d.ts +46 -86
  93. package/dist/wait-for-transaction.js +154 -0
  94. package/dist/webhook-events.d.ts +1360 -35
  95. package/package.json +176 -36
  96. package/dist/api-types.generated.d.ts +0 -14160
  97. package/dist/api-types.generated.d.ts.map +0 -1
  98. package/dist/auth-permissions.d.ts.map +0 -1
  99. package/dist/auth-wallet-plugins.d.ts +0 -86
  100. package/dist/auth-wallet-plugins.d.ts.map +0 -1
  101. package/dist/auth.d.ts.map +0 -1
  102. package/dist/bundler.d.ts +0 -217
  103. package/dist/bundler.d.ts.map +0 -1
  104. package/dist/client.d.ts +0 -19
  105. package/dist/client.d.ts.map +0 -1
  106. package/dist/contract-errors.d.ts +0 -4156
  107. package/dist/contract-errors.d.ts.map +0 -1
  108. package/dist/contract.d.ts +0 -22
  109. package/dist/contract.d.ts.map +0 -1
  110. package/dist/cookie-store.d.ts +0 -10
  111. package/dist/cookie-store.d.ts.map +0 -1
  112. package/dist/dapi-errors.d.ts +0 -656
  113. package/dist/dapi-errors.d.ts.map +0 -1
  114. package/dist/errors.d.ts +0 -639
  115. package/dist/errors.d.ts.map +0 -1
  116. package/dist/index.d.ts.map +0 -1
  117. package/dist/platform.d.ts +0 -41
  118. package/dist/platform.d.ts.map +0 -1
  119. package/dist/plugins/index.d.ts +0 -13
  120. package/dist/plugins/index.d.ts.map +0 -1
  121. package/dist/plugins/index.js +0 -8
  122. package/dist/sdk-error.d.ts +0 -74
  123. package/dist/sdk-error.d.ts.map +0 -1
  124. package/dist/serializers.d.ts +0 -41
  125. package/dist/serializers.d.ts.map +0 -1
  126. package/dist/types.d.ts.map +0 -1
  127. package/dist/url.d.ts.map +0 -1
  128. package/dist/verify-webhook.d.ts.map +0 -1
  129. package/dist/version.d.ts.map +0 -1
  130. package/dist/version.generated.d.ts +0 -8
  131. package/dist/version.generated.d.ts.map +0 -1
  132. package/dist/wait-for-transaction.d.ts.map +0 -1
  133. package/dist/webhook-events.d.ts.map +0 -1
@@ -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 };
@@ -0,0 +1,29 @@
1
+ import {
2
+ createDalpSdkConfigurationError2
3
+ } from "./chunk-k3ntysxx.js";
4
+
5
+ // src/url.ts
6
+ var TRAILING_SLASHES_PATTERN = /\/+$/;
7
+ function normalizeDalpBaseUrl(url) {
8
+ let parsed;
9
+ try {
10
+ parsed = new URL(url);
11
+ } catch (error) {
12
+ throw createDalpSdkConfigurationError2({
13
+ message: `DALP SDK: invalid url "${url}". Provide a full URL including the protocol (e.g., "https://dalp.example.com").`,
14
+ why: "The SDK could not parse the configured DALP API URL.",
15
+ fix: 'Provide a full http:// or https:// URL, for example "https://dalp.example.com".',
16
+ cause: error
17
+ });
18
+ }
19
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
20
+ throw createDalpSdkConfigurationError2({
21
+ message: `DALP SDK: url must use https:// or http:// protocol, got "${parsed.protocol}".`,
22
+ why: `The SDK received a URL with the unsupported "${parsed.protocol}" protocol.`,
23
+ fix: 'Use a DALP API base URL that starts with "https://" or "http://".'
24
+ });
25
+ }
26
+ return `${parsed.origin}${parsed.pathname.replace(TRAILING_SLASHES_PATTERN, "")}`;
27
+ }
28
+
29
+ export { normalizeDalpBaseUrl };
@@ -0,0 +1,99 @@
1
+ // src/verify-webhook.ts
2
+ import { Webhook as StandardWebhook } from "standardwebhooks";
3
+ var WEBHOOK_SECRET_PREFIX_PATTERN = /^dalp_whsk_/u;
4
+ var DEFAULT_TIMESTAMP_TOLERANCE_SECONDS = 5 * 60;
5
+ function toStandardWebhookSecret2(secret) {
6
+ return secret.replace(WEBHOOK_SECRET_PREFIX_PATTERN, "");
7
+ }
8
+ async function verifyWebhook2(input) {
9
+ const headers = normalizeHeaders(input.headers);
10
+ const nowMillis = input.now instanceof Date ? input.now.getTime() : input.now ?? Date.now();
11
+ const tolerance = input.timestampToleranceSeconds ?? DEFAULT_TIMESTAMP_TOLERANCE_SECONDS;
12
+ if (!hasFiniteTimestamp(headers) || isOutsideTimestampTolerance(headers, nowMillis, tolerance)) {
13
+ return { ok: false, code: "TIMESTAMP_SKEW" };
14
+ }
15
+ const rawText = typeof input.rawBody === "string" ? input.rawBody : new TextDecoder().decode(input.rawBody);
16
+ const eventId = headers["webhook-id"];
17
+ const candidates = typeof input.secret === "string" ? [input.secret] : input.secret;
18
+ if (eventId === undefined || !candidates.some((candidate) => matchesSignature(candidate, rawText, headers))) {
19
+ return { ok: false, code: classifySignatureFailure(rawText, headers) };
20
+ }
21
+ let event;
22
+ try {
23
+ event = JSON.parse(rawText);
24
+ } catch {
25
+ return { ok: false, code: "MALFORMED_BODY" };
26
+ }
27
+ const { replayStore } = input;
28
+ if (replayStore === undefined) {
29
+ return { ok: true, event, release: () => Promise.resolve() };
30
+ }
31
+ const claimId = crypto.randomUUID();
32
+ let claimed;
33
+ try {
34
+ claimed = await replayStore.claim(eventId, claimId);
35
+ } catch {
36
+ await Promise.allSettled([releaseClaim(replayStore, eventId, claimId)]);
37
+ return { ok: false, code: "REPLAY_STORE_FAILURE" };
38
+ }
39
+ if (!claimed) {
40
+ return { ok: false, code: "REPLAYED_EVENT" };
41
+ }
42
+ return { ok: true, event, release: () => releaseClaim(replayStore, eventId, claimId) };
43
+ }
44
+ async function releaseClaim(replayStore, eventId, claimId) {
45
+ await replayStore.release(eventId, claimId);
46
+ }
47
+ function matchesSignature(secret, rawBody, headers) {
48
+ const eventId = headers["webhook-id"];
49
+ const timestamp = Number(headers["webhook-timestamp"]);
50
+ const signatures = headers["webhook-signature"];
51
+ if (eventId === undefined || !Number.isFinite(timestamp) || signatures === undefined) {
52
+ return false;
53
+ }
54
+ const expected = new StandardWebhook(toStandardWebhookSecret2(secret)).sign(eventId, new Date(timestamp * 1000), rawBody);
55
+ return signatures.split(" ").some((signature) => {
56
+ const left = new TextEncoder().encode(signature);
57
+ const right = new TextEncoder().encode(expected);
58
+ if (left.byteLength !== right.byteLength) {
59
+ return false;
60
+ }
61
+ let difference = 0;
62
+ for (let index = 0;index < left.byteLength; index += 1) {
63
+ difference |= (left[index] ?? 0) ^ (right[index] ?? 0);
64
+ }
65
+ return difference === 0;
66
+ });
67
+ }
68
+ function normalizeHeaders(input) {
69
+ if (input instanceof Headers) {
70
+ return Object.fromEntries(input.entries());
71
+ }
72
+ const headers = {};
73
+ for (const [key, value] of Object.entries(input)) {
74
+ if (value !== undefined) {
75
+ headers[key.toLowerCase()] = typeof value === "string" ? value : value.join(",");
76
+ }
77
+ }
78
+ return headers;
79
+ }
80
+ function hasFiniteTimestamp(headers) {
81
+ return Number.isFinite(Number(headers["webhook-timestamp"]));
82
+ }
83
+ function isOutsideTimestampTolerance(headers, nowMillis, toleranceSeconds) {
84
+ const timestamp = Number(headers["webhook-timestamp"]);
85
+ return Number.isFinite(timestamp) && Math.abs(nowMillis / 1000 - timestamp) > toleranceSeconds;
86
+ }
87
+ function classifySignatureFailure(rawBody, headers) {
88
+ try {
89
+ const parsed = JSON.parse(rawBody);
90
+ if (typeof parsed.evt_id !== "string" || parsed.evt_id !== headers["webhook-id"]) {
91
+ return "BODY_HASH_MISMATCH";
92
+ }
93
+ } catch {
94
+ return "BODY_HASH_MISMATCH";
95
+ }
96
+ return "SECRET_MISMATCH";
97
+ }
98
+
99
+ export { toStandardWebhookSecret2, verifyWebhook2 };