@paykka/card-checkout-ui 0.21.0 → 0.22.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.
Files changed (37) hide show
  1. package/README.md +3 -3
  2. package/dist/card-checkout-ui.js +14 -14
  3. package/dist/card-checkout-ui.umd.cjs +14 -14
  4. package/dist/es/api/modules/apple-pay/index.js +9 -2
  5. package/dist/es/api/modules/checkout/map.js +1 -0
  6. package/dist/es/api/modules/get-browser-params.js +1 -1
  7. package/dist/es/api/modules/risk/index.js +2 -1
  8. package/dist/es/components/ApplePay/index.js +7 -1
  9. package/dist/es/core/logger.js +44 -1
  10. package/dist/es/index.js +2 -2
  11. package/dist/es/out/fraud-detection.js +26 -3
  12. package/dist/es/out/paykka-detection.js +2 -0
  13. package/dist/es/polyfill.js +165 -165
  14. package/dist/es/types/event.js +6 -6
  15. package/dist/es/utils/base64.js +20 -0
  16. package/dist/es/utils/system-info/finger-print.js +5 -1
  17. package/dist/polyfill.js +165 -165
  18. package/dist/types/api/modules/apple-pay/index.d.ts +4 -1
  19. package/dist/types/api/modules/checkout/type.d.ts +2 -0
  20. package/dist/types/api/modules/risk/index.d.ts +1 -0
  21. package/dist/types/components/wallets/Doku/Doku.d.ts +2 -2
  22. package/dist/types/components/wallets/DragonPay/DragonPay.d.ts +1 -1
  23. package/dist/types/components/wallets/GoPay/GoPay.d.ts +0 -1
  24. package/dist/types/components/wallets/IDeal/IDeal.d.ts +1 -1
  25. package/dist/types/components/wallets/LinkAja/LinkAja.d.ts +2 -2
  26. package/dist/types/components/wallets/MyBank/MyBank.d.ts +0 -1
  27. package/dist/types/components/wallets/OnlineBankingEstonia/OnlineBankingEstonia.d.ts +0 -1
  28. package/dist/types/components/wallets/OnlineBankingFinland/OnlineBankingFinland.d.ts +0 -1
  29. package/dist/types/components/wallets/P24/P24.d.ts +1 -1
  30. package/dist/types/components/wallets/PayU/PayU.d.ts +1 -1
  31. package/dist/types/components/wallets/Twint/Twint.d.ts +0 -1
  32. package/dist/types/core/error.d.ts +1 -12
  33. package/dist/types/core/logger.d.ts +5 -1
  34. package/dist/types/types/event.d.ts +21 -9
  35. package/dist/types/utils/base64.d.ts +18 -0
  36. package/dist/types/utils/index.d.ts +1 -0
  37. package/package.json +85 -81
@@ -1,7 +1,14 @@
1
1
  import { apiPrefix } from "../../../config.js";
2
2
  import { http } from "../../http.js";
3
- const getMerchantSession = async (options) => {
4
- return http.post(`${apiPrefix}/apple-pay/create-session`, options);
3
+ const getMerchantSession = async (params, options) => {
4
+ return http.post(
5
+ `${apiPrefix}/apple-pay/create-session`,
6
+ {
7
+ merchant_id: params.merchantId,
8
+ merchant_product_id: params.merchantProductId
9
+ },
10
+ options
11
+ );
5
12
  };
6
13
  export {
7
14
  getMerchantSession
@@ -69,6 +69,7 @@ const checkoutMap = (res = {}) => {
69
69
  return {
70
70
  country: res.country,
71
71
  merchantId: res.merchant_id,
72
+ merchantProductId: res.merchant_product_id,
72
73
  sessionId: res.session_id,
73
74
  clientKey: res.client_key,
74
75
  status: res.status,
@@ -35,7 +35,7 @@ const getBaseBrowserParams = async (params = {}) => {
35
35
  terminal_type: terminalType,
36
36
  fraud_detection_id: fraudDetectionId,
37
37
  // 当前组件库版本(构建时由 define 注入)
38
- app_version: "0.21.0"
38
+ app_version: "0.22.0"
39
39
  };
40
40
  };
41
41
  const getBrowserParams = async (params = {}) => {
@@ -29,7 +29,8 @@ const reportUrls = async (params) => {
29
29
  return http.post("/pub/fraud-detection/report/urls", {
30
30
  client_key: params.clientKey,
31
31
  fraud_detection_mode: params.fraudDetectionMode,
32
- data: params.data
32
+ data: params.data,
33
+ browser: params.browser
33
34
  });
34
35
  };
35
36
  export {
@@ -370,7 +370,13 @@ const ApplePay = w((props) => {
370
370
  onValidate: async () => {
371
371
  var _a2;
372
372
  onEvent == null ? void 0 : onEvent(ApplePayEventType.APPLE_PAY_VALIDATE_MERCHANT);
373
- const merchantSession = await getMerchantSession();
373
+ const checkout = session == null ? void 0 : session.checkout;
374
+ const merchantSession = await getMerchantSession({
375
+ // 仅 DROP_IN / COMPONENT 收银台需要传 merchantId,HOSTED 不传
376
+ merchantId: (checkout == null ? void 0 : checkout.sessionMode) === SessionMode.HOSTED ? void 0 : checkout == null ? void 0 : checkout.merchantId,
377
+ // 没有 merchantProductId 时用 sessionId 兜底
378
+ merchantProductId: (checkout == null ? void 0 : checkout.merchantProductId) || (checkout == null ? void 0 : checkout.sessionId)
379
+ });
374
380
  (_a2 = applePaySession.current) == null ? void 0 : _a2.completeMerchantValidation(merchantSession);
375
381
  },
376
382
  onAuthorized: async (event) => {
@@ -1,13 +1,19 @@
1
1
  var _a;
2
2
  import { origin2Env, DEV_ORIGIN, FAT_ORIGIN, SANDBOX_ORIGIN, HK_ORIGIN, EU_ORIGIN, loggerEnvInfoMap } from "./environment.js";
3
3
  import { STRIPE_RADAR_SCRIPT_ORIGIN, WORLDPAY_JSC_ORIGIN } from "../out/config.js";
4
+ import { EnvEventType } from "../types/event.js";
4
5
  import "../utils/card-brand/brands.js";
6
+ import { getFingerprint } from "../utils/system-info/finger-print.js";
5
7
  import "../utils/system-info/get-browser-info.js";
6
8
  import { parseUrl } from "../utils/location.js";
9
+ import { encodeBase64, decodeBase64 } from "../utils/base64.js";
7
10
  import "../core.js";
8
11
  import "./context.js";
9
12
  import "../out/fraud-detection.js";
10
13
  const COMPONENT_PID = "71667dde4a0247c187c1c26bdc3aadcf";
14
+ const LOGGER_TAG_PREFIX = "tr";
15
+ const LOGGER_TAG_STORAGE_KEY = "paykka_buic";
16
+ const LOGGER_TAG_TABLE = "BFOZkRHwuCJ8Gr1sThX5PpLb-MUIxjdn0oY3DilAtva7ySKzNmVQ6WE9_ef42gqc";
11
17
  const REPORT_ORIGINS = [
12
18
  DEV_ORIGIN,
13
19
  FAT_ORIGIN,
@@ -43,14 +49,25 @@ class PayKKaLogger {
43
49
  if (options.sid) {
44
50
  (_a2 = window.sessionStorage) == null ? void 0 : _a2.setItem("felogger_sid", options.sid);
45
51
  }
52
+ const tag = await this.getTag();
46
53
  (_b = window.JlFeLogger) == null ? void 0 : _b.init({
47
54
  pid: options.pid || COMPONENT_PID,
48
55
  env: loggerEnvInfo.env,
49
- release: "0.21.0",
56
+ release: "0.22.0",
50
57
  imgUrl: loggerEnvInfo.imgUrl,
51
58
  postUrl: loggerEnvInfo.postUrl,
59
+ tag,
52
60
  beforeSend: this.beforeSendEvent
53
61
  });
62
+ this.reportEnvInfo();
63
+ }
64
+ reportEnvInfo() {
65
+ this.reportCustomEvent(EnvEventType.ENV_INFO, {
66
+ itg: "npm",
67
+ benv: "npm",
68
+ ifr: window.self !== window.top,
69
+ v: "0.22.0"
70
+ });
54
71
  }
55
72
  /** 上报自定义事件 */
56
73
  reportCustomEvent(event, data) {
@@ -79,6 +96,32 @@ class PayKKaLogger {
79
96
  var _a2;
80
97
  (_a2 = window.JlFeLogger) == null ? void 0 : _a2.setOptions(options);
81
98
  }
99
+ async getTag() {
100
+ var _a2;
101
+ const fingerprint = this.getCachedFingerprint() || await getFingerprint();
102
+ if (!fingerprint) {
103
+ return "";
104
+ }
105
+ const tag = `${LOGGER_TAG_PREFIX}_${fingerprint}_${Date.now()}`;
106
+ try {
107
+ (_a2 = window.localStorage) == null ? void 0 : _a2.setItem(LOGGER_TAG_STORAGE_KEY, encodeBase64(tag, LOGGER_TAG_TABLE));
108
+ } catch {
109
+ }
110
+ return tag;
111
+ }
112
+ /** 读取缓存中的设备指纹段,缓存缺失或损坏时返回空串 */
113
+ getCachedFingerprint() {
114
+ var _a2;
115
+ try {
116
+ const [prefix, fingerprint] = decodeBase64(
117
+ ((_a2 = window.localStorage) == null ? void 0 : _a2.getItem(LOGGER_TAG_STORAGE_KEY)) || "",
118
+ LOGGER_TAG_TABLE
119
+ ).split("_");
120
+ return prefix === LOGGER_TAG_PREFIX && fingerprint ? fingerprint : "";
121
+ } catch {
122
+ return "";
123
+ }
124
+ }
82
125
  /**
83
126
  * 在日志上报前执行,拦截部分日志上报
84
127
  * 1. 过滤接口日志,只上报收银台相关接口,用接口域名判断
package/dist/es/index.js CHANGED
@@ -87,7 +87,7 @@ import "./out/fraud-detection.js";
87
87
  import "./core/logger.js";
88
88
  import { ECollMode } from "./types/fraud-detection.js";
89
89
  import { MessageAction } from "./types/message.js";
90
- import { ApplePayEventType, FraudDetectionEventType, GooglePayEventType, LoggerEventType, PaymentEventType, SecurityIframeEventType, ThreeDSEventType, WechatPayEventType } from "./types/event.js";
90
+ import { ApplePayEventType, EnvEventType, FraudDetectionEventType, GooglePayEventType, PaymentEventType, SecurityIframeEventType, ThreeDSEventType, WechatPayEventType } from "./types/event.js";
91
91
  export {
92
92
  Alipay,
93
93
  AlipayHK,
@@ -119,6 +119,7 @@ export {
119
119
  EPS,
120
120
  EPayKKaEnv,
121
121
  EncryptedCard,
122
+ EnvEventType,
122
123
  Fpx,
123
124
  FraudDetectionEventType,
124
125
  GCash,
@@ -133,7 +134,6 @@ export {
133
134
  LinePay,
134
135
  LinkAja,
135
136
  LocaleKey,
136
- LoggerEventType,
137
137
  MayBankQRPay,
138
138
  MbWay,
139
139
  MessageAction,
@@ -28,6 +28,7 @@ import { getChannelSDKConfig } from "../api/modules/risk/index.js";
28
28
  import { setApiUrl, setCDNUrl, setApiPrefix } from "../config.js";
29
29
  import { ChannelCode } from "../constant.js";
30
30
  import { apiEnv, cdnEnv } from "../core/environment.js";
31
+ import { PayKKaLogger } from "../core/logger.js";
31
32
  import { ECollMode } from "../types/fraud-detection.js";
32
33
  import { FraudDetectionEventType } from "../types/event.js";
33
34
  import { difference } from "../utils/array.js";
@@ -36,14 +37,36 @@ import { PayKKaDetection } from "./paykka-detection.js";
36
37
  import { StripeRadar } from "./stripe-radar.js";
37
38
  import { WorldpayDDCManager } from "./worldpay-ddc-manager.js";
38
39
  import { WorldpayJSC } from "./worldpay-jsc.js";
40
+ const isIIFE = typeof __IS_IIFE__ !== "undefined" && __IS_IIFE__;
39
41
  const DEFAULT_ENV = "eu";
40
42
  const DEFAULT_MODES = [ECollMode.SR, ECollMode.WP, ECollMode.WJ];
41
43
  let instance = null;
42
44
  function getFraudDetectionInstance(config, options) {
45
+ const env = config.env || DEFAULT_ENV;
46
+ const logger = isIIFE ? new PayKKaLogger() : void 0;
47
+ const loggerReady = logger == null ? void 0 : logger.init({ env }).catch(() => void 0);
48
+ loggerReady == null ? void 0 : loggerReady.then(() => logger == null ? void 0 : logger.reportCustomEvent(FraudDetectionEventType.FRAUD_DETECTION_CDN));
43
49
  if (!instance) {
44
- instance = new FraudDetection(config, options);
50
+ instance = new FraudDetection(config, {
51
+ ...options,
52
+ // 保留原有事件回调,同时将同一批事件转发给 CDN logger。
53
+ onEvent: (event, data) => {
54
+ var _a;
55
+ (_a = options == null ? void 0 : options.onEvent) == null ? void 0 : _a.call(options, event, data);
56
+ logger == null ? void 0 : logger.reportCustomEvent(event, data);
57
+ }
58
+ });
45
59
  }
46
- return instance;
60
+ return {
61
+ async getFraudDetectionId(options2) {
62
+ await loggerReady;
63
+ return instance.getFraudDetectionId(options2);
64
+ },
65
+ async createFraudDetection() {
66
+ await loggerReady;
67
+ return instance.createFraudDetection();
68
+ }
69
+ };
47
70
  }
48
71
  class FraudDetection {
49
72
  constructor(config, options) {
@@ -60,7 +83,7 @@ class FraudDetection {
60
83
  __publicField(this, "channelConfig");
61
84
  __publicField(this, "channelConfigPromise");
62
85
  /** 是否是 IIFE 模式,在 build 时通过 define 定义,如果 IIFE 为 true,说明商户是直接引入 SDK,用于 API 支付 */
63
- __publicField(this, "isIIFE", typeof __IS_IIFE__ !== "undefined" && __IS_IIFE__);
86
+ __publicField(this, "isIIFE", isIIFE);
64
87
  __privateAdd(this, _sessionMode, void 0);
65
88
  const { env, clientKey, modes } = config;
66
89
  this.modes = (modes == null ? void 0 : modes.length) ? [...modes] : DEFAULT_MODES;
@@ -10,6 +10,7 @@ import "../core/context.js";
10
10
  import "./fraud-detection.js";
11
11
  import { ChannelCode } from "../constant.js";
12
12
  import "../core/logger.js";
13
+ import { getBrowserParams } from "../api/modules/get-browser-params.js";
13
14
  import { reportUrls } from "../api/modules/risk/index.js";
14
15
  import { encryptAES } from "../utils/encrypt.js";
15
16
  import { BaseFraudDetection } from "./base-fraud-detection.js";
@@ -41,6 +42,7 @@ const _PayKKaDetection = class _PayKKaDetection extends BaseFraudDetection {
41
42
  const res = await reportUrls({
42
43
  clientKey,
43
44
  fraudDetectionMode: sessionMode,
45
+ browser: await getBrowserParams(),
44
46
  data: await encryptAES(clientKey, JSON.stringify(data))
45
47
  });
46
48
  return res;
@@ -1,166 +1,166 @@
1
- ;(function (global) {
2
- 'use strict'
3
-
4
- // globalThis
5
- if (typeof global.globalThis === 'undefined') {
6
- global.globalThis = global
7
- }
8
-
9
- // Object.values
10
- if (typeof Object.values !== 'function') {
11
- Object.values = function (obj) {
12
- if (obj == null) {
13
- throw new TypeError('Cannot convert undefined or null to object')
14
- }
15
-
16
- var target = Object(obj)
17
- var keys = Object.keys(target)
18
- var result = new Array(keys.length)
19
-
20
- for (var i = 0; i < keys.length; i++) {
21
- result[i] = target[keys[i]]
22
- }
23
-
24
- return result
25
- }
26
- }
27
-
28
- // Object.entries
29
- if (typeof Object.entries !== 'function') {
30
- Object.entries = function (obj) {
31
- if (obj == null) {
32
- throw new TypeError('Cannot convert undefined or null to object')
33
- }
34
-
35
- var target = Object(obj)
36
- var keys = Object.keys(target)
37
- var result = new Array(keys.length)
38
-
39
- for (var i = 0; i < keys.length; i++) {
40
- result[i] = [keys[i], target[keys[i]]]
41
- }
42
-
43
- return result
44
- }
45
- }
46
-
47
- // Promise.prototype.finally
48
- if (
49
- typeof global.Promise !== 'undefined' &&
50
- global.Promise.prototype &&
51
- typeof global.Promise.prototype.finally !== 'function'
52
- ) {
53
- global.Promise.prototype.finally = function (onFinally) {
54
- var P = this.constructor
55
-
56
- return this.then(
57
- function (value) {
58
- return P.resolve(
59
- typeof onFinally === 'function' ? onFinally() : onFinally
60
- ).then(function () {
61
- return value
62
- })
63
- },
64
- function (reason) {
65
- return P.resolve(
66
- typeof onFinally === 'function' ? onFinally() : onFinally
67
- ).then(function () {
68
- throw reason
69
- })
70
- }
71
- )
72
- }
73
- }
74
-
75
- // AbortController minimal shim
76
- // 说明:
77
- // 1. 只解决 "AbortController is not defined"
78
- // 2. 不保证旧浏览器原生 fetch 一定真正中断请求
79
- // 3. 但足够避免直接 ReferenceError,并让依赖 signal 的逻辑尽量工作
80
- if (typeof global.AbortController === 'undefined') {
81
- function AbortSignal() {
82
- this.aborted = false
83
- this.reason = void 0
84
- this.onabort = null
85
- this._listeners = []
86
- }
87
-
88
- AbortSignal.prototype.addEventListener = function (type, listener) {
89
- if (type !== 'abort' || typeof listener !== 'function') return
90
- this._listeners.push(listener)
91
- }
92
-
93
- AbortSignal.prototype.removeEventListener = function (type, listener) {
94
- if (type !== 'abort') return
95
-
96
- for (var i = 0; i < this._listeners.length; i++) {
97
- if (this._listeners[i] === listener) {
98
- this._listeners.splice(i, 1)
99
- break
100
- }
101
- }
102
- }
103
-
104
- AbortSignal.prototype.dispatchEvent = function (event) {
105
- var listeners = this._listeners.slice()
106
-
107
- for (var i = 0; i < listeners.length; i++) {
108
- try {
109
- listeners[i].call(this, event)
110
- } catch (e) {}
111
- }
112
-
113
- return true
114
- }
115
-
116
- function AbortController() {
117
- this.signal = new AbortSignal()
118
- }
119
-
120
- AbortController.prototype.abort = function (reason) {
121
- if (this.signal.aborted) return
122
-
123
- this.signal.aborted = true
124
- this.signal.reason = reason
125
-
126
- var event = { type: 'abort' }
127
-
128
- if (typeof this.signal.onabort === 'function') {
129
- try {
130
- this.signal.onabort.call(this.signal, event)
131
- } catch (e) {}
132
- }
133
-
134
- this.signal.dispatchEvent(event)
135
- }
136
-
137
- global.AbortController = AbortController
138
- global.AbortSignal = AbortSignal
139
- }
140
-
141
- // postMessage compatibility helper
142
- // 用法:
143
- // window.__postMessageCompat(targetWindow, data, targetOrigin)
144
- //
145
- // 说明:
146
- // 旧 WebView 不支持 postMessage(message, { targetOrigin })
147
- // 必须改成 postMessage(message, targetOrigin)
148
- if (typeof global.__postMessageCompat !== 'function') {
149
- global.__postMessageCompat = function (targetWindow, data, targetOrigin) {
150
- if (!targetWindow || targetWindow === global) return
151
-
152
- var message = typeof data === 'string' ? data : JSON.stringify(data)
153
- var origin = typeof targetOrigin === 'string' ? targetOrigin : '*'
154
-
155
- targetWindow.postMessage(message, origin)
156
- }
157
- }
158
- })(
159
- typeof window !== 'undefined'
160
- ? window
161
- : typeof globalThis !== 'undefined'
162
- ? globalThis
163
- : typeof self !== 'undefined'
164
- ? self
165
- : this
1
+ ;(function (global) {
2
+ 'use strict'
3
+
4
+ // globalThis
5
+ if (typeof global.globalThis === 'undefined') {
6
+ global.globalThis = global
7
+ }
8
+
9
+ // Object.values
10
+ if (typeof Object.values !== 'function') {
11
+ Object.values = function (obj) {
12
+ if (obj == null) {
13
+ throw new TypeError('Cannot convert undefined or null to object')
14
+ }
15
+
16
+ var target = Object(obj)
17
+ var keys = Object.keys(target)
18
+ var result = new Array(keys.length)
19
+
20
+ for (var i = 0; i < keys.length; i++) {
21
+ result[i] = target[keys[i]]
22
+ }
23
+
24
+ return result
25
+ }
26
+ }
27
+
28
+ // Object.entries
29
+ if (typeof Object.entries !== 'function') {
30
+ Object.entries = function (obj) {
31
+ if (obj == null) {
32
+ throw new TypeError('Cannot convert undefined or null to object')
33
+ }
34
+
35
+ var target = Object(obj)
36
+ var keys = Object.keys(target)
37
+ var result = new Array(keys.length)
38
+
39
+ for (var i = 0; i < keys.length; i++) {
40
+ result[i] = [keys[i], target[keys[i]]]
41
+ }
42
+
43
+ return result
44
+ }
45
+ }
46
+
47
+ // Promise.prototype.finally
48
+ if (
49
+ typeof global.Promise !== 'undefined' &&
50
+ global.Promise.prototype &&
51
+ typeof global.Promise.prototype.finally !== 'function'
52
+ ) {
53
+ global.Promise.prototype.finally = function (onFinally) {
54
+ var P = this.constructor
55
+
56
+ return this.then(
57
+ function (value) {
58
+ return P.resolve(
59
+ typeof onFinally === 'function' ? onFinally() : onFinally
60
+ ).then(function () {
61
+ return value
62
+ })
63
+ },
64
+ function (reason) {
65
+ return P.resolve(
66
+ typeof onFinally === 'function' ? onFinally() : onFinally
67
+ ).then(function () {
68
+ throw reason
69
+ })
70
+ }
71
+ )
72
+ }
73
+ }
74
+
75
+ // AbortController minimal shim
76
+ // 说明:
77
+ // 1. 只解决 "AbortController is not defined"
78
+ // 2. 不保证旧浏览器原生 fetch 一定真正中断请求
79
+ // 3. 但足够避免直接 ReferenceError,并让依赖 signal 的逻辑尽量工作
80
+ if (typeof global.AbortController === 'undefined') {
81
+ function AbortSignal() {
82
+ this.aborted = false
83
+ this.reason = void 0
84
+ this.onabort = null
85
+ this._listeners = []
86
+ }
87
+
88
+ AbortSignal.prototype.addEventListener = function (type, listener) {
89
+ if (type !== 'abort' || typeof listener !== 'function') return
90
+ this._listeners.push(listener)
91
+ }
92
+
93
+ AbortSignal.prototype.removeEventListener = function (type, listener) {
94
+ if (type !== 'abort') return
95
+
96
+ for (var i = 0; i < this._listeners.length; i++) {
97
+ if (this._listeners[i] === listener) {
98
+ this._listeners.splice(i, 1)
99
+ break
100
+ }
101
+ }
102
+ }
103
+
104
+ AbortSignal.prototype.dispatchEvent = function (event) {
105
+ var listeners = this._listeners.slice()
106
+
107
+ for (var i = 0; i < listeners.length; i++) {
108
+ try {
109
+ listeners[i].call(this, event)
110
+ } catch (e) {}
111
+ }
112
+
113
+ return true
114
+ }
115
+
116
+ function AbortController() {
117
+ this.signal = new AbortSignal()
118
+ }
119
+
120
+ AbortController.prototype.abort = function (reason) {
121
+ if (this.signal.aborted) return
122
+
123
+ this.signal.aborted = true
124
+ this.signal.reason = reason
125
+
126
+ var event = { type: 'abort' }
127
+
128
+ if (typeof this.signal.onabort === 'function') {
129
+ try {
130
+ this.signal.onabort.call(this.signal, event)
131
+ } catch (e) {}
132
+ }
133
+
134
+ this.signal.dispatchEvent(event)
135
+ }
136
+
137
+ global.AbortController = AbortController
138
+ global.AbortSignal = AbortSignal
139
+ }
140
+
141
+ // postMessage compatibility helper
142
+ // 用法:
143
+ // window.__postMessageCompat(targetWindow, data, targetOrigin)
144
+ //
145
+ // 说明:
146
+ // 旧 WebView 不支持 postMessage(message, { targetOrigin })
147
+ // 必须改成 postMessage(message, targetOrigin)
148
+ if (typeof global.__postMessageCompat !== 'function') {
149
+ global.__postMessageCompat = function (targetWindow, data, targetOrigin) {
150
+ if (!targetWindow || targetWindow === global) return
151
+
152
+ var message = typeof data === 'string' ? data : JSON.stringify(data)
153
+ var origin = typeof targetOrigin === 'string' ? targetOrigin : '*'
154
+
155
+ targetWindow.postMessage(message, origin)
156
+ }
157
+ }
158
+ })(
159
+ typeof window !== 'undefined'
160
+ ? window
161
+ : typeof globalThis !== 'undefined'
162
+ ? globalThis
163
+ : typeof self !== 'undefined'
164
+ ? self
165
+ : this
166
166
  )
@@ -7,6 +7,7 @@ var FraudDetectionEventType = /* @__PURE__ */ ((FraudDetectionEventType2) => {
7
7
  FraudDetectionEventType2["FRAUD_DETECTION_TIMEOUT"] = "fraudDetection:timeout";
8
8
  FraudDetectionEventType2["FRAUD_DETECTION_LOAD_ERROR"] = "fraudDetection:loadError";
9
9
  FraudDetectionEventType2["FRAUD_DETECTION_WARNING"] = "fraudDetection:warning";
10
+ FraudDetectionEventType2["FRAUD_DETECTION_CDN"] = "fraudDetection:cdn";
10
11
  return FraudDetectionEventType2;
11
12
  })(FraudDetectionEventType || {});
12
13
  var ApplePayEventType = /* @__PURE__ */ ((ApplePayEventType2) => {
@@ -58,16 +59,15 @@ var SecurityIframeEventType = /* @__PURE__ */ ((SecurityIframeEventType2) => {
58
59
  SecurityIframeEventType2["SECURITY_IFRAME_LOAD_ERROR"] = "securityIframe:loadError";
59
60
  return SecurityIframeEventType2;
60
61
  })(SecurityIframeEventType || {});
61
- var LoggerEventType = /* @__PURE__ */ ((LoggerEventType2) => {
62
- LoggerEventType2["ENV"] = "logger:env";
63
- LoggerEventType2["BEHAVIOR"] = "logger:behavior";
64
- return LoggerEventType2;
65
- })(LoggerEventType || {});
62
+ var EnvEventType = /* @__PURE__ */ ((EnvEventType2) => {
63
+ EnvEventType2["ENV_INFO"] = "env:info";
64
+ return EnvEventType2;
65
+ })(EnvEventType || {});
66
66
  export {
67
67
  ApplePayEventType,
68
+ EnvEventType,
68
69
  FraudDetectionEventType,
69
70
  GooglePayEventType,
70
- LoggerEventType,
71
71
  PaymentEventType,
72
72
  SecurityIframeEventType,
73
73
  ThreeDSEventType,
@@ -0,0 +1,20 @@
1
+ const BASE64_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2
+ const encodeBase64 = (value, table = BASE64_TABLE) => {
3
+ try {
4
+ return btoa(value).split("").map((char) => char === "=" ? "" : table[BASE64_TABLE.indexOf(char)]).join("");
5
+ } catch {
6
+ return "";
7
+ }
8
+ };
9
+ const decodeBase64 = (value, table = BASE64_TABLE) => {
10
+ try {
11
+ const base64 = value.split("").map((char) => BASE64_TABLE[table.indexOf(char)] ?? "").join("");
12
+ return atob(base64 + "=".repeat((4 - base64.length % 4) % 4));
13
+ } catch {
14
+ return "";
15
+ }
16
+ };
17
+ export {
18
+ decodeBase64,
19
+ encodeBase64
20
+ };
@@ -4,7 +4,11 @@ const loadFingerprint = async () => {
4
4
  };
5
5
  let fingerPrint = "";
6
6
  const getFingerprint = async () => {
7
- return fingerPrint || (fingerPrint = (await loadFingerprint()).visitorId);
7
+ try {
8
+ return fingerPrint || (fingerPrint = (await loadFingerprint()).visitorId);
9
+ } catch {
10
+ return "";
11
+ }
8
12
  };
9
13
  export {
10
14
  getFingerprint