@settlemint/dalp-sdk 3.1.33 → 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,186 @@
1
+ import"./chunk-k3ntysxx.js";
2
+ import {
3
+ normalizeDalpBaseUrl
4
+ } from "./chunk-crtb9edj.js";
5
+
6
+ // ../wire/http-contract/src/trusted-client-address.ts
7
+ import { isIP } from "node:net";
8
+ var validAddress = (value) => {
9
+ const trimmed = value?.trim();
10
+ return trimmed !== undefined && isIP(trimmed) !== 0 ? trimmed : undefined;
11
+ };
12
+ var appendedForwardedFor = (headers) => validAddress(headers.get("x-forwarded-for")?.split(",").at(-1));
13
+ function readTrustedClientAddress(input) {
14
+ const { headers, profile } = input;
15
+ if (profile === "envoy") {
16
+ return validAddress(headers.get("x-envoy-external-address") ?? undefined) ?? appendedForwardedFor(headers);
17
+ }
18
+ if (profile === "nginx" || profile === "openshift") {
19
+ return appendedForwardedFor(headers);
20
+ }
21
+ return;
22
+ }
23
+
24
+ // src/server-proxy.ts
25
+ var HOP_BY_HOP_HEADERS = [
26
+ "connection",
27
+ "keep-alive",
28
+ "proxy-authenticate",
29
+ "proxy-authorization",
30
+ "te",
31
+ "trailer",
32
+ "transfer-encoding",
33
+ "upgrade"
34
+ ];
35
+ var TRUSTED_FORWARDING_HEADERS = [
36
+ "forwarded",
37
+ "forwarded-for",
38
+ "x-forwarded",
39
+ "x-forwarded-for",
40
+ "x-forwarded-host",
41
+ "x-forwarded-port",
42
+ "x-forwarded-prefix",
43
+ "x-forwarded-proto",
44
+ "x-forwarded-client-cert",
45
+ "x-original-forwarded-for",
46
+ "x-real-ip",
47
+ "x-client-ip",
48
+ "x-cluster-client-ip",
49
+ "x-envoy-external-address",
50
+ "x-envoy-downstream-remote-address",
51
+ "x-envoy-original-host",
52
+ "x-envoy-original-path",
53
+ "cf-connecting-ip",
54
+ "true-client-ip",
55
+ "fastly-client-ip"
56
+ ];
57
+ var STRIPPED_REQUEST_HEADERS = [...HOP_BY_HOP_HEADERS, ...TRUSTED_FORWARDING_HEADERS, "host", "content-length"];
58
+ function createDalpProxy(options) {
59
+ const upstream = normalizeDalpBaseUrl(String(options.upstream));
60
+ const origin = options.origin === undefined ? undefined : new URL(String(options.origin)).origin;
61
+ const trustedProxyProfile = options.trustedProxyProfile ?? "none";
62
+ const acceptEncoding = options.acceptEncoding ?? "identity";
63
+ const fetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
64
+ const onUpstreamFailure = options.onUpstreamFailure ?? (() => {});
65
+ const upstreamFailureMessage = options.upstreamFailureMessage ?? ((path) => `The service behind ${path} did not answer. Retry after a short delay.`);
66
+ return async (request) => {
67
+ const requestUrl = new URL(request.url);
68
+ const targetUrl = `${upstream}${requestUrl.pathname}${requestUrl.search}`;
69
+ const hasBody = request.method !== "GET" && request.method !== "HEAD";
70
+ const init = {
71
+ method: request.method,
72
+ headers: sanitizeRequestHeaders(request.headers, trustedProxyProfile, origin, acceptEncoding),
73
+ body: hasBody ? request.body : undefined,
74
+ duplex: hasBody ? "half" : undefined,
75
+ decompress: false,
76
+ redirect: "manual",
77
+ signal: request.signal
78
+ };
79
+ let response;
80
+ try {
81
+ response = await fetch(targetUrl, init);
82
+ } catch (error) {
83
+ if (hasBody || request.signal.aborted || !isConnectionReset(error)) {
84
+ return upstreamFailure(request, upstream, onUpstreamFailure, upstreamFailureMessage, error);
85
+ }
86
+ try {
87
+ response = await fetch(targetUrl, init);
88
+ } catch (retryError) {
89
+ return upstreamFailure(request, upstream, onUpstreamFailure, upstreamFailureMessage, retryError);
90
+ }
91
+ }
92
+ const isRedirect = response.status >= 300 && response.status < 400;
93
+ const isNullBody = response.status === 204 || response.status === 205 || isRedirect;
94
+ const contentType = response.headers.get("content-type") ?? "";
95
+ const isStream = contentType.includes("text/event-stream") || contentType.includes("application/x-ndjson");
96
+ let body = null;
97
+ if (!isNullBody) {
98
+ if (isStream) {
99
+ body = response.body ?? "";
100
+ } else {
101
+ try {
102
+ body = await response.arrayBuffer();
103
+ } catch (error) {
104
+ return upstreamFailure(request, upstream, onUpstreamFailure, upstreamFailureMessage, error);
105
+ }
106
+ }
107
+ }
108
+ const headers = sanitizeResponseHeaders(response.headers);
109
+ if (isNullBody) {
110
+ headers.delete("content-length");
111
+ headers.delete("content-encoding");
112
+ headers.delete("content-type");
113
+ headers.delete("transfer-encoding");
114
+ }
115
+ return new Response(body, { status: response.status, statusText: response.statusText, headers });
116
+ };
117
+ }
118
+ function sanitizeRequestHeaders(original, profile, origin, acceptEncoding) {
119
+ const headers = Object.fromEntries(original.entries());
120
+ if (headers.origin === undefined && origin !== undefined) {
121
+ headers.origin = origin;
122
+ }
123
+ if (acceptEncoding === "identity") {
124
+ headers["accept-encoding"] = "identity";
125
+ }
126
+ const trustedSignal = readTrustedClientSignal(original, profile);
127
+ for (const name of STRIPPED_REQUEST_HEADERS) {
128
+ Reflect.deleteProperty(headers, name);
129
+ }
130
+ if (trustedSignal !== undefined) {
131
+ headers[trustedSignal.name] = trustedSignal.value;
132
+ }
133
+ return headers;
134
+ }
135
+ function sanitizeResponseHeaders(original) {
136
+ const headers = new Headers(original);
137
+ for (const name of HOP_BY_HOP_HEADERS) {
138
+ headers.delete(name);
139
+ }
140
+ return headers;
141
+ }
142
+ function readTrustedClientSignal(headers, profile) {
143
+ const value = readTrustedClientAddress({ headers, profile });
144
+ return value === undefined ? undefined : { name: profile === "envoy" ? "x-envoy-external-address" : "x-forwarded-for", value };
145
+ }
146
+ function upstreamFailure(request, upstream, onUpstreamFailure, upstreamFailureMessage, error) {
147
+ if (request.signal.aborted) {
148
+ return new Response(null, { status: 499, headers: { "cache-control": "no-store" } });
149
+ }
150
+ const cause = error instanceof Error ? error : undefined;
151
+ const code = readErrorCode(error);
152
+ const route = new URL(request.url).pathname;
153
+ onUpstreamFailure({
154
+ method: request.method,
155
+ path: route,
156
+ upstream: new URL(upstream).origin,
157
+ errorName: cause?.name ?? typeof error,
158
+ errorMessage: cause?.message ?? String(error),
159
+ errorCode: code
160
+ });
161
+ return Response.json({
162
+ status: 502,
163
+ code: "UPSTREAM_UNAVAILABLE",
164
+ message: upstreamFailureMessage(route)
165
+ }, { status: 502, headers: { "cache-control": "no-store" } });
166
+ }
167
+ function isConnectionReset(error) {
168
+ if (!(error instanceof Error)) {
169
+ return false;
170
+ }
171
+ if (readErrorCode(error) === "ECONNRESET") {
172
+ return true;
173
+ }
174
+ const message = error.message.toLowerCase();
175
+ return message.includes("socket connection was closed") || message.includes("connection was closed");
176
+ }
177
+ function readErrorCode(error) {
178
+ if (!(error instanceof Error)) {
179
+ return;
180
+ }
181
+ const code = Reflect.get(error, "code");
182
+ return typeof code === "string" || typeof code === "number" ? String(code) : undefined;
183
+ }
184
+ export {
185
+ createDalpProxy
186
+ };
@@ -0,0 +1,16 @@
1
+ export declare const RECEIPT_SIGNING_SCHEME = "dalp.whr.v1";
2
+ export interface ReceiptSigningTuple {
3
+ deliveryId: string;
4
+ endpointId: string;
5
+ evtId: string;
6
+ innerEventHash: string;
7
+ }
8
+ export interface SignWebhookReceiptInput extends ReceiptSigningTuple {
9
+ secret: string;
10
+ }
11
+ export declare function buildReceiptSigningString(tuple: Readonly<ReceiptSigningTuple>): string;
12
+ export declare function signWebhookReceipt({ secret, ...tuple }: Readonly<SignWebhookReceiptInput>): string;
13
+ export interface VerifyWebhookReceiptInput extends SignWebhookReceiptInput {
14
+ readonly signature: string;
15
+ }
16
+ export declare function verifyWebhookReceipt({ signature, ...input }: Readonly<VerifyWebhookReceiptInput>): boolean;
@@ -0,0 +1,26 @@
1
+ import {
2
+ toStandardWebhookSecret2
3
+ } from "./chunk-g5j1xky8.js";
4
+
5
+ // src/sign-webhook-receipt.ts
6
+ import { createHmac, timingSafeEqual } from "node:crypto";
7
+ var RECEIPT_SIGNING_SCHEME = "dalp.whr.v1";
8
+ function buildReceiptSigningString(tuple) {
9
+ return [RECEIPT_SIGNING_SCHEME, tuple.deliveryId, tuple.endpointId, tuple.evtId, tuple.innerEventHash].join(`
10
+ `);
11
+ }
12
+ function signWebhookReceipt({ secret, ...tuple }) {
13
+ const key = Buffer.from(toStandardWebhookSecret2(secret), "base64");
14
+ return createHmac("sha256", key).update(buildReceiptSigningString(tuple), "utf8").digest("hex");
15
+ }
16
+ function verifyWebhookReceipt({ signature, ...input }) {
17
+ const expected = Buffer.from(signWebhookReceipt(input), "hex");
18
+ const received = Buffer.from(signature, "hex");
19
+ return expected.length === received.length && timingSafeEqual(expected, received);
20
+ }
21
+ export {
22
+ RECEIPT_SIGNING_SCHEME,
23
+ buildReceiptSigningString,
24
+ signWebhookReceipt,
25
+ verifyWebhookReceipt
26
+ };
@@ -0,0 +1,9 @@
1
+ export type CookieStoreFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
2
+ export interface CookieStoreShape {
3
+ readonly header: () => string;
4
+ readonly isEmpty: () => boolean;
5
+ readonly setCookieHeader: (header: string) => void;
6
+ readonly storeSetCookieHeaders: (headers: ReadonlyArray<string>) => void;
7
+ }
8
+ export declare function makeCookieStore(initialHeader?: string): CookieStoreShape;
9
+ export declare function createCookieStoreFetch(cookieStore: CookieStoreShape, fetchImpl?: CookieStoreFetch): CookieStoreFetch;
@@ -0,0 +1,24 @@
1
+ export type SseEventDisposition = "continue" | "success" | "failure";
2
+ export interface SseStreamResult<T> {
3
+ readonly stream: AsyncIterable<T>;
4
+ }
5
+ export interface SseLifecycleOptions<T> {
6
+ readonly connect: (signal: AbortSignal) => Promise<SseStreamResult<T>>;
7
+ readonly classify: (event: T) => SseEventDisposition;
8
+ readonly signal?: AbortSignal;
9
+ readonly onEvent?: (event: T) => void;
10
+ readonly maxReconnects?: number;
11
+ readonly reconnectWindowMs?: number;
12
+ readonly healthyConnectionMs?: number;
13
+ readonly initialBackoffMs?: number;
14
+ readonly maxBackoffMs?: number;
15
+ readonly sleep?: (milliseconds: number) => Promise<void>;
16
+ readonly now?: () => number;
17
+ }
18
+ export type SseLifecycleFailureReason = "aborted" | "terminal-failure" | "transport-failure";
19
+ export declare class SseLifecycleError<T = unknown> extends Error {
20
+ readonly reason: SseLifecycleFailureReason;
21
+ readonly lastEvent?: T;
22
+ constructor(reason: SseLifecycleFailureReason, lastEvent?: T, options?: ErrorOptions);
23
+ }
24
+ export declare function consumeSseUntilTerminal<T>(options: SseLifecycleOptions<T>): Promise<T>;
package/dist/types.d.ts CHANGED
@@ -1,115 +1,39 @@
1
- /**
2
- * Type-only exports for the DALP SDK.
3
- *
4
- * Import from `@settlemint/dalp-sdk/types` when you only need types
5
- * (e.g., for function signatures) without pulling in runtime code.
6
- *
7
- * Related: kit/sdk/src/client.ts
8
- *
9
- * @module
10
- */
11
- import type { DalpApi } from "./api-types.generated.js";
12
- /**
13
- * Fully typed DALP API client.
14
- *
15
- * The shapes come from `./api-types.generated.ts` rather than from the contract
16
- * router's inferred type. A declaration that names the contract cannot be
17
- * published: `@dalp/api-contract` is private, and the inferred type does not
18
- * survive declaration emit at all (`TS7056` on the larger route files). See
19
- * `./contract.ts`.
20
- *
21
- * Response values carry the wire representation, so a `bigint` field reads as a
22
- * decimal string and a timestamp as an ISO string. The client serializes on the
23
- * way out but does not decode on the way back, so a request may pass either the
24
- * native value or its string form.
25
- *
26
- * Provides auto-completed access to all v2 API namespaces:
27
- * `account`, `actions`, `addons`, `admin`, `contacts`, `exchangeRates`,
28
- * `externalToken`, `identityRecovery`, `monitoring`, `search`,
29
- * `settings`, `system`, `token`, `transaction`, `user`.
30
- */
31
- export type DalpClient = DalpApi;
32
- /**
33
- * Per-call client context threaded into individual SDK operations as the second
34
- * argument, e.g. `client.token.create(input, { context: { idempotencyKey } })`.
35
- * Every field is optional and scoped to the single call, unlike the client-level
36
- * {@link BaseDalpClientConfig.idempotencyKey} which applies to every request.
37
- */
38
- export interface DalpClientCallContext {
39
- /**
40
- * Idempotency key sent as the `Idempotency-Key` header for this call only,
41
- * overriding any client-level key. Use a fresh value per genuine retry of a
42
- * failed mutation: dapi burns the key of a failed transaction, so re-sending
43
- * under the same key is rejected ("previously failed. Use a new idempotency
44
- * key to retry"). A stable value within one logical attempt keeps network-level
45
- * fetch retries deduplicated.
46
- */
47
- idempotencyKey?: string;
48
- /**
49
- * oRPC error codes the caller treats as expected for this call and does not
50
- * want surfaced by its own error logging (e.g. an existence probe that accepts
51
- * `NOT_FOUND`). A client-side hint scoped to the single call; it is not sent to
52
- * the server.
53
- */
54
- skipLoggingFor?: readonly string[];
1
+ import type { AssumableParticipant, JoinableParticipant, JoinableProvider, EvmAddress, TokenTopicScheme, TokenTrustedIssuer, EvmUserEventV2Item, UserEventV2Item, UserMe, party_multisigDrafts_issueInvite_Response, party_topicSchemes_addForToken_Request, party_trustedIssuers_addForToken_Request, party_users_activityStats_Response, party_users_events_Response, platform_settings_settingsThemeUploadLogo_Request, token_create_Request, token_documents_getUploadUrl_Request, token_features_list_Response, system_feeds_issuerSigned_create_Request } from "./generated/api-types.ts";
2
+ export type ParticipantKind = "person" | "company" | "fund" | "spv" | "department" | "joint_account" | "asset" | "organisation" | "claim_issuer" | "addon" | "agent";
3
+ export type ParticipantAddressPurpose = "transfer" | "identity" | "participant";
4
+ export interface EligibleForTokenFilter {
5
+ readonly tokenAddress: EvmAddress;
6
+ readonly action: "mint" | "transfer" | "burn";
7
+ readonly reveal?: boolean;
55
8
  }
56
- interface BaseDalpClientConfig {
57
- /** Base URL of the DALP API (e.g., `"https://dalp.example.com"`). */
58
- url: string;
59
- /**
60
- * Organization ID for multi-tenant setups.
61
- * Required when the API key is scoped to multiple organizations.
62
- */
63
- organizationId?: string;
64
- /**
65
- * Additional headers merged into every request.
66
- * Accepts a static object or a (possibly async) function for dynamic headers.
67
- * Can override defaults like `User-Agent` but cannot override security headers (`x-api-key`, `x-organization-id`).
68
- */
69
- headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
70
- /**
71
- * Validate outgoing requests against the contract before sending.
72
- * Catches schema violations client-side for faster feedback.
73
- * @defaultValue false
74
- */
75
- requestValidation?: boolean;
76
- /**
77
- * Validate incoming responses against the contract.
78
- * Useful during development to catch API drift.
79
- * @defaultValue false
80
- */
81
- responseValidation?: boolean;
82
- /**
83
- * Custom `fetch` implementation.
84
- * Use this to inject logging, proxy configuration, or test doubles.
85
- */
86
- fetch?: typeof globalThis.fetch;
87
- /**
88
- * Idempotency key sent as the `Idempotency-Key` header on every request.
89
- *
90
- * **Warning:** This value is sent on _every_ request made by the client.
91
- * If you reuse the same client instance for multiple mutations, the server
92
- * will deduplicate all but the first — subsequent mutations silently return
93
- * the first response. Only set this when the client is used for a single
94
- * mutation (e.g., a one-shot script). For multi-mutation workflows, set the
95
- * header per-request via the `headers` callback instead.
96
- *
97
- * When omitted, no idempotency key header is sent.
98
- */
99
- idempotencyKey?: string;
100
- }
101
- /**
102
- * Configuration for creating an authenticated DALP API client.
103
- */
104
- export interface DalpClientConfig extends BaseDalpClientConfig {
105
- /** API key for authenticated routes (issued via the DALP dashboard or CLI). */
106
- apiKey: string;
107
- }
108
- /**
109
- * Configuration for creating a public DALP API client.
110
- */
111
- export interface PublicDalpClientConfig extends BaseDalpClientConfig {
112
- apiKey?: undefined;
113
- }
114
- export type { WalletAuthEndpointPath } from "./auth-wallet-plugins.js";
115
- //# sourceMappingURL=types.d.ts.map
9
+ export type JoinableParticipantOption = JoinableParticipant;
10
+ export type JoinableProviderOption = JoinableProvider;
11
+ export type ActAvailability = AssumableParticipant["actAvailability"];
12
+ export type OnboardingState = UserMe["onboardingState"];
13
+ export type UserEvent = UserEventV2Item;
14
+ export type EvmUserEvent = EvmUserEventV2Item;
15
+ export type UserEventCollectionResponse = party_users_events_Response;
16
+ export type UserActivityChartResponse = party_users_activityStats_Response;
17
+ export type UserEventValue = NonNullable<EvmUserEvent["values"]>[number];
18
+ export type TokenTopicSchemeInheritanceLevel = TokenTopicScheme["inheritanceLevel"];
19
+ export type TokenTrustedIssuerInheritanceLevel = TokenTrustedIssuer["inheritanceLevel"];
20
+ export type TokenTopicSchemeCreateInput = party_topicSchemes_addForToken_Request;
21
+ export type TokenTrustedIssuerCreateInput = party_trustedIssuers_addForToken_Request;
22
+ export type MultisigDraftCreateInviteOutput = party_multisigDrafts_issueInvite_Response;
23
+ export type IssuerSignedCreateInput = system_feeds_issuerSigned_create_Request;
24
+ export type ThemeLogoMode = platform_settings_settingsThemeUploadLogo_Request["mode"];
25
+ type AttachedTokenFeature = token_features_list_Response["data"][number];
26
+ type AttachedTokenFeatureConfig<Name extends AttachedTokenFeature["name"]> = NonNullable<Extract<AttachedTokenFeature, {
27
+ readonly name: Name;
28
+ }>["config"]>;
29
+ export type TokenFeatureHistoricalBalancesConfig = AttachedTokenFeatureConfig<"historical-balances">;
30
+ export type TokenFeatureMaturityRedemptionConfig = AttachedTokenFeatureConfig<"maturity-redemption">;
31
+ export type TokenFeatureFixedTreasuryYieldConfig = AttachedTokenFeatureConfig<"fixed-treasury-yield">;
32
+ export type TokenFeatureDividendYieldConfig = AttachedTokenFeatureConfig<"dividend-yield">;
33
+ export type TokenFeatureInterestYieldConfig = AttachedTokenFeatureConfig<"interest-yield">;
34
+ export type TokenFeatureTransactionFeeConfig = AttachedTokenFeatureConfig<"transaction-fee">;
35
+ export type TokenFeatureTransactionFeeAccountingConfig = AttachedTokenFeatureConfig<"transaction-fee-accounting">;
36
+ export type TokenFeatureExternalTransactionFeeConfig = AttachedTokenFeatureConfig<"external-transaction-fee">;
37
+ export type TokenDocumentMimeType = token_documents_getUploadUrl_Request["mimeType"];
38
+ export type TokenCreateInput = token_create_Request;
39
+ export type * from "./generated/api-types.ts";
package/dist/url.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export declare function normalizeDalpBaseUrl(url: string): string;
2
- //# sourceMappingURL=url.d.ts.map
@@ -1,34 +1,24 @@
1
- import type { Webhook } from "./webhook-events.js";
2
- export type WebhookVerificationFailure = "TIMESTAMP_SKEW" | "SECRET_MISMATCH" | "BODY_HASH_MISMATCH";
1
+ import type { Webhook } from "./webhook-events.ts";
2
+ export type WebhookVerificationFailure = "TIMESTAMP_SKEW" | "SECRET_MISMATCH" | "BODY_HASH_MISMATCH" | "REPLAYED_EVENT" | "MALFORMED_BODY" | "REPLAY_STORE_FAILURE";
3
3
  export type WebhookVerificationResult = {
4
- ok: true;
5
- event: Webhook.Event;
4
+ readonly ok: true;
5
+ readonly event: Webhook.Event;
6
+ readonly release: () => Promise<void>;
6
7
  } | {
7
- ok: false;
8
- code: WebhookVerificationFailure;
8
+ readonly ok: false;
9
+ readonly code: WebhookVerificationFailure;
9
10
  };
11
+ export interface WebhookReplayStore {
12
+ readonly claim: (eventId: string, claimId: string) => boolean | Promise<boolean>;
13
+ readonly release: (eventId: string, claimId: string) => void | Promise<void>;
14
+ }
10
15
  export interface VerifyWebhookInput {
11
- rawBody: string | Uint8Array;
12
- headers: Headers | Record<string, string | string[] | undefined>;
13
- secret: string | readonly string[];
16
+ readonly rawBody: string | Uint8Array;
17
+ readonly headers: Headers | Record<string, string | ReadonlyArray<string> | undefined>;
18
+ readonly secret: string | ReadonlyArray<string>;
19
+ readonly replayStore?: WebhookReplayStore;
20
+ readonly now?: number | Date;
21
+ readonly timestampToleranceSeconds?: number;
14
22
  }
15
- /**
16
- * Strip the `dalp_whsk_` family prefix from a DALP signing secret.
17
- *
18
- * The Standard Webhooks library expects the bare secret material; DALP
19
- * adds the prefix for parity with the `sm_dalp_` API-key family. Both
20
- * the dispatcher (DALP-side) and any verifier (DALP or consumer) must
21
- * call this before constructing a `new Webhook(...)` instance, otherwise
22
- * the HMAC inputs differ on the two ends and every signature mismatches.
23
- */
24
23
  export declare function toStandardWebhookSecret(secret: string): string;
25
- /**
26
- * Verifies a DALP webhook signature and returns the typed event union.
27
- *
28
- * Use the returned lifecycle state and `supersedes` accessor to reconcile
29
- * cached DAPI mutation responses with later on-chain outcomes.
30
- *
31
- * @see ../../kit/docs/content/events/idempotency-and-on-chain-outcome.mdx
32
- */
33
- export declare function verifyWebhook({ rawBody, headers, secret }: VerifyWebhookInput): WebhookVerificationResult;
34
- //# sourceMappingURL=verify-webhook.d.ts.map
24
+ export declare function verifyWebhook(input: VerifyWebhookInput): Promise<WebhookVerificationResult>;
@@ -0,0 +1,8 @@
1
+ import {
2
+ toStandardWebhookSecret2,
3
+ verifyWebhook2
4
+ } from "./chunk-g5j1xky8.js";
5
+ export {
6
+ toStandardWebhookSecret2 as toStandardWebhookSecret,
7
+ verifyWebhook2 as verifyWebhook
8
+ };
package/dist/version.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- /** Semver version of the published SDK package. */
2
1
  export declare const SDK_VERSION: string;
3
- /** Default User-Agent header sent with every SDK request. */
4
2
  export declare const SDK_USER_AGENT: string;
5
- //# sourceMappingURL=version.d.ts.map
@@ -1,94 +1,54 @@
1
- /**
2
- * Bounded wait-until-terminal barrier for queued DALP mutations.
3
- *
4
- * A v2 mutation may return a `202`-style async-accepted envelope when its
5
- * synchronous wait window elapses while the execution workflow is still
6
- * confirming. `waitForTransaction` turns that into a deterministic outcome:
7
- * poll the transaction status route at a FIXED interval bounded by a wall-clock
8
- * deadline, resolve on a terminal success, throw a typed error on a terminal
9
- * failure, and throw a loud timeout error if the deadline elapses first.
10
- *
11
- * This is a determinism barrier, not a masking retry — total wait is bounded by
12
- * `timeoutMs` (never exponential), and a never-terminating transaction fails
13
- * loud and bounded instead of hanging.
14
- *
15
- * Related: kit/sdk/src/types.ts
16
- * Related: packages/dalp/api-contract/src/routes/transaction/routes/transaction.status.schema.ts
17
- *
18
- * @module
19
- */
20
- import type { DalpClient } from "./types.js";
21
- /** Outcome shape returned by the transaction status route, narrowed to the fields this helper reads. */
22
- export interface WaitForTransactionResult {
23
- readonly tokenAddress?: unknown;
1
+ import type { DalpClient } from "./proxy/client.ts";
2
+ import type { EvmTransactionStatusOutput } from "./generated/api-types.ts";
3
+ export interface WaitForTransactionContractError {
4
+ readonly id: string;
5
+ readonly args: Readonly<Record<string, string>>;
6
+ readonly why: string;
7
+ readonly message: string;
8
+ readonly fix?: string;
24
9
  }
25
10
  export interface WaitForTransactionStatus {
26
- transactionId: string;
27
- status: string;
28
- subStatus: string | null;
29
- transactionHash: string | null;
30
- errorMessage: string | null;
31
- result?: WaitForTransactionResult;
11
+ readonly transactionId: string;
12
+ readonly status: string;
13
+ readonly subStatus: string | null;
14
+ readonly transactionHash: string | null;
15
+ readonly blockNumber?: string | null;
16
+ readonly errorMessage: string | null;
17
+ readonly contractError?: WaitForTransactionContractError | null;
18
+ readonly result?: WaitForTransactionResult;
19
+ readonly activeRequirement?: EvmTransactionStatusOutput["activeRequirement"];
20
+ readonly activeRequirementUnavailable?: EvmTransactionStatusOutput["activeRequirementUnavailable"];
21
+ readonly indexerRebuild?: EvmTransactionStatusOutput["indexerRebuild"];
22
+ readonly indexerRebuildUnavailable?: EvmTransactionStatusOutput["indexerRebuildUnavailable"];
23
+ readonly mayStillLand?: EvmTransactionStatusOutput["mayStillLand"];
24
+ }
25
+ export type WaitForTransactionResult = NonNullable<EvmTransactionStatusOutput["result"]>;
26
+ export interface WaitForTransactionSuccess extends WaitForTransactionStatus {
27
+ readonly status: "COMPLETED";
32
28
  }
33
29
  export interface WaitForTransactionOptions {
34
- /** Wall-clock ceiling for the whole wait, in milliseconds. Default 120_000. */
35
- timeoutMs?: number;
36
- /** Fixed delay between status polls, in milliseconds. Default 2_000. */
37
- intervalMs?: number;
38
- /**
39
- * Resolve (instead of continuing to poll) when the transaction reaches
40
- * `PENDING_APPROVAL` — an external approval gate (DFNS / Fireblocks) that is
41
- * not a stall and may legitimately outlast the deadline. Default `true`.
42
- */
43
- resolveOnPendingApproval?: boolean;
44
- /**
45
- * Cancels the wait when the owning context (React component, request handler,
46
- * workflow step) is torn down. An aborted signal stops the loop on the next
47
- * iteration, cancels the in-flight status request, and surfaces as a
48
- * {@link DalpTransactionWaitError} with `reason: "aborted"`.
49
- */
50
- signal?: AbortSignal;
30
+ readonly timeoutMs?: number;
31
+ readonly pollIntervalMs?: number;
32
+ readonly signal?: AbortSignal;
33
+ readonly onStatus?: (status: WaitForTransactionStatus) => void;
34
+ readonly holdWhilePaused?: boolean;
35
+ readonly holdWhileRebuilding?: boolean;
36
+ readonly now?: () => number;
37
+ readonly sleep?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
38
+ readonly readStatus?: (transactionId: string, signal?: AbortSignal) => Promise<WaitForTransactionStatus>;
51
39
  }
52
- /**
53
- * Thrown when a transaction reaches a terminal failure state
54
- * (`FAILED` / `DEAD_LETTER` / `CANCELLED`), does not reach any terminal state
55
- * within the deadline (`reason: "timeout"`), or the caller's `AbortSignal`
56
- * fires (`reason: "aborted"`).
57
- */
40
+ export type TransactionWaitFailureReason = "terminal-failure" | "timeout" | "aborted" | "funding-paused" | "indexer-rebuild";
58
41
  export declare class DalpTransactionWaitError extends Error {
42
+ readonly code = "sdk.transaction.WAIT_FAILED";
43
+ readonly category: "operational";
59
44
  readonly transactionId: string;
60
- readonly status: string;
61
- readonly subStatus: string | null;
62
- readonly reason: "terminal-failure" | "timeout" | "aborted";
63
- readonly lastStatus: WaitForTransactionStatus | undefined;
64
- constructor(options: {
65
- message: string;
66
- transactionId: string;
67
- status: string;
68
- subStatus: string | null;
69
- reason: "terminal-failure" | "timeout" | "aborted";
70
- lastStatus?: WaitForTransactionStatus;
71
- cause?: unknown;
72
- });
45
+ readonly reason: TransactionWaitFailureReason;
46
+ readonly lastStatus?: WaitForTransactionStatus;
47
+ readonly elapsedMs?: number;
48
+ constructor(transactionId: string, reason: TransactionWaitFailureReason, lastStatus?: WaitForTransactionStatus, elapsedMs?: number);
49
+ get status(): string;
50
+ get subStatus(): string | null;
51
+ get retryable(): boolean;
73
52
  }
74
- /**
75
- * Poll the transaction status route until the transaction reaches a terminal
76
- * state or the deadline elapses.
77
- *
78
- * - `COMPLETED` → resolves with the final status (the handler already waited for
79
- * the indexer drain, so this is a true read-after-write guarantee).
80
- * - `FAILED` / `DEAD_LETTER` / `CANCELLED` → throws {@link DalpTransactionWaitError}
81
- * (`reason: "terminal-failure"`) carrying `status`, `subStatus`, and
82
- * `errorMessage` — fail fast, do not keep polling.
83
- * - `PENDING_APPROVAL` → resolves as pending (when `resolveOnPendingApproval`,
84
- * the default) so an external approval gate is never treated as a stall.
85
- * - deadline elapsed → throws {@link DalpTransactionWaitError} (`reason: "timeout"`)
86
- * carrying the last observed status — a loud, bounded failure, never an
87
- * indefinite hang.
88
- *
89
- * @param client A DALP API client.
90
- * @param transactionId The queue transaction identifier (UUIDv7) returned in the
91
- * async-accepted envelope.
92
- */
93
- export declare function waitForTransaction(client: DalpClient, transactionId: string, options?: WaitForTransactionOptions): Promise<WaitForTransactionStatus>;
94
- //# sourceMappingURL=wait-for-transaction.d.ts.map
53
+ export declare const isDalpTransactionWaitError: (error: unknown) => error is DalpTransactionWaitError;
54
+ export declare function waitForTransaction(client: DalpClient, transactionId: string, options?: WaitForTransactionOptions): Promise<WaitForTransactionSuccess>;