@invonetwork/web-sdk 3.32.0 → 3.34.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,6 +1,6 @@
1
- import { I as InvoError, H as Http, $ as AuthHeader, g as CallOptions, a0 as PlatformPurchaseInput, a1 as PlatformPurchaseResult, a2 as PlatformOrderStatusResult, a3 as PlatformPurchaseHistoryQuery, a4 as PlatformPurchaseHistoryResult, a5 as PlatformRefundInput, a6 as PlatformRefundResult, a7 as CreateSubscriptionInput, a8 as SubscriptionResult, a9 as GetSubscriptionOptions, aa as GetSubscriptionResult, ab as ListSubscriptionsOptions, ac as SubscriptionListResult, ad as CancelSubscriptionOptions, ae as CancelResult, af as ChangeAmountResult, ag as SetPaymentMethodInput, ah as SetPaymentMethodResult, ai as RefundSubscriptionInput, aj as RefundResult, ak as SteamSubscriptionInitInput, al as SteamInitResult, am as SteamFinalizeSubscriptionResult, an as CardSetupSessionInput, ao as CardSetupSessionResult, ap as CardSetupInput, aq as CardSetupResult, ar as CardSetupConfirmInput, as as CardSetupConfirmResult, at as PlayerCardsResult, au as SandboxClockResult, av as SandboxFailureOutcome, aw as SandboxForceFailureOptions, ax as SandboxForceAuthChallengeOptions, ay as ServerConfig, az as MintPlayerTokenInput, aA as PlayerToken, aB as RegisterPlayerInput, aC as RegisterPlayerResult, aD as UpdatePlayerPhoneInput, aE as UpdatePlayerPhoneResult, aF as RequestPhoneChangeInput, aG as RequestPhoneChangeResult, aH as PhoneChangeRequest, aI as InitiateSendInput, aJ as InitiateResult, aK as InitiateTransferInput, aL as CreateCheckoutInput, aM as CreateCheckoutResult, a as PurchaseStatusResult, aN as PurchaseInput, aO as PurchaseResult, aP as CurrencyPurchaseQuoteInput, aQ as CurrencyPurchaseQuote, aR as ConfirmPaymentResult, aS as OrderDetailsResult, aT as SteamPacksQuery, aU as SteamPacksResult, aV as SteamInitPurchaseInput, aW as SteamInitPurchaseResult, aX as SteamFinalizeInput, aY as SteamFinalizeResult, aZ as PurchaseItemInput, a_ as PurchaseItemResult, a$ as ItemHistoryQuery, b0 as ItemHistoryResult, b1 as ItemOrderQuery, b2 as PlayerActivityQuery, b3 as PlayerActivityResult, b4 as PlayerActivityEntry, b5 as PlayerBalanceQuery, b6 as PlayerBalanceResult, q as LoyaltyCardsResult, b7 as InboundPendingQuery, b8 as InboundPendingResult, b9 as LinkedIdentitiesQuery, ba as LinkedIdentitiesResult, bb as SmsVerifyResult, bc as ClaimTransferInput, bd as ClaimResult, be as ClaimCurrencyInput, bf as TransactionStatusResult, bg as GuardianApprovalStatusResult, bh as ServerDestinationsQuery, p as DestinationsResult, bi as PhoneShareContact, bj as PhoneShareInitiateResult, bk as PhoneShareApproveInput, bl as PhoneShareApproveResult, bm as PhoneShareStatusResult, bn as BeginDeviceApprovalInput, bo as DeviceApprovalGrant, bp as PollDeviceApprovalInput, bq as DeviceApprovalPollResult, br as ConfirmDeviceEnrollmentInput, bs as ConfirmDeviceEnrollmentResult, bt as ApproveWithDeviceCodeInput, bu as DeviceApprovalSettleResult, bv as CompleteDeviceApprovalInput, bw as CompleteDeviceApprovalResult } from './types-CaPHNjOU.js';
1
+ import { I as InvoError, H as Http, $ as AuthHeader, g as CallOptions, a0 as PlatformPurchaseInput, a1 as PlatformPurchaseResult, a2 as PlatformApprovalResult, a3 as PlatformOrderStatusResult, a4 as PlatformPurchaseHistoryQuery, a5 as PlatformPurchaseHistoryResult, a6 as PlatformRefundInput, a7 as PlatformRefundResult, a8 as CreateSubscriptionInput, a9 as SubscriptionResult, aa as GetSubscriptionOptions, ab as GetSubscriptionResult, ac as ListSubscriptionsOptions, ad as SubscriptionListResult, ae as CancelSubscriptionOptions, af as CancelResult, ag as ChangeAmountResult, ah as SetPaymentMethodInput, ai as SetPaymentMethodResult, aj as RefundSubscriptionInput, ak as RefundResult, al as SteamSubscriptionInitInput, am as SteamInitResult, an as SteamFinalizeSubscriptionResult, ao as CardSetupSessionInput, ap as CardSetupSessionResult, aq as CardSetupInput, ar as CardSetupResult, as as CardSetupConfirmInput, at as CardSetupConfirmResult, au as PlayerCardsResult, av as SandboxClockResult, aw as SandboxFailureOutcome, ax as SandboxForceFailureOptions, ay as SandboxForceAuthChallengeOptions, az as ServerConfig, aA as MintPlayerTokenInput, aB as PlayerToken, aC as RegisterPlayerInput, aD as RegisterPlayerResult, aE as UpdatePlayerPhoneInput, aF as UpdatePlayerPhoneResult, aG as RequestPhoneChangeInput, aH as RequestPhoneChangeResult, aI as PhoneChangeRequest, aJ as InitiateSendInput, aK as InitiateResult, aL as InitiateTransferInput, aM as CreateCheckoutInput, aN as CreateCheckoutResult, a as PurchaseStatusResult, aO as PurchaseInput, aP as PurchaseResult, aQ as CurrencyPurchaseQuoteInput, aR as CurrencyPurchaseQuote, aS as ConfirmPaymentResult, aT as OrderDetailsResult, aU as SteamPacksQuery, aV as SteamPacksResult, aW as SteamInitPurchaseInput, aX as SteamInitPurchaseResult, aY as SteamFinalizeInput, aZ as SteamFinalizeResult, a_ as PurchaseItemInput, a$ as PurchaseItemResult, b0 as ItemHistoryQuery, b1 as ItemHistoryResult, b2 as ItemOrderQuery, b3 as PlayerActivityQuery, b4 as PlayerActivityResult, b5 as PlayerActivityEntry, b6 as PlayerBalanceQuery, b7 as PlayerBalanceResult, q as LoyaltyCardsResult, b8 as InboundPendingQuery, b9 as InboundPendingResult, ba as LinkedIdentitiesQuery, bb as LinkedIdentitiesResult, bc as SmsVerifyResult, bd as ClaimTransferInput, be as ClaimResult, bf as ClaimCurrencyInput, bg as TransactionStatusResult, bh as GuardianApprovalStatusResult, bi as ServerDestinationsQuery, p as DestinationsResult, bj as PhoneShareContact, bk as PhoneShareInitiateResult, bl as PhoneShareApproveInput, bm as PhoneShareApproveResult, bn as PhoneShareStatusResult, bo as BeginDeviceApprovalInput, bp as DeviceApprovalGrant, bq as PollDeviceApprovalInput, br as DeviceApprovalPollResult, bs as ConfirmDeviceEnrollmentInput, bt as ConfirmDeviceEnrollmentResult, bu as ApproveWithDeviceCodeInput, bv as DeviceApprovalSettleResult, bw as CompleteDeviceApprovalInput, bx as CompleteDeviceApprovalResult } from './types-Ctn8N2_l.js';
2
2
  import { b as ReportServerGameEventInput, a as ReportGameEventResult } from './loyalty-events-CmDw2ZoR.js';
3
- import './version-CqwGhQXV.js';
3
+ import './version-Ce_pLpJf.js';
4
4
 
5
5
  /**
6
6
  * Pick the INVO environment from the game secret alone (3.28.0).
@@ -10,13 +10,46 @@ import './version-CqwGhQXV.js';
10
10
  * your code changes.
11
11
  *
12
12
  * - The public demo key starts with `ivsdk_demo_`: always the sandbox, no network call.
13
- * - Any other key: INVO is asked once (`GET /api/sdk/key-environment`), production first,
14
- * then the sandbox. The answer is cached per key for the life of the process.
13
+ * - A test key starts with `ivsdk_test_`: always the sandbox, no network call (3.34.0).
14
+ * - A live key starts with `ivsdk_live_`: always production, no network call (3.34.0).
15
+ * - Any other key (the original `ivsdk_...` keys, which keep working): INVO is asked once
16
+ * (`GET /api/sdk/key-environment`), production first, then the sandbox. The answer is
17
+ * cached per key for the life of the process.
15
18
  */
16
19
  declare const PRODUCTION_BASE_URL = "https://invo.network";
17
20
  declare const SANDBOX_BASE_URL = "https://sandbox.invo.network/sandbox";
18
21
  declare const DEMO_KEY_PREFIX = "ivsdk_demo_";
22
+ /** Keys for the sandbox (3.34.0). */
23
+ declare const TEST_KEY_PREFIX = "ivsdk_test_";
24
+ /** Keys for production (3.34.0). */
25
+ declare const LIVE_KEY_PREFIX = "ivsdk_live_";
19
26
  type InvoEnvironment = "production" | "sandbox";
27
+ /**
28
+ * The environment a key's prefix names, with no network call (3.34.0): `"production"` for
29
+ * `ivsdk_live_`, `"sandbox"` for `ivsdk_test_` and the public demo key `ivsdk_demo_`, and
30
+ * `null` for any other key (an unprefixed `ivsdk_...` key is looked up with
31
+ * {@link resolveEnvironment}).
32
+ */
33
+ declare function environmentFromKeyPrefix(gameSecret: string | undefined | null): InvoEnvironment | null;
34
+ /**
35
+ * The INVO environment a base URL points at, or `null` when it is not one of INVO's hosts
36
+ * (your own proxy, `localhost`, anything else) (3.34.0). `sandbox.invo.network` is the
37
+ * sandbox; `invo.network` (and `www.`) is production, unless its path starts with
38
+ * `/sandbox`. A trailing slash or an `/api` suffix makes no difference.
39
+ */
40
+ declare function environmentForBaseUrl(baseUrl: string | undefined | null): InvoEnvironment | null;
41
+ /**
42
+ * A prefixed key (`ivsdk_live_` / `ivsdk_test_`) was configured against the other INVO
43
+ * environment (3.34.0). Thrown at construction, before any request. The message says what
44
+ * to change.
45
+ */
46
+ declare class KeyEnvironmentMismatchError extends Error {
47
+ /** The environment the key's prefix names. */
48
+ readonly keyEnvironment: InvoEnvironment;
49
+ /** The environment the configuration points at. */
50
+ readonly configuredEnvironment: InvoEnvironment;
51
+ constructor(message: string, keyEnvironment: InvoEnvironment, configuredEnvironment: InvoEnvironment);
52
+ }
20
53
  /** Neither environment recognised the key, or INVO could not be reached. */
21
54
  declare class EnvironmentUnknownError extends Error {
22
55
  constructor(message: string);
@@ -1207,6 +1240,17 @@ declare class PlatformCommerceServer {
1207
1240
  * `err.isNotPlatformTenant` (403).
1208
1241
  */
1209
1242
  purchase(input: PlatformPurchaseInput, opts?: CallOptions): Promise<PlatformPurchaseResult>;
1243
+ /** Read a buyer-approved purchase (3.33.0) by `approvalId` or by your `clientRequestId`
1244
+ * (exactly one). A fallback to the webhooks: `completed` carries `orderId`; an ending
1245
+ * without a sale carries `reason`. Throws `err.isApprovalNotFound` (404). */
1246
+ getApproval(key: {
1247
+ approvalId?: string;
1248
+ clientRequestId?: string;
1249
+ }, opts?: CallOptions): Promise<PlatformApprovalResult>;
1250
+ /** Withdraw a buyer-approved purchase that is still waiting (3.33.0).
1251
+ * `platform_commerce.declined` follows with reason `cancelled`. Throws
1252
+ * `err.isApprovalAlreadyEnded` (409) when it had already ended. */
1253
+ cancelApproval(approvalId: string, opts?: CallOptions): Promise<PlatformApprovalResult>;
1210
1254
  /** Poll an order's status: `completed` (balance immediately; card after the webhook),
1211
1255
  * `pending_payment` (card awaiting confirmation), or `refunded`. Once the sale has settled,
1212
1256
  * `invoFeeUsd` / `partnerShareUsd` say what INVO kept and what you earned (additive). */
@@ -2204,4 +2248,4 @@ declare class InvoServer {
2204
2248
  private toInitiateResult;
2205
2249
  }
2206
2250
 
2207
- export { type SubscriptionRenewedData as $, type RegisterPayeeResult as A, type RequestPayoutInput as B, CardsServer as C, DEMO_KEY_PREFIX as D, EnvironmentUnknownError as E, type RequestPayoutResult as F, type ReturnReasonCode as G, SandboxServer as H, InvoServer as I, SandboxSubscriptionsServer as J, type SubscriptionAuthenticationRequiredData as K, type ListPayeesQuery as L, type SubscriptionCanceledData as M, type SubscriptionEventCommon as N, type SubscriptionExpiredData as O, PRODUCTION_BASE_URL as P, type SubscriptionPastDueData as Q, type RegisterPayeeInput as R, SANDBOX_BASE_URL as S, type SubscriptionPaymentFailedData as T, type SubscriptionRefundApprovedData as U, type SubscriptionRefundDetail as V, type SubscriptionRefundRejectedData as W, type SubscriptionRefundRequestData as X, type SubscriptionRefundedData as Y, type SubscriptionRenewalFunding as Z, type SubscriptionRenewalSplit as _, type InvoEnvironment as a, type SubscriptionRevenueShareAttribution as a0, type SubscriptionTrialEventFields as a1, SubscriptionsServer as a2, type TransferEventData as a3, type VerifyWebhookOptions as a4, type WebhookHandlerOptions as a5, createWebhookHandler as a6, verifyWebhook as a7, verifyWebhookAsync as a8, baseUrlForKey as b, type IdentityPasskeyResetData as c, type InvoWebhookEvent as d, type ItemPurchasedData as e, type ListPayeesResult as f, type ListPayoutsQuery as g, type ListPayoutsResult as h, isDemoKey as i, type PayableBlocker as j, type Payee as k, type PayeeInvite as l, type PayeeStatus as m, type PayeeStatusChangedData as n, type Payout as o, type PayoutStatus as p, type PayoutStatusChangedData as q, resolveEnvironment as r, PayoutsServer as s, type PlatformCommercePurchasedData as t, type PlatformCommerceRefundedData as u, verifyInvoSignature as v, PlatformCommerceServer as w, type PlayerPhoneChangedData as x, type PurchaseCompletedData as y, type PurchaseEventData as z };
2251
+ export { type SubscriptionRefundRejectedData as $, type PlayerPhoneChangedData as A, type PurchaseCompletedData as B, CardsServer as C, DEMO_KEY_PREFIX as D, EnvironmentUnknownError as E, type PurchaseEventData as F, type RegisterPayeeResult as G, type RequestPayoutInput as H, InvoServer as I, type RequestPayoutResult as J, KeyEnvironmentMismatchError as K, LIVE_KEY_PREFIX as L, type ReturnReasonCode as M, SandboxServer as N, SandboxSubscriptionsServer as O, PRODUCTION_BASE_URL as P, type SubscriptionAuthenticationRequiredData as Q, type RegisterPayeeInput as R, SANDBOX_BASE_URL as S, TEST_KEY_PREFIX as T, type SubscriptionCanceledData as U, type SubscriptionEventCommon as V, type SubscriptionExpiredData as W, type SubscriptionPastDueData as X, type SubscriptionPaymentFailedData as Y, type SubscriptionRefundApprovedData as Z, type SubscriptionRefundDetail as _, type InvoEnvironment as a, type SubscriptionRefundRequestData as a0, type SubscriptionRefundedData as a1, type SubscriptionRenewalFunding as a2, type SubscriptionRenewalSplit as a3, type SubscriptionRenewedData as a4, type SubscriptionRevenueShareAttribution as a5, type SubscriptionTrialEventFields as a6, SubscriptionsServer as a7, type TransferEventData as a8, type VerifyWebhookOptions as a9, type WebhookHandlerOptions as aa, createWebhookHandler as ab, verifyWebhook as ac, verifyWebhookAsync as ad, baseUrlForKey as b, environmentFromKeyPrefix as c, type IdentityPasskeyResetData as d, environmentForBaseUrl as e, type InvoWebhookEvent as f, type ItemPurchasedData as g, type ListPayeesQuery as h, isDemoKey as i, type ListPayeesResult as j, type ListPayoutsQuery as k, type ListPayoutsResult as l, type PayableBlocker as m, type Payee as n, type PayeeInvite as o, type PayeeStatus as p, type PayeeStatusChangedData as q, resolveEnvironment as r, type Payout as s, type PayoutStatus as t, type PayoutStatusChangedData as u, verifyInvoSignature as v, PayoutsServer as w, type PlatformCommercePurchasedData as x, type PlatformCommerceRefundedData as y, PlatformCommerceServer as z };
@@ -1,6 +1,6 @@
1
- import { I as InvoError, H as Http, $ as AuthHeader, g as CallOptions, a0 as PlatformPurchaseInput, a1 as PlatformPurchaseResult, a2 as PlatformOrderStatusResult, a3 as PlatformPurchaseHistoryQuery, a4 as PlatformPurchaseHistoryResult, a5 as PlatformRefundInput, a6 as PlatformRefundResult, a7 as CreateSubscriptionInput, a8 as SubscriptionResult, a9 as GetSubscriptionOptions, aa as GetSubscriptionResult, ab as ListSubscriptionsOptions, ac as SubscriptionListResult, ad as CancelSubscriptionOptions, ae as CancelResult, af as ChangeAmountResult, ag as SetPaymentMethodInput, ah as SetPaymentMethodResult, ai as RefundSubscriptionInput, aj as RefundResult, ak as SteamSubscriptionInitInput, al as SteamInitResult, am as SteamFinalizeSubscriptionResult, an as CardSetupSessionInput, ao as CardSetupSessionResult, ap as CardSetupInput, aq as CardSetupResult, ar as CardSetupConfirmInput, as as CardSetupConfirmResult, at as PlayerCardsResult, au as SandboxClockResult, av as SandboxFailureOutcome, aw as SandboxForceFailureOptions, ax as SandboxForceAuthChallengeOptions, ay as ServerConfig, az as MintPlayerTokenInput, aA as PlayerToken, aB as RegisterPlayerInput, aC as RegisterPlayerResult, aD as UpdatePlayerPhoneInput, aE as UpdatePlayerPhoneResult, aF as RequestPhoneChangeInput, aG as RequestPhoneChangeResult, aH as PhoneChangeRequest, aI as InitiateSendInput, aJ as InitiateResult, aK as InitiateTransferInput, aL as CreateCheckoutInput, aM as CreateCheckoutResult, a as PurchaseStatusResult, aN as PurchaseInput, aO as PurchaseResult, aP as CurrencyPurchaseQuoteInput, aQ as CurrencyPurchaseQuote, aR as ConfirmPaymentResult, aS as OrderDetailsResult, aT as SteamPacksQuery, aU as SteamPacksResult, aV as SteamInitPurchaseInput, aW as SteamInitPurchaseResult, aX as SteamFinalizeInput, aY as SteamFinalizeResult, aZ as PurchaseItemInput, a_ as PurchaseItemResult, a$ as ItemHistoryQuery, b0 as ItemHistoryResult, b1 as ItemOrderQuery, b2 as PlayerActivityQuery, b3 as PlayerActivityResult, b4 as PlayerActivityEntry, b5 as PlayerBalanceQuery, b6 as PlayerBalanceResult, q as LoyaltyCardsResult, b7 as InboundPendingQuery, b8 as InboundPendingResult, b9 as LinkedIdentitiesQuery, ba as LinkedIdentitiesResult, bb as SmsVerifyResult, bc as ClaimTransferInput, bd as ClaimResult, be as ClaimCurrencyInput, bf as TransactionStatusResult, bg as GuardianApprovalStatusResult, bh as ServerDestinationsQuery, p as DestinationsResult, bi as PhoneShareContact, bj as PhoneShareInitiateResult, bk as PhoneShareApproveInput, bl as PhoneShareApproveResult, bm as PhoneShareStatusResult, bn as BeginDeviceApprovalInput, bo as DeviceApprovalGrant, bp as PollDeviceApprovalInput, bq as DeviceApprovalPollResult, br as ConfirmDeviceEnrollmentInput, bs as ConfirmDeviceEnrollmentResult, bt as ApproveWithDeviceCodeInput, bu as DeviceApprovalSettleResult, bv as CompleteDeviceApprovalInput, bw as CompleteDeviceApprovalResult } from './types-CaPHNjOU.cjs';
1
+ import { I as InvoError, H as Http, $ as AuthHeader, g as CallOptions, a0 as PlatformPurchaseInput, a1 as PlatformPurchaseResult, a2 as PlatformApprovalResult, a3 as PlatformOrderStatusResult, a4 as PlatformPurchaseHistoryQuery, a5 as PlatformPurchaseHistoryResult, a6 as PlatformRefundInput, a7 as PlatformRefundResult, a8 as CreateSubscriptionInput, a9 as SubscriptionResult, aa as GetSubscriptionOptions, ab as GetSubscriptionResult, ac as ListSubscriptionsOptions, ad as SubscriptionListResult, ae as CancelSubscriptionOptions, af as CancelResult, ag as ChangeAmountResult, ah as SetPaymentMethodInput, ai as SetPaymentMethodResult, aj as RefundSubscriptionInput, ak as RefundResult, al as SteamSubscriptionInitInput, am as SteamInitResult, an as SteamFinalizeSubscriptionResult, ao as CardSetupSessionInput, ap as CardSetupSessionResult, aq as CardSetupInput, ar as CardSetupResult, as as CardSetupConfirmInput, at as CardSetupConfirmResult, au as PlayerCardsResult, av as SandboxClockResult, aw as SandboxFailureOutcome, ax as SandboxForceFailureOptions, ay as SandboxForceAuthChallengeOptions, az as ServerConfig, aA as MintPlayerTokenInput, aB as PlayerToken, aC as RegisterPlayerInput, aD as RegisterPlayerResult, aE as UpdatePlayerPhoneInput, aF as UpdatePlayerPhoneResult, aG as RequestPhoneChangeInput, aH as RequestPhoneChangeResult, aI as PhoneChangeRequest, aJ as InitiateSendInput, aK as InitiateResult, aL as InitiateTransferInput, aM as CreateCheckoutInput, aN as CreateCheckoutResult, a as PurchaseStatusResult, aO as PurchaseInput, aP as PurchaseResult, aQ as CurrencyPurchaseQuoteInput, aR as CurrencyPurchaseQuote, aS as ConfirmPaymentResult, aT as OrderDetailsResult, aU as SteamPacksQuery, aV as SteamPacksResult, aW as SteamInitPurchaseInput, aX as SteamInitPurchaseResult, aY as SteamFinalizeInput, aZ as SteamFinalizeResult, a_ as PurchaseItemInput, a$ as PurchaseItemResult, b0 as ItemHistoryQuery, b1 as ItemHistoryResult, b2 as ItemOrderQuery, b3 as PlayerActivityQuery, b4 as PlayerActivityResult, b5 as PlayerActivityEntry, b6 as PlayerBalanceQuery, b7 as PlayerBalanceResult, q as LoyaltyCardsResult, b8 as InboundPendingQuery, b9 as InboundPendingResult, ba as LinkedIdentitiesQuery, bb as LinkedIdentitiesResult, bc as SmsVerifyResult, bd as ClaimTransferInput, be as ClaimResult, bf as ClaimCurrencyInput, bg as TransactionStatusResult, bh as GuardianApprovalStatusResult, bi as ServerDestinationsQuery, p as DestinationsResult, bj as PhoneShareContact, bk as PhoneShareInitiateResult, bl as PhoneShareApproveInput, bm as PhoneShareApproveResult, bn as PhoneShareStatusResult, bo as BeginDeviceApprovalInput, bp as DeviceApprovalGrant, bq as PollDeviceApprovalInput, br as DeviceApprovalPollResult, bs as ConfirmDeviceEnrollmentInput, bt as ConfirmDeviceEnrollmentResult, bu as ApproveWithDeviceCodeInput, bv as DeviceApprovalSettleResult, bw as CompleteDeviceApprovalInput, bx as CompleteDeviceApprovalResult } from './types-Ctn8N2_l.cjs';
2
2
  import { b as ReportServerGameEventInput, a as ReportGameEventResult } from './loyalty-events-CmDw2ZoR.cjs';
3
- import './version-CqwGhQXV.cjs';
3
+ import './version-Ce_pLpJf.cjs';
4
4
 
5
5
  /**
6
6
  * Pick the INVO environment from the game secret alone (3.28.0).
@@ -10,13 +10,46 @@ import './version-CqwGhQXV.cjs';
10
10
  * your code changes.
11
11
  *
12
12
  * - The public demo key starts with `ivsdk_demo_`: always the sandbox, no network call.
13
- * - Any other key: INVO is asked once (`GET /api/sdk/key-environment`), production first,
14
- * then the sandbox. The answer is cached per key for the life of the process.
13
+ * - A test key starts with `ivsdk_test_`: always the sandbox, no network call (3.34.0).
14
+ * - A live key starts with `ivsdk_live_`: always production, no network call (3.34.0).
15
+ * - Any other key (the original `ivsdk_...` keys, which keep working): INVO is asked once
16
+ * (`GET /api/sdk/key-environment`), production first, then the sandbox. The answer is
17
+ * cached per key for the life of the process.
15
18
  */
16
19
  declare const PRODUCTION_BASE_URL = "https://invo.network";
17
20
  declare const SANDBOX_BASE_URL = "https://sandbox.invo.network/sandbox";
18
21
  declare const DEMO_KEY_PREFIX = "ivsdk_demo_";
22
+ /** Keys for the sandbox (3.34.0). */
23
+ declare const TEST_KEY_PREFIX = "ivsdk_test_";
24
+ /** Keys for production (3.34.0). */
25
+ declare const LIVE_KEY_PREFIX = "ivsdk_live_";
19
26
  type InvoEnvironment = "production" | "sandbox";
27
+ /**
28
+ * The environment a key's prefix names, with no network call (3.34.0): `"production"` for
29
+ * `ivsdk_live_`, `"sandbox"` for `ivsdk_test_` and the public demo key `ivsdk_demo_`, and
30
+ * `null` for any other key (an unprefixed `ivsdk_...` key is looked up with
31
+ * {@link resolveEnvironment}).
32
+ */
33
+ declare function environmentFromKeyPrefix(gameSecret: string | undefined | null): InvoEnvironment | null;
34
+ /**
35
+ * The INVO environment a base URL points at, or `null` when it is not one of INVO's hosts
36
+ * (your own proxy, `localhost`, anything else) (3.34.0). `sandbox.invo.network` is the
37
+ * sandbox; `invo.network` (and `www.`) is production, unless its path starts with
38
+ * `/sandbox`. A trailing slash or an `/api` suffix makes no difference.
39
+ */
40
+ declare function environmentForBaseUrl(baseUrl: string | undefined | null): InvoEnvironment | null;
41
+ /**
42
+ * A prefixed key (`ivsdk_live_` / `ivsdk_test_`) was configured against the other INVO
43
+ * environment (3.34.0). Thrown at construction, before any request. The message says what
44
+ * to change.
45
+ */
46
+ declare class KeyEnvironmentMismatchError extends Error {
47
+ /** The environment the key's prefix names. */
48
+ readonly keyEnvironment: InvoEnvironment;
49
+ /** The environment the configuration points at. */
50
+ readonly configuredEnvironment: InvoEnvironment;
51
+ constructor(message: string, keyEnvironment: InvoEnvironment, configuredEnvironment: InvoEnvironment);
52
+ }
20
53
  /** Neither environment recognised the key, or INVO could not be reached. */
21
54
  declare class EnvironmentUnknownError extends Error {
22
55
  constructor(message: string);
@@ -1207,6 +1240,17 @@ declare class PlatformCommerceServer {
1207
1240
  * `err.isNotPlatformTenant` (403).
1208
1241
  */
1209
1242
  purchase(input: PlatformPurchaseInput, opts?: CallOptions): Promise<PlatformPurchaseResult>;
1243
+ /** Read a buyer-approved purchase (3.33.0) by `approvalId` or by your `clientRequestId`
1244
+ * (exactly one). A fallback to the webhooks: `completed` carries `orderId`; an ending
1245
+ * without a sale carries `reason`. Throws `err.isApprovalNotFound` (404). */
1246
+ getApproval(key: {
1247
+ approvalId?: string;
1248
+ clientRequestId?: string;
1249
+ }, opts?: CallOptions): Promise<PlatformApprovalResult>;
1250
+ /** Withdraw a buyer-approved purchase that is still waiting (3.33.0).
1251
+ * `platform_commerce.declined` follows with reason `cancelled`. Throws
1252
+ * `err.isApprovalAlreadyEnded` (409) when it had already ended. */
1253
+ cancelApproval(approvalId: string, opts?: CallOptions): Promise<PlatformApprovalResult>;
1210
1254
  /** Poll an order's status: `completed` (balance immediately; card after the webhook),
1211
1255
  * `pending_payment` (card awaiting confirmation), or `refunded`. Once the sale has settled,
1212
1256
  * `invoFeeUsd` / `partnerShareUsd` say what INVO kept and what you earned (additive). */
@@ -2204,4 +2248,4 @@ declare class InvoServer {
2204
2248
  private toInitiateResult;
2205
2249
  }
2206
2250
 
2207
- export { type SubscriptionRenewedData as $, type RegisterPayeeResult as A, type RequestPayoutInput as B, CardsServer as C, DEMO_KEY_PREFIX as D, EnvironmentUnknownError as E, type RequestPayoutResult as F, type ReturnReasonCode as G, SandboxServer as H, InvoServer as I, SandboxSubscriptionsServer as J, type SubscriptionAuthenticationRequiredData as K, type ListPayeesQuery as L, type SubscriptionCanceledData as M, type SubscriptionEventCommon as N, type SubscriptionExpiredData as O, PRODUCTION_BASE_URL as P, type SubscriptionPastDueData as Q, type RegisterPayeeInput as R, SANDBOX_BASE_URL as S, type SubscriptionPaymentFailedData as T, type SubscriptionRefundApprovedData as U, type SubscriptionRefundDetail as V, type SubscriptionRefundRejectedData as W, type SubscriptionRefundRequestData as X, type SubscriptionRefundedData as Y, type SubscriptionRenewalFunding as Z, type SubscriptionRenewalSplit as _, type InvoEnvironment as a, type SubscriptionRevenueShareAttribution as a0, type SubscriptionTrialEventFields as a1, SubscriptionsServer as a2, type TransferEventData as a3, type VerifyWebhookOptions as a4, type WebhookHandlerOptions as a5, createWebhookHandler as a6, verifyWebhook as a7, verifyWebhookAsync as a8, baseUrlForKey as b, type IdentityPasskeyResetData as c, type InvoWebhookEvent as d, type ItemPurchasedData as e, type ListPayeesResult as f, type ListPayoutsQuery as g, type ListPayoutsResult as h, isDemoKey as i, type PayableBlocker as j, type Payee as k, type PayeeInvite as l, type PayeeStatus as m, type PayeeStatusChangedData as n, type Payout as o, type PayoutStatus as p, type PayoutStatusChangedData as q, resolveEnvironment as r, PayoutsServer as s, type PlatformCommercePurchasedData as t, type PlatformCommerceRefundedData as u, verifyInvoSignature as v, PlatformCommerceServer as w, type PlayerPhoneChangedData as x, type PurchaseCompletedData as y, type PurchaseEventData as z };
2251
+ export { type SubscriptionRefundRejectedData as $, type PlayerPhoneChangedData as A, type PurchaseCompletedData as B, CardsServer as C, DEMO_KEY_PREFIX as D, EnvironmentUnknownError as E, type PurchaseEventData as F, type RegisterPayeeResult as G, type RequestPayoutInput as H, InvoServer as I, type RequestPayoutResult as J, KeyEnvironmentMismatchError as K, LIVE_KEY_PREFIX as L, type ReturnReasonCode as M, SandboxServer as N, SandboxSubscriptionsServer as O, PRODUCTION_BASE_URL as P, type SubscriptionAuthenticationRequiredData as Q, type RegisterPayeeInput as R, SANDBOX_BASE_URL as S, TEST_KEY_PREFIX as T, type SubscriptionCanceledData as U, type SubscriptionEventCommon as V, type SubscriptionExpiredData as W, type SubscriptionPastDueData as X, type SubscriptionPaymentFailedData as Y, type SubscriptionRefundApprovedData as Z, type SubscriptionRefundDetail as _, type InvoEnvironment as a, type SubscriptionRefundRequestData as a0, type SubscriptionRefundedData as a1, type SubscriptionRenewalFunding as a2, type SubscriptionRenewalSplit as a3, type SubscriptionRenewedData as a4, type SubscriptionRevenueShareAttribution as a5, type SubscriptionTrialEventFields as a6, SubscriptionsServer as a7, type TransferEventData as a8, type VerifyWebhookOptions as a9, type WebhookHandlerOptions as aa, createWebhookHandler as ab, verifyWebhook as ac, verifyWebhookAsync as ad, baseUrlForKey as b, environmentFromKeyPrefix as c, type IdentityPasskeyResetData as d, environmentForBaseUrl as e, type InvoWebhookEvent as f, type ItemPurchasedData as g, type ListPayeesQuery as h, isDemoKey as i, type ListPayeesResult as j, type ListPayoutsQuery as k, type ListPayoutsResult as l, type PayableBlocker as m, type Payee as n, type PayeeInvite as o, type PayeeStatus as p, type PayeeStatusChangedData as q, resolveEnvironment as r, type Payout as s, type PayoutStatus as t, type PayoutStatusChangedData as u, verifyInvoSignature as v, PayoutsServer as w, type PlatformCommercePurchasedData as x, type PlatformCommerceRefundedData as y, PlatformCommerceServer as z };
package/dist/server.cjs CHANGED
@@ -349,6 +349,36 @@ var InvoError = class _InvoError extends Error {
349
349
  get isPaymentsPaused() {
350
350
  return this.code === "PAYMENTS_PAUSED";
351
351
  }
352
+ /** The key belongs to the other INVO environment (`KEY_FOR_OTHER_ENVIRONMENT`, 401;
353
+ * additive, 3.34.0): a test key (`ivsdk_test_`) sent to production, or a live key
354
+ * (`ivsdk_live_`) sent to the sandbox. Never retried. Use the key for the environment
355
+ * you are calling, or point the SDK at the environment the key is for. The code is
356
+ * matched on any code field (`code`, `rawCode`, `publicCode`, or the body's
357
+ * `error_code` / `code`), since the 401 may carry a different `code`. */
358
+ get isKeyForOtherEnvironment() {
359
+ const C = "KEY_FOR_OTHER_ENVIRONMENT";
360
+ const b = this.bodyObject();
361
+ return this.code === C || this.rawCode === C || this.publicCode === C || b["error_code"] === C || b["code"] === C;
362
+ }
363
+ /** A buyer-approved balance purchase cannot start (`BALANCE_UNAVAILABLE`, 400; 3.33.0):
364
+ * the buyer is unknown here or their balance is short. One answer on purpose; the
365
+ * balance is never disclosed. Offer another way to pay. */
366
+ get isBalanceUnavailable() {
367
+ return this.code === "BALANCE_UNAVAILABLE";
368
+ }
369
+ /** Buyer approval is not available (`APPROVAL_NOT_AVAILABLE`, 503 or 409; 3.33.0). */
370
+ get isApprovalNotAvailable() {
371
+ return this.code === "APPROVAL_NOT_AVAILABLE";
372
+ }
373
+ /** No buyer-approved purchase with that id in your store (`APPROVAL_NOT_FOUND`, 404). */
374
+ get isApprovalNotFound() {
375
+ return this.code === "APPROVAL_NOT_FOUND";
376
+ }
377
+ /** `cancelApproval` on an approval that already ended (`APPROVAL_ALREADY_ENDED`, 409).
378
+ * Read it with `getApproval`: it may have completed. */
379
+ get isApprovalAlreadyEnded() {
380
+ return this.code === "APPROVAL_ALREADY_ENDED";
381
+ }
352
382
  /** True when init-purchase was given a `packId` that is not in INVO's Steam
353
383
  * catalogue (`UNKNOWN_STEAM_PACK`, 400). The error body's
354
384
  * `valid_pack_ids` lists what exists; re-fetch `steamPacks()` — the
@@ -1650,7 +1680,7 @@ function toPhoneChangeRequest(raw) {
1650
1680
  }
1651
1681
 
1652
1682
  // src/version.ts
1653
- var SDK_VERSION = "3.32.0";
1683
+ var SDK_VERSION = "3.34.0";
1654
1684
 
1655
1685
  // src/payouts.ts
1656
1686
  var AMOUNT = /^\d+(\.\d{1,2})?$/;
@@ -1844,6 +1874,140 @@ var PayoutsServer = class {
1844
1874
  }
1845
1875
  };
1846
1876
 
1877
+ // src/environment.ts
1878
+ var PRODUCTION_BASE_URL = "https://invo.network";
1879
+ var SANDBOX_BASE_URL = "https://sandbox.invo.network/sandbox";
1880
+ var DEMO_KEY_PREFIX = "ivsdk_demo_";
1881
+ var TEST_KEY_PREFIX = "ivsdk_test_";
1882
+ var LIVE_KEY_PREFIX = "ivsdk_live_";
1883
+ var KEY_ENVIRONMENT_PATH = "/api/sdk/key-environment";
1884
+ function environmentFromKeyPrefix(gameSecret) {
1885
+ if (typeof gameSecret !== "string") return null;
1886
+ if (gameSecret.startsWith(LIVE_KEY_PREFIX)) return "production";
1887
+ if (gameSecret.startsWith(TEST_KEY_PREFIX) || gameSecret.startsWith(DEMO_KEY_PREFIX)) return "sandbox";
1888
+ return null;
1889
+ }
1890
+ function environmentForBaseUrl(baseUrl) {
1891
+ if (typeof baseUrl !== "string" || !baseUrl.trim()) return null;
1892
+ let url;
1893
+ try {
1894
+ url = new URL(baseUrl.trim());
1895
+ } catch {
1896
+ return null;
1897
+ }
1898
+ const host = url.hostname.toLowerCase().replace(/\.$/, "");
1899
+ if (host === "sandbox.invo.network") return "sandbox";
1900
+ if (host === "invo.network" || host === "www.invo.network") {
1901
+ const first = url.pathname.split("/").filter(Boolean)[0]?.toLowerCase();
1902
+ return first === "sandbox" ? "sandbox" : "production";
1903
+ }
1904
+ return null;
1905
+ }
1906
+ var KeyEnvironmentMismatchError = class extends Error {
1907
+ constructor(message, keyEnvironment, configuredEnvironment) {
1908
+ super(message);
1909
+ this.name = "KeyEnvironmentMismatchError";
1910
+ this.keyEnvironment = keyEnvironment;
1911
+ this.configuredEnvironment = configuredEnvironment;
1912
+ }
1913
+ };
1914
+ function strictKeyEnvironment(gameSecret) {
1915
+ if (typeof gameSecret !== "string") return null;
1916
+ if (gameSecret.startsWith(LIVE_KEY_PREFIX)) return "production";
1917
+ if (gameSecret.startsWith(TEST_KEY_PREFIX)) return "sandbox";
1918
+ return null;
1919
+ }
1920
+ function describeKey(env) {
1921
+ return env === "production" ? `a live key (${LIVE_KEY_PREFIX})` : `a test key (${TEST_KEY_PREFIX})`;
1922
+ }
1923
+ function fixFor(keyEnv) {
1924
+ return keyEnv === "production" ? `Use ${PRODUCTION_BASE_URL}, or a test key.` : `Use ${SANDBOX_BASE_URL}, or a live key.`;
1925
+ }
1926
+ function displayUrl(baseUrl) {
1927
+ try {
1928
+ const u = new URL(baseUrl.trim());
1929
+ return `${u.protocol}//${u.host}${u.pathname}`.replace(/\/+$/, "");
1930
+ } catch {
1931
+ return "(the configured URL)";
1932
+ }
1933
+ }
1934
+ function assertKeyMatchesBaseUrl(gameSecret, baseUrl, setting = "baseUrl") {
1935
+ const keyEnv = strictKeyEnvironment(gameSecret);
1936
+ if (!keyEnv) return;
1937
+ const urlEnv = environmentForBaseUrl(baseUrl);
1938
+ if (!urlEnv || urlEnv === keyEnv) return;
1939
+ const where = urlEnv === "production" ? "production" : "the sandbox";
1940
+ const shown = displayUrl(String(baseUrl));
1941
+ throw new KeyEnvironmentMismatchError(
1942
+ `This is ${describeKey(keyEnv)} but ${setting} points at ${where} ${shown}. ${fixFor(keyEnv)}`,
1943
+ keyEnv,
1944
+ urlEnv
1945
+ );
1946
+ }
1947
+ var EnvironmentUnknownError = class extends Error {
1948
+ constructor(message) {
1949
+ super(message);
1950
+ this.name = "EnvironmentUnknownError";
1951
+ }
1952
+ };
1953
+ function isDemoKey(gameSecret) {
1954
+ return typeof gameSecret === "string" && gameSecret.startsWith(DEMO_KEY_PREFIX);
1955
+ }
1956
+ var cache = /* @__PURE__ */ new Map();
1957
+ async function ask(baseUrl, gameSecret, fetchImpl) {
1958
+ let res;
1959
+ try {
1960
+ res = await fetchImpl(baseUrl + KEY_ENVIRONMENT_PATH, {
1961
+ method: "GET",
1962
+ headers: { "X-Game-Secret-Key": gameSecret, Accept: "application/json" },
1963
+ redirect: "error"
1964
+ });
1965
+ } catch {
1966
+ throw new EnvironmentUnknownError("Could not reach INVO to check the key.");
1967
+ }
1968
+ if (res.status === 401 || res.status === 403 || res.status === 404) return null;
1969
+ if (!res.ok) throw new EnvironmentUnknownError(`INVO answered ${res.status} while checking the key.`);
1970
+ const body = await res.json().catch(() => ({}));
1971
+ return body.environment === "production" || body.environment === "sandbox" ? body.environment : null;
1972
+ }
1973
+ function resolveEnvironment(gameSecret, opts = {}) {
1974
+ if (!gameSecret) return Promise.reject(new Error("A game secret is required."));
1975
+ const byPrefix = environmentFromKeyPrefix(gameSecret);
1976
+ if (byPrefix) return Promise.resolve(byPrefix);
1977
+ const hit = cache.get(gameSecret);
1978
+ if (hit) return hit;
1979
+ const fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
1980
+ const p = (async () => {
1981
+ let prodError = null;
1982
+ let env = null;
1983
+ try {
1984
+ env = await ask(PRODUCTION_BASE_URL, gameSecret, fetchImpl);
1985
+ } catch (err) {
1986
+ prodError = err;
1987
+ }
1988
+ if (!env) {
1989
+ try {
1990
+ env = await ask(SANDBOX_BASE_URL, gameSecret, fetchImpl);
1991
+ } catch (err) {
1992
+ throw prodError ?? err;
1993
+ }
1994
+ }
1995
+ if (!env && prodError) throw prodError;
1996
+ if (!env) {
1997
+ throw new EnvironmentUnknownError(
1998
+ "Neither INVO production nor the INVO sandbox recognises this key. Check INVO_GAME_SECRET in your secrets."
1999
+ );
2000
+ }
2001
+ return env;
2002
+ })();
2003
+ cache.set(gameSecret, p);
2004
+ p.catch(() => cache.delete(gameSecret));
2005
+ return p;
2006
+ }
2007
+ async function baseUrlForKey(gameSecret, opts = {}) {
2008
+ return await resolveEnvironment(gameSecret, opts) === "production" ? PRODUCTION_BASE_URL : SANDBOX_BASE_URL;
2009
+ }
2010
+
1847
2011
  // src/shared/types.ts
1848
2012
  function isRefundPendingApproval(r) {
1849
2013
  return r.status === "pending_approval";
@@ -2012,74 +2176,6 @@ async function hmacHexSubtle(secret, message) {
2012
2176
  return hex;
2013
2177
  }
2014
2178
 
2015
- // src/environment.ts
2016
- var PRODUCTION_BASE_URL = "https://invo.network";
2017
- var SANDBOX_BASE_URL = "https://sandbox.invo.network/sandbox";
2018
- var DEMO_KEY_PREFIX = "ivsdk_demo_";
2019
- var KEY_ENVIRONMENT_PATH = "/api/sdk/key-environment";
2020
- var EnvironmentUnknownError = class extends Error {
2021
- constructor(message) {
2022
- super(message);
2023
- this.name = "EnvironmentUnknownError";
2024
- }
2025
- };
2026
- function isDemoKey(gameSecret) {
2027
- return typeof gameSecret === "string" && gameSecret.startsWith(DEMO_KEY_PREFIX);
2028
- }
2029
- var cache = /* @__PURE__ */ new Map();
2030
- async function ask(baseUrl, gameSecret, fetchImpl) {
2031
- let res;
2032
- try {
2033
- res = await fetchImpl(baseUrl + KEY_ENVIRONMENT_PATH, {
2034
- method: "GET",
2035
- headers: { "X-Game-Secret-Key": gameSecret, Accept: "application/json" },
2036
- redirect: "error"
2037
- });
2038
- } catch {
2039
- throw new EnvironmentUnknownError("Could not reach INVO to check the key.");
2040
- }
2041
- if (res.status === 401 || res.status === 403 || res.status === 404) return null;
2042
- if (!res.ok) throw new EnvironmentUnknownError(`INVO answered ${res.status} while checking the key.`);
2043
- const body = await res.json().catch(() => ({}));
2044
- return body.environment === "production" || body.environment === "sandbox" ? body.environment : null;
2045
- }
2046
- function resolveEnvironment(gameSecret, opts = {}) {
2047
- if (!gameSecret) return Promise.reject(new Error("A game secret is required."));
2048
- if (isDemoKey(gameSecret)) return Promise.resolve("sandbox");
2049
- const hit = cache.get(gameSecret);
2050
- if (hit) return hit;
2051
- const fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
2052
- const p = (async () => {
2053
- let prodError = null;
2054
- let env = null;
2055
- try {
2056
- env = await ask(PRODUCTION_BASE_URL, gameSecret, fetchImpl);
2057
- } catch (err) {
2058
- prodError = err;
2059
- }
2060
- if (!env) {
2061
- try {
2062
- env = await ask(SANDBOX_BASE_URL, gameSecret, fetchImpl);
2063
- } catch (err) {
2064
- throw prodError ?? err;
2065
- }
2066
- }
2067
- if (!env && prodError) throw prodError;
2068
- if (!env) {
2069
- throw new EnvironmentUnknownError(
2070
- "Neither INVO production nor the INVO sandbox recognises this key. Check INVO_GAME_SECRET in your secrets."
2071
- );
2072
- }
2073
- return env;
2074
- })();
2075
- cache.set(gameSecret, p);
2076
- p.catch(() => cache.delete(gameSecret));
2077
- return p;
2078
- }
2079
- async function baseUrlForKey(gameSecret, opts = {}) {
2080
- return await resolveEnvironment(gameSecret, opts) === "production" ? PRODUCTION_BASE_URL : SANDBOX_BASE_URL;
2081
- }
2082
-
2083
2179
  // src/server.ts
2084
2180
  var DEFAULT_UA = `invonetwork-web-sdk/${SDK_VERSION} (+https://invo.network)`;
2085
2181
  var MAX_USD_AMOUNT = 999999.99;
@@ -2339,6 +2435,23 @@ function toPlayerActivityEntry(raw) {
2339
2435
  raw
2340
2436
  };
2341
2437
  }
2438
+ function toPlatformApproval(raw) {
2439
+ const s = (k) => raw[k] == null ? null : String(raw[k]);
2440
+ const meta = raw["metadata"];
2441
+ return {
2442
+ approvalId: String(raw["approval_id"] ?? ""),
2443
+ clientRequestId: String(raw["client_request_id"] ?? ""),
2444
+ status: String(raw["status"] ?? ""),
2445
+ reason: s("reason"),
2446
+ totalPrice: s("total_price"),
2447
+ orderId: raw["order_id"] ?? null,
2448
+ transactionId: s("transaction_id"),
2449
+ expiresAt: s("expires_at"),
2450
+ decidedAt: s("decided_at"),
2451
+ metadata: meta && typeof meta === "object" && !Array.isArray(meta) ? meta : {},
2452
+ raw
2453
+ };
2454
+ }
2342
2455
  function toPlatformOrderStatus(raw, fallbackOrderId) {
2343
2456
  return {
2344
2457
  orderId: raw["order_id"] ?? fallbackOrderId ?? "",
@@ -2645,6 +2758,10 @@ var PlatformCommerceServer = class {
2645
2758
  if (input.successUrl) body["success_url"] = input.successUrl;
2646
2759
  if (input.cancelUrl) body["cancel_url"] = input.cancelUrl;
2647
2760
  if (input.metadata) body["metadata"] = input.metadata;
2761
+ if (input.requirePlayerApproval === true) {
2762
+ body["require_player_approval"] = true;
2763
+ if (input.returnUrl) body["return_url"] = input.returnUrl;
2764
+ }
2648
2765
  const raw = await this.http.post(
2649
2766
  "/api/platform-commerce/purchase",
2650
2767
  body,
@@ -2653,7 +2770,9 @@ var PlatformCommerceServer = class {
2653
2770
  { idempotent: true, signal: opts?.signal }
2654
2771
  );
2655
2772
  const status = String(raw["status"] ?? "");
2656
- if (status === "requires_payment") {
2773
+ if (status === "pending_approval") {
2774
+ requireField2(raw["approval_id"], "approval_id", raw);
2775
+ } else if (status === "requires_payment") {
2657
2776
  requireField2(raw["checkout_url"], "checkout_url", raw);
2658
2777
  } else {
2659
2778
  requireField2(raw["order_id"], "order_id", raw);
@@ -2674,9 +2793,39 @@ var PlatformCommerceServer = class {
2674
2793
  amountUsd: raw["amount_usd"] ?? null,
2675
2794
  idempotentReplay: raw["idempotent_replay"] === true,
2676
2795
  ...minPurchaseWarningField(raw),
2796
+ ...raw["approval_id"] != null ? { approvalId: String(raw["approval_id"]) } : {},
2797
+ ..."approval_url" in raw ? { approvalUrl: raw["approval_url"] ?? null } : {},
2677
2798
  raw
2678
2799
  };
2679
2800
  }
2801
+ /** Read a buyer-approved purchase (3.33.0) by `approvalId` or by your `clientRequestId`
2802
+ * (exactly one). A fallback to the webhooks: `completed` carries `orderId`; an ending
2803
+ * without a sale carries `reason`. Throws `err.isApprovalNotFound` (404). */
2804
+ async getApproval(key, opts) {
2805
+ const id = key?.approvalId;
2806
+ const crid = key?.clientRequestId;
2807
+ if (Boolean(id) === Boolean(crid)) {
2808
+ throw invalidInput2("approvalId", id, "provide exactly one of approvalId or clientRequestId");
2809
+ }
2810
+ const path = id ? `/api/platform-commerce/approvals/${encodeURIComponent(String(id))}` : `/api/platform-commerce/approvals?${new URLSearchParams({ client_request_id: String(crid) }).toString()}`;
2811
+ const raw = await this.http.get(path, this.auth, { signal: opts?.signal });
2812
+ return toPlatformApproval(raw);
2813
+ }
2814
+ /** Withdraw a buyer-approved purchase that is still waiting (3.33.0).
2815
+ * `platform_commerce.declined` follows with reason `cancelled`. Throws
2816
+ * `err.isApprovalAlreadyEnded` (409) when it had already ended. */
2817
+ async cancelApproval(approvalId, opts) {
2818
+ if (typeof approvalId !== "string" || !approvalId.trim()) {
2819
+ throw invalidInput2("approvalId", approvalId, "is required");
2820
+ }
2821
+ const raw = await this.http.post(
2822
+ `/api/platform-commerce/approvals/${encodeURIComponent(approvalId)}/cancel`,
2823
+ {},
2824
+ this.auth,
2825
+ { idempotent: true, signal: opts?.signal }
2826
+ );
2827
+ return toPlatformApproval(raw);
2828
+ }
2680
2829
  /** Poll an order's status: `completed` (balance immediately; card after the webhook),
2681
2830
  * `pending_payment` (card awaiting confirmation), or `refunded`. Once the sale has settled,
2682
2831
  * `invoFeeUsd` / `partnerShareUsd` say what INVO kept and what you earned (additive). */
@@ -3903,6 +4052,7 @@ var InvoServer = class {
3903
4052
  if (!config.gameSecret) throw new Error("InvoServer requires a `gameSecret`.");
3904
4053
  if (!config.baseUrl) throw new Error("InvoServer requires a `baseUrl`.");
3905
4054
  assertSecureBaseUrl(config.baseUrl);
4055
+ assertKeyMatchesBaseUrl(config.gameSecret.trim(), config.baseUrl);
3906
4056
  this.http = new Http({
3907
4057
  baseUrl: config.baseUrl,
3908
4058
  timeoutMs: config.timeoutMs,
@@ -5453,6 +5603,8 @@ exports.DEMO_KEY_PREFIX = DEMO_KEY_PREFIX;
5453
5603
  exports.EnvironmentUnknownError = EnvironmentUnknownError;
5454
5604
  exports.InvoError = InvoError;
5455
5605
  exports.InvoServer = InvoServer;
5606
+ exports.KeyEnvironmentMismatchError = KeyEnvironmentMismatchError;
5607
+ exports.LIVE_KEY_PREFIX = LIVE_KEY_PREFIX;
5456
5608
  exports.PRODUCTION_BASE_URL = PRODUCTION_BASE_URL;
5457
5609
  exports.PayoutsServer = PayoutsServer;
5458
5610
  exports.PlatformCommerceServer = PlatformCommerceServer;
@@ -5461,8 +5613,11 @@ exports.SDK_VERSION = SDK_VERSION;
5461
5613
  exports.SandboxServer = SandboxServer;
5462
5614
  exports.SandboxSubscriptionsServer = SandboxSubscriptionsServer;
5463
5615
  exports.SubscriptionsServer = SubscriptionsServer;
5616
+ exports.TEST_KEY_PREFIX = TEST_KEY_PREFIX;
5464
5617
  exports.baseUrlForKey = baseUrlForKey;
5465
5618
  exports.createWebhookHandler = createWebhookHandler;
5619
+ exports.environmentForBaseUrl = environmentForBaseUrl;
5620
+ exports.environmentFromKeyPrefix = environmentFromKeyPrefix;
5466
5621
  exports.isDemoKey = isDemoKey;
5467
5622
  exports.isRefundPendingApproval = isRefundPendingApproval;
5468
5623
  exports.resolveEnvironment = resolveEnvironment;
package/dist/server.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { bt as ApproveWithDeviceCodeInput, bn as BeginDeviceApprovalInput, g as CallOptions, ae as CancelResult, ad as CancelSubscriptionOptions, ar as CardSetupConfirmInput, as as CardSetupConfirmResult, ap as CardSetupInput, aq as CardSetupResult, an as CardSetupSessionInput, ao as CardSetupSessionResult, bx as CardSetupStatus, af as ChangeAmountResult, by as CheckoutWarning, be as ClaimCurrencyInput, y as ClaimDelivery, bd as ClaimResult, bc as ClaimTransferInput, bv as CompleteDeviceApprovalInput, bw as CompleteDeviceApprovalResult, br as ConfirmDeviceEnrollmentInput, bs as ConfirmDeviceEnrollmentResult, aR as ConfirmPaymentResult, aL as CreateCheckoutInput, aM as CreateCheckoutResult, a7 as CreateSubscriptionInput, bz as CurrencyBalance, aQ as CurrencyPurchaseQuote, bA as CurrencyPurchaseQuoteBreakdown, aP as CurrencyPurchaseQuoteInput, D as DestinationGame, p as DestinationsResult, bB as DeviceApprovalChannel, bC as DeviceApprovalEnrollment, bD as DeviceApprovalFlow, bo as DeviceApprovalGrant, bq as DeviceApprovalPollResult, bE as DeviceApprovalPollStatus, bu as DeviceApprovalSettleResult, bF as DeviceEnrollmentDecision, bG as DeviceEnrollmentRespond, bH as ExpiryReason, bI as FeeTakenFrom, bJ as FirstCharge, bK as FirstChargeStatus, bL as FundingSource, a9 as GetSubscriptionOptions, aa as GetSubscriptionResult, bg as GuardianApprovalStatusResult, bM as InboundPendingItem, b7 as InboundPendingQuery, b8 as InboundPendingResult, aJ as InitiateResult, aI as InitiateSendInput, aK as InitiateTransferInput, I as InvoError, z as InvoErrorInfo, F as InvoHooks, G as InvoRequestInfo, J as InvoResponseInfo, a$ as ItemHistoryQuery, b0 as ItemHistoryResult, b1 as ItemOrderQuery, b9 as LinkedIdentitiesQuery, ba as LinkedIdentitiesResult, bN as LinkedIdentityEmail, ab as ListSubscriptionsOptions, K as LoyaltyCard, N as LoyaltyCardReward, O as LoyaltyCardStep, q as LoyaltyCardsResult, Q as LoyaltyRewardState, S as LoyaltyStepProgress, T as LoyaltyStepState, bO as MinPurchaseWarning, az as MintPlayerTokenInput, aS as OrderDetailsResult, bP as PhoneChangeConfirmation, aH as PhoneChangeRequest, bQ as PhoneChangeRequestStatus, bk as PhoneShareApproveInput, bl as PhoneShareApproveResult, bi as PhoneShareContact, bj as PhoneShareInitiateResult, bm as PhoneShareStatusResult, a2 as PlatformOrderStatusResult, a3 as PlatformPurchaseHistoryQuery, a4 as PlatformPurchaseHistoryResult, a0 as PlatformPurchaseInput, a1 as PlatformPurchaseResult, bR as PlatformPurchaseStatus, a5 as PlatformRefundInput, a6 as PlatformRefundResult, b4 as PlayerActivityEntry, b2 as PlayerActivityQuery, b3 as PlayerActivityResult, bS as PlayerActivityType, b5 as PlayerBalanceQuery, b6 as PlayerBalanceResult, at as PlayerCardsResult, aA as PlayerToken, bp as PollDeviceApprovalInput, aN as PurchaseInput, aZ as PurchaseItemInput, a_ as PurchaseItemResult, aO as PurchaseResult, Z as Rail, bT as RefundInitiation, bU as RefundPendingApproval, bV as RefundProcessingFeeBasis, bW as RefundReceipt, aj as RefundResult, bX as RefundRevenueShareAttribution, ai as RefundSubscriptionInput, bY as RefundWarning, aB as RegisterPlayerInput, aC as RegisterPlayerResult, aF as RequestPhoneChangeInput, aG as RequestPhoneChangeResult, au as SandboxClockResult, bZ as SandboxClockState, av as SandboxFailureOutcome, ax as SandboxForceAuthChallengeOptions, aw as SandboxForceFailureOptions, b_ as SavedCard, ay as ServerConfig, bh as ServerDestinationsQuery, ag as SetPaymentMethodInput, ah as SetPaymentMethodResult, bb as SmsVerifyResult, aX as SteamFinalizeInput, aY as SteamFinalizeResult, am as SteamFinalizeSubscriptionResult, aV as SteamInitPurchaseInput, aW as SteamInitPurchaseResult, al as SteamInitResult, b$ as SteamPack, aT as SteamPacksQuery, aU as SteamPacksResult, ak as SteamSubscriptionInitInput, c0 as SteamUserSession, c1 as Subscription, c2 as SubscriptionBaseInput, c3 as SubscriptionConsent, c4 as SubscriptionConsentInput, c5 as SubscriptionFundingRail, c6 as SubscriptionInterval, ac as SubscriptionListResult, a8 as SubscriptionResult, c7 as SubscriptionRevenueShare, c8 as SubscriptionRevenueShareInput, c9 as SubscriptionStatus, bf as TransactionStatusResult, ca as UnacknowledgedPurchaseOutcome, aD as UpdatePlayerPhoneInput, aE as UpdatePlayerPhoneResult, _ as VerificationMethod, cb as isRefundPendingApproval } from './types-CaPHNjOU.cjs';
1
+ export { bu as ApproveWithDeviceCodeInput, bo as BeginDeviceApprovalInput, g as CallOptions, af as CancelResult, ae as CancelSubscriptionOptions, as as CardSetupConfirmInput, at as CardSetupConfirmResult, aq as CardSetupInput, ar as CardSetupResult, ao as CardSetupSessionInput, ap as CardSetupSessionResult, by as CardSetupStatus, ag as ChangeAmountResult, bz as CheckoutWarning, bf as ClaimCurrencyInput, y as ClaimDelivery, be as ClaimResult, bd as ClaimTransferInput, bw as CompleteDeviceApprovalInput, bx as CompleteDeviceApprovalResult, bs as ConfirmDeviceEnrollmentInput, bt as ConfirmDeviceEnrollmentResult, aS as ConfirmPaymentResult, aM as CreateCheckoutInput, aN as CreateCheckoutResult, a8 as CreateSubscriptionInput, bA as CurrencyBalance, aR as CurrencyPurchaseQuote, bB as CurrencyPurchaseQuoteBreakdown, aQ as CurrencyPurchaseQuoteInput, D as DestinationGame, p as DestinationsResult, bC as DeviceApprovalChannel, bD as DeviceApprovalEnrollment, bE as DeviceApprovalFlow, bp as DeviceApprovalGrant, br as DeviceApprovalPollResult, bF as DeviceApprovalPollStatus, bv as DeviceApprovalSettleResult, bG as DeviceEnrollmentDecision, bH as DeviceEnrollmentRespond, bI as ExpiryReason, bJ as FeeTakenFrom, bK as FirstCharge, bL as FirstChargeStatus, bM as FundingSource, aa as GetSubscriptionOptions, ab as GetSubscriptionResult, bh as GuardianApprovalStatusResult, bN as InboundPendingItem, b8 as InboundPendingQuery, b9 as InboundPendingResult, aK as InitiateResult, aJ as InitiateSendInput, aL as InitiateTransferInput, I as InvoError, z as InvoErrorInfo, F as InvoHooks, G as InvoRequestInfo, J as InvoResponseInfo, b0 as ItemHistoryQuery, b1 as ItemHistoryResult, b2 as ItemOrderQuery, ba as LinkedIdentitiesQuery, bb as LinkedIdentitiesResult, bO as LinkedIdentityEmail, ac as ListSubscriptionsOptions, K as LoyaltyCard, N as LoyaltyCardReward, O as LoyaltyCardStep, q as LoyaltyCardsResult, Q as LoyaltyRewardState, S as LoyaltyStepProgress, T as LoyaltyStepState, bP as MinPurchaseWarning, aA as MintPlayerTokenInput, aT as OrderDetailsResult, bQ as PhoneChangeConfirmation, aI as PhoneChangeRequest, bR as PhoneChangeRequestStatus, bl as PhoneShareApproveInput, bm as PhoneShareApproveResult, bj as PhoneShareContact, bk as PhoneShareInitiateResult, bn as PhoneShareStatusResult, a2 as PlatformApprovalResult, a3 as PlatformOrderStatusResult, a4 as PlatformPurchaseHistoryQuery, a5 as PlatformPurchaseHistoryResult, a0 as PlatformPurchaseInput, a1 as PlatformPurchaseResult, bS as PlatformPurchaseStatus, a6 as PlatformRefundInput, a7 as PlatformRefundResult, b5 as PlayerActivityEntry, b3 as PlayerActivityQuery, b4 as PlayerActivityResult, bT as PlayerActivityType, b6 as PlayerBalanceQuery, b7 as PlayerBalanceResult, au as PlayerCardsResult, aB as PlayerToken, bq as PollDeviceApprovalInput, aO as PurchaseInput, a_ as PurchaseItemInput, a$ as PurchaseItemResult, aP as PurchaseResult, Z as Rail, bU as RefundInitiation, bV as RefundPendingApproval, bW as RefundProcessingFeeBasis, bX as RefundReceipt, ak as RefundResult, bY as RefundRevenueShareAttribution, aj as RefundSubscriptionInput, bZ as RefundWarning, aC as RegisterPlayerInput, aD as RegisterPlayerResult, aG as RequestPhoneChangeInput, aH as RequestPhoneChangeResult, av as SandboxClockResult, b_ as SandboxClockState, aw as SandboxFailureOutcome, ay as SandboxForceAuthChallengeOptions, ax as SandboxForceFailureOptions, b$ as SavedCard, az as ServerConfig, bi as ServerDestinationsQuery, ah as SetPaymentMethodInput, ai as SetPaymentMethodResult, bc as SmsVerifyResult, aY as SteamFinalizeInput, aZ as SteamFinalizeResult, an as SteamFinalizeSubscriptionResult, aW as SteamInitPurchaseInput, aX as SteamInitPurchaseResult, am as SteamInitResult, c0 as SteamPack, aU as SteamPacksQuery, aV as SteamPacksResult, al as SteamSubscriptionInitInput, c1 as SteamUserSession, c2 as Subscription, c3 as SubscriptionBaseInput, c4 as SubscriptionConsent, c5 as SubscriptionConsentInput, c6 as SubscriptionFundingRail, c7 as SubscriptionInterval, ad as SubscriptionListResult, a9 as SubscriptionResult, c8 as SubscriptionRevenueShare, c9 as SubscriptionRevenueShareInput, ca as SubscriptionStatus, bg as TransactionStatusResult, cb as UnacknowledgedPurchaseOutcome, aE as UpdatePlayerPhoneInput, aF as UpdatePlayerPhoneResult, _ as VerificationMethod, cc as isRefundPendingApproval } from './types-Ctn8N2_l.cjs';
2
2
  export { G as GameEventType, R as ReportGameEventInput, a as ReportGameEventResult, b as ReportServerGameEventInput } from './loyalty-events-CmDw2ZoR.cjs';
3
- export { C as CardsServer, D as DEMO_KEY_PREFIX, E as EnvironmentUnknownError, c as IdentityPasskeyResetData, a as InvoEnvironment, I as InvoServer, d as InvoWebhookEvent, e as ItemPurchasedData, L as ListPayeesQuery, f as ListPayeesResult, g as ListPayoutsQuery, h as ListPayoutsResult, P as PRODUCTION_BASE_URL, j as PayableBlocker, k as Payee, l as PayeeInvite, m as PayeeStatus, n as PayeeStatusChangedData, o as Payout, p as PayoutStatus, q as PayoutStatusChangedData, s as PayoutsServer, t as PlatformCommercePurchasedData, u as PlatformCommerceRefundedData, w as PlatformCommerceServer, x as PlayerPhoneChangedData, y as PurchaseCompletedData, z as PurchaseEventData, R as RegisterPayeeInput, A as RegisterPayeeResult, B as RequestPayoutInput, F as RequestPayoutResult, G as ReturnReasonCode, S as SANDBOX_BASE_URL, H as SandboxServer, J as SandboxSubscriptionsServer, K as SubscriptionAuthenticationRequiredData, M as SubscriptionCanceledData, N as SubscriptionEventCommon, O as SubscriptionExpiredData, Q as SubscriptionPastDueData, T as SubscriptionPaymentFailedData, U as SubscriptionRefundApprovedData, V as SubscriptionRefundDetail, W as SubscriptionRefundRejectedData, X as SubscriptionRefundRequestData, Y as SubscriptionRefundedData, Z as SubscriptionRenewalFunding, _ as SubscriptionRenewalSplit, $ as SubscriptionRenewedData, a0 as SubscriptionRevenueShareAttribution, a1 as SubscriptionTrialEventFields, a2 as SubscriptionsServer, a3 as TransferEventData, a4 as VerifyWebhookOptions, a5 as WebhookHandlerOptions, b as baseUrlForKey, a6 as createWebhookHandler, i as isDemoKey, r as resolveEnvironment, a7 as verifyWebhook, a8 as verifyWebhookAsync } from './server-jAn9dNM3.cjs';
4
- export { S as SDK_VERSION } from './version-CqwGhQXV.cjs';
3
+ export { C as CardsServer, D as DEMO_KEY_PREFIX, E as EnvironmentUnknownError, d as IdentityPasskeyResetData, a as InvoEnvironment, I as InvoServer, f as InvoWebhookEvent, g as ItemPurchasedData, K as KeyEnvironmentMismatchError, L as LIVE_KEY_PREFIX, h as ListPayeesQuery, j as ListPayeesResult, k as ListPayoutsQuery, l as ListPayoutsResult, P as PRODUCTION_BASE_URL, m as PayableBlocker, n as Payee, o as PayeeInvite, p as PayeeStatus, q as PayeeStatusChangedData, s as Payout, t as PayoutStatus, u as PayoutStatusChangedData, w as PayoutsServer, x as PlatformCommercePurchasedData, y as PlatformCommerceRefundedData, z as PlatformCommerceServer, A as PlayerPhoneChangedData, B as PurchaseCompletedData, F as PurchaseEventData, R as RegisterPayeeInput, G as RegisterPayeeResult, H as RequestPayoutInput, J as RequestPayoutResult, M as ReturnReasonCode, S as SANDBOX_BASE_URL, N as SandboxServer, O as SandboxSubscriptionsServer, Q as SubscriptionAuthenticationRequiredData, U as SubscriptionCanceledData, V as SubscriptionEventCommon, W as SubscriptionExpiredData, X as SubscriptionPastDueData, Y as SubscriptionPaymentFailedData, Z as SubscriptionRefundApprovedData, _ as SubscriptionRefundDetail, $ as SubscriptionRefundRejectedData, a0 as SubscriptionRefundRequestData, a1 as SubscriptionRefundedData, a2 as SubscriptionRenewalFunding, a3 as SubscriptionRenewalSplit, a4 as SubscriptionRenewedData, a5 as SubscriptionRevenueShareAttribution, a6 as SubscriptionTrialEventFields, a7 as SubscriptionsServer, T as TEST_KEY_PREFIX, a8 as TransferEventData, a9 as VerifyWebhookOptions, aa as WebhookHandlerOptions, b as baseUrlForKey, ab as createWebhookHandler, e as environmentForBaseUrl, c as environmentFromKeyPrefix, i as isDemoKey, r as resolveEnvironment, ac as verifyWebhook, ad as verifyWebhookAsync } from './server-ZnCyLWA2.cjs';
4
+ export { S as SDK_VERSION } from './version-Ce_pLpJf.cjs';