@vonpay/checkout-cli 0.15.0 → 0.15.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/dist/index.js +37 -6
- package/package.json +6 -1
package/dist/index.js
CHANGED
|
@@ -1694,8 +1694,10 @@ function buildEventData(event, ids, amount, currency) {
|
|
|
1694
1694
|
refund_amount: amount,
|
|
1695
1695
|
amount_refunded_total: 0,
|
|
1696
1696
|
reason: "customer_request",
|
|
1697
|
-
//
|
|
1698
|
-
// `
|
|
1697
|
+
// An OPEN refund vocabulary (the SDK's RefundFailedData.reason_code):
|
|
1698
|
+
// `refund_declined` (the provider refused, retrying unchanged fails the
|
|
1699
|
+
// same way) and `refund_unresolved` (no provider response, true state
|
|
1700
|
+
// unknown) are the values sent so far. This sample uses the first.
|
|
1699
1701
|
reason_code: "refund_declined",
|
|
1700
1702
|
is_partial: false,
|
|
1701
1703
|
original_charge_amount: amount,
|
|
@@ -1928,6 +1930,9 @@ var SseParser = class {
|
|
|
1928
1930
|
// src/utils/sse-consumer.ts
|
|
1929
1931
|
var MAX_PENDING_CHARS = 1048576;
|
|
1930
1932
|
var MAX_EVENT_ID_LENGTH = 256;
|
|
1933
|
+
var SERVER_RECONNECT_FLOOR_MS = 250;
|
|
1934
|
+
var SERVER_RECONNECT_WINDOW_MS = 5e3;
|
|
1935
|
+
var SERVER_RECONNECT_MAX_IN_WINDOW = 3;
|
|
1931
1936
|
function resumeId(lastId) {
|
|
1932
1937
|
return /^[\x20-\x7e]+$/.test(lastId) ? lastId : void 0;
|
|
1933
1938
|
}
|
|
@@ -1941,6 +1946,8 @@ async function* consumeSse(opts) {
|
|
|
1941
1946
|
);
|
|
1942
1947
|
let backoffMs = initialBackoffMs;
|
|
1943
1948
|
const onLifecycle = opts.onLifecycle ?? noop;
|
|
1949
|
+
let serverReconnectTimes = [];
|
|
1950
|
+
let holdBackoff = false;
|
|
1944
1951
|
while (!opts.signal.aborted) {
|
|
1945
1952
|
const headers = {
|
|
1946
1953
|
Accept: "text/event-stream",
|
|
@@ -1994,7 +2001,8 @@ async function* consumeSse(opts) {
|
|
|
1994
2001
|
continue;
|
|
1995
2002
|
}
|
|
1996
2003
|
onLifecycle({ kind: "connected" });
|
|
1997
|
-
|
|
2004
|
+
const connectedAt = Date.now();
|
|
2005
|
+
if (!holdBackoff) backoffMs = initialBackoffMs;
|
|
1998
2006
|
parser.reset();
|
|
1999
2007
|
const reader = response.body.getReader();
|
|
2000
2008
|
const decoder = new TextDecoder("utf-8");
|
|
@@ -2011,11 +2019,13 @@ async function* consumeSse(opts) {
|
|
|
2011
2019
|
}
|
|
2012
2020
|
for (const ev of pending.splice(0)) {
|
|
2013
2021
|
if (ev.type === "timeout") {
|
|
2014
|
-
yield ev;
|
|
2015
2022
|
serverInitiatedReconnect = true;
|
|
2016
2023
|
} else {
|
|
2017
|
-
|
|
2024
|
+
serverReconnectTimes = [];
|
|
2025
|
+
holdBackoff = false;
|
|
2026
|
+
backoffMs = initialBackoffMs;
|
|
2018
2027
|
}
|
|
2028
|
+
yield ev;
|
|
2019
2029
|
}
|
|
2020
2030
|
if (feedError !== void 0) throw feedError;
|
|
2021
2031
|
}
|
|
@@ -2031,6 +2041,27 @@ async function* consumeSse(opts) {
|
|
|
2031
2041
|
}
|
|
2032
2042
|
if (opts.signal.aborted) return;
|
|
2033
2043
|
if (serverInitiatedReconnect) {
|
|
2044
|
+
const now = Date.now();
|
|
2045
|
+
if (now - connectedAt >= SERVER_RECONNECT_WINDOW_MS) {
|
|
2046
|
+
serverReconnectTimes = [];
|
|
2047
|
+
holdBackoff = false;
|
|
2048
|
+
backoffMs = initialBackoffMs;
|
|
2049
|
+
} else {
|
|
2050
|
+
serverReconnectTimes = serverReconnectTimes.filter((t) => now - t < SERVER_RECONNECT_WINDOW_MS);
|
|
2051
|
+
serverReconnectTimes.push(now);
|
|
2052
|
+
}
|
|
2053
|
+
if (holdBackoff || serverReconnectTimes.length > SERVER_RECONNECT_MAX_IN_WINDOW) {
|
|
2054
|
+
holdBackoff = true;
|
|
2055
|
+
onLifecycle({
|
|
2056
|
+
kind: "disconnected",
|
|
2057
|
+
reason: "the server keeps asking to reconnect; backing off",
|
|
2058
|
+
willRetryInMs: backoffMs
|
|
2059
|
+
});
|
|
2060
|
+
await sleep(backoffMs, opts.signal);
|
|
2061
|
+
backoffMs = Math.min(backoffMs * 2, maxBackoffMs);
|
|
2062
|
+
continue;
|
|
2063
|
+
}
|
|
2064
|
+
await sleep(SERVER_RECONNECT_FLOOR_MS, opts.signal);
|
|
2034
2065
|
continue;
|
|
2035
2066
|
}
|
|
2036
2067
|
onLifecycle({
|
|
@@ -2287,7 +2318,7 @@ function listenCommand() {
|
|
|
2287
2318
|
onLifecycle({
|
|
2288
2319
|
kind: "disconnected",
|
|
2289
2320
|
reason: "server-ceiling (1h cap; auto-reconnecting)",
|
|
2290
|
-
willRetryInMs:
|
|
2321
|
+
willRetryInMs: SERVER_RECONNECT_FLOOR_MS
|
|
2291
2322
|
});
|
|
2292
2323
|
continue;
|
|
2293
2324
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonpay/checkout-cli",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Von Payments CLI — developer tools for checkout integration",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Von-Payments/vonpay.git",
|
|
8
|
+
"directory": "packages/checkout-cli"
|
|
9
|
+
},
|
|
5
10
|
"license": "MIT",
|
|
6
11
|
"type": "module",
|
|
7
12
|
"bin": {
|