@invonetwork/web-sdk 3.34.0 → 3.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +104 -11
- package/dist/chunk-6763YM7P.js +6 -0
- package/dist/{chunk-R65CANFG.js → chunk-BGCSSWVL.js} +105 -3
- package/dist/{chunk-DMTNU5PM.js → chunk-SCFK6IVH.js} +3 -3
- package/dist/{chunk-D2AUZRYS.js → chunk-XN6MCLQV.js} +231 -70
- package/dist/game-server.cjs +294 -74
- package/dist/game-server.d.cts +4 -4
- package/dist/game-server.d.ts +4 -4
- package/dist/game-server.js +5 -5
- package/dist/game.cjs +105 -3
- package/dist/game.d.cts +3 -3
- package/dist/game.d.ts +3 -3
- package/dist/game.js +4 -4
- package/dist/{hosted-approval-CFlj4UQE.d.ts → hosted-approval-DIYUGgHi.d.ts} +1 -1
- package/dist/{hosted-approval-C1hQvbu6.d.cts → hosted-approval-VQ3uyeDh.d.cts} +1 -1
- package/dist/index.cjs +103 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/{server-CtXpytKt.d.ts → server-CMJHOmYL.d.ts} +120 -9
- package/dist/{server-ZnCyLWA2.d.cts → server-DF-BZU0B.d.cts} +120 -9
- package/dist/server.cjs +333 -67
- package/dist/server.d.cts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +3 -3
- package/dist/{types-Ctn8N2_l.d.ts → types-Dv0UavA9.d.cts} +149 -4
- package/dist/{types-Ctn8N2_l.d.cts → types-Dv0UavA9.d.ts} +149 -4
- package/dist/{version-Ce_pLpJf.d.cts → version-DB2wgiPY.d.cts} +1 -1
- package/dist/{version-Ce_pLpJf.d.ts → version-DB2wgiPY.d.ts} +1 -1
- package/docs/apple-in-app-purchases.md +382 -0
- package/package.json +2 -1
- package/dist/chunk-73ZVDQZV.js +0 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as InvoError, H as Http, $ as AuthHeader, g as CallOptions, a0 as
|
|
1
|
+
import { I as InvoError, H as Http, $ as AuthHeader, g as CallOptions, a0 as ApplePurchaseResult, a1 as PlatformPurchaseInput, a2 as PlatformPurchaseResult, a3 as PlatformApprovalResult, a4 as PlatformOrderStatusResult, a5 as PlatformPurchaseHistoryQuery, a6 as PlatformPurchaseHistoryResult, a7 as PlatformRefundInput, a8 as PlatformRefundResult, a9 as CreateSubscriptionInput, aa as SubscriptionResult, ab as GetSubscriptionOptions, ac as GetSubscriptionResult, ad as ListSubscriptionsOptions, ae as SubscriptionListResult, af as CancelSubscriptionOptions, ag as CancelResult, ah as ChangeAmountResult, ai as SetPaymentMethodInput, aj as SetPaymentMethodResult, ak as RefundSubscriptionInput, al as RefundResult, am as SteamSubscriptionInitInput, an as SteamInitResult, ao as SteamFinalizeSubscriptionResult, ap as CardSetupSessionInput, aq as CardSetupSessionResult, ar as CardSetupInput, as as CardSetupResult, at as CardSetupConfirmInput, au as CardSetupConfirmResult, av as PlayerCardsResult, aw as SandboxClockResult, ax as SandboxFailureOutcome, ay as SandboxForceFailureOptions, az as SandboxForceAuthChallengeOptions, aA as ServerConfig, aB as MintPlayerTokenInput, aC as PlayerToken, aD as RegisterPlayerInput, aE as RegisterPlayerResult, aF as UpdatePlayerPhoneInput, aG as UpdatePlayerPhoneResult, aH as RequestPhoneChangeInput, aI as RequestPhoneChangeResult, aJ as PhoneChangeRequest, aK as InitiateSendInput, aL as InitiateResult, aM as InitiateTransferInput, aN as CreateCheckoutInput, aO as CreateCheckoutResult, a as PurchaseStatusResult, aP as PurchaseInput, aQ as PurchaseResult, aR as CurrencyPurchaseQuoteInput, aS as CurrencyPurchaseQuote, aT as ConfirmPaymentResult, aU as OrderDetailsResult, aV as SteamPacksQuery, aW as SteamPacksResult, aX as SteamInitPurchaseInput, aY as SteamInitPurchaseResult, aZ as SteamFinalizeInput, a_ as SteamFinalizeResult, a$ as AppleProductsResult, b0 as VerifyApplePurchaseInput, b1 as PurchaseItemInput, b2 as PurchaseItemResult, b3 as ItemHistoryQuery, b4 as ItemHistoryResult, b5 as ItemOrderQuery, b6 as PlayerActivityQuery, b7 as PlayerActivityResult, b8 as PlayerActivityEntry, b9 as PlayerBalanceQuery, ba as PlayerBalanceResult, q as LoyaltyCardsResult, bb as InboundPendingQuery, bc as InboundPendingResult, bd as LinkedIdentitiesQuery, be as LinkedIdentitiesResult, bf as SmsVerifyResult, bg as ClaimTransferInput, bh as ClaimResult, bi as ClaimCurrencyInput, bj as TransactionStatusResult, bk as GuardianApprovalStatusResult, bl as ServerDestinationsQuery, p as DestinationsResult, bm as PhoneShareContact, bn as PhoneShareInitiateResult, bo as PhoneShareApproveInput, bp as PhoneShareApproveResult, bq as PhoneShareStatusResult, br as BeginDeviceApprovalInput, bs as DeviceApprovalGrant, bt as PollDeviceApprovalInput, bu as DeviceApprovalPollResult, bv as ConfirmDeviceEnrollmentInput, bw as ConfirmDeviceEnrollmentResult, bx as ApproveWithDeviceCodeInput, by as DeviceApprovalSettleResult, bz as CompleteDeviceApprovalInput, bA as CompleteDeviceApprovalResult } from './types-Dv0UavA9.cjs';
|
|
2
2
|
import { b as ReportServerGameEventInput, a as ReportGameEventResult } from './loyalty-events-CmDw2ZoR.cjs';
|
|
3
|
-
import './version-
|
|
3
|
+
import './version-DB2wgiPY.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Pick the INVO environment from the game secret alone (3.28.0).
|
|
@@ -81,6 +81,33 @@ interface WebhookBase {
|
|
|
81
81
|
/** Your game_id. */
|
|
82
82
|
tenant_id: string;
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* The verified App Store transaction behind an Apple-rail purchase (additive, 3.35.0). Sent
|
|
86
|
+
* as `data.apple` on `purchase.completed` and `purchase.refunded` when `rail` is `"apple"`;
|
|
87
|
+
* absent on every other rail.
|
|
88
|
+
*/
|
|
89
|
+
interface AppleWebhookDetails {
|
|
90
|
+
/** Apple's `transactionId`. */
|
|
91
|
+
transaction_id: string;
|
|
92
|
+
original_transaction_id: string;
|
|
93
|
+
/** The App Store product id. */
|
|
94
|
+
product_id: string;
|
|
95
|
+
/** `"Production"` or `"Sandbox"`. */
|
|
96
|
+
environment: string;
|
|
97
|
+
/** The App Store storefront (for example `"USA"`), or `null` when Apple sent none. */
|
|
98
|
+
storefront: string | null;
|
|
99
|
+
/** Per-unit price in the storefront's currency, decimal string, or `null`. */
|
|
100
|
+
price: string | null;
|
|
101
|
+
/** ISO 4217 code of `price`, or `null`. */
|
|
102
|
+
currency: string | null;
|
|
103
|
+
/**
|
|
104
|
+
* `false` when `usd_amount` is exactly what the player paid (a USD storefront). `true` when
|
|
105
|
+
* the storefront is not in USD and `usd_amount` is the product's registered US price.
|
|
106
|
+
*/
|
|
107
|
+
charged_usd_estimated: boolean;
|
|
108
|
+
/** `true` for an App Review (Sandbox) purchase accepted on INVO production. */
|
|
109
|
+
test_mode: boolean;
|
|
110
|
+
}
|
|
84
111
|
interface PurchaseCompletedData {
|
|
85
112
|
transaction_id: string;
|
|
86
113
|
order_id: string;
|
|
@@ -90,7 +117,8 @@ interface PurchaseCompletedData {
|
|
|
90
117
|
currency_amount: string;
|
|
91
118
|
currency_name: string;
|
|
92
119
|
new_balance: string;
|
|
93
|
-
/** Which settlement rail carried the money. Provider-neutral
|
|
120
|
+
/** Which settlement rail carried the money. Provider-neutral: `"platform"`, `"game"`,
|
|
121
|
+
* `"steam"`, `"apple"` (3.35.0). Treat an unknown value as a new rail. */
|
|
94
122
|
rail: string;
|
|
95
123
|
/**
|
|
96
124
|
* Which STOREFRONT the purchase came from — "steam" / "ios" / "android" /
|
|
@@ -100,8 +128,8 @@ interface PurchaseCompletedData {
|
|
|
100
128
|
*/
|
|
101
129
|
channel?: string | null;
|
|
102
130
|
/**
|
|
103
|
-
* The metadata you passed to createCheckout/purchaseCurrency/steamInitPurchase
|
|
104
|
-
* (all rails).
|
|
131
|
+
* The metadata you passed to createCheckout/purchaseCurrency/steamInitPurchase/
|
|
132
|
+
* verifyApplePurchase, echoed back (all rails).
|
|
105
133
|
*
|
|
106
134
|
* **Subscription renewals also emit `purchase.completed`** (every paid card renewal, for the
|
|
107
135
|
* coins its charge minted). Those carry `metadata.source === "subscription_renewal"` and
|
|
@@ -141,6 +169,12 @@ interface PurchaseCompletedData {
|
|
|
141
169
|
* Card purchases only; absent and `null` on the same terms as `partner_fee_usd`.
|
|
142
170
|
*/
|
|
143
171
|
international_card_fee_usd?: string | null;
|
|
172
|
+
/**
|
|
173
|
+
* Additive (3.35.0), Apple rail only (`rail: "apple"`, `channel: "ios"`): the verified App
|
|
174
|
+
* Store transaction. `usd_amount` is what the player paid in USD (exact on a USD storefront;
|
|
175
|
+
* otherwise the registered US price, with `apple.charged_usd_estimated: true`).
|
|
176
|
+
*/
|
|
177
|
+
apple?: AppleWebhookDetails;
|
|
144
178
|
[key: string]: unknown;
|
|
145
179
|
}
|
|
146
180
|
interface PurchaseEventData {
|
|
@@ -231,13 +265,21 @@ interface PurchaseEventData {
|
|
|
231
265
|
dispute_id?: string | null;
|
|
232
266
|
/**
|
|
233
267
|
* The rail the purchase was paid on, where the event carries it: `"steam"` on a Steam
|
|
234
|
-
* `purchase.refunded` or `purchase.disputed`.
|
|
268
|
+
* `purchase.refunded` or `purchase.disputed`, `"apple"` on an Apple `purchase.refunded`.
|
|
235
269
|
*/
|
|
236
270
|
rail?: string;
|
|
237
271
|
/** The Steam transaction id, on a Steam `purchase.refunded` or `purchase.disputed`. */
|
|
238
272
|
steam_transid?: string;
|
|
239
273
|
/** On purchase.refunded: `false` for a partial refund (a Steam partial refund included). */
|
|
240
274
|
fully_refunded?: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Additive (3.35.0), on an Apple `purchase.refunded` (Apple refunded or revoked the
|
|
277
|
+
* transaction): the verified App Store transaction. Only coins the player still holds from
|
|
278
|
+
* the purchase are taken back, never below zero.
|
|
279
|
+
*/
|
|
280
|
+
apple?: AppleWebhookDetails;
|
|
281
|
+
/** On an Apple `purchase.refunded`: the metadata you passed to `verifyApplePurchase`. */
|
|
282
|
+
metadata?: Record<string, unknown>;
|
|
241
283
|
/** Coins taken back by this event, or `null` when the player has no balance row. */
|
|
242
284
|
currency_debited?: string | null;
|
|
243
285
|
/** The player's balance after this event. Never below zero. */
|
|
@@ -1190,6 +1232,36 @@ declare class PayoutsServer {
|
|
|
1190
1232
|
cancelPayout(payoutIdValue: number, opts?: CallOptions): Promise<Payout>;
|
|
1191
1233
|
}
|
|
1192
1234
|
|
|
1235
|
+
/**
|
|
1236
|
+
* The refusals after which the transaction is finished, because nothing can ever be delivered
|
|
1237
|
+
* for it: Apple refunded or revoked it, it was credited in another INVO game, or it was bought
|
|
1238
|
+
* before the game sold through INVO. Used only when a response carries no `finish` flag.
|
|
1239
|
+
*/
|
|
1240
|
+
declare const APPLE_FINISH_ERROR_CODES: readonly string[];
|
|
1241
|
+
/**
|
|
1242
|
+
* Should the game call StoreKit's `Transaction.finish()` after this outcome of
|
|
1243
|
+
* `verifyApplePurchase`? Pass either the result or the thrown error.
|
|
1244
|
+
*
|
|
1245
|
+
* INVO decides: every verify-purchase answer, success or error, carries a boolean `finish`,
|
|
1246
|
+
* and this returns it. When an answer carries none (an older backend, or a refusal from
|
|
1247
|
+
* outside the Apple route such as an unknown key), it falls back to the same rule INVO
|
|
1248
|
+
* applies: `true` for a result with `status` `"credited"` or `"already_credited"`, and for
|
|
1249
|
+
* the errors `APPLE_TRANSACTION_REVOKED`, `APPLE_TRANSACTION_ALREADY_USED` and
|
|
1250
|
+
* `APPLE_TRANSACTION_TOO_OLD` (nothing can ever be delivered for those).
|
|
1251
|
+
*
|
|
1252
|
+
* `false` for everything else, including `APPLE_CREDIT_PENDING`, every other refusal, a
|
|
1253
|
+
* network error or timeout, and anything unrecognised. Leave the transaction unfinished:
|
|
1254
|
+
* StoreKit redelivers it and your server retries `verifyApplePurchase` with the same
|
|
1255
|
+
* signed transaction, which never credits twice.
|
|
1256
|
+
*/
|
|
1257
|
+
declare function shouldFinishAppleTransaction(outcome: ApplePurchaseResult | unknown): boolean;
|
|
1258
|
+
/**
|
|
1259
|
+
* `true` when `verifyApplePurchase` threw `APPLE_CREDIT_PENDING` (503): the purchase is
|
|
1260
|
+
* verified and held, and will credit on a later retry. Keep the transaction unfinished and
|
|
1261
|
+
* retry; never ask the player to pay again.
|
|
1262
|
+
*/
|
|
1263
|
+
declare function isAppleCreditPending(err: unknown): boolean;
|
|
1264
|
+
|
|
1193
1265
|
/**
|
|
1194
1266
|
* @invonetwork/web-sdk/server — NODE entry.
|
|
1195
1267
|
*
|
|
@@ -1576,8 +1648,8 @@ declare class CardsServer {
|
|
|
1576
1648
|
* `/subscriptions/<id>/...` relative to it. They do not exist in production (404).
|
|
1577
1649
|
*
|
|
1578
1650
|
* **Second credential.** Every call sends `X-Game-Secret-Key` AND `X-Sandbox-Clock-Key`
|
|
1579
|
-
* (`new InvoServer({ ..., sandboxClockKey })`, from the
|
|
1580
|
-
* Game Settings, "Sandbox clock key"). A missing key throws `INVALID_INPUT` before the
|
|
1651
|
+
* (`new InvoServer({ ..., sandboxClockKey })`, from the INVO console in test mode (console.invo.network/test):
|
|
1652
|
+
* open the game, Game Settings, "Sandbox clock key"). A missing key throws `INVALID_INPUT` before the
|
|
1581
1653
|
* network; a wrong one is `401 SANDBOX_CLOCK_UNAUTHORIZED` (`err.isSandboxClockUnauthorized`).
|
|
1582
1654
|
* None of these calls is auto-retried: each one moves the clock or runs the engine.
|
|
1583
1655
|
*/
|
|
@@ -1931,6 +2003,45 @@ declare class InvoServer {
|
|
|
1931
2003
|
* detects the authorized transaction and credits, on a delay.
|
|
1932
2004
|
*/
|
|
1933
2005
|
steamFinalizePurchase(input: SteamFinalizeInput, opts?: CallOptions): Promise<SteamFinalizeResult>;
|
|
2006
|
+
/**
|
|
2007
|
+
* The App Store products registered for this game, and whether INVO will sell each one
|
|
2008
|
+
* right now. Call it with the game's iOS key **before every purchase** and offer only
|
|
2009
|
+
* products with `available: true`: Apple charges the player before INVO sees the
|
|
2010
|
+
* purchase, so this is the only point where INVO can say no. Ask StoreKit for exactly the
|
|
2011
|
+
* `productId`s listed.
|
|
2012
|
+
*
|
|
2013
|
+
* `unavailableReason` (per product, and for the whole game when `canSell` is `false`):
|
|
2014
|
+
* `APPLE_NOT_VERIFIED`, `PARTNER_BILLING_NOT_SET_UP`, `PARTNER_RAIL_SUSPENDED`,
|
|
2015
|
+
* `PARTNER_CREDIT_UNAVAILABLE`.
|
|
2016
|
+
*
|
|
2017
|
+
* Refusals: `err.isAppleNotConfigured` (409, no Apple configuration or turned off),
|
|
2018
|
+
* `err.isRailChannelMismatch` (409, the key is not an iOS key on the Apple rail).
|
|
2019
|
+
*/
|
|
2020
|
+
appleProducts(opts?: CallOptions): Promise<AppleProductsResult>;
|
|
2021
|
+
/**
|
|
2022
|
+
* Verify a StoreKit 2 transaction and credit its coins, once. Call it from your game
|
|
2023
|
+
* SERVER, never the device, after StoreKit returns a verified transaction, with the
|
|
2024
|
+
* game's iOS key. Send `Transaction.jwsRepresentation` unchanged as `signedTransaction`.
|
|
2025
|
+
*
|
|
2026
|
+
* Then decide `Transaction.finish()` with {@link shouldFinishAppleTransaction}, passing
|
|
2027
|
+
* the result or the thrown error. It reads INVO's `finish` flag, which every answer carries
|
|
2028
|
+
* (`result.finish`, `err.finish`): `true` for `credited`, `already_credited` and the terminal
|
|
2029
|
+
* errors `isAppleTransactionRevoked`, `isAppleTransactionAlreadyUsed` and
|
|
2030
|
+
* `isAppleTransactionTooOld`. On anything else leave the transaction unfinished and
|
|
2031
|
+
* retry: StoreKit redelivers it, and a retry with the same signed transaction never credits
|
|
2032
|
+
* twice (a replay answers `already_credited`, with `balance` `null` unless you name the
|
|
2033
|
+
* same player). Safe to auto-retry for the same reason.
|
|
2034
|
+
*
|
|
2035
|
+
* Refusals: `isAppleSignatureInvalid`, `isAppleBundleMismatch`,
|
|
2036
|
+
* `isAppleEnvironmentNotAllowed`, `isAppleProductTypeUnsupported`, `isAppleProductUnknown`,
|
|
2037
|
+
* `isInvalidMetadata` / `isInvalidInput` (400); `isAppleReviewAccountRequired` (403);
|
|
2038
|
+
* `isAppleTransactionRevoked`, `isAppleTransactionAlreadyUsed`, `isAppleTransactionTooOld`,
|
|
2039
|
+
* `isAppleValueExceedsPrice`, `isAppleAccountTokenMismatch`, `isAppleNotConfigured`,
|
|
2040
|
+
* `isAppleNotVerified`, `isRailChannelMismatch` (409); `isAppleReviewPurchaseLimit` (429);
|
|
2041
|
+
* `isAppleCreditPending` (503, verified and held: retry; also while payments are paused);
|
|
2042
|
+
* and the usual game-key refusals, which carry no `finish` (treated as not finished).
|
|
2043
|
+
*/
|
|
2044
|
+
verifyApplePurchase(input: VerifyApplePurchaseInput, opts?: CallOptions): Promise<ApplePurchaseResult>;
|
|
1934
2045
|
/**
|
|
1935
2046
|
* Buy an in-game item by SPENDING the player's existing game currency (§4.8).
|
|
1936
2047
|
* No real money, no payment rail, no passkey — it's a balance debit, authenticated
|
|
@@ -2248,4 +2359,4 @@ declare class InvoServer {
|
|
|
2248
2359
|
private toInitiateResult;
|
|
2249
2360
|
}
|
|
2250
2361
|
|
|
2251
|
-
export { type
|
|
2362
|
+
export { type SubscriptionRefundApprovedData as $, APPLE_FINISH_ERROR_CODES as A, PlatformCommerceServer as B, CardsServer as C, DEMO_KEY_PREFIX as D, EnvironmentUnknownError as E, type PlayerPhoneChangedData as F, type PurchaseCompletedData as G, type PurchaseEventData as H, InvoServer as I, type RegisterPayeeResult as J, KeyEnvironmentMismatchError as K, LIVE_KEY_PREFIX as L, type RequestPayoutInput as M, type RequestPayoutResult as N, type ReturnReasonCode as O, PRODUCTION_BASE_URL as P, SandboxServer as Q, type RegisterPayeeInput as R, SANDBOX_BASE_URL as S, TEST_KEY_PREFIX as T, SandboxSubscriptionsServer as U, type SubscriptionAuthenticationRequiredData as V, type SubscriptionCanceledData as W, type SubscriptionEventCommon as X, type SubscriptionExpiredData as Y, type SubscriptionPastDueData as Z, type SubscriptionPaymentFailedData as _, type InvoEnvironment as a, type SubscriptionRefundDetail as a0, type SubscriptionRefundRejectedData as a1, type SubscriptionRefundRequestData as a2, type SubscriptionRefundedData as a3, type SubscriptionRenewalFunding as a4, type SubscriptionRenewalSplit as a5, type SubscriptionRenewedData as a6, type SubscriptionRevenueShareAttribution as a7, type SubscriptionTrialEventFields as a8, SubscriptionsServer as a9, type TransferEventData as aa, type VerifyWebhookOptions as ab, type WebhookHandlerOptions as ac, createWebhookHandler as ad, isAppleCreditPending as ae, shouldFinishAppleTransaction as af, verifyWebhook as ag, verifyWebhookAsync as ah, baseUrlForKey as b, environmentFromKeyPrefix as c, type AppleWebhookDetails as d, environmentForBaseUrl as e, type IdentityPasskeyResetData as f, type InvoWebhookEvent as g, type ItemPurchasedData as h, isDemoKey as i, type ListPayeesQuery as j, type ListPayeesResult as k, type ListPayoutsQuery as l, type ListPayoutsResult as m, type PayableBlocker as n, type Payee as o, type PayeeInvite as p, type PayeeStatus as q, resolveEnvironment as r, type PayeeStatusChangedData as s, type Payout as t, type PayoutStatus as u, verifyInvoSignature as v, type PayoutStatusChangedData as w, PayoutsServer as x, type PlatformCommercePurchasedData as y, type PlatformCommerceRefundedData as z };
|