@invonetwork/web-sdk 2.4.1 → 2.5.1
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 +67 -0
- package/README.md +108 -6
- package/dist/{chunk-SSTZKXPC.js → chunk-5X3ESHJR.js} +35 -5
- package/dist/index.cjs +244 -3
- package/dist/index.d.cts +53 -3
- package/dist/index.d.ts +53 -3
- package/dist/index.js +213 -3
- package/dist/server.cjs +247 -4
- package/dist/server.d.cts +112 -3
- package/dist/server.d.ts +112 -3
- package/dist/server.js +216 -4
- package/dist/{types-7Hl0Z1Ta.d.cts → types-BHvVjdMV.d.cts} +271 -2
- package/dist/{types-7Hl0Z1Ta.d.ts → types-BHvVjdMV.d.ts} +271 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,62 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export {
|
|
1
|
+
import { M as MountCardPaymentOptions, C as CardPaymentSession, a as ConfirmCardPaymentOptions, b as CardPaymentResult, c as ClientConfig, d as CallOptions, A as ApproveResult, e as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, f as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, g as EnrollmentVerifyResult, R as RecoveryBeginResult, h as RecoveryCompleteResult } from './types-BHvVjdMV.cjs';
|
|
2
|
+
export { i as BalanceRow, j as CardPaymentStatus, k as DestinationGame, I as InvoCardConfirmResponse, l as InvoCardElement, m as InvoCardElements, n as InvoCardProcessor, o as InvoError, p as InvoErrorInfo, q as InvoHooks, r as InvoRequestInfo, s as InvoResponseInfo, t as PendingCollectItem, u as Rail, V as VerificationMethod } from './types-BHvVjdMV.cjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Platform Commerce card confirmation (browser side). The server (`InvoServer.
|
|
6
|
+
* platformCommerce.purchase` with `fundingSource:"card"`) returns a `clientSecret`; this
|
|
7
|
+
* mounts the processor's Payment Element (card / Apple Pay / Google Pay) and confirms it.
|
|
8
|
+
* The sale is real only on the `platform_commerce.purchased` webhook — treat a "succeeded"
|
|
9
|
+
* here as "show processing", never as fulfilled.
|
|
10
|
+
*/
|
|
11
|
+
declare class PlatformCommerceClient {
|
|
12
|
+
private readonly defaultPublishableKey;
|
|
13
|
+
constructor(defaultPublishableKey: () => string | undefined);
|
|
14
|
+
/**
|
|
15
|
+
* Mount the Payment Element and get a session you confirm from your OWN Pay button.
|
|
16
|
+
* This is the fully-controllable primitive (`confirmCardPayment` builds on it).
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const session = await invo.platformCommerce.mountCardPayment(clientSecret, {
|
|
20
|
+
* mount: "#pay", publishableKey: "pk_live_…",
|
|
21
|
+
* });
|
|
22
|
+
* // on your Pay button click:
|
|
23
|
+
* const r = await session.confirm({ returnUrl: location.href });
|
|
24
|
+
* if (r.status === "succeeded") showProcessing();
|
|
25
|
+
* session.destroy();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
mountCardPayment(clientSecret: string, opts: MountCardPaymentOptions): Promise<CardPaymentSession>;
|
|
29
|
+
/**
|
|
30
|
+
* One-call mount + confirm. Mounts the Payment Element into `opts.mount` and resolves
|
|
31
|
+
* when the payment is confirmed via a submit trigger — either `opts.submit` (your Pay
|
|
32
|
+
* button, selector or element) or a minimal button the SDK renders inside `mount`. For
|
|
33
|
+
* full control over the button, prefer {@link mountCardPayment}.
|
|
34
|
+
*
|
|
35
|
+
* Two flow notes:
|
|
36
|
+
* - **Bank redirect:** with `redirect: "if_required"` most cards confirm in-page, but a
|
|
37
|
+
* bank can force a full redirect — the browser then navigates away (this promise never
|
|
38
|
+
* settles) and returns to `returnUrl`. On that return page, reconcile via your server's
|
|
39
|
+
* `platformCommerce.getStatus(orderId)` / the `platform_commerce.purchased` webhook.
|
|
40
|
+
* - **Decline / "failed":** the element is torn down when this resolves — to let the user
|
|
41
|
+
* retry after a decline, call `confirmCardPayment` (or `mountCardPayment`) again to
|
|
42
|
+
* remount.
|
|
43
|
+
*/
|
|
44
|
+
confirmCardPayment(clientSecret: string, opts: ConfirmCardPaymentOptions): Promise<CardPaymentResult>;
|
|
45
|
+
}
|
|
4
46
|
declare class InvoClient {
|
|
5
47
|
private readonly http;
|
|
6
48
|
private auth;
|
|
7
49
|
private readonly refreshToken;
|
|
8
50
|
/** In-flight refresh, shared so concurrent expiries trigger a single re-mint. */
|
|
9
51
|
private refreshInFlight;
|
|
52
|
+
private readonly commercePublishableKey;
|
|
53
|
+
/**
|
|
54
|
+
* Platform Commerce (ecommerce) card confirmation. Use after
|
|
55
|
+
* `InvoServer.platformCommerce.purchase({ fundingSource: "card" })` returns a
|
|
56
|
+
* `clientSecret`. The passkey/token flows never touch this. See
|
|
57
|
+
* {@link PlatformCommerceClient}.
|
|
58
|
+
*/
|
|
59
|
+
readonly platformCommerce: PlatformCommerceClient;
|
|
10
60
|
constructor(config: ClientConfig);
|
|
11
61
|
private assertWebAuthn;
|
|
12
62
|
/**
|
|
@@ -129,4 +179,4 @@ declare class InvoClient {
|
|
|
129
179
|
private confirmReceipt;
|
|
130
180
|
}
|
|
131
181
|
|
|
132
|
-
export { ApproveResult, BalanceResult, CallOptions, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, PendingCollectResult, RecoveryBeginResult, RecoveryCompleteResult };
|
|
182
|
+
export { ApproveResult, BalanceResult, CallOptions, CardPaymentResult, CardPaymentSession, ClientConfig, ConfirmCardPaymentOptions, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, MountCardPaymentOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,62 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export {
|
|
1
|
+
import { M as MountCardPaymentOptions, C as CardPaymentSession, a as ConfirmCardPaymentOptions, b as CardPaymentResult, c as ClientConfig, d as CallOptions, A as ApproveResult, e as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, f as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, g as EnrollmentVerifyResult, R as RecoveryBeginResult, h as RecoveryCompleteResult } from './types-BHvVjdMV.js';
|
|
2
|
+
export { i as BalanceRow, j as CardPaymentStatus, k as DestinationGame, I as InvoCardConfirmResponse, l as InvoCardElement, m as InvoCardElements, n as InvoCardProcessor, o as InvoError, p as InvoErrorInfo, q as InvoHooks, r as InvoRequestInfo, s as InvoResponseInfo, t as PendingCollectItem, u as Rail, V as VerificationMethod } from './types-BHvVjdMV.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Platform Commerce card confirmation (browser side). The server (`InvoServer.
|
|
6
|
+
* platformCommerce.purchase` with `fundingSource:"card"`) returns a `clientSecret`; this
|
|
7
|
+
* mounts the processor's Payment Element (card / Apple Pay / Google Pay) and confirms it.
|
|
8
|
+
* The sale is real only on the `platform_commerce.purchased` webhook — treat a "succeeded"
|
|
9
|
+
* here as "show processing", never as fulfilled.
|
|
10
|
+
*/
|
|
11
|
+
declare class PlatformCommerceClient {
|
|
12
|
+
private readonly defaultPublishableKey;
|
|
13
|
+
constructor(defaultPublishableKey: () => string | undefined);
|
|
14
|
+
/**
|
|
15
|
+
* Mount the Payment Element and get a session you confirm from your OWN Pay button.
|
|
16
|
+
* This is the fully-controllable primitive (`confirmCardPayment` builds on it).
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const session = await invo.platformCommerce.mountCardPayment(clientSecret, {
|
|
20
|
+
* mount: "#pay", publishableKey: "pk_live_…",
|
|
21
|
+
* });
|
|
22
|
+
* // on your Pay button click:
|
|
23
|
+
* const r = await session.confirm({ returnUrl: location.href });
|
|
24
|
+
* if (r.status === "succeeded") showProcessing();
|
|
25
|
+
* session.destroy();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
mountCardPayment(clientSecret: string, opts: MountCardPaymentOptions): Promise<CardPaymentSession>;
|
|
29
|
+
/**
|
|
30
|
+
* One-call mount + confirm. Mounts the Payment Element into `opts.mount` and resolves
|
|
31
|
+
* when the payment is confirmed via a submit trigger — either `opts.submit` (your Pay
|
|
32
|
+
* button, selector or element) or a minimal button the SDK renders inside `mount`. For
|
|
33
|
+
* full control over the button, prefer {@link mountCardPayment}.
|
|
34
|
+
*
|
|
35
|
+
* Two flow notes:
|
|
36
|
+
* - **Bank redirect:** with `redirect: "if_required"` most cards confirm in-page, but a
|
|
37
|
+
* bank can force a full redirect — the browser then navigates away (this promise never
|
|
38
|
+
* settles) and returns to `returnUrl`. On that return page, reconcile via your server's
|
|
39
|
+
* `platformCommerce.getStatus(orderId)` / the `platform_commerce.purchased` webhook.
|
|
40
|
+
* - **Decline / "failed":** the element is torn down when this resolves — to let the user
|
|
41
|
+
* retry after a decline, call `confirmCardPayment` (or `mountCardPayment`) again to
|
|
42
|
+
* remount.
|
|
43
|
+
*/
|
|
44
|
+
confirmCardPayment(clientSecret: string, opts: ConfirmCardPaymentOptions): Promise<CardPaymentResult>;
|
|
45
|
+
}
|
|
4
46
|
declare class InvoClient {
|
|
5
47
|
private readonly http;
|
|
6
48
|
private auth;
|
|
7
49
|
private readonly refreshToken;
|
|
8
50
|
/** In-flight refresh, shared so concurrent expiries trigger a single re-mint. */
|
|
9
51
|
private refreshInFlight;
|
|
52
|
+
private readonly commercePublishableKey;
|
|
53
|
+
/**
|
|
54
|
+
* Platform Commerce (ecommerce) card confirmation. Use after
|
|
55
|
+
* `InvoServer.platformCommerce.purchase({ fundingSource: "card" })` returns a
|
|
56
|
+
* `clientSecret`. The passkey/token flows never touch this. See
|
|
57
|
+
* {@link PlatformCommerceClient}.
|
|
58
|
+
*/
|
|
59
|
+
readonly platformCommerce: PlatformCommerceClient;
|
|
10
60
|
constructor(config: ClientConfig);
|
|
11
61
|
private assertWebAuthn;
|
|
12
62
|
/**
|
|
@@ -129,4 +179,4 @@ declare class InvoClient {
|
|
|
129
179
|
private confirmReceipt;
|
|
130
180
|
}
|
|
131
181
|
|
|
132
|
-
export { ApproveResult, BalanceResult, CallOptions, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, PendingCollectResult, RecoveryBeginResult, RecoveryCompleteResult };
|
|
182
|
+
export { ApproveResult, BalanceResult, CallOptions, CardPaymentResult, CardPaymentSession, ClientConfig, ConfirmCardPaymentOptions, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, MountCardPaymentOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assertSecureBaseUrl, Http, toDestinationsResult
|
|
2
|
-
export { InvoError } from './chunk-
|
|
1
|
+
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-5X3ESHJR.js';
|
|
2
|
+
export { InvoError } from './chunk-5X3ESHJR.js';
|
|
3
3
|
|
|
4
4
|
// src/shared/webauthn.ts
|
|
5
5
|
function malformedOptions(field) {
|
|
@@ -120,6 +120,214 @@ function toBalanceRow(row) {
|
|
|
120
120
|
raw: row
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
+
var PROCESSOR_SRC = "https://js.stripe.com/v3";
|
|
124
|
+
var PROCESSOR_LOAD_TIMEOUT_MS = 1e4;
|
|
125
|
+
var processorScriptLoad;
|
|
126
|
+
function loadProcessorScript() {
|
|
127
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
128
|
+
return Promise.reject(
|
|
129
|
+
new InvoError({
|
|
130
|
+
message: "confirmCardPayment requires a browser DOM (window/document).",
|
|
131
|
+
code: "DOM_UNAVAILABLE",
|
|
132
|
+
status: 0
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
if (window.Stripe) return Promise.resolve();
|
|
137
|
+
if (processorScriptLoad) return processorScriptLoad;
|
|
138
|
+
processorScriptLoad = new Promise((resolve, reject) => {
|
|
139
|
+
const fail = () => {
|
|
140
|
+
processorScriptLoad = void 0;
|
|
141
|
+
reject(
|
|
142
|
+
new InvoError({
|
|
143
|
+
message: "Failed to load the card processor script.",
|
|
144
|
+
code: "PROCESSOR_LOAD_FAILED",
|
|
145
|
+
status: 0
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
const existing = document.querySelector(
|
|
150
|
+
`script[src="${PROCESSOR_SRC}"]`
|
|
151
|
+
);
|
|
152
|
+
if (existing) {
|
|
153
|
+
const started = Date.now();
|
|
154
|
+
const poll = setInterval(() => {
|
|
155
|
+
if (window.Stripe) {
|
|
156
|
+
clearInterval(poll);
|
|
157
|
+
resolve();
|
|
158
|
+
} else if (Date.now() - started > PROCESSOR_LOAD_TIMEOUT_MS) {
|
|
159
|
+
clearInterval(poll);
|
|
160
|
+
existing.remove();
|
|
161
|
+
fail();
|
|
162
|
+
}
|
|
163
|
+
}, 100);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const script = document.createElement("script");
|
|
167
|
+
script.src = PROCESSOR_SRC;
|
|
168
|
+
script.async = true;
|
|
169
|
+
script.addEventListener("load", () => resolve());
|
|
170
|
+
script.addEventListener("error", () => {
|
|
171
|
+
script.remove();
|
|
172
|
+
fail();
|
|
173
|
+
});
|
|
174
|
+
document.head.appendChild(script);
|
|
175
|
+
});
|
|
176
|
+
return processorScriptLoad;
|
|
177
|
+
}
|
|
178
|
+
async function defaultLoadProcessor(publishableKey) {
|
|
179
|
+
await loadProcessorScript();
|
|
180
|
+
const factory = window.Stripe;
|
|
181
|
+
if (typeof factory !== "function") {
|
|
182
|
+
throw new InvoError({
|
|
183
|
+
message: "The card processor was unavailable after loading.",
|
|
184
|
+
code: "PROCESSOR_UNAVAILABLE",
|
|
185
|
+
status: 0
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return factory(publishableKey);
|
|
189
|
+
}
|
|
190
|
+
function mapCardConfirm(res) {
|
|
191
|
+
const raw = res;
|
|
192
|
+
if (res.error) {
|
|
193
|
+
return { status: "failed", error: res.error.message ?? "Card payment failed.", raw };
|
|
194
|
+
}
|
|
195
|
+
const pi = res.paymentIntent;
|
|
196
|
+
const s = pi?.status;
|
|
197
|
+
let status;
|
|
198
|
+
if (s === "succeeded") status = "succeeded";
|
|
199
|
+
else if (s === "processing") status = "processing";
|
|
200
|
+
else if (s === "requires_action" || s === "requires_confirmation") status = "requires_action";
|
|
201
|
+
else status = "failed";
|
|
202
|
+
return { status, paymentIntentId: pi?.id, raw };
|
|
203
|
+
}
|
|
204
|
+
function resolveSubmit(opts) {
|
|
205
|
+
if (opts.submit) {
|
|
206
|
+
const el = typeof opts.submit === "string" ? typeof document !== "undefined" ? document.querySelector(opts.submit) : null : opts.submit;
|
|
207
|
+
if (!el) {
|
|
208
|
+
throw new InvoError({
|
|
209
|
+
message: `confirmCardPayment could not find the submit element "${String(opts.submit)}".`,
|
|
210
|
+
code: "SUBMIT_NOT_FOUND",
|
|
211
|
+
status: 0
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return { el, created: false };
|
|
215
|
+
}
|
|
216
|
+
if (typeof document === "undefined") {
|
|
217
|
+
throw new InvoError({
|
|
218
|
+
message: "confirmCardPayment needs a submit button: pass `submit`, or use `mountCardPayment(...).confirm()` from your own button.",
|
|
219
|
+
code: "SUBMIT_REQUIRED",
|
|
220
|
+
status: 0
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
const container = typeof opts.mount === "string" ? document.querySelector(opts.mount) : opts.mount;
|
|
224
|
+
const btn = document.createElement("button");
|
|
225
|
+
btn.type = "button";
|
|
226
|
+
btn.textContent = opts.submitLabel ?? "Pay";
|
|
227
|
+
(container ?? document.body).appendChild(btn);
|
|
228
|
+
return { el: btn, created: true };
|
|
229
|
+
}
|
|
230
|
+
var PlatformCommerceClient = class {
|
|
231
|
+
constructor(defaultPublishableKey) {
|
|
232
|
+
this.defaultPublishableKey = defaultPublishableKey;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Mount the Payment Element and get a session you confirm from your OWN Pay button.
|
|
236
|
+
* This is the fully-controllable primitive (`confirmCardPayment` builds on it).
|
|
237
|
+
*
|
|
238
|
+
* ```ts
|
|
239
|
+
* const session = await invo.platformCommerce.mountCardPayment(clientSecret, {
|
|
240
|
+
* mount: "#pay", publishableKey: "pk_live_…",
|
|
241
|
+
* });
|
|
242
|
+
* // on your Pay button click:
|
|
243
|
+
* const r = await session.confirm({ returnUrl: location.href });
|
|
244
|
+
* if (r.status === "succeeded") showProcessing();
|
|
245
|
+
* session.destroy();
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
async mountCardPayment(clientSecret, opts) {
|
|
249
|
+
if (!clientSecret || !clientSecret.trim()) {
|
|
250
|
+
throw new Error("mountCardPayment requires a `clientSecret`.");
|
|
251
|
+
}
|
|
252
|
+
if (opts?.mount == null || typeof opts.mount === "string" && !opts.mount.trim()) {
|
|
253
|
+
throw new Error("mountCardPayment requires a `mount` target (selector or element).");
|
|
254
|
+
}
|
|
255
|
+
const pk = opts.publishableKey ?? this.defaultPublishableKey();
|
|
256
|
+
if (!pk) {
|
|
257
|
+
throw new InvoError({
|
|
258
|
+
message: "A card processor publishableKey is required \u2014 pass it in options, or set `commercePublishableKey` on the InvoClient config.",
|
|
259
|
+
code: "MISSING_PUBLISHABLE_KEY",
|
|
260
|
+
status: 0
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
const load = opts.loadProcessor ?? defaultLoadProcessor;
|
|
264
|
+
const processor = await load(pk);
|
|
265
|
+
const elements = processor.elements({ clientSecret, appearance: opts.appearance });
|
|
266
|
+
const element = elements.create("payment");
|
|
267
|
+
element.mount(opts.mount);
|
|
268
|
+
const confirm = async (confirmOpts) => {
|
|
269
|
+
const returnUrl = confirmOpts?.returnUrl ?? opts.returnUrl;
|
|
270
|
+
const res = await processor.confirmPayment({
|
|
271
|
+
elements,
|
|
272
|
+
confirmParams: returnUrl ? { return_url: returnUrl } : void 0,
|
|
273
|
+
// Stay in-page unless the bank forces a redirect (then return_url completes it).
|
|
274
|
+
redirect: "if_required"
|
|
275
|
+
});
|
|
276
|
+
return mapCardConfirm(res);
|
|
277
|
+
};
|
|
278
|
+
return {
|
|
279
|
+
element,
|
|
280
|
+
confirm,
|
|
281
|
+
destroy() {
|
|
282
|
+
try {
|
|
283
|
+
element.unmount?.();
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* One-call mount + confirm. Mounts the Payment Element into `opts.mount` and resolves
|
|
291
|
+
* when the payment is confirmed via a submit trigger — either `opts.submit` (your Pay
|
|
292
|
+
* button, selector or element) or a minimal button the SDK renders inside `mount`. For
|
|
293
|
+
* full control over the button, prefer {@link mountCardPayment}.
|
|
294
|
+
*
|
|
295
|
+
* Two flow notes:
|
|
296
|
+
* - **Bank redirect:** with `redirect: "if_required"` most cards confirm in-page, but a
|
|
297
|
+
* bank can force a full redirect — the browser then navigates away (this promise never
|
|
298
|
+
* settles) and returns to `returnUrl`. On that return page, reconcile via your server's
|
|
299
|
+
* `platformCommerce.getStatus(orderId)` / the `platform_commerce.purchased` webhook.
|
|
300
|
+
* - **Decline / "failed":** the element is torn down when this resolves — to let the user
|
|
301
|
+
* retry after a decline, call `confirmCardPayment` (or `mountCardPayment`) again to
|
|
302
|
+
* remount.
|
|
303
|
+
*/
|
|
304
|
+
async confirmCardPayment(clientSecret, opts) {
|
|
305
|
+
const session = await this.mountCardPayment(clientSecret, opts);
|
|
306
|
+
let trigger;
|
|
307
|
+
try {
|
|
308
|
+
trigger = resolveSubmit(opts);
|
|
309
|
+
} catch (e) {
|
|
310
|
+
session.destroy();
|
|
311
|
+
throw e;
|
|
312
|
+
}
|
|
313
|
+
return new Promise((resolve, reject) => {
|
|
314
|
+
const finish = (settle) => {
|
|
315
|
+
if (trigger.created) trigger.el.remove();
|
|
316
|
+
session.destroy();
|
|
317
|
+
settle();
|
|
318
|
+
};
|
|
319
|
+
const onClick = () => {
|
|
320
|
+
trigger.el.removeEventListener("click", onClick);
|
|
321
|
+
if ("disabled" in trigger.el) trigger.el.disabled = true;
|
|
322
|
+
session.confirm().then(
|
|
323
|
+
(r) => finish(() => resolve(r)),
|
|
324
|
+
(e) => finish(() => reject(e))
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
trigger.el.addEventListener("click", onClick);
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
};
|
|
123
331
|
var InvoClient = class {
|
|
124
332
|
constructor(config) {
|
|
125
333
|
if (!config.token) throw new Error("InvoClient requires a player `token`.");
|
|
@@ -136,6 +344,8 @@ var InvoClient = class {
|
|
|
136
344
|
});
|
|
137
345
|
this.auth = { kind: "bearer", token: config.token };
|
|
138
346
|
this.refreshToken = config.refreshToken;
|
|
347
|
+
this.commercePublishableKey = config.commercePublishableKey;
|
|
348
|
+
this.platformCommerce = new PlatformCommerceClient(() => this.commercePublishableKey);
|
|
139
349
|
}
|
|
140
350
|
assertWebAuthn() {
|
|
141
351
|
if (typeof navigator === "undefined" || !navigator.credentials) {
|
|
@@ -476,6 +686,6 @@ var InvoClient = class {
|
|
|
476
686
|
}
|
|
477
687
|
};
|
|
478
688
|
|
|
479
|
-
export { InvoClient };
|
|
689
|
+
export { InvoClient, PlatformCommerceClient };
|
|
480
690
|
//# sourceMappingURL=index.js.map
|
|
481
691
|
//# sourceMappingURL=index.js.map
|