@wirexapp/card-sdk-core 0.1.0-beta.3 → 0.1.0-beta.5
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 +28 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +155 -39
- package/dist/protocol.d.ts.map +1 -1
- package/dist/walletElement.d.ts +39 -45
- package/dist/walletElement.d.ts.map +1 -1
- package/dist/walletElement.js +37 -51
- package/dist/walletElement.js.map +1 -1
- package/dist/walletPopup.d.ts +32 -0
- package/dist/walletPopup.d.ts.map +1 -0
- package/dist/walletPopup.js +210 -0
- package/dist/walletPopup.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @wirexapp/card-sdk-core
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0a24437: Wallet top-up reworked to the confirmed backend contract ("Wallet Top-Ups
|
|
8
|
+
Integration"): the checkout frame now TOKENIZES AND RETURNS instead of
|
|
9
|
+
executing. Breaking within the beta line for the wallet surface only
|
|
10
|
+
(collect/reveal/3ds untouched):
|
|
11
|
+
|
|
12
|
+
- `createWalletTopUpForm` / `<WalletTopUpForm />` take `{ quote, walletConfig }`
|
|
13
|
+
(the host's estimate response + the app config's `topup` provider block,
|
|
14
|
+
passed verbatim) instead of `{ session: { estimationId, getCheckoutToken } }`
|
|
15
|
+
— `checkout_token` does not exist in the confirmed contract.
|
|
16
|
+
- The payment sheet's encrypted payload arrives in `onToken` (replaces
|
|
17
|
+
`onResult`); relay it verbatim as the execute call's `wallet_payment_token`.
|
|
18
|
+
The execute watchdog is gone (the host owns execute), and the
|
|
19
|
+
`threeDsRequired` result is removed — `three_ds_state` is never present on a
|
|
20
|
+
wallet top-up.
|
|
21
|
+
- New `onAttemptFailed(reason)` callback for sheet attempts that produce no
|
|
22
|
+
token (e.g. merchant validation failure).
|
|
23
|
+
- `checkWalletAvailability` / `useWalletAvailability` accept the provider
|
|
24
|
+
config so the Google readiness check uses the backend's
|
|
25
|
+
`allowed_auth_methods` / networks verbatim instead of built-in defaults.
|
|
26
|
+
- Frames: the checkout document no longer calls estimation-view/config/execute
|
|
27
|
+
endpoints (its only backend call is Apple merchant validation); the dev mock
|
|
28
|
+
API now mirrors the real contract shapes (`/api/v1/cards/topup/estimate`,
|
|
29
|
+
`/execute`, `/api/v1/config` `topup` block).
|
|
30
|
+
|
|
3
31
|
## 0.1.0-beta.3
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -16,8 +16,10 @@ export { PciCollectGroup } from './collectGroup.js';
|
|
|
16
16
|
export { PciFrameChannel, PciFrameRequestError } from './frameChannel.js';
|
|
17
17
|
export type { PciEnvironment, PciFrameDocument, PciSdkConfig } from './frameUrl.js';
|
|
18
18
|
export { buildFrameUrl, resolveFrameOrigin } from './frameUrl.js';
|
|
19
|
-
export type { PciAppearance, PciAppearanceVariables, PciBrandBadgeAppearance, PciCardBrand, PciCollectChangeState, PciCollectFieldInitConfig, PciCollectFieldName, PciCollectInitConfig, PciCollectProfile, PciFrameAuth, PciFrameError, PciFrameStrings, PciFrameToHostMessage, PciHostToFrameMessage, PciInitConfig, PciRevealField, PciRevealInitConfig, PciRevealState, PciRevealStatus, PciTokenizeOctRequest, PciTokenizeOctResult, PciTokenizeRequest, PciTokenizeTopUpRequest, PciTokenizeTopUpResult, PciWalletAvailability, PciWalletButtonAppearance, PciWalletCheckoutInitConfig, PciWalletCheckoutState, PciWalletProbeInitConfig,
|
|
19
|
+
export type { PciAppearance, PciAppearanceVariables, PciBrandBadgeAppearance, PciCardBrand, PciCollectChangeState, PciCollectFieldInitConfig, PciCollectFieldName, PciCollectInitConfig, PciCollectProfile, PciFrameAuth, PciFrameError, PciFrameStrings, PciFrameToHostMessage, PciHostToFrameMessage, PciInitConfig, PciRevealField, PciRevealInitConfig, PciRevealState, PciRevealStatus, PciTokenizeOctRequest, PciTokenizeOctResult, PciTokenizeRequest, PciTokenizeTopUpRequest, PciTokenizeTopUpResult, PciWalletApplePayConfig, PciWalletAvailability, PciWalletBrandingConfig, PciWalletButtonAppearance, PciWalletCheckoutInitConfig, PciWalletCheckoutState, PciWalletGooglePayConfig, PciWalletMoney, PciWalletPaymentTokenDto, PciWalletProbeInitConfig, PciWalletProviderConfig, PciWalletQuote, } from './protocol.js';
|
|
20
20
|
export { PCI_PROTOCOL_VERSION } from './protocol.js';
|
|
21
|
-
export type {
|
|
21
|
+
export type { PciWalletPaymentToken, PciWalletTopUpElementConfig, } from './walletElement.js';
|
|
22
22
|
export { PciWalletTopUpElement, probeWalletAvailability } from './walletElement.js';
|
|
23
|
+
export type { PciWalletTopUpPopup, PciWalletTopUpPopupConfig } from './walletPopup.js';
|
|
24
|
+
export { openWalletTopUpPopup } from './walletPopup.js';
|
|
23
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EA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,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,YAAY,EACV,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACjF,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,4 +15,5 @@ export { PciFrameChannel, PciFrameRequestError } from './frameChannel.js';
|
|
|
15
15
|
export { buildFrameUrl, resolveFrameOrigin } from './frameUrl.js';
|
|
16
16
|
export { PCI_PROTOCOL_VERSION } from './protocol.js';
|
|
17
17
|
export { PciWalletTopUpElement, probeWalletAvailability } from './walletElement.js';
|
|
18
|
+
export { openWalletTopUpPopup } from './walletPopup.js';
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAuC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKlD,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -227,6 +227,11 @@ export interface PciRevealInitConfig {
|
|
|
227
227
|
* request's result carries `PciWalletAvailability`. */
|
|
228
228
|
export interface PciWalletProbeInitConfig {
|
|
229
229
|
mode: 'wallet-probe';
|
|
230
|
+
/** Provider wallet config (from the app config's `topup` block). Optional —
|
|
231
|
+
* the probe is loadable before any quote — but when present its Google Pay
|
|
232
|
+
* values (auth methods, networks) are used verbatim so the availability
|
|
233
|
+
* answer reflects the real tokenization path instead of built-in defaults. */
|
|
234
|
+
config?: PciWalletProviderConfig;
|
|
230
235
|
}
|
|
231
236
|
export interface PciWalletAvailability {
|
|
232
237
|
applePay: boolean;
|
|
@@ -247,42 +252,139 @@ export interface PciWalletButtonAppearance {
|
|
|
247
252
|
type?: 'plain' | 'pay' | 'buy';
|
|
248
253
|
};
|
|
249
254
|
}
|
|
255
|
+
export interface PciWalletMoney {
|
|
256
|
+
amount: string | number;
|
|
257
|
+
currency: string;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Provider wallet config blocks — the `topup.providers.<name>` entry of
|
|
261
|
+
* `GET /api/v1/config`, passed through VERBATIM in the backend's own casing.
|
|
262
|
+
* The frame copies these values into the platform payment requests unchanged
|
|
263
|
+
* (contract rule: a value that is wrong here reaches the provider unchanged,
|
|
264
|
+
* so nothing is normalised, re-cased or hardcoded).
|
|
265
|
+
*/
|
|
266
|
+
export interface PciWalletApplePayConfig {
|
|
267
|
+
merchant_name?: string;
|
|
268
|
+
/** ISO-3166-1 alpha-2 — the acquirer's country, not the cardholder's. */
|
|
269
|
+
merchant_country_code?: string;
|
|
270
|
+
/** Apple's values, e.g. `supports3DS`. */
|
|
271
|
+
merchant_capabilities?: string[];
|
|
272
|
+
/** Apple's casing — `visa`, `masterCard`. */
|
|
273
|
+
supported_networks?: string[];
|
|
274
|
+
/** Empty when the acquirer needs none. */
|
|
275
|
+
required_billing_contact_fields?: string[];
|
|
276
|
+
/** `ApplePaySession` version the page constructs. */
|
|
277
|
+
api_version?: number;
|
|
278
|
+
}
|
|
279
|
+
export interface PciWalletGooglePayConfig {
|
|
280
|
+
merchant_id?: string;
|
|
281
|
+
merchant_name?: string;
|
|
282
|
+
merchant_country_code?: string;
|
|
283
|
+
/** Gateway as registered with Google, and the merchant id it knows you by. */
|
|
284
|
+
gateway_name?: string;
|
|
285
|
+
gateway_merchant_id?: string;
|
|
286
|
+
api_version?: number;
|
|
287
|
+
api_version_minor?: number;
|
|
288
|
+
/** Read, never hardcoded — `CRYPTOGRAM_3DS` alone keeps this leg out of 3DS. */
|
|
289
|
+
allowed_auth_methods?: string[];
|
|
290
|
+
/** Google's casing — `VISA`, `MASTERCARD`. */
|
|
291
|
+
allowed_card_networks?: string[];
|
|
292
|
+
allow_credit_cards?: boolean;
|
|
293
|
+
allow_prepaid_cards?: boolean;
|
|
294
|
+
billing_address_required?: boolean;
|
|
295
|
+
/** Read only when `billing_address_required`. */
|
|
296
|
+
billing_address_parameters?: {
|
|
297
|
+
format?: string;
|
|
298
|
+
phone_number_required?: boolean;
|
|
299
|
+
};
|
|
300
|
+
/** Lowest Android WebView major version that reaches the native sheet. */
|
|
301
|
+
min_webview_version?: number;
|
|
302
|
+
}
|
|
303
|
+
/** A provider that doesn't acquire a given method simply omits that key —
|
|
304
|
+
* an absent `apple_pay` is not an error state; it means "don't offer it". */
|
|
305
|
+
export interface PciWalletProviderConfig {
|
|
306
|
+
apple_pay?: PciWalletApplePayConfig;
|
|
307
|
+
google_pay?: PciWalletGooglePayConfig;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* The quote the frame renders and binds the payment sheet to — taken from the
|
|
311
|
+
* host's estimate response (`POST /api/v1/cards/topup/estimate` with a wallet
|
|
312
|
+
* `payment_method`). The backend re-validates the estimation on execute, so
|
|
313
|
+
* the sheet display is UX; the estimation is the priced truth.
|
|
314
|
+
*/
|
|
315
|
+
export interface PciWalletQuote {
|
|
316
|
+
estimationId: string;
|
|
317
|
+
/** The fiat leg the sheet charges (estimate `source_amount`/`_currency`). */
|
|
318
|
+
sourceAmount: PciWalletMoney;
|
|
319
|
+
/** "You receive" row — the on-chain leg (`currency` = token symbol). */
|
|
320
|
+
destinationAmount?: PciWalletMoney;
|
|
321
|
+
fee?: PciWalletMoney;
|
|
322
|
+
/** Display-only rate line. */
|
|
323
|
+
rate?: string;
|
|
324
|
+
/** Estimate `expires_at` converted to epoch MILLISECONDS. Drives the
|
|
325
|
+
* countdown + button disable; the server check on execute is the guarantee. */
|
|
326
|
+
expiresAtMs?: number;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Wallet checkout frame init. The host passes the quote (from its estimate
|
|
330
|
+
* call) and the provider's wallet config (from the app config, keyed by the
|
|
331
|
+
* estimate's `provider`) — the frame makes no backend calls of its own except
|
|
332
|
+
* Apple merchant validation. Everything rides postMessage; nothing sensitive
|
|
333
|
+
* is in the frame URL.
|
|
334
|
+
*/
|
|
250
335
|
/**
|
|
251
|
-
* Wallet checkout
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* backend itself. No amounts, no API URLs, nothing in the frame URL.
|
|
336
|
+
* Wallet checkout branding — the partner-controllable chrome around the
|
|
337
|
+
* review card. Same trust model as `PciAppearanceVariables`: fixed slots the
|
|
338
|
+
* host picks among, never injected markup; all text lands via `textContent`.
|
|
255
339
|
*/
|
|
340
|
+
export interface PciWalletBrandingConfig {
|
|
341
|
+
/** The logo above "Total to pay": `wirex` (bundled mark, default),
|
|
342
|
+
* `hidden`, or `custom` with `logoImage`. */
|
|
343
|
+
logo?: 'wirex' | 'hidden' | 'custom';
|
|
344
|
+
/** Custom logo for `logo: 'custom'` — a `data:image/...` URI ONLY (the
|
|
345
|
+
* frame's CSP is `img-src 'self' data:`, a remote URL would never load).
|
|
346
|
+
* Rendered in a 64×64 rounded slot. */
|
|
347
|
+
logoImage?: string;
|
|
348
|
+
/** Renders "Wirex processes this payment on behalf of {partnerName}" under
|
|
349
|
+
* the summary card (template overridable via the `walletDisclosureText`
|
|
350
|
+
* string). Omit to hide the line entirely. */
|
|
351
|
+
processingDisclosure?: {
|
|
352
|
+
partnerName: string;
|
|
353
|
+
};
|
|
354
|
+
}
|
|
256
355
|
export interface PciWalletCheckoutInitConfig {
|
|
257
356
|
mode: 'wallet-checkout';
|
|
258
|
-
|
|
259
|
-
|
|
357
|
+
quote: PciWalletQuote;
|
|
358
|
+
config: PciWalletProviderConfig;
|
|
260
359
|
appearance?: PciAppearance;
|
|
261
360
|
buttons?: PciWalletButtonAppearance;
|
|
361
|
+
branding?: PciWalletBrandingConfig;
|
|
262
362
|
strings?: PciFrameStrings;
|
|
363
|
+
/** DEV ONLY: arm the frame's `wallet-debug` channel — in-frame JS errors,
|
|
364
|
+
* unhandled rejections and console output stream to the host as
|
|
365
|
+
* `wallet-debug` events (native WebViews have no reachable console).
|
|
366
|
+
* Wallet frames only — the PCI collect/reveal frames never forward
|
|
367
|
+
* console output (cardholder data risk). Never enable in production. */
|
|
368
|
+
debug?: boolean;
|
|
263
369
|
}
|
|
264
|
-
|
|
265
|
-
* (e.g. after the previous estimation expired). */
|
|
266
|
-
export interface PciWalletSessionRef {
|
|
267
|
-
estimationId: string;
|
|
268
|
-
checkoutToken: string;
|
|
269
|
-
}
|
|
270
|
-
export type PciWalletCheckoutState = 'loading' | 'ready' | 'sheet-open' | 'executing';
|
|
370
|
+
export type PciWalletCheckoutState = 'loading' | 'ready' | 'sheet-open';
|
|
271
371
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
372
|
+
* One authorized payment sheet's output. `walletPaymentToken` is the encrypted
|
|
373
|
+
* payload straight off the sheet, serialized for the wire — relay it VERBATIM
|
|
374
|
+
* as the execute call's `wallet_payment_token` (never parse, reshape or log
|
|
375
|
+
* it; max 16384 chars server-side). The rest is non-sensitive display
|
|
376
|
+
* metadata. The sheet has already closed successfully when this arrives —
|
|
377
|
+
* sheet success means "tokenized", not "money moved"; the execute response
|
|
378
|
+
* and the status feed own the top-up outcome, and `three_ds_state` is never
|
|
379
|
+
* present on a wallet top-up.
|
|
276
380
|
*/
|
|
277
|
-
export
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
url: string;
|
|
285
|
-
};
|
|
381
|
+
export interface PciWalletPaymentTokenDto {
|
|
382
|
+
method: 'apple_pay' | 'google_pay';
|
|
383
|
+
walletPaymentToken: string;
|
|
384
|
+
cardNetwork?: string;
|
|
385
|
+
panLast4?: string;
|
|
386
|
+
displayName?: string;
|
|
387
|
+
}
|
|
286
388
|
export type PciInitConfig = PciCollectInitConfig | PciCollectFieldInitConfig | PciRevealInitConfig | PciWalletProbeInitConfig | PciWalletCheckoutInitConfig;
|
|
287
389
|
/** Extra non-sensitive data merged into the tokenize call by the frame. */
|
|
288
390
|
export interface PciTokenizeTopUpRequest {
|
|
@@ -346,12 +448,14 @@ export type PciHostToFrameMessage = Envelope & ({
|
|
|
346
448
|
requestId: string;
|
|
347
449
|
payload: PciTokenizeRequest;
|
|
348
450
|
}
|
|
349
|
-
/** Re-arm a mounted wallet checkout frame with a fresh
|
|
350
|
-
*
|
|
451
|
+
/** Re-arm a mounted wallet checkout frame with a fresh quote (typically
|
|
452
|
+
* after expiry) — re-renders in place, no remount. `config` rides along
|
|
453
|
+
* because the fresh estimate's `provider` may differ from the last one. */
|
|
351
454
|
| {
|
|
352
455
|
type: 'wallet-update';
|
|
353
456
|
requestId: string;
|
|
354
|
-
|
|
457
|
+
quote: PciWalletQuote;
|
|
458
|
+
config: PciWalletProviderConfig;
|
|
355
459
|
});
|
|
356
460
|
export type PciFrameToHostMessage = Envelope & ({
|
|
357
461
|
type: 'ready';
|
|
@@ -373,27 +477,39 @@ export type PciFrameToHostMessage = Envelope & ({
|
|
|
373
477
|
type: 'reveal-copied';
|
|
374
478
|
field: PciRevealField;
|
|
375
479
|
}
|
|
376
|
-
/** Wallet checkout lifecycle. `sheet-open` = the OS wallet sheet is up
|
|
377
|
-
* `executing` = token obtained, execute call in flight (the host arms its
|
|
378
|
-
* watchdog on this). */
|
|
480
|
+
/** Wallet checkout lifecycle. `sheet-open` = the OS wallet sheet is up. */
|
|
379
481
|
| {
|
|
380
482
|
type: 'wallet-state';
|
|
381
483
|
state: PciWalletCheckoutState;
|
|
382
484
|
}
|
|
383
|
-
/**
|
|
485
|
+
/** DEV ONLY diagnostics (armed by the init `debug` flag): in-frame JS
|
|
486
|
+
* errors and console output, truncated. Wallet frames only. */
|
|
487
|
+
| {
|
|
488
|
+
type: 'wallet-debug';
|
|
489
|
+
level: 'log' | 'warn' | 'error';
|
|
490
|
+
message: string;
|
|
491
|
+
}
|
|
492
|
+
/** The user dismissed the wallet sheet — nothing was tokenized. */
|
|
384
493
|
| {
|
|
385
494
|
type: 'wallet-cancelled';
|
|
386
495
|
}
|
|
387
|
-
/** The
|
|
388
|
-
*
|
|
496
|
+
/** The sheet opened but no token came out (session/tokenization failure).
|
|
497
|
+
* `reason` is a stable slug, e.g. `merchant_validation_failed`. */
|
|
498
|
+
| {
|
|
499
|
+
type: 'wallet-attempt-failed';
|
|
500
|
+
reason: string;
|
|
501
|
+
}
|
|
502
|
+
/** The quote reached `expiresAtMs`; buttons are disabled until the host
|
|
503
|
+
* re-estimates and re-arms via `wallet-update`. */
|
|
389
504
|
| {
|
|
390
505
|
type: 'wallet-estimation-expired';
|
|
391
506
|
}
|
|
392
|
-
/**
|
|
393
|
-
* an event rather than a
|
|
507
|
+
/** The sheet authorized — the encrypted token is handed to the host, which
|
|
508
|
+
* calls execute (user-gesture-driven, so an event rather than a
|
|
509
|
+
* request/response pair). */
|
|
394
510
|
| {
|
|
395
|
-
type: 'wallet-
|
|
396
|
-
|
|
511
|
+
type: 'wallet-token';
|
|
512
|
+
token: PciWalletPaymentTokenDto;
|
|
397
513
|
} | {
|
|
398
514
|
type: 'result';
|
|
399
515
|
requestId: string;
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;8DAE8D;AAC9D,eAAO,MAAM,oBAAoB,EAAE,MAAwB,CAAC;AAE5D,8DAA8D;AAC9D,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,iBAAiB,CAAC;AAE5D,uEAAuE;AACvE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;AAE7D,2EAA2E;AAC3E,MAAM,WAAW,qBAAqB;IACpC,2CAA2C;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EA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AC;IAAC,KAAK,EAAE,wBAAwB,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CACzE,CAAC"}
|
package/dist/walletElement.d.ts
CHANGED
|
@@ -1,73 +1,67 @@
|
|
|
1
|
-
import type { PciAppearance, PciFrameStrings, PciWalletAvailability, PciWalletButtonAppearance, PciWalletCheckoutState,
|
|
2
|
-
export
|
|
3
|
-
/** From the partner backend's estimate call. */
|
|
4
|
-
estimationId: string;
|
|
5
|
-
/**
|
|
6
|
-
* Called at mount/update time so a refreshed estimation can re-arm the
|
|
7
|
-
* element. The token is the frame flow's only credential (short-lived,
|
|
8
|
-
* estimation-scoped, single successful execute) — it authorizes the frame's
|
|
9
|
-
* backend calls: estimation view, wallet config, validate-merchant, execute.
|
|
10
|
-
*/
|
|
11
|
-
getCheckoutToken: () => Promise<string>;
|
|
12
|
-
}
|
|
13
|
-
export type PciWalletTopUpResult = PciWalletTopUpResultDto;
|
|
1
|
+
import type { PciAppearance, PciFrameStrings, PciWalletAvailability, PciWalletBrandingConfig, PciWalletButtonAppearance, PciWalletCheckoutState, PciWalletPaymentTokenDto, PciWalletProviderConfig, PciWalletQuote } from './protocol.js';
|
|
2
|
+
export type PciWalletPaymentToken = PciWalletPaymentTokenDto;
|
|
14
3
|
export interface PciWalletTopUpElementConfig {
|
|
15
|
-
|
|
4
|
+
/** From your estimate call (a wallet `payment_method`, no card id). */
|
|
5
|
+
quote: PciWalletQuote;
|
|
6
|
+
/** The provider block of the app config's `topup` section, selected by the
|
|
7
|
+
* ESTIMATE's `provider` field — passed to the frame verbatim. */
|
|
8
|
+
walletConfig: PciWalletProviderConfig;
|
|
16
9
|
appearance?: PciAppearance;
|
|
17
10
|
buttons?: PciWalletButtonAppearance;
|
|
11
|
+
/** Logo slot + partner processing disclosure; see PciWalletBrandingConfig. */
|
|
12
|
+
branding?: PciWalletBrandingConfig;
|
|
18
13
|
strings?: PciFrameStrings;
|
|
19
|
-
/**
|
|
14
|
+
/** Review screen rendered, buttons live. */
|
|
20
15
|
onReady?: () => void;
|
|
21
16
|
onStateChange?: (state: PciWalletCheckoutState) => void;
|
|
22
|
-
/** The user dismissed the wallet sheet —
|
|
17
|
+
/** The user dismissed the wallet sheet — nothing was tokenized. */
|
|
23
18
|
onCancel?: () => void;
|
|
24
|
-
/** The
|
|
25
|
-
*
|
|
19
|
+
/** The sheet opened but produced no token (e.g. merchant validation
|
|
20
|
+
* failure). `reason` is a stable slug for messaging/analytics. */
|
|
21
|
+
onAttemptFailed?: (reason: string) => void;
|
|
22
|
+
/** The quote expired in view. Re-estimate through your backend and call
|
|
23
|
+
* `update()` with the fresh quote — no remount needed. */
|
|
26
24
|
onEstimationExpired?: () => void;
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
onResult: (result: PciWalletTopUpResult) => void;
|
|
34
|
-
/**
|
|
35
|
-
* Execute-phase watchdog (ms, default 90_000). If the frame reported
|
|
36
|
-
* `executing` and no result arrived in time (lost message, hung request),
|
|
37
|
-
* `onResult` fires once with `{ kind: 'pending', status: 'watchdog_timeout' }`
|
|
38
|
-
* instead of hanging the user.
|
|
26
|
+
* The payment sheet authorized. Relay `walletPaymentToken` VERBATIM as the
|
|
27
|
+
* execute call's `wallet_payment_token` (never parse, reshape or log it).
|
|
28
|
+
* The sheet has already closed successfully — its success means
|
|
29
|
+
* "tokenized"; the execute response and your status feed own the top-up
|
|
30
|
+
* outcome. `three_ds_state` is never present on a wallet top-up.
|
|
39
31
|
*/
|
|
40
|
-
|
|
32
|
+
onToken: (token: PciWalletPaymentToken) => void;
|
|
33
|
+
/** DEV ONLY: arm the frame's diagnostics channel — in-frame JS errors and
|
|
34
|
+
* console output arrive in `onDebug`. Never enable in production. */
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
onDebug?: (level: 'log' | 'warn' | 'error', message: string) => void;
|
|
41
37
|
}
|
|
42
38
|
/**
|
|
43
39
|
* The wallet checkout element — review screen + wallet buttons in one
|
|
44
|
-
* Wirex-served iframe. `mount()` resolves when the frame has
|
|
45
|
-
*
|
|
46
|
-
*
|
|
40
|
+
* Wirex-served iframe. `mount()` resolves when the frame has rendered the
|
|
41
|
+
* quote; payment attempts are user-gesture-driven inside the frame and
|
|
42
|
+
* surface through the config callbacks.
|
|
47
43
|
*/
|
|
48
44
|
export declare class PciWalletTopUpElement {
|
|
49
45
|
private readonly config;
|
|
50
46
|
private readonly channel;
|
|
51
|
-
|
|
52
|
-
private watchdog;
|
|
53
|
-
/** One terminal outcome per payment attempt; re-armed when a new sheet opens. */
|
|
47
|
+
/** One token per payment attempt; re-armed when a new sheet opens. */
|
|
54
48
|
private attemptSettled;
|
|
55
49
|
constructor(frameUrl: string, config: PciWalletTopUpElementConfig);
|
|
56
50
|
mount(container: HTMLElement): Promise<void>;
|
|
57
|
-
/** Re-arm a mounted element with a fresh
|
|
58
|
-
* `onEstimationExpired`) —
|
|
59
|
-
|
|
51
|
+
/** Re-arm a mounted element with a fresh quote (typically after
|
|
52
|
+
* `onEstimationExpired`) — re-renders in place. Pass `walletConfig` when
|
|
53
|
+
* the fresh estimate's `provider` selects a different config block. */
|
|
54
|
+
update(quote: PciWalletQuote, walletConfig?: PciWalletProviderConfig): Promise<void>;
|
|
60
55
|
destroy(): void;
|
|
61
|
-
private armWatchdog;
|
|
62
|
-
private clearWatchdog;
|
|
63
|
-
private settle;
|
|
64
56
|
}
|
|
65
57
|
/**
|
|
66
58
|
* Phase-A availability probe: mounts a hidden probe frame that runs
|
|
67
59
|
* `ApplePaySession.canMakePayments()` / Google Pay `isReadyToPay()`
|
|
68
60
|
* (cryptogram-only) and reports booleans. No transaction context, no backend
|
|
69
|
-
* calls.
|
|
70
|
-
* `
|
|
61
|
+
* calls. Pass the provider's wallet config when you have it (app config's
|
|
62
|
+
* `topup` block, `default_provider` entry) so the Google check mirrors the
|
|
63
|
+
* real tokenization parameters. Callers cache the result per page session —
|
|
64
|
+
* see `checkWalletAvailability` in `@wirexapp/card-wallet-topup-web`.
|
|
71
65
|
*/
|
|
72
|
-
export declare const probeWalletAvailability: (frameUrl: string) => Promise<PciWalletAvailability>;
|
|
66
|
+
export declare const probeWalletAvailability: (frameUrl: string, config?: PciWalletProviderConfig) => Promise<PciWalletAvailability>;
|
|
73
67
|
//# sourceMappingURL=walletElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletElement.d.ts","sourceRoot":"","sources":["../src/walletElement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"walletElement.d.ts","sourceRoot":"","sources":["../src/walletElement.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE7D,MAAM,WAAW,2BAA2B;IAC1C,uEAAuE;IACvE,KAAK,EAAE,cAAc,CAAC;IACtB;sEACkE;IAClE,YAAY,EAAE,uBAAuB,CAAC;IACtC,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACxD,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;uEACmE;IACnE,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C;+DAC2D;IAC3D,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC;;;;;;OAMG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChD;0EACsE;IACtE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACtE;AAED;;;;;GAKG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,sEAAsE;IACtE,OAAO,CAAC,cAAc,CAAS;gBAEnB,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,2BAA2B;IAgC3D,KAAK,CAAC,SAAS,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBlD;;4EAEwE;IAClE,MAAM,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1F,OAAO,IAAI,IAAI;CAGhB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,MAAM,EAChB,SAAS,uBAAuB,KAC/B,OAAO,CAAC,qBAAqB,CAqB/B,CAAC"}
|
package/dist/walletElement.js
CHANGED
|
@@ -1,49 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Wallet top-up (Apple Pay / Google Pay) host-side machinery: the checkout
|
|
3
3
|
* element that mounts the Wirex-hosted wallet frame, and the availability
|
|
4
|
-
* probe. Design: docs/WALLET-TOPUP-DESIGN.md
|
|
4
|
+
* probe. Design: docs/WALLET-TOPUP-DESIGN.md, on the confirmed backend
|
|
5
|
+
* contract ("Wallet Top-Ups Integration").
|
|
5
6
|
*
|
|
6
7
|
* Unlike collect/reveal this is not CHD isolation — wallet tokens are
|
|
7
|
-
* encrypted, gateway-bound blobs. The frame exists for
|
|
8
|
+
* encrypted, gateway-bound blobs. The frame exists for Apple Pay's origin
|
|
8
9
|
* binding: the wallet JS must run on a Wirex-registered domain, so partners
|
|
9
|
-
* skip Apple onboarding entirely
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* skip Apple onboarding entirely. The frame TOKENIZES AND RETURNS: the sheet's
|
|
11
|
+
* encrypted payload arrives in `onToken`, and the HOST calls the execute
|
|
12
|
+
* endpoint with it (`wallet_payment_token`). There is no 3DS on this path.
|
|
12
13
|
*/
|
|
13
14
|
import { PciFrameChannel } from './frameChannel.js';
|
|
14
|
-
const EXECUTE_WATCHDOG_MS = 90000;
|
|
15
15
|
/**
|
|
16
16
|
* The wallet checkout element — review screen + wallet buttons in one
|
|
17
|
-
* Wirex-served iframe. `mount()` resolves when the frame has
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* Wirex-served iframe. `mount()` resolves when the frame has rendered the
|
|
18
|
+
* quote; payment attempts are user-gesture-driven inside the frame and
|
|
19
|
+
* surface through the config callbacks.
|
|
20
20
|
*/
|
|
21
21
|
export class PciWalletTopUpElement {
|
|
22
22
|
constructor(frameUrl, config) {
|
|
23
|
-
|
|
24
|
-
/** One terminal outcome per payment attempt; re-armed when a new sheet opens. */
|
|
23
|
+
/** One token per payment attempt; re-armed when a new sheet opens. */
|
|
25
24
|
this.attemptSettled = false;
|
|
26
25
|
this.config = config;
|
|
27
|
-
this.session = config.session;
|
|
28
26
|
this.channel = new PciFrameChannel(frameUrl, {}, { allowPayment: true });
|
|
29
27
|
this.channel.onMessage(message => {
|
|
30
28
|
switch (message.type) {
|
|
31
29
|
case 'wallet-state':
|
|
32
30
|
if (message.state === 'sheet-open')
|
|
33
31
|
this.attemptSettled = false;
|
|
34
|
-
if (message.state === 'executing')
|
|
35
|
-
this.armWatchdog();
|
|
36
32
|
this.config.onStateChange?.(message.state);
|
|
37
33
|
break;
|
|
34
|
+
case 'wallet-debug':
|
|
35
|
+
this.config.onDebug?.(message.level, message.message);
|
|
36
|
+
break;
|
|
38
37
|
case 'wallet-cancelled':
|
|
39
|
-
this.clearWatchdog();
|
|
40
38
|
this.config.onCancel?.();
|
|
41
39
|
break;
|
|
40
|
+
case 'wallet-attempt-failed':
|
|
41
|
+
this.config.onAttemptFailed?.(message.reason);
|
|
42
|
+
break;
|
|
42
43
|
case 'wallet-estimation-expired':
|
|
43
44
|
this.config.onEstimationExpired?.();
|
|
44
45
|
break;
|
|
45
|
-
case 'wallet-
|
|
46
|
-
this.
|
|
46
|
+
case 'wallet-token':
|
|
47
|
+
if (this.attemptSettled)
|
|
48
|
+
break;
|
|
49
|
+
this.attemptSettled = true;
|
|
50
|
+
this.config.onToken(message.token);
|
|
47
51
|
break;
|
|
48
52
|
default:
|
|
49
53
|
break;
|
|
@@ -56,59 +60,41 @@ export class PciWalletTopUpElement {
|
|
|
56
60
|
type: 'init',
|
|
57
61
|
config: {
|
|
58
62
|
mode: 'wallet-checkout',
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
quote: this.config.quote,
|
|
64
|
+
config: this.config.walletConfig,
|
|
61
65
|
appearance: this.config.appearance,
|
|
62
66
|
buttons: this.config.buttons,
|
|
67
|
+
branding: this.config.branding,
|
|
63
68
|
strings: this.config.strings,
|
|
69
|
+
debug: this.config.debug,
|
|
64
70
|
},
|
|
65
71
|
});
|
|
66
72
|
this.config.onReady?.();
|
|
67
73
|
}
|
|
68
|
-
/** Re-arm a mounted element with a fresh
|
|
69
|
-
* `onEstimationExpired`) —
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
/** Re-arm a mounted element with a fresh quote (typically after
|
|
75
|
+
* `onEstimationExpired`) — re-renders in place. Pass `walletConfig` when
|
|
76
|
+
* the fresh estimate's `provider` selects a different config block. */
|
|
77
|
+
async update(quote, walletConfig) {
|
|
72
78
|
await this.channel.request({
|
|
73
79
|
type: 'wallet-update',
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
checkoutToken: await session.getCheckoutToken(),
|
|
77
|
-
},
|
|
80
|
+
quote,
|
|
81
|
+
config: walletConfig ?? this.config.walletConfig,
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
destroy() {
|
|
81
|
-
this.clearWatchdog();
|
|
82
85
|
this.channel.destroy();
|
|
83
86
|
}
|
|
84
|
-
armWatchdog() {
|
|
85
|
-
this.clearWatchdog();
|
|
86
|
-
this.watchdog = setTimeout(() => {
|
|
87
|
-
this.settle({ kind: 'pending', topupId: '', status: 'watchdog_timeout' });
|
|
88
|
-
}, this.config.executeTimeoutMs ?? EXECUTE_WATCHDOG_MS);
|
|
89
|
-
}
|
|
90
|
-
clearWatchdog() {
|
|
91
|
-
if (this.watchdog) {
|
|
92
|
-
clearTimeout(this.watchdog);
|
|
93
|
-
this.watchdog = null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
settle(result) {
|
|
97
|
-
if (this.attemptSettled)
|
|
98
|
-
return;
|
|
99
|
-
this.attemptSettled = true;
|
|
100
|
-
this.clearWatchdog();
|
|
101
|
-
this.config.onResult(result);
|
|
102
|
-
}
|
|
103
87
|
}
|
|
104
88
|
/**
|
|
105
89
|
* Phase-A availability probe: mounts a hidden probe frame that runs
|
|
106
90
|
* `ApplePaySession.canMakePayments()` / Google Pay `isReadyToPay()`
|
|
107
91
|
* (cryptogram-only) and reports booleans. No transaction context, no backend
|
|
108
|
-
* calls.
|
|
109
|
-
* `
|
|
92
|
+
* calls. Pass the provider's wallet config when you have it (app config's
|
|
93
|
+
* `topup` block, `default_provider` entry) so the Google check mirrors the
|
|
94
|
+
* real tokenization parameters. Callers cache the result per page session —
|
|
95
|
+
* see `checkWalletAvailability` in `@wirexapp/card-wallet-topup-web`.
|
|
110
96
|
*/
|
|
111
|
-
export const probeWalletAvailability = async (frameUrl) => {
|
|
97
|
+
export const probeWalletAvailability = async (frameUrl, config) => {
|
|
112
98
|
// Zero-sized but not display:none/visibility:hidden — some wallet
|
|
113
99
|
// availability checks report unavailable inside hidden documents.
|
|
114
100
|
const container = document.createElement('div');
|
|
@@ -122,7 +108,7 @@ export const probeWalletAvailability = async (frameUrl) => {
|
|
|
122
108
|
await channel.mount(container);
|
|
123
109
|
return await channel.request({
|
|
124
110
|
type: 'init',
|
|
125
|
-
config: { mode: 'wallet-probe' },
|
|
111
|
+
config: { mode: 'wallet-probe', config },
|
|
126
112
|
});
|
|
127
113
|
}
|
|
128
114
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletElement.js","sourceRoot":"","sources":["../src/walletElement.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"walletElement.js","sourceRoot":"","sources":["../src/walletElement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAmDjD;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAMhC,YAAY,QAAgB,EAAE,MAAmC;QAHjE,sEAAsE;QAC9D,mBAAc,GAAG,KAAK,CAAC;QAG7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;YAC/B,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;gBACrB,KAAK,cAAc;oBACjB,IAAI,OAAO,CAAC,KAAK,KAAK,YAAY;wBAAE,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;oB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D,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE;SACzC,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,SAAS,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PciWalletTopUpElementConfig } from './walletElement.js';
|
|
2
|
+
export interface PciWalletTopUpPopupConfig extends Omit<PciWalletTopUpElementConfig, 'quote' | 'walletConfig'> {
|
|
3
|
+
/** The quote may be OMITTED at open time: `window.open` must run
|
|
4
|
+
* synchronously inside the click handler, while the estimate is usually
|
|
5
|
+
* still in flight — open first, then call `arm(quote, walletConfig)` when
|
|
6
|
+
* the estimate lands. Providing both here arms immediately. */
|
|
7
|
+
quote?: PciWalletTopUpElementConfig['quote'];
|
|
8
|
+
walletConfig?: PciWalletTopUpElementConfig['walletConfig'];
|
|
9
|
+
/** The popup was closed (by the user or programmatically) without a token.
|
|
10
|
+
* Not fired after `onToken` — a token hand-off closes the popup too. */
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
/** The popup failed to boot: blocked by the browser (call `open` from a
|
|
13
|
+
* click handler), or the frame never became ready. */
|
|
14
|
+
onMountError?: (error: Error) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface PciWalletTopUpPopup {
|
|
17
|
+
/** Deliver the quote when it wasn't available at open time (the estimate
|
|
18
|
+
* resolved after the click). First call initializes the checkout; later
|
|
19
|
+
* calls behave like `update`. No-op after the popup closed. */
|
|
20
|
+
arm(quote: PciWalletTopUpElementConfig['quote'], walletConfig: PciWalletTopUpElementConfig['walletConfig']): void;
|
|
21
|
+
/** Re-arm with a fresh quote (after `onEstimationExpired`) — re-renders in
|
|
22
|
+
* place, the popup stays open. */
|
|
23
|
+
update(quote: PciWalletTopUpElementConfig['quote'], walletConfig?: PciWalletTopUpElementConfig['walletConfig']): Promise<void>;
|
|
24
|
+
/** Close the popup. Fires `onClose` if nothing was tokenized yet. */
|
|
25
|
+
close(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Opens the wallet checkout in a popup. MUST be called synchronously from a
|
|
29
|
+
* user gesture (click handler) or browsers will block the window.
|
|
30
|
+
*/
|
|
31
|
+
export declare const openWalletTopUpPopup: (frameUrl: string, config: PciWalletTopUpPopupConfig) => PciWalletTopUpPopup;
|
|
32
|
+
//# sourceMappingURL=walletPopup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletPopup.d.ts","sourceRoot":"","sources":["../src/walletPopup.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAgBnE,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CAAC,2BAA2B,EAAE,OAAO,GAAG,cAAc,CAAC;IAC5G;;;oEAGgE;IAChE,KAAK,CAAC,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAC7C,YAAY,CAAC,EAAE,2BAA2B,CAAC,cAAc,CAAC,CAAC;IAC3D;6EACyE;IACzE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;2DACuD;IACvD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,mBAAmB;IAClC;;oEAEgE;IAChE,GAAG,CAAC,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,2BAA2B,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IAClH;uCACmC;IACnC,MAAM,CAAC,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,EAAE,2BAA2B,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/H,qEAAqE;IACrE,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,MAAM,EAChB,QAAQ,yBAAyB,KAChC,mBA8KF,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet checkout POPUP (Mode B): the same wallet-checkout document, opened
|
|
3
|
+
* TOP-LEVEL on the frames domain via `window.open`, driven over
|
|
4
|
+
* `window.opener` postMessage with the same channel + origin checks as the
|
|
5
|
+
* iframe transport (`openerTransport` in the frame's bridge).
|
|
6
|
+
*
|
|
7
|
+
* Why this mode exists: Apple binds merchant sessions to the TOP-LEVEL
|
|
8
|
+
* page's domain. Embedded as an iframe, that is the PARTNER's domain — which
|
|
9
|
+
* must be registered + verified under Wirex's Apple merchant ID and host the
|
|
10
|
+
* domain-association file. In a popup the top-level domain is the frames
|
|
11
|
+
* origin itself, which is already verified — partners need NO Apple steps at
|
|
12
|
+
* all. The trade-off is the user briefly leaving the host page.
|
|
13
|
+
*
|
|
14
|
+
* The tokenize-and-return contract is unchanged: the sheet's encrypted
|
|
15
|
+
* payload arrives in `onToken` and the HOST calls execute; the popup closes
|
|
16
|
+
* itself once the token is handed off.
|
|
17
|
+
*/
|
|
18
|
+
import { PCI_PROTOCOL_VERSION } from './protocol.js';
|
|
19
|
+
const READY_TIMEOUT_MS = 15000;
|
|
20
|
+
const REQUEST_TIMEOUT_MS = 30000;
|
|
21
|
+
const CLOSE_POLL_MS = 400;
|
|
22
|
+
/** ~mobile-sheet proportions, centered by the browser. */
|
|
23
|
+
const POPUP_FEATURES = 'popup=yes,width=430,height=780,resizable=yes,scrollbars=yes';
|
|
24
|
+
/** The checkout renders on a transparent surface for iframes; a top-level
|
|
25
|
+
* popup needs an opaque ground. Overridable via appearance.surfaceColor. */
|
|
26
|
+
const POPUP_DEFAULT_SURFACE = '#141414';
|
|
27
|
+
const randomId = () => typeof crypto !== 'undefined' && 'randomUUID' in crypto
|
|
28
|
+
? crypto.randomUUID()
|
|
29
|
+
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
30
|
+
/**
|
|
31
|
+
* Opens the wallet checkout in a popup. MUST be called synchronously from a
|
|
32
|
+
* user gesture (click handler) or browsers will block the window.
|
|
33
|
+
*/
|
|
34
|
+
export const openWalletTopUpPopup = (frameUrl, config) => {
|
|
35
|
+
const frameOrigin = new URL(frameUrl, window.location.href).origin;
|
|
36
|
+
const channelId = randomId();
|
|
37
|
+
const url = `${frameUrl}#channel=${channelId}&parent=${encodeURIComponent(window.location.origin)}`;
|
|
38
|
+
const popup = window.open(url, '_blank', POPUP_FEATURES);
|
|
39
|
+
const pending = new Map();
|
|
40
|
+
let settled = false; // a token was handed off
|
|
41
|
+
let closed = false;
|
|
42
|
+
let closePoll = null;
|
|
43
|
+
let readyTimer = null;
|
|
44
|
+
/** One payment attempt per sheet opening (mirrors the element). */
|
|
45
|
+
let attemptSettled = false;
|
|
46
|
+
// Deferred-arm state: the frame may report ready before the host has a
|
|
47
|
+
// quote (estimate in flight), or the quote may arrive first — init is sent
|
|
48
|
+
// once BOTH are true.
|
|
49
|
+
let frameReady = false;
|
|
50
|
+
let initialized = false;
|
|
51
|
+
let armedQuote = config.quote ?? null;
|
|
52
|
+
let armedWalletConfig = config.walletConfig ?? null;
|
|
53
|
+
const cleanup = () => {
|
|
54
|
+
if (closed)
|
|
55
|
+
return;
|
|
56
|
+
closed = true;
|
|
57
|
+
if (closePoll)
|
|
58
|
+
clearInterval(closePoll);
|
|
59
|
+
if (readyTimer)
|
|
60
|
+
clearTimeout(readyTimer);
|
|
61
|
+
window.removeEventListener('message', onWindowMessage);
|
|
62
|
+
for (const [, entry] of pending) {
|
|
63
|
+
clearTimeout(entry.timer);
|
|
64
|
+
entry.reject(new Error('Wallet popup closed'));
|
|
65
|
+
}
|
|
66
|
+
pending.clear();
|
|
67
|
+
};
|
|
68
|
+
const closePopup = () => {
|
|
69
|
+
const wasSettled = settled;
|
|
70
|
+
cleanup();
|
|
71
|
+
if (popup && !popup.closed)
|
|
72
|
+
popup.close();
|
|
73
|
+
if (!wasSettled)
|
|
74
|
+
config.onClose?.();
|
|
75
|
+
};
|
|
76
|
+
const request = (message) => {
|
|
77
|
+
if (!popup || popup.closed || closed)
|
|
78
|
+
return Promise.reject(new Error('Wallet popup is not open'));
|
|
79
|
+
const requestId = randomId();
|
|
80
|
+
const promise = new Promise((resolve, reject) => {
|
|
81
|
+
const timer = setTimeout(() => {
|
|
82
|
+
pending.delete(requestId);
|
|
83
|
+
reject(new Error('Wallet popup request timed out'));
|
|
84
|
+
}, REQUEST_TIMEOUT_MS);
|
|
85
|
+
pending.set(requestId, { resolve: resolve, reject, timer });
|
|
86
|
+
});
|
|
87
|
+
popup.postMessage({ ...message, requestId, v: PCI_PROTOCOL_VERSION, channel: channelId }, frameOrigin);
|
|
88
|
+
return promise;
|
|
89
|
+
};
|
|
90
|
+
const sendInit = () => {
|
|
91
|
+
if (initialized || !frameReady || !armedQuote || !armedWalletConfig)
|
|
92
|
+
return;
|
|
93
|
+
initialized = true;
|
|
94
|
+
request({
|
|
95
|
+
type: 'init',
|
|
96
|
+
config: {
|
|
97
|
+
mode: 'wallet-checkout',
|
|
98
|
+
quote: armedQuote,
|
|
99
|
+
config: armedWalletConfig,
|
|
100
|
+
appearance: {
|
|
101
|
+
...config.appearance,
|
|
102
|
+
variables: { surfaceColor: POPUP_DEFAULT_SURFACE, ...config.appearance?.variables },
|
|
103
|
+
},
|
|
104
|
+
buttons: config.buttons,
|
|
105
|
+
branding: config.branding,
|
|
106
|
+
strings: config.strings,
|
|
107
|
+
debug: config.debug,
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
.then(() => config.onReady?.())
|
|
111
|
+
.catch((error) => config.onMountError?.(error));
|
|
112
|
+
};
|
|
113
|
+
const onWindowMessage = (event) => {
|
|
114
|
+
// Provenance: our popup window + the frames origin + our channel id.
|
|
115
|
+
if (!popup || event.source !== popup)
|
|
116
|
+
return;
|
|
117
|
+
if (event.origin !== frameOrigin)
|
|
118
|
+
return;
|
|
119
|
+
const message = event.data;
|
|
120
|
+
if (!message || message.v !== PCI_PROTOCOL_VERSION || message.channel !== channelId)
|
|
121
|
+
return;
|
|
122
|
+
switch (message.type) {
|
|
123
|
+
case 'ready':
|
|
124
|
+
if (readyTimer)
|
|
125
|
+
clearTimeout(readyTimer);
|
|
126
|
+
readyTimer = null;
|
|
127
|
+
frameReady = true;
|
|
128
|
+
sendInit();
|
|
129
|
+
break;
|
|
130
|
+
case 'result': {
|
|
131
|
+
const entry = pending.get(message.requestId);
|
|
132
|
+
if (!entry)
|
|
133
|
+
break;
|
|
134
|
+
pending.delete(message.requestId);
|
|
135
|
+
clearTimeout(entry.timer);
|
|
136
|
+
if (message.ok)
|
|
137
|
+
entry.resolve(message.data);
|
|
138
|
+
else
|
|
139
|
+
entry.reject(new Error(message.error?.message ?? 'Wallet popup request failed'));
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case 'wallet-state':
|
|
143
|
+
if (message.state === 'sheet-open')
|
|
144
|
+
attemptSettled = false;
|
|
145
|
+
config.onStateChange?.(message.state);
|
|
146
|
+
break;
|
|
147
|
+
case 'wallet-debug':
|
|
148
|
+
config.onDebug?.(message.level, message.message);
|
|
149
|
+
break;
|
|
150
|
+
case 'wallet-cancelled':
|
|
151
|
+
config.onCancel?.();
|
|
152
|
+
break;
|
|
153
|
+
case 'wallet-attempt-failed':
|
|
154
|
+
config.onAttemptFailed?.(message.reason);
|
|
155
|
+
break;
|
|
156
|
+
case 'wallet-estimation-expired':
|
|
157
|
+
config.onEstimationExpired?.();
|
|
158
|
+
break;
|
|
159
|
+
case 'wallet-token':
|
|
160
|
+
if (attemptSettled)
|
|
161
|
+
break;
|
|
162
|
+
attemptSettled = true;
|
|
163
|
+
settled = true;
|
|
164
|
+
// Hand the token to the host FIRST, then close — the host executes.
|
|
165
|
+
config.onToken(message.token);
|
|
166
|
+
closePopup();
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
if (!popup) {
|
|
173
|
+
// Blocked: window.open returned null (not called from a user gesture, or
|
|
174
|
+
// a popup blocker). Report async so the caller's flow stays uniform.
|
|
175
|
+
setTimeout(() => config.onMountError?.(new Error('Wallet popup was blocked — open it from a click handler')), 0);
|
|
176
|
+
return {
|
|
177
|
+
arm: () => { },
|
|
178
|
+
update: () => Promise.reject(new Error('Wallet popup was blocked')),
|
|
179
|
+
close: () => { },
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
window.addEventListener('message', onWindowMessage);
|
|
183
|
+
readyTimer = setTimeout(() => {
|
|
184
|
+
config.onMountError?.(new Error('Wallet popup did not become ready in time'));
|
|
185
|
+
closePopup();
|
|
186
|
+
}, READY_TIMEOUT_MS);
|
|
187
|
+
closePoll = setInterval(() => {
|
|
188
|
+
if (popup.closed)
|
|
189
|
+
closePopup();
|
|
190
|
+
}, CLOSE_POLL_MS);
|
|
191
|
+
return {
|
|
192
|
+
arm: (quote, walletConfig) => {
|
|
193
|
+
if (closed)
|
|
194
|
+
return;
|
|
195
|
+
if (initialized) {
|
|
196
|
+
// Already armed once — behave like update (fresh estimate).
|
|
197
|
+
armedQuote = quote;
|
|
198
|
+
armedWalletConfig = walletConfig;
|
|
199
|
+
void request({ type: 'wallet-update', quote, config: walletConfig }).catch(() => undefined);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
armedQuote = quote;
|
|
203
|
+
armedWalletConfig = walletConfig;
|
|
204
|
+
sendInit();
|
|
205
|
+
},
|
|
206
|
+
update: (quote, walletConfig) => request({ type: 'wallet-update', quote, config: walletConfig ?? armedWalletConfig ?? undefined }).then(() => undefined),
|
|
207
|
+
close: closePopup,
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=walletPopup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletPopup.js","sourceRoot":"","sources":["../src/walletPopup.ts"],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C1B,KAAK,EAAE,UAAU;KAClB,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirexapp/card-sdk-core",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared foundation of the Wirex PCI card SDK: postMessage protocol, frame channel, frame-URL building, collect machinery. CHD-free.",
|
|
6
6
|
"license": "UNLICENSED",
|