@klappay/types 3.5.2 → 3.7.0
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 +1 -1
- package/dist/index.d.mts +377 -44
- package/dist/index.d.ts +377 -44
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
ChargesMetricFieldSchema: () => ChargesMetricFieldSchema,
|
|
43
43
|
ChargesQueryFieldSchema: () => ChargesQueryFieldSchema,
|
|
44
44
|
CheckChargeRequestSchema: () => CheckChargeRequestSchema,
|
|
45
|
+
CheckChargeResponseSchema: () => CheckChargeResponseSchema,
|
|
45
46
|
CheckoutProductSchema: () => CheckoutProductSchema,
|
|
46
47
|
CreateChargeSchema: () => CreateChargeSchema,
|
|
47
48
|
CreateRecipientSchema: () => CreateRecipientSchema,
|
|
@@ -90,6 +91,7 @@ __export(index_exports, {
|
|
|
90
91
|
PendingDistributionRecipientSchema: () => PendingDistributionRecipientSchema,
|
|
91
92
|
PendingDistributionSchema: () => PendingDistributionSchema,
|
|
92
93
|
RecipientSchema: () => RecipientSchema,
|
|
94
|
+
RefundEscrowRequestSchema: () => RefundEscrowRequestSchema,
|
|
93
95
|
ReleaseEscrowRequestSchema: () => ReleaseEscrowRequestSchema,
|
|
94
96
|
SandboxTriggerSchema: () => SandboxTriggerSchema,
|
|
95
97
|
SetRecipientPayoutSchema: () => SetRecipientPayoutSchema,
|
|
@@ -369,6 +371,11 @@ var ReleaseEscrowRequestSchema = import_zod9.z.object({
|
|
|
369
371
|
"The Safe transaction signature authorizing this release, produced by signing a transfer of the escrow's entire current token balance to the charge's already-frozen split address (the same split that would have received the payment on a normal, non-escrow charge) with the private key behind this charge's `escrowReleaserAddress` \u2014 never anything Klappay can produce itself. The destination is fixed by the charge's `splitConfig` (frozen at creation); the amount is read live on-chain at release time, not fixed in advance, so it always matches whatever actually arrived \u2014 reconstruct the exact transaction server-side computes (ERC-20 `transfer(splitAddress, balance)` from the escrow Safe, nonce 0) before signing. Independently verified on-chain before anything moves \u2014 the Safe contract itself rejects a signature that isn't from `escrowReleaserAddress`, never trusted at face value by Klappay."
|
|
370
372
|
)
|
|
371
373
|
});
|
|
374
|
+
var RefundEscrowRequestSchema = import_zod9.z.object({
|
|
375
|
+
signature: import_zod9.z.string().regex(/^0x[0-9a-fA-F]+$/, "must be hex-encoded signature bytes").describe(
|
|
376
|
+
"The Safe transaction signature authorizing this refund, produced by signing a transfer of the escrow's entire current token balance back to the address that funded this charge (`Charge.payerAddress`, captured from the credited transfer) with the private key behind this charge's `escrowReleaserAddress` \u2014 never anything Klappay can produce itself. The amount is read live on-chain at refund time, not fixed in advance, so it always matches whatever actually arrived \u2014 reconstruct the exact transaction Klappay computes server-side (ERC-20 `transfer(payerAddress, balance)` from the escrow Safe, nonce 0) before signing. Independently verified on-chain before anything moves \u2014 the Safe contract itself rejects a signature that isn't from `escrowReleaserAddress`, never trusted at face value by Klappay."
|
|
377
|
+
)
|
|
378
|
+
});
|
|
372
379
|
|
|
373
380
|
// src/charges.ts
|
|
374
381
|
var ChargeStatusSchema = import_zod10.z.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid"]).describe(
|
|
@@ -523,7 +530,10 @@ var ChargeSchema = import_zod10.z.object({
|
|
|
523
530
|
),
|
|
524
531
|
escrow: import_zod10.z.object({
|
|
525
532
|
releaserAddress: import_zod10.z.string().describe("The only address that can ever release this escrow \u2014 never Klappay."),
|
|
526
|
-
releasedAt: import_zod10.z.string().datetime().nullable().describe("When the release actually executed on-chain. `null` until then.")
|
|
533
|
+
releasedAt: import_zod10.z.string().datetime().nullable().describe("When the release actually executed on-chain. `null` until then."),
|
|
534
|
+
refundedAt: import_zod10.z.string().datetime().nullable().describe(
|
|
535
|
+
"When the refund actually executed on-chain. `null` until then. Mutually exclusive with `releasedAt` \u2014 an escrow can only ever be released or refunded once, never both."
|
|
536
|
+
)
|
|
527
537
|
}).nullable().describe(
|
|
528
538
|
"Present only when this charge was created as an escrow (see `escrow` on the create request) \u2014 `null` for a normal charge."
|
|
529
539
|
)
|
|
@@ -562,6 +572,11 @@ var CheckChargeRequestSchema = import_zod11.z.object({
|
|
|
562
572
|
}).refine((data) => Boolean(data.txHash) === Boolean(data.network), {
|
|
563
573
|
message: "`txHash` and `network` must be provided together, or both omitted"
|
|
564
574
|
});
|
|
575
|
+
var CheckChargeResponseSchema = ChargeSchema.extend({
|
|
576
|
+
transactionSender: import_zod11.z.string().nullable().describe(
|
|
577
|
+
"The `txHash` transaction's own sender (`from`) \u2014 who actually signed and submitted it on-chain, which stays the payer's own wallet even when the transaction swaps through a router/aggregator on the way to paying, unlike the credited transfer's `from` (which can be the router/pool contract, not the payer). `null` unless `txHash`/`network` was passed in the request and a successful receipt was found for it \u2014 a hint-less background scan, an unaccepted network, or a not-found/reverted transaction all leave this `null`."
|
|
578
|
+
)
|
|
579
|
+
});
|
|
565
580
|
|
|
566
581
|
// src/distributions.ts
|
|
567
582
|
var import_zod12 = require("zod");
|
|
@@ -868,9 +883,10 @@ var ChargeWebhookEventTypeSchema = import_zod14.z.enum([
|
|
|
868
883
|
"charge.settled",
|
|
869
884
|
"charge.settlement_failed",
|
|
870
885
|
"charge.overpaid",
|
|
871
|
-
"charge.escrow_released"
|
|
886
|
+
"charge.escrow_released",
|
|
887
|
+
"charge.escrow_refunded"
|
|
872
888
|
]).describe(
|
|
873
|
-
'Note the distinction between `charge.confirmed` and `charge.settled`: `confirmed` means the payment was detected on-chain; `settled` means the merchant\'s wallet actually received the funds \u2014 a separate, later step. Subscribe to `confirmed` if you only need "will I get paid," or `settled` if you need "has the money actually arrived." `charge.overpaid` fires alongside `charge.confirmed`/`charge.partially_paid` whenever the cumulative amount received ends up above `amount` (see `Charge.isOverpaid`). `charge.escrow_released` fires once an escrow-configured charge\'s funds have been moved out of its Safe to the split address by `POST /v1/charges/{id}/release` \u2014 a normal `charge.settled` still follows once the split itself finishes distributing. Every event in this category carries the full `Charge` object as `data`.'
|
|
889
|
+
'Note the distinction between `charge.confirmed` and `charge.settled`: `confirmed` means the payment was detected on-chain; `settled` means the merchant\'s wallet actually received the funds \u2014 a separate, later step. Subscribe to `confirmed` if you only need "will I get paid," or `settled` if you need "has the money actually arrived." `charge.overpaid` fires alongside `charge.confirmed`/`charge.partially_paid` whenever the cumulative amount received ends up above `amount` (see `Charge.isOverpaid`). `charge.escrow_released` fires once an escrow-configured charge\'s funds have been moved out of its Safe to the split address by `POST /v1/charges/{id}/release` \u2014 a normal `charge.settled` still follows once the split itself finishes distributing. `charge.escrow_refunded` fires once an escrow-configured charge\'s funds have been moved out of its Safe back to the payer by `POST /v1/charges/{id}/refund` \u2014 mutually exclusive with `charge.escrow_released`, an escrow charge only ever emits one of the two. Every event in this category carries the full `Charge` object as `data`.'
|
|
874
890
|
);
|
|
875
891
|
var WebhookDeliveryEventTypeSchema = import_zod14.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
|
|
876
892
|
"Meta-events about the health of your own webhook endpoints \u2014 useful for monitoring without polling `GET /v1/webhooks/{id}/deliveries`. `webhook.endpoint_unhealthy` fires once when a webhook's failure rate over the trailing 24h crosses 20%, and `webhook.delivery_recovered` fires once when a delivery to that webhook next succeeds. `data` for every event in this category: `{ webhookId, url, failureRatio? }` (`failureRatio` only present on `webhook.endpoint_unhealthy`)."
|
|
@@ -901,9 +917,11 @@ var WEBHOOK_EVENT_CATEGORIES = {
|
|
|
901
917
|
webhooks: WebhookDeliveryEventTypeSchema.options
|
|
902
918
|
};
|
|
903
919
|
var TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([
|
|
904
|
-
"charge.created"
|
|
920
|
+
"charge.created",
|
|
921
|
+
"charge.escrow_released",
|
|
922
|
+
"charge.escrow_refunded"
|
|
905
923
|
]).describe(
|
|
906
|
-
"Every charge event that represents a payment-progress state transition a sandbox charge can be pushed into \u2014 everything except `charge.created` (a charge already exists by the time you have an id to trigger against)."
|
|
924
|
+
"Every charge event that represents a payment-progress state transition a sandbox charge can be pushed into \u2014 everything except `charge.created` (a charge already exists by the time you have an id to trigger against) and the two escrow-terminal events, which are reached by actually calling `POST /v1/charges/{id}/release` or `POST /v1/charges/{id}/refund` on a test-environment escrow charge (a real Safe transaction on that network's testnet), not this generic trigger."
|
|
907
925
|
);
|
|
908
926
|
|
|
909
927
|
// src/webhooks.ts
|
|
@@ -1151,6 +1169,7 @@ var SwapQuoteSchema = import_zod21.z.object({
|
|
|
1151
1169
|
ChargesMetricFieldSchema,
|
|
1152
1170
|
ChargesQueryFieldSchema,
|
|
1153
1171
|
CheckChargeRequestSchema,
|
|
1172
|
+
CheckChargeResponseSchema,
|
|
1154
1173
|
CheckoutProductSchema,
|
|
1155
1174
|
CreateChargeSchema,
|
|
1156
1175
|
CreateRecipientSchema,
|
|
@@ -1199,6 +1218,7 @@ var SwapQuoteSchema = import_zod21.z.object({
|
|
|
1199
1218
|
PendingDistributionRecipientSchema,
|
|
1200
1219
|
PendingDistributionSchema,
|
|
1201
1220
|
RecipientSchema,
|
|
1221
|
+
RefundEscrowRequestSchema,
|
|
1202
1222
|
ReleaseEscrowRequestSchema,
|
|
1203
1223
|
SandboxTriggerSchema,
|
|
1204
1224
|
SetRecipientPayoutSchema,
|