@paykka/card-checkout-ui 0.21.2 → 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.
- package/dist/card-checkout-ui.js +14 -14
- package/dist/card-checkout-ui.umd.cjs +14 -14
- package/dist/es/api/modules/apple-pay/index.js +4 -1
- package/dist/es/api/modules/checkout/map.js +1 -0
- package/dist/es/api/modules/get-browser-params.js +1 -1
- package/dist/es/api/modules/risk/index.js +2 -1
- package/dist/es/components/ApplePay/index.js +9 -5
- package/dist/es/core/logger.js +44 -1
- package/dist/es/index.js +2 -2
- package/dist/es/out/fraud-detection.js +26 -3
- package/dist/es/out/paykka-detection.js +2 -0
- package/dist/es/types/event.js +6 -6
- package/dist/es/utils/base64.js +20 -0
- package/dist/es/utils/system-info/finger-print.js +5 -1
- package/dist/types/api/modules/apple-pay/index.d.ts +1 -0
- package/dist/types/api/modules/checkout/type.d.ts +2 -0
- package/dist/types/api/modules/risk/index.d.ts +1 -0
- package/dist/types/core/error.d.ts +1 -12
- package/dist/types/core/logger.d.ts +5 -1
- package/dist/types/types/event.d.ts +21 -9
- package/dist/types/utils/base64.d.ts +18 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +5 -1
|
@@ -3,7 +3,10 @@ import { http } from "../../http.js";
|
|
|
3
3
|
const getMerchantSession = async (params, options) => {
|
|
4
4
|
return http.post(
|
|
5
5
|
`${apiPrefix}/apple-pay/create-session`,
|
|
6
|
-
{
|
|
6
|
+
{
|
|
7
|
+
merchant_id: params.merchantId,
|
|
8
|
+
merchant_product_id: params.merchantProductId
|
|
9
|
+
},
|
|
7
10
|
options
|
|
8
11
|
);
|
|
9
12
|
};
|
|
@@ -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.
|
|
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 {
|
|
@@ -368,12 +368,16 @@ const ApplePay = w((props) => {
|
|
|
368
368
|
initApplePaySession({
|
|
369
369
|
request,
|
|
370
370
|
onValidate: async () => {
|
|
371
|
-
var _a2
|
|
371
|
+
var _a2;
|
|
372
372
|
onEvent == null ? void 0 : onEvent(ApplePayEventType.APPLE_PAY_VALIDATE_MERCHANT);
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
+
});
|
|
380
|
+
(_a2 = applePaySession.current) == null ? void 0 : _a2.completeMerchantValidation(merchantSession);
|
|
377
381
|
},
|
|
378
382
|
onAuthorized: async (event) => {
|
|
379
383
|
var _a2;
|
package/dist/es/core/logger.js
CHANGED
|
@@ -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.
|
|
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,
|
|
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,
|
|
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
|
|
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",
|
|
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;
|
package/dist/es/types/event.js
CHANGED
|
@@ -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
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
7
|
+
try {
|
|
8
|
+
return fingerPrint || (fingerPrint = (await loadFingerprint()).visitorId);
|
|
9
|
+
} catch {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
8
12
|
};
|
|
9
13
|
export {
|
|
10
14
|
getFingerprint
|
|
@@ -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
|
|
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 |
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paykka/card-checkout-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/paykka-card-checkout-ui.umd.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
"changeset:pre-exit": "changeset pre exit",
|
|
35
35
|
"changeset:version": "changeset version",
|
|
36
36
|
"changeset:release": "changeset publish",
|
|
37
|
+
"version:dev": "node scripts/version.cjs dev",
|
|
38
|
+
"version:fat": "node scripts/version.cjs fat",
|
|
39
|
+
"version:sandbox": "node scripts/version.cjs sandbox",
|
|
40
|
+
"version:prod": "node scripts/version.cjs prod",
|
|
37
41
|
"release:dev": "node scripts/release.cjs dev",
|
|
38
42
|
"release:fat": "node scripts/release.cjs fat",
|
|
39
43
|
"release:sandbox": "node scripts/release.cjs sandbox",
|