@zauthx402/sdk 0.1.3 → 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/README.md +1 -1
- 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 +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { d as ZauthMiddlewareOptions, b as createZauthMiddleware, z as zauthProvider } from '../index-
|
|
1
|
+
export { d as ZauthMiddlewareOptions, b as createZauthMiddleware, z as zauthProvider } from '../index-CylVkunV.mjs';
|
|
2
2
|
import 'express';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { d as ZauthMiddlewareOptions, b as createZauthMiddleware, z as zauthProvider } from '../index-
|
|
1
|
+
export { d as ZauthMiddlewareOptions, b as createZauthMiddleware, z as zauthProvider } from '../index-CylVkunV.js';
|
|
2
2
|
import 'express';
|
package/dist/middleware/index.js
CHANGED
|
@@ -4695,6 +4695,8 @@ var RefundExecutor = class {
|
|
|
4695
4695
|
// YYYY-MM-DD
|
|
4696
4696
|
lastCapResetMonth = (/* @__PURE__ */ new Date()).toISOString().slice(0, 7);
|
|
4697
4697
|
// YYYY-MM
|
|
4698
|
+
// Track processed refundIds to prevent double execution within same session
|
|
4699
|
+
processedRefundIds = /* @__PURE__ */ new Set();
|
|
4698
4700
|
constructor(client, config, debug = false) {
|
|
4699
4701
|
this.client = client;
|
|
4700
4702
|
this.config = config;
|
|
@@ -4787,6 +4789,11 @@ var RefundExecutor = class {
|
|
|
4787
4789
|
case "rejection_ack":
|
|
4788
4790
|
this.log("Refund rejection acknowledged", { refundId: msg.refundId });
|
|
4789
4791
|
break;
|
|
4792
|
+
case "executing_ack":
|
|
4793
|
+
if (this.debug) {
|
|
4794
|
+
this.log("Refund executing acknowledged", { refundId: msg.refundId, status: msg.status });
|
|
4795
|
+
}
|
|
4796
|
+
break;
|
|
4790
4797
|
case "pong":
|
|
4791
4798
|
break;
|
|
4792
4799
|
default:
|
|
@@ -4801,6 +4808,10 @@ var RefundExecutor = class {
|
|
|
4801
4808
|
*/
|
|
4802
4809
|
async processSingleRefund(refund) {
|
|
4803
4810
|
try {
|
|
4811
|
+
if (this.processedRefundIds.has(refund.id)) {
|
|
4812
|
+
this.log("Refund already processed in this session", { refundId: refund.id });
|
|
4813
|
+
return;
|
|
4814
|
+
}
|
|
4804
4815
|
const endpointConfig = this.getEndpointConfig(refund.url);
|
|
4805
4816
|
if (endpointConfig?.enabled === false) {
|
|
4806
4817
|
this.log("Refunds disabled for endpoint", { url: refund.url });
|
|
@@ -4859,8 +4870,13 @@ var RefundExecutor = class {
|
|
|
4859
4870
|
return;
|
|
4860
4871
|
}
|
|
4861
4872
|
}
|
|
4873
|
+
this.sendMessage({
|
|
4874
|
+
type: "refund_executing",
|
|
4875
|
+
refundId: refund.id
|
|
4876
|
+
});
|
|
4862
4877
|
const result = await this.executeRefundTx(refund);
|
|
4863
4878
|
if (result.success) {
|
|
4879
|
+
this.processedRefundIds.add(refund.id);
|
|
4864
4880
|
this.sendMessage({
|
|
4865
4881
|
type: "refund_confirmed",
|
|
4866
4882
|
refundId: refund.id,
|
|
@@ -5106,6 +5122,25 @@ function createZauthMiddleware(options) {
|
|
|
5106
5122
|
if (config.debug) {
|
|
5107
5123
|
console.log("[zauthSDK] Refund executor started");
|
|
5108
5124
|
}
|
|
5125
|
+
client.updateRefundConfig({
|
|
5126
|
+
enabled: true,
|
|
5127
|
+
maxRefundUsdCents: Math.round((config.refund.maxRefundUsd || 1) * 100),
|
|
5128
|
+
dailyCapCents: config.refund.dailyCapUsd ? Math.round(config.refund.dailyCapUsd * 100) : void 0,
|
|
5129
|
+
monthlyCapCents: config.refund.monthlyCapUsd ? Math.round(config.refund.monthlyCapUsd * 100) : void 0,
|
|
5130
|
+
triggers: {
|
|
5131
|
+
serverError: config.refund.triggers?.serverError ?? true,
|
|
5132
|
+
timeout: config.refund.triggers?.timeout ?? true,
|
|
5133
|
+
emptyResponse: config.refund.triggers?.emptyResponse ?? true,
|
|
5134
|
+
schemaValidation: config.refund.triggers?.schemaValidation ?? false,
|
|
5135
|
+
minMeaningfulness: config.refund.triggers?.minMeaningfulness ?? 0.3
|
|
5136
|
+
}
|
|
5137
|
+
}).then((result) => {
|
|
5138
|
+
if (config.debug) {
|
|
5139
|
+
console.log("[zauthSDK] Refund config registered with server", { success: result.success });
|
|
5140
|
+
}
|
|
5141
|
+
}).catch((err) => {
|
|
5142
|
+
console.error("[zauthSDK] Failed to register refund config:", err.message);
|
|
5143
|
+
});
|
|
5109
5144
|
}
|
|
5110
5145
|
function shouldMonitorRoute(req) {
|
|
5111
5146
|
if (options.shouldMonitor) {
|