@invonetwork/web-sdk 3.20.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/CHANGELOG.md +17 -0
- package/README.md +78 -14
- package/dist/{chunk-6IY4473A.js → chunk-7L4O5Q7K.js} +40 -3
- package/dist/index.cjs +49 -3
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +13 -4
- package/dist/server.cjs +156 -15
- package/dist/server.d.cts +48 -19
- package/dist/server.d.ts +48 -19
- package/dist/server.js +120 -16
- package/dist/{types-BwgkJoM6.d.cts → types-BXcPz6Xw.d.cts} +113 -1
- package/dist/{types-BwgkJoM6.d.ts → types-BXcPz6Xw.d.ts} +113 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0238b53: Player registration, phone changes and identity re-key. Server: `mintPlayerToken` takes optional
|
|
8
|
+
`playerPhone` and `playerName`; with a phone, a player new to your title is created, and the
|
|
9
|
+
result now carries `created` and `phoneMismatch` (previously dropped). New
|
|
10
|
+
`registerPlayer({ playerEmail, playerPhone, playerName? })` (`POST /api/sdk/players`) and
|
|
11
|
+
`updatePlayerPhone({ playerEmail, newPhone })` (`POST /api/sdk/players/phone`, never
|
|
12
|
+
auto-retried). `initiateSend` / `initiateTransfer` results expose `identityRekeyed`,
|
|
13
|
+
`playerToken`, `playerTokenExpiresAt`, `identityId` and `claimDeliveryPlanned`; approve results
|
|
14
|
+
expose `claimDelivery`. New error predicates `isPlayerTokenStale`,
|
|
15
|
+
`isPhoneChangeRequiresVerification`, `isPhoneMismatch`, `isPhoneShareRefused`;
|
|
16
|
+
`isPlayerNotFound` also recognises the codeless `player_not_found` 404. A 403
|
|
17
|
+
`PLAYER_TOKEN_STALE` on approve is surfaced, never auto-retried: re-mint and retry once.
|
|
18
|
+
Additive only. README section "Registering players and changing their phone".
|
|
19
|
+
|
|
3
20
|
## 3.20.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -93,6 +93,7 @@ The right approval method is a property of the **client the player is sitting in
|
|
|
93
93
|
- [Passkeys are the gold standard — don't build on SMS](#passkeys-are-the-gold-standard--dont-build-on-sms)
|
|
94
94
|
- [Install](#install)
|
|
95
95
|
- [Architecture & the two entry points](#architecture--the-two-entry-points)
|
|
96
|
+
- [Registering players and changing their phone](#registering-players-and-changing-their-phone)
|
|
96
97
|
- [Before you go live](#before-you-go-live)
|
|
97
98
|
- [Configuration](#configuration)
|
|
98
99
|
- [Tiers](#tiers)
|
|
@@ -173,28 +174,86 @@ Build and test against the **dev console + sandbox** first, then switch to the *
|
|
|
173
174
|
|
|
174
175
|
### Player token (session mint for an existing player)
|
|
175
176
|
|
|
176
|
-
`mintPlayerToken` mints a short-lived, game-scoped **session token** for a player
|
|
177
|
-
**already exists**
|
|
178
|
-
|
|
179
|
-
such player exists). It only needs `playerEmail`:
|
|
177
|
+
`mintPlayerToken` mints a short-lived, game-scoped **session token** for a player. For a
|
|
178
|
+
player who **already exists** in your title it looks them up by `playerEmail` and returns a
|
|
179
|
+
token for their identity; it only needs `playerEmail`:
|
|
180
180
|
|
|
181
181
|
```ts
|
|
182
182
|
// your backend
|
|
183
183
|
const { token } = await invo.mintPlayerToken({ playerEmail: "player@example.com" });
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
For a player who is **not in your title yet**, the answer depends on `playerPhone`:
|
|
187
|
+
|
|
188
|
+
- without `playerPhone`: `404`, `err.isPlayerNotFound` (unchanged behaviour);
|
|
189
|
+
- with `playerPhone` (E.164) and optionally `playerName`: INVO **creates** the player and
|
|
190
|
+
the result carries `created: true`. A first-time receiver can then collect in-game without
|
|
191
|
+
buying first.
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
const t = await invo.mintPlayerToken({
|
|
195
|
+
playerEmail: "player@example.com",
|
|
196
|
+
playerPhone: "+15555550100",
|
|
197
|
+
playerName: "Pat",
|
|
198
|
+
});
|
|
199
|
+
if (t.created) { /* the player was new to your title */ }
|
|
200
|
+
if (t.phoneMismatch) { /* they exist with a different phone; see updatePlayerPhone */ }
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
An existing player's phone is **never changed** by this call. When it differs from the
|
|
204
|
+
`playerPhone` you passed, the token is still minted for that player and the result carries
|
|
205
|
+
`phoneMismatch: true`. A phone that already belongs to another email is a `409`
|
|
206
|
+
(`err.isPhoneShareRefused`).
|
|
188
207
|
|
|
189
208
|
**Where phone actually matters.** A player's INVO identity encodes their phone, and cross-game
|
|
190
|
-
money routing keys off it
|
|
209
|
+
money routing keys off it:
|
|
191
210
|
|
|
192
211
|
- **`initiateSend` / `initiateTransfer`** require the **sender's** phone (E.164), and take the
|
|
193
|
-
**recipient's** phone. You can send by the recipient's **phone alone
|
|
212
|
+
**recipient's** phone. You can send by the recipient's **phone alone**; they supply their
|
|
194
213
|
email when they claim.
|
|
195
214
|
- An account with no phone can't receive cross-game money and can't take part in the
|
|
196
|
-
account-linking consent
|
|
197
|
-
(
|
|
215
|
+
account-linking consent, so make sure players have a phone at **creation / enrollment**
|
|
216
|
+
(`registerPlayer`, or `mintPlayerToken` with `playerPhone`), before they transact.
|
|
217
|
+
|
|
218
|
+
### Registering players and changing their phone
|
|
219
|
+
|
|
220
|
+
Two server calls, both authenticated with your game secret, neither moves money nor sends the
|
|
221
|
+
player a message.
|
|
222
|
+
|
|
223
|
+
**`registerPlayer({ playerEmail, playerPhone, playerName? })`** creates the player in your
|
|
224
|
+
title. It returns `status: "created"` (new) or `status: "exists"` (already in your title with
|
|
225
|
+
that phone), the `identityId`, and a `playerToken` / `playerTokenExpiresAt` when INVO can issue
|
|
226
|
+
one for your title, so you can hand the browser a token straight away.
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
const reg = await invo.registerPlayer({
|
|
230
|
+
playerEmail: "player@example.com",
|
|
231
|
+
playerPhone: "+15555550100",
|
|
232
|
+
playerName: "Pat",
|
|
233
|
+
});
|
|
234
|
+
// reg.status: "created" | "exists"; reg.playerToken may be present
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**`updatePlayerPhone({ playerEmail, newPhone })`** sets the phone of a player already in your
|
|
238
|
+
title. It returns `status: "updated"` or `status: "unchanged"`, and `identityRekeyed`. A phone
|
|
239
|
+
change can give the player a **new INVO identity**: when `identityRekeyed` is `true`, every
|
|
240
|
+
player token minted before the change is out of date, so use the `playerToken` in the result
|
|
241
|
+
(or mint a new one). This call is never retried automatically.
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
const upd = await invo.updatePlayerPhone({ playerEmail: "player@example.com", newPhone: "+15555550111" });
|
|
245
|
+
if (upd.identityRekeyed && upd.playerToken) handTokenToBrowser(upd.playerToken);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
| Refusal | HTTP | Means | Do |
|
|
249
|
+
|---|---|---|---|
|
|
250
|
+
| `err.isPhoneMismatch` (`PHONE_MISMATCH`) | 409 | `registerPlayer`: the player is already in your title with a **different** phone. Nothing changed. | Call `updatePlayerPhone` if the change is genuine. |
|
|
251
|
+
| `err.isPhoneShareRefused` (`PHONE_SHARE_APPROVAL_REQUIRED`) | 409 | The phone belongs to another email. Nothing was created or changed. Same code as `err.isPhoneShareApprovalRequired`. | Show `err.message`; ask the player to check the number. |
|
|
252
|
+
| `err.isPhoneChangeRequiresVerification` (`PHONE_CHANGE_REQUIRES_VERIFICATION`) | 409 | `updatePlayerPhone`: the player has secured this account, so the change needs the player's own confirmation. Nothing changed. | Until that flow is available, contact INVO support to change it. |
|
|
253
|
+
| `err.isPlayerNotFound` | 404 | `updatePlayerPhone` (or `mintPlayerToken` without `playerPhone`): no player with that email in your title. | Create the player first (`registerPlayer`). |
|
|
254
|
+
| `INVALID_INPUT` / `INVALID_PHONE` | 400 | A missing email or phone, or a phone INVO does not accept. | Fix the input. The SDK also refuses a non-E.164 phone before the network (`status === 0`). |
|
|
255
|
+
| rate limited | 429 | Too many registrations or phone changes for this player. | Back off by `err.retryAfter`. |
|
|
256
|
+
| `PHONE_UPDATE_UNAVAILABLE` | 503 | `updatePlayerPhone` could not be checked right now. Nothing changed. | Try again shortly. |
|
|
198
257
|
|
|
199
258
|
### Token bootstrap (both modes)
|
|
200
259
|
|
|
@@ -1587,6 +1646,7 @@ the same one: a grant approved for `transfer` settles nothing else.
|
|
|
1587
1646
|
| `TRANSACTION_NOT_PENDING` | 400 | The transaction is not at this step. Three different situations: your earlier attempt **already landed**; the transaction is **dead** (expired / refunded); or — on a receipt flow — it has **not got here yet**, because the sender's own approval is still pending or held at a guardian. | **Not thrown by `approveWithDeviceCode`** — it comes back as `{ status: "not_pending", alreadySettled, currentStatus }`. `alreadySettled` separates the first case from the other two. When it is `false`, go read `getTransferStatus` / `getSendStatus` rather than assuming; never retry-loop. |
|
|
1588
1647
|
| `DEVICE_APPROVAL_NOT_APPROVED` | 400 | The `device_code` was unknown, another player's, bound to a different transaction, bound to a different **flow**, or the player has not approved yet. One answer for all five, deliberately — distinguishing them would leak which transactions have a live approval. | `err.isDeviceApprovalNotApproved`. Check the `flow` matches the `begin`, and that the poll actually said `approved`. |
|
|
1589
1648
|
| `DEVICE_APPROVAL_ALREADY_PENDING` | 409 | An **approved** grant for this transaction and flow is still inside its window. The player already approved. | `err.isDeviceApprovalAlreadyPending`, `err.deviceApprovalExpiresAt`. You are missing stage 4, not a new code — call `approveWithDeviceCode` with the code you have. (A merely *pending* earlier grant does **not** 409; `begin` supersedes it.) |
|
|
1649
|
+
| `PLAYER_TOKEN_STALE` | 403 | The player token predates a change to the sender's identity: their phone was added (often on this very initiate), which gives them a new identity. Nothing moved; the old token stays refused. | `err.isPlayerTokenStale`. The SDK does not retry money calls itself: re-mint the player token (or use `playerToken` from the initiate result, present when `identityRekeyed` is `true`) and retry the approve **once**. |
|
|
1590
1650
|
| `PASSKEY_RECOVERY_COOLDOWN` | 403 | Money **out** is paused for 24 h after a passkey recovery (SIM-swap protection). Receiving and collecting are unaffected. | `err.isPasskeyRecoveryCooldown`, `err.retryAfterAt` (ISO; the body also carries `retry_after_seconds`). Expect a fresh initiate later — do not retry-loop. |
|
|
1591
1651
|
| `SEND_APPROVE_FAILED`, `TRANSFER_APPROVE_FAILED`, `CONFIRM_RECEIPT_FAILED` | 400 | A **fault** on INVO's side, not a rule. `err.isSettleFault`; the body carries **`error_ref`** (`err.errorRef`). | Never retryable. See the ambiguity note below — do **not** tell the player it failed until you have read the transaction. Quote `errorRef` to INVO support; it names the exact server log line. |
|
|
1592
1652
|
| guardian hold | 202 | A minor's transaction is waiting on a guardian. **The money is held, not refused.** | Returned as a result with `holdReason`; poll `getGuardianApprovalStatus`. Terminal outcomes (`GUARDIAN_APPROVAL_REJECTED` / `_EXPIRED`) throw as 410. |
|
|
@@ -2370,6 +2430,8 @@ Helpers:
|
|
|
2370
2430
|
| `.isEnrollmentAuthorizationRequired` | first-enrollment needs the OTP grant → `enrollmentBegin`/`enrollmentVerify` |
|
|
2371
2431
|
| `.isEnrollmentProofRequired` | another method exists → prove it via `linkDevice` |
|
|
2372
2432
|
| `.isPhoneShareApprovalRequired` | phone needs owner approval — at register/mint **or** at claim/`confirmReceipt*` (contested receiver phone) → show `.message` (+ `.phoneShareLast4`), retry the same call after approval |
|
|
2433
|
+
| `.isPhoneShareRefused` / `.isPhoneMismatch` / `.isPhoneChangeRequiresVerification` | `mintPlayerToken` / `registerPlayer` / `updatePlayerPhone` refusals (409); see [Registering players and changing their phone](#registering-players-and-changing-their-phone) |
|
|
2434
|
+
| `.isPlayerTokenStale` | approve refused (403 `PLAYER_TOKEN_STALE`): the token predates the sender's phone being added. Re-mint (or use the initiate's `playerToken`) and retry once; never auto-retried |
|
|
2373
2435
|
| `.isSteamValueNonTransferable` | initiate blocked (409): would move more than the non-Steam balance to a non-Steam destination → show `.message`, cap input at `.steamTransferableMax` (`.steamOriginAmount` = Steam-locked portion) |
|
|
2374
2436
|
| `.isNonSteamValueIntoSteamBlocked` | initiate blocked (409): non-Steam value can't move into a Steam title → show `.message`, pick a non-Steam destination |
|
|
2375
2437
|
| `.isPhoneShareAlreadyApproved` | phone-share was already approved (e.g. from a `/reject`) |
|
|
@@ -2399,9 +2461,11 @@ try {
|
|
|
2399
2461
|
|
|
2400
2462
|
| Method | Returns |
|
|
2401
2463
|
|---|---|
|
|
2402
|
-
| `mintPlayerToken({ playerEmail, playerPhone? })` | `{ token, expiresAt, identityId }
|
|
2403
|
-
| `
|
|
2404
|
-
| `
|
|
2464
|
+
| `mintPlayerToken({ playerEmail, playerPhone?, playerName? })` | `{ token, expiresAt, identityId, created?, phoneMismatch? }`: session mint; an unknown player is a 404 without `playerPhone` and is created with it (`created: true`); an existing player's phone is never changed (`phoneMismatch: true` when it differs). See [Player token](#player-token-session-mint-for-an-existing-player) |
|
|
2465
|
+
| `registerPlayer({ playerEmail, playerPhone, playerName? })` | `{ status: "created" \| "exists", identityId, playerToken?, playerTokenExpiresAt?, raw }`; moves no money. `isPhoneMismatch` / `isPhoneShareRefused` |
|
|
2466
|
+
| `updatePlayerPhone({ playerEmail, newPhone })` | `{ status: "updated" \| "unchanged", identityRekeyed, identityId, playerToken?, playerTokenExpiresAt?, raw }`; never auto-retried. `isPhoneChangeRequiresVerification` / `isPhoneShareRefused` / `isPlayerNotFound` |
|
|
2467
|
+
| `initiateSend(input)` | `{ transactionId, verificationMethod, guardianApproval?, identityRekeyed?, playerToken?, playerTokenExpiresAt?, identityId?, claimDeliveryPlanned?, raw }`; when `identityRekeyed` is `true`, hand the browser `playerToken` before it approves |
|
|
2468
|
+
| `initiateTransfer(input)` | same as `initiateSend` |
|
|
2405
2469
|
| `createCheckout(input)` | `{ sessionId, checkoutUrl, sessionToken?, expiresAt, expiresInSeconds, warnings?, minPurchaseWarning?, raw }` (`minPurchaseWarning` while an amount under INVO's minimum card purchase is still accepted), where `sessionToken` is INVO's own `session_token` field (falling back to the `checkoutUrl` query string on a backend that predates it) and is the credential for the [status read](#did-the-purchase-go-through-the-status-read) |
|
|
2406
2470
|
| `quoteCurrencyPurchase({ playerEmail, usdAmount, country?, subdivision? })` | `CurrencyPurchaseQuote`: `{ totalUsd, amountCents, subtotalUsd, processingFeeUsd, partnerFeeUsd?, internationalCardFeeUsd?, feeTakenFrom?, minPurchaseWarning?, coins, currencyName, breakdown, ifUnacknowledged, raw }`; moves no money; send `totalUsd` back as `acknowledgedTotalUsd` (see [INVO's card fee](#invos-card-fee-quote-show-acknowledge)) |
|
|
2407
2471
|
| `purchaseCurrency(input)` | `{ status, clientSecret?, paymentIntentId?, paymentUrl?, transactionId?, orderId?, newBalance?, processingFeeUsd?, feeTakenFrom?, partnerFeeUsd?, internationalCardFeeUsd?, minPurchaseWarning?, coinsCredited?, chargeTotalUsd?, receiptNumber?, receiptUrl?, raw }`; optional `acknowledgedTotalUsd`, `country` and `subdivision` inputs; `receiptNumber` / `receiptUrl` on Merchant of Record only |
|
|
@@ -2456,7 +2520,7 @@ Every method also accepts an optional final `{ signal }` (`AbortSignal`) for can
|
|
|
2456
2520
|
| `enrollPasskey()` | `{ status, device, raw }` |
|
|
2457
2521
|
| `enrollmentBegin()` / `enrollmentVerify(code)` | OTP grant for `ENROLLMENT_REQUIRES_AUTHORIZATION` (then retry `enrollPasskey`) |
|
|
2458
2522
|
| `recoveryBegin()` / `recoveryComplete(code)` | passkey recovery for `ENROLLMENT_REQUIRES_PROOF` when the passkey was lost/deleted (then retry `enrollPasskey`) — recovered keys can't move money OUT for 24h (`PASSKEY_RECOVERY_COOLDOWN`) |
|
|
2459
|
-
| `approveSend(txnId)` / `approveTransfer(txnId)` | `{ status, next, transactionId, claimCode?, claimCodeExpiresAt?, holdReason?, risk?, guardianApproval?, pollEndpoint?, raw }` |
|
|
2523
|
+
| `approveSend(txnId)` / `approveTransfer(txnId)` | `{ status, next, transactionId, claimCode?, claimCodeExpiresAt?, holdReason?, risk?, guardianApproval?, pollEndpoint?, claimDelivery?, raw }`; `claimDelivery` is `"email"`, `"none"` or legacy `"sms"`. 403 `err.isPlayerTokenStale`: re-mint and retry once (never auto-retried) |
|
|
2460
2524
|
| `confirmReceiptSend(txnId)` / `confirmReceiptTransfer(txnId)` | `{ status, holdReason?, raw }` |
|
|
2461
2525
|
| `linkDevice()` | `{ status, raw }` — call with no arguments; the server mints the link id (a value passed by 3.10-era code is still accepted and ignored) |
|
|
2462
2526
|
| `getPendingCollect()` | `{ pending, raw }` — the player's own pending-to-collect list (player-token) |
|
|
@@ -820,7 +820,44 @@ var InvoError = class _InvoError extends Error {
|
|
|
820
820
|
* `getPlayerRewards` answers it when no player has that email in this game.
|
|
821
821
|
*/
|
|
822
822
|
get isPlayerNotFound() {
|
|
823
|
-
|
|
823
|
+
if (this.code === "PLAYER_NOT_FOUND") return true;
|
|
824
|
+
return this.status === 404 && this.bodyObject()["error"] === "player_not_found";
|
|
825
|
+
}
|
|
826
|
+
// ---- Player registration, phone changes, identity re-key ----
|
|
827
|
+
/**
|
|
828
|
+
* True when an approve was refused because the player token predates a change to the
|
|
829
|
+
* sender's identity (`PLAYER_TOKEN_STALE`, 403): their phone was added (for example on
|
|
830
|
+
* the initiate), which gives them a new identity. Nothing moved and the token stays
|
|
831
|
+
* refused. Re-mint the player token (or use the `playerToken` from the initiate result)
|
|
832
|
+
* and retry once. The SDK never retries a money call on its own.
|
|
833
|
+
*/
|
|
834
|
+
get isPlayerTokenStale() {
|
|
835
|
+
return this.code === "PLAYER_TOKEN_STALE";
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* True when `updatePlayerPhone` was refused because the player has secured this account,
|
|
839
|
+
* so the change needs the player's own confirmation (`PHONE_CHANGE_REQUIRES_VERIFICATION`,
|
|
840
|
+
* 409). Nothing changed. Until that confirmation flow is available, contact INVO support.
|
|
841
|
+
*/
|
|
842
|
+
get isPhoneChangeRequiresVerification() {
|
|
843
|
+
return this.code === "PHONE_CHANGE_REQUIRES_VERIFICATION";
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* True when `registerPlayer` found the player already in your game with a DIFFERENT
|
|
847
|
+
* phone (`PHONE_MISMATCH`, 409). Nothing changed; use `updatePlayerPhone` to change it.
|
|
848
|
+
* (`mintPlayerToken` reports the same situation as `phoneMismatch: true` on success.)
|
|
849
|
+
*/
|
|
850
|
+
get isPhoneMismatch() {
|
|
851
|
+
return this.code === "PHONE_MISMATCH";
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* True when the phone you supplied belongs to another email
|
|
855
|
+
* (`PHONE_SHARE_APPROVAL_REQUIRED`, 409) on `mintPlayerToken`, `registerPlayer` or
|
|
856
|
+
* `updatePlayerPhone`. Nothing was created or changed. The same condition as
|
|
857
|
+
* {@link isPhoneShareApprovalRequired}, named for these registration calls.
|
|
858
|
+
*/
|
|
859
|
+
get isPhoneShareRefused() {
|
|
860
|
+
return this.isPhoneShareApprovalRequired;
|
|
824
861
|
}
|
|
825
862
|
/**
|
|
826
863
|
* True when `cards.createSetupSession` was asked to create a new member (`playerName`
|
|
@@ -1321,5 +1358,5 @@ function toRewardsPageLink(raw) {
|
|
|
1321
1358
|
}
|
|
1322
1359
|
|
|
1323
1360
|
export { Http, InvoError, assertSecureBaseUrl, creditFields, receiptFields, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink };
|
|
1324
|
-
//# sourceMappingURL=chunk-
|
|
1325
|
-
//# sourceMappingURL=chunk-
|
|
1361
|
+
//# sourceMappingURL=chunk-7L4O5Q7K.js.map
|
|
1362
|
+
//# sourceMappingURL=chunk-7L4O5Q7K.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -822,7 +822,44 @@ var InvoError = class _InvoError extends Error {
|
|
|
822
822
|
* `getPlayerRewards` answers it when no player has that email in this game.
|
|
823
823
|
*/
|
|
824
824
|
get isPlayerNotFound() {
|
|
825
|
-
|
|
825
|
+
if (this.code === "PLAYER_NOT_FOUND") return true;
|
|
826
|
+
return this.status === 404 && this.bodyObject()["error"] === "player_not_found";
|
|
827
|
+
}
|
|
828
|
+
// ---- Player registration, phone changes, identity re-key ----
|
|
829
|
+
/**
|
|
830
|
+
* True when an approve was refused because the player token predates a change to the
|
|
831
|
+
* sender's identity (`PLAYER_TOKEN_STALE`, 403): their phone was added (for example on
|
|
832
|
+
* the initiate), which gives them a new identity. Nothing moved and the token stays
|
|
833
|
+
* refused. Re-mint the player token (or use the `playerToken` from the initiate result)
|
|
834
|
+
* and retry once. The SDK never retries a money call on its own.
|
|
835
|
+
*/
|
|
836
|
+
get isPlayerTokenStale() {
|
|
837
|
+
return this.code === "PLAYER_TOKEN_STALE";
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* True when `updatePlayerPhone` was refused because the player has secured this account,
|
|
841
|
+
* so the change needs the player's own confirmation (`PHONE_CHANGE_REQUIRES_VERIFICATION`,
|
|
842
|
+
* 409). Nothing changed. Until that confirmation flow is available, contact INVO support.
|
|
843
|
+
*/
|
|
844
|
+
get isPhoneChangeRequiresVerification() {
|
|
845
|
+
return this.code === "PHONE_CHANGE_REQUIRES_VERIFICATION";
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* True when `registerPlayer` found the player already in your game with a DIFFERENT
|
|
849
|
+
* phone (`PHONE_MISMATCH`, 409). Nothing changed; use `updatePlayerPhone` to change it.
|
|
850
|
+
* (`mintPlayerToken` reports the same situation as `phoneMismatch: true` on success.)
|
|
851
|
+
*/
|
|
852
|
+
get isPhoneMismatch() {
|
|
853
|
+
return this.code === "PHONE_MISMATCH";
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* True when the phone you supplied belongs to another email
|
|
857
|
+
* (`PHONE_SHARE_APPROVAL_REQUIRED`, 409) on `mintPlayerToken`, `registerPlayer` or
|
|
858
|
+
* `updatePlayerPhone`. Nothing was created or changed. The same condition as
|
|
859
|
+
* {@link isPhoneShareApprovalRequired}, named for these registration calls.
|
|
860
|
+
*/
|
|
861
|
+
get isPhoneShareRefused() {
|
|
862
|
+
return this.isPhoneShareApprovalRequired;
|
|
826
863
|
}
|
|
827
864
|
/**
|
|
828
865
|
* True when `cards.createSetupSession` was asked to create a new member (`playerName`
|
|
@@ -2082,6 +2119,7 @@ function toApproveResult(raw, transactionId) {
|
|
|
2082
2119
|
risk: raw["risk"],
|
|
2083
2120
|
guardianApproval: raw["guardian_approval"] ?? void 0,
|
|
2084
2121
|
pollEndpoint: raw["poll_endpoint"],
|
|
2122
|
+
...typeof raw["claim_delivery"] === "string" && raw["claim_delivery"] ? { claimDelivery: raw["claim_delivery"] } : {},
|
|
2085
2123
|
raw
|
|
2086
2124
|
};
|
|
2087
2125
|
}
|
|
@@ -2443,11 +2481,19 @@ var InvoClient = class {
|
|
|
2443
2481
|
};
|
|
2444
2482
|
return runHostedApproval(opts, api);
|
|
2445
2483
|
}
|
|
2446
|
-
/**
|
|
2484
|
+
/**
|
|
2485
|
+
* Approve a SEND with the player's passkey.
|
|
2486
|
+
*
|
|
2487
|
+
* Throws 403 `err.isPlayerTokenStale` when the player token predates a change to the
|
|
2488
|
+
* sender's identity (their phone was added on the initiate). Not retried automatically,
|
|
2489
|
+
* because this call moves money: re-mint the player token (or use the `playerToken`
|
|
2490
|
+
* your server got back from `initiateSend`) and retry once.
|
|
2491
|
+
*/
|
|
2447
2492
|
async approveSend(transactionId, opts) {
|
|
2448
2493
|
return this.approve("send", transactionId, opts);
|
|
2449
2494
|
}
|
|
2450
|
-
/** Approve a TRANSFER with the player's passkey (returns the sender's claim code).
|
|
2495
|
+
/** Approve a TRANSFER with the player's passkey (returns the sender's claim code). Same
|
|
2496
|
+
* `err.isPlayerTokenStale` handling as {@link approveSend}: re-mint and retry once. */
|
|
2451
2497
|
async approveTransfer(transactionId, opts) {
|
|
2452
2498
|
return this.approve("transfers", transactionId, opts);
|
|
2453
2499
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ApproveResult, C as ConfirmReceiptResult, P as PurchaseStatusResult, a as PurchaseCredited, b as PurchaseExpired, c as PurchaseRefunded, d as PurchaseRefused, e as CheckoutClientConfig, H as Http, f as PurchaseStatusInput, g as CallOptions, W as WaitForPurchaseInput, M as MountCheckoutOptions, h as CheckoutMountHandle, i as ClientConfig, L as LinkDeviceResult, j as PendingCollectResult, D as DestinationsQuery, k as DestinationsResult, B as BalanceResult, l as LoyaltyCardsResult, m as LoyaltyVaultResult, R as RedeemRewardResult, n as RewardsPageLink, E as EnrollmentBeginResult, o as EnrollmentVerifyResult, p as RecoveryBeginResult, q as RecoveryCompleteResult } from './types-
|
|
2
|
-
export { r as BalanceRow, s as CheckoutPurchaseStatus, t as DestinationGame, I as InvoError,
|
|
1
|
+
import { A as ApproveResult, C as ConfirmReceiptResult, P as PurchaseStatusResult, a as PurchaseCredited, b as PurchaseExpired, c as PurchaseRefunded, d as PurchaseRefused, e as CheckoutClientConfig, H as Http, f as PurchaseStatusInput, g as CallOptions, W as WaitForPurchaseInput, M as MountCheckoutOptions, h as CheckoutMountHandle, i as ClientConfig, L as LinkDeviceResult, j as PendingCollectResult, D as DestinationsQuery, k as DestinationsResult, B as BalanceResult, l as LoyaltyCardsResult, m as LoyaltyVaultResult, R as RedeemRewardResult, n as RewardsPageLink, E as EnrollmentBeginResult, o as EnrollmentVerifyResult, p as RecoveryBeginResult, q as RecoveryCompleteResult } from './types-BXcPz6Xw.cjs';
|
|
2
|
+
export { r as BalanceRow, s as CheckoutPurchaseStatus, t as ClaimDelivery, u as DestinationGame, I as InvoError, v as InvoErrorInfo, w as InvoHooks, x as InvoRequestInfo, y as InvoResponseInfo, z as LoyaltyCard, F as LoyaltyCardReward, G as LoyaltyCardStep, J as LoyaltyRewardState, K as LoyaltyStepProgress, N as LoyaltyStepState, O as LoyaltyVaultEntry, Q as PendingCollectItem, S as PurchaseRefusalReason, T as Rail, V as VerificationMethod } from './types-BXcPz6Xw.cjs';
|
|
3
3
|
|
|
4
4
|
/** The four device-approval flows (`begin.flow`). */
|
|
5
5
|
type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
|
|
@@ -309,9 +309,17 @@ declare class InvoClient {
|
|
|
309
309
|
flow: "send_receipt" | "transfer_receipt";
|
|
310
310
|
}): Promise<ApproveHostedResult<ConfirmReceiptResult>>;
|
|
311
311
|
approveHosted(opts: ApproveHostedOptions): Promise<ApproveHostedResult>;
|
|
312
|
-
/**
|
|
312
|
+
/**
|
|
313
|
+
* Approve a SEND with the player's passkey.
|
|
314
|
+
*
|
|
315
|
+
* Throws 403 `err.isPlayerTokenStale` when the player token predates a change to the
|
|
316
|
+
* sender's identity (their phone was added on the initiate). Not retried automatically,
|
|
317
|
+
* because this call moves money: re-mint the player token (or use the `playerToken`
|
|
318
|
+
* your server got back from `initiateSend`) and retry once.
|
|
319
|
+
*/
|
|
313
320
|
approveSend(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
|
|
314
|
-
/** Approve a TRANSFER with the player's passkey (returns the sender's claim code).
|
|
321
|
+
/** Approve a TRANSFER with the player's passkey (returns the sender's claim code). Same
|
|
322
|
+
* `err.isPlayerTokenStale` handling as {@link approveSend}: re-mint and retry once. */
|
|
315
323
|
approveTransfer(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
|
|
316
324
|
/**
|
|
317
325
|
* Recipient self-claims a SEND with their passkey.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ApproveResult, C as ConfirmReceiptResult, P as PurchaseStatusResult, a as PurchaseCredited, b as PurchaseExpired, c as PurchaseRefunded, d as PurchaseRefused, e as CheckoutClientConfig, H as Http, f as PurchaseStatusInput, g as CallOptions, W as WaitForPurchaseInput, M as MountCheckoutOptions, h as CheckoutMountHandle, i as ClientConfig, L as LinkDeviceResult, j as PendingCollectResult, D as DestinationsQuery, k as DestinationsResult, B as BalanceResult, l as LoyaltyCardsResult, m as LoyaltyVaultResult, R as RedeemRewardResult, n as RewardsPageLink, E as EnrollmentBeginResult, o as EnrollmentVerifyResult, p as RecoveryBeginResult, q as RecoveryCompleteResult } from './types-
|
|
2
|
-
export { r as BalanceRow, s as CheckoutPurchaseStatus, t as DestinationGame, I as InvoError,
|
|
1
|
+
import { A as ApproveResult, C as ConfirmReceiptResult, P as PurchaseStatusResult, a as PurchaseCredited, b as PurchaseExpired, c as PurchaseRefunded, d as PurchaseRefused, e as CheckoutClientConfig, H as Http, f as PurchaseStatusInput, g as CallOptions, W as WaitForPurchaseInput, M as MountCheckoutOptions, h as CheckoutMountHandle, i as ClientConfig, L as LinkDeviceResult, j as PendingCollectResult, D as DestinationsQuery, k as DestinationsResult, B as BalanceResult, l as LoyaltyCardsResult, m as LoyaltyVaultResult, R as RedeemRewardResult, n as RewardsPageLink, E as EnrollmentBeginResult, o as EnrollmentVerifyResult, p as RecoveryBeginResult, q as RecoveryCompleteResult } from './types-BXcPz6Xw.js';
|
|
2
|
+
export { r as BalanceRow, s as CheckoutPurchaseStatus, t as ClaimDelivery, u as DestinationGame, I as InvoError, v as InvoErrorInfo, w as InvoHooks, x as InvoRequestInfo, y as InvoResponseInfo, z as LoyaltyCard, F as LoyaltyCardReward, G as LoyaltyCardStep, J as LoyaltyRewardState, K as LoyaltyStepProgress, N as LoyaltyStepState, O as LoyaltyVaultEntry, Q as PendingCollectItem, S as PurchaseRefusalReason, T as Rail, V as VerificationMethod } from './types-BXcPz6Xw.js';
|
|
3
3
|
|
|
4
4
|
/** The four device-approval flows (`begin.flow`). */
|
|
5
5
|
type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
|
|
@@ -309,9 +309,17 @@ declare class InvoClient {
|
|
|
309
309
|
flow: "send_receipt" | "transfer_receipt";
|
|
310
310
|
}): Promise<ApproveHostedResult<ConfirmReceiptResult>>;
|
|
311
311
|
approveHosted(opts: ApproveHostedOptions): Promise<ApproveHostedResult>;
|
|
312
|
-
/**
|
|
312
|
+
/**
|
|
313
|
+
* Approve a SEND with the player's passkey.
|
|
314
|
+
*
|
|
315
|
+
* Throws 403 `err.isPlayerTokenStale` when the player token predates a change to the
|
|
316
|
+
* sender's identity (their phone was added on the initiate). Not retried automatically,
|
|
317
|
+
* because this call moves money: re-mint the player token (or use the `playerToken`
|
|
318
|
+
* your server got back from `initiateSend`) and retry once.
|
|
319
|
+
*/
|
|
313
320
|
approveSend(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
|
|
314
|
-
/** Approve a TRANSFER with the player's passkey (returns the sender's claim code).
|
|
321
|
+
/** Approve a TRANSFER with the player's passkey (returns the sender's claim code). Same
|
|
322
|
+
* `err.isPlayerTokenStale` handling as {@link approveSend}: re-mint and retry once. */
|
|
315
323
|
approveTransfer(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
|
|
316
324
|
/**
|
|
317
325
|
* Recipient self-claims a SEND with their passkey.
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, receiptFields } from './chunk-
|
|
2
|
-
export { InvoError } from './chunk-
|
|
1
|
+
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, receiptFields } from './chunk-7L4O5Q7K.js';
|
|
2
|
+
export { InvoError } from './chunk-7L4O5Q7K.js';
|
|
3
3
|
|
|
4
4
|
// src/shared/webauthn.ts
|
|
5
5
|
function malformedOptions(field) {
|
|
@@ -770,6 +770,7 @@ function toApproveResult(raw, transactionId) {
|
|
|
770
770
|
risk: raw["risk"],
|
|
771
771
|
guardianApproval: raw["guardian_approval"] ?? void 0,
|
|
772
772
|
pollEndpoint: raw["poll_endpoint"],
|
|
773
|
+
...typeof raw["claim_delivery"] === "string" && raw["claim_delivery"] ? { claimDelivery: raw["claim_delivery"] } : {},
|
|
773
774
|
raw
|
|
774
775
|
};
|
|
775
776
|
}
|
|
@@ -1131,11 +1132,19 @@ var InvoClient = class {
|
|
|
1131
1132
|
};
|
|
1132
1133
|
return runHostedApproval(opts, api);
|
|
1133
1134
|
}
|
|
1134
|
-
/**
|
|
1135
|
+
/**
|
|
1136
|
+
* Approve a SEND with the player's passkey.
|
|
1137
|
+
*
|
|
1138
|
+
* Throws 403 `err.isPlayerTokenStale` when the player token predates a change to the
|
|
1139
|
+
* sender's identity (their phone was added on the initiate). Not retried automatically,
|
|
1140
|
+
* because this call moves money: re-mint the player token (or use the `playerToken`
|
|
1141
|
+
* your server got back from `initiateSend`) and retry once.
|
|
1142
|
+
*/
|
|
1135
1143
|
async approveSend(transactionId, opts) {
|
|
1136
1144
|
return this.approve("send", transactionId, opts);
|
|
1137
1145
|
}
|
|
1138
|
-
/** Approve a TRANSFER with the player's passkey (returns the sender's claim code).
|
|
1146
|
+
/** Approve a TRANSFER with the player's passkey (returns the sender's claim code). Same
|
|
1147
|
+
* `err.isPlayerTokenStale` handling as {@link approveSend}: re-mint and retry once. */
|
|
1139
1148
|
async approveTransfer(transactionId, opts) {
|
|
1140
1149
|
return this.approve("transfers", transactionId, opts);
|
|
1141
1150
|
}
|
package/dist/server.cjs
CHANGED
|
@@ -824,7 +824,44 @@ var InvoError = class _InvoError extends Error {
|
|
|
824
824
|
* `getPlayerRewards` answers it when no player has that email in this game.
|
|
825
825
|
*/
|
|
826
826
|
get isPlayerNotFound() {
|
|
827
|
-
|
|
827
|
+
if (this.code === "PLAYER_NOT_FOUND") return true;
|
|
828
|
+
return this.status === 404 && this.bodyObject()["error"] === "player_not_found";
|
|
829
|
+
}
|
|
830
|
+
// ---- Player registration, phone changes, identity re-key ----
|
|
831
|
+
/**
|
|
832
|
+
* True when an approve was refused because the player token predates a change to the
|
|
833
|
+
* sender's identity (`PLAYER_TOKEN_STALE`, 403): their phone was added (for example on
|
|
834
|
+
* the initiate), which gives them a new identity. Nothing moved and the token stays
|
|
835
|
+
* refused. Re-mint the player token (or use the `playerToken` from the initiate result)
|
|
836
|
+
* and retry once. The SDK never retries a money call on its own.
|
|
837
|
+
*/
|
|
838
|
+
get isPlayerTokenStale() {
|
|
839
|
+
return this.code === "PLAYER_TOKEN_STALE";
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* True when `updatePlayerPhone` was refused because the player has secured this account,
|
|
843
|
+
* so the change needs the player's own confirmation (`PHONE_CHANGE_REQUIRES_VERIFICATION`,
|
|
844
|
+
* 409). Nothing changed. Until that confirmation flow is available, contact INVO support.
|
|
845
|
+
*/
|
|
846
|
+
get isPhoneChangeRequiresVerification() {
|
|
847
|
+
return this.code === "PHONE_CHANGE_REQUIRES_VERIFICATION";
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* True when `registerPlayer` found the player already in your game with a DIFFERENT
|
|
851
|
+
* phone (`PHONE_MISMATCH`, 409). Nothing changed; use `updatePlayerPhone` to change it.
|
|
852
|
+
* (`mintPlayerToken` reports the same situation as `phoneMismatch: true` on success.)
|
|
853
|
+
*/
|
|
854
|
+
get isPhoneMismatch() {
|
|
855
|
+
return this.code === "PHONE_MISMATCH";
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* True when the phone you supplied belongs to another email
|
|
859
|
+
* (`PHONE_SHARE_APPROVAL_REQUIRED`, 409) on `mintPlayerToken`, `registerPlayer` or
|
|
860
|
+
* `updatePlayerPhone`. Nothing was created or changed. The same condition as
|
|
861
|
+
* {@link isPhoneShareApprovalRequired}, named for these registration calls.
|
|
862
|
+
*/
|
|
863
|
+
get isPhoneShareRefused() {
|
|
864
|
+
return this.isPhoneShareApprovalRequired;
|
|
828
865
|
}
|
|
829
866
|
/**
|
|
830
867
|
* True when `cards.createSetupSession` was asked to create a new member (`playerName`
|
|
@@ -1291,7 +1328,7 @@ function receiptFields(raw) {
|
|
|
1291
1328
|
}
|
|
1292
1329
|
|
|
1293
1330
|
// src/version.ts
|
|
1294
|
-
var SDK_VERSION = "3.
|
|
1331
|
+
var SDK_VERSION = "3.21.0";
|
|
1295
1332
|
|
|
1296
1333
|
// src/shared/types.ts
|
|
1297
1334
|
function isRefundPendingApproval(r) {
|
|
@@ -1846,6 +1883,16 @@ function toCurrencyBalance(row) {
|
|
|
1846
1883
|
raw: row
|
|
1847
1884
|
};
|
|
1848
1885
|
}
|
|
1886
|
+
function playerTokenFields(raw) {
|
|
1887
|
+
const out = {};
|
|
1888
|
+
if (typeof raw["player_token"] === "string" && raw["player_token"]) {
|
|
1889
|
+
out.playerToken = raw["player_token"];
|
|
1890
|
+
if (typeof raw["player_token_expires_at"] === "string") {
|
|
1891
|
+
out.playerTokenExpiresAt = raw["player_token_expires_at"];
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
return out;
|
|
1895
|
+
}
|
|
1849
1896
|
function requireField(value, field, raw) {
|
|
1850
1897
|
const s = value == null ? "" : String(value);
|
|
1851
1898
|
if (!s) {
|
|
@@ -3143,16 +3190,19 @@ var InvoServer = class {
|
|
|
3143
3190
|
/**
|
|
3144
3191
|
* Mint a short-lived, game-scoped player token to hand to the browser InvoClient.
|
|
3145
3192
|
*
|
|
3146
|
-
*
|
|
3147
|
-
*
|
|
3148
|
-
*
|
|
3149
|
-
* network identity (which encodes the player's phone) is established when the player
|
|
3150
|
-
* is created and on the money-routing calls, so phone is NOT required or read here.
|
|
3193
|
+
* For a player who already exists in your game, this is a session mint: INVO looks the
|
|
3194
|
+
* player up by `playerEmail` and returns a token for their identity. `playerPhone` and
|
|
3195
|
+
* `playerName` do not change an existing player.
|
|
3151
3196
|
*
|
|
3152
|
-
*
|
|
3153
|
-
*
|
|
3154
|
-
*
|
|
3155
|
-
*
|
|
3197
|
+
* For a player who is NOT in your game yet: without `playerPhone` INVO answers 404
|
|
3198
|
+
* (`err.isPlayerNotFound`); with `playerPhone` INVO creates the player and the result
|
|
3199
|
+
* carries `created: true`, so a first-time receiver can collect without buying first.
|
|
3200
|
+
* Use `registerPlayer` when you want creation to be explicit.
|
|
3201
|
+
*
|
|
3202
|
+
* `phoneMismatch: true` means the existing player has a different phone than the one
|
|
3203
|
+
* you passed; the token is still for that player and their phone is unchanged
|
|
3204
|
+
* (`updatePlayerPhone` changes it). A phone already held by another email is a 409
|
|
3205
|
+
* (`err.isPhoneShareRefused`).
|
|
3156
3206
|
*/
|
|
3157
3207
|
async mintPlayerToken(input, opts) {
|
|
3158
3208
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
@@ -3163,18 +3213,103 @@ var InvoServer = class {
|
|
|
3163
3213
|
assertE164(input.playerPhone, "playerPhone");
|
|
3164
3214
|
body["player_phone"] = input.playerPhone;
|
|
3165
3215
|
}
|
|
3216
|
+
if (input.playerName !== void 0) {
|
|
3217
|
+
if (typeof input.playerName !== "string") {
|
|
3218
|
+
throw invalidInput("playerName", input.playerName, "must be a string");
|
|
3219
|
+
}
|
|
3220
|
+
body["player_name"] = input.playerName;
|
|
3221
|
+
}
|
|
3166
3222
|
const raw = await this.http.post(
|
|
3167
3223
|
"/api/sdk/player-token",
|
|
3168
3224
|
body,
|
|
3169
3225
|
this.auth,
|
|
3226
|
+
// Safe to retry: a re-mint issues a fresh token, and a create that already happened
|
|
3227
|
+
// answers the retry for the existing player.
|
|
3170
3228
|
{ idempotent: true, signal: opts?.signal }
|
|
3171
|
-
// safe to retry: re-mint just issues a fresh token
|
|
3172
3229
|
);
|
|
3173
|
-
|
|
3230
|
+
const out = {
|
|
3174
3231
|
token: requireField(raw["token"], "token", raw),
|
|
3175
3232
|
expiresAt: String(raw["expires_at"] ?? ""),
|
|
3176
3233
|
identityId: String(raw["identity_id"] ?? "")
|
|
3177
3234
|
};
|
|
3235
|
+
if (raw["created"] === true) out.created = true;
|
|
3236
|
+
if (raw["phone_mismatch"] === true) out.phoneMismatch = true;
|
|
3237
|
+
return out;
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* Create a player in your game without moving money (`POST /api/sdk/players`), so a
|
|
3241
|
+
* first-time receiver can collect in-game. Sends no message to the player.
|
|
3242
|
+
*
|
|
3243
|
+
* Returns `status: "created"` (new) or `"exists"` (already in your game with that
|
|
3244
|
+
* phone), with a player token when INVO can issue one. Refusals: 409
|
|
3245
|
+
* `err.isPhoneMismatch` (already in your game with a different phone; use
|
|
3246
|
+
* `updatePlayerPhone`), 409 `err.isPhoneShareRefused` (the phone belongs to another
|
|
3247
|
+
* email), 400 `INVALID_INPUT` / `INVALID_PHONE`, 429 (`err.retryAfter`).
|
|
3248
|
+
*/
|
|
3249
|
+
async registerPlayer(input, opts) {
|
|
3250
|
+
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3251
|
+
throw invalidInput("playerEmail", input.playerEmail, "is required");
|
|
3252
|
+
}
|
|
3253
|
+
assertE164(input.playerPhone, "playerPhone");
|
|
3254
|
+
const body = {
|
|
3255
|
+
player_email: input.playerEmail,
|
|
3256
|
+
player_phone: input.playerPhone
|
|
3257
|
+
};
|
|
3258
|
+
if (input.playerName !== void 0) {
|
|
3259
|
+
if (typeof input.playerName !== "string") {
|
|
3260
|
+
throw invalidInput("playerName", input.playerName, "must be a string");
|
|
3261
|
+
}
|
|
3262
|
+
body["player_name"] = input.playerName;
|
|
3263
|
+
}
|
|
3264
|
+
const raw = await this.http.post(
|
|
3265
|
+
"/api/sdk/players",
|
|
3266
|
+
body,
|
|
3267
|
+
this.auth,
|
|
3268
|
+
// Find-or-create, no money: a retry after a create answers "exists".
|
|
3269
|
+
{ idempotent: true, signal: opts?.signal }
|
|
3270
|
+
);
|
|
3271
|
+
const status = requireField(raw["status"], "status", raw);
|
|
3272
|
+
return {
|
|
3273
|
+
status: status === "created" ? "created" : "exists",
|
|
3274
|
+
identityId: String(raw["identity_id"] ?? ""),
|
|
3275
|
+
...playerTokenFields(raw),
|
|
3276
|
+
raw
|
|
3277
|
+
};
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Set a player's phone from your server (`POST /api/sdk/players/phone`). A phone change
|
|
3281
|
+
* can give the player a new INVO identity: `identityRekeyed: true`, and the result
|
|
3282
|
+
* carries a fresh `playerToken` for it (tokens minted before the change are then out
|
|
3283
|
+
* of date).
|
|
3284
|
+
*
|
|
3285
|
+
* Refusals: 409 `err.isPhoneChangeRequiresVerification` (the player has secured this
|
|
3286
|
+
* account, so the change needs the player's own confirmation; contact INVO support
|
|
3287
|
+
* meanwhile), 409 `err.isPhoneShareRefused` (the number belongs to another email),
|
|
3288
|
+
* 404 `err.isPlayerNotFound`, 400 `INVALID_INPUT` / `INVALID_PHONE`, 429
|
|
3289
|
+
* (`err.retryAfter`), 503 (could not be checked right now; try again shortly).
|
|
3290
|
+
*
|
|
3291
|
+
* Never auto-retried: a retry after a change that landed would answer `"unchanged"` and
|
|
3292
|
+
* hide `identityRekeyed`.
|
|
3293
|
+
*/
|
|
3294
|
+
async updatePlayerPhone(input, opts) {
|
|
3295
|
+
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3296
|
+
throw invalidInput("playerEmail", input.playerEmail, "is required");
|
|
3297
|
+
}
|
|
3298
|
+
assertE164(input.newPhone, "newPhone");
|
|
3299
|
+
const raw = await this.http.post(
|
|
3300
|
+
"/api/sdk/players/phone",
|
|
3301
|
+
{ player_email: input.playerEmail, new_phone: input.newPhone },
|
|
3302
|
+
this.auth,
|
|
3303
|
+
{ signal: opts?.signal }
|
|
3304
|
+
);
|
|
3305
|
+
const status = requireField(raw["status"], "status", raw);
|
|
3306
|
+
return {
|
|
3307
|
+
status: status === "updated" ? "updated" : "unchanged",
|
|
3308
|
+
identityRekeyed: raw["identity_rekeyed"] === true,
|
|
3309
|
+
identityId: String(raw["identity_id"] ?? ""),
|
|
3310
|
+
...playerTokenFields(raw),
|
|
3311
|
+
raw
|
|
3312
|
+
};
|
|
3178
3313
|
}
|
|
3179
3314
|
/**
|
|
3180
3315
|
* Initiate a cross-game currency SEND. Inspect result.verificationMethod.
|
|
@@ -4222,8 +4357,10 @@ var InvoServer = class {
|
|
|
4222
4357
|
*
|
|
4223
4358
|
* Throws `InvoError`: `err.isDeviceApprovalNotApproved` (400 — wrong/foreign code,
|
|
4224
4359
|
* wrong flow, or the poll never said approved), `err.isPasskeyRecoveryCooldown` (403,
|
|
4225
|
-
* money-out after a passkey recovery — `err.retryAfterAt`),
|
|
4226
|
-
* (
|
|
4360
|
+
* money-out after a passkey recovery — `err.retryAfterAt`), `err.isPlayerTokenStale`
|
|
4361
|
+
* (403, the player token predates the sender's phone being added: re-mint, or use the
|
|
4362
|
+
* initiate's `playerToken`, and retry once), guardian terminal states (410). Never
|
|
4363
|
+
* auto-retried: the device_code is a single-use factor.
|
|
4227
4364
|
*
|
|
4228
4365
|
* **A FAILURE HERE IS AMBIGUOUS ABOUT THE MONEY.** The backend commits the transfer and
|
|
4229
4366
|
* *then* builds its 200 by reading the transaction back, so a fault raised after that
|
|
@@ -4380,6 +4517,10 @@ var InvoServer = class {
|
|
|
4380
4517
|
transactionId: String(raw["transaction_id"] ?? ""),
|
|
4381
4518
|
verificationMethod: guardian ? void 0 : vm === "in_app" || vm === "sms" ? vm : void 0,
|
|
4382
4519
|
guardianApproval: guardian ?? void 0,
|
|
4520
|
+
...raw["identity_rekeyed"] === true ? { identityRekeyed: true } : {},
|
|
4521
|
+
...playerTokenFields(raw),
|
|
4522
|
+
...typeof raw["identity_id"] === "string" && raw["identity_id"] ? { identityId: raw["identity_id"] } : {},
|
|
4523
|
+
...typeof raw["claim_delivery_planned"] === "string" && raw["claim_delivery_planned"] ? { claimDeliveryPlanned: raw["claim_delivery_planned"] } : {},
|
|
4383
4524
|
raw
|
|
4384
4525
|
};
|
|
4385
4526
|
}
|