@invonetwork/web-sdk 3.7.0 → 3.8.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.cjs CHANGED
@@ -346,6 +346,7 @@ var InvoError = class _InvoError extends Error {
346
346
  * instead of the backend's vocabulary. Only `Init` (and an absent status)
347
347
  * can mean "not yet"; every named status that is not Init is an outcome. */
348
348
  get isSteamAuthorizationPending() {
349
+ if (this.code === "STEAM_AUTHORIZATION_PENDING") return true;
349
350
  const b = this.body;
350
351
  if (!b || b["status"] !== "not_authorized") return false;
351
352
  const st = String(b["steam_status"] ?? "").toLowerCase();
@@ -468,6 +469,102 @@ var InvoError = class _InvoError extends Error {
468
469
  const v = this.bodyObject()["error_ref"];
469
470
  return typeof v === "string" && v ? v : void 0;
470
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
+ }
471
568
  /** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
472
569
  get retryAfter() {
473
570
  const v = this.bodyObject()["retry_after"];
@@ -541,11 +638,11 @@ var _Http = class _Http {
541
638
  * (e.g. single-use WebAuthn assertions) are NEVER auto-retried.
542
639
  */
543
640
  async post(path, body, auth, opts) {
544
- 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);
545
642
  }
546
643
  // GET is always idempotent → safe to retry.
547
644
  async get(path, auth, opts) {
548
- 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);
549
646
  }
550
647
  authHeaders(auth) {
551
648
  switch (auth.kind) {
@@ -557,10 +654,13 @@ var _Http = class _Http {
557
654
  return {};
558
655
  }
559
656
  }
560
- async request(method, path, body, auth, idempotent, signal) {
657
+ async request(method, path, body, auth, idempotent, signal, extraHeaders) {
561
658
  const url = `${this.baseUrl}${path}`;
562
659
  const headers = {
563
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 ?? {},
564
664
  ...this.authHeaders(auth)
565
665
  };
566
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-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';
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-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';
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-23TGMTII.js';
2
- export { InvoError } from './chunk-23TGMTII.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) {