@settlemint/dalp-sdk 3.1.33 → 3.2.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +3 -157
  2. package/README.md +276 -169
  3. package/dist/auth/client.d.ts +114 -0
  4. package/dist/auth/invite-step-up.d.ts +2 -0
  5. package/dist/auth/live.d.ts +47 -0
  6. package/dist/auth/native-passkey.d.ts +8 -0
  7. package/dist/{auth-permissions.d.ts → auth/permissions.d.ts} +0 -8
  8. package/dist/auth/wallet-plugins.d.ts +196 -0
  9. package/dist/auth-surface.d.ts +2 -0
  10. package/dist/auth.d.ts +8 -115
  11. package/dist/auth.js +540 -0
  12. package/dist/chunk-6hckdbwt.js +600 -0
  13. package/dist/chunk-7mvx7xq8.js +4 -0
  14. package/dist/chunk-b03ycwb7.js +68 -0
  15. package/dist/chunk-crtb9edj.js +29 -0
  16. package/dist/chunk-g5j1xky8.js +99 -0
  17. package/dist/chunk-grdfnbwd.js +1529 -0
  18. package/dist/chunk-j43gfc9p.js +5 -0
  19. package/dist/chunk-k3ntysxx.js +57 -0
  20. package/dist/chunk-ptwkww6j.js +38 -0
  21. package/dist/chunk-qncpzave.js +185 -0
  22. package/dist/chunk-t8v94nvb.js +5 -0
  23. package/dist/chunk-xnarraj7.js +339 -0
  24. package/dist/client/conditional-request.d.ts +8 -0
  25. package/dist/client/factory.d.ts +4 -0
  26. package/dist/client/query-serializer.d.ts +1 -0
  27. package/dist/client/request-compression.d.ts +12 -0
  28. package/dist/client/ssr-fetch.d.ts +10 -0
  29. package/dist/client/step-up-challenge.d.ts +10 -0
  30. package/dist/effect.d.ts +39 -0
  31. package/dist/effect.js +110 -0
  32. package/dist/errors/api-error.d.ts +35 -0
  33. package/dist/errors/error-codes.d.ts +18 -0
  34. package/dist/errors/find-current-error.d.ts +2 -0
  35. package/dist/errors/public-error.d.ts +3 -0
  36. package/dist/errors/public-error.js +9 -0
  37. package/dist/errors/sdk-error.d.ts +52 -0
  38. package/dist/errors/sdk-error.js +8 -0
  39. package/dist/generated/api-types.d.ts +104535 -0
  40. package/dist/generated/api-types.ts +111921 -0
  41. package/dist/generated/console-routes.d.ts +12 -0
  42. package/dist/generated/error-catalog.d.ts +9 -0
  43. package/dist/generated/error-codes.d.ts +9 -0
  44. package/dist/generated/response-scalars.d.ts +9 -0
  45. package/dist/generated/response-schemas.d.ts +9 -0
  46. package/dist/generated/route-error-codes.d.ts +9 -0
  47. package/dist/generated/routes.d.ts +12 -0
  48. package/dist/index.d.ts +28 -45
  49. package/dist/index.js +159 -94522
  50. package/dist/proxy/builder.d.ts +17 -0
  51. package/dist/proxy/client-core.d.ts +36 -0
  52. package/dist/proxy/client.d.ts +5 -0
  53. package/dist/proxy/fetch-executor.d.ts +7 -0
  54. package/dist/proxy/flat-args.d.ts +24 -0
  55. package/dist/proxy/response-decode.d.ts +38 -0
  56. package/dist/proxy/sse.d.ts +11 -0
  57. package/dist/proxy/step-up-challenge.d.ts +4 -0
  58. package/dist/proxy/tanstack.d.ts +6 -0
  59. package/dist/proxy/transport.d.ts +76 -0
  60. package/dist/react-query.d.ts +2 -0
  61. package/dist/react-query.js +14 -0
  62. package/dist/routes/cli-command.d.ts +17 -0
  63. package/dist/routes/console.d.ts +14 -0
  64. package/dist/routes/console.js +27 -0
  65. package/dist/routes/index.d.ts +6 -0
  66. package/dist/routes/index.js +122 -0
  67. package/dist/routes/types.d.ts +73 -0
  68. package/dist/runtime-exports.d.ts +4 -0
  69. package/dist/runtime-exports.js +38 -0
  70. package/dist/runtime.d.ts +8 -0
  71. package/dist/scalars/big-decimal.d.ts +22 -0
  72. package/dist/scalars/big-int.d.ts +3 -0
  73. package/dist/scalars/dalp-scalars.d.ts +28 -0
  74. package/dist/scalars/ethereum-address.d.ts +3 -0
  75. package/dist/scalars/exchange-rates.d.ts +13 -0
  76. package/dist/scalars/index.d.ts +14 -0
  77. package/dist/scalars/index.js +236 -0
  78. package/dist/scalars/organization-id.d.ts +5 -0
  79. package/dist/scalars/token-decimals.d.ts +4 -0
  80. package/dist/secret.d.ts +12 -0
  81. package/dist/server-proxy.d.ts +39 -0
  82. package/dist/server-proxy.js +186 -0
  83. package/dist/sign-webhook-receipt.d.ts +16 -0
  84. package/dist/sign-webhook-receipt.js +26 -0
  85. package/dist/transport/cookie-store.d.ts +9 -0
  86. package/dist/transport/sse-lifecycle.d.ts +24 -0
  87. package/dist/types.d.ts +38 -114
  88. package/dist/url.d.ts +0 -1
  89. package/dist/verify-webhook.d.ts +18 -28
  90. package/dist/verify-webhook.js +8 -0
  91. package/dist/version.d.ts +0 -3
  92. package/dist/wait-for-transaction.d.ts +46 -86
  93. package/dist/wait-for-transaction.js +154 -0
  94. package/dist/webhook-events.d.ts +1360 -35
  95. package/package.json +176 -36
  96. package/dist/api-types.generated.d.ts +0 -14160
  97. package/dist/api-types.generated.d.ts.map +0 -1
  98. package/dist/auth-permissions.d.ts.map +0 -1
  99. package/dist/auth-wallet-plugins.d.ts +0 -86
  100. package/dist/auth-wallet-plugins.d.ts.map +0 -1
  101. package/dist/auth.d.ts.map +0 -1
  102. package/dist/bundler.d.ts +0 -217
  103. package/dist/bundler.d.ts.map +0 -1
  104. package/dist/client.d.ts +0 -19
  105. package/dist/client.d.ts.map +0 -1
  106. package/dist/contract-errors.d.ts +0 -4156
  107. package/dist/contract-errors.d.ts.map +0 -1
  108. package/dist/contract.d.ts +0 -22
  109. package/dist/contract.d.ts.map +0 -1
  110. package/dist/cookie-store.d.ts +0 -10
  111. package/dist/cookie-store.d.ts.map +0 -1
  112. package/dist/dapi-errors.d.ts +0 -656
  113. package/dist/dapi-errors.d.ts.map +0 -1
  114. package/dist/errors.d.ts +0 -639
  115. package/dist/errors.d.ts.map +0 -1
  116. package/dist/index.d.ts.map +0 -1
  117. package/dist/platform.d.ts +0 -41
  118. package/dist/platform.d.ts.map +0 -1
  119. package/dist/plugins/index.d.ts +0 -13
  120. package/dist/plugins/index.d.ts.map +0 -1
  121. package/dist/plugins/index.js +0 -8
  122. package/dist/sdk-error.d.ts +0 -74
  123. package/dist/sdk-error.d.ts.map +0 -1
  124. package/dist/serializers.d.ts +0 -41
  125. package/dist/serializers.d.ts.map +0 -1
  126. package/dist/types.d.ts.map +0 -1
  127. package/dist/url.d.ts.map +0 -1
  128. package/dist/verify-webhook.d.ts.map +0 -1
  129. package/dist/version.d.ts.map +0 -1
  130. package/dist/version.generated.d.ts +0 -8
  131. package/dist/version.generated.d.ts.map +0 -1
  132. package/dist/wait-for-transaction.d.ts.map +0 -1
  133. package/dist/webhook-events.d.ts.map +0 -1
@@ -0,0 +1,6 @@
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";
5
+ export { apiLineFor, cliCommandFor, commandPathForUrl, INDEX_COMMAND, isNonCliOperation, NON_CLI_OPERATIONS, staticUrlSegments, } from "./cli-command.ts";
6
+ export type { CliCommand, CliCommandInput, CliInputValues } from "./cli-command.ts";
@@ -0,0 +1,122 @@
1
+ import {
2
+ data2
3
+ } from "../chunk-7mvx7xq8.js";
4
+
5
+ // src/routes/cli-command.ts
6
+ var INDEX_COMMAND = "index";
7
+ var METHOD_VERB = {
8
+ GET: "get",
9
+ POST: "create",
10
+ PUT: "replace",
11
+ PATCH: "patch",
12
+ DELETE: "delete"
13
+ };
14
+ var NON_CLI_OPERATIONS = new Map([
15
+ ["token/conversionFeatureProbe", "Dapp converter form-validation probe."],
16
+ [
17
+ "platform.invitations.invitationsHasOnChainRoles",
18
+ "Dapp resend-dialog branch probe with no operator or scripting value."
19
+ ]
20
+ ]);
21
+ function isNonCliOperation(operation) {
22
+ return NON_CLI_OPERATIONS.has(operation);
23
+ }
24
+ function verbForMethod(method) {
25
+ return METHOD_VERB[method.toUpperCase()] ?? method.toLowerCase();
26
+ }
27
+ var isPathParameter = (part) => part.startsWith("{") && part.endsWith("}") || part.startsWith(":");
28
+ function staticUrlSegments(url) {
29
+ const parts = url.split("/").filter((part) => part.length > 0);
30
+ let start = 0;
31
+ if (parts[0] === "api" && parts[1] === "v2") {
32
+ start = 2;
33
+ } else if (parts[0] === "api") {
34
+ start = 1;
35
+ }
36
+ return parts.slice(start).filter((part) => !isPathParameter(part));
37
+ }
38
+ function commandPathForUrl(method, url) {
39
+ const verb = verbForMethod(method);
40
+ const segments = staticUrlSegments(url);
41
+ return segments.length === 0 ? [verb] : [verb, ...segments];
42
+ }
43
+ var PATH_SEPARATOR = "\x00";
44
+ var BARE_ARGUMENT = /^[A-Za-z0-9_.:/@=,+-]+$/u;
45
+ var parentPaths;
46
+ function commandParents() {
47
+ if (parentPaths === undefined) {
48
+ const parents = new Set;
49
+ for (const [routeId, row] of Object.entries(data2.routes)) {
50
+ if (row === undefined || isNonCliOperation(routeId)) {
51
+ continue;
52
+ }
53
+ const path = commandPathForUrl(row.method, row.path);
54
+ for (let length = 1;length < path.length; length += 1) {
55
+ parents.add(path.slice(0, length).join(PATH_SEPARATOR));
56
+ }
57
+ }
58
+ parentPaths = parents;
59
+ }
60
+ return parentPaths;
61
+ }
62
+ function quote(argument) {
63
+ return BARE_ARGUMENT.test(argument) ? argument : `'${argument.replaceAll("'", String.raw`'\''`)}'`;
64
+ }
65
+ function positionalArguments(row, params) {
66
+ const values = [];
67
+ for (const name of row.params) {
68
+ const value = params[name];
69
+ if (typeof value !== "string" && typeof value !== "number") {
70
+ return null;
71
+ }
72
+ values.push(String(value));
73
+ }
74
+ return values;
75
+ }
76
+ var PATH_PARAMETER = /\{(\w+)\}|:(\w+)/gu;
77
+ function apiLineFor(routeId, input) {
78
+ const row = Object.hasOwn(data2.routes, routeId) ? data2.routes[routeId] : undefined;
79
+ if (row === undefined) {
80
+ return null;
81
+ }
82
+ const params = input.params ?? {};
83
+ const path = row.path.replaceAll(PATH_PARAMETER, (_match, braced, colon) => {
84
+ const name = braced ?? colon ?? "";
85
+ const value = params[name];
86
+ return typeof value === "string" || typeof value === "number" ? encodeURIComponent(String(value)) : `:${name}`;
87
+ });
88
+ return `${row.method.toUpperCase()} /api/v2${path.startsWith("/") ? path : `/${path}`}`;
89
+ }
90
+ function cliCommandFor(routeId, input) {
91
+ const row = Object.hasOwn(data2.routes, routeId) ? data2.routes[routeId] : undefined;
92
+ if (row === undefined || isNonCliOperation(routeId) || row.method.toUpperCase() !== "GET") {
93
+ return null;
94
+ }
95
+ const positional = positionalArguments(row, input.params ?? {});
96
+ if (positional === null) {
97
+ return null;
98
+ }
99
+ const query = input.query ?? {};
100
+ const hasQuery = Object.keys(query).length > 0;
101
+ if (hasQuery && row.queryParams.length === 0) {
102
+ return null;
103
+ }
104
+ const path = commandPathForUrl(row.method, row.path);
105
+ const mounted = commandParents().has(path.join(PATH_SEPARATOR)) ? [...path, INDEX_COMMAND] : path;
106
+ const argv = ["dalp", ...mounted, ...positional, ...hasQuery ? ["--query", JSON.stringify(query)] : []];
107
+ return { argv, text: argv.map(quote).join(" ") };
108
+ }
109
+
110
+ // src/routes/index.ts
111
+ var routeIds = Object.keys(data2.routes).sort();
112
+ export {
113
+ INDEX_COMMAND,
114
+ NON_CLI_OPERATIONS,
115
+ apiLineFor,
116
+ cliCommandFor,
117
+ commandPathForUrl,
118
+ isNonCliOperation,
119
+ routeIds,
120
+ data2 as routeTable,
121
+ staticUrlSegments
122
+ };
@@ -0,0 +1,73 @@
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
+ readonly uniqueItems?: boolean;
64
+ }
65
+ export interface ResponseSchemaTable {
66
+ readonly version: 1;
67
+ readonly definitions: Readonly<Record<string, JsonSchemaNode>>;
68
+ readonly routes: Readonly<Record<string, Readonly<Record<string, JsonSchemaNode | null>> | undefined>>;
69
+ }
70
+ export interface ResponseScalarTable {
71
+ readonly version: 1;
72
+ readonly routes: Readonly<Record<string, Readonly<Record<string, string>> | undefined>>;
73
+ }
@@ -0,0 +1,4 @@
1
+ export declare const SDK_RUNTIME_EXPORT_RELATIVE_PATHS: readonly ["dist/index.js", "dist/types.js", "dist/react-query.js", "dist/effect.js", "dist/routes/index.js", "dist/routes/console.js", "dist/scalars/index.js", "dist/auth.js", "dist/verify-webhook.js", "dist/wait-for-transaction.js", "dist/errors/public-error.js", "dist/errors/sdk-error.js", "dist/sign-webhook-receipt.js", "dist/runtime-exports.js", "dist/index.d.ts", "dist/types.d.ts", "dist/react-query.d.ts", "dist/effect.d.ts", "dist/routes/index.d.ts", "dist/routes/console.d.ts", "dist/scalars/index.d.ts", "dist/auth.d.ts", "dist/verify-webhook.d.ts", "dist/wait-for-transaction.d.ts", "dist/errors/public-error.d.ts", "dist/errors/sdk-error.d.ts", "dist/sign-webhook-receipt.d.ts", "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";
@@ -0,0 +1,38 @@
1
+ // src/runtime-exports.ts
2
+ var SDK_RUNTIME_EXPORT_RELATIVE_PATHS = [
3
+ "dist/index.js",
4
+ "dist/types.js",
5
+ "dist/react-query.js",
6
+ "dist/effect.js",
7
+ "dist/routes/index.js",
8
+ "dist/routes/console.js",
9
+ "dist/scalars/index.js",
10
+ "dist/auth.js",
11
+ "dist/verify-webhook.js",
12
+ "dist/wait-for-transaction.js",
13
+ "dist/errors/public-error.js",
14
+ "dist/errors/sdk-error.js",
15
+ "dist/sign-webhook-receipt.js",
16
+ "dist/runtime-exports.js",
17
+ "dist/index.d.ts",
18
+ "dist/types.d.ts",
19
+ "dist/react-query.d.ts",
20
+ "dist/effect.d.ts",
21
+ "dist/routes/index.d.ts",
22
+ "dist/routes/console.d.ts",
23
+ "dist/scalars/index.d.ts",
24
+ "dist/auth.d.ts",
25
+ "dist/verify-webhook.d.ts",
26
+ "dist/wait-for-transaction.d.ts",
27
+ "dist/errors/public-error.d.ts",
28
+ "dist/errors/sdk-error.d.ts",
29
+ "dist/sign-webhook-receipt.d.ts",
30
+ "dist/runtime-exports.d.ts"
31
+ ];
32
+ var SDK_TYPE_ONLY_EXPORT_RELATIVE_PATHS = ["dist/types.js"];
33
+ var [SDK_BUILD_SENTINEL_RELATIVE_PATH] = SDK_RUNTIME_EXPORT_RELATIVE_PATHS;
34
+ export {
35
+ SDK_BUILD_SENTINEL_RELATIVE_PATH,
36
+ SDK_RUNTIME_EXPORT_RELATIVE_PATHS,
37
+ SDK_TYPE_ONLY_EXPORT_RELATIVE_PATHS
38
+ };
@@ -0,0 +1,8 @@
1
+ export type DalpRuntime = "browser" | "server" | "react-native";
2
+ export declare function detectDalpRuntime(): DalpRuntime;
3
+ export declare function runtimeCredentials(runtime: DalpRuntime): RequestCredentials;
4
+ export declare function refuseCrossOriginBrowserSession(runtime: DalpRuntime, baseUrl: string, usesApiKey: boolean): void;
5
+ export declare function isBufferingFetch(fetchImpl: unknown): boolean;
6
+ export declare function keepBufferingMarker<Wrapper extends object>(wrapped: unknown, wrapper: Wrapper): Wrapper;
7
+ export declare function globalFetch(): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
8
+ export declare function refuseBundledApiKey(runtime: DalpRuntime): void;
@@ -0,0 +1,22 @@
1
+ import * as dn from "dnum";
2
+ import type { Dnum } from "dnum";
3
+ export type BigDecimalValue = Dnum;
4
+ export declare function decodeBigDecimal(wire: string): BigDecimalValue;
5
+ export declare const encodeBigDecimal: (value: Dnum) => string;
6
+ export declare const decimalOps: {
7
+ from: typeof dn.from;
8
+ isDnum: typeof dn.isDnum;
9
+ toString: typeof dn.toString;
10
+ toNumber: typeof dn.toNumber;
11
+ add: typeof dn.add;
12
+ subtract: typeof dn.sub;
13
+ multiply: typeof dn.mul;
14
+ divide: typeof dn.div;
15
+ setDecimals: typeof dn.setDecimals;
16
+ abs: typeof dn.abs;
17
+ equal: typeof dn.eq;
18
+ greaterThan: typeof dn.greaterThan;
19
+ lessThan: typeof dn.lessThan;
20
+ compare: typeof dn.cmp;
21
+ };
22
+ export type DecimalRounding = dn.Rounding;
@@ -0,0 +1,3 @@
1
+ export type BigIntWireValue = string | number | bigint;
2
+ export declare function tryDecodeBigInt(wire: unknown): bigint | undefined;
3
+ export declare function decodeBigInt(wire: unknown, fallback?: bigint): bigint;
@@ -0,0 +1,28 @@
1
+ import type { DalpScalar } from "../generated/api-types.ts";
2
+ export type EvmAddress = DalpScalar<"EvmAddress">;
3
+ export type EthereumHash = DalpScalar<"EthereumHash">;
4
+ export type EthereumHex = DalpScalar<"EthereumHex">;
5
+ export type CantonPartyId = DalpScalar<"CantonPartyId">;
6
+ export type FiatCurrency = DalpScalar<"FiatCurrency">;
7
+ export type NetworkId = DalpScalar<"NetworkId">;
8
+ export type Timestamp = DalpScalar<"Timestamp">;
9
+ export type IntegerString = `${bigint}`;
10
+ export type DecimalString = `${number}`;
11
+ export declare function isEvmAddress(value: unknown): value is EvmAddress;
12
+ export declare function isEthereumHash(value: unknown): value is EthereumHash;
13
+ export declare function isEthereumHex(value: unknown): value is EthereumHex;
14
+ export declare function isCantonPartyId(value: unknown): value is CantonPartyId;
15
+ export declare function isFiatCurrency(value: unknown): value is FiatCurrency;
16
+ export declare function isNetworkId(value: unknown): value is NetworkId;
17
+ export declare function isTimestamp(value: unknown): value is Timestamp;
18
+ export declare function isIntegerString(value: unknown): value is IntegerString;
19
+ export declare function isDecimalString(value: unknown): value is DecimalString;
20
+ export declare const evmAddress: (value: string) => EvmAddress;
21
+ export declare const ethereumHash: (value: string) => EthereumHash;
22
+ export declare const ethereumHex: (value: string) => EthereumHex;
23
+ export declare const cantonPartyId: (value: string) => CantonPartyId;
24
+ export declare const fiatCurrency: (value: string) => FiatCurrency;
25
+ export declare const networkId: (value: string) => NetworkId;
26
+ export declare function timestamp(value: Date | string): Timestamp;
27
+ export declare function integerString(value: bigint | number | string): IntegerString;
28
+ export declare function decimalString(value: number | string): DecimalString;
@@ -0,0 +1,3 @@
1
+ import { type EvmAddress } from "./dalp-scalars.ts";
2
+ export declare function decodeEthereumAddress(wire: string): EvmAddress;
3
+ export declare function tryDecodeEthereumAddress(wire: unknown): EvmAddress | undefined;
@@ -0,0 +1,13 @@
1
+ import { type BigDecimalValue } from "./big-decimal.ts";
2
+ import type { EvmAddress } from "./dalp-scalars.ts";
3
+ export interface ExchangeRateRow {
4
+ readonly rate: BigDecimalValue | null;
5
+ readonly feedAddress: EvmAddress | 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>;
@@ -0,0 +1,14 @@
1
+ export { decodeBigInt, tryDecodeBigInt } from "./big-int.ts";
2
+ export type { BigIntWireValue } from "./big-int.ts";
3
+ export { decodeBigDecimal, decimalOps, encodeBigDecimal } from "./big-decimal.ts";
4
+ export type { DecimalRounding } from "./big-decimal.ts";
5
+ export type { BigDecimalValue } from "./big-decimal.ts";
6
+ export { decodeTokenDecimals } from "./token-decimals.ts";
7
+ export type { TokenDecimals } from "./token-decimals.ts";
8
+ export { decodeEthereumAddress, tryDecodeEthereumAddress } from "./ethereum-address.ts";
9
+ export { cantonPartyId, decimalString, ethereumHash, ethereumHex, evmAddress, fiatCurrency, integerString, isCantonPartyId, isDecimalString, isEthereumHash, isEthereumHex, isEvmAddress, isFiatCurrency, isIntegerString, isNetworkId, isTimestamp, networkId, timestamp, } from "./dalp-scalars.ts";
10
+ export type { CantonPartyId, DecimalString, EthereumHash, EthereumHex, EvmAddress, FiatCurrency, IntegerString, NetworkId, Timestamp, } from "./dalp-scalars.ts";
11
+ export { decodeOrganizationId, tryDecodeOrganizationId } from "./organization-id.ts";
12
+ export type { OrganizationIdValue } from "./organization-id.ts";
13
+ export { decodeExchangeRatesListResponse, exchangeRatesListTransformer } from "./exchange-rates.ts";
14
+ export type { ExchangeRateRow, ExchangeRatesListResponse } from "./exchange-rates.ts";
@@ -0,0 +1,236 @@
1
+ import {
2
+ DalpSdkError2
3
+ } from "../chunk-k3ntysxx.js";
4
+
5
+ // src/scalars/big-int.ts
6
+ var INTEGER_WIRE = /^[+-]?\d+$/u;
7
+ function tryDecodeBigInt(wire) {
8
+ if (typeof wire === "bigint") {
9
+ return wire;
10
+ }
11
+ if (typeof wire === "number") {
12
+ return Number.isSafeInteger(wire) ? BigInt(wire) : undefined;
13
+ }
14
+ return typeof wire === "string" && INTEGER_WIRE.test(wire) ? BigInt(wire) : undefined;
15
+ }
16
+ function decodeBigInt(wire, fallback) {
17
+ const value = tryDecodeBigInt(wire);
18
+ if (value !== undefined) {
19
+ return value;
20
+ }
21
+ if (fallback !== undefined) {
22
+ return fallback;
23
+ }
24
+ throw new TypeError("The value is not a safe integer or decimal integer string.");
25
+ }
26
+ // src/scalars/big-decimal.ts
27
+ import * as dn from "dnum";
28
+ var DECIMAL_WIRE = /^-?\d+(?:\.\d+)?$/u;
29
+ function decodeBigDecimal(wire) {
30
+ if (!DECIMAL_WIRE.test(wire)) {
31
+ throw new DalpSdkError2({
32
+ code: "sdk.scalar.BIG_DECIMAL_INVALID",
33
+ category: "sdk.configuration",
34
+ retryable: false,
35
+ message: `\`${wire}\` is not a plain decimal string.`,
36
+ why: "A BigDecimal field carries an unscaled decimal, with no exponent and no separators.",
37
+ fix: "Pass the value exactly as the API returned it."
38
+ });
39
+ }
40
+ return dn.from(wire);
41
+ }
42
+ var encodeBigDecimal = (value) => dn.toString(value);
43
+ var decimalOps = {
44
+ from: dn.from,
45
+ isDnum: dn.isDnum,
46
+ toString: dn.toString,
47
+ toNumber: dn.toNumber,
48
+ add: dn.add,
49
+ subtract: dn.subtract,
50
+ multiply: dn.multiply,
51
+ divide: dn.divide,
52
+ setDecimals: dn.setDecimals,
53
+ abs: dn.abs,
54
+ equal: dn.equal,
55
+ greaterThan: dn.greaterThan,
56
+ lessThan: dn.lessThan,
57
+ compare: dn.compare
58
+ };
59
+ // src/scalars/token-decimals.ts
60
+ var DIGITS_PATTERN = /^\d+$/u;
61
+ function decodeTokenDecimals(wire) {
62
+ const value = typeof wire === "string" && DIGITS_PATTERN.test(wire) ? Number(wire) : wire;
63
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 18) {
64
+ throw new DalpSdkError2({
65
+ code: "sdk.scalar.TOKEN_DECIMALS_INVALID",
66
+ category: "sdk.configuration",
67
+ retryable: false,
68
+ message: "Token decimals are missing or outside the range 0–18.",
69
+ why: "An ERC-20 token scale is a whole number from 0 through 18.",
70
+ fix: "Pass the decimals field exactly as the API returned it."
71
+ });
72
+ }
73
+ return value;
74
+ }
75
+ // src/scalars/ethereum-address.ts
76
+ import { getAddress, isAddress as isAddress2 } from "viem/utils";
77
+
78
+ // src/scalars/dalp-scalars.ts
79
+ import { isAddress, isHash, isHex } from "viem/utils";
80
+ var FIAT_CURRENCY = /^[A-Z]{3}$/u;
81
+ var EPOCH_DIGITS = /^\d{1,16}$/u;
82
+ var INTEGER_TEXT = /^-?\d+$/u;
83
+ var DECIMAL_TEXT = /^[+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?$/u;
84
+ function isEvmAddress(value) {
85
+ return typeof value === "string" && isAddress(value);
86
+ }
87
+ function isEthereumHash(value) {
88
+ return typeof value === "string" && isHash(value);
89
+ }
90
+ function isEthereumHex(value) {
91
+ return typeof value === "string" && isHex(value, { strict: true });
92
+ }
93
+ function isCantonPartyId(value) {
94
+ return typeof value === "string" && value.length > 0;
95
+ }
96
+ function isFiatCurrency(value) {
97
+ return typeof value === "string" && FIAT_CURRENCY.test(value);
98
+ }
99
+ function isNetworkId(value) {
100
+ return typeof value === "string" && value.length > 0;
101
+ }
102
+ function isTimestamp(value) {
103
+ return typeof value === "string" && (EPOCH_DIGITS.test(value) || !Number.isNaN(Date.parse(value)));
104
+ }
105
+ function isIntegerString(value) {
106
+ return typeof value === "string" && INTEGER_TEXT.test(value);
107
+ }
108
+ function isDecimalString(value) {
109
+ return typeof value === "string" && DECIMAL_TEXT.test(value);
110
+ }
111
+ function refuse(code, value, identity, why) {
112
+ return new DalpSdkError2({
113
+ code,
114
+ category: "sdk.configuration",
115
+ retryable: false,
116
+ message: `\`${String(value)}\` is not a ${identity}.`,
117
+ why,
118
+ fix: `Pass a ${identity} the API returned, or check the value before you build the request.`
119
+ });
120
+ }
121
+ function scalar(guard, code, identity, why) {
122
+ return (value) => {
123
+ if (guard(value)) {
124
+ return value;
125
+ }
126
+ throw refuse(code, value, identity, why);
127
+ };
128
+ }
129
+ var evmAddress = scalar(isEvmAddress, "sdk.scalar.EVM_ADDRESS_INVALID", "EVM address", "An EVM address is 0x followed by 40 hex digits, with a valid checksum when it mixes upper and lower case.");
130
+ var ethereumHash = scalar(isEthereumHash, "sdk.scalar.VALUE_INVALID", "transaction or block hash", "A hash is 0x followed by 64 hex digits.");
131
+ var ethereumHex = scalar(isEthereumHex, "sdk.scalar.VALUE_INVALID", "hex string", "A hex string is 0x followed by hex digits.");
132
+ var cantonPartyId = scalar(isCantonPartyId, "sdk.scalar.VALUE_INVALID", "Canton party id", "A Canton party id is a non-empty string.");
133
+ var fiatCurrency = scalar(isFiatCurrency, "sdk.scalar.VALUE_INVALID", "currency code", "A currency code is three upper-case letters (ISO 4217).");
134
+ var networkId = scalar(isNetworkId, "sdk.scalar.VALUE_INVALID", "network id", "A network id is a non-empty string.");
135
+ var timestampText = scalar(isTimestamp, "sdk.scalar.VALUE_INVALID", "timestamp", "A timestamp is epoch milliseconds as digits, or a date and time such as an ISO 8601 string.");
136
+ function timestamp(value) {
137
+ if (typeof value !== "string" && Number.isNaN(value.getTime())) {
138
+ throw refuse("sdk.scalar.VALUE_INVALID", value, "timestamp", "A Date must hold a valid point in time.");
139
+ }
140
+ return timestampText(typeof value === "string" ? value : value.toISOString());
141
+ }
142
+ var integerText = scalar(isIntegerString, "sdk.scalar.VALUE_INVALID", "whole number", "A whole number is written as digits, with an optional leading minus sign.");
143
+ function integerString(value) {
144
+ if (typeof value === "bigint") {
145
+ return `${value}`;
146
+ }
147
+ if (typeof value === "number" && !Number.isSafeInteger(value)) {
148
+ throw refuse("sdk.scalar.VALUE_INVALID", value, "whole number", "A number must be a safe integer.");
149
+ }
150
+ return integerText(String(value));
151
+ }
152
+ var decimalText = scalar(isDecimalString, "sdk.scalar.VALUE_INVALID", "decimal number", "A decimal number is written as digits with an optional fraction and exponent.");
153
+ function decimalString(value) {
154
+ if (typeof value === "number" && !Number.isFinite(value)) {
155
+ throw refuse("sdk.scalar.VALUE_INVALID", value, "decimal number", "A number must be finite.");
156
+ }
157
+ return decimalText(String(value));
158
+ }
159
+
160
+ // src/scalars/ethereum-address.ts
161
+ function decodeEthereumAddress(wire) {
162
+ return evmAddress(isAddress2(wire, { strict: false }) ? getAddress(wire) : wire);
163
+ }
164
+ function tryDecodeEthereumAddress(wire) {
165
+ if (typeof wire !== "string" || !isAddress2(wire, { strict: false })) {
166
+ return;
167
+ }
168
+ const checksummed = getAddress(wire);
169
+ return isEvmAddress(checksummed) ? checksummed : undefined;
170
+ }
171
+ // src/scalars/organization-id.ts
172
+ function decodeOrganizationId(wire) {
173
+ if (wire.length === 0) {
174
+ throw new DalpSdkError2({
175
+ code: "sdk.scalar.ORGANIZATION_ID_INVALID",
176
+ category: "sdk.configuration",
177
+ retryable: false,
178
+ message: "An organization id cannot be empty.",
179
+ why: "The organization id scopes every tenant-owned request.",
180
+ fix: "Pass the id the platform returned for the active organization."
181
+ });
182
+ }
183
+ return wire;
184
+ }
185
+ function tryDecodeOrganizationId(wire) {
186
+ return typeof wire === "string" && wire.length > 0 ? wire : undefined;
187
+ }
188
+ // src/scalars/exchange-rates.ts
189
+ function decodeRow(row) {
190
+ const source = row !== null && typeof row === "object" ? row : { rate: null, feedAddress: null };
191
+ const rate = Reflect.get(source, "rate");
192
+ const feedAddress = Reflect.get(source, "feedAddress");
193
+ return {
194
+ ...source,
195
+ rate: typeof rate === "string" ? decodeBigDecimal(rate) : null,
196
+ feedAddress: typeof feedAddress === "string" ? decodeEthereumAddress(feedAddress) : null
197
+ };
198
+ }
199
+ function decodeExchangeRatesListResponse(payload) {
200
+ const source = payload !== null && typeof payload === "object" ? payload : { data: [] };
201
+ const rows = Reflect.get(source, "data");
202
+ return { ...source, data: Array.isArray(rows) ? rows.map(decodeRow) : [] };
203
+ }
204
+ var exchangeRatesListTransformer = async (data) => decodeExchangeRatesListResponse(data);
205
+ export {
206
+ cantonPartyId,
207
+ decimalOps,
208
+ decimalString,
209
+ decodeBigDecimal,
210
+ decodeBigInt,
211
+ decodeEthereumAddress,
212
+ decodeExchangeRatesListResponse,
213
+ decodeOrganizationId,
214
+ decodeTokenDecimals,
215
+ encodeBigDecimal,
216
+ ethereumHash,
217
+ ethereumHex,
218
+ evmAddress,
219
+ exchangeRatesListTransformer,
220
+ fiatCurrency,
221
+ integerString,
222
+ isCantonPartyId,
223
+ isDecimalString,
224
+ isEthereumHash,
225
+ isEthereumHex,
226
+ isEvmAddress,
227
+ isFiatCurrency,
228
+ isIntegerString,
229
+ isNetworkId,
230
+ isTimestamp,
231
+ networkId,
232
+ timestamp,
233
+ tryDecodeBigInt,
234
+ tryDecodeEthereumAddress,
235
+ tryDecodeOrganizationId
236
+ };
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,4 @@
1
+ export type TokenDecimals = number & {
2
+ readonly __brand: "TokenDecimals";
3
+ };
4
+ export declare function decodeTokenDecimals(wire: string | number | undefined): TokenDecimals;
@@ -0,0 +1,12 @@
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 {};
@@ -0,0 +1,39 @@
1
+ /** Edge proxy profile used to recover one verified client address. */
2
+ export type DalpTrustedProxyProfile = "none" | "envoy" | "nginx" | "openshift";
3
+ /** Fetch implementation used by the proxy; override this in tests or runtimes with a custom fetch. */
4
+ export type DalpProxyFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
5
+ /** Structured details reported when the upstream cannot serve a proxied request. */
6
+ export interface DalpProxyUpstreamFailure {
7
+ readonly method: string;
8
+ readonly path: string;
9
+ readonly upstream: string;
10
+ readonly errorName: string;
11
+ readonly errorMessage: string;
12
+ readonly errorCode: string | undefined;
13
+ }
14
+ /** Configuration for a same-origin DALP server proxy. */
15
+ export interface CreateDalpProxyOptions {
16
+ readonly upstream: string | URL;
17
+ /** Public app origin stamped when the incoming request has no Origin header. */
18
+ readonly origin?: string | URL;
19
+ readonly trustedProxyProfile?: DalpTrustedProxyProfile;
20
+ /**
21
+ * `identity` (the default) asks the upstream for an uncompressed body. `forward` passes the browser's
22
+ * `Accept-Encoding` on and returns the compressed bytes untouched; use it only on a runtime whose fetch
23
+ * honours `decompress: false`, such as Bun, or the browser receives a decoded body labelled as compressed.
24
+ */
25
+ readonly acceptEncoding?: "identity" | "forward";
26
+ readonly fetch?: DalpProxyFetch;
27
+ readonly onUpstreamFailure?: (failure: DalpProxyUpstreamFailure) => void;
28
+ readonly upstreamFailureMessage?: (path: string) => string;
29
+ }
30
+ /** Standard Fetch handler returned by {@link createDalpProxy}. */
31
+ export type DalpProxyHandler = (request: Request) => Promise<Response>;
32
+ /**
33
+ * Create a same-origin proxy for DALP API and asset routes.
34
+ *
35
+ * The handler forwards cookies and supported request bodies, sanitizes proxy
36
+ * headers, preserves cookies and framed event streams, and returns a 502 when
37
+ * the configured upstream is unavailable.
38
+ */
39
+ export declare function createDalpProxy(options: CreateDalpProxyOptions): DalpProxyHandler;