@invonetwork/web-sdk 3.20.0 → 3.22.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/index.cjs CHANGED
@@ -9,6 +9,7 @@ var InvoError = class _InvoError extends Error {
9
9
  this.name = "InvoError";
10
10
  this.code = args.code;
11
11
  this.rawCode = args.rawCode ?? args.code;
12
+ this.publicCode = args.publicCode;
12
13
  this.status = args.status;
13
14
  this.body = args.body ?? null;
14
15
  this.requestId = args.requestId;
@@ -394,7 +395,7 @@ var InvoError = class _InvoError extends Error {
394
395
  * unaffected. Raise the amount; do not retry it unchanged.
395
396
  */
396
397
  get isBelowCardMinimum() {
397
- return this.code === "BELOW_CARD_MINIMUM" || this.rawCode === "BELOW_STRIPE_MINIMUM";
398
+ return this.code === "BELOW_CARD_MINIMUM" || this.code === "BELOW_STRIPE_MINIMUM" || this.publicCode === "BELOW_CARD_MINIMUM" || this.rawCode === "BELOW_STRIPE_MINIMUM";
398
399
  }
399
400
  /** On `BELOW_CARD_MINIMUM`: the minimum card purchase in force (`min_usd`), USD decimal
400
401
  * string, for example `"2.99"`. `undefined` when the body does not carry it. */
@@ -822,7 +823,167 @@ var InvoError = class _InvoError extends Error {
822
823
  * `getPlayerRewards` answers it when no player has that email in this game.
823
824
  */
824
825
  get isPlayerNotFound() {
825
- return this.code === "PLAYER_NOT_FOUND";
826
+ if (this.code === "PLAYER_NOT_FOUND") return true;
827
+ return this.status === 404 && this.bodyObject()["error"] === "player_not_found";
828
+ }
829
+ // ---- Player registration, phone changes, identity re-key ----
830
+ /**
831
+ * True when an approve was refused because the player token predates a change to the
832
+ * sender's identity (`PLAYER_TOKEN_STALE`, 403): their phone was added (for example on
833
+ * the initiate), which gives them a new identity. Nothing moved and the token stays
834
+ * refused. Re-mint the player token (or use the `playerToken` from the initiate result)
835
+ * and retry once. The SDK never retries a money call on its own.
836
+ */
837
+ get isPlayerTokenStale() {
838
+ return this.code === "PLAYER_TOKEN_STALE";
839
+ }
840
+ /**
841
+ * True when `updatePlayerPhone` was refused because the player has secured this account,
842
+ * so the change needs the player's own confirmation (`PHONE_CHANGE_REQUIRES_VERIFICATION`,
843
+ * 409). Nothing changed. Call `requestPhoneChange`: INVO emails the player, who confirms
844
+ * on INVO's page. {@link changeRequestEndpoint} names the route.
845
+ */
846
+ get isPhoneChangeRequiresVerification() {
847
+ return this.code === "PHONE_CHANGE_REQUIRES_VERIFICATION";
848
+ }
849
+ /**
850
+ * On `PHONE_CHANGE_REQUIRES_VERIFICATION`: the route to create a change request on, as INVO
851
+ * returned it (`change_request_endpoint`; it carries the `/sandbox` prefix in sandbox).
852
+ * `requestPhoneChange` already calls it. `undefined` when the body does not carry it.
853
+ */
854
+ get changeRequestEndpoint() {
855
+ const v = this.bodyObject()["change_request_endpoint"];
856
+ return typeof v === "string" && v ? v : void 0;
857
+ }
858
+ // ---- Player-confirmed phone change (change requests) ----
859
+ /**
860
+ * True when a game tried to confirm a phone change itself (`CONFIRM_ON_INVO_PAGE`, 409).
861
+ * The player confirms only on INVO's page, from the link in INVO's email; a game never
862
+ * collects the code.
863
+ */
864
+ get isConfirmOnInvoPage() {
865
+ return this.code === "CONFIRM_ON_INVO_PAGE";
866
+ }
867
+ /**
868
+ * True when the change request is unknown, belongs to another game (`getPhoneChange`), or
869
+ * to another player (`approvePhoneChange`) (`CHANGE_REQUEST_NOT_FOUND`, 404).
870
+ */
871
+ get isChangeRequestNotFound() {
872
+ return this.code === "CHANGE_REQUEST_NOT_FOUND";
873
+ }
874
+ /**
875
+ * True when `approvePhoneChange` came before the player entered the emailed code on INVO's
876
+ * page (`CHANGE_REQUEST_NOT_READY`, 409). Nothing changed; approve after they do.
877
+ */
878
+ get isChangeRequestNotReady() {
879
+ return this.code === "CHANGE_REQUEST_NOT_READY";
880
+ }
881
+ /**
882
+ * True when the change request is no longer pending (`CHANGE_REQUEST_NOT_PENDING`, 409):
883
+ * already confirmed, expired, cancelled, refused or declined. See
884
+ * {@link changeRequestStatus}.
885
+ */
886
+ get isChangeRequestNotPending() {
887
+ return this.code === "CHANGE_REQUEST_NOT_PENDING";
888
+ }
889
+ /** On `CHANGE_REQUEST_NOT_PENDING`: the request's current `status`. */
890
+ get changeRequestStatus() {
891
+ if (this.code !== "CHANGE_REQUEST_NOT_PENDING") return void 0;
892
+ const v = this.bodyObject()["status"];
893
+ return typeof v === "string" && v ? v : void 0;
894
+ }
895
+ /**
896
+ * True when another game's change request for this player is waiting for the player
897
+ * (`CHANGE_REQUEST_IN_PROGRESS`, 409). Retry after it is confirmed or expires.
898
+ */
899
+ get isChangeRequestInProgress() {
900
+ return this.code === "CHANGE_REQUEST_IN_PROGRESS";
901
+ }
902
+ /**
903
+ * True when phone changes for this player are paused after repeated failed confirmations
904
+ * (`PHONE_CHANGE_LOCKED`, 409). The player has been emailed. Retry later.
905
+ */
906
+ get isPhoneChangeLocked() {
907
+ return this.code === "PHONE_CHANGE_LOCKED";
908
+ }
909
+ /**
910
+ * True when `requestPhoneChange` was refused because there were too many change requests
911
+ * for this player (`TOO_MANY_CHANGE_REQUESTS`, 429). Try again later; do not loop.
912
+ */
913
+ get isTooManyChangeRequests() {
914
+ return this.code === "TOO_MANY_CHANGE_REQUESTS";
915
+ }
916
+ /**
917
+ * True when a phone change call could not be served right now (`PHONE_CHANGE_UNAVAILABLE`,
918
+ * 503) or the confirmation email could not be sent (`CONFIRMATION_EMAIL_UNAVAILABLE`, 503;
919
+ * that request is closed). Retry shortly.
920
+ */
921
+ get isPhoneChangeUnavailable() {
922
+ return this.code === "PHONE_CHANGE_UNAVAILABLE" || this.code === "CONFIRMATION_EMAIL_UNAVAILABLE";
923
+ }
924
+ /**
925
+ * True when a phone change was refused because transfers to the player's CURRENT number
926
+ * are still waiting to be collected (`PENDING_TRANSFERS_TO_OLD_PHONE`, 409), on
927
+ * `updatePlayerPhone`, `requestPhoneChange` or `approvePhoneChange`. Changing the number
928
+ * now would strand them. Nothing changed. Ask the player to collect them first (or wait
929
+ * until they expire), then retry.
930
+ */
931
+ get isPendingTransfersToOldPhone() {
932
+ return this.code === "PENDING_TRANSFERS_TO_OLD_PHONE";
933
+ }
934
+ /**
935
+ * True when a phone change was refused because transfers to the NEW number are still
936
+ * waiting to be collected (`PENDING_TRANSFERS_TO_NEW_PHONE`, 409), on `updatePlayerPhone`,
937
+ * `requestPhoneChange` or `approvePhoneChange`. Nothing changed. Retry after they are
938
+ * collected or expire.
939
+ */
940
+ get isPendingTransfersToNewPhone() {
941
+ return this.code === "PENDING_TRANSFERS_TO_NEW_PHONE";
942
+ }
943
+ /**
944
+ * True when the player's account recently went through a sign-in recovery, so the number
945
+ * cannot be changed yet (`PHONE_CHANGE_RECOVERY_COOLDOWN`, 409), on `requestPhoneChange`
946
+ * or `approvePhoneChange`. Nothing changed. Retry later; on `approvePhoneChange`,
947
+ * declining (`decision: "deny"`) still works.
948
+ */
949
+ get isPhoneChangeRecoveryCooldown() {
950
+ return this.code === "PHONE_CHANGE_RECOVERY_COOLDOWN";
951
+ }
952
+ /**
953
+ * True when `approvePhoneChange` was refused because this device (or its key) was set up
954
+ * after the change was requested, so it cannot approve it
955
+ * (`DEVICE_ENROLLED_AFTER_REQUEST`, 409). Nothing changed. The player approves on their
956
+ * earlier device, or your game creates a new request.
957
+ */
958
+ get isDeviceEnrolledAfterRequest() {
959
+ return this.code === "DEVICE_ENROLLED_AFTER_REQUEST";
960
+ }
961
+ /**
962
+ * True when `approvePhoneChange` was refused because the device signal did not verify
963
+ * (401, the reason in `error`, for example `SIGNAL_INVALID`). Nothing changed. Sign the
964
+ * exact message again with a fresh nonce and timestamp.
965
+ */
966
+ get isDeviceSignalRejected() {
967
+ if (this.status !== 401) return false;
968
+ const e = this.bodyObject()["error"];
969
+ return typeof e === "string" && e.startsWith("SIGNAL_");
970
+ }
971
+ /**
972
+ * True when `registerPlayer` found the player already in your game with a DIFFERENT
973
+ * phone (`PHONE_MISMATCH`, 409). Nothing changed; use `updatePlayerPhone` to change it.
974
+ * (`mintPlayerToken` reports the same situation as `phoneMismatch: true` on success.)
975
+ */
976
+ get isPhoneMismatch() {
977
+ return this.code === "PHONE_MISMATCH";
978
+ }
979
+ /**
980
+ * True when the phone you supplied belongs to another email
981
+ * (`PHONE_SHARE_APPROVAL_REQUIRED`, 409) on `mintPlayerToken`, `registerPlayer` or
982
+ * `updatePlayerPhone`. Nothing was created or changed. The same condition as
983
+ * {@link isPhoneShareApprovalRequired}, named for these registration calls.
984
+ */
985
+ get isPhoneShareRefused() {
986
+ return this.isPhoneShareApprovalRequired;
826
987
  }
827
988
  /**
828
989
  * True when `cards.createSetupSession` was asked to create a new member (`playerName`
@@ -922,11 +1083,13 @@ function errorFromResponse(status, body, requestId) {
922
1083
  let message = `INVO request failed (HTTP ${status})`;
923
1084
  let code;
924
1085
  let rawCode;
1086
+ let publicCode;
925
1087
  if (body && typeof body === "object") {
926
1088
  const b = body;
927
1089
  if (typeof b["code"] === "string") rawCode = b["code"];
928
1090
  else if (typeof b["error_code"] === "string") rawCode = b["error_code"];
929
- code = typeof b["error_code_public"] === "string" ? b["error_code_public"] : rawCode;
1091
+ if (typeof b["error_code_public"] === "string") publicCode = b["error_code_public"];
1092
+ code = publicCode ?? rawCode;
930
1093
  if (typeof b["error"] === "string") message = b["error"];
931
1094
  else if (typeof b["message"] === "string") message = b["message"];
932
1095
  if (!code && typeof b["error"] === "string" && /^(flow_paused|spending_limit_exceeded|receiver_not_enrolled_use_claim_code|no_channel_on_file|rate_limited|service_unavailable|authorization_pending|slow_down|expired_token|access_denied|invalid_grant)$/.test(
@@ -938,7 +1101,7 @@ function errorFromResponse(status, body, requestId) {
938
1101
  } else if (typeof body === "string" && body.trim()) {
939
1102
  message = body;
940
1103
  }
941
- return new InvoError({ message, code, rawCode, status, body, requestId });
1104
+ return new InvoError({ message, code, rawCode, publicCode, status, body, requestId });
942
1105
  }
943
1106
 
944
1107
  // src/shared/http.ts
@@ -2041,7 +2204,82 @@ function toRewardsPageLink(raw) {
2041
2204
  return { url: str2(raw["url"]), expiresAt: str2(raw["expires_at"]), raw };
2042
2205
  }
2043
2206
 
2207
+ // src/shared/phone-change.ts
2208
+ function phoneChangeSignalMessage(changeRequestId, nonce, timestamp, decision = "approve") {
2209
+ const action = decision === "deny" ? "phone-change-deny" : "phone-change";
2210
+ return `${action}|${changeRequestId}|${nonce}|${Math.trunc(timestamp)}`;
2211
+ }
2212
+ function requireField(value, field, raw) {
2213
+ const s = value == null ? "" : String(value);
2214
+ if (!s) {
2215
+ throw new InvoError({
2216
+ message: `INVO response was missing the required \`${field}\` field.`,
2217
+ code: "INVALID_RESPONSE",
2218
+ status: 0,
2219
+ body: raw
2220
+ });
2221
+ }
2222
+ return s;
2223
+ }
2224
+ var str3 = (v) => v == null ? "" : String(v);
2225
+ var strOrNull2 = (v) => typeof v === "string" ? v : v == null ? null : String(v);
2226
+ function toPhoneChangeApprovalsResult(raw) {
2227
+ const rows2 = Array.isArray(raw["approvals"]) ? raw["approvals"] : [];
2228
+ const approvals = rows2.filter((r) => r && typeof r === "object").map((r) => ({
2229
+ changeRequestId: str3(r["change_request_id"]),
2230
+ gameName: strOrNull2(r["game_name"]),
2231
+ oldPhoneMasked: strOrNull2(r["old_phone_masked"]),
2232
+ newPhoneMasked: strOrNull2(r["new_phone_masked"]),
2233
+ expiresAt: strOrNull2(r["expires_at"])
2234
+ }));
2235
+ return { approvals, raw };
2236
+ }
2237
+ function toApprovePhoneChangeResult(raw, changeRequestId) {
2238
+ const id = str3(raw["change_request_id"] ?? changeRequestId);
2239
+ const status = requireField(raw["status"], "status", raw);
2240
+ if (status === "denied") {
2241
+ return { status: "denied", changeRequestId: id, raw };
2242
+ }
2243
+ if (status !== "confirmed") {
2244
+ throw new InvoError({
2245
+ message: `INVO answered an unexpected phone change status \`${status}\`.`,
2246
+ code: "INVALID_RESPONSE",
2247
+ status: 0,
2248
+ body: raw
2249
+ });
2250
+ }
2251
+ const out = {
2252
+ status: "confirmed",
2253
+ changeRequestId: id,
2254
+ identityId: str3(raw["identity_id"]),
2255
+ previousIdentityId: str3(raw["previous_identity_id"]),
2256
+ playersUpdated: Number(raw["players_updated"] ?? 0) || 0,
2257
+ verifiedPhone: raw["verified_phone"] === true,
2258
+ raw
2259
+ };
2260
+ if (typeof raw["player_token"] === "string" && raw["player_token"]) {
2261
+ out.playerToken = raw["player_token"];
2262
+ if (typeof raw["player_token_expires_at"] === "string") {
2263
+ out.playerTokenExpiresAt = raw["player_token_expires_at"];
2264
+ }
2265
+ }
2266
+ return out;
2267
+ }
2268
+
2044
2269
  // src/index.ts
2270
+ function clientInvalidInput(message) {
2271
+ return new InvoError({ message, code: "INVALID_INPUT", status: 0 });
2272
+ }
2273
+ function randomNonce() {
2274
+ const c = globalThis.crypto;
2275
+ if (!c || typeof c.getRandomValues !== "function") {
2276
+ throw clientInvalidInput(
2277
+ "No secure random source in this environment; pass a deviceSignal you built yourself."
2278
+ );
2279
+ }
2280
+ const bytes = c.getRandomValues(new Uint8Array(16));
2281
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
2282
+ }
2045
2283
  var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2046
2284
  function toPendingCollectItem(row) {
2047
2285
  return {
@@ -2082,6 +2320,7 @@ function toApproveResult(raw, transactionId) {
2082
2320
  risk: raw["risk"],
2083
2321
  guardianApproval: raw["guardian_approval"] ?? void 0,
2084
2322
  pollEndpoint: raw["poll_endpoint"],
2323
+ ...typeof raw["claim_delivery"] === "string" && raw["claim_delivery"] ? { claimDelivery: raw["claim_delivery"] } : {},
2085
2324
  raw
2086
2325
  };
2087
2326
  }
@@ -2443,11 +2682,19 @@ var InvoClient = class {
2443
2682
  };
2444
2683
  return runHostedApproval(opts, api);
2445
2684
  }
2446
- /** Approve a SEND with the player's passkey. */
2685
+ /**
2686
+ * Approve a SEND with the player's passkey.
2687
+ *
2688
+ * Throws 403 `err.isPlayerTokenStale` when the player token predates a change to the
2689
+ * sender's identity (their phone was added on the initiate). Not retried automatically,
2690
+ * because this call moves money: re-mint the player token (or use the `playerToken`
2691
+ * your server got back from `initiateSend`) and retry once.
2692
+ */
2447
2693
  async approveSend(transactionId, opts) {
2448
2694
  return this.approve("send", transactionId, opts);
2449
2695
  }
2450
- /** Approve a TRANSFER with the player's passkey (returns the sender's claim code). */
2696
+ /** Approve a TRANSFER with the player's passkey (returns the sender's claim code). Same
2697
+ * `err.isPlayerTokenStale` handling as {@link approveSend}: re-mint and retry once. */
2451
2698
  async approveTransfer(transactionId, opts) {
2452
2699
  return this.approve("transfers", transactionId, opts);
2453
2700
  }
@@ -2469,6 +2716,99 @@ var InvoClient = class {
2469
2716
  async confirmReceiptTransfer(transactionId, opts) {
2470
2717
  return this.confirmReceipt("transfers", transactionId, opts);
2471
2718
  }
2719
+ /**
2720
+ * Phone changes waiting for THIS player's enrolled device to approve
2721
+ * (`GET /api/sdk/players/phone/change-approvals`, player token). A row appears after the
2722
+ * player entered the emailed code on INVO's page for a change whose `confirmation` is
2723
+ * `"email_code_and_device"`. Show each one ("Approve changing your number to
2724
+ * ***-***-0123?") and answer it with {@link approvePhoneChange}. Read-only.
2725
+ */
2726
+ async listPhoneChangeApprovals(opts) {
2727
+ return this.withTokenRetry(async () => {
2728
+ const raw = await this.get(
2729
+ "/api/sdk/players/phone/change-approvals",
2730
+ opts?.signal
2731
+ );
2732
+ return toPhoneChangeApprovalsResult(raw);
2733
+ });
2734
+ }
2735
+ /**
2736
+ * Approve (or, with `decision: "deny"`, decline) a phone change from the player's enrolled
2737
+ * device (`POST /api/sdk/players/phone/change-requests/{id}/approve`, player token).
2738
+ *
2739
+ * The device key signs `phone-change|<changeRequestId>|<nonce>|<timestamp>` to approve or
2740
+ * `phone-change-deny|<changeRequestId>|<nonce>|<timestamp>` to decline (`timestamp` in
2741
+ * epoch seconds). Either pass `sign`, and the SDK makes a fresh nonce and timestamp, builds
2742
+ * that message and asks you for the base64 signature; or pass a `deviceSignal` you signed
2743
+ * yourself (build the message with {@link phoneChangeSignalMessage}). This is a device key
2744
+ * registered with INVO, not a passkey.
2745
+ *
2746
+ * `status: "confirmed"` means the change is applied: store `identityId` and use
2747
+ * `playerToken` (tokens minted before the change are stale). `status: "denied"` means
2748
+ * nothing changed. Refusals: 409 `err.isChangeRequestNotReady` (the player has not entered
2749
+ * the code on INVO's page yet), 409 `err.isChangeRequestNotPending` (`err.changeRequestStatus`),
2750
+ * 409 `err.isDeviceEnrolledAfterRequest` (this device was set up after the change was
2751
+ * requested; approve on the earlier device, or the game creates a new request), 409
2752
+ * `err.isPhoneChangeRecoveryCooldown` (a recent sign-in recovery; retry later, declining
2753
+ * still works), 404 `err.isChangeRequestNotFound`, 401 `err.isDeviceSignalRejected`, 403
2754
+ * `DEVICE_REQUIRES_ELEVATION`, or any refusal of the change itself (for example
2755
+ * `err.isPendingTransfersToOldPhone`).
2756
+ */
2757
+ async approvePhoneChange(changeRequestId, input, opts) {
2758
+ if (typeof changeRequestId !== "string" || !changeRequestId.trim()) {
2759
+ throw clientInvalidInput("changeRequestId is required.");
2760
+ }
2761
+ if (!input || typeof input.deviceFingerprint !== "string" || !input.deviceFingerprint.trim()) {
2762
+ throw clientInvalidInput("deviceFingerprint is required.");
2763
+ }
2764
+ const decision = input.decision ?? "approve";
2765
+ if (decision !== "approve" && decision !== "deny") {
2766
+ throw clientInvalidInput('decision must be "approve" or "deny".');
2767
+ }
2768
+ const hasSignal = input.deviceSignal !== void 0;
2769
+ const hasSigner = typeof input.sign === "function";
2770
+ if (hasSignal === hasSigner) {
2771
+ throw clientInvalidInput("Pass exactly one of deviceSignal or sign.");
2772
+ }
2773
+ if (hasSignal) {
2774
+ const sig = input.deviceSignal;
2775
+ if (!sig || typeof sig.nonce !== "string" || !sig.nonce || typeof sig.timestamp !== "number" || !Number.isInteger(sig.timestamp) || typeof sig.signature !== "string" || !sig.signature) {
2776
+ throw clientInvalidInput(
2777
+ "deviceSignal needs a nonce (string), an integer epoch-seconds timestamp and a base64 signature."
2778
+ );
2779
+ }
2780
+ }
2781
+ const id = encodeURIComponent(changeRequestId);
2782
+ const signal = opts?.signal;
2783
+ return this.withTokenRetry(async () => {
2784
+ let deviceSignal;
2785
+ if (hasSignal) {
2786
+ const sig = input.deviceSignal;
2787
+ deviceSignal = {
2788
+ transfer_id: changeRequestId,
2789
+ nonce: sig.nonce,
2790
+ timestamp: sig.timestamp,
2791
+ signature: sig.signature
2792
+ };
2793
+ } else {
2794
+ const nonce = randomNonce();
2795
+ const timestamp = Math.floor(Date.now() / 1e3);
2796
+ const signature = await input.sign(
2797
+ phoneChangeSignalMessage(changeRequestId, nonce, timestamp, decision)
2798
+ );
2799
+ if (typeof signature !== "string" || !signature) {
2800
+ throw clientInvalidInput("sign must return the base64 signature as a non-empty string.");
2801
+ }
2802
+ deviceSignal = { transfer_id: changeRequestId, nonce, timestamp, signature };
2803
+ }
2804
+ const raw = await this.post(
2805
+ `/api/sdk/players/phone/change-requests/${id}/approve`,
2806
+ { device_fingerprint: input.deviceFingerprint, device_signal: deviceSignal, decision },
2807
+ signal
2808
+ );
2809
+ return toApprovePhoneChangeResult(raw, changeRequestId);
2810
+ });
2811
+ }
2472
2812
  /**
2473
2813
  * Interchangeable methods (§4.6): prove an *already-enrolled* method (e.g. the
2474
2814
  * INVO app device key) to authorize adding a new partner passkey. The returned
@@ -2814,5 +3154,6 @@ exports.isPurchaseExpired = isPurchaseExpired;
2814
3154
  exports.isPurchaseRefunded = isPurchaseRefunded;
2815
3155
  exports.isPurchaseRefused = isPurchaseRefused;
2816
3156
  exports.nothingWasCharged = nothingWasCharged;
3157
+ exports.phoneChangeSignalMessage = phoneChangeSignalMessage;
2817
3158
  //# sourceMappingURL=index.cjs.map
2818
3159
  //# sourceMappingURL=index.cjs.map
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-BwgkJoM6.cjs';
2
- export { r as BalanceRow, s as CheckoutPurchaseStatus, t as DestinationGame, I as InvoError, u as InvoErrorInfo, v as InvoHooks, w as InvoRequestInfo, x as InvoResponseInfo, y as LoyaltyCard, z as LoyaltyCardReward, F as LoyaltyCardStep, G as LoyaltyRewardState, J as LoyaltyStepProgress, K as LoyaltyStepState, N as LoyaltyVaultEntry, O as PendingCollectItem, Q as PurchaseRefusalReason, S as Rail, V as VerificationMethod } from './types-BwgkJoM6.cjs';
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, j as PhoneChangeApprovalsResult, k as ApprovePhoneChangeInput, l as ApprovePhoneChangeResult, L as LinkDeviceResult, m as PendingCollectResult, D as DestinationsQuery, n as DestinationsResult, B as BalanceResult, o as LoyaltyCardsResult, p as LoyaltyVaultResult, R as RedeemRewardResult, q as RewardsPageLink, E as EnrollmentBeginResult, r as EnrollmentVerifyResult, s as RecoveryBeginResult, t as RecoveryCompleteResult } from './types-C7vpPqsF.cjs';
2
+ export { u as BalanceRow, v as CheckoutPurchaseStatus, w as ClaimDelivery, x as DestinationGame, I as InvoError, y as InvoErrorInfo, z as InvoHooks, F as InvoRequestInfo, G as InvoResponseInfo, J as LoyaltyCard, K as LoyaltyCardReward, N as LoyaltyCardStep, O as LoyaltyRewardState, Q as LoyaltyStepProgress, S as LoyaltyStepState, T as LoyaltyVaultEntry, U as PendingCollectItem, V as PhoneChangeApproval, X as PhoneChangeDeviceSignal, Y as PurchaseRefusalReason, Z as Rail, _ as VerificationMethod } from './types-C7vpPqsF.cjs';
3
3
 
4
4
  /** The four device-approval flows (`begin.flow`). */
5
5
  type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
@@ -126,6 +126,20 @@ declare function isPurchaseExpired(r: PurchaseStatusResult): r is PurchaseExpire
126
126
  */
127
127
  declare function nothingWasCharged(r: PurchaseStatusResult): boolean;
128
128
 
129
+ /**
130
+ * Player-confirmed phone change: the device-approval message and the wire mappers shared by
131
+ * `InvoServer.requestPhoneChange` / `getPhoneChange` and `InvoClient.listPhoneChangeApprovals`
132
+ * / `approvePhoneChange`.
133
+ */
134
+
135
+ /**
136
+ * The exact message an enrolled device signs to answer a phone change request:
137
+ * `phone-change|<changeRequestId>|<nonce>|<timestamp>` to approve, or
138
+ * `phone-change-deny|<changeRequestId>|<nonce>|<timestamp>` to decline. `timestamp` is epoch
139
+ * seconds (an integer).
140
+ */
141
+ declare function phoneChangeSignalMessage(changeRequestId: string, nonce: string, timestamp: number, decision?: "approve" | "deny"): string;
142
+
129
143
  /**
130
144
  * @invonetwork/web-sdk — BROWSER entry.
131
145
  *
@@ -309,9 +323,17 @@ declare class InvoClient {
309
323
  flow: "send_receipt" | "transfer_receipt";
310
324
  }): Promise<ApproveHostedResult<ConfirmReceiptResult>>;
311
325
  approveHosted(opts: ApproveHostedOptions): Promise<ApproveHostedResult>;
312
- /** Approve a SEND with the player's passkey. */
326
+ /**
327
+ * Approve a SEND with the player's passkey.
328
+ *
329
+ * Throws 403 `err.isPlayerTokenStale` when the player token predates a change to the
330
+ * sender's identity (their phone was added on the initiate). Not retried automatically,
331
+ * because this call moves money: re-mint the player token (or use the `playerToken`
332
+ * your server got back from `initiateSend`) and retry once.
333
+ */
313
334
  approveSend(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
314
- /** Approve a TRANSFER with the player's passkey (returns the sender's claim code). */
335
+ /** Approve a TRANSFER with the player's passkey (returns the sender's claim code). Same
336
+ * `err.isPlayerTokenStale` handling as {@link approveSend}: re-mint and retry once. */
315
337
  approveTransfer(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
316
338
  /**
317
339
  * Recipient self-claims a SEND with their passkey.
@@ -327,6 +349,37 @@ declare class InvoClient {
327
349
  * 409 as {@link confirmReceiptSend} (`err.isPhoneShareApprovalRequired`) — handle it the
328
350
  * same way: show `err.message`, retry after the phone owner approves. */
329
351
  confirmReceiptTransfer(transactionId: string, opts?: CallOptions): Promise<ConfirmReceiptResult>;
352
+ /**
353
+ * Phone changes waiting for THIS player's enrolled device to approve
354
+ * (`GET /api/sdk/players/phone/change-approvals`, player token). A row appears after the
355
+ * player entered the emailed code on INVO's page for a change whose `confirmation` is
356
+ * `"email_code_and_device"`. Show each one ("Approve changing your number to
357
+ * ***-***-0123?") and answer it with {@link approvePhoneChange}. Read-only.
358
+ */
359
+ listPhoneChangeApprovals(opts?: CallOptions): Promise<PhoneChangeApprovalsResult>;
360
+ /**
361
+ * Approve (or, with `decision: "deny"`, decline) a phone change from the player's enrolled
362
+ * device (`POST /api/sdk/players/phone/change-requests/{id}/approve`, player token).
363
+ *
364
+ * The device key signs `phone-change|<changeRequestId>|<nonce>|<timestamp>` to approve or
365
+ * `phone-change-deny|<changeRequestId>|<nonce>|<timestamp>` to decline (`timestamp` in
366
+ * epoch seconds). Either pass `sign`, and the SDK makes a fresh nonce and timestamp, builds
367
+ * that message and asks you for the base64 signature; or pass a `deviceSignal` you signed
368
+ * yourself (build the message with {@link phoneChangeSignalMessage}). This is a device key
369
+ * registered with INVO, not a passkey.
370
+ *
371
+ * `status: "confirmed"` means the change is applied: store `identityId` and use
372
+ * `playerToken` (tokens minted before the change are stale). `status: "denied"` means
373
+ * nothing changed. Refusals: 409 `err.isChangeRequestNotReady` (the player has not entered
374
+ * the code on INVO's page yet), 409 `err.isChangeRequestNotPending` (`err.changeRequestStatus`),
375
+ * 409 `err.isDeviceEnrolledAfterRequest` (this device was set up after the change was
376
+ * requested; approve on the earlier device, or the game creates a new request), 409
377
+ * `err.isPhoneChangeRecoveryCooldown` (a recent sign-in recovery; retry later, declining
378
+ * still works), 404 `err.isChangeRequestNotFound`, 401 `err.isDeviceSignalRejected`, 403
379
+ * `DEVICE_REQUIRES_ELEVATION`, or any refusal of the change itself (for example
380
+ * `err.isPendingTransfersToOldPhone`).
381
+ */
382
+ approvePhoneChange(changeRequestId: string, input: ApprovePhoneChangeInput, opts?: CallOptions): Promise<ApprovePhoneChangeResult>;
330
383
  /**
331
384
  * Interchangeable methods (§4.6): prove an *already-enrolled* method (e.g. the
332
385
  * INVO app device key) to authorize adding a new partner passkey. The returned
@@ -453,4 +506,4 @@ declare class InvoClient {
453
506
  private confirmReceipt;
454
507
  }
455
508
 
456
- export { type ApproveHostedOptions, type ApproveHostedResult, ApproveResult, BalanceResult, CallOptions, CheckoutClient, CheckoutClientConfig, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, LoyaltyCardsResult, LoyaltyVaultResult, MountCheckoutOptions, PendingCollectResult, PlatformCommerceClient, PurchaseCredited, PurchaseExpired, PurchaseRefunded, PurchaseRefused, PurchaseStatusInput, PurchaseStatusResult, RecoveryBeginResult, RecoveryCompleteResult, RedeemRewardResult, RewardsPageLink, WaitForPurchaseInput, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, nothingWasCharged };
509
+ export { type ApproveHostedOptions, type ApproveHostedResult, ApprovePhoneChangeInput, ApprovePhoneChangeResult, ApproveResult, BalanceResult, CallOptions, CheckoutClient, CheckoutClientConfig, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, LoyaltyCardsResult, LoyaltyVaultResult, MountCheckoutOptions, PendingCollectResult, PhoneChangeApprovalsResult, PlatformCommerceClient, PurchaseCredited, PurchaseExpired, PurchaseRefunded, PurchaseRefused, PurchaseStatusInput, PurchaseStatusResult, RecoveryBeginResult, RecoveryCompleteResult, RedeemRewardResult, RewardsPageLink, WaitForPurchaseInput, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, nothingWasCharged, phoneChangeSignalMessage };
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-BwgkJoM6.js';
2
- export { r as BalanceRow, s as CheckoutPurchaseStatus, t as DestinationGame, I as InvoError, u as InvoErrorInfo, v as InvoHooks, w as InvoRequestInfo, x as InvoResponseInfo, y as LoyaltyCard, z as LoyaltyCardReward, F as LoyaltyCardStep, G as LoyaltyRewardState, J as LoyaltyStepProgress, K as LoyaltyStepState, N as LoyaltyVaultEntry, O as PendingCollectItem, Q as PurchaseRefusalReason, S as Rail, V as VerificationMethod } from './types-BwgkJoM6.js';
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, j as PhoneChangeApprovalsResult, k as ApprovePhoneChangeInput, l as ApprovePhoneChangeResult, L as LinkDeviceResult, m as PendingCollectResult, D as DestinationsQuery, n as DestinationsResult, B as BalanceResult, o as LoyaltyCardsResult, p as LoyaltyVaultResult, R as RedeemRewardResult, q as RewardsPageLink, E as EnrollmentBeginResult, r as EnrollmentVerifyResult, s as RecoveryBeginResult, t as RecoveryCompleteResult } from './types-C7vpPqsF.js';
2
+ export { u as BalanceRow, v as CheckoutPurchaseStatus, w as ClaimDelivery, x as DestinationGame, I as InvoError, y as InvoErrorInfo, z as InvoHooks, F as InvoRequestInfo, G as InvoResponseInfo, J as LoyaltyCard, K as LoyaltyCardReward, N as LoyaltyCardStep, O as LoyaltyRewardState, Q as LoyaltyStepProgress, S as LoyaltyStepState, T as LoyaltyVaultEntry, U as PendingCollectItem, V as PhoneChangeApproval, X as PhoneChangeDeviceSignal, Y as PurchaseRefusalReason, Z as Rail, _ as VerificationMethod } from './types-C7vpPqsF.js';
3
3
 
4
4
  /** The four device-approval flows (`begin.flow`). */
5
5
  type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
@@ -126,6 +126,20 @@ declare function isPurchaseExpired(r: PurchaseStatusResult): r is PurchaseExpire
126
126
  */
127
127
  declare function nothingWasCharged(r: PurchaseStatusResult): boolean;
128
128
 
129
+ /**
130
+ * Player-confirmed phone change: the device-approval message and the wire mappers shared by
131
+ * `InvoServer.requestPhoneChange` / `getPhoneChange` and `InvoClient.listPhoneChangeApprovals`
132
+ * / `approvePhoneChange`.
133
+ */
134
+
135
+ /**
136
+ * The exact message an enrolled device signs to answer a phone change request:
137
+ * `phone-change|<changeRequestId>|<nonce>|<timestamp>` to approve, or
138
+ * `phone-change-deny|<changeRequestId>|<nonce>|<timestamp>` to decline. `timestamp` is epoch
139
+ * seconds (an integer).
140
+ */
141
+ declare function phoneChangeSignalMessage(changeRequestId: string, nonce: string, timestamp: number, decision?: "approve" | "deny"): string;
142
+
129
143
  /**
130
144
  * @invonetwork/web-sdk — BROWSER entry.
131
145
  *
@@ -309,9 +323,17 @@ declare class InvoClient {
309
323
  flow: "send_receipt" | "transfer_receipt";
310
324
  }): Promise<ApproveHostedResult<ConfirmReceiptResult>>;
311
325
  approveHosted(opts: ApproveHostedOptions): Promise<ApproveHostedResult>;
312
- /** Approve a SEND with the player's passkey. */
326
+ /**
327
+ * Approve a SEND with the player's passkey.
328
+ *
329
+ * Throws 403 `err.isPlayerTokenStale` when the player token predates a change to the
330
+ * sender's identity (their phone was added on the initiate). Not retried automatically,
331
+ * because this call moves money: re-mint the player token (or use the `playerToken`
332
+ * your server got back from `initiateSend`) and retry once.
333
+ */
313
334
  approveSend(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
314
- /** Approve a TRANSFER with the player's passkey (returns the sender's claim code). */
335
+ /** Approve a TRANSFER with the player's passkey (returns the sender's claim code). Same
336
+ * `err.isPlayerTokenStale` handling as {@link approveSend}: re-mint and retry once. */
315
337
  approveTransfer(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
316
338
  /**
317
339
  * Recipient self-claims a SEND with their passkey.
@@ -327,6 +349,37 @@ declare class InvoClient {
327
349
  * 409 as {@link confirmReceiptSend} (`err.isPhoneShareApprovalRequired`) — handle it the
328
350
  * same way: show `err.message`, retry after the phone owner approves. */
329
351
  confirmReceiptTransfer(transactionId: string, opts?: CallOptions): Promise<ConfirmReceiptResult>;
352
+ /**
353
+ * Phone changes waiting for THIS player's enrolled device to approve
354
+ * (`GET /api/sdk/players/phone/change-approvals`, player token). A row appears after the
355
+ * player entered the emailed code on INVO's page for a change whose `confirmation` is
356
+ * `"email_code_and_device"`. Show each one ("Approve changing your number to
357
+ * ***-***-0123?") and answer it with {@link approvePhoneChange}. Read-only.
358
+ */
359
+ listPhoneChangeApprovals(opts?: CallOptions): Promise<PhoneChangeApprovalsResult>;
360
+ /**
361
+ * Approve (or, with `decision: "deny"`, decline) a phone change from the player's enrolled
362
+ * device (`POST /api/sdk/players/phone/change-requests/{id}/approve`, player token).
363
+ *
364
+ * The device key signs `phone-change|<changeRequestId>|<nonce>|<timestamp>` to approve or
365
+ * `phone-change-deny|<changeRequestId>|<nonce>|<timestamp>` to decline (`timestamp` in
366
+ * epoch seconds). Either pass `sign`, and the SDK makes a fresh nonce and timestamp, builds
367
+ * that message and asks you for the base64 signature; or pass a `deviceSignal` you signed
368
+ * yourself (build the message with {@link phoneChangeSignalMessage}). This is a device key
369
+ * registered with INVO, not a passkey.
370
+ *
371
+ * `status: "confirmed"` means the change is applied: store `identityId` and use
372
+ * `playerToken` (tokens minted before the change are stale). `status: "denied"` means
373
+ * nothing changed. Refusals: 409 `err.isChangeRequestNotReady` (the player has not entered
374
+ * the code on INVO's page yet), 409 `err.isChangeRequestNotPending` (`err.changeRequestStatus`),
375
+ * 409 `err.isDeviceEnrolledAfterRequest` (this device was set up after the change was
376
+ * requested; approve on the earlier device, or the game creates a new request), 409
377
+ * `err.isPhoneChangeRecoveryCooldown` (a recent sign-in recovery; retry later, declining
378
+ * still works), 404 `err.isChangeRequestNotFound`, 401 `err.isDeviceSignalRejected`, 403
379
+ * `DEVICE_REQUIRES_ELEVATION`, or any refusal of the change itself (for example
380
+ * `err.isPendingTransfersToOldPhone`).
381
+ */
382
+ approvePhoneChange(changeRequestId: string, input: ApprovePhoneChangeInput, opts?: CallOptions): Promise<ApprovePhoneChangeResult>;
330
383
  /**
331
384
  * Interchangeable methods (§4.6): prove an *already-enrolled* method (e.g. the
332
385
  * INVO app device key) to authorize adding a new partner passkey. The returned
@@ -453,4 +506,4 @@ declare class InvoClient {
453
506
  private confirmReceipt;
454
507
  }
455
508
 
456
- export { type ApproveHostedOptions, type ApproveHostedResult, ApproveResult, BalanceResult, CallOptions, CheckoutClient, CheckoutClientConfig, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, LoyaltyCardsResult, LoyaltyVaultResult, MountCheckoutOptions, PendingCollectResult, PlatformCommerceClient, PurchaseCredited, PurchaseExpired, PurchaseRefunded, PurchaseRefused, PurchaseStatusInput, PurchaseStatusResult, RecoveryBeginResult, RecoveryCompleteResult, RedeemRewardResult, RewardsPageLink, WaitForPurchaseInput, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, nothingWasCharged };
509
+ export { type ApproveHostedOptions, type ApproveHostedResult, ApprovePhoneChangeInput, ApprovePhoneChangeResult, ApproveResult, BalanceResult, CallOptions, CheckoutClient, CheckoutClientConfig, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, LoyaltyCardsResult, LoyaltyVaultResult, MountCheckoutOptions, PendingCollectResult, PhoneChangeApprovalsResult, PlatformCommerceClient, PurchaseCredited, PurchaseExpired, PurchaseRefunded, PurchaseRefused, PurchaseStatusInput, PurchaseStatusResult, RecoveryBeginResult, RecoveryCompleteResult, RedeemRewardResult, RewardsPageLink, WaitForPurchaseInput, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, nothingWasCharged, phoneChangeSignalMessage };