@swichpay/react-native 0.0.0-stage → 1.0.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 +32 -0
- package/LICENSE +21 -0
- package/README.md +82 -2
- package/docs/checkouts.md +98 -0
- package/docs/getting-started.md +140 -0
- package/docs/going-live.md +45 -0
- package/docs/own-screen.md +81 -0
- package/docs/results-and-errors.md +75 -0
- package/docs/server.md +163 -0
- package/docs/troubleshooting.md +57 -0
- package/lib/commonjs/HostedCheckout.js +115 -0
- package/lib/commonjs/checkout-webview.js +85 -0
- package/lib/commonjs/checkouts/PaymentSheet.js +1317 -0
- package/lib/commonjs/checkouts/direct.js +671 -0
- package/lib/commonjs/context.js +64 -0
- package/lib/commonjs/core/api/direct-payment-api.js +425 -0
- package/lib/commonjs/core/api/discount-api.js +19 -0
- package/lib/commonjs/core/api/gateway-api.js +366 -0
- package/lib/commonjs/core/api/payments-api.js +79 -0
- package/lib/commonjs/core/api/repositories.js +5 -0
- package/lib/commonjs/core/assets/images.js +12 -0
- package/lib/commonjs/core/assets/method-logos.js +19 -0
- package/lib/commonjs/core/assets/pwa-images.js +13 -0
- package/lib/commonjs/core/browser/clipboard.js +30 -0
- package/lib/commonjs/core/browser/dom.js +71 -0
- package/lib/commonjs/core/browser/hosted-checkout.js +107 -0
- package/lib/commonjs/core/browser/index.js +119 -0
- package/lib/commonjs/core/browser/qr.js +109 -0
- package/lib/commonjs/core/browser/three-ds.js +151 -0
- package/lib/commonjs/core/client.js +344 -0
- package/lib/commonjs/core/config.js +132 -0
- package/lib/commonjs/core/environment.js +34 -0
- package/lib/commonjs/core/errors.js +138 -0
- package/lib/commonjs/core/events.js +57 -0
- package/lib/commonjs/core/flows/controller.js +106 -0
- package/lib/commonjs/core/flows/countdown.js +41 -0
- package/lib/commonjs/core/flows/direct-bank-transfer.js +236 -0
- package/lib/commonjs/core/flows/direct-card.js +354 -0
- package/lib/commonjs/core/flows/direct-ewallet.js +124 -0
- package/lib/commonjs/core/flows/direct-one-bill.js +172 -0
- package/lib/commonjs/core/flows/direct-qr.js +109 -0
- package/lib/commonjs/core/flows/direct-rtp.js +302 -0
- package/lib/commonjs/core/flows/discount-lookup.js +80 -0
- package/lib/commonjs/core/flows/headless.js +94 -0
- package/lib/commonjs/core/flows/payment-sheet.js +1321 -0
- package/lib/commonjs/core/flows/services.js +31 -0
- package/lib/commonjs/core/flows/shared.js +90 -0
- package/lib/commonjs/core/http/api-client.js +208 -0
- package/lib/commonjs/core/http/endpoints.js +61 -0
- package/lib/commonjs/core/http/token-manager.js +46 -0
- package/lib/commonjs/core/http/transport.js +134 -0
- package/lib/commonjs/core/index.js +688 -0
- package/lib/commonjs/core/models/category.js +113 -0
- package/lib/commonjs/core/models/discount.js +51 -0
- package/lib/commonjs/core/models/payment.js +95 -0
- package/lib/commonjs/core/models/session.js +131 -0
- package/lib/commonjs/core/server/index.js +64 -0
- package/lib/commonjs/core/server/node.js +60 -0
- package/lib/commonjs/core/server/proxy.js +194 -0
- package/lib/commonjs/core/server/verify.js +122 -0
- package/lib/commonjs/core/swichpay.js +72 -0
- package/lib/commonjs/core/utils/crypto.js +78 -0
- package/lib/commonjs/core/utils/formatters.js +68 -0
- package/lib/commonjs/core/utils/json.js +110 -0
- package/lib/commonjs/core/utils/log.js +75 -0
- package/lib/commonjs/core/utils/runtime.js +34 -0
- package/lib/commonjs/core/utils/validators.js +59 -0
- package/lib/commonjs/hooks.js +77 -0
- package/lib/commonjs/index.js +203 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/polyfills.js +3 -0
- package/lib/commonjs/presenter.js +61 -0
- package/lib/commonjs/provider.js +192 -0
- package/lib/commonjs/swichpay.js +192 -0
- package/lib/commonjs/theme.js +54 -0
- package/lib/commonjs/ui.js +1142 -0
- package/lib/commonjs/webviews.js +279 -0
- package/lib/module/HostedCheckout.js +111 -0
- package/lib/module/checkout-webview.js +83 -0
- package/lib/module/checkouts/PaymentSheet.js +1313 -0
- package/lib/module/checkouts/direct.js +661 -0
- package/lib/module/context.js +58 -0
- package/lib/module/core/api/direct-payment-api.js +413 -0
- package/lib/module/core/api/discount-api.js +14 -0
- package/lib/module/core/api/gateway-api.js +358 -0
- package/lib/module/core/api/payments-api.js +73 -0
- package/lib/module/core/api/repositories.js +3 -0
- package/lib/module/core/assets/images.js +8 -0
- package/lib/module/core/assets/method-logos.js +15 -0
- package/lib/module/core/assets/pwa-images.js +9 -0
- package/lib/module/core/browser/clipboard.js +27 -0
- package/lib/module/core/browser/dom.js +63 -0
- package/lib/module/core/browser/hosted-checkout.js +102 -0
- package/lib/module/core/browser/index.js +12 -0
- package/lib/module/core/browser/qr.js +100 -0
- package/lib/module/core/browser/three-ds.js +145 -0
- package/lib/module/core/client.js +338 -0
- package/lib/module/core/config.js +128 -0
- package/lib/module/core/environment.js +29 -0
- package/lib/module/core/errors.js +125 -0
- package/lib/module/core/events.js +51 -0
- package/lib/module/core/flows/controller.js +101 -0
- package/lib/module/core/flows/countdown.js +36 -0
- package/lib/module/core/flows/direct-bank-transfer.js +231 -0
- package/lib/module/core/flows/direct-card.js +349 -0
- package/lib/module/core/flows/direct-ewallet.js +119 -0
- package/lib/module/core/flows/direct-one-bill.js +167 -0
- package/lib/module/core/flows/direct-qr.js +104 -0
- package/lib/module/core/flows/direct-rtp.js +297 -0
- package/lib/module/core/flows/discount-lookup.js +75 -0
- package/lib/module/core/flows/headless.js +90 -0
- package/lib/module/core/flows/payment-sheet.js +1315 -0
- package/lib/module/core/flows/services.js +27 -0
- package/lib/module/core/flows/shared.js +78 -0
- package/lib/module/core/http/api-client.js +203 -0
- package/lib/module/core/http/endpoints.js +57 -0
- package/lib/module/core/http/token-manager.js +41 -0
- package/lib/module/core/http/transport.js +126 -0
- package/lib/module/core/index.js +52 -0
- package/lib/module/core/models/category.js +104 -0
- package/lib/module/core/models/discount.js +46 -0
- package/lib/module/core/models/payment.js +89 -0
- package/lib/module/core/models/session.js +120 -0
- package/lib/module/core/server/index.js +11 -0
- package/lib/module/core/server/node.js +56 -0
- package/lib/module/core/server/proxy.js +191 -0
- package/lib/module/core/server/verify.js +115 -0
- package/lib/module/core/swichpay.js +68 -0
- package/lib/module/core/utils/crypto.js +72 -0
- package/lib/module/core/utils/formatters.js +56 -0
- package/lib/module/core/utils/json.js +94 -0
- package/lib/module/core/utils/log.js +67 -0
- package/lib/module/core/utils/runtime.js +28 -0
- package/lib/module/core/utils/validators.js +54 -0
- package/lib/module/hooks.js +72 -0
- package/lib/module/index.js +36 -0
- package/lib/module/polyfills.js +4 -0
- package/lib/module/presenter.js +58 -0
- package/lib/module/provider.js +188 -0
- package/lib/module/swichpay.js +187 -0
- package/lib/module/theme.js +50 -0
- package/lib/module/ui.js +1116 -0
- package/lib/module/webviews.js +272 -0
- package/lib/typescript/commonjs/HostedCheckout.d.ts +17 -0
- package/lib/typescript/commonjs/checkout-webview.d.ts +14 -0
- package/lib/typescript/commonjs/checkouts/PaymentSheet.d.ts +14 -0
- package/lib/typescript/commonjs/checkouts/direct.d.ts +18 -0
- package/lib/typescript/commonjs/context.d.ts +20 -0
- package/lib/typescript/commonjs/core/api/direct-payment-api.d.ts +103 -0
- package/lib/typescript/commonjs/core/api/discount-api.d.ts +10 -0
- package/lib/typescript/commonjs/core/api/gateway-api.d.ts +150 -0
- package/lib/typescript/commonjs/core/api/payments-api.d.ts +22 -0
- package/lib/typescript/commonjs/core/api/repositories.d.ts +86 -0
- package/lib/typescript/commonjs/core/assets/images.d.ts +5 -0
- package/lib/typescript/commonjs/core/assets/method-logos.d.ts +12 -0
- package/lib/typescript/commonjs/core/assets/pwa-images.d.ts +7 -0
- package/lib/typescript/commonjs/core/browser/clipboard.d.ts +3 -0
- package/lib/typescript/commonjs/core/browser/dom.d.ts +11 -0
- package/lib/typescript/commonjs/core/browser/hosted-checkout.d.ts +27 -0
- package/lib/typescript/commonjs/core/browser/index.d.ts +11 -0
- package/lib/typescript/commonjs/core/browser/qr.d.ts +18 -0
- package/lib/typescript/commonjs/core/browser/three-ds.d.ts +45 -0
- package/lib/typescript/commonjs/core/client.d.ts +181 -0
- package/lib/typescript/commonjs/core/config.d.ts +86 -0
- package/lib/typescript/commonjs/core/environment.d.ts +22 -0
- package/lib/typescript/commonjs/core/errors.d.ts +78 -0
- package/lib/typescript/commonjs/core/events.d.ts +19 -0
- package/lib/typescript/commonjs/core/flows/controller.d.ts +41 -0
- package/lib/typescript/commonjs/core/flows/countdown.d.ts +15 -0
- package/lib/typescript/commonjs/core/flows/direct-bank-transfer.d.ts +49 -0
- package/lib/typescript/commonjs/core/flows/direct-card.d.ts +94 -0
- package/lib/typescript/commonjs/core/flows/direct-ewallet.d.ts +39 -0
- package/lib/typescript/commonjs/core/flows/direct-one-bill.d.ts +38 -0
- package/lib/typescript/commonjs/core/flows/direct-qr.d.ts +25 -0
- package/lib/typescript/commonjs/core/flows/direct-rtp.d.ts +72 -0
- package/lib/typescript/commonjs/core/flows/discount-lookup.d.ts +37 -0
- package/lib/typescript/commonjs/core/flows/headless.d.ts +38 -0
- package/lib/typescript/commonjs/core/flows/payment-sheet.d.ts +263 -0
- package/lib/typescript/commonjs/core/flows/services.d.ts +22 -0
- package/lib/typescript/commonjs/core/flows/shared.d.ts +40 -0
- package/lib/typescript/commonjs/core/http/api-client.d.ts +37 -0
- package/lib/typescript/commonjs/core/http/endpoints.d.ts +39 -0
- package/lib/typescript/commonjs/core/http/token-manager.d.ts +19 -0
- package/lib/typescript/commonjs/core/http/transport.d.ts +37 -0
- package/lib/typescript/commonjs/core/index.d.ts +42 -0
- package/lib/typescript/commonjs/core/models/category.d.ts +35 -0
- package/lib/typescript/commonjs/core/models/discount.d.ts +41 -0
- package/lib/typescript/commonjs/core/models/payment.d.ts +104 -0
- package/lib/typescript/commonjs/core/models/session.d.ts +87 -0
- package/lib/typescript/commonjs/core/server/index.d.ts +10 -0
- package/lib/typescript/commonjs/core/server/node.d.ts +19 -0
- package/lib/typescript/commonjs/core/server/proxy.d.ts +30 -0
- package/lib/typescript/commonjs/core/server/verify.d.ts +61 -0
- package/lib/typescript/commonjs/core/swichpay.d.ts +40 -0
- package/lib/typescript/commonjs/core/utils/crypto.d.ts +19 -0
- package/lib/typescript/commonjs/core/utils/formatters.d.ts +19 -0
- package/lib/typescript/commonjs/core/utils/json.d.ts +27 -0
- package/lib/typescript/commonjs/core/utils/log.d.ts +15 -0
- package/lib/typescript/commonjs/core/utils/runtime.d.ts +12 -0
- package/lib/typescript/commonjs/core/utils/validators.d.ts +23 -0
- package/lib/typescript/commonjs/hooks.d.ts +21 -0
- package/lib/typescript/commonjs/index.d.ts +26 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/polyfills.d.ts +2 -0
- package/lib/typescript/commonjs/presenter.d.ts +25 -0
- package/lib/typescript/commonjs/provider.d.ts +22 -0
- package/lib/typescript/commonjs/swichpay.d.ts +125 -0
- package/lib/typescript/commonjs/theme.d.ts +52 -0
- package/lib/typescript/commonjs/ui.d.ts +583 -0
- package/lib/typescript/commonjs/webviews.d.ts +40 -0
- package/lib/typescript/module/HostedCheckout.d.ts +17 -0
- package/lib/typescript/module/checkout-webview.d.ts +14 -0
- package/lib/typescript/module/checkouts/PaymentSheet.d.ts +14 -0
- package/lib/typescript/module/checkouts/direct.d.ts +18 -0
- package/lib/typescript/module/context.d.ts +20 -0
- package/lib/typescript/module/core/api/direct-payment-api.d.ts +103 -0
- package/lib/typescript/module/core/api/discount-api.d.ts +10 -0
- package/lib/typescript/module/core/api/gateway-api.d.ts +150 -0
- package/lib/typescript/module/core/api/payments-api.d.ts +22 -0
- package/lib/typescript/module/core/api/repositories.d.ts +86 -0
- package/lib/typescript/module/core/assets/images.d.ts +5 -0
- package/lib/typescript/module/core/assets/method-logos.d.ts +12 -0
- package/lib/typescript/module/core/assets/pwa-images.d.ts +7 -0
- package/lib/typescript/module/core/browser/clipboard.d.ts +3 -0
- package/lib/typescript/module/core/browser/dom.d.ts +11 -0
- package/lib/typescript/module/core/browser/hosted-checkout.d.ts +27 -0
- package/lib/typescript/module/core/browser/index.d.ts +11 -0
- package/lib/typescript/module/core/browser/qr.d.ts +18 -0
- package/lib/typescript/module/core/browser/three-ds.d.ts +45 -0
- package/lib/typescript/module/core/client.d.ts +181 -0
- package/lib/typescript/module/core/config.d.ts +86 -0
- package/lib/typescript/module/core/environment.d.ts +22 -0
- package/lib/typescript/module/core/errors.d.ts +78 -0
- package/lib/typescript/module/core/events.d.ts +19 -0
- package/lib/typescript/module/core/flows/controller.d.ts +41 -0
- package/lib/typescript/module/core/flows/countdown.d.ts +15 -0
- package/lib/typescript/module/core/flows/direct-bank-transfer.d.ts +49 -0
- package/lib/typescript/module/core/flows/direct-card.d.ts +94 -0
- package/lib/typescript/module/core/flows/direct-ewallet.d.ts +39 -0
- package/lib/typescript/module/core/flows/direct-one-bill.d.ts +38 -0
- package/lib/typescript/module/core/flows/direct-qr.d.ts +25 -0
- package/lib/typescript/module/core/flows/direct-rtp.d.ts +72 -0
- package/lib/typescript/module/core/flows/discount-lookup.d.ts +37 -0
- package/lib/typescript/module/core/flows/headless.d.ts +38 -0
- package/lib/typescript/module/core/flows/payment-sheet.d.ts +263 -0
- package/lib/typescript/module/core/flows/services.d.ts +22 -0
- package/lib/typescript/module/core/flows/shared.d.ts +40 -0
- package/lib/typescript/module/core/http/api-client.d.ts +37 -0
- package/lib/typescript/module/core/http/endpoints.d.ts +39 -0
- package/lib/typescript/module/core/http/token-manager.d.ts +19 -0
- package/lib/typescript/module/core/http/transport.d.ts +37 -0
- package/lib/typescript/module/core/index.d.ts +42 -0
- package/lib/typescript/module/core/models/category.d.ts +35 -0
- package/lib/typescript/module/core/models/discount.d.ts +41 -0
- package/lib/typescript/module/core/models/payment.d.ts +104 -0
- package/lib/typescript/module/core/models/session.d.ts +87 -0
- package/lib/typescript/module/core/server/index.d.ts +10 -0
- package/lib/typescript/module/core/server/node.d.ts +19 -0
- package/lib/typescript/module/core/server/proxy.d.ts +30 -0
- package/lib/typescript/module/core/server/verify.d.ts +61 -0
- package/lib/typescript/module/core/swichpay.d.ts +40 -0
- package/lib/typescript/module/core/utils/crypto.d.ts +19 -0
- package/lib/typescript/module/core/utils/formatters.d.ts +19 -0
- package/lib/typescript/module/core/utils/json.d.ts +27 -0
- package/lib/typescript/module/core/utils/log.d.ts +15 -0
- package/lib/typescript/module/core/utils/runtime.d.ts +12 -0
- package/lib/typescript/module/core/utils/validators.d.ts +23 -0
- package/lib/typescript/module/hooks.d.ts +21 -0
- package/lib/typescript/module/index.d.ts +26 -0
- package/lib/typescript/module/polyfills.d.ts +2 -0
- package/lib/typescript/module/presenter.d.ts +25 -0
- package/lib/typescript/module/provider.d.ts +22 -0
- package/lib/typescript/module/swichpay.d.ts +125 -0
- package/lib/typescript/module/theme.d.ts +52 -0
- package/lib/typescript/module/ui.d.ts +583 -0
- package/lib/typescript/module/webviews.d.ts +40 -0
- package/package.json +129 -4
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "TRANSACTION_COMPLETE", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _threeDs.TRANSACTION_COMPLETE;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "copyText", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _clipboard.copyText;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "createPostForm", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _dom.createPostForm;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "downloadQrCode", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _qr.downloadQrCode;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "encodeQr", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _qr.encodeQr;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "hostedCheckoutResultForUrl", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _hostedCheckout.hostedCheckoutResultForUrl;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "isBrowser", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _runtime.isBrowser;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "messageDataAsObject", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _dom.messageDataAsObject;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "mountHostedCheckout", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _hostedCheckout.mountHostedCheckout;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "mountStepUpChallenge", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _threeDs.mountStepUpChallenge;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "qrPngBlob", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _qr.qrPngBlob;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "qrSvg", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _qr.qrSvg;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "readFrameUrl", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _dom.readFrameUrl;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "redirectToHostedCheckout", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _hostedCheckout.redirectToHostedCheckout;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "runDeviceDataCollection", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _threeDs.runDeviceDataCollection;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "serializeMessageData", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _dom.serializeMessageData;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "shareQrCode", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _qr.shareQrCode;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "stepUpRequest", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _threeDs.stepUpRequest;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
var _clipboard = require("./clipboard.js");
|
|
115
|
+
var _dom = require("./dom.js");
|
|
116
|
+
var _hostedCheckout = require("./hosted-checkout.js");
|
|
117
|
+
var _qr = require("./qr.js");
|
|
118
|
+
var _threeDs = require("./three-ds.js");
|
|
119
|
+
var _runtime = require("../utils/runtime.js");
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.downloadQrCode = downloadQrCode;
|
|
7
|
+
exports.encodeQr = encodeQr;
|
|
8
|
+
exports.qrPngBlob = qrPngBlob;
|
|
9
|
+
exports.qrSvg = qrSvg;
|
|
10
|
+
exports.shareQrCode = shareQrCode;
|
|
11
|
+
var _qrcodeGenerator = _interopRequireDefault(require("qrcode-generator"));
|
|
12
|
+
var _runtime = require("../utils/runtime.js");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
/** Encodes `text` as a QR matrix (error correction M, automatic version). Pure - SSR-safe. */
|
|
15
|
+
function encodeQr(text) {
|
|
16
|
+
const qr = (0, _qrcodeGenerator.default)(0, 'M');
|
|
17
|
+
qr.addData(text, 'Byte');
|
|
18
|
+
qr.make();
|
|
19
|
+
return {
|
|
20
|
+
size: qr.getModuleCount(),
|
|
21
|
+
isDark: (r, c) => qr.isDark(r, c)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** An SVG string for `text`, scalable to any size. Pure - safe to render on the server. */
|
|
26
|
+
function qrSvg(text, options = {}) {
|
|
27
|
+
const matrix = encodeQr(text);
|
|
28
|
+
const margin = options.margin ?? 4;
|
|
29
|
+
const dim = matrix.size + margin * 2;
|
|
30
|
+
let path = '';
|
|
31
|
+
for (let r = 0; r < matrix.size; r++) {
|
|
32
|
+
for (let c = 0; c < matrix.size; c++) {
|
|
33
|
+
if (matrix.isDark(r, c)) path += `M${c + margin} ${r + margin}h1v1h-1z`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const title = options.title ? `<title>${escapeXml(options.title)}</title>` : '';
|
|
37
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${dim} ${dim}" shape-rendering="crispEdges" role="img">` + `${title}<rect width="100%" height="100%" fill="#fff"/><path d="${path}" fill="#000"/></svg>`;
|
|
38
|
+
}
|
|
39
|
+
function escapeXml(value) {
|
|
40
|
+
return value.replace(/[<>&"']/g, ch => `&#${ch.charCodeAt(0)};`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Rasterizes the QR to a PNG blob (for download/share). Browser only. */
|
|
44
|
+
async function qrPngBlob(text, pixels = 660) {
|
|
45
|
+
(0, _runtime.assertBrowser)('QR image export');
|
|
46
|
+
const matrix = encodeQr(text);
|
|
47
|
+
const margin = 4;
|
|
48
|
+
const dim = matrix.size + margin * 2;
|
|
49
|
+
const cell = Math.max(1, Math.floor(pixels / dim));
|
|
50
|
+
const canvas = document.createElement('canvas');
|
|
51
|
+
canvas.width = canvas.height = dim * cell;
|
|
52
|
+
const ctx = canvas.getContext('2d');
|
|
53
|
+
if (!ctx) throw new Error('Canvas 2D is unavailable.');
|
|
54
|
+
ctx.fillStyle = '#fff';
|
|
55
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
56
|
+
ctx.fillStyle = '#000';
|
|
57
|
+
for (let r = 0; r < matrix.size; r++) {
|
|
58
|
+
for (let c = 0; c < matrix.size; c++) {
|
|
59
|
+
if (matrix.isDark(r, c)) ctx.fillRect((c + margin) * cell, (r + margin) * cell, cell, cell);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
canvas.toBlob(blob => blob ? resolve(blob) : reject(new Error('Could not encode the QR image.')), 'image/png');
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function qrFileName(now = Date.now()) {
|
|
67
|
+
return `swichpay_qr_${now}.png`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Saves the QR as a PNG file. */
|
|
71
|
+
async function downloadQrCode(text, fileName = qrFileName()) {
|
|
72
|
+
const blob = await qrPngBlob(text);
|
|
73
|
+
const url = URL.createObjectURL(blob);
|
|
74
|
+
try {
|
|
75
|
+
const link = document.createElement('a');
|
|
76
|
+
link.href = url;
|
|
77
|
+
link.download = fileName;
|
|
78
|
+
link.rel = 'noopener';
|
|
79
|
+
link.style.display = 'none';
|
|
80
|
+
document.body.appendChild(link);
|
|
81
|
+
link.click();
|
|
82
|
+
link.remove();
|
|
83
|
+
} finally {
|
|
84
|
+
// Give the browser a moment to start the download before revoking.
|
|
85
|
+
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Shares the QR PNG with the Web Share API when it can share files; downloads it otherwise. */
|
|
90
|
+
async function shareQrCode(text) {
|
|
91
|
+
const blob = await qrPngBlob(text);
|
|
92
|
+
const fileName = qrFileName();
|
|
93
|
+
const nav = navigator;
|
|
94
|
+
if (typeof File === 'function' && typeof nav.share === 'function' && typeof nav.canShare === 'function') {
|
|
95
|
+
const file = new File([blob], fileName, {
|
|
96
|
+
type: 'image/png'
|
|
97
|
+
});
|
|
98
|
+
const data = {
|
|
99
|
+
files: [file],
|
|
100
|
+
text: 'SwichPay QR code'
|
|
101
|
+
};
|
|
102
|
+
if (nav.canShare(data)) {
|
|
103
|
+
await nav.share(data);
|
|
104
|
+
return 'shared';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
await downloadQrCode(text, fileName);
|
|
108
|
+
return 'downloaded';
|
|
109
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TRANSACTION_COMPLETE = void 0;
|
|
7
|
+
exports.mountStepUpChallenge = mountStepUpChallenge;
|
|
8
|
+
exports.runDeviceDataCollection = runDeviceDataCollection;
|
|
9
|
+
exports.stepUpRequest = stepUpRequest;
|
|
10
|
+
var _runtime = require("../utils/runtime.js");
|
|
11
|
+
var _dom = require("./dom.js");
|
|
12
|
+
/** Hosts Cardinal Commerce serves its 3-D Secure pages from. */
|
|
13
|
+
const CARDINAL_HOST = /(^|\.)(cardinalcommerce\.com|cardinaltrusted\.com)$/i;
|
|
14
|
+
|
|
15
|
+
/** SwichPay / JazzCash hosts - a return to these means "challenge finished". */
|
|
16
|
+
const SWICHPAY_HOST = /(^|\.)(swichnow\.com|jazzcash\.com\.pk)$/i;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The checkout host's 3-D Secure return page (`CallBack.cshtml` in Swich.CardPayment) posts
|
|
20
|
+
* `{ type: "TRANSACTION_COMPLETE", status }` to `window.parent` once the issuer step is over.
|
|
21
|
+
*/
|
|
22
|
+
const TRANSACTION_COMPLETE = exports.TRANSACTION_COMPLETE = 'TRANSACTION_COMPLETE';
|
|
23
|
+
function hostMatches(origin, pattern) {
|
|
24
|
+
try {
|
|
25
|
+
return pattern.test(new URL(origin).hostname);
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function isFromFrameOrCardinal(event, iframe) {
|
|
31
|
+
if (event.source != null && event.source === iframe.contentWindow) return true;
|
|
32
|
+
return hostMatches(event.origin, CARDINAL_HOST);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Runs Cardinal Cruise device-data-collection invisibly: POSTs `formFields` (the `JWT`) to `url`
|
|
37
|
+
* in a hidden iframe and resolves `true` on its `profile.complete` message, `false` after
|
|
38
|
+
* `timeoutMs`.
|
|
39
|
+
*/
|
|
40
|
+
function runDeviceDataCollection(input) {
|
|
41
|
+
(0, _runtime.assertBrowser)('3-D Secure device data collection');
|
|
42
|
+
return new Promise(resolve => {
|
|
43
|
+
const name = (0, _dom.uniqueName)('swichpay-ddc');
|
|
44
|
+
const iframe = document.createElement('iframe');
|
|
45
|
+
iframe.name = name;
|
|
46
|
+
iframe.title = 'Card verification';
|
|
47
|
+
iframe.setAttribute('aria-hidden', 'true');
|
|
48
|
+
iframe.tabIndex = -1;
|
|
49
|
+
iframe.style.cssText = 'position:absolute;width:1px;height:1px;border:0;left:-9999px;top:-9999px;opacity:0;pointer-events:none;';
|
|
50
|
+
const form = (0, _dom.createPostForm)(input.url, input.formFields, name);
|
|
51
|
+
let done = false;
|
|
52
|
+
const finish = completed => {
|
|
53
|
+
if (done) return;
|
|
54
|
+
done = true;
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
window.removeEventListener('message', onMessage);
|
|
57
|
+
iframe.remove();
|
|
58
|
+
form.remove();
|
|
59
|
+
resolve(completed);
|
|
60
|
+
};
|
|
61
|
+
const onMessage = event => {
|
|
62
|
+
if (!isFromFrameOrCardinal(event, iframe)) return;
|
|
63
|
+
if ((0, _dom.messageDataAsObject)(event.data)?.MessageType === 'profile.complete') finish(true);
|
|
64
|
+
};
|
|
65
|
+
const timer = setTimeout(() => finish(false), input.timeoutMs);
|
|
66
|
+
window.addEventListener('message', onMessage);
|
|
67
|
+
document.body.append(iframe, form);
|
|
68
|
+
form.submit();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** The form a step-up challenge is POSTed with. */
|
|
72
|
+
function stepUpRequest(url, jwt) {
|
|
73
|
+
if (jwt != null) return {
|
|
74
|
+
action: url,
|
|
75
|
+
fields: {
|
|
76
|
+
JWT: jwt
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
// Meezan's 3DS2 page rejects GET and wants its own query params as the body - only there.
|
|
80
|
+
const [base] = url.split('?');
|
|
81
|
+
let fields = {};
|
|
82
|
+
try {
|
|
83
|
+
fields = Object.fromEntries(new URL(url).searchParams.entries());
|
|
84
|
+
} catch {
|
|
85
|
+
fields = {};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
action: base ?? url,
|
|
89
|
+
fields
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Shows the issuer's 3-D Secure challenge in an iframe inside `container`. Completes on:
|
|
95
|
+
* - the first `postMessage` from the challenge frame -
|
|
96
|
+
* in practice SwichPay's return page's `{ type: "TRANSACTION_COMPLETE", status }`;
|
|
97
|
+
* - a `TRANSACTION_COMPLETE` message from a SwichPay/JazzCash origin posted by a nested frame;
|
|
98
|
+
* - a navigation to a completion URL we can read (same-origin only - browsers hide others).
|
|
99
|
+
* UIs also offer a manual "I've completed verification" action as a last resort.
|
|
100
|
+
*/
|
|
101
|
+
function mountStepUpChallenge(container, options) {
|
|
102
|
+
(0, _runtime.assertBrowser)('The 3-D Secure challenge');
|
|
103
|
+
const name = (0, _dom.uniqueName)('swichpay-3ds');
|
|
104
|
+
const iframe = document.createElement('iframe');
|
|
105
|
+
iframe.name = name;
|
|
106
|
+
iframe.title = 'Card verification with your bank';
|
|
107
|
+
iframe.className = 'sp-frame';
|
|
108
|
+
iframe.setAttribute('allow', 'payment');
|
|
109
|
+
const {
|
|
110
|
+
action,
|
|
111
|
+
fields
|
|
112
|
+
} = stepUpRequest(options.url, options.jwt);
|
|
113
|
+
const form = (0, _dom.createPostForm)(action, fields, name);
|
|
114
|
+
let completed = false;
|
|
115
|
+
let destroyed = false;
|
|
116
|
+
const complete = data => {
|
|
117
|
+
if (completed || destroyed) return;
|
|
118
|
+
completed = true;
|
|
119
|
+
options.onComplete(data);
|
|
120
|
+
};
|
|
121
|
+
const onMessage = event => {
|
|
122
|
+
const fromFrame = event.source != null && event.source === iframe.contentWindow;
|
|
123
|
+
const isSwichPayCompletion = hostMatches(event.origin, SWICHPAY_HOST) && (0, _dom.messageDataAsObject)(event.data)?.type === TRANSACTION_COMPLETE;
|
|
124
|
+
if (!fromFrame && !isSwichPayCompletion) return;
|
|
125
|
+
complete((0, _dom.serializeMessageData)(event.data));
|
|
126
|
+
};
|
|
127
|
+
const onLoad = () => {
|
|
128
|
+
options.onLoadingChange?.(false);
|
|
129
|
+
const url = (0, _dom.readFrameUrl)(iframe);
|
|
130
|
+
if (url && options.isCompletionUrl?.(url)) complete(JSON.stringify({
|
|
131
|
+
type: 'redirect',
|
|
132
|
+
url: url.href
|
|
133
|
+
}));
|
|
134
|
+
};
|
|
135
|
+
window.addEventListener('message', onMessage);
|
|
136
|
+
iframe.addEventListener('load', onLoad);
|
|
137
|
+
container.append(iframe, form);
|
|
138
|
+
options.onLoadingChange?.(true);
|
|
139
|
+
form.submit();
|
|
140
|
+
return {
|
|
141
|
+
iframe,
|
|
142
|
+
destroy() {
|
|
143
|
+
if (destroyed) return;
|
|
144
|
+
destroyed = true;
|
|
145
|
+
window.removeEventListener('message', onMessage);
|
|
146
|
+
iframe.removeEventListener('load', onLoad);
|
|
147
|
+
iframe.remove();
|
|
148
|
+
form.remove();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|