@wirexapp/card-sdk-core 1.1.0-beta.3 → 1.1.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 +260 -0
- package/dist/collectElement.d.ts +48 -2
- package/dist/collectElement.d.ts.map +1 -1
- package/dist/collectElement.js +20 -0
- package/dist/collectElement.js.map +1 -1
- package/dist/collectGroup.d.ts +24 -4
- package/dist/collectGroup.d.ts.map +1 -1
- package/dist/collectGroup.js +43 -2
- package/dist/collectGroup.js.map +1 -1
- package/dist/collectMask.d.ts +24 -0
- package/dist/collectMask.d.ts.map +1 -0
- package/dist/collectMask.js +42 -0
- package/dist/collectMask.js.map +1 -0
- package/dist/frameChannel.d.ts +17 -1
- package/dist/frameChannel.d.ts.map +1 -1
- package/dist/frameChannel.js +40 -4
- package/dist/frameChannel.js.map +1 -1
- package/dist/frameUrl.d.ts +4 -2
- package/dist/frameUrl.d.ts.map +1 -1
- package/dist/frameUrl.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +403 -19
- package/dist/protocol.d.ts.map +1 -1
- package/dist/walletLaunch.d.ts +44 -0
- package/dist/walletLaunch.d.ts.map +1 -0
- package/dist/walletLaunch.js +45 -0
- package/dist/walletLaunch.js.map +1 -0
- package/dist/walletReturnUrl.d.ts +30 -0
- package/dist/walletReturnUrl.d.ts.map +1 -0
- package/dist/walletReturnUrl.js +63 -0
- package/dist/walletReturnUrl.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletLaunch.d.ts","sourceRoot":"","sources":["../src/walletLaunch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,cAAc,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB;;8DAE0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,kEAAkE;AAClE,eAAO,MAAM,sBAAsB;;;;;;;;;CASzB,CAAC;AAIX;;;;qDAIqD;AACrD,eAAO,MAAM,yBAAyB,GAAI,QAAQ,qBAAqB,KAAG,MAiBzE,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,oBAAoB,GAAI,aAAa,MAAM,EAAE,QAAQ,qBAAqB,EAAE,SAAS,MAAM,KAAG,MAI1G,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { resolveWalletReturnUrl } from './walletReturnUrl.js';
|
|
2
|
+
/** Fragment keys (single letters: the fragment is QR payload). */
|
|
3
|
+
export const PCI_WALLET_LAUNCH_KEYS = {
|
|
4
|
+
token: 't',
|
|
5
|
+
estimationId: 'e',
|
|
6
|
+
sourceAmount: 's',
|
|
7
|
+
destinationAmount: 'd',
|
|
8
|
+
fee: 'f',
|
|
9
|
+
expiresAt: 'x',
|
|
10
|
+
provider: 'p',
|
|
11
|
+
returnUrl: 'r',
|
|
12
|
+
};
|
|
13
|
+
const money = (value) => `${value.amount}:${value.currency}`;
|
|
14
|
+
/** `t=<token>&e=<estimationId>&s=<amount>:<CUR>[&d=…][&f=…][&x=<unix seconds>]&p=<provider>[&r=<return link>]`
|
|
15
|
+
* (no leading `#`). Throws a `TypeError` for a `returnUrl` the frame would
|
|
16
|
+
* refuse (the frame ignores such a link silently — fail here, at build
|
|
17
|
+
* time, instead). The raw value is encoded, never a normalised form, so the
|
|
18
|
+
* fragment stays byte-identical across the SDKs. */
|
|
19
|
+
export const buildWalletLaunchFragment = (params) => {
|
|
20
|
+
if (params.returnUrl !== undefined && !resolveWalletReturnUrl(params.returnUrl)) {
|
|
21
|
+
throw new TypeError("returnUrl must be an https App Link or your app's own scheme — javascript:, data:, blob:, file:, about: and http: are refused");
|
|
22
|
+
}
|
|
23
|
+
const keys = PCI_WALLET_LAUNCH_KEYS;
|
|
24
|
+
const query = new URLSearchParams();
|
|
25
|
+
query.set(keys.token, params.checkoutToken);
|
|
26
|
+
query.set(keys.estimationId, params.quote.estimationId);
|
|
27
|
+
query.set(keys.sourceAmount, money(params.quote.sourceAmount));
|
|
28
|
+
if (params.quote.destinationAmount)
|
|
29
|
+
query.set(keys.destinationAmount, money(params.quote.destinationAmount));
|
|
30
|
+
if (params.quote.fee)
|
|
31
|
+
query.set(keys.fee, money(params.quote.fee));
|
|
32
|
+
if (params.quote.expiresAtMs)
|
|
33
|
+
query.set(keys.expiresAt, String(Math.floor(params.quote.expiresAtMs / 1000)));
|
|
34
|
+
query.set(keys.provider, params.provider);
|
|
35
|
+
if (params.returnUrl)
|
|
36
|
+
query.set(keys.returnUrl, params.returnUrl);
|
|
37
|
+
return query.toString();
|
|
38
|
+
};
|
|
39
|
+
/** The full URL to open top-level (Custom Tab) or to encode in a QR. */
|
|
40
|
+
export const buildWalletLaunchUrl = (frameOrigin, params, client) => {
|
|
41
|
+
const base = `${frameOrigin.replace(/\/+$/, '')}/wallet-checkout.html`;
|
|
42
|
+
const query = client ? `?client=${encodeURIComponent(client)}` : '';
|
|
43
|
+
return `${base}${query}#${buildWalletLaunchFragment(params)}`;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=walletLaunch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletLaunch.js","sourceRoot":"","sources":["../src/walletLaunch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AA0B3D,kEAAkE;AAClE,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,KAAK,EAAE,GAAG;IACV,YAAY,EAAE,GAAG;IACjB,YAAY,EAAE,GAAG;IACjB,iBAAiB,EAAE,GAAG;IACtB,GAAG,EAAE,GAAG;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AC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7G,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,MAAM,CAAC,SAAS;QAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,WAAmB,EAAE,MAA6B,EAAE,MAAe,EAAU,EAAE;IAClH,MAAM,IAAI,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC;IACvE,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACpE,OAAO,GAAG,IAAI,GAAG,KAAK,IAAI,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAC;AAChE,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return-link policy for STANDALONE launches (the result screen's "Return to
|
|
3
|
+
* the app" — `returnUrl` in the init, `r` in the launch fragment).
|
|
4
|
+
*
|
|
5
|
+
* Any scheme an app can register is accepted: `https:` (an Android App Link /
|
|
6
|
+
* iOS Universal Link — the OS verifies it for the partner's package, the
|
|
7
|
+
* preferred form) or the app's own scheme (`com.partner.app:/wallet/return` —
|
|
8
|
+
* works on both platforms without a domain; any installed app may claim it,
|
|
9
|
+
* which the partner accepts). Refused are only the schemes that differ IN
|
|
10
|
+
* KIND from "open the partner's app": the ones a browser executes as content
|
|
11
|
+
* in the checkout's own origin (`javascript:`, `data:`, `blob:`, …),
|
|
12
|
+
* browser-internal ones, and cleartext `http:`. Everything else is reachable
|
|
13
|
+
* through an https redirect anyway, so a longer denylist would be theatre.
|
|
14
|
+
*
|
|
15
|
+
* The link carries `estimation_id` and `outcome` only — never the token,
|
|
16
|
+
* never the wallet payload — and is a UX signal: the app reconciles by
|
|
17
|
+
* estimation status. Mirrored byte-for-byte in
|
|
18
|
+
* `sdk-service/frames-src/src/returnLink.ts` (the frames bundle must not
|
|
19
|
+
* pull the host SDK in) — change both.
|
|
20
|
+
*/
|
|
21
|
+
export declare const PCI_WALLET_RETURN_URL_BLOCKED_SCHEMES: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* The normalised href when `candidate` is an acceptable return link, else
|
|
24
|
+
* `null`. Parsed with the WHATWG URL parser BEFORE the scheme check, so case
|
|
25
|
+
* tricks and embedded tabs / newlines in the scheme (`JavaScript:`,
|
|
26
|
+
* `java\tscript:`) are normalised away rather than slipping past a string
|
|
27
|
+
* compare.
|
|
28
|
+
*/
|
|
29
|
+
export declare const resolveWalletReturnUrl: (candidate: unknown) => string | null;
|
|
30
|
+
//# sourceMappingURL=walletReturnUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletReturnUrl.d.ts","sourceRoot":"","sources":["../src/walletReturnUrl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qCAAqC,EAAE,SAAS,MAAM,EAkBlE,CAAC;AAQF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,WAAW,OAAO,KAAG,MAAM,GAAG,IASpE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return-link policy for STANDALONE launches (the result screen's "Return to
|
|
3
|
+
* the app" — `returnUrl` in the init, `r` in the launch fragment).
|
|
4
|
+
*
|
|
5
|
+
* Any scheme an app can register is accepted: `https:` (an Android App Link /
|
|
6
|
+
* iOS Universal Link — the OS verifies it for the partner's package, the
|
|
7
|
+
* preferred form) or the app's own scheme (`com.partner.app:/wallet/return` —
|
|
8
|
+
* works on both platforms without a domain; any installed app may claim it,
|
|
9
|
+
* which the partner accepts). Refused are only the schemes that differ IN
|
|
10
|
+
* KIND from "open the partner's app": the ones a browser executes as content
|
|
11
|
+
* in the checkout's own origin (`javascript:`, `data:`, `blob:`, …),
|
|
12
|
+
* browser-internal ones, and cleartext `http:`. Everything else is reachable
|
|
13
|
+
* through an https redirect anyway, so a longer denylist would be theatre.
|
|
14
|
+
*
|
|
15
|
+
* The link carries `estimation_id` and `outcome` only — never the token,
|
|
16
|
+
* never the wallet payload — and is a UX signal: the app reconciles by
|
|
17
|
+
* estimation status. Mirrored byte-for-byte in
|
|
18
|
+
* `sdk-service/frames-src/src/returnLink.ts` (the frames bundle must not
|
|
19
|
+
* pull the host SDK in) — change both.
|
|
20
|
+
*/
|
|
21
|
+
export const PCI_WALLET_RETURN_URL_BLOCKED_SCHEMES = [
|
|
22
|
+
// executed as content in this origin
|
|
23
|
+
'javascript:',
|
|
24
|
+
'vbscript:',
|
|
25
|
+
'data:',
|
|
26
|
+
'blob:',
|
|
27
|
+
'filesystem:',
|
|
28
|
+
// browser-internal
|
|
29
|
+
'file:',
|
|
30
|
+
'about:',
|
|
31
|
+
'chrome:',
|
|
32
|
+
'chrome-extension:',
|
|
33
|
+
'edge:',
|
|
34
|
+
'moz-extension:',
|
|
35
|
+
'safari-web-extension:',
|
|
36
|
+
'view-source:',
|
|
37
|
+
// cleartext — https is the only web scheme
|
|
38
|
+
'http:',
|
|
39
|
+
];
|
|
40
|
+
const BLOCKED = new Set(PCI_WALLET_RETURN_URL_BLOCKED_SCHEMES);
|
|
41
|
+
/** Longest return link accepted — the launch URL is a QR payload / a Custom
|
|
42
|
+
* Tab URL, and a partner's return link is a short route. */
|
|
43
|
+
const MAX_RETURN_URL_CHARS = 2048;
|
|
44
|
+
/**
|
|
45
|
+
* The normalised href when `candidate` is an acceptable return link, else
|
|
46
|
+
* `null`. Parsed with the WHATWG URL parser BEFORE the scheme check, so case
|
|
47
|
+
* tricks and embedded tabs / newlines in the scheme (`JavaScript:`,
|
|
48
|
+
* `java\tscript:`) are normalised away rather than slipping past a string
|
|
49
|
+
* compare.
|
|
50
|
+
*/
|
|
51
|
+
export const resolveWalletReturnUrl = (candidate) => {
|
|
52
|
+
if (typeof candidate !== 'string' || !candidate || candidate.length > MAX_RETURN_URL_CHARS)
|
|
53
|
+
return null;
|
|
54
|
+
let url;
|
|
55
|
+
try {
|
|
56
|
+
url = new URL(candidate);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return BLOCKED.has(url.protocol) ? null : url.href;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=walletReturnUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletReturnUrl.js","sourceRoot":"","sources":["../src/walletReturnUrl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAsB;IACtE,qCAAqC;IACrC,aAAa;IACb,WAAW;IACX,OAAO;IACP,OAAO;IACP,aAAa;IACb,mBAAmB;IACnB,OAAO;IACP,QAAQ;IACR,SAAS;IACT,mBAAmB;IACnB,OAAO;IACP,gBAAgB;IAChB,uBAAuB;IACvB,cAAc;IACd,2CAA2C;IAC3C,OAAO;CACR,CAAC;AAEF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,qCAAqC,CAAC,CAAC;AAE/D;6DAC6D;AAC7D,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,SAAkB,EAAiB,EAAE;IAC1E,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,oBAAoB;QAAE,OAAO,IAAI,CAAC;IACxG,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;AACrD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirexapp/card-sdk-core",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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",
|