@invonetwork/web-sdk 3.6.0 → 3.8.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.
@@ -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);
@@ -342,6 +344,7 @@ var InvoError = class _InvoError extends Error {
342
344
  * instead of the backend's vocabulary. Only `Init` (and an absent status)
343
345
  * can mean "not yet"; every named status that is not Init is an outcome. */
344
346
  get isSteamAuthorizationPending() {
347
+ if (this.code === "STEAM_AUTHORIZATION_PENDING") return true;
345
348
  const b = this.body;
346
349
  if (!b || b["status"] !== "not_authorized") return false;
347
350
  const st = String(b["steam_status"] ?? "").toLowerCase();
@@ -379,6 +382,187 @@ var InvoError = class _InvoError extends Error {
379
382
  get isAlreadyRefunded() {
380
383
  return this.code === "ALREADY_REFUNDED" || this.status === 409 && /already\s+refunded/i.test(this.message);
381
384
  }
385
+ /**
386
+ * True when an approve / confirm-receipt was refused because the transaction is no
387
+ * longer awaiting that step (`TRANSACTION_NOT_PENDING`, 400). `approveWithDeviceCode`
388
+ * maps this into a non-throwing `status: "not_pending"` result; you meet it as a thrown
389
+ * error only from a raw call. Usually "already done" (a repeat call with a device_code
390
+ * that was consumed the first time) — read `currentTransactionStatus`, do not retry-loop.
391
+ *
392
+ * The message fallback is for OLDER BACKEND RELEASES. The stable
393
+ * `TRANSACTION_NOT_PENDING` code was added on 2026-09-04; before that the same four
394
+ * endpoints answered `{"status":"error","message":"Transaction not pending PIN
395
+ * verification (current status: …)"}` — or, on the two receipt flows, "…cannot be
396
+ * confirmed (current status: …)" — with **no machine code at all**. An integrator
397
+ * running against an older deployment must still be able to tell "already done" from a
398
+ * real refusal without string-matching in their own code, so the string-matching lives
399
+ * here, once.
400
+ *
401
+ * That fallback is deliberately narrow, because it is guessing. It requires all three
402
+ * of: HTTP 400, one of those two phrases, AND a readable status clause. "cannot be
403
+ * confirmed" is an ordinary English phrase that some future refusal could reasonably
404
+ * use, so a phrase match ALONE must never be able to tell a caller that money moved —
405
+ * and with the clause required, `currentStatus` is always populated on this path, which
406
+ * is what actually decides `alreadySettled`.
407
+ */
408
+ get isTransactionNotPending() {
409
+ if (this.code === "TRANSACTION_NOT_PENDING") return true;
410
+ return this.status === 400 && LEGACY_NOT_PENDING_RE.test(this.message) && LEGACY_CURRENT_STATUS_RE.test(this.message);
411
+ }
412
+ /**
413
+ * The `current_status` a `TRANSACTION_NOT_PENDING` refusal reports (e.g. `pending_claim`,
414
+ * `completed`, `expired`).
415
+ *
416
+ * Falls back to the `(current status: …)` clause inside the message, which is where the
417
+ * older releases described above put it — they carried no `current_status` field.
418
+ */
419
+ get currentTransactionStatus() {
420
+ const v = this.bodyObject()["current_status"];
421
+ if (typeof v === "string" && v) return v;
422
+ const m = LEGACY_CURRENT_STATUS_RE.exec(this.message);
423
+ const parsed = m?.[1]?.trim();
424
+ return parsed ? parsed : void 0;
425
+ }
426
+ /**
427
+ * True when the approve endpoint did not accept the `device_code`
428
+ * (`DEVICE_APPROVAL_NOT_APPROVED`, 400): unknown, another player's, bound to a
429
+ * different transaction or FLOW, or not yet approved. Deliberately one answer for all
430
+ * of those (no oracle). Check the `flow` you passed matches the one you began with,
431
+ * and that the poll actually said `approved` before you called approve.
432
+ */
433
+ get isDeviceApprovalNotApproved() {
434
+ return this.code === "DEVICE_APPROVAL_NOT_APPROVED";
435
+ }
436
+ /**
437
+ * True when `beginDeviceApproval` was refused because an APPROVED grant for this
438
+ * transaction and flow is still inside its window (`DEVICE_APPROVAL_ALREADY_PENDING`,
439
+ * 409). The player already approved — you are missing the approve call, not a new
440
+ * code. If you still hold the `device_code`, call `approveWithDeviceCode`; otherwise
441
+ * `begin` works again after `deviceApprovalExpiresAt`. (A merely PENDING earlier grant
442
+ * does not 409 — `begin` supersedes it with a fresh code.)
443
+ */
444
+ get isDeviceApprovalAlreadyPending() {
445
+ return this.code === "DEVICE_APPROVAL_ALREADY_PENDING";
446
+ }
447
+ /** ISO time the blocking approved grant's window closes (`expires_at` on a `DEVICE_APPROVAL_ALREADY_PENDING` 409). */
448
+ get deviceApprovalExpiresAt() {
449
+ const v = this.bodyObject()["expires_at"];
450
+ return typeof v === "string" && v ? v : void 0;
451
+ }
452
+ /**
453
+ * True when a settle call failed on INVO's side rather than being refused by a rule
454
+ * (`SEND_APPROVE_FAILED` / `TRANSFER_APPROVE_FAILED` / `CONFIRM_RECEIPT_FAILED`, 400).
455
+ *
456
+ * A fault, never a rule and never retryable. Show a neutral failure and report
457
+ * {@link errorRef} — do not treat it as a decision about the player or the money.
458
+ */
459
+ get isSettleFault() {
460
+ return this.code === "SEND_APPROVE_FAILED" || this.code === "TRANSFER_APPROVE_FAILED" || this.code === "CONFIRM_RECEIPT_FAILED";
461
+ }
462
+ /**
463
+ * The `error_ref` a settle fault carries. It names the exact server log line, so quoting
464
+ * it to INVO support gets the cause in one message instead of a description of symptoms.
465
+ */
466
+ get errorRef() {
467
+ const v = this.bodyObject()["error_ref"];
468
+ return typeof v === "string" && v ? v : void 0;
469
+ }
470
+ // ---- Subscriptions ----
471
+ /**
472
+ * True when a create (`subscriptions.create` / `steamInit`) was refused because the
473
+ * player already has a LIVE subscription to this `itemId` (`ACTIVE_SUBSCRIPTION_EXISTS`,
474
+ * 409). Use `existingSubscriptionId`. This is what you hit if you regenerate
475
+ * `clientRequestId` inside a retry loop: replay the same key instead.
476
+ */
477
+ get isActiveSubscriptionExists() {
478
+ return this.code === "ACTIVE_SUBSCRIPTION_EXISTS";
479
+ }
480
+ /**
481
+ * The `subscription_id` a create refusal names: the LIVE subscription on
482
+ * `ACTIVE_SUBSCRIPTION_EXISTS`, the PENDING Steam row on `STEAM_AUTHORIZATION_PENDING`,
483
+ * or the abandoned (now `expired`) row when a Steam-side failure abandoned it after creation.
484
+ */
485
+ get existingSubscriptionId() {
486
+ const v = this.bodyObject()["subscription_id"];
487
+ return typeof v === "string" && v ? v : void 0;
488
+ }
489
+ /**
490
+ * True when the same `clientRequestId` was replayed for the same player and item but
491
+ * with DIFFERENT material terms (`IDEMPOTENT_REPLAY_MISMATCH`, 409). See
492
+ * `mismatchedFields` (any of `amount_usd`, `interval`, `interval_count`, `wallet_only`,
493
+ * `funding_rail`). To change terms use `changeAmount` / `setPaymentMethod`; to create a
494
+ * new subscription use a new key.
495
+ */
496
+ get isIdempotentReplayMismatch() {
497
+ return this.code === "IDEMPOTENT_REPLAY_MISMATCH";
498
+ }
499
+ /** The `mismatched_fields` on an `IDEMPOTENT_REPLAY_MISMATCH` 409. */
500
+ get mismatchedFields() {
501
+ const v = this.bodyObject()["mismatched_fields"];
502
+ return Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
503
+ }
504
+ /**
505
+ * True when `changeAmount` tried to RAISE the price of a Steam subscription
506
+ * (`STEAM_REAUTHORIZATION_REQUIRED`, 409). The member consented to a ceiling; start a
507
+ * new Steam subscription at the new price and cancel this one. Decreases stage normally.
508
+ * The body carries `current_amount_usd` and `requested_amount_usd`.
509
+ */
510
+ get isSteamReauthorizationRequired() {
511
+ return this.code === "STEAM_REAUTHORIZATION_REQUIRED";
512
+ }
513
+ /** True when `setPaymentMethod` was called on a Steam subscription (`NOT_A_CARD_SUBSCRIPTION`, 409). A rail is fixed at creation. */
514
+ get isNotACardSubscription() {
515
+ return this.code === "NOT_A_CARD_SUBSCRIPTION";
516
+ }
517
+ /**
518
+ * True when a Steam subscription was started with a key for a non-Steam channel
519
+ * (`STEAM_CHANNEL_REQUIRED`, 409). Use the primary game key or the `steam` channel key.
520
+ */
521
+ get isSteamChannelRequired() {
522
+ return this.code === "STEAM_CHANNEL_REQUIRED";
523
+ }
524
+ /**
525
+ * True when `subscriptions.refund` targeted a period that was charged through Steam
526
+ * (`STEAM_REFUND_NOT_SUPPORTED`, 409). Refunds of Steam-charged periods are not
527
+ * supported yet; periods of a Steam subscription that the wallet covered entirely
528
+ * remain refundable in coins.
529
+ */
530
+ get isSteamRefundNotSupported() {
531
+ return this.code === "STEAM_REFUND_NOT_SUPPORTED";
532
+ }
533
+ /** True when the subscription is `canceled` or `expired` and the call cannot apply (`SUBSCRIPTION_TERMINAL`, 409). Start a new one. */
534
+ get isSubscriptionTerminal() {
535
+ return this.code === "SUBSCRIPTION_TERMINAL";
536
+ }
537
+ /**
538
+ * True when `subscriptions.steamFinalize` was called before the member completed the
539
+ * Steam authorisation (409, body `status: "not_authorized"`, with `steam_status`).
540
+ * THE NORMAL WAIT STATE: call finalize again after the overlay or checkout closes.
541
+ * The member has 24 hours; after that the row expires.
542
+ */
543
+ get isNotAuthorized() {
544
+ return this.bodyObject()["status"] === "not_authorized";
545
+ }
546
+ /**
547
+ * True when a sandbox clock call was refused for a missing, wrong or never-issued
548
+ * `X-Sandbox-Clock-Key` (`SANDBOX_CLOCK_UNAUTHORIZED`, 401). Reveal or rotate the key on
549
+ * the game's Game Settings page in the sandbox console.
550
+ */
551
+ get isSandboxClockUnauthorized() {
552
+ return this.code === "SANDBOX_CLOCK_UNAUTHORIZED";
553
+ }
554
+ /**
555
+ * True when INVO has paused this flow for maintenance (503): `flow_paused` on create /
556
+ * amount / payment-method / Steam init / card setup, `FLOW_PAUSED` on refund and the
557
+ * sandbox clock. Retry later WITH THE SAME idempotency key.
558
+ */
559
+ get isFlowPaused() {
560
+ return this.code === "flow_paused" || this.code === "FLOW_PAUSED";
561
+ }
562
+ /** True when a create was refused because the game is not `live` (`GAME_NOT_LIVE`, 403). Make it live in the console. */
563
+ get isGameNotLive() {
564
+ return this.code === "GAME_NOT_LIVE";
565
+ }
382
566
  /** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
383
567
  get retryAfter() {
384
568
  const v = this.bodyObject()["retry_after"];
@@ -402,7 +586,7 @@ function errorFromResponse(status, body, requestId) {
402
586
  code = typeof b["error_code_public"] === "string" ? b["error_code_public"] : rawCode;
403
587
  if (typeof b["error"] === "string") message = b["error"];
404
588
  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(
589
+ 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
590
  b["error"]
407
591
  )) {
408
592
  code = b["error"];
@@ -452,11 +636,11 @@ var _Http = class _Http {
452
636
  * (e.g. single-use WebAuthn assertions) are NEVER auto-retried.
453
637
  */
454
638
  async post(path, body, auth, opts) {
455
- return this.request("POST", path, body, auth, opts?.idempotent ?? false, opts?.signal);
639
+ return this.request("POST", path, body, auth, opts?.idempotent ?? false, opts?.signal, opts?.headers);
456
640
  }
457
641
  // GET is always idempotent → safe to retry.
458
642
  async get(path, auth, opts) {
459
- return this.request("GET", path, void 0, auth, true, opts?.signal);
643
+ return this.request("GET", path, void 0, auth, true, opts?.signal, opts?.headers);
460
644
  }
461
645
  authHeaders(auth) {
462
646
  switch (auth.kind) {
@@ -468,10 +652,13 @@ var _Http = class _Http {
468
652
  return {};
469
653
  }
470
654
  }
471
- async request(method, path, body, auth, idempotent, signal) {
655
+ async request(method, path, body, auth, idempotent, signal, extraHeaders) {
472
656
  const url = `${this.baseUrl}${path}`;
473
657
  const headers = {
474
658
  Accept: "application/json",
659
+ ...this.authHeaders(auth),
660
+ // Per-call extras (e.g. the sandbox clock key) — never able to override the auth header.
661
+ ...extraHeaders ?? {},
475
662
  ...this.authHeaders(auth)
476
663
  };
477
664
  if (this.userAgent) headers["User-Agent"] = this.userAgent;
@@ -659,5 +846,5 @@ function toDestinationsResult(raw, direction) {
659
846
  }
660
847
 
661
848
  export { Http, InvoError, assertSecureBaseUrl, toDestinationsResult };
662
- //# sourceMappingURL=chunk-MBKE6ULW.js.map
663
- //# sourceMappingURL=chunk-MBKE6ULW.js.map
849
+ //# sourceMappingURL=chunk-HYGBTUEJ.js.map
850
+ //# sourceMappingURL=chunk-HYGBTUEJ.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);
@@ -344,6 +346,7 @@ var InvoError = class _InvoError extends Error {
344
346
  * instead of the backend's vocabulary. Only `Init` (and an absent status)
345
347
  * can mean "not yet"; every named status that is not Init is an outcome. */
346
348
  get isSteamAuthorizationPending() {
349
+ if (this.code === "STEAM_AUTHORIZATION_PENDING") return true;
347
350
  const b = this.body;
348
351
  if (!b || b["status"] !== "not_authorized") return false;
349
352
  const st = String(b["steam_status"] ?? "").toLowerCase();
@@ -381,6 +384,187 @@ var InvoError = class _InvoError extends Error {
381
384
  get isAlreadyRefunded() {
382
385
  return this.code === "ALREADY_REFUNDED" || this.status === 409 && /already\s+refunded/i.test(this.message);
383
386
  }
387
+ /**
388
+ * True when an approve / confirm-receipt was refused because the transaction is no
389
+ * longer awaiting that step (`TRANSACTION_NOT_PENDING`, 400). `approveWithDeviceCode`
390
+ * maps this into a non-throwing `status: "not_pending"` result; you meet it as a thrown
391
+ * error only from a raw call. Usually "already done" (a repeat call with a device_code
392
+ * that was consumed the first time) — read `currentTransactionStatus`, do not retry-loop.
393
+ *
394
+ * The message fallback is for OLDER BACKEND RELEASES. The stable
395
+ * `TRANSACTION_NOT_PENDING` code was added on 2026-09-04; before that the same four
396
+ * endpoints answered `{"status":"error","message":"Transaction not pending PIN
397
+ * verification (current status: …)"}` — or, on the two receipt flows, "…cannot be
398
+ * confirmed (current status: …)" — with **no machine code at all**. An integrator
399
+ * running against an older deployment must still be able to tell "already done" from a
400
+ * real refusal without string-matching in their own code, so the string-matching lives
401
+ * here, once.
402
+ *
403
+ * That fallback is deliberately narrow, because it is guessing. It requires all three
404
+ * of: HTTP 400, one of those two phrases, AND a readable status clause. "cannot be
405
+ * confirmed" is an ordinary English phrase that some future refusal could reasonably
406
+ * use, so a phrase match ALONE must never be able to tell a caller that money moved —
407
+ * and with the clause required, `currentStatus` is always populated on this path, which
408
+ * is what actually decides `alreadySettled`.
409
+ */
410
+ get isTransactionNotPending() {
411
+ if (this.code === "TRANSACTION_NOT_PENDING") return true;
412
+ return this.status === 400 && LEGACY_NOT_PENDING_RE.test(this.message) && LEGACY_CURRENT_STATUS_RE.test(this.message);
413
+ }
414
+ /**
415
+ * The `current_status` a `TRANSACTION_NOT_PENDING` refusal reports (e.g. `pending_claim`,
416
+ * `completed`, `expired`).
417
+ *
418
+ * Falls back to the `(current status: …)` clause inside the message, which is where the
419
+ * older releases described above put it — they carried no `current_status` field.
420
+ */
421
+ get currentTransactionStatus() {
422
+ const v = this.bodyObject()["current_status"];
423
+ if (typeof v === "string" && v) return v;
424
+ const m = LEGACY_CURRENT_STATUS_RE.exec(this.message);
425
+ const parsed = m?.[1]?.trim();
426
+ return parsed ? parsed : void 0;
427
+ }
428
+ /**
429
+ * True when the approve endpoint did not accept the `device_code`
430
+ * (`DEVICE_APPROVAL_NOT_APPROVED`, 400): unknown, another player's, bound to a
431
+ * different transaction or FLOW, or not yet approved. Deliberately one answer for all
432
+ * of those (no oracle). Check the `flow` you passed matches the one you began with,
433
+ * and that the poll actually said `approved` before you called approve.
434
+ */
435
+ get isDeviceApprovalNotApproved() {
436
+ return this.code === "DEVICE_APPROVAL_NOT_APPROVED";
437
+ }
438
+ /**
439
+ * True when `beginDeviceApproval` was refused because an APPROVED grant for this
440
+ * transaction and flow is still inside its window (`DEVICE_APPROVAL_ALREADY_PENDING`,
441
+ * 409). The player already approved — you are missing the approve call, not a new
442
+ * code. If you still hold the `device_code`, call `approveWithDeviceCode`; otherwise
443
+ * `begin` works again after `deviceApprovalExpiresAt`. (A merely PENDING earlier grant
444
+ * does not 409 — `begin` supersedes it with a fresh code.)
445
+ */
446
+ get isDeviceApprovalAlreadyPending() {
447
+ return this.code === "DEVICE_APPROVAL_ALREADY_PENDING";
448
+ }
449
+ /** ISO time the blocking approved grant's window closes (`expires_at` on a `DEVICE_APPROVAL_ALREADY_PENDING` 409). */
450
+ get deviceApprovalExpiresAt() {
451
+ const v = this.bodyObject()["expires_at"];
452
+ return typeof v === "string" && v ? v : void 0;
453
+ }
454
+ /**
455
+ * True when a settle call failed on INVO's side rather than being refused by a rule
456
+ * (`SEND_APPROVE_FAILED` / `TRANSFER_APPROVE_FAILED` / `CONFIRM_RECEIPT_FAILED`, 400).
457
+ *
458
+ * A fault, never a rule and never retryable. Show a neutral failure and report
459
+ * {@link errorRef} — do not treat it as a decision about the player or the money.
460
+ */
461
+ get isSettleFault() {
462
+ return this.code === "SEND_APPROVE_FAILED" || this.code === "TRANSFER_APPROVE_FAILED" || this.code === "CONFIRM_RECEIPT_FAILED";
463
+ }
464
+ /**
465
+ * The `error_ref` a settle fault carries. It names the exact server log line, so quoting
466
+ * it to INVO support gets the cause in one message instead of a description of symptoms.
467
+ */
468
+ get errorRef() {
469
+ const v = this.bodyObject()["error_ref"];
470
+ return typeof v === "string" && v ? v : void 0;
471
+ }
472
+ // ---- Subscriptions ----
473
+ /**
474
+ * True when a create (`subscriptions.create` / `steamInit`) was refused because the
475
+ * player already has a LIVE subscription to this `itemId` (`ACTIVE_SUBSCRIPTION_EXISTS`,
476
+ * 409). Use `existingSubscriptionId`. This is what you hit if you regenerate
477
+ * `clientRequestId` inside a retry loop: replay the same key instead.
478
+ */
479
+ get isActiveSubscriptionExists() {
480
+ return this.code === "ACTIVE_SUBSCRIPTION_EXISTS";
481
+ }
482
+ /**
483
+ * The `subscription_id` a create refusal names: the LIVE subscription on
484
+ * `ACTIVE_SUBSCRIPTION_EXISTS`, the PENDING Steam row on `STEAM_AUTHORIZATION_PENDING`,
485
+ * or the abandoned (now `expired`) row when a Steam-side failure abandoned it after creation.
486
+ */
487
+ get existingSubscriptionId() {
488
+ const v = this.bodyObject()["subscription_id"];
489
+ return typeof v === "string" && v ? v : void 0;
490
+ }
491
+ /**
492
+ * True when the same `clientRequestId` was replayed for the same player and item but
493
+ * with DIFFERENT material terms (`IDEMPOTENT_REPLAY_MISMATCH`, 409). See
494
+ * `mismatchedFields` (any of `amount_usd`, `interval`, `interval_count`, `wallet_only`,
495
+ * `funding_rail`). To change terms use `changeAmount` / `setPaymentMethod`; to create a
496
+ * new subscription use a new key.
497
+ */
498
+ get isIdempotentReplayMismatch() {
499
+ return this.code === "IDEMPOTENT_REPLAY_MISMATCH";
500
+ }
501
+ /** The `mismatched_fields` on an `IDEMPOTENT_REPLAY_MISMATCH` 409. */
502
+ get mismatchedFields() {
503
+ const v = this.bodyObject()["mismatched_fields"];
504
+ return Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
505
+ }
506
+ /**
507
+ * True when `changeAmount` tried to RAISE the price of a Steam subscription
508
+ * (`STEAM_REAUTHORIZATION_REQUIRED`, 409). The member consented to a ceiling; start a
509
+ * new Steam subscription at the new price and cancel this one. Decreases stage normally.
510
+ * The body carries `current_amount_usd` and `requested_amount_usd`.
511
+ */
512
+ get isSteamReauthorizationRequired() {
513
+ return this.code === "STEAM_REAUTHORIZATION_REQUIRED";
514
+ }
515
+ /** True when `setPaymentMethod` was called on a Steam subscription (`NOT_A_CARD_SUBSCRIPTION`, 409). A rail is fixed at creation. */
516
+ get isNotACardSubscription() {
517
+ return this.code === "NOT_A_CARD_SUBSCRIPTION";
518
+ }
519
+ /**
520
+ * True when a Steam subscription was started with a key for a non-Steam channel
521
+ * (`STEAM_CHANNEL_REQUIRED`, 409). Use the primary game key or the `steam` channel key.
522
+ */
523
+ get isSteamChannelRequired() {
524
+ return this.code === "STEAM_CHANNEL_REQUIRED";
525
+ }
526
+ /**
527
+ * True when `subscriptions.refund` targeted a period that was charged through Steam
528
+ * (`STEAM_REFUND_NOT_SUPPORTED`, 409). Refunds of Steam-charged periods are not
529
+ * supported yet; periods of a Steam subscription that the wallet covered entirely
530
+ * remain refundable in coins.
531
+ */
532
+ get isSteamRefundNotSupported() {
533
+ return this.code === "STEAM_REFUND_NOT_SUPPORTED";
534
+ }
535
+ /** True when the subscription is `canceled` or `expired` and the call cannot apply (`SUBSCRIPTION_TERMINAL`, 409). Start a new one. */
536
+ get isSubscriptionTerminal() {
537
+ return this.code === "SUBSCRIPTION_TERMINAL";
538
+ }
539
+ /**
540
+ * True when `subscriptions.steamFinalize` was called before the member completed the
541
+ * Steam authorisation (409, body `status: "not_authorized"`, with `steam_status`).
542
+ * THE NORMAL WAIT STATE: call finalize again after the overlay or checkout closes.
543
+ * The member has 24 hours; after that the row expires.
544
+ */
545
+ get isNotAuthorized() {
546
+ return this.bodyObject()["status"] === "not_authorized";
547
+ }
548
+ /**
549
+ * True when a sandbox clock call was refused for a missing, wrong or never-issued
550
+ * `X-Sandbox-Clock-Key` (`SANDBOX_CLOCK_UNAUTHORIZED`, 401). Reveal or rotate the key on
551
+ * the game's Game Settings page in the sandbox console.
552
+ */
553
+ get isSandboxClockUnauthorized() {
554
+ return this.code === "SANDBOX_CLOCK_UNAUTHORIZED";
555
+ }
556
+ /**
557
+ * True when INVO has paused this flow for maintenance (503): `flow_paused` on create /
558
+ * amount / payment-method / Steam init / card setup, `FLOW_PAUSED` on refund and the
559
+ * sandbox clock. Retry later WITH THE SAME idempotency key.
560
+ */
561
+ get isFlowPaused() {
562
+ return this.code === "flow_paused" || this.code === "FLOW_PAUSED";
563
+ }
564
+ /** True when a create was refused because the game is not `live` (`GAME_NOT_LIVE`, 403). Make it live in the console. */
565
+ get isGameNotLive() {
566
+ return this.code === "GAME_NOT_LIVE";
567
+ }
384
568
  /** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
385
569
  get retryAfter() {
386
570
  const v = this.bodyObject()["retry_after"];
@@ -404,7 +588,7 @@ function errorFromResponse(status, body, requestId) {
404
588
  code = typeof b["error_code_public"] === "string" ? b["error_code_public"] : rawCode;
405
589
  if (typeof b["error"] === "string") message = b["error"];
406
590
  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(
591
+ 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
592
  b["error"]
409
593
  )) {
410
594
  code = b["error"];
@@ -454,11 +638,11 @@ var _Http = class _Http {
454
638
  * (e.g. single-use WebAuthn assertions) are NEVER auto-retried.
455
639
  */
456
640
  async post(path, body, auth, opts) {
457
- return this.request("POST", path, body, auth, opts?.idempotent ?? false, opts?.signal);
641
+ return this.request("POST", path, body, auth, opts?.idempotent ?? false, opts?.signal, opts?.headers);
458
642
  }
459
643
  // GET is always idempotent → safe to retry.
460
644
  async get(path, auth, opts) {
461
- return this.request("GET", path, void 0, auth, true, opts?.signal);
645
+ return this.request("GET", path, void 0, auth, true, opts?.signal, opts?.headers);
462
646
  }
463
647
  authHeaders(auth) {
464
648
  switch (auth.kind) {
@@ -470,10 +654,13 @@ var _Http = class _Http {
470
654
  return {};
471
655
  }
472
656
  }
473
- async request(method, path, body, auth, idempotent, signal) {
657
+ async request(method, path, body, auth, idempotent, signal, extraHeaders) {
474
658
  const url = `${this.baseUrl}${path}`;
475
659
  const headers = {
476
660
  Accept: "application/json",
661
+ ...this.authHeaders(auth),
662
+ // Per-call extras (e.g. the sandbox clock key) — never able to override the auth header.
663
+ ...extraHeaders ?? {},
477
664
  ...this.authHeaders(auth)
478
665
  };
479
666
  if (this.userAgent) headers["User-Agent"] = this.userAgent;
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-ZNoG09S5.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-ZNoG09S5.cjs';
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-DqRuqbqI.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-DqRuqbqI.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-ZNoG09S5.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-ZNoG09S5.js';
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-DqRuqbqI.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-DqRuqbqI.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-MBKE6ULW.js';
2
- export { InvoError } from './chunk-MBKE6ULW.js';
1
+ import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-HYGBTUEJ.js';
2
+ export { InvoError } from './chunk-HYGBTUEJ.js';
3
3
 
4
4
  // src/shared/webauthn.ts
5
5
  function malformedOptions(field) {