@settlemint/dalp-sdk 3.1.26-main.37116470199 → 3.1.26

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 (123) hide show
  1. package/README.md +172 -239
  2. package/dist/api-types.generated.d.ts +14160 -0
  3. package/dist/api-types.generated.d.ts.map +1 -0
  4. package/dist/{auth/permissions.d.ts → auth-permissions.d.ts} +8 -0
  5. package/dist/auth-permissions.d.ts.map +1 -0
  6. package/dist/{auth/wallet-plugins.d.ts → auth-wallet-plugins.d.ts} +6 -68
  7. package/dist/auth-wallet-plugins.d.ts.map +1 -0
  8. package/dist/auth.d.ts +115 -8
  9. package/dist/auth.d.ts.map +1 -0
  10. package/dist/bundler.d.ts +217 -0
  11. package/dist/bundler.d.ts.map +1 -0
  12. package/dist/chunk-xm8h1dzh.js +33 -0
  13. package/dist/client.d.ts +19 -0
  14. package/dist/client.d.ts.map +1 -0
  15. package/dist/contract-errors.d.ts +4156 -0
  16. package/dist/contract-errors.d.ts.map +1 -0
  17. package/dist/contract.d.ts +22 -0
  18. package/dist/contract.d.ts.map +1 -0
  19. package/dist/cookie-store.d.ts +10 -0
  20. package/dist/cookie-store.d.ts.map +1 -0
  21. package/dist/dapi-errors.d.ts +654 -0
  22. package/dist/dapi-errors.d.ts.map +1 -0
  23. package/dist/errors.d.ts +637 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/index.d.ts +45 -28
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +96216 -150
  28. package/dist/platform.d.ts +41 -0
  29. package/dist/platform.d.ts.map +1 -0
  30. package/dist/plugins/index.d.ts +13 -0
  31. package/dist/plugins/index.d.ts.map +1 -0
  32. package/dist/plugins/index.js +10 -0
  33. package/dist/sdk-error.d.ts +74 -0
  34. package/dist/sdk-error.d.ts.map +1 -0
  35. package/dist/serializers.d.ts +41 -0
  36. package/dist/serializers.d.ts.map +1 -0
  37. package/dist/types.d.ts +114 -37
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/url.d.ts +1 -0
  40. package/dist/url.d.ts.map +1 -0
  41. package/dist/verify-webhook.d.ts +28 -17
  42. package/dist/verify-webhook.d.ts.map +1 -0
  43. package/dist/version.d.ts +3 -0
  44. package/dist/version.d.ts.map +1 -0
  45. package/dist/version.generated.d.ts +8 -0
  46. package/dist/version.generated.d.ts.map +1 -0
  47. package/dist/wait-for-transaction.d.ts +86 -44
  48. package/dist/wait-for-transaction.d.ts.map +1 -0
  49. package/dist/webhook-events.d.ts +33 -543
  50. package/dist/webhook-events.d.ts.map +1 -0
  51. package/package.json +34 -110
  52. package/dist/auth/client.d.ts +0 -103
  53. package/dist/auth/invite-step-up.d.ts +0 -2
  54. package/dist/auth/live.d.ts +0 -47
  55. package/dist/auth/native-passkey.d.ts +0 -9
  56. package/dist/auth-surface.d.ts +0 -2
  57. package/dist/auth.js +0 -525
  58. package/dist/chunk-4f4kjtt0.js +0 -149
  59. package/dist/chunk-b03ycwb7.js +0 -68
  60. package/dist/chunk-ghgcmyhk.js +0 -5
  61. package/dist/chunk-h241xecg.js +0 -1625
  62. package/dist/chunk-hqz56e6q.js +0 -4
  63. package/dist/chunk-k3ntysxx.js +0 -57
  64. package/dist/chunk-pjjrxre1.js +0 -36
  65. package/dist/chunk-qvtjb3dz.js +0 -102
  66. package/dist/chunk-v54k7mgr.js +0 -271
  67. package/dist/chunk-w361dpdk.js +0 -5
  68. package/dist/client/conditional-request.d.ts +0 -8
  69. package/dist/client/factory.d.ts +0 -4
  70. package/dist/client/query-serializer.d.ts +0 -1
  71. package/dist/client/request-compression.d.ts +0 -12
  72. package/dist/client/ssr-fetch.d.ts +0 -10
  73. package/dist/client/step-up-challenge.d.ts +0 -10
  74. package/dist/effect.d.ts +0 -38
  75. package/dist/effect.js +0 -87
  76. package/dist/errors/api-error.d.ts +0 -35
  77. package/dist/errors/error-codes.d.ts +0 -21
  78. package/dist/errors/find-current-error.d.ts +0 -2
  79. package/dist/errors/sdk-error.d.ts +0 -52
  80. package/dist/errors/sdk-error.js +0 -8
  81. package/dist/generated/api-types.d.ts +0 -69961
  82. package/dist/generated/console-routes.d.ts +0 -12
  83. package/dist/generated/error-catalog.d.ts +0 -9
  84. package/dist/generated/error-codes.d.ts +0 -9
  85. package/dist/generated/response-scalars.d.ts +0 -9
  86. package/dist/generated/response-schemas.d.ts +0 -9
  87. package/dist/generated/route-error-codes.d.ts +0 -9
  88. package/dist/generated/routes.d.ts +0 -12
  89. package/dist/proxy/builder.d.ts +0 -17
  90. package/dist/proxy/client-core.d.ts +0 -28
  91. package/dist/proxy/client.d.ts +0 -5
  92. package/dist/proxy/fetch-executor.d.ts +0 -6
  93. package/dist/proxy/flat-args.d.ts +0 -24
  94. package/dist/proxy/response-decode.d.ts +0 -37
  95. package/dist/proxy/sse.d.ts +0 -11
  96. package/dist/proxy/step-up-challenge.d.ts +0 -4
  97. package/dist/proxy/tanstack.d.ts +0 -6
  98. package/dist/proxy/transport.d.ts +0 -63
  99. package/dist/react-query.d.ts +0 -2
  100. package/dist/react-query.js +0 -12
  101. package/dist/readonly-deep.d.ts +0 -3
  102. package/dist/routes/console.d.ts +0 -14
  103. package/dist/routes/console.js +0 -25
  104. package/dist/routes/index.d.ts +0 -4
  105. package/dist/routes/index.js +0 -10
  106. package/dist/routes/types.d.ts +0 -72
  107. package/dist/runtime-exports.d.ts +0 -4
  108. package/dist/runtime-exports.js +0 -16
  109. package/dist/runtime.d.ts +0 -11
  110. package/dist/scalars/big-decimal.d.ts +0 -4
  111. package/dist/scalars/ethereum-address.d.ts +0 -5
  112. package/dist/scalars/exchange-rates.d.ts +0 -13
  113. package/dist/scalars/index.d.ts +0 -10
  114. package/dist/scalars/index.js +0 -102
  115. package/dist/scalars/organization-id.d.ts +0 -5
  116. package/dist/scalars/token-decimals.d.ts +0 -4
  117. package/dist/secret.d.ts +0 -12
  118. package/dist/sign-webhook-receipt.d.ts +0 -16
  119. package/dist/sign-webhook-receipt.js +0 -26
  120. package/dist/transport/cookie-store.d.ts +0 -9
  121. package/dist/transport/sse-lifecycle.d.ts +0 -24
  122. package/dist/verify-webhook.js +0 -8
  123. package/dist/wait-for-transaction.js +0 -151
@@ -1,4 +0,0 @@
1
- import { data as routeTable } from "../generated/routes.ts";
2
- export declare const routeIds: ReadonlyArray<keyof typeof routeTable.routes>;
3
- export { routeTable };
4
- export type { ResponseScalarTable, RouteRow, RouteTable } from "./types.ts";
@@ -1,10 +0,0 @@
1
- import {
2
- data2
3
- } from "../chunk-hqz56e6q.js";
4
-
5
- // src/routes/index.ts
6
- var routeIds = Object.keys(data2.routes).sort();
7
- export {
8
- routeIds,
9
- data2 as routeTable
10
- };
@@ -1,72 +0,0 @@
1
- export interface RouteRow {
2
- readonly method: string;
3
- readonly path: string;
4
- readonly params: ReadonlyArray<string>;
5
- readonly successStatuses: ReadonlyArray<number>;
6
- readonly errorStatuses: ReadonlyArray<number>;
7
- readonly queueBacked: boolean;
8
- readonly settlementTrait: string;
9
- readonly serializer: string;
10
- readonly auth: string;
11
- readonly access: string;
12
- readonly idempotency: boolean;
13
- readonly hasPayload: boolean;
14
- readonly bodyParams: ReadonlyArray<string>;
15
- readonly queryParams: ReadonlyArray<string>;
16
- readonly scalars: Readonly<Record<string, string | undefined>>;
17
- }
18
- export interface RouteTable {
19
- readonly version: 1;
20
- readonly routes: Readonly<Record<string, RouteRow | undefined>>;
21
- readonly settlementDisagreements: ReadonlyArray<string>;
22
- }
23
- export interface ErrorCodeTable {
24
- readonly version: 1;
25
- readonly codes: ReadonlyArray<string>;
26
- }
27
- export interface ErrorCatalogEntry {
28
- readonly id: string;
29
- readonly status: number;
30
- }
31
- export interface ErrorCatalogTable {
32
- readonly version: 1;
33
- readonly entries: Readonly<Record<string, ErrorCatalogEntry>>;
34
- }
35
- export interface RouteErrorCodeTable {
36
- readonly version: 1;
37
- readonly routes: Readonly<Record<string, ReadonlyArray<number> | undefined>>;
38
- }
39
- export interface JsonSchemaNode {
40
- readonly $ref?: string;
41
- readonly type?: string | ReadonlyArray<string>;
42
- readonly properties?: Readonly<Record<string, JsonSchemaNode>>;
43
- readonly required?: ReadonlyArray<string>;
44
- readonly additionalProperties?: boolean | JsonSchemaNode;
45
- readonly propertyNames?: JsonSchemaNode;
46
- readonly items?: JsonSchemaNode;
47
- readonly prefixItems?: ReadonlyArray<JsonSchemaNode>;
48
- readonly anyOf?: ReadonlyArray<JsonSchemaNode>;
49
- readonly oneOf?: ReadonlyArray<JsonSchemaNode>;
50
- readonly allOf?: ReadonlyArray<JsonSchemaNode>;
51
- readonly enum?: ReadonlyArray<unknown>;
52
- readonly const?: unknown;
53
- readonly pattern?: string;
54
- readonly minLength?: number;
55
- readonly maxLength?: number;
56
- readonly minimum?: number;
57
- readonly maximum?: number;
58
- readonly exclusiveMinimum?: number;
59
- readonly exclusiveMaximum?: number;
60
- readonly multipleOf?: number;
61
- readonly minItems?: number;
62
- readonly maxItems?: number;
63
- }
64
- export interface ResponseSchemaTable {
65
- readonly version: 1;
66
- readonly definitions: Readonly<Record<string, JsonSchemaNode>>;
67
- readonly routes: Readonly<Record<string, Readonly<Record<string, JsonSchemaNode | null>> | undefined>>;
68
- }
69
- export interface ResponseScalarTable {
70
- readonly version: 1;
71
- readonly routes: Readonly<Record<string, Readonly<Record<string, string>> | undefined>>;
72
- }
@@ -1,4 +0,0 @@
1
- export declare const SDK_RUNTIME_EXPORT_RELATIVE_PATHS: readonly ["dist/index.js", "dist/operations.js", "dist/types.js", "dist/index.d.ts", "dist/runtime-exports.js", "dist/runtime-exports.d.ts"];
2
- export declare const SDK_TYPE_ONLY_EXPORT_RELATIVE_PATHS: readonly ["dist/types.js"];
3
- export type SdkRuntimeExportRelativePath = (typeof SDK_RUNTIME_EXPORT_RELATIVE_PATHS)[number];
4
- export declare const SDK_BUILD_SENTINEL_RELATIVE_PATH: "dist/index.js";
@@ -1,16 +0,0 @@
1
- // src/runtime-exports.ts
2
- var SDK_RUNTIME_EXPORT_RELATIVE_PATHS = [
3
- "dist/index.js",
4
- "dist/operations.js",
5
- "dist/types.js",
6
- "dist/index.d.ts",
7
- "dist/runtime-exports.js",
8
- "dist/runtime-exports.d.ts"
9
- ];
10
- var SDK_TYPE_ONLY_EXPORT_RELATIVE_PATHS = ["dist/types.js"];
11
- var [SDK_BUILD_SENTINEL_RELATIVE_PATH] = SDK_RUNTIME_EXPORT_RELATIVE_PATHS;
12
- export {
13
- SDK_BUILD_SENTINEL_RELATIVE_PATH,
14
- SDK_RUNTIME_EXPORT_RELATIVE_PATHS,
15
- SDK_TYPE_ONLY_EXPORT_RELATIVE_PATHS
16
- };
package/dist/runtime.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export type DalpRuntime = "browser" | "server" | "react-native";
2
- /** @internal */
3
- export declare function detectDalpRuntime(): DalpRuntime;
4
- /** @internal */
5
- export declare function runtimeCredentials(runtime: DalpRuntime): RequestCredentials;
6
- /** @internal */
7
- export declare function isBufferingFetch(fetchImpl: unknown): boolean;
8
- /** @internal */
9
- export declare function keepBufferingMarker<Wrapper extends object>(wrapped: unknown, wrapper: Wrapper): Wrapper;
10
- /** @internal */
11
- export declare function refuseBundledApiKey(runtime: DalpRuntime): void;
@@ -1,4 +0,0 @@
1
- import type { Dnum } from "dnum";
2
- export type BigDecimalValue = Dnum;
3
- export declare function decodeBigDecimal(wire: string): BigDecimalValue;
4
- export declare const encodeBigDecimal: (value: Dnum) => string;
@@ -1,5 +0,0 @@
1
- export type EthereumAddressValue = string & {
2
- readonly __brand: "EthereumAddress";
3
- };
4
- export declare function decodeEthereumAddress(wire: string): EthereumAddressValue;
5
- export declare function tryDecodeEthereumAddress(wire: unknown): EthereumAddressValue | undefined;
@@ -1,13 +0,0 @@
1
- import { type BigDecimalValue } from "./big-decimal.ts";
2
- import { type EthereumAddressValue } from "./ethereum-address.ts";
3
- export interface ExchangeRateRow {
4
- readonly rate: BigDecimalValue | null;
5
- readonly feedAddress: EthereumAddressValue | null;
6
- readonly [key: string]: unknown;
7
- }
8
- export interface ExchangeRatesListResponse {
9
- readonly data: ReadonlyArray<ExchangeRateRow>;
10
- readonly [key: string]: unknown;
11
- }
12
- export declare function decodeExchangeRatesListResponse(payload: unknown): ExchangeRatesListResponse;
13
- export declare const exchangeRatesListTransformer: (data: unknown) => Promise<ExchangeRatesListResponse>;
@@ -1,10 +0,0 @@
1
- export { decodeBigDecimal, encodeBigDecimal } from "./big-decimal.ts";
2
- export type { BigDecimalValue } from "./big-decimal.ts";
3
- export { decodeTokenDecimals } from "./token-decimals.ts";
4
- export type { TokenDecimals } from "./token-decimals.ts";
5
- export { decodeEthereumAddress, tryDecodeEthereumAddress } from "./ethereum-address.ts";
6
- export type { EthereumAddressValue } from "./ethereum-address.ts";
7
- export { decodeOrganizationId, tryDecodeOrganizationId } from "./organization-id.ts";
8
- export type { OrganizationIdValue } from "./organization-id.ts";
9
- export { decodeExchangeRatesListResponse, exchangeRatesListTransformer } from "./exchange-rates.ts";
10
- export type { ExchangeRateRow, ExchangeRatesListResponse } from "./exchange-rates.ts";
@@ -1,102 +0,0 @@
1
- import {
2
- DalpSdkError2
3
- } from "../chunk-k3ntysxx.js";
4
-
5
- // src/scalars/big-decimal.ts
6
- import * as dn from "dnum";
7
- var DECIMAL_WIRE = /^-?\d+(?:\.\d+)?$/u;
8
- function decodeBigDecimal(wire) {
9
- if (!DECIMAL_WIRE.test(wire)) {
10
- throw new DalpSdkError2({
11
- code: "sdk.scalar.BIG_DECIMAL_INVALID",
12
- category: "sdk.configuration",
13
- retryable: false,
14
- message: `\`${wire}\` is not a plain decimal string.`,
15
- why: "A BigDecimal field carries an unscaled decimal, with no exponent and no separators.",
16
- fix: "Pass the value exactly as the API returned it."
17
- });
18
- }
19
- return dn.from(wire);
20
- }
21
- var encodeBigDecimal = (value) => dn.toString(value);
22
- // src/scalars/token-decimals.ts
23
- function decodeTokenDecimals(wire) {
24
- const value = typeof wire === "string" && /^\d+$/u.test(wire) ? Number(wire) : wire;
25
- if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 18) {
26
- throw new DalpSdkError2({
27
- code: "sdk.scalar.TOKEN_DECIMALS_INVALID",
28
- category: "sdk.configuration",
29
- retryable: false,
30
- message: "Token decimals are missing or outside the range 0–18.",
31
- why: "An ERC-20 token scale is a whole number from 0 through 18.",
32
- fix: "Pass the decimals field exactly as the API returned it."
33
- });
34
- }
35
- return value;
36
- }
37
- // src/scalars/ethereum-address.ts
38
- import { getAddress, isAddress } from "viem/utils";
39
- function decodeEthereumAddress(wire) {
40
- if (!isAddress(wire, { strict: false })) {
41
- throw new DalpSdkError2({
42
- code: "sdk.scalar.EVM_ADDRESS_INVALID",
43
- category: "sdk.configuration",
44
- retryable: false,
45
- message: `\`${wire}\` is not an EVM address.`,
46
- why: "An EVM address is 42 characters starting with 0x.",
47
- fix: "Pass the address exactly as the API returned it."
48
- });
49
- }
50
- return getAddress(wire);
51
- }
52
- function tryDecodeEthereumAddress(wire) {
53
- if (typeof wire !== "string" || !isAddress(wire, { strict: false })) {
54
- return;
55
- }
56
- return getAddress(wire);
57
- }
58
- // src/scalars/organization-id.ts
59
- function decodeOrganizationId(wire) {
60
- if (wire.length === 0) {
61
- throw new DalpSdkError2({
62
- code: "sdk.scalar.ORGANIZATION_ID_INVALID",
63
- category: "sdk.configuration",
64
- retryable: false,
65
- message: "An organization id cannot be empty.",
66
- why: "The organization id scopes every tenant-owned request.",
67
- fix: "Pass the id the platform returned for the active organization."
68
- });
69
- }
70
- return wire;
71
- }
72
- function tryDecodeOrganizationId(wire) {
73
- return typeof wire === "string" && wire.length > 0 ? wire : undefined;
74
- }
75
- // src/scalars/exchange-rates.ts
76
- function decodeRow(row) {
77
- const source = row !== null && typeof row === "object" ? row : { rate: null, feedAddress: null };
78
- const rate = Reflect.get(source, "rate");
79
- const feedAddress = Reflect.get(source, "feedAddress");
80
- return {
81
- ...source,
82
- rate: typeof rate === "string" ? decodeBigDecimal(rate) : null,
83
- feedAddress: typeof feedAddress === "string" ? decodeEthereumAddress(feedAddress) : null
84
- };
85
- }
86
- function decodeExchangeRatesListResponse(payload) {
87
- const source = payload !== null && typeof payload === "object" ? payload : { data: [] };
88
- const rows = Reflect.get(source, "data");
89
- return { ...source, data: Array.isArray(rows) ? rows.map(decodeRow) : [] };
90
- }
91
- var exchangeRatesListTransformer = async (data) => decodeExchangeRatesListResponse(data);
92
- export {
93
- decodeBigDecimal,
94
- decodeEthereumAddress,
95
- decodeExchangeRatesListResponse,
96
- decodeOrganizationId,
97
- decodeTokenDecimals,
98
- encodeBigDecimal,
99
- exchangeRatesListTransformer,
100
- tryDecodeEthereumAddress,
101
- tryDecodeOrganizationId
102
- };
@@ -1,5 +0,0 @@
1
- export type OrganizationIdValue = string & {
2
- readonly __brand: "OrganizationId";
3
- };
4
- export declare function decodeOrganizationId(wire: string): OrganizationIdValue;
5
- export declare function tryDecodeOrganizationId(wire: unknown): OrganizationIdValue | undefined;
@@ -1,4 +0,0 @@
1
- export type TokenDecimals = number & {
2
- readonly __brand: "TokenDecimals";
3
- };
4
- export declare function decodeTokenDecimals(wire: string | number | undefined): TokenDecimals;
package/dist/secret.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export declare const SECRET_REDACTION_MARKER = "[REDACTED]";
2
- declare const inspectSymbol: unique symbol;
3
- export declare class Secret {
4
- private constructor();
5
- static from(value: string): Secret;
6
- toString(): string;
7
- toJSON(): string;
8
- [inspectSymbol](): string;
9
- }
10
- export declare const secret: (value: string) => Secret;
11
- export declare const unwrapSecret: (value: Secret) => string;
12
- export {};
@@ -1,16 +0,0 @@
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;
@@ -1,26 +0,0 @@
1
- import {
2
- toStandardWebhookSecret2
3
- } from "./chunk-qvtjb3dz.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
- };
@@ -1,9 +0,0 @@
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;
@@ -1,24 +0,0 @@
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>;
@@ -1,8 +0,0 @@
1
- import {
2
- toStandardWebhookSecret2,
3
- verifyWebhook2
4
- } from "./chunk-qvtjb3dz.js";
5
- export {
6
- toStandardWebhookSecret2 as toStandardWebhookSecret,
7
- verifyWebhook2 as verifyWebhook
8
- };
@@ -1,151 +0,0 @@
1
- // src/wait-for-transaction.ts
2
- var failedStates = new Set(["FAILED", "DEAD_LETTER", "CANCELLED"]);
3
- var isWaitForTransactionSuccess = (status) => status.status === "COMPLETED";
4
-
5
- class DalpTransactionWaitError extends Error {
6
- code = "sdk.transaction.WAIT_FAILED";
7
- category = "operational";
8
- transactionId;
9
- reason;
10
- lastStatus;
11
- elapsedMs;
12
- constructor(transactionId, reason, lastStatus, elapsedMs) {
13
- let message;
14
- if (reason === "terminal-failure") {
15
- message = `Transaction ${transactionId} reached terminal state ${lastStatus?.status ?? "UNKNOWN"}`;
16
- } else if (reason === "timeout") {
17
- message = `Transaction ${transactionId} did not reach a terminal state within ${elapsedMs ?? 0}ms`;
18
- } else if (reason === "funding-paused") {
19
- message = `Transaction ${transactionId} is paused waiting for a gas funding payment`;
20
- } else if (reason === "indexer-rebuild") {
21
- const chainId = lastStatus?.indexerRebuild?.chainId;
22
- message = `Transaction ${transactionId} is on chain, and the platform is still rebuilding its index of chain ${chainId ?? "unknown"} before the write can be read back`;
23
- } else {
24
- message = `Transaction status observation was aborted for transaction ${transactionId}`;
25
- }
26
- super(message);
27
- this.name = "DalpTransactionWaitError";
28
- this.transactionId = transactionId;
29
- this.reason = reason;
30
- this.lastStatus = lastStatus;
31
- this.elapsedMs = elapsedMs;
32
- }
33
- get status() {
34
- return this.lastStatus?.status ?? "UNKNOWN";
35
- }
36
- get subStatus() {
37
- return this.lastStatus?.subStatus ?? null;
38
- }
39
- get retryable() {
40
- return this.reason === "timeout" || this.reason === "funding-paused" || this.reason === "indexer-rebuild";
41
- }
42
- }
43
- var isDalpTransactionWaitError = (error) => error instanceof DalpTransactionWaitError;
44
- var defaultSleep = (milliseconds, signal) => new Promise((resolve, reject) => {
45
- if (signal?.aborted === true) {
46
- reject(signal.reason);
47
- return;
48
- }
49
- const onAbort = () => {
50
- clearTimeout(timeout);
51
- reject(signal?.reason);
52
- };
53
- const timeout = setTimeout(() => {
54
- signal?.removeEventListener("abort", onAbort);
55
- resolve();
56
- }, milliseconds);
57
- signal?.addEventListener("abort", onAbort, { once: true });
58
- });
59
- var routeStatusReader = (client) => async (transactionId, signal) => {
60
- const result = await client.execute("transactionsV2.status", { transactionId }, signal === undefined ? undefined : { signal });
61
- const body = result !== null && typeof result === "object" ? Reflect.get(result, "data") ?? result : result;
62
- return body;
63
- };
64
- var MAX_UNREADABLE_HOLDS = 5;
65
- var noParks = { fundingPaused: false, indexerRebuild: false };
66
- var PAUSED_POLL_INTERVAL_MAX_MS = 30000;
67
- function readParks(status, held) {
68
- const fundingPaused = status.activeRequirement !== undefined && status.activeRequirement !== null;
69
- const indexerRebuild = status.indexerRebuild !== undefined && status.indexerRebuild !== null;
70
- return {
71
- fundingPaused: fundingPaused || held.fundingPaused && status.activeRequirementUnavailable === true,
72
- indexerRebuild: indexerRebuild || held.indexerRebuild && status.indexerRebuildUnavailable === true
73
- };
74
- }
75
- function namedPark(parks) {
76
- if (parks.fundingPaused) {
77
- return "funding-paused";
78
- }
79
- return parks.indexerRebuild ? "indexer-rebuild" : undefined;
80
- }
81
- async function waitForTransaction(client, transactionId, options = {}) {
82
- const timeoutMs = options.timeoutMs ?? 120000;
83
- const pollIntervalMs = options.pollIntervalMs ?? 1000;
84
- const now = options.now ?? Date.now;
85
- const sleep = options.sleep ?? defaultSleep;
86
- const readStatus = options.readStatus ?? routeStatusReader(client);
87
- const holdWhilePaused = options.holdWhilePaused ?? true;
88
- const holdWhileRebuilding = options.holdWhileRebuilding ?? true;
89
- const waitStartedAt = now();
90
- let budgetStartedAt = waitStartedAt;
91
- let pollDelayMs = pollIntervalMs;
92
- let lastStatus;
93
- let held = noParks;
94
- let unreadableHolds = 0;
95
- const isAborted = () => options.signal?.aborted === true;
96
- while (true) {
97
- if (isAborted()) {
98
- throw new DalpTransactionWaitError(transactionId, "aborted", lastStatus);
99
- }
100
- if (now() - budgetStartedAt >= timeoutMs) {
101
- const ranOutIn = namedPark(held) ?? "timeout";
102
- throw new DalpTransactionWaitError(transactionId, ranOutIn, lastStatus, now() - waitStartedAt);
103
- }
104
- try {
105
- lastStatus = await readStatus(transactionId, options.signal);
106
- } catch (error) {
107
- if (isAborted()) {
108
- throw new DalpTransactionWaitError(transactionId, "aborted", lastStatus);
109
- }
110
- throw error;
111
- }
112
- options.onStatus?.(lastStatus);
113
- if (failedStates.has(lastStatus.status)) {
114
- throw new DalpTransactionWaitError(transactionId, "terminal-failure", lastStatus);
115
- }
116
- if (isWaitForTransactionSuccess(lastStatus)) {
117
- return lastStatus;
118
- }
119
- const ownParks = readParks(lastStatus, noParks);
120
- held = readParks(lastStatus, held);
121
- const parkedBy = namedPark(held);
122
- unreadableHolds = parkedBy === undefined || namedPark(ownParks) !== undefined ? 0 : unreadableHolds + 1;
123
- let holdsThroughIt = false;
124
- if (parkedBy === "funding-paused") {
125
- holdsThroughIt = holdWhilePaused;
126
- } else if (parkedBy === "indexer-rebuild") {
127
- holdsThroughIt = holdWhileRebuilding;
128
- }
129
- if (parkedBy === undefined) {
130
- pollDelayMs = pollIntervalMs;
131
- } else {
132
- if (!holdsThroughIt) {
133
- throw new DalpTransactionWaitError(transactionId, parkedBy, lastStatus, now() - waitStartedAt);
134
- }
135
- if (unreadableHolds <= MAX_UNREADABLE_HOLDS) {
136
- budgetStartedAt = now();
137
- }
138
- pollDelayMs = Math.min(pollDelayMs * 2, Math.max(pollIntervalMs, PAUSED_POLL_INTERVAL_MAX_MS));
139
- }
140
- try {
141
- await sleep(Math.min(pollDelayMs, Math.max(0, timeoutMs - (now() - budgetStartedAt))), options.signal);
142
- } catch {
143
- throw new DalpTransactionWaitError(transactionId, "aborted", lastStatus);
144
- }
145
- }
146
- }
147
- export {
148
- DalpTransactionWaitError,
149
- isDalpTransactionWaitError,
150
- waitForTransaction
151
- };