@invonetwork/web-sdk 3.19.0 → 3.21.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/dist/server.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { I as InvoError, H as Http, x as AuthHeader, y as CardSetupSessionInput, g as CallOptions, z as CardSetupSessionResult, F as CardSetupInput, G as CardSetupResult, J as CardSetupConfirmInput, K as CardSetupConfirmResult, N as PlayerCardsResult, O as PlatformPurchaseInput, Q as PlatformPurchaseResult, S as PlatformOrderStatusResult, T as PlatformRefundInput, U as PlatformRefundResult, X as CreateSubscriptionInput, Y as SubscriptionResult, Z as GetSubscriptionOptions, _ as GetSubscriptionResult, $ as ListSubscriptionsOptions, a0 as SubscriptionListResult, a1 as CancelSubscriptionOptions, a2 as CancelResult, a3 as ChangeAmountResult, a4 as SetPaymentMethodInput, a5 as SetPaymentMethodResult, a6 as RefundSubscriptionInput, a7 as RefundResult, a8 as SteamSubscriptionInitInput, a9 as SteamInitResult, aa as SteamFinalizeSubscriptionResult, ab as SandboxClockResult, ac as SandboxFailureOutcome, ad as SandboxForceFailureOptions, ae as SandboxForceAuthChallengeOptions, af as ServerConfig, ag as PlayerToken, ah as InitiateSendInput, ai as InitiateResult, aj as InitiateTransferInput, ak as CreateCheckoutInput, al as CreateCheckoutResult, am as PurchaseInput, an as PurchaseResult, ao as CurrencyPurchaseQuoteInput, ap as CurrencyPurchaseQuote, aq as ConfirmPaymentResult, ar as OrderDetailsResult, as as SteamPacksQuery, at as SteamPacksResult, au as SteamInitPurchaseInput, av as SteamInitPurchaseResult, aw as SteamFinalizeInput, ax as SteamFinalizeResult, ay as PurchaseItemInput, az as PurchaseItemResult, aA as ItemHistoryQuery, aB as ItemHistoryResult, aC as ItemOrderQuery, aD as PlayerBalanceQuery, aE as PlayerBalanceResult, aF as InboundPendingQuery, aG as InboundPendingResult, aH as LinkedIdentitiesQuery, aI as LinkedIdentitiesResult, aJ as SmsVerifyResult, aK as ClaimTransferInput, aL as ClaimResult, aM as ClaimCurrencyInput, aN as TransactionStatusResult, aO as GuardianApprovalStatusResult, aP as ServerDestinationsQuery, k as DestinationsResult, aQ as PhoneShareContact, aR as PhoneShareInitiateResult, aS as PhoneShareApproveInput, aT as PhoneShareApproveResult, aU as PhoneShareStatusResult, aV as BeginDeviceApprovalInput, aW as DeviceApprovalGrant, aX as PollDeviceApprovalInput, aY as DeviceApprovalPollResult, aZ as ConfirmDeviceEnrollmentInput, a_ as ConfirmDeviceEnrollmentResult, a$ as ApproveWithDeviceCodeInput, b0 as DeviceApprovalSettleResult, b1 as CompleteDeviceApprovalInput, b2 as CompleteDeviceApprovalResult } from './types-CCqgVhzf.js';
2
- export { b3 as CardSetupStatus, b4 as CheckoutWarning, b5 as CurrencyBalance, b6 as CurrencyPurchaseQuoteBreakdown, p as DestinationGame, b7 as DeviceApprovalChannel, b8 as DeviceApprovalEnrollment, b9 as DeviceApprovalFlow, ba as DeviceApprovalPollStatus, bb as DeviceEnrollmentDecision, bc as DeviceEnrollmentRespond, bd as FeeTakenFrom, be as FirstCharge, bf as FirstChargeStatus, bg as FundingSource, bh as InboundPendingItem, q as InvoErrorInfo, r as InvoHooks, s as InvoRequestInfo, t as InvoResponseInfo, bi as LinkedIdentityEmail, bj as MinPurchaseWarning, bk as PlatformPurchaseStatus, w as Rail, bl as RefundInitiation, bm as RefundPendingApproval, bn as RefundProcessingFeeBasis, bo as RefundReceipt, bp as RefundRevenueShareAttribution, bq as RefundWarning, br as SandboxClockState, bs as SavedCard, bt as SteamPack, bu as SteamUserSession, bv as Subscription, bw as SubscriptionBaseInput, bx as SubscriptionConsent, by as SubscriptionConsentInput, bz as SubscriptionFundingRail, bA as SubscriptionInterval, bB as SubscriptionRevenueShare, bC as SubscriptionRevenueShareInput, bD as SubscriptionStatus, bE as UnacknowledgedPurchaseOutcome, V as VerificationMethod, bF as isRefundPendingApproval } from './types-CCqgVhzf.js';
1
+ import { I as InvoError, H as Http, U as AuthHeader, X as CardSetupSessionInput, g as CallOptions, Y as CardSetupSessionResult, Z as CardSetupInput, _ as CardSetupResult, $ as CardSetupConfirmInput, a0 as CardSetupConfirmResult, a1 as PlayerCardsResult, a2 as PlatformPurchaseInput, a3 as PlatformPurchaseResult, a4 as PlatformOrderStatusResult, 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 SandboxClockResult, ao as SandboxFailureOutcome, ap as SandboxForceFailureOptions, aq as SandboxForceAuthChallengeOptions, ar as ServerConfig, as as MintPlayerTokenInput, at as PlayerToken, au as RegisterPlayerInput, av as RegisterPlayerResult, aw as UpdatePlayerPhoneInput, ax as UpdatePlayerPhoneResult, ay as InitiateSendInput, az as InitiateResult, aA as InitiateTransferInput, aB as CreateCheckoutInput, aC as CreateCheckoutResult, aD as PurchaseInput, aE as PurchaseResult, aF as CurrencyPurchaseQuoteInput, aG as CurrencyPurchaseQuote, aH as ConfirmPaymentResult, aI as OrderDetailsResult, aJ as SteamPacksQuery, aK as SteamPacksResult, aL as SteamInitPurchaseInput, aM as SteamInitPurchaseResult, aN as SteamFinalizeInput, aO as SteamFinalizeResult, aP as PurchaseItemInput, aQ as PurchaseItemResult, aR as ItemHistoryQuery, aS as ItemHistoryResult, aT as ItemOrderQuery, aU as PlayerBalanceQuery, aV as PlayerBalanceResult, l as LoyaltyCardsResult, aW as InboundPendingQuery, aX as InboundPendingResult, aY as LinkedIdentitiesQuery, aZ as LinkedIdentitiesResult, a_ as SmsVerifyResult, a$ as ClaimTransferInput, b0 as ClaimResult, b1 as ClaimCurrencyInput, b2 as TransactionStatusResult, b3 as GuardianApprovalStatusResult, b4 as ServerDestinationsQuery, k as DestinationsResult, b5 as PhoneShareContact, b6 as PhoneShareInitiateResult, b7 as PhoneShareApproveInput, b8 as PhoneShareApproveResult, b9 as PhoneShareStatusResult, ba as BeginDeviceApprovalInput, bb as DeviceApprovalGrant, bc as PollDeviceApprovalInput, bd as DeviceApprovalPollResult, be as ConfirmDeviceEnrollmentInput, bf as ConfirmDeviceEnrollmentResult, bg as ApproveWithDeviceCodeInput, bh as DeviceApprovalSettleResult, bi as CompleteDeviceApprovalInput, bj as CompleteDeviceApprovalResult } from './types-BXcPz6Xw.js';
2
+ export { bk as CardSetupStatus, bl as CheckoutWarning, t as ClaimDelivery, bm as CurrencyBalance, bn as CurrencyPurchaseQuoteBreakdown, u as DestinationGame, bo as DeviceApprovalChannel, bp as DeviceApprovalEnrollment, bq as DeviceApprovalFlow, br as DeviceApprovalPollStatus, bs as DeviceEnrollmentDecision, bt as DeviceEnrollmentRespond, bu as FeeTakenFrom, bv as FirstCharge, bw as FirstChargeStatus, bx as FundingSource, by as InboundPendingItem, v as InvoErrorInfo, w as InvoHooks, x as InvoRequestInfo, y as InvoResponseInfo, bz as LinkedIdentityEmail, z as LoyaltyCard, F as LoyaltyCardReward, G as LoyaltyCardStep, J as LoyaltyRewardState, K as LoyaltyStepProgress, N as LoyaltyStepState, bA as MinPurchaseWarning, bB as PlatformPurchaseStatus, T as Rail, bC as RefundInitiation, bD as RefundPendingApproval, bE as RefundProcessingFeeBasis, bF as RefundReceipt, bG as RefundRevenueShareAttribution, bH as RefundWarning, bI as SandboxClockState, bJ as SavedCard, bK as SteamPack, bL as SteamUserSession, bM as Subscription, bN as SubscriptionBaseInput, bO as SubscriptionConsent, bP as SubscriptionConsentInput, bQ as SubscriptionFundingRail, bR as SubscriptionInterval, bS as SubscriptionRevenueShare, bT as SubscriptionRevenueShareInput, bU as SubscriptionStatus, bV as UnacknowledgedPurchaseOutcome, V as VerificationMethod, bW as isRefundPendingApproval } from './types-BXcPz6Xw.js';
3
3
 
4
4
  /**
5
5
  * The package version, as sent in the server User-Agent. A test pins this to
6
6
  * `package.json` so it cannot drift silently (it did: the UA read 3.0.0 through 3.7.0).
7
7
  * Bump it with the changeset flow.
8
8
  */
9
- declare const SDK_VERSION = "3.19.0";
9
+ declare const SDK_VERSION = "3.21.0";
10
10
 
11
11
  interface VerifyWebhookOptions {
12
12
  /** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
@@ -1216,21 +1216,48 @@ declare class InvoServer {
1216
1216
  /**
1217
1217
  * Mint a short-lived, game-scoped player token to hand to the browser InvoClient.
1218
1218
  *
1219
- * This is a SESSION-TOKEN mint for a player who ALREADY EXISTS on the game — not a
1220
- * registration call. The backend looks the player up by `playerEmail` and returns a
1221
- * token for their existing identity; if no such player exists it responds 404. The
1222
- * network identity (which encodes the player's phone) is established when the player
1223
- * is created and on the money-routing calls, so phone is NOT required or read here.
1219
+ * For a player who already exists in your game, this is a session mint: INVO looks the
1220
+ * player up by `playerEmail` and returns a token for their identity. `playerPhone` and
1221
+ * `playerName` do not change an existing player.
1224
1222
  *
1225
- * `playerPhone` is optional and only validated (E.164) if you pass it — the backend
1226
- * ignores it on this endpoint, so an existing email-only player can still mint a token.
1227
- * Phone is enforced where it actually matters: `initiateSend`/`initiateTransfer` (the
1228
- * sender's phone, and the recipient's when known) and at player creation.
1223
+ * For a player who is NOT in your game yet: without `playerPhone` INVO answers 404
1224
+ * (`err.isPlayerNotFound`); with `playerPhone` INVO creates the player and the result
1225
+ * carries `created: true`, so a first-time receiver can collect without buying first.
1226
+ * Use `registerPlayer` when you want creation to be explicit.
1227
+ *
1228
+ * `phoneMismatch: true` means the existing player has a different phone than the one
1229
+ * you passed; the token is still for that player and their phone is unchanged
1230
+ * (`updatePlayerPhone` changes it). A phone already held by another email is a 409
1231
+ * (`err.isPhoneShareRefused`).
1229
1232
  */
1230
- mintPlayerToken(input: {
1231
- playerEmail: string;
1232
- playerPhone?: string;
1233
- }, opts?: CallOptions): Promise<PlayerToken>;
1233
+ mintPlayerToken(input: MintPlayerTokenInput, opts?: CallOptions): Promise<PlayerToken>;
1234
+ /**
1235
+ * Create a player in your game without moving money (`POST /api/sdk/players`), so a
1236
+ * first-time receiver can collect in-game. Sends no message to the player.
1237
+ *
1238
+ * Returns `status: "created"` (new) or `"exists"` (already in your game with that
1239
+ * phone), with a player token when INVO can issue one. Refusals: 409
1240
+ * `err.isPhoneMismatch` (already in your game with a different phone; use
1241
+ * `updatePlayerPhone`), 409 `err.isPhoneShareRefused` (the phone belongs to another
1242
+ * email), 400 `INVALID_INPUT` / `INVALID_PHONE`, 429 (`err.retryAfter`).
1243
+ */
1244
+ registerPlayer(input: RegisterPlayerInput, opts?: CallOptions): Promise<RegisterPlayerResult>;
1245
+ /**
1246
+ * Set a player's phone from your server (`POST /api/sdk/players/phone`). A phone change
1247
+ * can give the player a new INVO identity: `identityRekeyed: true`, and the result
1248
+ * carries a fresh `playerToken` for it (tokens minted before the change are then out
1249
+ * of date).
1250
+ *
1251
+ * Refusals: 409 `err.isPhoneChangeRequiresVerification` (the player has secured this
1252
+ * account, so the change needs the player's own confirmation; contact INVO support
1253
+ * meanwhile), 409 `err.isPhoneShareRefused` (the number belongs to another email),
1254
+ * 404 `err.isPlayerNotFound`, 400 `INVALID_INPUT` / `INVALID_PHONE`, 429
1255
+ * (`err.retryAfter`), 503 (could not be checked right now; try again shortly).
1256
+ *
1257
+ * Never auto-retried: a retry after a change that landed would answer `"unchanged"` and
1258
+ * hide `identityRekeyed`.
1259
+ */
1260
+ updatePlayerPhone(input: UpdatePlayerPhoneInput, opts?: CallOptions): Promise<UpdatePlayerPhoneResult>;
1234
1261
  /**
1235
1262
  * Initiate a cross-game currency SEND. Inspect result.verificationMethod.
1236
1263
  *
@@ -1408,6 +1435,22 @@ declare class InvoServer {
1408
1435
  * client-side read, or `playerEmail` here server-side.
1409
1436
  */
1410
1437
  getPlayerBalance(query: PlayerBalanceQuery, opts?: CallOptions): Promise<PlayerBalanceResult>;
1438
+ /**
1439
+ * One player's loyalty cards, read by your SERVER with the game secret: the same cards
1440
+ * the player sees through `InvoClient.getMyRewards()`, for the player with this email in
1441
+ * your game. Each step carries `state` and `progress` (`{ current, target }`, or `null`
1442
+ * when the number could not be read this time: render `state` alone then). Rewards carry
1443
+ * their masked code only; a code is never returned here.
1444
+ *
1445
+ * Refusals (all `InvoError`): a blank email throws `INVALID_INPUT` before the network;
1446
+ * `400 INVALID_PLAYER_EMAIL` (`err.isInvalidPlayerEmail`), `401 INVALID_GAME_SECRET` for a missing or wrong key, or
1447
+ * a per-channel key (this read takes the game's server secret only), `404 PLAYER_NOT_FOUND`
1448
+ * (`err.isPlayerNotFound`: no player with this email in this game), `429` (back off;
1449
+ * `err.retryAfter`). Also `409 NO_TENANT` (the game is not set up for loyalty), `503`
1450
+ * (temporarily unavailable) and `502` / `504` (the loyalty service could not be reached or
1451
+ * timed out): retry later. A GET, so transient failures are retried automatically.
1452
+ */
1453
+ getPlayerRewards(playerEmail: string, opts?: CallOptions): Promise<LoyaltyCardsResult>;
1411
1454
  /**
1412
1455
  * List LIVE, unclaimed inbound sends/transfers addressed to a player at YOUR game —
1413
1456
  * the source of truth for a "you have X to collect" badge. Pass the player's email
@@ -1575,8 +1618,10 @@ declare class InvoServer {
1575
1618
  *
1576
1619
  * Throws `InvoError`: `err.isDeviceApprovalNotApproved` (400 — wrong/foreign code,
1577
1620
  * wrong flow, or the poll never said approved), `err.isPasskeyRecoveryCooldown` (403,
1578
- * money-out after a passkey recovery — `err.retryAfterAt`), guardian terminal states
1579
- * (410). Never auto-retried: the device_code is a single-use factor.
1621
+ * money-out after a passkey recovery — `err.retryAfterAt`), `err.isPlayerTokenStale`
1622
+ * (403, the player token predates the sender's phone being added: re-mint, or use the
1623
+ * initiate's `playerToken`, and retry once), guardian terminal states (410). Never
1624
+ * auto-retried: the device_code is a single-use factor.
1580
1625
  *
1581
1626
  * **A FAILURE HERE IS AMBIGUOUS ABOUT THE MONEY.** The backend commits the transfer and
1582
1627
  * *then* builds its 200 by reading the transaction back, so a fault raised after that
@@ -1619,4 +1664,4 @@ declare class InvoServer {
1619
1664
  private toInitiateResult;
1620
1665
  }
1621
1666
 
1622
- export { ApproveWithDeviceCodeInput, BeginDeviceApprovalInput, CallOptions, CancelResult, CancelSubscriptionOptions, CardSetupConfirmInput, CardSetupConfirmResult, CardSetupInput, CardSetupResult, CardSetupSessionInput, CardSetupSessionResult, CardsServer, ChangeAmountResult, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, CompleteDeviceApprovalInput, CompleteDeviceApprovalResult, ConfirmDeviceEnrollmentInput, ConfirmDeviceEnrollmentResult, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, CreateSubscriptionInput, CurrencyPurchaseQuote, CurrencyPurchaseQuoteInput, DestinationsResult, DeviceApprovalGrant, DeviceApprovalPollResult, DeviceApprovalSettleResult, GetSubscriptionOptions, GetSubscriptionResult, GuardianApprovalStatusResult, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, ListSubscriptionsOptions, OrderDetailsResult, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerCardsResult, PlayerToken, PollDeviceApprovalInput, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, RefundResult, RefundSubscriptionInput, SDK_VERSION, SandboxClockResult, SandboxFailureOutcome, SandboxForceAuthChallengeOptions, SandboxForceFailureOptions, SandboxServer, SandboxSubscriptionsServer, ServerConfig, ServerDestinationsQuery, SetPaymentMethodInput, SetPaymentMethodResult, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamFinalizeSubscriptionResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamInitResult, SteamPacksQuery, SteamPacksResult, SteamSubscriptionInitInput, type SubscriptionAuthenticationRequiredData, type SubscriptionCanceledData, type SubscriptionEventCommon, type SubscriptionExpiredData, SubscriptionListResult, type SubscriptionPastDueData, type SubscriptionPaymentFailedData, type SubscriptionRefundApprovedData, type SubscriptionRefundDetail, type SubscriptionRefundRejectedData, type SubscriptionRefundRequestData, type SubscriptionRefundedData, type SubscriptionRenewalFunding, type SubscriptionRenewalSplit, type SubscriptionRenewedData, SubscriptionResult, type SubscriptionRevenueShareAttribution, type SubscriptionTrialEventFields, SubscriptionsServer, TransactionStatusResult, type TransferEventData, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };
1667
+ export { ApproveWithDeviceCodeInput, BeginDeviceApprovalInput, CallOptions, CancelResult, CancelSubscriptionOptions, CardSetupConfirmInput, CardSetupConfirmResult, CardSetupInput, CardSetupResult, CardSetupSessionInput, CardSetupSessionResult, CardsServer, ChangeAmountResult, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, CompleteDeviceApprovalInput, CompleteDeviceApprovalResult, ConfirmDeviceEnrollmentInput, ConfirmDeviceEnrollmentResult, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, CreateSubscriptionInput, CurrencyPurchaseQuote, CurrencyPurchaseQuoteInput, DestinationsResult, DeviceApprovalGrant, DeviceApprovalPollResult, DeviceApprovalSettleResult, GetSubscriptionOptions, GetSubscriptionResult, GuardianApprovalStatusResult, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, ListSubscriptionsOptions, LoyaltyCardsResult, MintPlayerTokenInput, OrderDetailsResult, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerCardsResult, PlayerToken, PollDeviceApprovalInput, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, RefundResult, RefundSubscriptionInput, RegisterPlayerInput, RegisterPlayerResult, SDK_VERSION, SandboxClockResult, SandboxFailureOutcome, SandboxForceAuthChallengeOptions, SandboxForceFailureOptions, SandboxServer, SandboxSubscriptionsServer, ServerConfig, ServerDestinationsQuery, SetPaymentMethodInput, SetPaymentMethodResult, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamFinalizeSubscriptionResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamInitResult, SteamPacksQuery, SteamPacksResult, SteamSubscriptionInitInput, type SubscriptionAuthenticationRequiredData, type SubscriptionCanceledData, type SubscriptionEventCommon, type SubscriptionExpiredData, SubscriptionListResult, type SubscriptionPastDueData, type SubscriptionPaymentFailedData, type SubscriptionRefundApprovedData, type SubscriptionRefundDetail, type SubscriptionRefundRejectedData, type SubscriptionRefundRequestData, type SubscriptionRefundedData, type SubscriptionRenewalFunding, type SubscriptionRenewalSplit, type SubscriptionRenewedData, SubscriptionResult, type SubscriptionRevenueShareAttribution, type SubscriptionTrialEventFields, SubscriptionsServer, TransactionStatusResult, type TransferEventData, UpdatePlayerPhoneInput, UpdatePlayerPhoneResult, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };
package/dist/server.js CHANGED
@@ -1,9 +1,9 @@
1
- import { InvoError, receiptFields, assertSecureBaseUrl, Http, creditFields, toDestinationsResult } from './chunk-YW2PYARQ.js';
2
- export { InvoError } from './chunk-YW2PYARQ.js';
1
+ import { InvoError, receiptFields, assertSecureBaseUrl, Http, creditFields, toLoyaltyCardsResult, toDestinationsResult } from './chunk-7L4O5Q7K.js';
2
+ export { InvoError } from './chunk-7L4O5Q7K.js';
3
3
  import { createHmac, timingSafeEqual } from 'crypto';
4
4
 
5
5
  // src/version.ts
6
- var SDK_VERSION = "3.19.0";
6
+ var SDK_VERSION = "3.21.0";
7
7
 
8
8
  // src/shared/types.ts
9
9
  function isRefundPendingApproval(r) {
@@ -558,6 +558,16 @@ function toCurrencyBalance(row) {
558
558
  raw: row
559
559
  };
560
560
  }
561
+ function playerTokenFields(raw) {
562
+ const out = {};
563
+ if (typeof raw["player_token"] === "string" && raw["player_token"]) {
564
+ out.playerToken = raw["player_token"];
565
+ if (typeof raw["player_token_expires_at"] === "string") {
566
+ out.playerTokenExpiresAt = raw["player_token_expires_at"];
567
+ }
568
+ }
569
+ return out;
570
+ }
561
571
  function requireField(value, field, raw) {
562
572
  const s = value == null ? "" : String(value);
563
573
  if (!s) {
@@ -1855,16 +1865,19 @@ var InvoServer = class {
1855
1865
  /**
1856
1866
  * Mint a short-lived, game-scoped player token to hand to the browser InvoClient.
1857
1867
  *
1858
- * This is a SESSION-TOKEN mint for a player who ALREADY EXISTS on the game — not a
1859
- * registration call. The backend looks the player up by `playerEmail` and returns a
1860
- * token for their existing identity; if no such player exists it responds 404. The
1861
- * network identity (which encodes the player's phone) is established when the player
1862
- * is created and on the money-routing calls, so phone is NOT required or read here.
1868
+ * For a player who already exists in your game, this is a session mint: INVO looks the
1869
+ * player up by `playerEmail` and returns a token for their identity. `playerPhone` and
1870
+ * `playerName` do not change an existing player.
1871
+ *
1872
+ * For a player who is NOT in your game yet: without `playerPhone` INVO answers 404
1873
+ * (`err.isPlayerNotFound`); with `playerPhone` INVO creates the player and the result
1874
+ * carries `created: true`, so a first-time receiver can collect without buying first.
1875
+ * Use `registerPlayer` when you want creation to be explicit.
1863
1876
  *
1864
- * `playerPhone` is optional and only validated (E.164) if you pass it — the backend
1865
- * ignores it on this endpoint, so an existing email-only player can still mint a token.
1866
- * Phone is enforced where it actually matters: `initiateSend`/`initiateTransfer` (the
1867
- * sender's phone, and the recipient's when known) and at player creation.
1877
+ * `phoneMismatch: true` means the existing player has a different phone than the one
1878
+ * you passed; the token is still for that player and their phone is unchanged
1879
+ * (`updatePlayerPhone` changes it). A phone already held by another email is a 409
1880
+ * (`err.isPhoneShareRefused`).
1868
1881
  */
1869
1882
  async mintPlayerToken(input, opts) {
1870
1883
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
@@ -1875,18 +1888,103 @@ var InvoServer = class {
1875
1888
  assertE164(input.playerPhone, "playerPhone");
1876
1889
  body["player_phone"] = input.playerPhone;
1877
1890
  }
1891
+ if (input.playerName !== void 0) {
1892
+ if (typeof input.playerName !== "string") {
1893
+ throw invalidInput("playerName", input.playerName, "must be a string");
1894
+ }
1895
+ body["player_name"] = input.playerName;
1896
+ }
1878
1897
  const raw = await this.http.post(
1879
1898
  "/api/sdk/player-token",
1880
1899
  body,
1881
1900
  this.auth,
1901
+ // Safe to retry: a re-mint issues a fresh token, and a create that already happened
1902
+ // answers the retry for the existing player.
1882
1903
  { idempotent: true, signal: opts?.signal }
1883
- // safe to retry: re-mint just issues a fresh token
1884
1904
  );
1885
- return {
1905
+ const out = {
1886
1906
  token: requireField(raw["token"], "token", raw),
1887
1907
  expiresAt: String(raw["expires_at"] ?? ""),
1888
1908
  identityId: String(raw["identity_id"] ?? "")
1889
1909
  };
1910
+ if (raw["created"] === true) out.created = true;
1911
+ if (raw["phone_mismatch"] === true) out.phoneMismatch = true;
1912
+ return out;
1913
+ }
1914
+ /**
1915
+ * Create a player in your game without moving money (`POST /api/sdk/players`), so a
1916
+ * first-time receiver can collect in-game. Sends no message to the player.
1917
+ *
1918
+ * Returns `status: "created"` (new) or `"exists"` (already in your game with that
1919
+ * phone), with a player token when INVO can issue one. Refusals: 409
1920
+ * `err.isPhoneMismatch` (already in your game with a different phone; use
1921
+ * `updatePlayerPhone`), 409 `err.isPhoneShareRefused` (the phone belongs to another
1922
+ * email), 400 `INVALID_INPUT` / `INVALID_PHONE`, 429 (`err.retryAfter`).
1923
+ */
1924
+ async registerPlayer(input, opts) {
1925
+ if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
1926
+ throw invalidInput("playerEmail", input.playerEmail, "is required");
1927
+ }
1928
+ assertE164(input.playerPhone, "playerPhone");
1929
+ const body = {
1930
+ player_email: input.playerEmail,
1931
+ player_phone: input.playerPhone
1932
+ };
1933
+ if (input.playerName !== void 0) {
1934
+ if (typeof input.playerName !== "string") {
1935
+ throw invalidInput("playerName", input.playerName, "must be a string");
1936
+ }
1937
+ body["player_name"] = input.playerName;
1938
+ }
1939
+ const raw = await this.http.post(
1940
+ "/api/sdk/players",
1941
+ body,
1942
+ this.auth,
1943
+ // Find-or-create, no money: a retry after a create answers "exists".
1944
+ { idempotent: true, signal: opts?.signal }
1945
+ );
1946
+ const status = requireField(raw["status"], "status", raw);
1947
+ return {
1948
+ status: status === "created" ? "created" : "exists",
1949
+ identityId: String(raw["identity_id"] ?? ""),
1950
+ ...playerTokenFields(raw),
1951
+ raw
1952
+ };
1953
+ }
1954
+ /**
1955
+ * Set a player's phone from your server (`POST /api/sdk/players/phone`). A phone change
1956
+ * can give the player a new INVO identity: `identityRekeyed: true`, and the result
1957
+ * carries a fresh `playerToken` for it (tokens minted before the change are then out
1958
+ * of date).
1959
+ *
1960
+ * Refusals: 409 `err.isPhoneChangeRequiresVerification` (the player has secured this
1961
+ * account, so the change needs the player's own confirmation; contact INVO support
1962
+ * meanwhile), 409 `err.isPhoneShareRefused` (the number belongs to another email),
1963
+ * 404 `err.isPlayerNotFound`, 400 `INVALID_INPUT` / `INVALID_PHONE`, 429
1964
+ * (`err.retryAfter`), 503 (could not be checked right now; try again shortly).
1965
+ *
1966
+ * Never auto-retried: a retry after a change that landed would answer `"unchanged"` and
1967
+ * hide `identityRekeyed`.
1968
+ */
1969
+ async updatePlayerPhone(input, opts) {
1970
+ if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
1971
+ throw invalidInput("playerEmail", input.playerEmail, "is required");
1972
+ }
1973
+ assertE164(input.newPhone, "newPhone");
1974
+ const raw = await this.http.post(
1975
+ "/api/sdk/players/phone",
1976
+ { player_email: input.playerEmail, new_phone: input.newPhone },
1977
+ this.auth,
1978
+ { signal: opts?.signal }
1979
+ );
1980
+ const status = requireField(raw["status"], "status", raw);
1981
+ return {
1982
+ status: status === "updated" ? "updated" : "unchanged",
1983
+ identityRekeyed: raw["identity_rekeyed"] === true,
1984
+ identityId: String(raw["identity_id"] ?? ""),
1985
+ ...playerTokenFields(raw),
1986
+ raw
1987
+ };
1890
1988
  }
1891
1989
  /**
1892
1990
  * Initiate a cross-game currency SEND. Inspect result.verificationMethod.
@@ -2459,6 +2557,32 @@ var InvoServer = class {
2459
2557
  raw
2460
2558
  };
2461
2559
  }
2560
+ /**
2561
+ * One player's loyalty cards, read by your SERVER with the game secret: the same cards
2562
+ * the player sees through `InvoClient.getMyRewards()`, for the player with this email in
2563
+ * your game. Each step carries `state` and `progress` (`{ current, target }`, or `null`
2564
+ * when the number could not be read this time: render `state` alone then). Rewards carry
2565
+ * their masked code only; a code is never returned here.
2566
+ *
2567
+ * Refusals (all `InvoError`): a blank email throws `INVALID_INPUT` before the network;
2568
+ * `400 INVALID_PLAYER_EMAIL` (`err.isInvalidPlayerEmail`), `401 INVALID_GAME_SECRET` for a missing or wrong key, or
2569
+ * a per-channel key (this read takes the game's server secret only), `404 PLAYER_NOT_FOUND`
2570
+ * (`err.isPlayerNotFound`: no player with this email in this game), `429` (back off;
2571
+ * `err.retryAfter`). Also `409 NO_TENANT` (the game is not set up for loyalty), `503`
2572
+ * (temporarily unavailable) and `502` / `504` (the loyalty service could not be reached or
2573
+ * timed out): retry later. A GET, so transient failures are retried automatically.
2574
+ */
2575
+ async getPlayerRewards(playerEmail, opts) {
2576
+ if (typeof playerEmail !== "string" || !playerEmail.trim()) {
2577
+ throw invalidInput("playerEmail", playerEmail, "is required");
2578
+ }
2579
+ const raw = await this.http.get(
2580
+ `/api/sdk/loyalty/players/rewards?player_email=${encodeURIComponent(playerEmail.trim())}`,
2581
+ this.auth,
2582
+ { signal: opts?.signal }
2583
+ );
2584
+ return toLoyaltyCardsResult(raw);
2585
+ }
2462
2586
  /**
2463
2587
  * List LIVE, unclaimed inbound sends/transfers addressed to a player at YOUR game —
2464
2588
  * the source of truth for a "you have X to collect" badge. Pass the player's email
@@ -2908,8 +3032,10 @@ var InvoServer = class {
2908
3032
  *
2909
3033
  * Throws `InvoError`: `err.isDeviceApprovalNotApproved` (400 — wrong/foreign code,
2910
3034
  * wrong flow, or the poll never said approved), `err.isPasskeyRecoveryCooldown` (403,
2911
- * money-out after a passkey recovery — `err.retryAfterAt`), guardian terminal states
2912
- * (410). Never auto-retried: the device_code is a single-use factor.
3035
+ * money-out after a passkey recovery — `err.retryAfterAt`), `err.isPlayerTokenStale`
3036
+ * (403, the player token predates the sender's phone being added: re-mint, or use the
3037
+ * initiate's `playerToken`, and retry once), guardian terminal states (410). Never
3038
+ * auto-retried: the device_code is a single-use factor.
2913
3039
  *
2914
3040
  * **A FAILURE HERE IS AMBIGUOUS ABOUT THE MONEY.** The backend commits the transfer and
2915
3041
  * *then* builds its 200 by reading the transaction back, so a fault raised after that
@@ -3066,6 +3192,10 @@ var InvoServer = class {
3066
3192
  transactionId: String(raw["transaction_id"] ?? ""),
3067
3193
  verificationMethod: guardian ? void 0 : vm === "in_app" || vm === "sms" ? vm : void 0,
3068
3194
  guardianApproval: guardian ?? void 0,
3195
+ ...raw["identity_rekeyed"] === true ? { identityRekeyed: true } : {},
3196
+ ...playerTokenFields(raw),
3197
+ ...typeof raw["identity_id"] === "string" && raw["identity_id"] ? { identityId: raw["identity_id"] } : {},
3198
+ ...typeof raw["claim_delivery_planned"] === "string" && raw["claim_delivery_planned"] ? { claimDeliveryPlanned: raw["claim_delivery_planned"] } : {},
3069
3199
  raw
3070
3200
  };
3071
3201
  }