@zauthx402/sdk 0.1.5 → 0.1.6
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/dist/{index-CzB2rK59.d.mts → index-CylVkunV.d.mts} +1 -0
- package/dist/{index-CzB2rK59.d.ts → index-CylVkunV.d.ts} +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -1
- package/dist/middleware/index.d.mts +1 -1
- package/dist/middleware/index.d.ts +1 -1
- package/dist/middleware/index.js +35 -0
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/index.mjs +35 -0
- package/dist/middleware/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1010,6 +1010,7 @@ declare class RefundExecutor {
|
|
|
1010
1010
|
private monthRefundedCents;
|
|
1011
1011
|
private lastCapResetDate;
|
|
1012
1012
|
private lastCapResetMonth;
|
|
1013
|
+
private processedRefundIds;
|
|
1013
1014
|
constructor(client: ZauthClient, config: ResolvedRefundConfig, debug?: boolean);
|
|
1014
1015
|
/**
|
|
1015
1016
|
* Start the WebSocket connection for refund notifications
|
|
@@ -1010,6 +1010,7 @@ declare class RefundExecutor {
|
|
|
1010
1010
|
private monthRefundedCents;
|
|
1011
1011
|
private lastCapResetDate;
|
|
1012
1012
|
private lastCapResetMonth;
|
|
1013
|
+
private processedRefundIds;
|
|
1013
1014
|
constructor(client: ZauthClient, config: ResolvedRefundConfig, debug?: boolean);
|
|
1014
1015
|
/**
|
|
1015
1016
|
* Start the WebSocket connection for refund notifications
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as ValidationConfig, a as ValidationResult } from './index-
|
|
2
|
-
export { Q as BatchingConfig, K as ConfirmRefundRequest, L as ConfirmRefundResponse, a6 as DEFAULT_CONFIG, W as EndpointRefundConfig, E as EndpointStatus, B as ErrorEvent, F as EventBatch, G as EventSubmitResponse, _ as ExecutedRefund, H as HealthCheckEvent, P as PaymentEvent, I as PendingRefund, J as PendingRefundsResponse, a2 as ProviderMiddlewareConfig, a0 as RefundCondition, S as RefundConfig, $ as RefundError, y as RefundEvent, R as RefundHandler, Y as RefundPollingConfig, A as RefundReason, f as RefundRequest, g as RefundResult, T as RefundSigner, U as RefundTriggers, M as RejectRefundRequest, N as RejectRefundResponse, w as RequestEvent, a5 as ResolvedConfig, a4 as ResolvedRefundConfig, a3 as ResolvedValidationConfig, x as ResponseEvent, a1 as TelemetryConfig, C as ValidationCheck, X as X402Network, p as X402PaymentInfo, n as X402PaymentPayload, j as X402PaymentRequirement, o as X402PaymentResponse, m as X402Response, k as X402ResponseV1, l as X402ResponseV2, h as X402Scheme, i as X402Version, Z as ZauthClient, O as ZauthConfig, D as ZauthEvent, v as ZauthEventBase, d as ZauthMiddlewareOptions, c as createClient, e as createRefundHandler, b as createZauthMiddleware, t as decodePaymentResponse, u as encodePaymentPayload, r as getPaymentRequirements, s as getPriceUsdc, q as parseX402Response, a7 as resolveConfig, z as zauthProvider } from './index-
|
|
1
|
+
import { V as ValidationConfig, a as ValidationResult } from './index-CylVkunV.mjs';
|
|
2
|
+
export { Q as BatchingConfig, K as ConfirmRefundRequest, L as ConfirmRefundResponse, a6 as DEFAULT_CONFIG, W as EndpointRefundConfig, E as EndpointStatus, B as ErrorEvent, F as EventBatch, G as EventSubmitResponse, _ as ExecutedRefund, H as HealthCheckEvent, P as PaymentEvent, I as PendingRefund, J as PendingRefundsResponse, a2 as ProviderMiddlewareConfig, a0 as RefundCondition, S as RefundConfig, $ as RefundError, y as RefundEvent, R as RefundHandler, Y as RefundPollingConfig, A as RefundReason, f as RefundRequest, g as RefundResult, T as RefundSigner, U as RefundTriggers, M as RejectRefundRequest, N as RejectRefundResponse, w as RequestEvent, a5 as ResolvedConfig, a4 as ResolvedRefundConfig, a3 as ResolvedValidationConfig, x as ResponseEvent, a1 as TelemetryConfig, C as ValidationCheck, X as X402Network, p as X402PaymentInfo, n as X402PaymentPayload, j as X402PaymentRequirement, o as X402PaymentResponse, m as X402Response, k as X402ResponseV1, l as X402ResponseV2, h as X402Scheme, i as X402Version, Z as ZauthClient, O as ZauthConfig, D as ZauthEvent, v as ZauthEventBase, d as ZauthMiddlewareOptions, c as createClient, e as createRefundHandler, b as createZauthMiddleware, t as decodePaymentResponse, u as encodePaymentPayload, r as getPaymentRequirements, s as getPriceUsdc, q as parseX402Response, a7 as resolveConfig, z as zauthProvider } from './index-CylVkunV.mjs';
|
|
3
3
|
import 'express';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as ValidationConfig, a as ValidationResult } from './index-
|
|
2
|
-
export { Q as BatchingConfig, K as ConfirmRefundRequest, L as ConfirmRefundResponse, a6 as DEFAULT_CONFIG, W as EndpointRefundConfig, E as EndpointStatus, B as ErrorEvent, F as EventBatch, G as EventSubmitResponse, _ as ExecutedRefund, H as HealthCheckEvent, P as PaymentEvent, I as PendingRefund, J as PendingRefundsResponse, a2 as ProviderMiddlewareConfig, a0 as RefundCondition, S as RefundConfig, $ as RefundError, y as RefundEvent, R as RefundHandler, Y as RefundPollingConfig, A as RefundReason, f as RefundRequest, g as RefundResult, T as RefundSigner, U as RefundTriggers, M as RejectRefundRequest, N as RejectRefundResponse, w as RequestEvent, a5 as ResolvedConfig, a4 as ResolvedRefundConfig, a3 as ResolvedValidationConfig, x as ResponseEvent, a1 as TelemetryConfig, C as ValidationCheck, X as X402Network, p as X402PaymentInfo, n as X402PaymentPayload, j as X402PaymentRequirement, o as X402PaymentResponse, m as X402Response, k as X402ResponseV1, l as X402ResponseV2, h as X402Scheme, i as X402Version, Z as ZauthClient, O as ZauthConfig, D as ZauthEvent, v as ZauthEventBase, d as ZauthMiddlewareOptions, c as createClient, e as createRefundHandler, b as createZauthMiddleware, t as decodePaymentResponse, u as encodePaymentPayload, r as getPaymentRequirements, s as getPriceUsdc, q as parseX402Response, a7 as resolveConfig, z as zauthProvider } from './index-
|
|
1
|
+
import { V as ValidationConfig, a as ValidationResult } from './index-CylVkunV.js';
|
|
2
|
+
export { Q as BatchingConfig, K as ConfirmRefundRequest, L as ConfirmRefundResponse, a6 as DEFAULT_CONFIG, W as EndpointRefundConfig, E as EndpointStatus, B as ErrorEvent, F as EventBatch, G as EventSubmitResponse, _ as ExecutedRefund, H as HealthCheckEvent, P as PaymentEvent, I as PendingRefund, J as PendingRefundsResponse, a2 as ProviderMiddlewareConfig, a0 as RefundCondition, S as RefundConfig, $ as RefundError, y as RefundEvent, R as RefundHandler, Y as RefundPollingConfig, A as RefundReason, f as RefundRequest, g as RefundResult, T as RefundSigner, U as RefundTriggers, M as RejectRefundRequest, N as RejectRefundResponse, w as RequestEvent, a5 as ResolvedConfig, a4 as ResolvedRefundConfig, a3 as ResolvedValidationConfig, x as ResponseEvent, a1 as TelemetryConfig, C as ValidationCheck, X as X402Network, p as X402PaymentInfo, n as X402PaymentPayload, j as X402PaymentRequirement, o as X402PaymentResponse, m as X402Response, k as X402ResponseV1, l as X402ResponseV2, h as X402Scheme, i as X402Version, Z as ZauthClient, O as ZauthConfig, D as ZauthEvent, v as ZauthEventBase, d as ZauthMiddlewareOptions, c as createClient, e as createRefundHandler, b as createZauthMiddleware, t as decodePaymentResponse, u as encodePaymentPayload, r as getPaymentRequirements, s as getPriceUsdc, q as parseX402Response, a7 as resolveConfig, z as zauthProvider } from './index-CylVkunV.js';
|
|
3
3
|
import 'express';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -4965,6 +4965,8 @@ var RefundExecutor = class {
|
|
|
4965
4965
|
// YYYY-MM-DD
|
|
4966
4966
|
lastCapResetMonth = (/* @__PURE__ */ new Date()).toISOString().slice(0, 7);
|
|
4967
4967
|
// YYYY-MM
|
|
4968
|
+
// Track processed refundIds to prevent double execution within same session
|
|
4969
|
+
processedRefundIds = /* @__PURE__ */ new Set();
|
|
4968
4970
|
constructor(client, config, debug = false) {
|
|
4969
4971
|
this.client = client;
|
|
4970
4972
|
this.config = config;
|
|
@@ -5057,6 +5059,11 @@ var RefundExecutor = class {
|
|
|
5057
5059
|
case "rejection_ack":
|
|
5058
5060
|
this.log("Refund rejection acknowledged", { refundId: msg.refundId });
|
|
5059
5061
|
break;
|
|
5062
|
+
case "executing_ack":
|
|
5063
|
+
if (this.debug) {
|
|
5064
|
+
this.log("Refund executing acknowledged", { refundId: msg.refundId, status: msg.status });
|
|
5065
|
+
}
|
|
5066
|
+
break;
|
|
5060
5067
|
case "pong":
|
|
5061
5068
|
break;
|
|
5062
5069
|
default:
|
|
@@ -5071,6 +5078,10 @@ var RefundExecutor = class {
|
|
|
5071
5078
|
*/
|
|
5072
5079
|
async processSingleRefund(refund) {
|
|
5073
5080
|
try {
|
|
5081
|
+
if (this.processedRefundIds.has(refund.id)) {
|
|
5082
|
+
this.log("Refund already processed in this session", { refundId: refund.id });
|
|
5083
|
+
return;
|
|
5084
|
+
}
|
|
5074
5085
|
const endpointConfig = this.getEndpointConfig(refund.url);
|
|
5075
5086
|
if (endpointConfig?.enabled === false) {
|
|
5076
5087
|
this.log("Refunds disabled for endpoint", { url: refund.url });
|
|
@@ -5129,8 +5140,13 @@ var RefundExecutor = class {
|
|
|
5129
5140
|
return;
|
|
5130
5141
|
}
|
|
5131
5142
|
}
|
|
5143
|
+
this.sendMessage({
|
|
5144
|
+
type: "refund_executing",
|
|
5145
|
+
refundId: refund.id
|
|
5146
|
+
});
|
|
5132
5147
|
const result = await this.executeRefundTx(refund);
|
|
5133
5148
|
if (result.success) {
|
|
5149
|
+
this.processedRefundIds.add(refund.id);
|
|
5134
5150
|
this.sendMessage({
|
|
5135
5151
|
type: "refund_confirmed",
|
|
5136
5152
|
refundId: refund.id,
|
|
@@ -5376,6 +5392,25 @@ function createZauthMiddleware(options) {
|
|
|
5376
5392
|
if (config.debug) {
|
|
5377
5393
|
console.log("[zauthSDK] Refund executor started");
|
|
5378
5394
|
}
|
|
5395
|
+
client.updateRefundConfig({
|
|
5396
|
+
enabled: true,
|
|
5397
|
+
maxRefundUsdCents: Math.round((config.refund.maxRefundUsd || 1) * 100),
|
|
5398
|
+
dailyCapCents: config.refund.dailyCapUsd ? Math.round(config.refund.dailyCapUsd * 100) : void 0,
|
|
5399
|
+
monthlyCapCents: config.refund.monthlyCapUsd ? Math.round(config.refund.monthlyCapUsd * 100) : void 0,
|
|
5400
|
+
triggers: {
|
|
5401
|
+
serverError: config.refund.triggers?.serverError ?? true,
|
|
5402
|
+
timeout: config.refund.triggers?.timeout ?? true,
|
|
5403
|
+
emptyResponse: config.refund.triggers?.emptyResponse ?? true,
|
|
5404
|
+
schemaValidation: config.refund.triggers?.schemaValidation ?? false,
|
|
5405
|
+
minMeaningfulness: config.refund.triggers?.minMeaningfulness ?? 0.3
|
|
5406
|
+
}
|
|
5407
|
+
}).then((result) => {
|
|
5408
|
+
if (config.debug) {
|
|
5409
|
+
console.log("[zauthSDK] Refund config registered with server", { success: result.success });
|
|
5410
|
+
}
|
|
5411
|
+
}).catch((err) => {
|
|
5412
|
+
console.error("[zauthSDK] Failed to register refund config:", err.message);
|
|
5413
|
+
});
|
|
5379
5414
|
}
|
|
5380
5415
|
function shouldMonitorRoute(req) {
|
|
5381
5416
|
if (options.shouldMonitor) {
|