@klappay/types 3.0.2 → 3.1.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.
- package/README.md +22 -2
- package/dist/chunk-KZ3646WX.mjs +109 -0
- package/dist/chunk-KZ3646WX.mjs.map +1 -0
- package/dist/constants-DQGVNS9O.d.mts +41 -0
- package/dist/constants-DQGVNS9O.d.ts +41 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +143 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +23 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index.d.mts +6 -39
- package/dist/index.d.ts +6 -39
- package/dist/index.js +32 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export { A as ALT_TOKEN_ADDRESSES, a as ALT_TOKEN_DECIMALS, b as AltToken, c as AltTokenSchema, C as CHAIN_IDS, E as EVM_NETWORKS, d as Environment, e as EnvironmentSchema, f as EvmNetwork, N as NETWORK_EXPLORERS, g as NETWORK_LABELS, h as Network, i as NetworkSchema, O as OPERATIONAL_NETWORKS, j as OperationalNetwork, S as SwapAlternative, k as SwapAlternativeSchema, T as TOKEN_ADDRESSES, l as TOKEN_DECIMALS, m as Token, n as TokenSchema, o as listSwapAlternatives } from './constants-DQGVNS9O.js';
|
|
2
3
|
|
|
3
4
|
declare const ErrorPayloadSchema: z.ZodObject<{
|
|
4
5
|
error: z.ZodObject<{
|
|
@@ -29,24 +30,12 @@ declare const ErrorPayloadSchema: z.ZodObject<{
|
|
|
29
30
|
}>;
|
|
30
31
|
type ErrorPayload = z.infer<typeof ErrorPayloadSchema>;
|
|
31
32
|
|
|
32
|
-
declare const EnvironmentSchema: z.ZodEnum<["live", "test"]>;
|
|
33
|
-
type Environment = z.infer<typeof EnvironmentSchema>;
|
|
34
|
-
|
|
35
33
|
declare const ApiKeyScopeSchema: z.ZodEnum<["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger", "charges:split_write", "recipients:read", "recipients:write", "recipients:manage_payout"]>;
|
|
36
34
|
type ApiKeyScope = z.infer<typeof ApiKeyScopeSchema>;
|
|
37
35
|
declare const API_KEY_SCOPES: ["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger", "charges:split_write", "recipients:read", "recipients:write", "recipients:manage_payout"];
|
|
38
36
|
declare const CONFLICTING_SCOPE_PAIRS: ReadonlyArray<readonly [ApiKeyScope, ApiKeyScope]>;
|
|
39
37
|
declare function findConflictingScopes(scopes: readonly ApiKeyScope[]): readonly [ApiKeyScope, ApiKeyScope] | null;
|
|
40
38
|
|
|
41
|
-
declare const NetworkSchema: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
|
|
42
|
-
type Network = z.infer<typeof NetworkSchema>;
|
|
43
|
-
declare const NETWORK_LABELS: Record<Network, string>;
|
|
44
|
-
declare const NETWORK_EXPLORERS: Record<Network, string>;
|
|
45
|
-
declare const EVM_NETWORKS: readonly ["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"];
|
|
46
|
-
type EvmNetwork = (typeof EVM_NETWORKS)[number];
|
|
47
|
-
declare const OPERATIONAL_NETWORKS: readonly ["base", "arbitrum", "optimism", "polygon", "ethereum", "avalanche", "bnb"];
|
|
48
|
-
type OperationalNetwork = (typeof OPERATIONAL_NETWORKS)[number];
|
|
49
|
-
|
|
50
39
|
declare const PAGINATION_LIMIT_MIN = 1;
|
|
51
40
|
declare const PAGINATION_LIMIT_MAX = 100;
|
|
52
41
|
declare const PAGINATION_LIMIT_DEFAULT = 20;
|
|
@@ -76,28 +65,6 @@ declare function paginatedSchema<T extends z.ZodTypeAny>(itemSchema: T): z.ZodOb
|
|
|
76
65
|
hasMore: boolean;
|
|
77
66
|
}>;
|
|
78
67
|
|
|
79
|
-
declare const TokenSchema: z.ZodEnum<["USDC", "USDT"]>;
|
|
80
|
-
type Token = z.infer<typeof TokenSchema>;
|
|
81
|
-
declare const TOKEN_DECIMALS = 6;
|
|
82
|
-
declare const TOKEN_ADDRESSES: Record<Token, Partial<Record<Network, Partial<Record<Environment, `0x${string}`>>>>>;
|
|
83
|
-
|
|
84
|
-
declare const AltTokenSchema: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
|
|
85
|
-
type AltToken = z.infer<typeof AltTokenSchema>;
|
|
86
|
-
declare const ALT_TOKEN_DECIMALS: Record<AltToken, number>;
|
|
87
|
-
declare const ALT_TOKEN_ADDRESSES: Record<Network, Partial<Record<AltToken, 'native' | `0x${string}`>>>;
|
|
88
|
-
declare const SwapAlternativeSchema: z.ZodObject<{
|
|
89
|
-
token: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
|
|
90
|
-
network: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
|
|
91
|
-
}, "strip", z.ZodTypeAny, {
|
|
92
|
-
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
93
|
-
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
94
|
-
}, {
|
|
95
|
-
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
96
|
-
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
97
|
-
}>;
|
|
98
|
-
type SwapAlternative = z.infer<typeof SwapAlternativeSchema>;
|
|
99
|
-
declare function listSwapAlternatives(networks: readonly Network[]): SwapAlternative[];
|
|
100
|
-
|
|
101
68
|
declare const ChargeStatusSchema: z.ZodEnum<["pending", "partially_paid", "confirmed", "expired", "underpaid"]>;
|
|
102
69
|
type ChargeStatus = z.infer<typeof ChargeStatusSchema>;
|
|
103
70
|
declare const SettlementStatusSchema: z.ZodEnum<["pending", "completed", "failed"]>;
|
|
@@ -2618,13 +2585,13 @@ declare const SwapQuoteSchema: z.ZodObject<{
|
|
|
2618
2585
|
data: string;
|
|
2619
2586
|
to: string;
|
|
2620
2587
|
}>;
|
|
2621
|
-
permit2: z.ZodOptional<z.ZodObject<{
|
|
2588
|
+
permit2: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
2622
2589
|
eip712: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2623
2590
|
}, "strip", z.ZodTypeAny, {
|
|
2624
2591
|
eip712: Record<string, unknown>;
|
|
2625
2592
|
}, {
|
|
2626
2593
|
eip712: Record<string, unknown>;
|
|
2627
|
-
}
|
|
2594
|
+
}>>>;
|
|
2628
2595
|
}, "strip", z.ZodTypeAny, {
|
|
2629
2596
|
expiresAt: string;
|
|
2630
2597
|
inputToken: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
@@ -2644,7 +2611,7 @@ declare const SwapQuoteSchema: z.ZodObject<{
|
|
|
2644
2611
|
};
|
|
2645
2612
|
permit2?: {
|
|
2646
2613
|
eip712: Record<string, unknown>;
|
|
2647
|
-
} | undefined;
|
|
2614
|
+
} | null | undefined;
|
|
2648
2615
|
}, {
|
|
2649
2616
|
expiresAt: string;
|
|
2650
2617
|
inputToken: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
@@ -2664,8 +2631,8 @@ declare const SwapQuoteSchema: z.ZodObject<{
|
|
|
2664
2631
|
};
|
|
2665
2632
|
permit2?: {
|
|
2666
2633
|
eip712: Record<string, unknown>;
|
|
2667
|
-
} | undefined;
|
|
2634
|
+
} | null | undefined;
|
|
2668
2635
|
}>;
|
|
2669
2636
|
type SwapQuote = z.infer<typeof SwapQuoteSchema>;
|
|
2670
2637
|
|
|
2671
|
-
export {
|
|
2638
|
+
export { API_KEY_SCOPES, type AcceptedPayment, AcceptedPaymentSchema, type ApiKeyScope, ApiKeyScopeSchema, CHARGE_ACCEPTED_PAYMENTS_MAX, CHARGE_AMOUNT_MAX, CHARGE_EXPIRES_IN_MAX_SECONDS, CHARGE_EXPIRES_IN_MIN_SECONDS, CHARGE_SPLIT_RECIPIENTS_MAX, CHECKOUT_PRODUCTS_MAX, CONFLICTING_SCOPE_PAIRS, type Capabilities, CapabilitiesSchema, type Charge, ChargeSchema, type ChargeStatus, ChargeStatusSchema, ChargeWebhookEventTypeSchema, type ChargesDateField, ChargesDateFieldSchema, type ChargesMetricField, ChargesMetricFieldSchema, type ChargesQueryField, ChargesQueryFieldSchema, type CheckoutProduct, CheckoutProductSchema, type CreateChargeInput, type CreateChargeRequest, CreateChargeSchema, type CreateRecipientInput, type CreateRecipientRequest, CreateRecipientSchema, type CreateSwapQuoteInput, CreateSwapQuoteSchema, type CreateWebhookInput, type CreateWebhookRequest, CreateWebhookSchema, type DistributionsDateField, DistributionsDateFieldSchema, type DistributionsMetricField, DistributionsMetricFieldSchema, type DistributionsQueryField, DistributionsQueryFieldSchema, EVENT_CATEGORY_MAP, type ErrorPayload, ErrorPayloadSchema, type GetChargeQrCodeQuery, type GetChargeQrCodeQueryRequest, GetChargeQrCodeQuerySchema, type Health, HealthSchema, type KlappayCheckoutMetadata, KlappayCheckoutMetadataSchema, type ListChargesInput, type ListChargesRequest, ListChargesSchema, type ListWebhookDeliveriesInput, type ListWebhookDeliveriesRequest, ListWebhookDeliveriesSchema, type ListenPendingDistributionsQuery, ListenPendingDistributionsQuerySchema, MAX_METRICS_QUERY_DATE_RANGE_DAYS, METRICS_QUERY_DEFAULT_ROW_LIMIT, METRICS_QUERY_MAX_FILTERS, METRICS_QUERY_MAX_GROUP_BY, METRICS_QUERY_MAX_METRICS, METRICS_QUERY_MAX_ROW_LIMIT, MetadataWithKlappaySchema, type MetricsAggregation, MetricsAggregationSchema, type MetricsDateGranularity, MetricsDateGranularitySchema, type MetricsFilterOperator, MetricsFilterOperatorSchema, type MetricsQuery, type MetricsQueryRequest, type MetricsQueryResult, type MetricsQueryResultRow, MetricsQueryResultRowSchema, MetricsQueryResultSchema, MetricsQuerySchema, type MetricsResource, MetricsResourceSchema, PAGINATION_LIMIT_DEFAULT, PAGINATION_LIMIT_MAX, PAGINATION_LIMIT_MIN, type PaginatedCharges, PaginatedChargesSchema, type PaginatedPendingDistributions, PaginatedPendingDistributionsSchema, type PaginatedWebhookDeliveries, PaginatedWebhookDeliveriesSchema, type PaginationQuery, type PaginationQueryRequest, PaginationQuerySchema, type PendingDistribution, type PendingDistributionEvent, PendingDistributionEventSchema, PendingDistributionRecipientSchema, PendingDistributionSchema, type Recipient, RecipientSchema, type SandboxTriggerInput, SandboxTriggerSchema, type SetRecipientPayoutInput, SetRecipientPayoutSchema, type SettlementStatus, SettlementStatusSchema, type SplitDistributionStatus, SplitDistributionStatusSchema, type SplitRecipient, type SplitRecipientInput, SplitRecipientInputSchema, SplitRecipientSchema, type SwapQuote, SwapQuoteSchema, type TimelineEvent, TimelineEventSchema, type TimelineEventType, TimelineEventTypeSchema, type TransactionSource, TransactionSourceSchema, type TransactionsDateField, TransactionsDateFieldSchema, type TransactionsMetricField, TransactionsMetricFieldSchema, type TransactionsQueryField, TransactionsQueryFieldSchema, type TriggerableChargeEvent, TriggerableChargeEventSchema, type TypedWebhookPayload, WEBHOOK_EVENTS_WILDCARD, WEBHOOK_EVENT_CATEGORIES, type Webhook, type WebhookCategory, WebhookCategorySchema, type WebhookDelivery, WebhookDeliveryEventTypeSchema, WebhookDeliverySchema, type WebhookDeliveryStatus, WebhookDeliveryStatusSchema, type WebhookEventDataMap, type WebhookEventType, WebhookEventTypeSchema, type WebhookHealthEventData, type WebhookListItem, WebhookListItemSchema, type WebhookPayload, WebhookPayloadSchema, WebhookSchema, findConflictingScopes, paginatedSchema };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
AcceptedPaymentSchema: () => AcceptedPaymentSchema,
|
|
27
27
|
AltTokenSchema: () => AltTokenSchema,
|
|
28
28
|
ApiKeyScopeSchema: () => ApiKeyScopeSchema,
|
|
29
|
+
CHAIN_IDS: () => CHAIN_IDS,
|
|
29
30
|
CHARGE_ACCEPTED_PAYMENTS_MAX: () => CHARGE_ACCEPTED_PAYMENTS_MAX,
|
|
30
31
|
CHARGE_AMOUNT_MAX: () => CHARGE_AMOUNT_MAX,
|
|
31
32
|
CHARGE_EXPIRES_IN_MAX_SECONDS: () => CHARGE_EXPIRES_IN_MAX_SECONDS,
|
|
@@ -176,7 +177,8 @@ function findConflictingScopes(scopes) {
|
|
|
176
177
|
|
|
177
178
|
// src/networks.ts
|
|
178
179
|
var import_zod4 = require("zod");
|
|
179
|
-
|
|
180
|
+
|
|
181
|
+
// src/networks.constants.ts
|
|
180
182
|
var NETWORK_LABELS = {
|
|
181
183
|
base: "Base",
|
|
182
184
|
optimism: "Optimism",
|
|
@@ -213,6 +215,18 @@ var OPERATIONAL_NETWORKS = [
|
|
|
213
215
|
"avalanche",
|
|
214
216
|
"bnb"
|
|
215
217
|
];
|
|
218
|
+
var CHAIN_IDS = {
|
|
219
|
+
base: { live: 8453, test: 84532 },
|
|
220
|
+
optimism: { live: 10, test: 11155420 },
|
|
221
|
+
ethereum: { live: 1, test: 11155111 },
|
|
222
|
+
polygon: { live: 137 },
|
|
223
|
+
arbitrum: { live: 42161 },
|
|
224
|
+
avalanche: { live: 43114 },
|
|
225
|
+
bnb: { live: 56 }
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// src/networks.ts
|
|
229
|
+
var NetworkSchema = import_zod4.z.enum(["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]).describe("The blockchain a charge/payment is on.");
|
|
216
230
|
|
|
217
231
|
// src/pagination.ts
|
|
218
232
|
var import_zod5 = require("zod");
|
|
@@ -237,9 +251,8 @@ function paginatedSchema(itemSchema) {
|
|
|
237
251
|
|
|
238
252
|
// src/tokens.ts
|
|
239
253
|
var import_zod6 = require("zod");
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
);
|
|
254
|
+
|
|
255
|
+
// src/tokens.constants.ts
|
|
243
256
|
var TOKEN_DECIMALS = 6;
|
|
244
257
|
var TOKEN_ADDRESSES = {
|
|
245
258
|
USDC: {
|
|
@@ -271,11 +284,15 @@ var TOKEN_ADDRESSES = {
|
|
|
271
284
|
}
|
|
272
285
|
};
|
|
273
286
|
|
|
287
|
+
// src/tokens.ts
|
|
288
|
+
var TokenSchema = import_zod6.z.enum(["USDC", "USDT"]).describe(
|
|
289
|
+
`Which stablecoin the payer will send. Support depends on both \`network\` and \`environment\` \u2014 not every token/network/environment combination is deployed; today, both \`USDC\` and \`USDT\` are deployed on every operational network's \`live\` side except BNB Chain (\`${OPERATIONAL_NETWORKS.join(", ")}\`), but \`test\` coverage varies per network \u2014 Base, Optimism, and Ethereum each have a \`test\` environment (\`USDC\` only; none has an official Sepolia USDT), Arbitrum, Polygon, Avalanche, and BNB Chain have none yet (0xSplits hasn't deployed on Arbitrum Sepolia and has no Polygon, Avalanche Fuji, or BNB testnet support at all). An unconfigured combination is rejected with \`422 token_not_supported\`, not silently accepted. **BNB Chain's \`USDC\` address is Binance-Peg USDC, not an official Circle deployment** \u2014 Circle does not issue native USDC on BNB Chain at all; this is a Binance-custodied, 1:1-pegged BEP-20 token, a materially different trust model than every other \`TOKEN_ADDRESSES\` entry (all verified directly against their real issuer). Accepted at the payer's own risk \u2014 Klappay does not verify or guarantee Binance's collateral backing it. \`USDT\` on BNB Chain is Tether's own official issuance, same trust model as everywhere else. More tokens/networks are expected to be added over time \u2014 check \`TOKEN_ADDRESSES\` in \`@klappay/types\` (or a future \`GET /v1/networks\` capabilities endpoint) for the exact current matrix rather than assuming full coverage.`
|
|
290
|
+
);
|
|
291
|
+
|
|
274
292
|
// src/alt-tokens.ts
|
|
275
293
|
var import_zod7 = require("zod");
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
);
|
|
294
|
+
|
|
295
|
+
// src/alt-tokens.constants.ts
|
|
279
296
|
var ALT_TOKEN_DECIMALS = {
|
|
280
297
|
ETH: 18,
|
|
281
298
|
BNB: 18,
|
|
@@ -292,6 +309,11 @@ var ALT_TOKEN_ADDRESSES = {
|
|
|
292
309
|
avalanche: { AVAX: "native" },
|
|
293
310
|
bnb: { BNB: "native" }
|
|
294
311
|
};
|
|
312
|
+
|
|
313
|
+
// src/alt-tokens.ts
|
|
314
|
+
var AltTokenSchema = import_zod7.z.enum(["ETH", "BNB", "MATIC", "AVAX", "BTC"]).describe(
|
|
315
|
+
"A non-stablecoin cryptocurrency Klappay trusts as swap input for a charge, via the 0x Swap API \u2014 swapped to one of the charge's `acceptedPayments` tokens before it ever reaches the merchant, so the merchant always receives USDC/USDT regardless of what the payer sent. Only a network's own native currency, plus `BTC` (wrapped) on the networks with deep, reputably-custodied liquidity, is trusted today (see `ALT_TOKEN_ADDRESSES`) \u2014 never assume every value here is available on every network."
|
|
316
|
+
);
|
|
295
317
|
var SwapAlternativeSchema = import_zod7.z.object({
|
|
296
318
|
token: AltTokenSchema,
|
|
297
319
|
network: NetworkSchema.describe(
|
|
@@ -1054,8 +1076,8 @@ var SwapQuoteSchema = import_zod19.z.object({
|
|
|
1054
1076
|
}).describe(
|
|
1055
1077
|
"Pass this directly to the payer's wallet (e.g. viem/ethers `sendTransaction`) \u2014 Klappay never touches the payer's private key or submits anything on their behalf. If `permit2` is present on this response, sign that first and append the signature to this `data` before sending; if `permit2` is absent, send `transaction` as-is with no extra step."
|
|
1056
1078
|
),
|
|
1057
|
-
permit2: import_zod19.z.object({ eip712: import_zod19.z.record(import_zod19.z.unknown()) }).
|
|
1058
|
-
"Present only when `inputToken` is an ERC-20 (today, only `BTC`) \u2014 the payer's wallet must sign this EIP-712 message and append the signature to `transaction.data` before sending, since an ERC-20 sell needs a Permit2 allowance signature that a native-currency sell doesn't.
|
|
1079
|
+
permit2: import_zod19.z.object({ eip712: import_zod19.z.record(import_zod19.z.unknown()) }).nullish().describe(
|
|
1080
|
+
"Present only when `inputToken` is an ERC-20 (today, only `BTC`) \u2014 the payer's wallet must sign this EIP-712 message and append the signature to `transaction.data` before sending, since an ERC-20 sell needs a Permit2 allowance signature that a native-currency sell doesn't. `null` (never omitted, in a genuine 0x-backed quote) when `inputToken` is a network's own native currency (ETH/BNB/MATIC/AVAX) \u2014 `transaction` is then ready to sign and send directly, no extra step."
|
|
1059
1081
|
)
|
|
1060
1082
|
});
|
|
1061
1083
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1066,6 +1088,7 @@ var SwapQuoteSchema = import_zod19.z.object({
|
|
|
1066
1088
|
AcceptedPaymentSchema,
|
|
1067
1089
|
AltTokenSchema,
|
|
1068
1090
|
ApiKeyScopeSchema,
|
|
1091
|
+
CHAIN_IDS,
|
|
1069
1092
|
CHARGE_ACCEPTED_PAYMENTS_MAX,
|
|
1070
1093
|
CHARGE_AMOUNT_MAX,
|
|
1071
1094
|
CHARGE_EXPIRES_IN_MAX_SECONDS,
|