@invonetwork/web-sdk 3.5.0 → 3.7.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 +194 -14
- package/README.md +619 -60
- package/dist/{chunk-MBKE6ULW.js → chunk-23TGMTII.js} +90 -3
- package/dist/index.cjs +760 -20
- package/dist/index.d.cts +135 -3
- package/dist/index.d.ts +135 -3
- package/dist/index.js +674 -21
- package/dist/server.cjs +508 -1
- package/dist/server.d.cts +109 -3
- package/dist/server.d.ts +109 -3
- package/dist/server.js +422 -2
- package/dist/{types-Dxo3IsYq.d.cts → types-CspPkmK9.d.cts} +265 -11
- package/dist/{types-Dxo3IsYq.d.ts → types-CspPkmK9.d.ts} +265 -11
- package/package.json +2 -1
package/dist/server.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InvoError, H as Http, o as AuthHeader, p as PlatformPurchaseInput,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvoError, H as Http, o as AuthHeader, p as PlatformPurchaseInput, c as CallOptions, q as PlatformPurchaseResult, r as PlatformOrderStatusResult, s as PlatformRefundInput, t as PlatformRefundResult, S as ServerConfig, u as PlayerToken, v as InitiateSendInput, w as InitiateResult, x as InitiateTransferInput, y as CreateCheckoutInput, z as CreateCheckoutResult, F as PurchaseInput, G as PurchaseResult, J as ConfirmPaymentResult, O as OrderDetailsResult, K as SteamPacksQuery, N as SteamPacksResult, Q as SteamInitPurchaseInput, T as SteamInitPurchaseResult, U as SteamFinalizeInput, W as SteamFinalizeResult, X as PurchaseItemInput, Y as PurchaseItemResult, Z as ItemHistoryQuery, _ as ItemHistoryResult, $ as ItemOrderQuery, a0 as PlayerBalanceQuery, a1 as PlayerBalanceResult, a2 as InboundPendingQuery, a3 as InboundPendingResult, a4 as LinkedIdentitiesQuery, a5 as LinkedIdentitiesResult, a6 as SmsVerifyResult, a7 as ClaimTransferInput, a8 as ClaimResult, a9 as ClaimCurrencyInput, aa as TransactionStatusResult, ab as GuardianApprovalStatusResult, ac as ServerDestinationsQuery, d as DestinationsResult, ad as PhoneShareContact, ae as PhoneShareInitiateResult, af as PhoneShareApproveInput, ag as PhoneShareApproveResult, ah as PhoneShareStatusResult, ai as BeginDeviceApprovalInput, aj as DeviceApprovalGrant, ak as PollDeviceApprovalInput, al as DeviceApprovalPollResult, am as ConfirmDeviceEnrollmentInput, an as ConfirmDeviceEnrollmentResult, ao as ApproveWithDeviceCodeInput, ap as DeviceApprovalSettleResult, aq as CompleteDeviceApprovalInput, ar as CompleteDeviceApprovalResult } from './types-CspPkmK9.cjs';
|
|
2
|
+
export { as as CurrencyBalance, h as DestinationGame, at as DeviceApprovalChannel, au as DeviceApprovalEnrollment, av as DeviceApprovalFlow, aw as DeviceApprovalPollStatus, ax as DeviceEnrollmentDecision, ay as DeviceEnrollmentRespond, az as FundingSource, aA as InboundPendingItem, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, aB as LinkedIdentityEmail, aC as PlatformPurchaseStatus, n as Rail, aD as SteamPack, aE as SteamUserSession, V as VerificationMethod } from './types-CspPkmK9.cjs';
|
|
3
3
|
|
|
4
4
|
interface VerifyWebhookOptions {
|
|
5
5
|
/** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
|
|
@@ -542,7 +542,113 @@ declare class InvoServer {
|
|
|
542
542
|
* be re-issued.
|
|
543
543
|
*/
|
|
544
544
|
phoneShareStatus(input: PhoneShareContact, opts?: CallOptions): Promise<PhoneShareStatusResult>;
|
|
545
|
+
/**
|
|
546
|
+
* Stage 1 — start a device approval for ONE transaction (RFC 8628 §3.1/§3.2).
|
|
547
|
+
*
|
|
548
|
+
* Returns the grant: render `verificationUriComplete` as the QR (print `userCode`
|
|
549
|
+
* under it for a TV with no camera), keep `deviceCode` on your server, then poll.
|
|
550
|
+
* A repeat `begin` while an earlier grant is merely PENDING supersedes it (fresh code;
|
|
551
|
+
* a page still open on the old one is told to scan again). A grant the player already
|
|
552
|
+
* APPROVED blocks a new `begin` for its window with `409 DEVICE_APPROVAL_ALREADY_PENDING`
|
|
553
|
+
* (`err.isDeviceApprovalAlreadyPending`, `err.deviceApprovalExpiresAt`) — the missing
|
|
554
|
+
* step there is `approveWithDeviceCode`, not a new code.
|
|
555
|
+
*
|
|
556
|
+
* For `transfer` / `send` the backend also pushes the transaction's own approval
|
|
557
|
+
* window past the grant's expiry, so an approval at minute nine cannot land on a
|
|
558
|
+
* transfer that has already been refunded. Auth: the player token. `channel: "popup"`
|
|
559
|
+
* is browser-only (`InvoClient.approveHosted`) and is refused before the network.
|
|
560
|
+
*/
|
|
561
|
+
beginDeviceApproval(input: BeginDeviceApprovalInput, opts?: CallOptions): Promise<DeviceApprovalGrant>;
|
|
562
|
+
/**
|
|
563
|
+
* Stage 3 — one poll (RFC 8628 §3.4/§3.5). Call it no faster than `interval` seconds.
|
|
564
|
+
*
|
|
565
|
+
* Returns `status`:
|
|
566
|
+
* - `authorization_pending` — keep polling. While a first-time phone waits on your
|
|
567
|
+
* screen, `enrollment` is present: show "Set up INVO on <deviceLabel>? Code
|
|
568
|
+
* <matchCode>" and answer with `confirmDeviceEnrollment`.
|
|
569
|
+
* - `slow_down` — add 5 s to your interval, then resume.
|
|
570
|
+
* - `approved` — **now call `approveWithDeviceCode`**. Nothing has moved yet.
|
|
571
|
+
* - `access_denied` — the player declined; do not retry silently.
|
|
572
|
+
* - `expired_token` — the grant lapsed; `beginDeviceApproval` again.
|
|
573
|
+
* Throws `InvoError` for `invalid_grant` (`err.code === "invalid_grant"`: unknown code,
|
|
574
|
+
* or not this player's — one answer for both, deliberately) and for transport failures
|
|
575
|
+
* after the retry budget (429 / 5xx are retried: this is an idempotent read).
|
|
576
|
+
*/
|
|
577
|
+
pollDeviceApproval(input: PollDeviceApprovalInput, opts?: CallOptions): Promise<DeviceApprovalPollResult>;
|
|
578
|
+
/**
|
|
579
|
+
* Stage 3b — answer the on-screen match-code prompt for a first-time phone.
|
|
580
|
+
*
|
|
581
|
+
* `approve` = "yes, the phone I just scanned with shows this code" (the phone then
|
|
582
|
+
* creates its INVO passkey and approves); `deny` ends the whole grant — the next poll
|
|
583
|
+
* answers `access_denied`. Answered once: `409 DEVICE_APPROVAL_ENROLLMENT_ALREADY_DECIDED`
|
|
584
|
+
* means the backup email got there first — take the prompt down quietly.
|
|
585
|
+
* `409 DEVICE_APPROVAL_NO_ENROLLMENT_PENDING`: no phone has asked. Not auto-retried.
|
|
586
|
+
*/
|
|
587
|
+
confirmDeviceEnrollment(input: ConfirmDeviceEnrollmentInput, opts?: CallOptions): Promise<ConfirmDeviceEnrollmentResult>;
|
|
588
|
+
/**
|
|
589
|
+
* Stage 4 — THE MONEY STEP. Once the poll says `approved`, call this with the same
|
|
590
|
+
* player token and the grant's `deviceCode`. Routes by `flow`:
|
|
591
|
+
*
|
|
592
|
+
* transfer → POST /api/sdk/transfers/{id}/approve
|
|
593
|
+
* send → POST /api/sdk/send/{id}/approve
|
|
594
|
+
* send_receipt → POST /api/sdk/send/{id}/confirm-receipt
|
|
595
|
+
* transfer_receipt → POST /api/sdk/transfers/{id}/confirm-receipt
|
|
596
|
+
*
|
|
597
|
+
* The grant proves WHO approved; this call runs every gate the in-app passkey approve
|
|
598
|
+
* runs (guardian, risk, recovery cooldown) and moves the money. A grant that is never
|
|
599
|
+
* followed by this call moves nothing, and is consumed by nothing.
|
|
600
|
+
*
|
|
601
|
+
* Result: `status: "approved"` + `next: "pending_claim"` (transfer/send; `claimCode`
|
|
602
|
+
* on a transfer) or `status: "completed"` + `amountReceived` (receipt flows). A 202
|
|
603
|
+
* hold returns `holdReason` (money held, not refused). A repeat call after the code was
|
|
604
|
+
* consumed returns `status: "not_pending"` with `currentStatus` and `alreadySettled`
|
|
605
|
+
* — the backend's `TRANSACTION_NOT_PENDING` mapped into a result rather than thrown,
|
|
606
|
+
* because for this call it is the normal answer to "did my earlier attempt land?".
|
|
607
|
+
*
|
|
608
|
+
* Throws `InvoError`: `err.isDeviceApprovalNotApproved` (400 — wrong/foreign code,
|
|
609
|
+
* wrong flow, or the poll never said approved), `err.isPasskeyRecoveryCooldown` (403,
|
|
610
|
+
* money-out after a passkey recovery — `err.retryAfterAt`), guardian terminal states
|
|
611
|
+
* (410). Never auto-retried: the device_code is a single-use factor.
|
|
612
|
+
*
|
|
613
|
+
* **A FAILURE HERE IS AMBIGUOUS ABOUT THE MONEY.** The backend commits the transfer and
|
|
614
|
+
* *then* builds its 200 by reading the transaction back, so a fault raised after that
|
|
615
|
+
* commit answers `SEND_APPROVE_FAILED` / `TRANSFER_APPROVE_FAILED` /
|
|
616
|
+
* `CONFIRM_RECEIPT_FAILED` (`err.isSettleFault`, `err.errorRef`) for money that already
|
|
617
|
+
* moved. A `status === 0` (timeout, connection dropped) is ambiguous for the same
|
|
618
|
+
* reason, and this call is deliberately not auto-retried. So on either: read
|
|
619
|
+
* `getTransferStatus` / `getSendStatus`, or wait for the `transfer.claim_pending`
|
|
620
|
+
* webhook, BEFORE you tell the player it failed — and never auto-start a replacement
|
|
621
|
+
* transaction.
|
|
622
|
+
*/
|
|
623
|
+
approveWithDeviceCode(input: ApproveWithDeviceCodeInput, opts?: CallOptions): Promise<DeviceApprovalSettleResult>;
|
|
624
|
+
/**
|
|
625
|
+
* Convenience only — stages 3 and 4 in one call, for a server that can hold the loop
|
|
626
|
+
* open (a per-request worker, a job). Polls `pollDeviceApproval` on `interval`, adds
|
|
627
|
+
* 5 s on `slow_down`, forwards the poll's `enrollment` to `onEnrollment` (answer with
|
|
628
|
+
* `respond`), and on `approved` calls `approveWithDeviceCode` — THEN resolves.
|
|
629
|
+
* `respond` is best-effort: a prompt the grant has outlived (`expired_token`,
|
|
630
|
+
* `invalid_grant`) or that was already answered elsewhere resolves quietly rather than
|
|
631
|
+
* rejecting, because callers fire it from UI code without awaiting it.
|
|
632
|
+
* You still call `beginDeviceApproval` yourself first, because your game has to draw
|
|
633
|
+
* the QR between begin and the first poll.
|
|
634
|
+
*
|
|
635
|
+
* Resolves `{ status: "approved", settlement }` | `denied` | `expired` | `aborted`.
|
|
636
|
+
* Rejects on `invalid_grant`, on a refused approve (e.g. `PASSKEY_RECOVERY_COOLDOWN`),
|
|
637
|
+
* and after 5 consecutive transport failures on the poll.
|
|
638
|
+
*
|
|
639
|
+
* **Record the attempt in your own store BEFORE you call this.** It blocks for as long
|
|
640
|
+
* as the player takes and then moves money from inside the loop, so if your process
|
|
641
|
+
* dies between the approve call and its response, a row you wrote first — plus
|
|
642
|
+
* `getTransferStatus` / `getSendStatus` — is the only way to learn whether the money
|
|
643
|
+
* moved. Servers that must not block a request use the three calls directly and keep
|
|
644
|
+
* `deviceCode` in their own store.
|
|
645
|
+
*
|
|
646
|
+
* `respond` (handed to `onEnrollment`) is best-effort: a prompt the grant has outlived
|
|
647
|
+
* resolves quietly rather than rejecting. Any other confirm-enrollment refusal
|
|
648
|
+
* propagates, so `await` it if you want to see one.
|
|
649
|
+
*/
|
|
650
|
+
completeDeviceApproval(input: CompleteDeviceApprovalInput, opts?: CallOptions): Promise<CompleteDeviceApprovalResult>;
|
|
545
651
|
private toInitiateResult;
|
|
546
652
|
}
|
|
547
653
|
|
|
548
|
-
export { CallOptions, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, DestinationsResult, GuardianApprovalStatusResult, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, OrderDetailsResult, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerToken, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, ServerConfig, ServerDestinationsQuery, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamPacksQuery, SteamPacksResult, TransactionStatusResult, type TransferEventData, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };
|
|
654
|
+
export { ApproveWithDeviceCodeInput, BeginDeviceApprovalInput, CallOptions, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, CompleteDeviceApprovalInput, CompleteDeviceApprovalResult, ConfirmDeviceEnrollmentInput, ConfirmDeviceEnrollmentResult, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, DestinationsResult, DeviceApprovalGrant, DeviceApprovalPollResult, DeviceApprovalSettleResult, GuardianApprovalStatusResult, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, OrderDetailsResult, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerToken, PollDeviceApprovalInput, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, ServerConfig, ServerDestinationsQuery, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamPacksQuery, SteamPacksResult, TransactionStatusResult, type TransferEventData, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InvoError, H as Http, o as AuthHeader, p as PlatformPurchaseInput,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvoError, H as Http, o as AuthHeader, p as PlatformPurchaseInput, c as CallOptions, q as PlatformPurchaseResult, r as PlatformOrderStatusResult, s as PlatformRefundInput, t as PlatformRefundResult, S as ServerConfig, u as PlayerToken, v as InitiateSendInput, w as InitiateResult, x as InitiateTransferInput, y as CreateCheckoutInput, z as CreateCheckoutResult, F as PurchaseInput, G as PurchaseResult, J as ConfirmPaymentResult, O as OrderDetailsResult, K as SteamPacksQuery, N as SteamPacksResult, Q as SteamInitPurchaseInput, T as SteamInitPurchaseResult, U as SteamFinalizeInput, W as SteamFinalizeResult, X as PurchaseItemInput, Y as PurchaseItemResult, Z as ItemHistoryQuery, _ as ItemHistoryResult, $ as ItemOrderQuery, a0 as PlayerBalanceQuery, a1 as PlayerBalanceResult, a2 as InboundPendingQuery, a3 as InboundPendingResult, a4 as LinkedIdentitiesQuery, a5 as LinkedIdentitiesResult, a6 as SmsVerifyResult, a7 as ClaimTransferInput, a8 as ClaimResult, a9 as ClaimCurrencyInput, aa as TransactionStatusResult, ab as GuardianApprovalStatusResult, ac as ServerDestinationsQuery, d as DestinationsResult, ad as PhoneShareContact, ae as PhoneShareInitiateResult, af as PhoneShareApproveInput, ag as PhoneShareApproveResult, ah as PhoneShareStatusResult, ai as BeginDeviceApprovalInput, aj as DeviceApprovalGrant, ak as PollDeviceApprovalInput, al as DeviceApprovalPollResult, am as ConfirmDeviceEnrollmentInput, an as ConfirmDeviceEnrollmentResult, ao as ApproveWithDeviceCodeInput, ap as DeviceApprovalSettleResult, aq as CompleteDeviceApprovalInput, ar as CompleteDeviceApprovalResult } from './types-CspPkmK9.js';
|
|
2
|
+
export { as as CurrencyBalance, h as DestinationGame, at as DeviceApprovalChannel, au as DeviceApprovalEnrollment, av as DeviceApprovalFlow, aw as DeviceApprovalPollStatus, ax as DeviceEnrollmentDecision, ay as DeviceEnrollmentRespond, az as FundingSource, aA as InboundPendingItem, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, aB as LinkedIdentityEmail, aC as PlatformPurchaseStatus, n as Rail, aD as SteamPack, aE as SteamUserSession, V as VerificationMethod } from './types-CspPkmK9.js';
|
|
3
3
|
|
|
4
4
|
interface VerifyWebhookOptions {
|
|
5
5
|
/** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
|
|
@@ -542,7 +542,113 @@ declare class InvoServer {
|
|
|
542
542
|
* be re-issued.
|
|
543
543
|
*/
|
|
544
544
|
phoneShareStatus(input: PhoneShareContact, opts?: CallOptions): Promise<PhoneShareStatusResult>;
|
|
545
|
+
/**
|
|
546
|
+
* Stage 1 — start a device approval for ONE transaction (RFC 8628 §3.1/§3.2).
|
|
547
|
+
*
|
|
548
|
+
* Returns the grant: render `verificationUriComplete` as the QR (print `userCode`
|
|
549
|
+
* under it for a TV with no camera), keep `deviceCode` on your server, then poll.
|
|
550
|
+
* A repeat `begin` while an earlier grant is merely PENDING supersedes it (fresh code;
|
|
551
|
+
* a page still open on the old one is told to scan again). A grant the player already
|
|
552
|
+
* APPROVED blocks a new `begin` for its window with `409 DEVICE_APPROVAL_ALREADY_PENDING`
|
|
553
|
+
* (`err.isDeviceApprovalAlreadyPending`, `err.deviceApprovalExpiresAt`) — the missing
|
|
554
|
+
* step there is `approveWithDeviceCode`, not a new code.
|
|
555
|
+
*
|
|
556
|
+
* For `transfer` / `send` the backend also pushes the transaction's own approval
|
|
557
|
+
* window past the grant's expiry, so an approval at minute nine cannot land on a
|
|
558
|
+
* transfer that has already been refunded. Auth: the player token. `channel: "popup"`
|
|
559
|
+
* is browser-only (`InvoClient.approveHosted`) and is refused before the network.
|
|
560
|
+
*/
|
|
561
|
+
beginDeviceApproval(input: BeginDeviceApprovalInput, opts?: CallOptions): Promise<DeviceApprovalGrant>;
|
|
562
|
+
/**
|
|
563
|
+
* Stage 3 — one poll (RFC 8628 §3.4/§3.5). Call it no faster than `interval` seconds.
|
|
564
|
+
*
|
|
565
|
+
* Returns `status`:
|
|
566
|
+
* - `authorization_pending` — keep polling. While a first-time phone waits on your
|
|
567
|
+
* screen, `enrollment` is present: show "Set up INVO on <deviceLabel>? Code
|
|
568
|
+
* <matchCode>" and answer with `confirmDeviceEnrollment`.
|
|
569
|
+
* - `slow_down` — add 5 s to your interval, then resume.
|
|
570
|
+
* - `approved` — **now call `approveWithDeviceCode`**. Nothing has moved yet.
|
|
571
|
+
* - `access_denied` — the player declined; do not retry silently.
|
|
572
|
+
* - `expired_token` — the grant lapsed; `beginDeviceApproval` again.
|
|
573
|
+
* Throws `InvoError` for `invalid_grant` (`err.code === "invalid_grant"`: unknown code,
|
|
574
|
+
* or not this player's — one answer for both, deliberately) and for transport failures
|
|
575
|
+
* after the retry budget (429 / 5xx are retried: this is an idempotent read).
|
|
576
|
+
*/
|
|
577
|
+
pollDeviceApproval(input: PollDeviceApprovalInput, opts?: CallOptions): Promise<DeviceApprovalPollResult>;
|
|
578
|
+
/**
|
|
579
|
+
* Stage 3b — answer the on-screen match-code prompt for a first-time phone.
|
|
580
|
+
*
|
|
581
|
+
* `approve` = "yes, the phone I just scanned with shows this code" (the phone then
|
|
582
|
+
* creates its INVO passkey and approves); `deny` ends the whole grant — the next poll
|
|
583
|
+
* answers `access_denied`. Answered once: `409 DEVICE_APPROVAL_ENROLLMENT_ALREADY_DECIDED`
|
|
584
|
+
* means the backup email got there first — take the prompt down quietly.
|
|
585
|
+
* `409 DEVICE_APPROVAL_NO_ENROLLMENT_PENDING`: no phone has asked. Not auto-retried.
|
|
586
|
+
*/
|
|
587
|
+
confirmDeviceEnrollment(input: ConfirmDeviceEnrollmentInput, opts?: CallOptions): Promise<ConfirmDeviceEnrollmentResult>;
|
|
588
|
+
/**
|
|
589
|
+
* Stage 4 — THE MONEY STEP. Once the poll says `approved`, call this with the same
|
|
590
|
+
* player token and the grant's `deviceCode`. Routes by `flow`:
|
|
591
|
+
*
|
|
592
|
+
* transfer → POST /api/sdk/transfers/{id}/approve
|
|
593
|
+
* send → POST /api/sdk/send/{id}/approve
|
|
594
|
+
* send_receipt → POST /api/sdk/send/{id}/confirm-receipt
|
|
595
|
+
* transfer_receipt → POST /api/sdk/transfers/{id}/confirm-receipt
|
|
596
|
+
*
|
|
597
|
+
* The grant proves WHO approved; this call runs every gate the in-app passkey approve
|
|
598
|
+
* runs (guardian, risk, recovery cooldown) and moves the money. A grant that is never
|
|
599
|
+
* followed by this call moves nothing, and is consumed by nothing.
|
|
600
|
+
*
|
|
601
|
+
* Result: `status: "approved"` + `next: "pending_claim"` (transfer/send; `claimCode`
|
|
602
|
+
* on a transfer) or `status: "completed"` + `amountReceived` (receipt flows). A 202
|
|
603
|
+
* hold returns `holdReason` (money held, not refused). A repeat call after the code was
|
|
604
|
+
* consumed returns `status: "not_pending"` with `currentStatus` and `alreadySettled`
|
|
605
|
+
* — the backend's `TRANSACTION_NOT_PENDING` mapped into a result rather than thrown,
|
|
606
|
+
* because for this call it is the normal answer to "did my earlier attempt land?".
|
|
607
|
+
*
|
|
608
|
+
* Throws `InvoError`: `err.isDeviceApprovalNotApproved` (400 — wrong/foreign code,
|
|
609
|
+
* wrong flow, or the poll never said approved), `err.isPasskeyRecoveryCooldown` (403,
|
|
610
|
+
* money-out after a passkey recovery — `err.retryAfterAt`), guardian terminal states
|
|
611
|
+
* (410). Never auto-retried: the device_code is a single-use factor.
|
|
612
|
+
*
|
|
613
|
+
* **A FAILURE HERE IS AMBIGUOUS ABOUT THE MONEY.** The backend commits the transfer and
|
|
614
|
+
* *then* builds its 200 by reading the transaction back, so a fault raised after that
|
|
615
|
+
* commit answers `SEND_APPROVE_FAILED` / `TRANSFER_APPROVE_FAILED` /
|
|
616
|
+
* `CONFIRM_RECEIPT_FAILED` (`err.isSettleFault`, `err.errorRef`) for money that already
|
|
617
|
+
* moved. A `status === 0` (timeout, connection dropped) is ambiguous for the same
|
|
618
|
+
* reason, and this call is deliberately not auto-retried. So on either: read
|
|
619
|
+
* `getTransferStatus` / `getSendStatus`, or wait for the `transfer.claim_pending`
|
|
620
|
+
* webhook, BEFORE you tell the player it failed — and never auto-start a replacement
|
|
621
|
+
* transaction.
|
|
622
|
+
*/
|
|
623
|
+
approveWithDeviceCode(input: ApproveWithDeviceCodeInput, opts?: CallOptions): Promise<DeviceApprovalSettleResult>;
|
|
624
|
+
/**
|
|
625
|
+
* Convenience only — stages 3 and 4 in one call, for a server that can hold the loop
|
|
626
|
+
* open (a per-request worker, a job). Polls `pollDeviceApproval` on `interval`, adds
|
|
627
|
+
* 5 s on `slow_down`, forwards the poll's `enrollment` to `onEnrollment` (answer with
|
|
628
|
+
* `respond`), and on `approved` calls `approveWithDeviceCode` — THEN resolves.
|
|
629
|
+
* `respond` is best-effort: a prompt the grant has outlived (`expired_token`,
|
|
630
|
+
* `invalid_grant`) or that was already answered elsewhere resolves quietly rather than
|
|
631
|
+
* rejecting, because callers fire it from UI code without awaiting it.
|
|
632
|
+
* You still call `beginDeviceApproval` yourself first, because your game has to draw
|
|
633
|
+
* the QR between begin and the first poll.
|
|
634
|
+
*
|
|
635
|
+
* Resolves `{ status: "approved", settlement }` | `denied` | `expired` | `aborted`.
|
|
636
|
+
* Rejects on `invalid_grant`, on a refused approve (e.g. `PASSKEY_RECOVERY_COOLDOWN`),
|
|
637
|
+
* and after 5 consecutive transport failures on the poll.
|
|
638
|
+
*
|
|
639
|
+
* **Record the attempt in your own store BEFORE you call this.** It blocks for as long
|
|
640
|
+
* as the player takes and then moves money from inside the loop, so if your process
|
|
641
|
+
* dies between the approve call and its response, a row you wrote first — plus
|
|
642
|
+
* `getTransferStatus` / `getSendStatus` — is the only way to learn whether the money
|
|
643
|
+
* moved. Servers that must not block a request use the three calls directly and keep
|
|
644
|
+
* `deviceCode` in their own store.
|
|
645
|
+
*
|
|
646
|
+
* `respond` (handed to `onEnrollment`) is best-effort: a prompt the grant has outlived
|
|
647
|
+
* resolves quietly rather than rejecting. Any other confirm-enrollment refusal
|
|
648
|
+
* propagates, so `await` it if you want to see one.
|
|
649
|
+
*/
|
|
650
|
+
completeDeviceApproval(input: CompleteDeviceApprovalInput, opts?: CallOptions): Promise<CompleteDeviceApprovalResult>;
|
|
545
651
|
private toInitiateResult;
|
|
546
652
|
}
|
|
547
653
|
|
|
548
|
-
export { CallOptions, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, DestinationsResult, GuardianApprovalStatusResult, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, OrderDetailsResult, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerToken, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, ServerConfig, ServerDestinationsQuery, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamPacksQuery, SteamPacksResult, TransactionStatusResult, type TransferEventData, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };
|
|
654
|
+
export { ApproveWithDeviceCodeInput, BeginDeviceApprovalInput, CallOptions, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, CompleteDeviceApprovalInput, CompleteDeviceApprovalResult, ConfirmDeviceEnrollmentInput, ConfirmDeviceEnrollmentResult, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, DestinationsResult, DeviceApprovalGrant, DeviceApprovalPollResult, DeviceApprovalSettleResult, GuardianApprovalStatusResult, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, OrderDetailsResult, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerToken, PollDeviceApprovalInput, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, ServerConfig, ServerDestinationsQuery, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamPacksQuery, SteamPacksResult, TransactionStatusResult, type TransferEventData, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };
|