@settlemint/dalp-sdk 3.1.15 → 3.1.16-main.33748846737
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 +154 -169
- package/dist/auth/client.d.ts +113 -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 +329 -0
- package/dist/bundler.d.ts +14 -207
- package/dist/bundler.js +99 -0
- package/dist/chunk-0m709wz4.js +4 -0
- package/dist/chunk-4wb2zpjw.js +260 -0
- package/dist/chunk-def7rqy6.js +946 -0
- package/dist/chunk-f4t1bm86.js +67 -0
- package/dist/chunk-fjnq61hj.js +11 -0
- package/dist/chunk-h12fatty.js +63 -0
- package/dist/chunk-n0b075da.js +33 -0
- package/dist/chunk-r0vsftj4.js +102 -0
- package/dist/chunk-y0d2c7kp.js +54 -0
- package/dist/client/conditional-request.d.ts +30 -0
- package/dist/client/factory.d.ts +14 -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/effect.d.ts +69 -0
- package/dist/effect.js +82 -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/api-types.d.ts +41238 -0
- package/dist/generated/response-scalars.d.ts +9 -0
- package/dist/generated/routes.d.ts +12 -0
- package/dist/index.d.ts +28 -40
- package/dist/index.js +131 -96108
- package/dist/proxy/builder.d.ts +47 -0
- package/dist/proxy/client.d.ts +32 -0
- package/dist/proxy/fetch-executor.d.ts +28 -0
- package/dist/proxy/flat-args.d.ts +51 -0
- package/dist/proxy/settlement.d.ts +67 -0
- package/dist/proxy/sse.d.ts +54 -0
- package/dist/proxy/tanstack.d.ts +27 -0
- package/dist/proxy/transport.d.ts +73 -0
- package/dist/react-query.d.ts +16 -0
- package/dist/react-query.js +13 -0
- package/dist/readonly-deep.d.ts +12 -0
- package/dist/reads-as-funding-paused.d.ts +20 -0
- package/dist/routes/index.d.ts +20 -0
- package/dist/routes/index.js +10 -0
- package/dist/routes/types.d.ts +51 -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 +20 -0
- package/dist/scalars/exchange-rates.d.ts +27 -0
- package/dist/scalars/index.d.ts +18 -0
- package/dist/scalars/index.js +86 -0
- package/dist/scalars/organization-id.d.ts +20 -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 +65 -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 +54 -81
- package/dist/wait-for-transaction.js +120 -0
- package/dist/webhook-events.d.ts +44 -27
- package/package.json +103 -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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich-scalar decoders.
|
|
3
|
+
*
|
|
4
|
+
* The route table names which fields carry a scalar, keyed by dotted path, so a
|
|
5
|
+
* caller applies these where the declaration says a scalar lives rather than
|
|
6
|
+
* guessing from a field name. They are plain functions: the SDK ships no
|
|
7
|
+
* runtime schema library, because the platform validates on the way out.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
export { decodeBigDecimal, encodeBigDecimal } from "./big-decimal.ts";
|
|
12
|
+
export type { BigDecimalValue } from "./big-decimal.ts";
|
|
13
|
+
export { decodeEthereumAddress, tryDecodeEthereumAddress } from "./ethereum-address.ts";
|
|
14
|
+
export type { EthereumAddressValue } from "./ethereum-address.ts";
|
|
15
|
+
export { decodeOrganizationId, tryDecodeOrganizationId } from "./organization-id.ts";
|
|
16
|
+
export type { OrganizationIdValue } from "./organization-id.ts";
|
|
17
|
+
export { decodeExchangeRatesListResponse, exchangeRatesListTransformer } from "./exchange-rates.ts";
|
|
18
|
+
export type { ExchangeRateRow, ExchangeRatesListResponse } from "./exchange-rates.ts";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DalpSdkError
|
|
3
|
+
} from "../chunk-y0d2c7kp.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 DalpSdkError({
|
|
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/ethereum-address.ts
|
|
23
|
+
import { getAddress, isAddress } from "viem";
|
|
24
|
+
function decodeEthereumAddress(wire) {
|
|
25
|
+
if (!isAddress(wire, { strict: false })) {
|
|
26
|
+
throw new DalpSdkError({
|
|
27
|
+
code: "sdk.scalar.EVM_ADDRESS_INVALID",
|
|
28
|
+
category: "sdk.configuration",
|
|
29
|
+
retryable: false,
|
|
30
|
+
message: `\`${wire}\` is not an EVM address.`,
|
|
31
|
+
why: "An EVM address is 42 characters starting with 0x.",
|
|
32
|
+
fix: "Pass the address exactly as the API returned it."
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return getAddress(wire);
|
|
36
|
+
}
|
|
37
|
+
function tryDecodeEthereumAddress(wire) {
|
|
38
|
+
if (typeof wire !== "string" || !isAddress(wire, { strict: false })) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
return getAddress(wire);
|
|
42
|
+
}
|
|
43
|
+
// src/scalars/organization-id.ts
|
|
44
|
+
function decodeOrganizationId(wire) {
|
|
45
|
+
if (wire.length === 0) {
|
|
46
|
+
throw new DalpSdkError({
|
|
47
|
+
code: "sdk.scalar.ORGANIZATION_ID_INVALID",
|
|
48
|
+
category: "sdk.configuration",
|
|
49
|
+
retryable: false,
|
|
50
|
+
message: "An organization id cannot be empty.",
|
|
51
|
+
why: "The organization id scopes every tenant-owned request.",
|
|
52
|
+
fix: "Pass the id the platform returned for the active organization."
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return wire;
|
|
56
|
+
}
|
|
57
|
+
function tryDecodeOrganizationId(wire) {
|
|
58
|
+
return typeof wire === "string" && wire.length > 0 ? wire : undefined;
|
|
59
|
+
}
|
|
60
|
+
// src/scalars/exchange-rates.ts
|
|
61
|
+
function decodeRow(row) {
|
|
62
|
+
const source = row !== null && typeof row === "object" ? row : { rate: null, feedAddress: null };
|
|
63
|
+
const rate = Reflect.get(source, "rate");
|
|
64
|
+
const feedAddress = Reflect.get(source, "feedAddress");
|
|
65
|
+
return {
|
|
66
|
+
...source,
|
|
67
|
+
rate: typeof rate === "string" ? decodeBigDecimal(rate) : null,
|
|
68
|
+
feedAddress: typeof feedAddress === "string" ? decodeEthereumAddress(feedAddress) : null
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function decodeExchangeRatesListResponse(payload) {
|
|
72
|
+
const source = payload !== null && typeof payload === "object" ? payload : { data: [] };
|
|
73
|
+
const rows = Reflect.get(source, "data");
|
|
74
|
+
return { ...source, data: Array.isArray(rows) ? rows.map(decodeRow) : [] };
|
|
75
|
+
}
|
|
76
|
+
var exchangeRatesListTransformer = async (data) => decodeExchangeRatesListResponse(data);
|
|
77
|
+
export {
|
|
78
|
+
decodeBigDecimal,
|
|
79
|
+
decodeEthereumAddress,
|
|
80
|
+
decodeExchangeRatesListResponse,
|
|
81
|
+
decodeOrganizationId,
|
|
82
|
+
encodeBigDecimal,
|
|
83
|
+
exchangeRatesListTransformer,
|
|
84
|
+
tryDecodeEthereumAddress,
|
|
85
|
+
tryDecodeOrganizationId
|
|
86
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branded organization id: the only entity id branded end to end across the
|
|
3
|
+
* platform. Runtime validation is minimal; the brand is the type-level
|
|
4
|
+
* contract.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export type OrganizationIdValue = string & {
|
|
9
|
+
readonly __brand: "OrganizationId";
|
|
10
|
+
};
|
|
11
|
+
/** Brand a non-empty organization id. */
|
|
12
|
+
export declare function decodeOrganizationId(wire: string): OrganizationIdValue;
|
|
13
|
+
/**
|
|
14
|
+
* Brand an organization id, or return nothing when it is not one.
|
|
15
|
+
*
|
|
16
|
+
* The mirror of {@link decodeOrganizationId} for callers that need a verdict
|
|
17
|
+
* rather than an exception, which is what the previous schema's `safeParse`
|
|
18
|
+
* gave them.
|
|
19
|
+
*/
|
|
20
|
+
export declare function tryDecodeOrganizationId(wire: unknown): OrganizationIdValue | undefined;
|
package/dist/secret.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const SECRET_REDACTION_MARKER = "[REDACTED]";
|
|
2
|
+
declare const inspectSymbol: unique symbol;
|
|
3
|
+
/** Opaque secret value which cannot leak through common serialization paths. */
|
|
4
|
+
export declare class Secret {
|
|
5
|
+
private constructor();
|
|
6
|
+
static from(value: string): Secret;
|
|
7
|
+
toString(): string;
|
|
8
|
+
toJSON(): string;
|
|
9
|
+
[inspectSymbol](): string;
|
|
10
|
+
}
|
|
11
|
+
export declare const secret: (value: string) => Secret;
|
|
12
|
+
/** Reveal a secret only at the transport header-injection boundary. */
|
|
13
|
+
export declare const unwrapSecret: (value: Secret) => string;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counter-sign a DALP webhook delivery receipt.
|
|
3
|
+
*
|
|
4
|
+
* The inbound half of webhook signing (`verifyWebhook`) proves a delivery
|
|
5
|
+
* DALP sent is authentic. This is the return half: after a consumer verifies
|
|
6
|
+
* and accepts a delivery, it counter-signs a receipt so the platform has
|
|
7
|
+
* non-repudiation proof the consumer received and acknowledged that specific
|
|
8
|
+
* delivery. Submit the result to `POST /api/v2/webhook-receipts`.
|
|
9
|
+
*
|
|
10
|
+
* The canonical signing string and HMAC mirror the server-side implementation,
|
|
11
|
+
* which a published package cannot import. A shared golden test vector pins the
|
|
12
|
+
* output of both so the two copies cannot drift.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Scheme tag prefixed to the counter-signed receipt signing string. It
|
|
18
|
+
* domain-separates receipt signatures from inbound delivery signatures and
|
|
19
|
+
* reserves room for a future scheme revision.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RECEIPT_SIGNING_SCHEME = "dalp.whr.v1";
|
|
22
|
+
/** The delivery tuple a receipt signature binds. */
|
|
23
|
+
export interface ReceiptSigningTuple {
|
|
24
|
+
/** The delivery being acknowledged. A retry allocates a fresh `deliveryId`. */
|
|
25
|
+
deliveryId: string;
|
|
26
|
+
/** The endpoint that received the delivery. */
|
|
27
|
+
endpointId: string;
|
|
28
|
+
/** The event identifier carried by the delivery (`evt_*`). */
|
|
29
|
+
evtId: string;
|
|
30
|
+
/** The hash of the delivered event body (`sha256:<hex>`). */
|
|
31
|
+
innerEventHash: string;
|
|
32
|
+
}
|
|
33
|
+
export interface SignWebhookReceiptInput extends ReceiptSigningTuple {
|
|
34
|
+
/** The endpoint signing secret (`dalp_whsk_...`); the prefix is stripped for you. */
|
|
35
|
+
secret: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the canonical string a consumer HMACs to counter-sign a receipt.
|
|
39
|
+
*
|
|
40
|
+
* Binding the signature to the full delivery tuple, not just the event body
|
|
41
|
+
* hash, is what closes the receipt-replay window: a retry allocates a fresh
|
|
42
|
+
* `deliveryId` for the same event, so a signature minted for one attempt
|
|
43
|
+
* produces a different signing string than another attempt and no longer
|
|
44
|
+
* verifies against it.
|
|
45
|
+
*
|
|
46
|
+
* Newline-joined is unambiguous because every field carries no newline:
|
|
47
|
+
* `deliveryId`/`endpointId` are UUIDs, `evtId` is the server-issued `evt_*`
|
|
48
|
+
* identifier, and `innerEventHash` is `sha256:<hex>`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildReceiptSigningString(tuple: Readonly<ReceiptSigningTuple>): string;
|
|
51
|
+
/**
|
|
52
|
+
* Counter-sign a webhook delivery receipt.
|
|
53
|
+
*
|
|
54
|
+
* Returns the lowercase hex `HMAC-SHA256(key, signingString)` to submit as the
|
|
55
|
+
* receipt's `consumerSignature`. The key is the base64-decoded prefix-stripped
|
|
56
|
+
* secret, the same derivation the Standard Webhooks library uses for inbound
|
|
57
|
+
* delivery verification (`verifyWebhook`) and that the dispatcher signs with —
|
|
58
|
+
* so the receipt and the delivery share key material.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const consumerSignature = signWebhookReceipt({
|
|
63
|
+
* deliveryId,
|
|
64
|
+
* endpointId,
|
|
65
|
+
* evtId,
|
|
66
|
+
* innerEventHash,
|
|
67
|
+
* secret, // the endpoint's dalp_whsk_... signing secret
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function signWebhookReceipt({ secret, ...tuple }: Readonly<SignWebhookReceiptInput>): string;
|
|
72
|
+
export interface VerifyWebhookReceiptInput extends SignWebhookReceiptInput {
|
|
73
|
+
readonly signature: string;
|
|
74
|
+
}
|
|
75
|
+
/** Verify a counter-signed receipt without leaking signature timing. */
|
|
76
|
+
export declare function verifyWebhookReceipt({ signature, ...input }: Readonly<VerifyWebhookReceiptInput>): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toStandardWebhookSecret
|
|
3
|
+
} from "./chunk-r0vsftj4.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(toStandardWebhookSecret(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,44 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* Opt into a bounded attempt count instead of the wall-clock window. Only
|
|
12
|
+
* for callers that genuinely want "n tries and stop" — a count is a poor
|
|
13
|
+
* budget when every failure is instant, because a single multi-second
|
|
14
|
+
* backend stall spends it all in a few hundred milliseconds.
|
|
15
|
+
*/
|
|
16
|
+
readonly maxReconnects?: number;
|
|
17
|
+
/**
|
|
18
|
+
* How long to keep reconnecting through an unbroken run of failures, in
|
|
19
|
+
* wall-clock milliseconds. The window is anchored at the first failure of a
|
|
20
|
+
* streak and restarts only after a connection stays up for
|
|
21
|
+
* `healthyConnectionMs`, so a long-lived stream that dies late still gets a
|
|
22
|
+
* full window.
|
|
23
|
+
*/
|
|
24
|
+
readonly reconnectWindowMs?: number;
|
|
25
|
+
/**
|
|
26
|
+
* How long a connection must stay up to count as recovered and clear the
|
|
27
|
+
* failure streak. Receiving events is deliberately *not* the test: a stream
|
|
28
|
+
* that replays its opening frame on every subscription would clear the
|
|
29
|
+
* streak on each attempt and reconnect forever.
|
|
30
|
+
*/
|
|
31
|
+
readonly healthyConnectionMs?: number;
|
|
32
|
+
readonly initialBackoffMs?: number;
|
|
33
|
+
readonly maxBackoffMs?: number;
|
|
34
|
+
readonly sleep?: (milliseconds: number) => Promise<void>;
|
|
35
|
+
readonly now?: () => number;
|
|
36
|
+
}
|
|
37
|
+
export type SseLifecycleFailureReason = "aborted" | "terminal-failure" | "transport-failure";
|
|
38
|
+
export declare class SseLifecycleError<T = unknown> extends Error {
|
|
39
|
+
readonly reason: SseLifecycleFailureReason;
|
|
40
|
+
readonly lastEvent?: T;
|
|
41
|
+
constructor(reason: SseLifecycleFailureReason, lastEvent?: T, options?: ErrorOptions);
|
|
42
|
+
}
|
|
43
|
+
/** Add terminal-state semantics to a generated Hey API SSE stream. */
|
|
44
|
+
export declare function consumeSseUntilTerminal<T>(options: SseLifecycleOptions<T>): Promise<T>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,110 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Generated request, response, and model types for the v2 surface.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Related: kit/sdk/src/client.ts
|
|
4
|
+
* Type-only by construction — the emitted JavaScript is empty, so a consumer
|
|
5
|
+
* that imports only types pays nothing at runtime. The dist completeness
|
|
6
|
+
* graph accepts that empty file when `dist/types.d.ts` is present.
|
|
8
7
|
*
|
|
9
8
|
* @module
|
|
10
9
|
*/
|
|
11
|
-
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* Provides auto-completed access to all v2 API namespaces:
|
|
22
|
-
* `account`, `actions`, `addons`, `admin`, `contacts`, `exchangeRates`,
|
|
23
|
-
* `externalToken`, `identityRecovery`, `monitoring`, `search`,
|
|
24
|
-
* `settings`, `system`, `token`, `transaction`, `user`.
|
|
25
|
-
*/
|
|
26
|
-
export type DalpClient = JsonifiedClient<ContractRouterClient<typeof rpcContract, DalpClientCallContext>>;
|
|
27
|
-
/**
|
|
28
|
-
* Per-call client context threaded into individual SDK operations as the second
|
|
29
|
-
* argument, e.g. `client.token.create(input, { context: { idempotencyKey } })`.
|
|
30
|
-
* Every field is optional and scoped to the single call, unlike the client-level
|
|
31
|
-
* {@link BaseDalpClientConfig.idempotencyKey} which applies to every request.
|
|
32
|
-
*/
|
|
33
|
-
export interface DalpClientCallContext {
|
|
34
|
-
/**
|
|
35
|
-
* Idempotency key sent as the `Idempotency-Key` header for this call only,
|
|
36
|
-
* overriding any client-level key. Use a fresh value per genuine retry of a
|
|
37
|
-
* failed mutation: dapi burns the key of a failed transaction, so re-sending
|
|
38
|
-
* under the same key is rejected ("previously failed. Use a new idempotency
|
|
39
|
-
* key to retry"). A stable value within one logical attempt keeps network-level
|
|
40
|
-
* fetch retries deduplicated.
|
|
41
|
-
*/
|
|
42
|
-
idempotencyKey?: string;
|
|
43
|
-
/**
|
|
44
|
-
* oRPC error codes the caller treats as expected for this call and does not
|
|
45
|
-
* want surfaced by its own error logging (e.g. an existence probe that accepts
|
|
46
|
-
* `NOT_FOUND`). A client-side hint scoped to the single call; it is not sent to
|
|
47
|
-
* the server.
|
|
48
|
-
*/
|
|
49
|
-
skipLoggingFor?: readonly string[];
|
|
50
|
-
}
|
|
51
|
-
interface BaseDalpClientConfig {
|
|
52
|
-
/** Base URL of the DALP API (e.g., `"https://dalp.example.com"`). */
|
|
53
|
-
url: string;
|
|
54
|
-
/**
|
|
55
|
-
* Organization ID for multi-tenant setups.
|
|
56
|
-
* Required when the API key is scoped to multiple organizations.
|
|
57
|
-
*/
|
|
58
|
-
organizationId?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Additional headers merged into every request.
|
|
61
|
-
* Accepts a static object or a (possibly async) function for dynamic headers.
|
|
62
|
-
* Can override defaults like `User-Agent` but cannot override security headers (`x-api-key`, `x-organization-id`).
|
|
63
|
-
*/
|
|
64
|
-
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
65
|
-
/**
|
|
66
|
-
* Validate outgoing requests against the contract before sending.
|
|
67
|
-
* Catches schema violations client-side for faster feedback.
|
|
68
|
-
* @defaultValue false
|
|
69
|
-
*/
|
|
70
|
-
requestValidation?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Validate incoming responses against the contract.
|
|
73
|
-
* Useful during development to catch API drift.
|
|
74
|
-
* @defaultValue false
|
|
75
|
-
*/
|
|
76
|
-
responseValidation?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Custom `fetch` implementation.
|
|
79
|
-
* Use this to inject logging, proxy configuration, or test doubles.
|
|
80
|
-
*/
|
|
81
|
-
fetch?: typeof globalThis.fetch;
|
|
82
|
-
/**
|
|
83
|
-
* Idempotency key sent as the `Idempotency-Key` header on every request.
|
|
84
|
-
*
|
|
85
|
-
* **Warning:** This value is sent on _every_ request made by the client.
|
|
86
|
-
* If you reuse the same client instance for multiple mutations, the server
|
|
87
|
-
* will deduplicate all but the first — subsequent mutations silently return
|
|
88
|
-
* the first response. Only set this when the client is used for a single
|
|
89
|
-
* mutation (e.g., a one-shot script). For multi-mutation workflows, set the
|
|
90
|
-
* header per-request via the `headers` callback instead.
|
|
91
|
-
*
|
|
92
|
-
* When omitted, no idempotency key header is sent.
|
|
93
|
-
*/
|
|
94
|
-
idempotencyKey?: string;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Configuration for creating an authenticated DALP API client.
|
|
98
|
-
*/
|
|
99
|
-
export interface DalpClientConfig extends BaseDalpClientConfig {
|
|
100
|
-
/** API key for authenticated routes (issued via the DALP dashboard or CLI). */
|
|
101
|
-
apiKey: string;
|
|
10
|
+
import type { AssumableParticipant, EvmAddress, TokenFeatureDividendYield as TokenFeatureDividendYieldWire, TokenFeatureExternalTransactionFee as TokenFeatureExternalTransactionFeeWire, TokenFeatureFixedTreasuryYield as TokenFeatureFixedTreasuryYieldWire, TokenFeatureHistoricalBalances as TokenFeatureHistoricalBalancesWire, TokenFeatureInterestYield as TokenFeatureInterestYieldWire, TokenFeatureMaturityRedemption as TokenFeatureMaturityRedemptionWire, TokenFeatureTransactionFee as TokenFeatureTransactionFeeWire, TokenFeatureTransactionFeeAccounting as TokenFeatureTransactionFeeAccountingWire, TokenDocumentGetUploadUrlBody, TokenTopicScheme, TokenTrustedIssuer, ThemeLogoUpload, EvmUserEventV2Item, UserEventV2Item, UserEventV2ItemCollectionResponse, UserMe, participantsMultisigDrafts_createInvite_Response, token_create_Request, system_feeds_issuerSigned_create_Request, tokenTopicSchemes_create_Request, tokenTrustedIssuers_create_Request } from "./generated/api-types.d.ts";
|
|
11
|
+
/** Participant kinds returned by the participant search surface. */
|
|
12
|
+
export type ParticipantKind = "person" | "company" | "fund" | "spv" | "department" | "joint_account" | "asset" | "organisation" | "claim_issuer" | "addon";
|
|
13
|
+
/** Address projection requested from participant search. */
|
|
14
|
+
export type ParticipantAddressPurpose = "transfer" | "identity" | "participant";
|
|
15
|
+
/** Token eligibility filter accepted by participant search. */
|
|
16
|
+
export interface EligibleForTokenFilter {
|
|
17
|
+
readonly tokenAddress: EvmAddress;
|
|
18
|
+
readonly action: "mint" | "transfer" | "burn";
|
|
19
|
+
readonly reveal?: boolean;
|
|
102
20
|
}
|
|
21
|
+
/** Current ability to act as an assumable participant. */
|
|
22
|
+
export type ActAvailability = AssumableParticipant["actAvailability"];
|
|
23
|
+
/** Stable onboarding flags returned with the current user. */
|
|
24
|
+
export type OnboardingState = UserMe["onboardingState"];
|
|
103
25
|
/**
|
|
104
|
-
*
|
|
26
|
+
* One row of the authenticated user's event feed, on whichever ledger produced it.
|
|
27
|
+
*
|
|
28
|
+
* Discriminated on `family`. Narrow before reading anything else: `blockNumber`,
|
|
29
|
+
* `transactionHash`, `gasUsed` and `gasPrice` exist only on the `evm` arm, and
|
|
30
|
+
* `ledgerOffset`, `updateId` and `nodeId` only on the `canton` one.
|
|
105
31
|
*/
|
|
106
|
-
export
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
32
|
+
export type UserEvent = UserEventV2Item;
|
|
33
|
+
/** The `evm` arm of {@link UserEvent}: one indexed contract event. */
|
|
34
|
+
export type EvmUserEvent = EvmUserEventV2Item;
|
|
35
|
+
/** One page of the authenticated user's event feed, across both chain families. */
|
|
36
|
+
export type UserEventCollectionResponse = UserEventV2ItemCollectionResponse;
|
|
37
|
+
/** One decoded name/value entry attached to a user activity event. */
|
|
38
|
+
export type UserEventValue = NonNullable<EvmUserEvent["values"]>[number];
|
|
39
|
+
/** Registry tier from which a topic scheme was inherited. */
|
|
40
|
+
export type TokenTopicSchemeInheritanceLevel = TokenTopicScheme["inheritanceLevel"];
|
|
41
|
+
/** Registry tier from which a trusted issuer was inherited. */
|
|
42
|
+
export type TokenTrustedIssuerInheritanceLevel = TokenTrustedIssuer["inheritanceLevel"];
|
|
43
|
+
/** Body accepted when a token-level topic scheme is created. */
|
|
44
|
+
export type TokenTopicSchemeCreateInput = tokenTopicSchemes_create_Request;
|
|
45
|
+
/** Body accepted when a token-level trusted issuer is created. */
|
|
46
|
+
export type TokenTrustedIssuerCreateInput = tokenTrustedIssuers_create_Request;
|
|
47
|
+
/** Successful token returned when a multisig invite is created. */
|
|
48
|
+
export type MultisigDraftCreateInviteOutput = participantsMultisigDrafts_createInvite_Response;
|
|
49
|
+
/** Body accepted when an issuer-signed scalar feed is created. */
|
|
50
|
+
export type IssuerSignedCreateInput = system_feeds_issuerSigned_create_Request;
|
|
51
|
+
/** Image slot accepted by the theme logo upload endpoints. */
|
|
52
|
+
export type ThemeLogoMode = ThemeLogoUpload["mode"];
|
|
53
|
+
/** Config carried by an attached historical-balances feature. */
|
|
54
|
+
export type TokenFeatureHistoricalBalancesConfig = NonNullable<TokenFeatureHistoricalBalancesWire>;
|
|
55
|
+
/** Config carried by an attached maturity-redemption feature. */
|
|
56
|
+
export type TokenFeatureMaturityRedemptionConfig = NonNullable<TokenFeatureMaturityRedemptionWire>;
|
|
57
|
+
/** Config carried by an attached fixed-treasury-yield feature. */
|
|
58
|
+
export type TokenFeatureFixedTreasuryYieldConfig = NonNullable<TokenFeatureFixedTreasuryYieldWire>;
|
|
59
|
+
/** Config carried by an attached dividend-yield feature. */
|
|
60
|
+
export type TokenFeatureDividendYieldConfig = NonNullable<TokenFeatureDividendYieldWire>;
|
|
61
|
+
/** Config carried by an attached interest-yield feature. */
|
|
62
|
+
export type TokenFeatureInterestYieldConfig = NonNullable<TokenFeatureInterestYieldWire>;
|
|
63
|
+
/** Config carried by an attached transaction-fee feature. */
|
|
64
|
+
export type TokenFeatureTransactionFeeConfig = NonNullable<TokenFeatureTransactionFeeWire>;
|
|
65
|
+
/** Config carried by an attached transaction-fee-accounting feature. */
|
|
66
|
+
export type TokenFeatureTransactionFeeAccountingConfig = NonNullable<TokenFeatureTransactionFeeAccountingWire>;
|
|
67
|
+
/** Config carried by an attached external-transaction-fee feature. */
|
|
68
|
+
export type TokenFeatureExternalTransactionFeeConfig = NonNullable<TokenFeatureExternalTransactionFeeWire>;
|
|
69
|
+
/** MIME type accepted by token-document upload endpoints. */
|
|
70
|
+
export type TokenDocumentMimeType = TokenDocumentGetUploadUrlBody["mimeType"];
|
|
71
|
+
/** Body accepted by the token-create endpoint. */
|
|
72
|
+
export type TokenCreateInput = token_create_Request;
|
|
73
|
+
export type * from "./generated/api-types.d.ts";
|
package/dist/url.d.ts
CHANGED
package/dist/verify-webhook.d.ts
CHANGED
|
@@ -1,34 +1,23 @@
|
|
|
1
|
-
import type { Webhook } from "./webhook-events.
|
|
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
6
|
} | {
|
|
7
|
-
ok: false;
|
|
8
|
-
code: WebhookVerificationFailure;
|
|
7
|
+
readonly ok: false;
|
|
8
|
+
readonly code: WebhookVerificationFailure;
|
|
9
9
|
};
|
|
10
|
+
export interface WebhookReplayStore {
|
|
11
|
+
readonly has: (eventId: string) => boolean | Promise<boolean>;
|
|
12
|
+
readonly add: (eventId: string) => void | Promise<void>;
|
|
13
|
+
}
|
|
10
14
|
export interface VerifyWebhookInput {
|
|
11
|
-
rawBody: string | Uint8Array;
|
|
12
|
-
headers: Headers | Record<string, string | string
|
|
13
|
-
secret: string |
|
|
15
|
+
readonly rawBody: string | Uint8Array;
|
|
16
|
+
readonly headers: Headers | Record<string, string | ReadonlyArray<string> | undefined>;
|
|
17
|
+
readonly secret: string | ReadonlyArray<string>;
|
|
18
|
+
readonly replayStore?: WebhookReplayStore;
|
|
19
|
+
readonly now?: number | Date;
|
|
20
|
+
readonly timestampToleranceSeconds?: number;
|
|
14
21
|
}
|
|
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
22
|
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
|
|
23
|
+
export declare function verifyWebhook(input: VerifyWebhookInput): Promise<WebhookVerificationResult>;
|
package/dist/version.d.ts
CHANGED