@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
package/dist/polyfill.js CHANGED
@@ -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
  )
@@ -1,2 +1,5 @@
1
1
  import { type RequestOptions } from '../../http';
2
- export declare const getMerchantSession: (options?: RequestOptions) => Promise<any>;
2
+ export declare const getMerchantSession: (params: {
3
+ merchantId?: string;
4
+ merchantProductId?: string;
5
+ }, options?: RequestOptions) => Promise<any>;
@@ -53,6 +53,8 @@ export interface ChannelParams {
53
53
  export interface CheckoutRes {
54
54
  /** 商户 ID */
55
55
  merchantId: string;
56
+ /** 产品 ID */
57
+ merchantProductId?: string;
56
58
  /** 支持的支付方式 */
57
59
  supportMethods: PaymentMethod[];
58
60
  /** 支付方式 */
@@ -26,4 +26,5 @@ export declare const reportUrls: (params: {
26
26
  clientKey: string;
27
27
  fraudDetectionMode?: string;
28
28
  data: string;
29
+ browser?: Recordable;
29
30
  }) => Promise<any>;
@@ -8,8 +8,8 @@ import type { DokuProps, DokuRef } from './type';
8
8
  export declare const Doku: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<DokuProps & import("../../../types").PayKKaCommonConfig & {
9
9
  session: import("../../../core").Session;
10
10
  core: import("../../../core").PayKKaCheckout;
11
- threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
12
- isDropIn?: boolean | undefined;
11
+ threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined; /** 表单是否验证通过 */
12
+ isDropIn?: boolean | undefined; /** 静默校验,校验表单但不展示错误提示,仅更新校验结果 */
13
13
  }> & {
14
14
  ref?: import("preact").Ref<DokuRef> | undefined;
15
15
  }>;
@@ -9,7 +9,7 @@ import './dragon-pay.scss';
9
9
  export declare const DragonPay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<DragonPayProps & import("../../../types").PayKKaCommonConfig & {
10
10
  session: import("../../../core").Session;
11
11
  core: import("../../../core").PayKKaCheckout;
12
- threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined; /** 设置表单引用时触发静默校验,避免表单引用初始化未完成时提前触发 */
12
+ threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
13
13
  isDropIn?: boolean | undefined;
14
14
  }> & {
15
15
  ref?: import("preact").Ref<DragonPayRef> | undefined;
@@ -7,7 +7,6 @@ import type { GoPayProps, GoPayRef } from './type';
7
7
  */
8
8
  export declare const GoPay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<GoPayProps & import("../../../types").PayKKaCommonConfig & {
9
9
  session: import("../../../core").Session;
10
- /** 静默校验,校验表单但不展示错误提示,仅更新校验结果 */
11
10
  core: import("../../../core").PayKKaCheckout;
12
11
  threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
13
12
  isDropIn?: boolean | undefined;
@@ -6,7 +6,7 @@ import type { IDealProps, IDealRef } from './type';
6
6
  * - 支付:跳转至银行页面完成支付
7
7
  */
8
8
  export declare const IDeal: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<IDealProps & import("../../../types").PayKKaCommonConfig & {
9
- session: import("../../../core").Session;
9
+ session: import("../../../core").Session; /** 表单数据 */
10
10
  core: import("../../../core").PayKKaCheckout;
11
11
  threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
12
12
  isDropIn?: boolean | undefined;
@@ -8,8 +8,8 @@ import type { LinkAjaProps, LinkAjaRef } from './type';
8
8
  export declare const LinkAja: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<LinkAjaProps & import("../../../types").PayKKaCommonConfig & {
9
9
  session: import("../../../core").Session;
10
10
  core: import("../../../core").PayKKaCheckout;
11
- threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined; /** 表单是否验证通过 */
12
- isDropIn?: boolean | undefined; /** 静默校验,校验表单但不展示错误提示,仅更新校验结果 */
11
+ threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
12
+ isDropIn?: boolean | undefined;
13
13
  }> & {
14
14
  ref?: import("preact").Ref<LinkAjaRef> | undefined;
15
15
  }>;
@@ -6,7 +6,6 @@ import type { MyBankProps, MyBankRef } from './type';
6
6
  * - 支付:跳转至 MyBank 页面完成支付
7
7
  */
8
8
  export declare const MyBank: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<MyBankProps & import("../../../types").PayKKaCommonConfig & {
9
- /** 表单数据 */
10
9
  session: import("../../../core").Session;
11
10
  core: import("../../../core").PayKKaCheckout;
12
11
  threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
@@ -9,7 +9,6 @@ import './online-banking-estonia.scss';
9
9
  export declare const OnlineBankingEstonia: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<OnlineBankingEstoniaProps & import("../../../types").PayKKaCommonConfig & {
10
10
  session: import("../../../core").Session;
11
11
  core: import("../../../core").PayKKaCheckout;
12
- /** 静默校验,校验表单但不展示错误提示,仅更新校验结果 */
13
12
  threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
14
13
  isDropIn?: boolean | undefined;
15
14
  }> & {
@@ -9,7 +9,6 @@ import './online-banking-finland.scss';
9
9
  export declare const OnlineBankingFinland: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<OnlineBankingFinlandProps & import("../../../types").PayKKaCommonConfig & {
10
10
  session: import("../../../core").Session;
11
11
  core: import("../../../core").PayKKaCheckout;
12
- /** 静默校验,校验表单但不展示错误提示,仅更新校验结果 */
13
12
  threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
14
13
  isDropIn?: boolean | undefined;
15
14
  }> & {
@@ -9,7 +9,7 @@ export declare const P24: import("preact").FunctionalComponent<import("preact/co
9
9
  session: import("../../../core").Session;
10
10
  core: import("../../../core").PayKKaCheckout;
11
11
  threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
12
- isDropIn?: boolean | undefined;
12
+ isDropIn?: boolean | undefined; /** 设置表单引用时触发静默校验,避免表单引用初始化未完成时提前触发 */
13
13
  }> & {
14
14
  ref?: import("preact").Ref<P24Ref> | undefined;
15
15
  }>;
@@ -8,7 +8,7 @@ import type { PayUProps, PayURef } from './type';
8
8
  export declare const PayU: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<PayUProps & import("../../../types").PayKKaCommonConfig & {
9
9
  session: import("../../../core").Session;
10
10
  core: import("../../../core").PayKKaCheckout;
11
- threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined; /** 表单是否验证通过 */
11
+ threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
12
12
  isDropIn?: boolean | undefined;
13
13
  }> & {
14
14
  ref?: import("preact").Ref<PayURef> | undefined;
@@ -7,7 +7,6 @@ import type { TwintProps, TwintRef } from './type';
7
7
  */
8
8
  export declare const Twint: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<TwintProps & import("../../../types").PayKKaCommonConfig & {
9
9
  session: import("../../../core").Session;
10
- /** 静默校验,校验表单但不展示错误提示,仅更新校验结果 */
11
10
  core: import("../../../core").PayKKaCheckout;
12
11
  threeDSFrame?: import("../../../types").ThreeDSFrameConfig | undefined;
13
12
  isDropIn?: boolean | undefined;
@@ -1,14 +1,3 @@
1
- /** 前端错误信息枚举,为了防止与后端 code 冲突做的区分 */
2
- export declare enum EPayKKaErrorReason {
3
- /** worldpay ddc 错误 */
4
- DDC_ERROR = "DDC_ERROR",
5
- /** worldpay ddc 超时 */
6
- DDC_TIMEOUT = "DDC_TIMEOUT",
7
- /** 欺诈检测数据转换错误 */
8
- FRAUD_DETECTION_ID_FORMAT_ERROR = "FRAUD_DETECTION_ID_FORMAT_ERROR",
9
- /** stripe radar 错误 */
10
- STRIPE_RADAR_ERROR = "STRIPE_RADAR_ERROR"
11
- }
12
1
  export declare enum EPayKKaError {
13
2
  /** 加载资源错误 */
14
3
  LOAD_ERROR = "LOAD_ERROR",
@@ -30,7 +19,7 @@ export declare class PayKKaError extends Error {
30
19
  code?: string;
31
20
  /** 错误原因 */
32
21
  cause?: any;
33
- constructor(type: keyof typeof EPayKKaError, msg?: string | EPayKKaErrorReason, info?: {
22
+ constructor(type: keyof typeof EPayKKaError, msg?: string, info?: {
34
23
  code?: string;
35
24
  cause?: any;
36
25
  });
@@ -7,7 +7,7 @@ import type { PayKKaError } from '../core';
7
7
  import { type EventData, type EventType, type PayKKaEnvType } from '../types';
8
8
  type LoggerCollect = 'ENV' | 'BEHAVIOR';
9
9
  interface LoggerOptions {
10
- /** 监控项目 id */
10
+ /** 监控项目 id,默认使用收银台组件 id */
11
11
  pid?: string;
12
12
  /** 监控会话 id */
13
13
  sid?: string;
@@ -36,6 +36,7 @@ export interface RequestLogInfo {
36
36
  export declare class PayKKaLogger {
37
37
  constructor();
38
38
  init(options?: LoggerOptions): Promise<void>;
39
+ private reportEnvInfo;
39
40
  /** 上报自定义事件 */
40
41
  reportCustomEvent(event: EventType, data?: EventData<EventType>): void;
41
42
  /** 上报错误 */
@@ -43,6 +44,9 @@ export declare class PayKKaLogger {
43
44
  /** 上报请求 */
44
45
  reportRequestEvent(request: RequestLogInfo): void;
45
46
  setLoggerOptions(options: Recordable): void;
47
+ private getTag;
48
+ /** 读取缓存中的设备指纹段,缓存缺失或损坏时返回空串 */
49
+ private getCachedFingerprint;
46
50
  /**
47
51
  * 在日志上报前执行,拦截部分日志上报
48
52
  * 1. 过滤接口日志,只上报收银台相关接口,用接口域名判断
@@ -6,7 +6,7 @@ import type { PaymentMethod } from '../constant';
6
6
  * 事件类型
7
7
  * 适用于埋点上报
8
8
  */
9
- export type EventType = FraudDetectionEventType | ApplePayEventType | GooglePayEventType | PaymentEventType | ThreeDSEventType | LoggerEventType | SecurityIframeEventType | WechatPayEventType;
9
+ export type EventType = FraudDetectionEventType | ApplePayEventType | GooglePayEventType | PaymentEventType | ThreeDSEventType | SecurityIframeEventType | WechatPayEventType | EnvEventType;
10
10
  export type EventData<T extends EventType> = EventDataMapping[T];
11
11
  /** fraud detection 事件类型 */
12
12
  export declare enum FraudDetectionEventType {
@@ -25,7 +25,9 @@ export declare enum FraudDetectionEventType {
25
25
  /** fraud detection 加载失败 */
26
26
  FRAUD_DETECTION_LOAD_ERROR = "fraudDetection:loadError",
27
27
  /** fraud detection 警告事件 */
28
- FRAUD_DETECTION_WARNING = "fraudDetection:warning"
28
+ FRAUD_DETECTION_WARNING = "fraudDetection:warning",
29
+ /** fraud detection CDN 脚本环境标识 */
30
+ FRAUD_DETECTION_CDN = "fraudDetection:cdn"
29
31
  }
30
32
  export declare enum ApplePayEventType {
31
33
  /** Apple Pay 环境检测失败 */
@@ -101,11 +103,10 @@ export declare enum SecurityIframeEventType {
101
103
  /** 安全 iframe 加载失败 */
102
104
  SECURITY_IFRAME_LOAD_ERROR = "securityIframe:loadError"
103
105
  }
104
- export declare enum LoggerEventType {
105
- /** 设备 */
106
- ENV = "logger:env",
107
- /** 行为 */
108
- BEHAVIOR = "logger:behavior"
106
+ /** 组件运行环境事件类型 */
107
+ export declare enum EnvEventType {
108
+ /** 组件初始化时的运行环境信息 */
109
+ ENV_INFO = "env:info"
109
110
  }
110
111
  export interface EventDataMapping {
111
112
  [FraudDetectionEventType.FRAUD_DETECTION_TRANSFORM_ERROR]: undefined;
@@ -116,6 +117,7 @@ export interface EventDataMapping {
116
117
  [FraudDetectionEventType.FRAUD_DETECTION_ERROR]: FraudDetectionErrorData;
117
118
  [FraudDetectionEventType.FRAUD_DETECTION_TIMEOUT]: FraudDetectionBaseData;
118
119
  [FraudDetectionEventType.FRAUD_DETECTION_WARNING]: FraudDetectionBaseData & CommonEventData;
120
+ [FraudDetectionEventType.FRAUD_DETECTION_CDN]: undefined;
119
121
  [ApplePayEventType.APPLE_PAY_LOAD_ERROR]: undefined;
120
122
  [ApplePayEventType.APPLE_PAY_CAN_NOT_USE]: undefined;
121
123
  [ApplePayEventType.APPLE_PAY_BUTTON_CLICKED]: undefined;
@@ -143,16 +145,26 @@ export interface EventDataMapping {
143
145
  [ThreeDSEventType.THREE_DS_INNER_CHANNEL]: undefined;
144
146
  [SecurityIframeEventType.SECURITY_IFRAME_LOADED]: SecurityIframeBaseData;
145
147
  [SecurityIframeEventType.SECURITY_IFRAME_LOAD_ERROR]: SecurityIframeBaseData;
146
- [LoggerEventType.ENV]: Recordable;
147
- [LoggerEventType.BEHAVIOR]: Recordable;
148
148
  [WechatPayEventType.WECHAT_PAY_START]: undefined;
149
149
  [WechatPayEventType.WECHAT_PAY_SUCCESS]: undefined;
150
150
  [WechatPayEventType.WECHAT_PAY_FAILURE]: CommonEventData;
151
151
  [WechatPayEventType.WECHAT_PAY_CANCELLED]: undefined;
152
+ [EnvEventType.ENV_INFO]: EnvInfoData;
152
153
  }
153
154
  export interface CommonEventData {
154
155
  message?: string;
155
156
  }
157
+ /** 组件运行环境信息,key 使用缩写,与 logger 的 url 参数风格保持一致 */
158
+ export interface EnvInfoData {
159
+ /** 接入方式 */
160
+ itg: string;
161
+ /** 构建环境 */
162
+ benv: string;
163
+ /** 是否运行在 iframe 中 */
164
+ ifr: boolean;
165
+ /** 组件版本 */
166
+ v: string;
167
+ }
156
168
  export interface FraudDetectionBaseData {
157
169
  /** 当前渠道 */
158
170
  channel: ChannelCode;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Base64 编解码
3
+ * 默认使用标准字母表;传入一张置换后的字母表即可得到私有变体,编解码必须传同一张表
4
+ */
5
+ /**
6
+ * 将字符串编码为 Base64
7
+ * @params value 原始字符串
8
+ * @params table 字母表,需为 64 个互不重复的字符;默认标准字母表
9
+ * @returns 编码结果(不含填充),编码失败返回空串
10
+ */
11
+ export declare const encodeBase64: (value: string, table?: string) => string;
12
+ /**
13
+ * 将 Base64 字符串解码
14
+ * @params value Base64 字符串
15
+ * @params table 编码时使用的同一张字母表;默认标准字母表
16
+ * @returns 解码结果,解码失败返回空串
17
+ */
18
+ export declare const decodeBase64: (value: string, table?: string) => string;
@@ -10,6 +10,7 @@ export * from './iframe';
10
10
  export * from './location';
11
11
  export * from './redirect';
12
12
  export * from './array';
13
+ export * from './base64';
13
14
  export * from './detect';
14
15
  export * from './date';
15
16
  export * from './object';