@invonetwork/web-sdk 3.6.0 → 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/CHANGELOG.md +81 -0
- package/README.md +378 -61
- package/dist/{chunk-MBKE6ULW.js → chunk-23TGMTII.js} +90 -3
- package/dist/index.cjs +88 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/server.cjs +508 -1
- package/dist/server.d.cts +109 -3
- package/dist/server.d.ts +109 -3
- package/dist/server.js +422 -2
- package/dist/{types-ZNoG09S5.d.cts → types-CspPkmK9.d.cts} +265 -11
- package/dist/{types-ZNoG09S5.d.ts → types-CspPkmK9.d.ts} +265 -11
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// src/shared/errors.ts
|
|
2
|
+
var LEGACY_NOT_PENDING_RE = /^transaction not pending\b|\bcannot be confirmed\b/i;
|
|
3
|
+
var LEGACY_CURRENT_STATUS_RE = /\((?:current )?status:\s*([^)]+)\)/i;
|
|
2
4
|
var InvoError = class _InvoError extends Error {
|
|
3
5
|
constructor(args) {
|
|
4
6
|
super(args.message);
|
|
@@ -379,6 +381,91 @@ var InvoError = class _InvoError extends Error {
|
|
|
379
381
|
get isAlreadyRefunded() {
|
|
380
382
|
return this.code === "ALREADY_REFUNDED" || this.status === 409 && /already\s+refunded/i.test(this.message);
|
|
381
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* True when an approve / confirm-receipt was refused because the transaction is no
|
|
386
|
+
* longer awaiting that step (`TRANSACTION_NOT_PENDING`, 400). `approveWithDeviceCode`
|
|
387
|
+
* maps this into a non-throwing `status: "not_pending"` result; you meet it as a thrown
|
|
388
|
+
* error only from a raw call. Usually "already done" (a repeat call with a device_code
|
|
389
|
+
* that was consumed the first time) — read `currentTransactionStatus`, do not retry-loop.
|
|
390
|
+
*
|
|
391
|
+
* The message fallback is for OLDER BACKEND RELEASES. The stable
|
|
392
|
+
* `TRANSACTION_NOT_PENDING` code was added on 2026-09-04; before that the same four
|
|
393
|
+
* endpoints answered `{"status":"error","message":"Transaction not pending PIN
|
|
394
|
+
* verification (current status: …)"}` — or, on the two receipt flows, "…cannot be
|
|
395
|
+
* confirmed (current status: …)" — with **no machine code at all**. An integrator
|
|
396
|
+
* running against an older deployment must still be able to tell "already done" from a
|
|
397
|
+
* real refusal without string-matching in their own code, so the string-matching lives
|
|
398
|
+
* here, once.
|
|
399
|
+
*
|
|
400
|
+
* That fallback is deliberately narrow, because it is guessing. It requires all three
|
|
401
|
+
* of: HTTP 400, one of those two phrases, AND a readable status clause. "cannot be
|
|
402
|
+
* confirmed" is an ordinary English phrase that some future refusal could reasonably
|
|
403
|
+
* use, so a phrase match ALONE must never be able to tell a caller that money moved —
|
|
404
|
+
* and with the clause required, `currentStatus` is always populated on this path, which
|
|
405
|
+
* is what actually decides `alreadySettled`.
|
|
406
|
+
*/
|
|
407
|
+
get isTransactionNotPending() {
|
|
408
|
+
if (this.code === "TRANSACTION_NOT_PENDING") return true;
|
|
409
|
+
return this.status === 400 && LEGACY_NOT_PENDING_RE.test(this.message) && LEGACY_CURRENT_STATUS_RE.test(this.message);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* The `current_status` a `TRANSACTION_NOT_PENDING` refusal reports (e.g. `pending_claim`,
|
|
413
|
+
* `completed`, `expired`).
|
|
414
|
+
*
|
|
415
|
+
* Falls back to the `(current status: …)` clause inside the message, which is where the
|
|
416
|
+
* older releases described above put it — they carried no `current_status` field.
|
|
417
|
+
*/
|
|
418
|
+
get currentTransactionStatus() {
|
|
419
|
+
const v = this.bodyObject()["current_status"];
|
|
420
|
+
if (typeof v === "string" && v) return v;
|
|
421
|
+
const m = LEGACY_CURRENT_STATUS_RE.exec(this.message);
|
|
422
|
+
const parsed = m?.[1]?.trim();
|
|
423
|
+
return parsed ? parsed : void 0;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* True when the approve endpoint did not accept the `device_code`
|
|
427
|
+
* (`DEVICE_APPROVAL_NOT_APPROVED`, 400): unknown, another player's, bound to a
|
|
428
|
+
* different transaction or FLOW, or not yet approved. Deliberately one answer for all
|
|
429
|
+
* of those (no oracle). Check the `flow` you passed matches the one you began with,
|
|
430
|
+
* and that the poll actually said `approved` before you called approve.
|
|
431
|
+
*/
|
|
432
|
+
get isDeviceApprovalNotApproved() {
|
|
433
|
+
return this.code === "DEVICE_APPROVAL_NOT_APPROVED";
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* True when `beginDeviceApproval` was refused because an APPROVED grant for this
|
|
437
|
+
* transaction and flow is still inside its window (`DEVICE_APPROVAL_ALREADY_PENDING`,
|
|
438
|
+
* 409). The player already approved — you are missing the approve call, not a new
|
|
439
|
+
* code. If you still hold the `device_code`, call `approveWithDeviceCode`; otherwise
|
|
440
|
+
* `begin` works again after `deviceApprovalExpiresAt`. (A merely PENDING earlier grant
|
|
441
|
+
* does not 409 — `begin` supersedes it with a fresh code.)
|
|
442
|
+
*/
|
|
443
|
+
get isDeviceApprovalAlreadyPending() {
|
|
444
|
+
return this.code === "DEVICE_APPROVAL_ALREADY_PENDING";
|
|
445
|
+
}
|
|
446
|
+
/** ISO time the blocking approved grant's window closes (`expires_at` on a `DEVICE_APPROVAL_ALREADY_PENDING` 409). */
|
|
447
|
+
get deviceApprovalExpiresAt() {
|
|
448
|
+
const v = this.bodyObject()["expires_at"];
|
|
449
|
+
return typeof v === "string" && v ? v : void 0;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* True when a settle call failed on INVO's side rather than being refused by a rule
|
|
453
|
+
* (`SEND_APPROVE_FAILED` / `TRANSFER_APPROVE_FAILED` / `CONFIRM_RECEIPT_FAILED`, 400).
|
|
454
|
+
*
|
|
455
|
+
* A fault, never a rule and never retryable. Show a neutral failure and report
|
|
456
|
+
* {@link errorRef} — do not treat it as a decision about the player or the money.
|
|
457
|
+
*/
|
|
458
|
+
get isSettleFault() {
|
|
459
|
+
return this.code === "SEND_APPROVE_FAILED" || this.code === "TRANSFER_APPROVE_FAILED" || this.code === "CONFIRM_RECEIPT_FAILED";
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* The `error_ref` a settle fault carries. It names the exact server log line, so quoting
|
|
463
|
+
* it to INVO support gets the cause in one message instead of a description of symptoms.
|
|
464
|
+
*/
|
|
465
|
+
get errorRef() {
|
|
466
|
+
const v = this.bodyObject()["error_ref"];
|
|
467
|
+
return typeof v === "string" && v ? v : void 0;
|
|
468
|
+
}
|
|
382
469
|
/** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
|
|
383
470
|
get retryAfter() {
|
|
384
471
|
const v = this.bodyObject()["retry_after"];
|
|
@@ -402,7 +489,7 @@ function errorFromResponse(status, body, requestId) {
|
|
|
402
489
|
code = typeof b["error_code_public"] === "string" ? b["error_code_public"] : rawCode;
|
|
403
490
|
if (typeof b["error"] === "string") message = b["error"];
|
|
404
491
|
else if (typeof b["message"] === "string") message = b["message"];
|
|
405
|
-
if (!code && typeof b["error"] === "string" && /^(flow_paused|spending_limit_exceeded|receiver_not_enrolled_use_claim_code|no_channel_on_file|rate_limited|service_unavailable)$/.test(
|
|
492
|
+
if (!code && typeof b["error"] === "string" && /^(flow_paused|spending_limit_exceeded|receiver_not_enrolled_use_claim_code|no_channel_on_file|rate_limited|service_unavailable|authorization_pending|slow_down|expired_token|access_denied|invalid_grant)$/.test(
|
|
406
493
|
b["error"]
|
|
407
494
|
)) {
|
|
408
495
|
code = b["error"];
|
|
@@ -659,5 +746,5 @@ function toDestinationsResult(raw, direction) {
|
|
|
659
746
|
}
|
|
660
747
|
|
|
661
748
|
export { Http, InvoError, assertSecureBaseUrl, toDestinationsResult };
|
|
662
|
-
//# sourceMappingURL=chunk-
|
|
663
|
-
//# sourceMappingURL=chunk-
|
|
749
|
+
//# sourceMappingURL=chunk-23TGMTII.js.map
|
|
750
|
+
//# sourceMappingURL=chunk-23TGMTII.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/shared/errors.ts
|
|
4
|
+
var LEGACY_NOT_PENDING_RE = /^transaction not pending\b|\bcannot be confirmed\b/i;
|
|
5
|
+
var LEGACY_CURRENT_STATUS_RE = /\((?:current )?status:\s*([^)]+)\)/i;
|
|
4
6
|
var InvoError = class _InvoError extends Error {
|
|
5
7
|
constructor(args) {
|
|
6
8
|
super(args.message);
|
|
@@ -381,6 +383,91 @@ var InvoError = class _InvoError extends Error {
|
|
|
381
383
|
get isAlreadyRefunded() {
|
|
382
384
|
return this.code === "ALREADY_REFUNDED" || this.status === 409 && /already\s+refunded/i.test(this.message);
|
|
383
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* True when an approve / confirm-receipt was refused because the transaction is no
|
|
388
|
+
* longer awaiting that step (`TRANSACTION_NOT_PENDING`, 400). `approveWithDeviceCode`
|
|
389
|
+
* maps this into a non-throwing `status: "not_pending"` result; you meet it as a thrown
|
|
390
|
+
* error only from a raw call. Usually "already done" (a repeat call with a device_code
|
|
391
|
+
* that was consumed the first time) — read `currentTransactionStatus`, do not retry-loop.
|
|
392
|
+
*
|
|
393
|
+
* The message fallback is for OLDER BACKEND RELEASES. The stable
|
|
394
|
+
* `TRANSACTION_NOT_PENDING` code was added on 2026-09-04; before that the same four
|
|
395
|
+
* endpoints answered `{"status":"error","message":"Transaction not pending PIN
|
|
396
|
+
* verification (current status: …)"}` — or, on the two receipt flows, "…cannot be
|
|
397
|
+
* confirmed (current status: …)" — with **no machine code at all**. An integrator
|
|
398
|
+
* running against an older deployment must still be able to tell "already done" from a
|
|
399
|
+
* real refusal without string-matching in their own code, so the string-matching lives
|
|
400
|
+
* here, once.
|
|
401
|
+
*
|
|
402
|
+
* That fallback is deliberately narrow, because it is guessing. It requires all three
|
|
403
|
+
* of: HTTP 400, one of those two phrases, AND a readable status clause. "cannot be
|
|
404
|
+
* confirmed" is an ordinary English phrase that some future refusal could reasonably
|
|
405
|
+
* use, so a phrase match ALONE must never be able to tell a caller that money moved —
|
|
406
|
+
* and with the clause required, `currentStatus` is always populated on this path, which
|
|
407
|
+
* is what actually decides `alreadySettled`.
|
|
408
|
+
*/
|
|
409
|
+
get isTransactionNotPending() {
|
|
410
|
+
if (this.code === "TRANSACTION_NOT_PENDING") return true;
|
|
411
|
+
return this.status === 400 && LEGACY_NOT_PENDING_RE.test(this.message) && LEGACY_CURRENT_STATUS_RE.test(this.message);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* The `current_status` a `TRANSACTION_NOT_PENDING` refusal reports (e.g. `pending_claim`,
|
|
415
|
+
* `completed`, `expired`).
|
|
416
|
+
*
|
|
417
|
+
* Falls back to the `(current status: …)` clause inside the message, which is where the
|
|
418
|
+
* older releases described above put it — they carried no `current_status` field.
|
|
419
|
+
*/
|
|
420
|
+
get currentTransactionStatus() {
|
|
421
|
+
const v = this.bodyObject()["current_status"];
|
|
422
|
+
if (typeof v === "string" && v) return v;
|
|
423
|
+
const m = LEGACY_CURRENT_STATUS_RE.exec(this.message);
|
|
424
|
+
const parsed = m?.[1]?.trim();
|
|
425
|
+
return parsed ? parsed : void 0;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* True when the approve endpoint did not accept the `device_code`
|
|
429
|
+
* (`DEVICE_APPROVAL_NOT_APPROVED`, 400): unknown, another player's, bound to a
|
|
430
|
+
* different transaction or FLOW, or not yet approved. Deliberately one answer for all
|
|
431
|
+
* of those (no oracle). Check the `flow` you passed matches the one you began with,
|
|
432
|
+
* and that the poll actually said `approved` before you called approve.
|
|
433
|
+
*/
|
|
434
|
+
get isDeviceApprovalNotApproved() {
|
|
435
|
+
return this.code === "DEVICE_APPROVAL_NOT_APPROVED";
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* True when `beginDeviceApproval` was refused because an APPROVED grant for this
|
|
439
|
+
* transaction and flow is still inside its window (`DEVICE_APPROVAL_ALREADY_PENDING`,
|
|
440
|
+
* 409). The player already approved — you are missing the approve call, not a new
|
|
441
|
+
* code. If you still hold the `device_code`, call `approveWithDeviceCode`; otherwise
|
|
442
|
+
* `begin` works again after `deviceApprovalExpiresAt`. (A merely PENDING earlier grant
|
|
443
|
+
* does not 409 — `begin` supersedes it with a fresh code.)
|
|
444
|
+
*/
|
|
445
|
+
get isDeviceApprovalAlreadyPending() {
|
|
446
|
+
return this.code === "DEVICE_APPROVAL_ALREADY_PENDING";
|
|
447
|
+
}
|
|
448
|
+
/** ISO time the blocking approved grant's window closes (`expires_at` on a `DEVICE_APPROVAL_ALREADY_PENDING` 409). */
|
|
449
|
+
get deviceApprovalExpiresAt() {
|
|
450
|
+
const v = this.bodyObject()["expires_at"];
|
|
451
|
+
return typeof v === "string" && v ? v : void 0;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* True when a settle call failed on INVO's side rather than being refused by a rule
|
|
455
|
+
* (`SEND_APPROVE_FAILED` / `TRANSFER_APPROVE_FAILED` / `CONFIRM_RECEIPT_FAILED`, 400).
|
|
456
|
+
*
|
|
457
|
+
* A fault, never a rule and never retryable. Show a neutral failure and report
|
|
458
|
+
* {@link errorRef} — do not treat it as a decision about the player or the money.
|
|
459
|
+
*/
|
|
460
|
+
get isSettleFault() {
|
|
461
|
+
return this.code === "SEND_APPROVE_FAILED" || this.code === "TRANSFER_APPROVE_FAILED" || this.code === "CONFIRM_RECEIPT_FAILED";
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* The `error_ref` a settle fault carries. It names the exact server log line, so quoting
|
|
465
|
+
* it to INVO support gets the cause in one message instead of a description of symptoms.
|
|
466
|
+
*/
|
|
467
|
+
get errorRef() {
|
|
468
|
+
const v = this.bodyObject()["error_ref"];
|
|
469
|
+
return typeof v === "string" && v ? v : void 0;
|
|
470
|
+
}
|
|
384
471
|
/** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
|
|
385
472
|
get retryAfter() {
|
|
386
473
|
const v = this.bodyObject()["retry_after"];
|
|
@@ -404,7 +491,7 @@ function errorFromResponse(status, body, requestId) {
|
|
|
404
491
|
code = typeof b["error_code_public"] === "string" ? b["error_code_public"] : rawCode;
|
|
405
492
|
if (typeof b["error"] === "string") message = b["error"];
|
|
406
493
|
else if (typeof b["message"] === "string") message = b["message"];
|
|
407
|
-
if (!code && typeof b["error"] === "string" && /^(flow_paused|spending_limit_exceeded|receiver_not_enrolled_use_claim_code|no_channel_on_file|rate_limited|service_unavailable)$/.test(
|
|
494
|
+
if (!code && typeof b["error"] === "string" && /^(flow_paused|spending_limit_exceeded|receiver_not_enrolled_use_claim_code|no_channel_on_file|rate_limited|service_unavailable|authorization_pending|slow_down|expired_token|access_denied|invalid_grant)$/.test(
|
|
408
495
|
b["error"]
|
|
409
496
|
)) {
|
|
410
497
|
code = b["error"];
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ApproveResult, C as ConfirmReceiptResult, M as MountCheckoutOptions, a as CheckoutMountHandle, b as ClientConfig, c as CallOptions, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-
|
|
2
|
-
export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-
|
|
1
|
+
import { A as ApproveResult, C as ConfirmReceiptResult, M as MountCheckoutOptions, a as CheckoutMountHandle, b as ClientConfig, c as CallOptions, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-CspPkmK9.cjs';
|
|
2
|
+
export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-CspPkmK9.cjs';
|
|
3
3
|
|
|
4
4
|
/** The four device-approval flows (`begin.flow`). */
|
|
5
5
|
type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ApproveResult, C as ConfirmReceiptResult, M as MountCheckoutOptions, a as CheckoutMountHandle, b as ClientConfig, c as CallOptions, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-
|
|
2
|
-
export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-
|
|
1
|
+
import { A as ApproveResult, C as ConfirmReceiptResult, M as MountCheckoutOptions, a as CheckoutMountHandle, b as ClientConfig, c as CallOptions, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-CspPkmK9.js';
|
|
2
|
+
export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-CspPkmK9.js';
|
|
3
3
|
|
|
4
4
|
/** The four device-approval flows (`begin.flow`). */
|
|
5
5
|
type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-
|
|
2
|
-
export { InvoError } from './chunk-
|
|
1
|
+
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-23TGMTII.js';
|
|
2
|
+
export { InvoError } from './chunk-23TGMTII.js';
|
|
3
3
|
|
|
4
4
|
// src/shared/webauthn.ts
|
|
5
5
|
function malformedOptions(field) {
|