@invonetwork/web-sdk 3.3.0 → 3.6.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,98 @@
1
- import { M as MountCheckoutOptions, C as CheckoutMountHandle, a as ClientConfig, b as CallOptions, A as ApproveResult, c as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-DzmukUr9.cjs';
2
- export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-DzmukUr9.cjs';
1
+ import { A as ApproveResult, C as ConfirmReceiptResult, M as MountCheckoutOptions, a as CheckoutMountHandle, b as ClientConfig, c as CallOptions, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-ZNoG09S5.cjs';
2
+ export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-ZNoG09S5.cjs';
3
+
4
+ /** The four device-approval flows (`begin.flow`). */
5
+ type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
6
+ /** Outcome of {@link InvoClient.approveHosted}. */
7
+ type HostedApprovalStatus =
8
+ /** The poll said approved AND the approve endpoint accepted the `device_code` — see `approval`. */
9
+ "approved"
10
+ /** The player declined (poll `access_denied`, incl. a denied enrolment). The popup stays open. */
11
+ | "denied"
12
+ /** The grant expired (poll `expired_token`, or `expires_in` passed) — start a new approval. */
13
+ | "expired"
14
+ /** The player closed the popup (or `signal` aborted) before an answer. */
15
+ | "closed"
16
+ /** Popups were blocked and `popupBlocked: "redirect"` navigated this tab. */
17
+ | "redirected"
18
+ /**
19
+ * The popup could not be used: blocked by the browser (default `popupBlocked: "resolve"`),
20
+ * severed by `Cross-Origin-Opener-Policy: same-origin` on your page, or the redirect
21
+ * fallback failed. `message` says which. Nothing was started when the browser blocked it.
22
+ */
23
+ | "blocked";
24
+ interface ApproveHostedResult<A = ApproveResult | ConfirmReceiptResult> {
25
+ status: HostedApprovalStatus;
26
+ /** true when the popup could not be used (status `redirected` or `blocked`). */
27
+ popupBlocked: boolean;
28
+ /** Human-readable reason for `blocked`; absent otherwise. */
29
+ message?: string;
30
+ /**
31
+ * On `approved`: the approve endpoint's response — the same shape `approveSend` /
32
+ * `approveTransfer` return for `transfer`/`send`, and `confirmReceipt*` for the
33
+ * receipt flows. A 202 hold (risk / guardian / step-up) surfaces as `holdReason`.
34
+ */
35
+ approval?: A;
36
+ }
37
+ /** The poll's `enrollment` object (snake_case on the wire; camelCase tolerated). */
38
+ interface HostedEnrollmentInput {
39
+ state?: string;
40
+ device_label?: string;
41
+ deviceLabel?: string;
42
+ match_code?: string;
43
+ matchCode?: string;
44
+ requested_at?: string;
45
+ requestedAt?: string;
46
+ [key: string]: unknown;
47
+ }
48
+ /** Normalised enrolment state the SDK renders and reports through `onEnrollment`. */
49
+ interface HostedEnrollment {
50
+ /** `awaiting_screen` → prompt shown; `confirmed` → "finishing" row; anything else → removed. */
51
+ state: string;
52
+ /** Fixed-list label of the device that opened the page (iPhone, Android phone, ...). */
53
+ deviceLabel: string;
54
+ /** The code the hosted page is showing; the player must see the SAME code here. */
55
+ matchCode: string;
56
+ requestedAt: string | undefined;
57
+ raw: Record<string, unknown>;
58
+ }
59
+ type EnrollmentDecision = "approve" | "deny";
60
+ /** Answer the match-code prompt (the SDK forwards it to `confirm-enrollment`). */
61
+ type EnrollmentRespond = (decision: EnrollmentDecision) => Promise<void>;
62
+ interface ApproveHostedOptions {
63
+ /** The transaction to approve (the id your server got when it initiated it). */
64
+ transactionId: string;
65
+ /** Which device-approval flow: `transfer` | `send` | `send_receipt` | `transfer_receipt`. */
66
+ flow: HostedFlow;
67
+ /**
68
+ * Pin the origin the wake-up is accepted from. `verification_uri_complete` is still
69
+ * parsed, must be https, and its origin must EQUAL this value — otherwise the call
70
+ * rejects. Default: the URL's own origin.
71
+ */
72
+ platformOrigin?: string;
73
+ /**
74
+ * Observe the enrolment state each time it changes (`null` when cleared). To draw
75
+ * your own prompt, set `renderPrompt: false` and call `respond("approve" | "deny")`.
76
+ */
77
+ onEnrollment?: (enrollment: HostedEnrollment | null, respond: EnrollmentRespond) => void;
78
+ /** Render the INVO match-code prompt (default true). */
79
+ renderPrompt?: boolean;
80
+ /**
81
+ * When the browser blocks the popup: `"resolve"` (default) resolves `blocked` before
82
+ * anything is started, so you can show a button and call again from its click
83
+ * handler; `"redirect"` starts the grant and navigates THIS tab to the hosted page
84
+ * (resolving `redirected` first — your page unloads; the `device_approval.approved`
85
+ * webhook is then your only signal).
86
+ */
87
+ popupBlocked?: "redirect" | "resolve";
88
+ /** Popup size. Defaults 480×720. */
89
+ popup?: {
90
+ width?: number;
91
+ height?: number;
92
+ };
93
+ /** Abort → the popup is closed and the promise resolves `closed`. */
94
+ signal?: AbortSignal;
95
+ }
3
96
 
4
97
  declare class PlatformCommerceClient {
5
98
  /**
@@ -49,6 +142,45 @@ declare class InvoClient {
49
142
  device: unknown;
50
143
  raw: Record<string, unknown>;
51
144
  }>;
145
+ /**
146
+ * Hosted approval for web games — the browser is the client of the device-approval
147
+ * grant (RFC 8628). One call does the whole thing with the player token this client
148
+ * already holds: `begin` (`channel: "popup"` — INVO records this page's `Origin` as
149
+ * the opener), opens INVO's hosted page in a popup, polls (honouring `interval` and
150
+ * `slow_down`), drives the match-code prompt from the poll's `enrollment` object and
151
+ * answers it via `confirm-enrollment`, and — when the poll says `approved` — calls
152
+ * the flow's approve endpoint with the `device_code`, through every existing gate.
153
+ * Your server does nothing new; its `device_approval.approved` webhook still fires.
154
+ *
155
+ * `device_code` is held in the call's closure for its duration: never on the result,
156
+ * never logged.
157
+ *
158
+ * Resolves `{ status }`:
159
+ * - `approved` — money moved (or is held: see `approval.holdReason`); `approval` is
160
+ * the approve endpoint's response (`ApproveResult` for transfer/send,
161
+ * `ConfirmReceiptResult` for the receipt flows).
162
+ * - `denied` — the player declined on the page or denied the enrolment.
163
+ * - `expired` — start a new approval.
164
+ * - `closed` — the player closed the popup (or `signal` aborted).
165
+ * - `blocked` / `redirected` — the popup could not be used; see `message`. With the
166
+ * default `popupBlocked: "resolve"` nothing was started: retry from a click.
167
+ * Rejects with `InvoError` when `begin` (400), `confirm-enrollment` (other than
168
+ * already-decided), the poll (`invalid_grant`) or the approve endpoint refuses.
169
+ *
170
+ * The page's `postMessage` is a wake-up that triggers an immediate poll — never a
171
+ * result. Call this from a click handler (the popup is opened synchronously, before
172
+ * any network round-trip) and do not send `Cross-Origin-Opener-Policy: same-origin`
173
+ * on the calling page (`same-origin-allow-popups` is fine). In-app passkeys on your
174
+ * own domain (`enrollPasskey`, `approveSend`, ...) keep working; this is the path for
175
+ * a player without one. (§3.1 / D-HIP-003 / D-HIP-004 / D-HIP-015.)
176
+ */
177
+ approveHosted(opts: ApproveHostedOptions & {
178
+ flow: "transfer" | "send";
179
+ }): Promise<ApproveHostedResult<ApproveResult>>;
180
+ approveHosted(opts: ApproveHostedOptions & {
181
+ flow: "send_receipt" | "transfer_receipt";
182
+ }): Promise<ApproveHostedResult<ConfirmReceiptResult>>;
183
+ approveHosted(opts: ApproveHostedOptions): Promise<ApproveHostedResult>;
52
184
  /** Approve a SEND with the player's passkey. */
53
185
  approveSend(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
54
186
  /** Approve a TRANSFER with the player's passkey (returns the sender's claim code). */
@@ -158,4 +290,4 @@ declare class InvoClient {
158
290
  private confirmReceipt;
159
291
  }
160
292
 
161
- export { ApproveResult, BalanceResult, CallOptions, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, MountCheckoutOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };
293
+ export { type ApproveHostedOptions, type ApproveHostedResult, ApproveResult, BalanceResult, CallOptions, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, MountCheckoutOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,98 @@
1
- import { M as MountCheckoutOptions, C as CheckoutMountHandle, a as ClientConfig, b as CallOptions, A as ApproveResult, c as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-DzmukUr9.js';
2
- export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-DzmukUr9.js';
1
+ import { A as ApproveResult, C as ConfirmReceiptResult, M as MountCheckoutOptions, a as CheckoutMountHandle, b as ClientConfig, c as CallOptions, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-ZNoG09S5.js';
2
+ export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-ZNoG09S5.js';
3
+
4
+ /** The four device-approval flows (`begin.flow`). */
5
+ type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
6
+ /** Outcome of {@link InvoClient.approveHosted}. */
7
+ type HostedApprovalStatus =
8
+ /** The poll said approved AND the approve endpoint accepted the `device_code` — see `approval`. */
9
+ "approved"
10
+ /** The player declined (poll `access_denied`, incl. a denied enrolment). The popup stays open. */
11
+ | "denied"
12
+ /** The grant expired (poll `expired_token`, or `expires_in` passed) — start a new approval. */
13
+ | "expired"
14
+ /** The player closed the popup (or `signal` aborted) before an answer. */
15
+ | "closed"
16
+ /** Popups were blocked and `popupBlocked: "redirect"` navigated this tab. */
17
+ | "redirected"
18
+ /**
19
+ * The popup could not be used: blocked by the browser (default `popupBlocked: "resolve"`),
20
+ * severed by `Cross-Origin-Opener-Policy: same-origin` on your page, or the redirect
21
+ * fallback failed. `message` says which. Nothing was started when the browser blocked it.
22
+ */
23
+ | "blocked";
24
+ interface ApproveHostedResult<A = ApproveResult | ConfirmReceiptResult> {
25
+ status: HostedApprovalStatus;
26
+ /** true when the popup could not be used (status `redirected` or `blocked`). */
27
+ popupBlocked: boolean;
28
+ /** Human-readable reason for `blocked`; absent otherwise. */
29
+ message?: string;
30
+ /**
31
+ * On `approved`: the approve endpoint's response — the same shape `approveSend` /
32
+ * `approveTransfer` return for `transfer`/`send`, and `confirmReceipt*` for the
33
+ * receipt flows. A 202 hold (risk / guardian / step-up) surfaces as `holdReason`.
34
+ */
35
+ approval?: A;
36
+ }
37
+ /** The poll's `enrollment` object (snake_case on the wire; camelCase tolerated). */
38
+ interface HostedEnrollmentInput {
39
+ state?: string;
40
+ device_label?: string;
41
+ deviceLabel?: string;
42
+ match_code?: string;
43
+ matchCode?: string;
44
+ requested_at?: string;
45
+ requestedAt?: string;
46
+ [key: string]: unknown;
47
+ }
48
+ /** Normalised enrolment state the SDK renders and reports through `onEnrollment`. */
49
+ interface HostedEnrollment {
50
+ /** `awaiting_screen` → prompt shown; `confirmed` → "finishing" row; anything else → removed. */
51
+ state: string;
52
+ /** Fixed-list label of the device that opened the page (iPhone, Android phone, ...). */
53
+ deviceLabel: string;
54
+ /** The code the hosted page is showing; the player must see the SAME code here. */
55
+ matchCode: string;
56
+ requestedAt: string | undefined;
57
+ raw: Record<string, unknown>;
58
+ }
59
+ type EnrollmentDecision = "approve" | "deny";
60
+ /** Answer the match-code prompt (the SDK forwards it to `confirm-enrollment`). */
61
+ type EnrollmentRespond = (decision: EnrollmentDecision) => Promise<void>;
62
+ interface ApproveHostedOptions {
63
+ /** The transaction to approve (the id your server got when it initiated it). */
64
+ transactionId: string;
65
+ /** Which device-approval flow: `transfer` | `send` | `send_receipt` | `transfer_receipt`. */
66
+ flow: HostedFlow;
67
+ /**
68
+ * Pin the origin the wake-up is accepted from. `verification_uri_complete` is still
69
+ * parsed, must be https, and its origin must EQUAL this value — otherwise the call
70
+ * rejects. Default: the URL's own origin.
71
+ */
72
+ platformOrigin?: string;
73
+ /**
74
+ * Observe the enrolment state each time it changes (`null` when cleared). To draw
75
+ * your own prompt, set `renderPrompt: false` and call `respond("approve" | "deny")`.
76
+ */
77
+ onEnrollment?: (enrollment: HostedEnrollment | null, respond: EnrollmentRespond) => void;
78
+ /** Render the INVO match-code prompt (default true). */
79
+ renderPrompt?: boolean;
80
+ /**
81
+ * When the browser blocks the popup: `"resolve"` (default) resolves `blocked` before
82
+ * anything is started, so you can show a button and call again from its click
83
+ * handler; `"redirect"` starts the grant and navigates THIS tab to the hosted page
84
+ * (resolving `redirected` first — your page unloads; the `device_approval.approved`
85
+ * webhook is then your only signal).
86
+ */
87
+ popupBlocked?: "redirect" | "resolve";
88
+ /** Popup size. Defaults 480×720. */
89
+ popup?: {
90
+ width?: number;
91
+ height?: number;
92
+ };
93
+ /** Abort → the popup is closed and the promise resolves `closed`. */
94
+ signal?: AbortSignal;
95
+ }
3
96
 
4
97
  declare class PlatformCommerceClient {
5
98
  /**
@@ -49,6 +142,45 @@ declare class InvoClient {
49
142
  device: unknown;
50
143
  raw: Record<string, unknown>;
51
144
  }>;
145
+ /**
146
+ * Hosted approval for web games — the browser is the client of the device-approval
147
+ * grant (RFC 8628). One call does the whole thing with the player token this client
148
+ * already holds: `begin` (`channel: "popup"` — INVO records this page's `Origin` as
149
+ * the opener), opens INVO's hosted page in a popup, polls (honouring `interval` and
150
+ * `slow_down`), drives the match-code prompt from the poll's `enrollment` object and
151
+ * answers it via `confirm-enrollment`, and — when the poll says `approved` — calls
152
+ * the flow's approve endpoint with the `device_code`, through every existing gate.
153
+ * Your server does nothing new; its `device_approval.approved` webhook still fires.
154
+ *
155
+ * `device_code` is held in the call's closure for its duration: never on the result,
156
+ * never logged.
157
+ *
158
+ * Resolves `{ status }`:
159
+ * - `approved` — money moved (or is held: see `approval.holdReason`); `approval` is
160
+ * the approve endpoint's response (`ApproveResult` for transfer/send,
161
+ * `ConfirmReceiptResult` for the receipt flows).
162
+ * - `denied` — the player declined on the page or denied the enrolment.
163
+ * - `expired` — start a new approval.
164
+ * - `closed` — the player closed the popup (or `signal` aborted).
165
+ * - `blocked` / `redirected` — the popup could not be used; see `message`. With the
166
+ * default `popupBlocked: "resolve"` nothing was started: retry from a click.
167
+ * Rejects with `InvoError` when `begin` (400), `confirm-enrollment` (other than
168
+ * already-decided), the poll (`invalid_grant`) or the approve endpoint refuses.
169
+ *
170
+ * The page's `postMessage` is a wake-up that triggers an immediate poll — never a
171
+ * result. Call this from a click handler (the popup is opened synchronously, before
172
+ * any network round-trip) and do not send `Cross-Origin-Opener-Policy: same-origin`
173
+ * on the calling page (`same-origin-allow-popups` is fine). In-app passkeys on your
174
+ * own domain (`enrollPasskey`, `approveSend`, ...) keep working; this is the path for
175
+ * a player without one. (§3.1 / D-HIP-003 / D-HIP-004 / D-HIP-015.)
176
+ */
177
+ approveHosted(opts: ApproveHostedOptions & {
178
+ flow: "transfer" | "send";
179
+ }): Promise<ApproveHostedResult<ApproveResult>>;
180
+ approveHosted(opts: ApproveHostedOptions & {
181
+ flow: "send_receipt" | "transfer_receipt";
182
+ }): Promise<ApproveHostedResult<ConfirmReceiptResult>>;
183
+ approveHosted(opts: ApproveHostedOptions): Promise<ApproveHostedResult>;
52
184
  /** Approve a SEND with the player's passkey. */
53
185
  approveSend(transactionId: string, opts?: CallOptions): Promise<ApproveResult>;
54
186
  /** Approve a TRANSFER with the player's passkey (returns the sender's claim code). */
@@ -158,4 +290,4 @@ declare class InvoClient {
158
290
  private confirmReceipt;
159
291
  }
160
292
 
161
- export { ApproveResult, BalanceResult, CallOptions, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, MountCheckoutOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };
293
+ export { type ApproveHostedOptions, type ApproveHostedResult, ApproveResult, BalanceResult, CallOptions, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, MountCheckoutOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };