@settlemint/dalp-sdk 3.1.10 → 3.1.11-main.33538712635
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -177
- package/dist/auth/client.d.ts +115 -0
- package/dist/auth/live.d.ts +4366 -0
- package/dist/{auth-permissions.d.ts → auth/permissions.d.ts} +1 -2
- package/dist/{auth-wallet-plugins.d.ts → auth/wallet-plugins.d.ts} +69 -5
- package/dist/auth.d.ts +22 -115
- package/dist/auth.js +248 -0
- package/dist/bundler.d.ts +17 -207
- package/dist/bundler.js +111 -0
- package/dist/chunk-63xjs3xe.js +45725 -0
- package/dist/chunk-cy9b59s6.js +503 -0
- package/dist/chunk-h12fatty.js +63 -0
- package/dist/chunk-nac758dt.js +14542 -0
- package/dist/chunk-p009n1rm.js +255 -0
- package/dist/chunk-r0vsftj4.js +102 -0
- package/dist/chunk-w21k7p99.js +843 -0
- package/dist/chunk-y0d2c7kp.js +54 -0
- package/dist/client/conditional-request.d.ts +16 -0
- package/dist/client/factory.d.ts +39 -0
- package/dist/client/query-serializer.d.ts +2 -0
- package/dist/client/request-compression.d.ts +47 -0
- package/dist/client/ssr-fetch.d.ts +12 -0
- package/dist/errors/api-error.d.ts +29 -0
- package/dist/errors/find-current-error.d.ts +8 -0
- package/dist/errors/sdk-error.d.ts +52 -0
- package/dist/errors/sdk-error.js +8 -0
- package/dist/generated/@tanstack/react-query.gen.d.ts +17380 -0
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/index.d.ts +10 -0
- package/dist/generated/client/types.gen.d.ts +120 -0
- package/dist/generated/client/utils.gen.d.ts +37 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/core/auth.gen.d.ts +25 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/types.gen.d.ts +83 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/sdk.gen.d.ts +5214 -0
- package/dist/generated/types.gen.d.ts +137282 -0
- package/dist/generated/zod.gen.d.ts +181286 -0
- package/dist/index.d.ts +23 -40
- package/dist/index.js +208 -96098
- package/dist/operations.d.ts +12 -0
- package/dist/operations.js +1747 -0
- package/dist/react-query.d.ts +11 -0
- package/dist/react-query.js +16485 -0
- package/dist/readonly-deep.d.ts +12 -0
- package/dist/runtime-exports.d.ts +20 -0
- package/dist/runtime-exports.js +16 -0
- package/dist/scalars/big-decimal.d.ts +16 -0
- package/dist/scalars/ethereum-address.d.ts +8 -0
- package/dist/scalars/exchange-rates.d.ts +36 -0
- package/dist/scalars/index.d.ts +15 -0
- package/dist/scalars/index.js +39 -0
- package/dist/scalars/organization-id.d.ts +8 -0
- package/dist/schemas.d.ts +10 -0
- package/dist/schemas.js +12040 -0
- package/dist/secret.d.ts +14 -0
- package/dist/sign-webhook-receipt.d.ts +76 -0
- package/dist/sign-webhook-receipt.js +26 -0
- package/dist/transport/cookie-store.d.ts +9 -0
- package/dist/transport/sse-lifecycle.d.ts +44 -0
- package/dist/types.d.ts +67 -102
- package/dist/url.d.ts +0 -1
- package/dist/verify-webhook.d.ts +17 -28
- package/dist/verify-webhook.js +8 -0
- package/dist/version.d.ts +0 -1
- package/dist/wait-for-transaction.d.ts +40 -86
- package/dist/wait-for-transaction.js +112 -0
- package/dist/webhook-events.d.ts +44 -27
- package/package.json +98 -30
- package/dist/auth-permissions.d.ts.map +0 -1
- package/dist/auth-wallet-plugins.d.ts.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/bundler.d.ts.map +0 -1
- package/dist/chunk-xm8h1dzh.js +0 -33
- package/dist/client.d.ts +0 -19
- package/dist/client.d.ts.map +0 -1
- package/dist/contract-errors.d.ts +0 -4156
- package/dist/contract-errors.d.ts.map +0 -1
- package/dist/contract.d.ts +0 -17
- package/dist/contract.d.ts.map +0 -1
- package/dist/cookie-store.d.ts +0 -10
- package/dist/cookie-store.d.ts.map +0 -1
- package/dist/dapi-errors.d.ts +0 -650
- package/dist/dapi-errors.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -633
- package/dist/errors.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/platform.d.ts +0 -41
- package/dist/platform.d.ts.map +0 -1
- package/dist/plugins/index.d.ts +0 -13
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -10
- package/dist/sdk-error.d.ts +0 -74
- package/dist/sdk-error.d.ts.map +0 -1
- package/dist/serializers.d.ts +0 -41
- package/dist/serializers.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/url.d.ts.map +0 -1
- package/dist/verify-webhook.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/wait-for-transaction.d.ts.map +0 -1
- package/dist/webhook-events.d.ts.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/errors/sdk-error.ts
|
|
2
|
+
var DALP_SDK_ERROR_CODE = "DALP_SDK_ERROR";
|
|
3
|
+
var DALP_SDK_ERROR_CATEGORY = "sdk.configuration";
|
|
4
|
+
|
|
5
|
+
class DalpSdkError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
category;
|
|
8
|
+
status;
|
|
9
|
+
retryable;
|
|
10
|
+
why;
|
|
11
|
+
fix;
|
|
12
|
+
details;
|
|
13
|
+
retryAfterSeconds;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options.message, { cause: options.cause });
|
|
16
|
+
this.name = "DalpSdkError";
|
|
17
|
+
this.code = options.code ?? DALP_SDK_ERROR_CODE;
|
|
18
|
+
this.category = options.category;
|
|
19
|
+
this.status = options.status;
|
|
20
|
+
this.retryable = options.retryable;
|
|
21
|
+
this.why = options.why;
|
|
22
|
+
this.fix = options.fix;
|
|
23
|
+
this.details = options.details;
|
|
24
|
+
this.retryAfterSeconds = options.retryAfterSeconds;
|
|
25
|
+
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
return {
|
|
28
|
+
name: "DalpSdkError",
|
|
29
|
+
code: this.code,
|
|
30
|
+
category: this.category,
|
|
31
|
+
retryable: this.retryable,
|
|
32
|
+
message: this.message,
|
|
33
|
+
why: this.why,
|
|
34
|
+
fix: this.fix,
|
|
35
|
+
...this.status === undefined ? {} : { status: this.status },
|
|
36
|
+
...this.details === undefined ? {} : { details: this.details },
|
|
37
|
+
...this.retryAfterSeconds === undefined ? {} : { retryAfterSeconds: this.retryAfterSeconds }
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function createDalpSdkConfigurationError(input) {
|
|
42
|
+
return new DalpSdkError({
|
|
43
|
+
code: DALP_SDK_ERROR_CODE,
|
|
44
|
+
category: DALP_SDK_ERROR_CATEGORY,
|
|
45
|
+
status: 400,
|
|
46
|
+
retryable: false,
|
|
47
|
+
message: input.message,
|
|
48
|
+
why: input.why,
|
|
49
|
+
fix: input.fix,
|
|
50
|
+
cause: input.cause
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { DalpSdkError, createDalpSdkConfigurationError };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Client } from "../generated/client/types.gen.ts";
|
|
2
|
+
/** Drop every held ETag/body for this client. Call on sign-out and organization switch. */
|
|
3
|
+
export declare function clearConditionalRequestStore(client: Client): void;
|
|
4
|
+
/**
|
|
5
|
+
* Install one per-client If-None-Match / 304 rewrite pair for conditional GET.
|
|
6
|
+
*
|
|
7
|
+
* Server ETags must be strong content digests computed after authorization
|
|
8
|
+
* inside the requester's partition. The dapi response cache guarantees this:
|
|
9
|
+
* `encodeResponseCacheEntry` sets `etag` to the SHA-256 of the serialized
|
|
10
|
+
* body after the request-context middleware has authenticated the session.
|
|
11
|
+
* Version-stamp ETags (generation counters, watermarks, table versions) are
|
|
12
|
+
* forbidden for conditional-request adopters — a stamp can collide across
|
|
13
|
+
* tenants or lag a body change and would let this store serve another
|
|
14
|
+
* partition's bytes as a 200.
|
|
15
|
+
*/
|
|
16
|
+
export declare function installConditionalRequestInterceptors(client: Client): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Client } from "../generated/client/types.gen.ts";
|
|
2
|
+
import { Secret } from "../secret.ts";
|
|
3
|
+
import { type DalpFetch } from "./ssr-fetch.ts";
|
|
4
|
+
export type { DalpFetch } from "./ssr-fetch.ts";
|
|
5
|
+
export interface DalpClientContext {
|
|
6
|
+
readonly organizationId?: string;
|
|
7
|
+
readonly participant?: string;
|
|
8
|
+
readonly executor?: "eoa" | "smart-wallet";
|
|
9
|
+
readonly chainId?: number | string;
|
|
10
|
+
readonly selectedSigners?: ReadonlyArray<string>;
|
|
11
|
+
readonly idempotencyKey?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DalpSsrOptions {
|
|
14
|
+
readonly requestHeaders: HeadersInit;
|
|
15
|
+
readonly allowedOrigins?: ReadonlyArray<string | URL>;
|
|
16
|
+
}
|
|
17
|
+
export interface CreateDalpClientOptions {
|
|
18
|
+
readonly baseUrl: string | URL;
|
|
19
|
+
readonly apiKey?: string | Secret;
|
|
20
|
+
readonly context?: DalpClientContext;
|
|
21
|
+
readonly fetch?: DalpFetch;
|
|
22
|
+
readonly runtime?: "browser" | "server";
|
|
23
|
+
readonly ssr?: DalpSsrOptions;
|
|
24
|
+
}
|
|
25
|
+
/** Build per-operation headers which override an instance's default acting context. */
|
|
26
|
+
export declare function createDalpContextHeaders(context: DalpClientContext): Headers;
|
|
27
|
+
/**
|
|
28
|
+
* Create one generated client instance for one caller or SSR request.
|
|
29
|
+
*
|
|
30
|
+
* Credential ownership matrix:
|
|
31
|
+
*
|
|
32
|
+
* | Credential | Owner | Client policy |
|
|
33
|
+
* | --- | --- | --- |
|
|
34
|
+
* | Session cookie | Browser and session server | Browsers use `credentials: include`; SSR forwards only the current inbound cookie. The SDK never parses, stores, or rewrites `Set-Cookie`, so Secure, HttpOnly, SameSite, expiry, and logout stay server-owned. |
|
|
35
|
+
* | API key | Server or CLI process | Injected from this per-instance factory only; never place it in a browser bundle. |
|
|
36
|
+
* | Webhook and bundler secret | Server integration | Not accepted by this REST client; the owning integration keeps rotation sets. |
|
|
37
|
+
* | Test key | Test fixture | Use a dedicated throwaway key, never a production credential. |
|
|
38
|
+
*/
|
|
39
|
+
export declare function createDalpClient(options: CreateDalpClientOptions): Client;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DalpFetch } from "./ssr-fetch.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Request-body compression for DALP server/CLI clients.
|
|
4
|
+
*
|
|
5
|
+
* Bun 1.4 added a `compress` fetch option: it compresses a buffered body
|
|
6
|
+
* before sending and sets `Content-Encoding` on the wire. This wrapper opts
|
|
7
|
+
* eligible outgoing bodies into gzip so big JSON payloads shrink in transit;
|
|
8
|
+
* the receiving DAPI host decodes them at its boundary
|
|
9
|
+
* (`@dapi/server/request-body-decoding`), so callers need no per-route work.
|
|
10
|
+
*
|
|
11
|
+
* Eligibility mirrors what the transport can actually do:
|
|
12
|
+
*
|
|
13
|
+
* - Only body-bearing methods (`GET`/`HEAD` never).
|
|
14
|
+
* - Bodies already carrying `Content-Encoding`, or an explicit caller
|
|
15
|
+
* `compress`, pass through untouched.
|
|
16
|
+
* - With `(url, init)` the body must be one of Bun's buffered types
|
|
17
|
+
* (string, ArrayBuffer, TypedArray/DataView, Blob) and fall inside the
|
|
18
|
+
* size window — gzip framing dominates tiny payloads, and huge explicitly
|
|
19
|
+
* sized bodies stay uncompressed (the DAPI decode cap mirrors this bound).
|
|
20
|
+
* - Streams, `FormData`, and `URLSearchParams` pass through: the transport
|
|
21
|
+
* forwards streaming bodies unchanged.
|
|
22
|
+
* - A `Request` instance is measured through a bounded clone before compression.
|
|
23
|
+
*/
|
|
24
|
+
/** Bodies smaller than this stay uncompressed; gzip framing dominates tiny JSON. */
|
|
25
|
+
export declare const DALP_SDK_REQUEST_COMPRESSION_MIN_BODY_BYTES = 1024;
|
|
26
|
+
/** Explicitly-sized bodies larger than this are sent uncompressed. */
|
|
27
|
+
export declare const DALP_SDK_REQUEST_COMPRESSION_MAX_BODY_BYTES = 16777216;
|
|
28
|
+
/**
|
|
29
|
+
* Bun's `compress` fetch option. bun-types 1.4.0 still types `RequestInit`
|
|
30
|
+
* from lib.dom without it, so the field is declared here and set through one
|
|
31
|
+
* narrow cast at the transport seam.
|
|
32
|
+
*/
|
|
33
|
+
export type FetchRequestCompression = true | "gzip" | "deflate" | "br" | "zstd";
|
|
34
|
+
export interface CompressionRequestInit extends RequestInit {
|
|
35
|
+
readonly compress?: FetchRequestCompression;
|
|
36
|
+
}
|
|
37
|
+
export interface RequestBodyCompressionOptions {
|
|
38
|
+
/** Test seam overriding DALP_SDK_REQUEST_COMPRESSION_MIN_BODY_BYTES. */
|
|
39
|
+
readonly minBodyBytes?: number;
|
|
40
|
+
/** Test seam overriding DALP_SDK_REQUEST_COMPRESSION_MAX_BODY_BYTES. */
|
|
41
|
+
readonly maxBodyBytes?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Wrap a fetch seam so eligible request bodies travel gzip-compressed.
|
|
45
|
+
* Ineligible calls forward the original arguments untouched.
|
|
46
|
+
*/
|
|
47
|
+
export declare function withRequestBodyCompression(fetchImpl: DalpFetch, options?: RequestBodyCompressionOptions): DalpFetch;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Minimal fetch shape — Bun's `typeof fetch` also requires `preconnect`. */
|
|
2
|
+
export type DalpFetch = ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & {
|
|
3
|
+
readonly preconnect?: typeof fetch.preconnect;
|
|
4
|
+
};
|
|
5
|
+
export interface CreateSsrFetchOptions {
|
|
6
|
+
readonly allowedOrigins?: ReadonlyArray<string | URL>;
|
|
7
|
+
readonly baseUrl: string | URL;
|
|
8
|
+
readonly fetch: DalpFetch;
|
|
9
|
+
readonly requestHeaders: HeadersInit;
|
|
10
|
+
}
|
|
11
|
+
/** Direct destinations must be approved; unapproved redirects lose all caller credentials and context. */
|
|
12
|
+
export declare function createSsrFetch(options: CreateSsrFetchOptions): DalpFetch;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { findCurrentError } from "./find-current-error.ts";
|
|
2
|
+
export type DalpApiErrorCategory = "client" | "auth" | "permission" | "domain" | "contract" | "dependency" | "operational" | "config" | "unknown";
|
|
3
|
+
export interface DalpApiErrorOptions {
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly cause?: unknown;
|
|
6
|
+
readonly id?: string;
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly category: DalpApiErrorCategory;
|
|
9
|
+
readonly status?: number;
|
|
10
|
+
readonly retryable: boolean;
|
|
11
|
+
readonly why: string;
|
|
12
|
+
readonly fix: string;
|
|
13
|
+
readonly retryAfterSeconds?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class DalpApiError extends Error {
|
|
16
|
+
readonly id?: string;
|
|
17
|
+
readonly code: string;
|
|
18
|
+
readonly category: DalpApiErrorCategory;
|
|
19
|
+
readonly status?: number;
|
|
20
|
+
readonly retryable: boolean;
|
|
21
|
+
readonly why: string;
|
|
22
|
+
readonly fix: string;
|
|
23
|
+
readonly retryAfterSeconds?: number;
|
|
24
|
+
constructor(options: DalpApiErrorOptions);
|
|
25
|
+
static make(options: DalpApiErrorOptions): DalpApiError;
|
|
26
|
+
}
|
|
27
|
+
export declare const isDalpApiError: (error: unknown) => error is DalpApiError;
|
|
28
|
+
export declare const findDalpSdkError: typeof findCurrentError;
|
|
29
|
+
export declare const makeDalpApiError: (error: unknown) => DalpApiError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DalpSdkError } from "./sdk-error.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Walk a nested SDK error graph and return the first DalpSdkError.
|
|
4
|
+
*
|
|
5
|
+
* Follows `cause` and `reasons[].error` / `reasons[].defect`. Stops after
|
|
6
|
+
* `maxNodes` so a cyclic wrapper cannot loop forever.
|
|
7
|
+
*/
|
|
8
|
+
export declare const findCurrentError: (error: unknown, maxNodes?: number) => DalpSdkError | undefined;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface DalpSdkErrorOptions {
|
|
2
|
+
readonly code?: string;
|
|
3
|
+
readonly category: string;
|
|
4
|
+
readonly status?: number;
|
|
5
|
+
readonly retryable: boolean;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly why: string;
|
|
8
|
+
readonly fix: string;
|
|
9
|
+
readonly details?: DalpSdkErrorDetails;
|
|
10
|
+
readonly retryAfterSeconds?: number;
|
|
11
|
+
readonly cause?: unknown;
|
|
12
|
+
}
|
|
13
|
+
/** JSON-compatible value attached to a serialized SDK error. */
|
|
14
|
+
export type DalpSdkJsonValue = null | boolean | number | string | ReadonlyArray<DalpSdkJsonValue> | DalpSdkJsonObject;
|
|
15
|
+
/** JSON object attached to a serialized SDK error. */
|
|
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: string;
|
|
29
|
+
readonly category: string;
|
|
30
|
+
readonly status?: number;
|
|
31
|
+
readonly retryable: boolean;
|
|
32
|
+
readonly message: string;
|
|
33
|
+
readonly why: string;
|
|
34
|
+
readonly fix: string;
|
|
35
|
+
readonly details?: DalpSdkErrorDetails;
|
|
36
|
+
readonly retryAfterSeconds?: number;
|
|
37
|
+
}
|
|
38
|
+
/** SDK-owned configuration or auxiliary-adapter failure. API calls expose route errors directly. */
|
|
39
|
+
export declare class DalpSdkError extends Error {
|
|
40
|
+
readonly code: string;
|
|
41
|
+
readonly category: string;
|
|
42
|
+
readonly status?: number;
|
|
43
|
+
readonly retryable: boolean;
|
|
44
|
+
readonly why: string;
|
|
45
|
+
readonly fix: string;
|
|
46
|
+
readonly details?: DalpSdkErrorDetails;
|
|
47
|
+
readonly retryAfterSeconds?: number;
|
|
48
|
+
constructor(options: Readonly<DalpSdkErrorOptions>);
|
|
49
|
+
toJSON(): DalpSdkErrorJson;
|
|
50
|
+
}
|
|
51
|
+
/** Build the one SDK-owned error used for invalid client construction. */
|
|
52
|
+
export declare function createDalpSdkConfigurationError(input: Readonly<DalpSdkConfigurationErrorInput>): DalpSdkError;
|