@settlemint/dalp-sdk 3.1.25 → 3.1.26-main.37113215468

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +239 -172
  2. package/dist/auth/client.d.ts +103 -0
  3. package/dist/auth/invite-step-up.d.ts +2 -0
  4. package/dist/auth/live.d.ts +47 -0
  5. package/dist/auth/native-passkey.d.ts +9 -0
  6. package/dist/{auth-permissions.d.ts → auth/permissions.d.ts} +0 -8
  7. package/dist/{auth-wallet-plugins.d.ts → auth/wallet-plugins.d.ts} +68 -6
  8. package/dist/auth-surface.d.ts +2 -0
  9. package/dist/auth.d.ts +8 -115
  10. package/dist/auth.js +525 -0
  11. package/dist/chunk-16xvy8xj.js +271 -0
  12. package/dist/chunk-4f4kjtt0.js +149 -0
  13. package/dist/chunk-b03ycwb7.js +68 -0
  14. package/dist/chunk-ghgcmyhk.js +5 -0
  15. package/dist/chunk-h241xecg.js +1625 -0
  16. package/dist/chunk-hqz56e6q.js +4 -0
  17. package/dist/chunk-k3ntysxx.js +57 -0
  18. package/dist/chunk-pjjrxre1.js +36 -0
  19. package/dist/chunk-qvtjb3dz.js +102 -0
  20. package/dist/chunk-w361dpdk.js +5 -0
  21. package/dist/client/conditional-request.d.ts +8 -0
  22. package/dist/client/factory.d.ts +4 -0
  23. package/dist/client/query-serializer.d.ts +1 -0
  24. package/dist/client/request-compression.d.ts +12 -0
  25. package/dist/client/ssr-fetch.d.ts +10 -0
  26. package/dist/client/step-up-challenge.d.ts +10 -0
  27. package/dist/effect.d.ts +38 -0
  28. package/dist/effect.js +87 -0
  29. package/dist/errors/api-error.d.ts +35 -0
  30. package/dist/errors/error-codes.d.ts +21 -0
  31. package/dist/errors/find-current-error.d.ts +2 -0
  32. package/dist/errors/sdk-error.d.ts +52 -0
  33. package/dist/errors/sdk-error.js +8 -0
  34. package/dist/generated/api-types.d.ts +69961 -0
  35. package/dist/generated/console-routes.d.ts +12 -0
  36. package/dist/generated/error-catalog.d.ts +9 -0
  37. package/dist/generated/error-codes.d.ts +9 -0
  38. package/dist/generated/response-scalars.d.ts +9 -0
  39. package/dist/generated/response-schemas.d.ts +9 -0
  40. package/dist/generated/route-error-codes.d.ts +9 -0
  41. package/dist/generated/routes.d.ts +12 -0
  42. package/dist/index.d.ts +28 -45
  43. package/dist/index.js +150 -96216
  44. package/dist/proxy/builder.d.ts +17 -0
  45. package/dist/proxy/client-core.d.ts +28 -0
  46. package/dist/proxy/client.d.ts +5 -0
  47. package/dist/proxy/fetch-executor.d.ts +6 -0
  48. package/dist/proxy/flat-args.d.ts +24 -0
  49. package/dist/proxy/response-decode.d.ts +37 -0
  50. package/dist/proxy/sse.d.ts +11 -0
  51. package/dist/proxy/step-up-challenge.d.ts +4 -0
  52. package/dist/proxy/tanstack.d.ts +6 -0
  53. package/dist/proxy/transport.d.ts +63 -0
  54. package/dist/react-query.d.ts +2 -0
  55. package/dist/react-query.js +12 -0
  56. package/dist/readonly-deep.d.ts +3 -0
  57. package/dist/routes/console.d.ts +14 -0
  58. package/dist/routes/console.js +25 -0
  59. package/dist/routes/index.d.ts +4 -0
  60. package/dist/routes/index.js +10 -0
  61. package/dist/routes/types.d.ts +72 -0
  62. package/dist/runtime-exports.d.ts +4 -0
  63. package/dist/runtime-exports.js +16 -0
  64. package/dist/runtime.d.ts +11 -0
  65. package/dist/scalars/big-decimal.d.ts +4 -0
  66. package/dist/scalars/ethereum-address.d.ts +5 -0
  67. package/dist/scalars/exchange-rates.d.ts +13 -0
  68. package/dist/scalars/index.d.ts +10 -0
  69. package/dist/scalars/index.js +102 -0
  70. package/dist/scalars/organization-id.d.ts +5 -0
  71. package/dist/scalars/token-decimals.d.ts +4 -0
  72. package/dist/secret.d.ts +12 -0
  73. package/dist/sign-webhook-receipt.d.ts +16 -0
  74. package/dist/sign-webhook-receipt.js +26 -0
  75. package/dist/transport/cookie-store.d.ts +9 -0
  76. package/dist/transport/sse-lifecycle.d.ts +24 -0
  77. package/dist/types.d.ts +37 -114
  78. package/dist/url.d.ts +0 -1
  79. package/dist/verify-webhook.d.ts +17 -28
  80. package/dist/verify-webhook.js +8 -0
  81. package/dist/version.d.ts +0 -3
  82. package/dist/wait-for-transaction.d.ts +44 -86
  83. package/dist/wait-for-transaction.js +151 -0
  84. package/dist/webhook-events.d.ts +543 -33
  85. package/package.json +110 -34
  86. package/dist/api-types.generated.d.ts +0 -14160
  87. package/dist/api-types.generated.d.ts.map +0 -1
  88. package/dist/auth-permissions.d.ts.map +0 -1
  89. package/dist/auth-wallet-plugins.d.ts.map +0 -1
  90. package/dist/auth.d.ts.map +0 -1
  91. package/dist/bundler.d.ts +0 -217
  92. package/dist/bundler.d.ts.map +0 -1
  93. package/dist/chunk-xm8h1dzh.js +0 -33
  94. package/dist/client.d.ts +0 -19
  95. package/dist/client.d.ts.map +0 -1
  96. package/dist/contract-errors.d.ts +0 -4156
  97. package/dist/contract-errors.d.ts.map +0 -1
  98. package/dist/contract.d.ts +0 -22
  99. package/dist/contract.d.ts.map +0 -1
  100. package/dist/cookie-store.d.ts +0 -10
  101. package/dist/cookie-store.d.ts.map +0 -1
  102. package/dist/dapi-errors.d.ts +0 -654
  103. package/dist/dapi-errors.d.ts.map +0 -1
  104. package/dist/errors.d.ts +0 -637
  105. package/dist/errors.d.ts.map +0 -1
  106. package/dist/index.d.ts.map +0 -1
  107. package/dist/platform.d.ts +0 -41
  108. package/dist/platform.d.ts.map +0 -1
  109. package/dist/plugins/index.d.ts +0 -13
  110. package/dist/plugins/index.d.ts.map +0 -1
  111. package/dist/plugins/index.js +0 -10
  112. package/dist/sdk-error.d.ts +0 -74
  113. package/dist/sdk-error.d.ts.map +0 -1
  114. package/dist/serializers.d.ts +0 -41
  115. package/dist/serializers.d.ts.map +0 -1
  116. package/dist/types.d.ts.map +0 -1
  117. package/dist/url.d.ts.map +0 -1
  118. package/dist/verify-webhook.d.ts.map +0 -1
  119. package/dist/version.d.ts.map +0 -1
  120. package/dist/version.generated.d.ts +0 -8
  121. package/dist/version.generated.d.ts.map +0 -1
  122. package/dist/wait-for-transaction.d.ts.map +0 -1
  123. package/dist/webhook-events.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ export declare function serializeDalpQuery(query: unknown): string;
@@ -0,0 +1,12 @@
1
+ import type { DalpFetch } from "./ssr-fetch.ts";
2
+ export declare const DALP_SDK_REQUEST_COMPRESSION_MIN_BODY_BYTES = 1024;
3
+ export declare const DALP_SDK_REQUEST_COMPRESSION_MAX_BODY_BYTES = 16777216;
4
+ export type FetchRequestCompression = true | "gzip" | "deflate" | "br" | "zstd";
5
+ export interface CompressionRequestInit extends RequestInit {
6
+ readonly compress?: FetchRequestCompression;
7
+ }
8
+ export interface RequestBodyCompressionOptions {
9
+ readonly minBodyBytes?: number;
10
+ readonly maxBodyBytes?: number;
11
+ }
12
+ export declare function withRequestBodyCompression(fetchImpl: DalpFetch, options?: RequestBodyCompressionOptions): DalpFetch;
@@ -0,0 +1,10 @@
1
+ export type DalpFetch = ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & {
2
+ readonly preconnect?: typeof fetch.preconnect;
3
+ };
4
+ export interface CreateSsrFetchOptions {
5
+ readonly allowedOrigins?: ReadonlyArray<string | URL>;
6
+ readonly baseUrl: string | URL;
7
+ readonly fetch: DalpFetch;
8
+ readonly requestHeaders: HeadersInit;
9
+ }
10
+ export declare function createSsrFetch(options: CreateSsrFetchOptions): DalpFetch;
@@ -0,0 +1,10 @@
1
+ export declare const STEP_UP_CHALLENGE_HEADER = "X-Step-Up-Challenge";
2
+ export declare const WALLET_VERIFICATION_HEADER = "X-Wallet-Verification";
3
+ export declare const STEP_UP_CHALLENGE_PATH = "/api/v2/step-up-challenges";
4
+ export interface StepUpChallengeRequest {
5
+ readonly operation: string;
6
+ readonly target: string | null;
7
+ readonly payloadDigest: string;
8
+ }
9
+ export declare function carriesWalletProof(body: unknown): boolean;
10
+ export declare function stepUpChallengeRequest(operation: string, target: string | null, body: unknown): Promise<StepUpChallengeRequest>;
@@ -0,0 +1,38 @@
1
+ import * as Effect from "effect/Effect";
2
+ import type { DalpApi, DalpRouteId, DalpRouteTypes } from "./generated/api-types.d.ts";
3
+ import { type CallOptions } from "./proxy/builder.ts";
4
+ import { type CreateDalpClientOptions } from "./proxy/transport.ts";
5
+ import { DalpApiError } from "./errors/api-error.ts";
6
+ export declare class DalpRequestError<Code extends string = string> extends Error {
7
+ readonly _tag = "DalpRequestError";
8
+ readonly id: string;
9
+ readonly code: Code;
10
+ readonly status: number | undefined;
11
+ readonly retryable: boolean;
12
+ readonly retryAfterSeconds: number | undefined;
13
+ readonly routeId: string;
14
+ readonly data: DalpApiError["data"];
15
+ constructor(routeId: string, cause: unknown);
16
+ }
17
+ export type DalpEffectApi = DalpEffectApiNode<DalpApi>;
18
+ type DalpEffectApiNode<T> = {
19
+ readonly [K in keyof T]: T[K] extends (...args: infer Args) => AsyncIterable<infer Frame> ? T[K] extends {
20
+ readonly __errorCode?: infer Code extends string;
21
+ } ? (...args: Args) => Effect.Effect<AsyncIterable<Frame>, DalpRequestError<Code>> : (...args: Args) => Effect.Effect<AsyncIterable<Frame>, DalpRequestError> : T[K] extends (...args: infer Args) => Promise<infer A> ? T[K] extends {
22
+ readonly __errorCode?: infer Code extends string;
23
+ } ? (...args: Args) => Effect.Effect<A, DalpRequestError<Code>> : (...args: Args) => Effect.Effect<A, DalpRequestError> : DalpEffectApiNode<T[K]>;
24
+ };
25
+ export type DalpStreamingRouteId = {
26
+ [Id in DalpRouteId]: DalpRouteTypes[Id]["streaming"] extends true ? Id : never;
27
+ }[DalpRouteId];
28
+ export interface DalpEffectClient {
29
+ readonly api: DalpEffectApi;
30
+ readonly execute: {
31
+ <Id extends DalpStreamingRouteId>(routeId: Id, input?: DalpRouteTypes[Id]["request"], options?: CallOptions): Effect.Effect<AsyncIterable<DalpRouteTypes[Id]["response"]>, DalpRequestError>;
32
+ <Id extends DalpRouteId>(routeId: Id, input?: DalpRouteTypes[Id]["request"], options?: CallOptions): Effect.Effect<DalpRouteTypes[Id]["response"], DalpRequestError>;
33
+ };
34
+ }
35
+ export declare function createDalpEffectClient(options: CreateDalpClientOptions): DalpEffectClient;
36
+ export type { CallOptions } from "./proxy/builder.ts";
37
+ export type { CreateDalpClientOptions } from "./proxy/transport.ts";
38
+ export type { DalpRouteId, DalpRouteTypes } from "./generated/api-types.d.ts";
package/dist/effect.js ADDED
@@ -0,0 +1,87 @@
1
+ import {
2
+ data2
3
+ } from "./chunk-hqz56e6q.js";
4
+ import"./chunk-k3ntysxx.js";
5
+ import {
6
+ DalpApiError2,
7
+ createTransport,
8
+ streamRequest,
9
+ sendRequest,
10
+ queryKeyFor2
11
+ } from "./chunk-h241xecg.js";
12
+ import"./chunk-4f4kjtt0.js";
13
+ import {
14
+ buildProxy,
15
+ findRoute
16
+ } from "./chunk-b03ycwb7.js";
17
+
18
+ // src/effect.ts
19
+ import * as Effect from "effect/Effect";
20
+ class DalpRequestError extends Error {
21
+ _tag = "DalpRequestError";
22
+ id;
23
+ code;
24
+ status;
25
+ retryable;
26
+ retryAfterSeconds;
27
+ routeId;
28
+ data;
29
+ constructor(routeId, cause) {
30
+ const api = cause instanceof DalpApiError2 ? cause : undefined;
31
+ super(api?.message ?? `DALP request failed for ${routeId}`, { cause });
32
+ this.name = "DalpRequestError";
33
+ this._tag = "DalpRequestError";
34
+ this.routeId = routeId;
35
+ this.code = api?.code ?? "sdk.transport.REQUEST_FAILED";
36
+ this.id = api?.id ?? this.code;
37
+ this.status = api?.status;
38
+ this.retryable = api?.retryable ?? true;
39
+ this.retryAfterSeconds = api?.retryAfterSeconds;
40
+ this.data = api?.data;
41
+ }
42
+ }
43
+ function runRoute(transport, route, id, input, options) {
44
+ return Effect.callback((resume) => {
45
+ const controller = new AbortController;
46
+ const signal = options?.signal ?? controller.signal;
47
+ const run = async () => {
48
+ try {
49
+ resume(Effect.succeed(route.serializer === "sse" ? streamRequest(transport, route, id, { flat: input }, { ...options, signal }) : await sendRequest(transport, route, id, { flat: input }, { ...options, signal })));
50
+ } catch (error) {
51
+ resume(Effect.fail(new DalpRequestError(id, error)));
52
+ }
53
+ };
54
+ run();
55
+ return Effect.sync(() => {
56
+ controller.abort();
57
+ });
58
+ });
59
+ }
60
+ function createDalpEffectClient(options) {
61
+ const transport = createTransport(options);
62
+ const executor = (route, id, input, callOptions) => runRoute(transport, route, id, input, callOptions);
63
+ const factories = {
64
+ queryOptions: (route, id, input, callOptions) => ({
65
+ queryKey: queryKeyFor2(id, input),
66
+ queryFn: () => runRoute(transport, route, id, input, callOptions)
67
+ }),
68
+ mutationOptions: (route, id, callOptions) => ({
69
+ mutationKey: ["dalp", id],
70
+ mutationFn: (input) => runRoute(transport, route, id, input, callOptions)
71
+ })
72
+ };
73
+ return {
74
+ api: buildProxy(data2, executor, factories),
75
+ execute: (routeId, input, callOptions) => {
76
+ const route = findRoute(data2, routeId);
77
+ if (route === undefined) {
78
+ return Effect.fail(new DalpRequestError(routeId, new TypeError(`Unknown DALP route \`${routeId}\``)));
79
+ }
80
+ return runRoute(transport, route, routeId, input, callOptions);
81
+ }
82
+ };
83
+ }
84
+ export {
85
+ DalpRequestError,
86
+ createDalpEffectClient
87
+ };
@@ -0,0 +1,35 @@
1
+ import { findCurrentError } from "./find-current-error.ts";
2
+ import type { DalpSdkErrorDetails } from "./sdk-error.ts";
3
+ import type { DalpApiErrorCode } from "./error-codes.ts";
4
+ export type DalpApiErrorCategory = "client" | "auth" | "permission" | "domain" | "contract" | "dependency" | "operational" | "config" | "unknown";
5
+ export interface DalpApiErrorOptions<Code extends DalpApiErrorCode = DalpApiErrorCode> {
6
+ readonly message: string;
7
+ readonly cause?: unknown;
8
+ readonly id?: string;
9
+ readonly code: Code;
10
+ readonly routeId?: string;
11
+ readonly category: DalpApiErrorCategory;
12
+ readonly status?: number;
13
+ readonly retryable: boolean;
14
+ readonly why: string;
15
+ readonly fix: string;
16
+ readonly retryAfterSeconds?: number;
17
+ readonly data?: DalpSdkErrorDetails;
18
+ }
19
+ export declare class DalpApiError<Code extends DalpApiErrorCode = DalpApiErrorCode> extends Error {
20
+ readonly id?: string;
21
+ readonly code: Code;
22
+ readonly routeId?: string;
23
+ readonly category: DalpApiErrorCategory;
24
+ readonly status?: number;
25
+ readonly retryable: boolean;
26
+ readonly why: string;
27
+ readonly fix: string;
28
+ readonly retryAfterSeconds?: number;
29
+ readonly data?: DalpSdkErrorDetails;
30
+ constructor(options: DalpApiErrorOptions<Code>);
31
+ static make(options: DalpApiErrorOptions): DalpApiError;
32
+ }
33
+ export declare const isDalpApiError: (error: unknown) => error is DalpApiError;
34
+ export declare const findDalpSdkError: typeof findCurrentError;
35
+ export declare const makeDalpApiError: (error: unknown) => DalpApiError;
@@ -0,0 +1,21 @@
1
+ import type { DalpErrorCode, DalpRouteErrorCode, DalpRouteId } from "../generated/api-types.d.ts";
2
+ import { type DalpApiError } from "./api-error.ts";
3
+ export type DalpSdkLocalErrorCode = "DALP_SDK_ERROR" | "sdk.transport.REQUEST_FAILED" | "sdk.transport.MALFORMED_RESPONSE" | "sdk.transport.UNPUBLISHED_ERROR_CODE" | "sdk.transport.UNVERIFIED_ERROR_CODE" | `sdk.transport.HTTP_${number}` | "sdk.response.MALFORMED_SUCCESS" | "sdk.stream.FAILED" | "sdk.stream.UNREADABLE_BODY" | "sdk.scalar.BIG_DECIMAL_INVALID" | "sdk.scalar.EVM_ADDRESS_INVALID" | "sdk.scalar.ORGANIZATION_ID_INVALID" | "sdk.scalar.TOKEN_DECIMALS_INVALID";
4
+ export type DalpApiErrorCode = DalpErrorCode | DalpSdkLocalErrorCode;
5
+ export declare const isDalpErrorCode: (code: string) => code is DalpErrorCode;
6
+ export declare const isDalpSdkLocalErrorCode: (code: string) => code is DalpSdkLocalErrorCode;
7
+ export declare const isDalpApiErrorCode: (code: string) => code is DalpApiErrorCode;
8
+ /** @internal */
9
+ export type RouteErrorCodeCheck = {
10
+ readonly kind: "published";
11
+ readonly code: DalpErrorCode;
12
+ } | {
13
+ readonly kind: "unpublished";
14
+ } | {
15
+ readonly kind: "unverified";
16
+ };
17
+ /** @internal */
18
+ export declare function checkRouteErrorCode(routeId: string, code: string): Promise<RouteErrorCodeCheck>;
19
+ /** @internal */
20
+ export declare const answeredByRoute: (error: DalpApiError, routeIds: ReadonlyArray<string>) => boolean;
21
+ export declare const isDalpRouteError: <Id extends DalpRouteId>(error: unknown, ...routeIds: readonly [Id, ...ReadonlyArray<Id>]) => error is DalpApiError<DalpRouteErrorCode<Id> | DalpSdkLocalErrorCode>;
@@ -0,0 +1,2 @@
1
+ import { DalpSdkError } from "./sdk-error.ts";
2
+ export declare const findCurrentError: (error: unknown, maxNodes?: number) => DalpSdkError | undefined;
@@ -0,0 +1,52 @@
1
+ import type { DalpApiErrorCode } from "./error-codes.ts";
2
+ export interface DalpSdkErrorOptions {
3
+ readonly code?: DalpApiErrorCode;
4
+ readonly routeId?: string;
5
+ readonly category: string;
6
+ readonly status?: number;
7
+ readonly retryable: boolean;
8
+ readonly message: string;
9
+ readonly why: string;
10
+ readonly fix: string;
11
+ readonly details?: DalpSdkErrorDetails;
12
+ readonly retryAfterSeconds?: number;
13
+ readonly cause?: unknown;
14
+ }
15
+ export type DalpSdkJsonValue = null | boolean | number | string | ReadonlyArray<DalpSdkJsonValue> | DalpSdkJsonObject;
16
+ export interface DalpSdkJsonObject {
17
+ readonly [key: string]: DalpSdkJsonValue;
18
+ }
19
+ export type DalpSdkErrorDetails = DalpSdkJsonObject;
20
+ export interface DalpSdkConfigurationErrorInput {
21
+ readonly message: string;
22
+ readonly why: string;
23
+ readonly fix: string;
24
+ readonly cause?: unknown;
25
+ }
26
+ export interface DalpSdkErrorJson {
27
+ readonly name: "DalpSdkError";
28
+ readonly code: DalpApiErrorCode;
29
+ readonly routeId?: string;
30
+ readonly category: string;
31
+ readonly status?: number;
32
+ readonly retryable: boolean;
33
+ readonly message: string;
34
+ readonly why: string;
35
+ readonly fix: string;
36
+ readonly details?: DalpSdkErrorDetails;
37
+ readonly retryAfterSeconds?: number;
38
+ }
39
+ export declare class DalpSdkError extends Error {
40
+ readonly code: DalpApiErrorCode;
41
+ readonly routeId?: string;
42
+ readonly category: string;
43
+ readonly status?: number;
44
+ readonly retryable: boolean;
45
+ readonly why: string;
46
+ readonly fix: string;
47
+ readonly details?: DalpSdkErrorDetails;
48
+ readonly retryAfterSeconds?: number;
49
+ constructor(options: Readonly<DalpSdkErrorOptions>);
50
+ toJSON(): DalpSdkErrorJson;
51
+ }
52
+ export declare function createDalpSdkConfigurationError(input: Readonly<DalpSdkConfigurationErrorInput>): DalpSdkError;
@@ -0,0 +1,8 @@
1
+ import {
2
+ DalpSdkError2,
3
+ createDalpSdkConfigurationError2
4
+ } from "../chunk-k3ntysxx.js";
5
+ export {
6
+ DalpSdkError2 as DalpSdkError,
7
+ createDalpSdkConfigurationError2 as createDalpSdkConfigurationError
8
+ };