@invonetwork/web-sdk 3.21.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.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-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';
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
  *
@@ -335,6 +349,37 @@ declare class InvoClient {
335
349
  * 409 as {@link confirmReceiptSend} (`err.isPhoneShareApprovalRequired`) — handle it the
336
350
  * same way: show `err.message`, retry after the phone owner approves. */
337
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>;
338
383
  /**
339
384
  * Interchangeable methods (§4.6): prove an *already-enrolled* method (e.g. the
340
385
  * INVO app device key) to authorize adding a new partner passkey. The returned
@@ -461,4 +506,4 @@ declare class InvoClient {
461
506
  private confirmReceipt;
462
507
  }
463
508
 
464
- 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-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';
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
  *
@@ -335,6 +349,37 @@ declare class InvoClient {
335
349
  * 409 as {@link confirmReceiptSend} (`err.isPhoneShareApprovalRequired`) — handle it the
336
350
  * same way: show `err.message`, retry after the phone owner approves. */
337
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>;
338
383
  /**
339
384
  * Interchangeable methods (§4.6): prove an *already-enrolled* method (e.g. the
340
385
  * INVO app device key) to authorize adding a new partner passkey. The returned
@@ -461,4 +506,4 @@ declare class InvoClient {
461
506
  private confirmReceipt;
462
507
  }
463
508
 
464
- 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.js CHANGED
@@ -1,5 +1,5 @@
1
- import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, receiptFields } from './chunk-7L4O5Q7K.js';
2
- export { InvoError } from './chunk-7L4O5Q7K.js';
1
+ import { InvoError, assertSecureBaseUrl, Http, toPhoneChangeApprovalsResult, phoneChangeSignalMessage, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, receiptFields } from './chunk-BOD4WOWO.js';
2
+ export { InvoError, phoneChangeSignalMessage } from './chunk-BOD4WOWO.js';
3
3
 
4
4
  // src/shared/webauthn.ts
5
5
  function malformedOptions(field) {
@@ -730,6 +730,19 @@ function nothingWasCharged(r) {
730
730
  }
731
731
 
732
732
  // src/index.ts
733
+ function clientInvalidInput(message) {
734
+ return new InvoError({ message, code: "INVALID_INPUT", status: 0 });
735
+ }
736
+ function randomNonce() {
737
+ const c = globalThis.crypto;
738
+ if (!c || typeof c.getRandomValues !== "function") {
739
+ throw clientInvalidInput(
740
+ "No secure random source in this environment; pass a deviceSignal you built yourself."
741
+ );
742
+ }
743
+ const bytes = c.getRandomValues(new Uint8Array(16));
744
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
745
+ }
733
746
  var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
734
747
  function toPendingCollectItem(row) {
735
748
  return {
@@ -1166,6 +1179,99 @@ var InvoClient = class {
1166
1179
  async confirmReceiptTransfer(transactionId, opts) {
1167
1180
  return this.confirmReceipt("transfers", transactionId, opts);
1168
1181
  }
1182
+ /**
1183
+ * Phone changes waiting for THIS player's enrolled device to approve
1184
+ * (`GET /api/sdk/players/phone/change-approvals`, player token). A row appears after the
1185
+ * player entered the emailed code on INVO's page for a change whose `confirmation` is
1186
+ * `"email_code_and_device"`. Show each one ("Approve changing your number to
1187
+ * ***-***-0123?") and answer it with {@link approvePhoneChange}. Read-only.
1188
+ */
1189
+ async listPhoneChangeApprovals(opts) {
1190
+ return this.withTokenRetry(async () => {
1191
+ const raw = await this.get(
1192
+ "/api/sdk/players/phone/change-approvals",
1193
+ opts?.signal
1194
+ );
1195
+ return toPhoneChangeApprovalsResult(raw);
1196
+ });
1197
+ }
1198
+ /**
1199
+ * Approve (or, with `decision: "deny"`, decline) a phone change from the player's enrolled
1200
+ * device (`POST /api/sdk/players/phone/change-requests/{id}/approve`, player token).
1201
+ *
1202
+ * The device key signs `phone-change|<changeRequestId>|<nonce>|<timestamp>` to approve or
1203
+ * `phone-change-deny|<changeRequestId>|<nonce>|<timestamp>` to decline (`timestamp` in
1204
+ * epoch seconds). Either pass `sign`, and the SDK makes a fresh nonce and timestamp, builds
1205
+ * that message and asks you for the base64 signature; or pass a `deviceSignal` you signed
1206
+ * yourself (build the message with {@link phoneChangeSignalMessage}). This is a device key
1207
+ * registered with INVO, not a passkey.
1208
+ *
1209
+ * `status: "confirmed"` means the change is applied: store `identityId` and use
1210
+ * `playerToken` (tokens minted before the change are stale). `status: "denied"` means
1211
+ * nothing changed. Refusals: 409 `err.isChangeRequestNotReady` (the player has not entered
1212
+ * the code on INVO's page yet), 409 `err.isChangeRequestNotPending` (`err.changeRequestStatus`),
1213
+ * 409 `err.isDeviceEnrolledAfterRequest` (this device was set up after the change was
1214
+ * requested; approve on the earlier device, or the game creates a new request), 409
1215
+ * `err.isPhoneChangeRecoveryCooldown` (a recent sign-in recovery; retry later, declining
1216
+ * still works), 404 `err.isChangeRequestNotFound`, 401 `err.isDeviceSignalRejected`, 403
1217
+ * `DEVICE_REQUIRES_ELEVATION`, or any refusal of the change itself (for example
1218
+ * `err.isPendingTransfersToOldPhone`).
1219
+ */
1220
+ async approvePhoneChange(changeRequestId, input, opts) {
1221
+ if (typeof changeRequestId !== "string" || !changeRequestId.trim()) {
1222
+ throw clientInvalidInput("changeRequestId is required.");
1223
+ }
1224
+ if (!input || typeof input.deviceFingerprint !== "string" || !input.deviceFingerprint.trim()) {
1225
+ throw clientInvalidInput("deviceFingerprint is required.");
1226
+ }
1227
+ const decision = input.decision ?? "approve";
1228
+ if (decision !== "approve" && decision !== "deny") {
1229
+ throw clientInvalidInput('decision must be "approve" or "deny".');
1230
+ }
1231
+ const hasSignal = input.deviceSignal !== void 0;
1232
+ const hasSigner = typeof input.sign === "function";
1233
+ if (hasSignal === hasSigner) {
1234
+ throw clientInvalidInput("Pass exactly one of deviceSignal or sign.");
1235
+ }
1236
+ if (hasSignal) {
1237
+ const sig = input.deviceSignal;
1238
+ if (!sig || typeof sig.nonce !== "string" || !sig.nonce || typeof sig.timestamp !== "number" || !Number.isInteger(sig.timestamp) || typeof sig.signature !== "string" || !sig.signature) {
1239
+ throw clientInvalidInput(
1240
+ "deviceSignal needs a nonce (string), an integer epoch-seconds timestamp and a base64 signature."
1241
+ );
1242
+ }
1243
+ }
1244
+ const id = encodeURIComponent(changeRequestId);
1245
+ const signal = opts?.signal;
1246
+ return this.withTokenRetry(async () => {
1247
+ let deviceSignal;
1248
+ if (hasSignal) {
1249
+ const sig = input.deviceSignal;
1250
+ deviceSignal = {
1251
+ transfer_id: changeRequestId,
1252
+ nonce: sig.nonce,
1253
+ timestamp: sig.timestamp,
1254
+ signature: sig.signature
1255
+ };
1256
+ } else {
1257
+ const nonce = randomNonce();
1258
+ const timestamp = Math.floor(Date.now() / 1e3);
1259
+ const signature = await input.sign(
1260
+ phoneChangeSignalMessage(changeRequestId, nonce, timestamp, decision)
1261
+ );
1262
+ if (typeof signature !== "string" || !signature) {
1263
+ throw clientInvalidInput("sign must return the base64 signature as a non-empty string.");
1264
+ }
1265
+ deviceSignal = { transfer_id: changeRequestId, nonce, timestamp, signature };
1266
+ }
1267
+ const raw = await this.post(
1268
+ `/api/sdk/players/phone/change-requests/${id}/approve`,
1269
+ { device_fingerprint: input.deviceFingerprint, device_signal: deviceSignal, decision },
1270
+ signal
1271
+ );
1272
+ return toApprovePhoneChangeResult(raw, changeRequestId);
1273
+ });
1274
+ }
1169
1275
  /**
1170
1276
  * Interchangeable methods (§4.6): prove an *already-enrolled* method (e.g. the
1171
1277
  * INVO app device key) to authorize adding a new partner passkey. The returned