@alipay/ams-checkout 1.5.8 → 1.5.10
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/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +1 -1
- package/esm/config/index.js +1 -1
- package/esm/constant/index.d.ts +13 -0
- package/esm/constant/index.js +13 -0
- package/esm/core/component/index.js +5 -2
- package/esm/core/instance/index.d.ts +13 -1
- package/esm/core/instance/index.js +76 -3
- package/esm/plugin/component/cashierApp.d.ts +4 -1
- package/esm/plugin/component/cashierApp.js +6 -3
- package/esm/plugin/component/index.d.ts +10 -3
- package/esm/plugin/component/index.js +396 -184
- package/esm/plugin/component/popupWindow.style.d.ts +6 -0
- package/esm/plugin/component/popupWindow.style.js +54 -0
- package/esm/request/index.d.ts +2 -1
- package/esm/request/index.js +57 -34
- package/esm/service/index.d.ts +9 -1
- package/esm/service/index.js +4 -3
- package/esm/types/index.d.ts +43 -5
- package/esm/types/index.js +13 -0
- package/esm/util/jshield-apdid/apdid-core.umd.min.js +1 -0
- package/esm/util/logger.d.ts +55 -0
- package/esm/util/logger.js +177 -0
- package/esm/util/security.d.ts +6 -3
- package/esm/util/security.js +97 -74
- package/package.json +1 -1
@@ -0,0 +1,55 @@
|
|
1
|
+
interface LogPayload {
|
2
|
+
title?: string;
|
3
|
+
msg?: string;
|
4
|
+
name?: string;
|
5
|
+
label?: string;
|
6
|
+
time?: number;
|
7
|
+
success?: boolean;
|
8
|
+
code?: string;
|
9
|
+
traceId?: string;
|
10
|
+
}
|
11
|
+
type Extra = Record<string, string>;
|
12
|
+
export interface LogMetaData {
|
13
|
+
platform?: string;
|
14
|
+
sdkVersion?: string;
|
15
|
+
fistLogTime?: number;
|
16
|
+
fsDuration?: number;
|
17
|
+
instanceId?: string;
|
18
|
+
storageId?: string;
|
19
|
+
renderDisplayType?: string;
|
20
|
+
merchantId?: string;
|
21
|
+
productScene?: string;
|
22
|
+
productSceneVersion?: string;
|
23
|
+
paymentMethodType?: string;
|
24
|
+
paymentMethodCategoryType?: string;
|
25
|
+
}
|
26
|
+
interface Config {
|
27
|
+
scriptUrl: string;
|
28
|
+
spmConfig: object;
|
29
|
+
appId: string;
|
30
|
+
server?: string;
|
31
|
+
bizType: string;
|
32
|
+
batchCount: number;
|
33
|
+
productId: string;
|
34
|
+
mdata?: LogMetaData;
|
35
|
+
version?: string;
|
36
|
+
}
|
37
|
+
export declare class Logger {
|
38
|
+
private logs;
|
39
|
+
private config;
|
40
|
+
private debug;
|
41
|
+
private componentStartTime;
|
42
|
+
private isLoaded;
|
43
|
+
constructor(config: Config, debug: boolean);
|
44
|
+
setMedta(mdata: LogMetaData): void;
|
45
|
+
logError(error: LogPayload, extra?: Extra): Logger;
|
46
|
+
logInfo(info: LogPayload, extra?: Extra): Logger;
|
47
|
+
reportRPC(rpcData: LogPayload, extra?: Extra): Logger;
|
48
|
+
reportLogs(): void;
|
49
|
+
loadScript(url: string, callback: () => void): void;
|
50
|
+
initTracker(): void;
|
51
|
+
send(): void;
|
52
|
+
setComponentStartTime(val: number): void;
|
53
|
+
}
|
54
|
+
export declare const LogConfig: Config;
|
55
|
+
export {};
|
@@ -0,0 +1,177 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
9
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
10
|
+
export var Logger = /*#__PURE__*/function () {
|
11
|
+
function Logger(config, debug) {
|
12
|
+
_classCallCheck(this, Logger);
|
13
|
+
_defineProperty(this, "logs", void 0);
|
14
|
+
_defineProperty(this, "config", void 0);
|
15
|
+
_defineProperty(this, "debug", void 0);
|
16
|
+
_defineProperty(this, "componentStartTime", void 0);
|
17
|
+
_defineProperty(this, "isLoaded", void 0);
|
18
|
+
this.logs = [];
|
19
|
+
this.config = config;
|
20
|
+
this.debug = debug;
|
21
|
+
this.componentStartTime = 0;
|
22
|
+
this.isLoaded = false;
|
23
|
+
}
|
24
|
+
_createClass(Logger, [{
|
25
|
+
key: "setMedta",
|
26
|
+
value: function setMedta(mdata) {
|
27
|
+
var _window,
|
28
|
+
_this = this;
|
29
|
+
this.config.mdata = Object.assign(this.config.mdata, mdata);
|
30
|
+
if ((_window = window) !== null && _window !== void 0 && _window.iTracker) {
|
31
|
+
var _window2;
|
32
|
+
(_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.iTracker) === null || _window2 === void 0 || _window2.set(this.config.mdata);
|
33
|
+
setTimeout(function () {
|
34
|
+
_this.reportLogs();
|
35
|
+
}, 80);
|
36
|
+
} else {
|
37
|
+
this.initTracker();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}, {
|
41
|
+
key: "logError",
|
42
|
+
value: function logError(error, extra) {
|
43
|
+
this.logs.push({
|
44
|
+
type: 'error',
|
45
|
+
logPayload: error,
|
46
|
+
extra: extra
|
47
|
+
});
|
48
|
+
if (this.debug) {
|
49
|
+
console.error(error);
|
50
|
+
}
|
51
|
+
return this;
|
52
|
+
}
|
53
|
+
}, {
|
54
|
+
key: "logInfo",
|
55
|
+
value: function logInfo(info, extra) {
|
56
|
+
this.logs.push({
|
57
|
+
type: 'info',
|
58
|
+
logPayload: info,
|
59
|
+
extra: extra
|
60
|
+
});
|
61
|
+
if (this.debug) {
|
62
|
+
console.log(info);
|
63
|
+
}
|
64
|
+
return this;
|
65
|
+
}
|
66
|
+
}, {
|
67
|
+
key: "reportRPC",
|
68
|
+
value: function reportRPC(rpcData, extra) {
|
69
|
+
this.logs.push({
|
70
|
+
type: 'rpc',
|
71
|
+
logPayload: rpcData,
|
72
|
+
extra: extra
|
73
|
+
});
|
74
|
+
if (this.debug) {
|
75
|
+
console.log(rpcData);
|
76
|
+
}
|
77
|
+
return this;
|
78
|
+
}
|
79
|
+
}, {
|
80
|
+
key: "reportLogs",
|
81
|
+
value: function reportLogs() {
|
82
|
+
var _window3;
|
83
|
+
if (!((_window3 = window) !== null && _window3 !== void 0 && _window3.iTracker)) {
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
var _window$iTracker = window.iTracker,
|
87
|
+
logError = _window$iTracker.logError,
|
88
|
+
logInfo = _window$iTracker.logInfo,
|
89
|
+
reportRPC = _window$iTracker.reportRPC;
|
90
|
+
var logs = this.logs;
|
91
|
+
var now = Date.now();
|
92
|
+
var fsDuration = now - this.componentStartTime;
|
93
|
+
while (logs.length > 0) {
|
94
|
+
try {
|
95
|
+
var log = logs.pop();
|
96
|
+
if (log.type === 'error') {
|
97
|
+
logError(log.logPayload, _objectSpread({
|
98
|
+
fsDuration: fsDuration,
|
99
|
+
timeStamp: now
|
100
|
+
}, log === null || log === void 0 ? void 0 : log.extra));
|
101
|
+
} else if (log.type === 'info') {
|
102
|
+
logInfo(log.logPayload, _objectSpread({
|
103
|
+
fsDuration: fsDuration,
|
104
|
+
timeStamp: now
|
105
|
+
}, log === null || log === void 0 ? void 0 : log.extra));
|
106
|
+
} else if (log.type === 'rpc') {
|
107
|
+
reportRPC(log.logPayload, _objectSpread({
|
108
|
+
fsDuration: fsDuration,
|
109
|
+
timeStamp: now
|
110
|
+
}, log === null || log === void 0 ? void 0 : log.extra));
|
111
|
+
}
|
112
|
+
} catch (error) {
|
113
|
+
console.error('Error occurred while calling iTracker method:', error);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}, {
|
118
|
+
key: "loadScript",
|
119
|
+
value: function loadScript(url, callback) {
|
120
|
+
var script = document.createElement('script');
|
121
|
+
script.type = 'text/javascript';
|
122
|
+
script.src = url;
|
123
|
+
script.onload = callback;
|
124
|
+
script.onerror = function () {
|
125
|
+
console.error("unable to load Antom script: ".concat(url));
|
126
|
+
};
|
127
|
+
document.body.appendChild(script);
|
128
|
+
}
|
129
|
+
}, {
|
130
|
+
key: "initTracker",
|
131
|
+
value: function initTracker() {
|
132
|
+
var _this2 = this;
|
133
|
+
if (this.isLoaded) return;
|
134
|
+
this.isLoaded = true;
|
135
|
+
this.loadScript(this.config.scriptUrl, function () {
|
136
|
+
try {
|
137
|
+
var _window4;
|
138
|
+
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(_this2.config);
|
139
|
+
setTimeout(function () {
|
140
|
+
_this2.reportLogs();
|
141
|
+
}, 80);
|
142
|
+
} catch (error) {
|
143
|
+
console.error('Failed to initialize iTracker:', error);
|
144
|
+
}
|
145
|
+
});
|
146
|
+
}
|
147
|
+
}, {
|
148
|
+
key: "send",
|
149
|
+
value: function send() {
|
150
|
+
var _window5;
|
151
|
+
if ((_window5 = window) !== null && _window5 !== void 0 && _window5.iTracker) {
|
152
|
+
this.reportLogs();
|
153
|
+
} else {
|
154
|
+
this.initTracker();
|
155
|
+
}
|
156
|
+
}
|
157
|
+
}, {
|
158
|
+
key: "setComponentStartTime",
|
159
|
+
value: function setComponentStartTime(val) {
|
160
|
+
this.componentStartTime = val;
|
161
|
+
}
|
162
|
+
}]);
|
163
|
+
return Logger;
|
164
|
+
}();
|
165
|
+
export var LogConfig = {
|
166
|
+
scriptUrl: 'https://gw.alipayobjects.com/render/p/yuyan_npm/@alipay_intl-tracker/1.6.0/dist/common.min.js',
|
167
|
+
spmConfig: {},
|
168
|
+
batchCount: 1,
|
169
|
+
appId: 'antom_sdk',
|
170
|
+
server: 'https://imdap-sea.alipay.com/loggw/dwcookieLogGet.do',
|
171
|
+
bizType: 'antom_sdk',
|
172
|
+
productId: 'ANTOM_SDK',
|
173
|
+
version: 'iteration/20231021',
|
174
|
+
mdata: {
|
175
|
+
fistLogTime: Date.now()
|
176
|
+
}
|
177
|
+
};
|
package/esm/util/security.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { IpaymentSecurityConfig, IsecurityConfig } from '../types';
|
1
2
|
export declare const securityHost: {
|
2
3
|
SG: string;
|
3
4
|
US: string;
|
@@ -5,8 +6,10 @@ export declare const securityHost: {
|
|
5
6
|
};
|
6
7
|
export declare const getSecurityHost: (region: string) => string;
|
7
8
|
export declare const appName: {
|
8
|
-
|
9
|
-
|
9
|
+
CARD: string;
|
10
|
+
EASYPAY: string;
|
10
11
|
};
|
12
|
+
export declare const initAPSecurity: (securityConfig: IsecurityConfig, successCallback: any, failCallback: any) => void;
|
13
|
+
export declare const initSecuritySDK: (appName: string, h5gateway: string, successCallback: () => void, failCallback: (errMsg?: string) => void) => void;
|
11
14
|
export declare const getAppname: (scene: string) => string;
|
12
|
-
export declare const getApdidToken: (scene: string,
|
15
|
+
export declare const getApdidToken: (scene: string, securityConfig?: IpaymentSecurityConfig) => Promise<string>;
|
package/esm/util/security.js
CHANGED
@@ -2,7 +2,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
2
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
3
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
4
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
5
|
-
import APDID from
|
5
|
+
import APDID from "./jshield-apdid/apdid-core.umd.min";
|
6
6
|
export var securityHost = {
|
7
7
|
SG: 'https://open-sea-global.alipay.com/api/open/risk_client',
|
8
8
|
US: 'https://open-na-global.alipay.com/api/open/risk_client',
|
@@ -12,83 +12,106 @@ export var getSecurityHost = function getSecurityHost(region) {
|
|
12
12
|
return securityHost[region] || '';
|
13
13
|
};
|
14
14
|
export var appName = {
|
15
|
-
|
16
|
-
|
15
|
+
CARD: 'Acquirer',
|
16
|
+
EASYPAY: 'EasyPay'
|
17
|
+
};
|
18
|
+
export var initAPSecurity = function initAPSecurity(securityConfig, successCallback, failCallback) {
|
19
|
+
if (!securityConfig || !(securityConfig !== null && securityConfig !== void 0 && securityConfig.scene) || !(securityConfig !== null && securityConfig !== void 0 && securityConfig.region)) {
|
20
|
+
throw new Error('securityConfig parameter error');
|
21
|
+
}
|
22
|
+
var curAppName = getAppname(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.scene);
|
23
|
+
var h5gateway = getSecurityHost(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.region);
|
24
|
+
if (!curAppName || !h5gateway) {
|
25
|
+
throw new Error("appName:".concat(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.scene, " or region:").concat(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.region, " do not supported"));
|
26
|
+
}
|
27
|
+
initSecuritySDK(curAppName, h5gateway, successCallback, failCallback);
|
28
|
+
};
|
29
|
+
export var initSecuritySDK = function initSecuritySDK(appName, h5gateway, successCallback, failCallback) {
|
30
|
+
try {
|
31
|
+
APDID === null || APDID === void 0 || APDID.initToken(appName, {
|
32
|
+
host: h5gateway
|
33
|
+
}, function (success, tokenResult, msg) {
|
34
|
+
if (success) {
|
35
|
+
successCallback && successCallback();
|
36
|
+
} else {
|
37
|
+
failCallback && failCallback(msg);
|
38
|
+
}
|
39
|
+
console.log('initToken result tokenResult', JSON.stringify(tokenResult), msg);
|
40
|
+
});
|
41
|
+
} catch (error) {
|
42
|
+
failCallback && failCallback();
|
43
|
+
}
|
17
44
|
};
|
18
45
|
export var getAppname = function getAppname(scene) {
|
19
46
|
return appName[scene] || '';
|
20
47
|
};
|
21
|
-
export var getApdidToken =
|
22
|
-
var
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
case 0:
|
45
|
-
_context.next = 2;
|
46
|
-
return tryGetDeviceId(scene);
|
47
|
-
case 2:
|
48
|
-
deviceId = _context.sent;
|
49
|
-
if (deviceId) {
|
50
|
-
clearInterval(interval);
|
51
|
-
resolve(deviceId);
|
52
|
-
}
|
53
|
-
case 4:
|
54
|
-
case "end":
|
55
|
-
return _context.stop();
|
56
|
-
}
|
57
|
-
}, _callee);
|
58
|
-
})), 1000);
|
59
|
-
setTimeout(function () {
|
48
|
+
export var getApdidToken = function getApdidToken(scene, securityConfig) {
|
49
|
+
var tokenCollectTime = parseInt((securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.tokenCollectTime) || '1500', 10);
|
50
|
+
var dataPollingInterval = parseInt((securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.dataPollingInterval) || '500', 10);
|
51
|
+
var asyncFunc = /*#__PURE__*/function () {
|
52
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
|
53
|
+
var deviceId, interval, polling;
|
54
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
55
|
+
while (1) switch (_context2.prev = _context2.next) {
|
56
|
+
case 0:
|
57
|
+
_context2.next = 2;
|
58
|
+
return tryGetDeviceId(scene);
|
59
|
+
case 2:
|
60
|
+
deviceId = _context2.sent;
|
61
|
+
polling = /*#__PURE__*/function () {
|
62
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
63
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
64
|
+
while (1) switch (_context.prev = _context.next) {
|
65
|
+
case 0:
|
66
|
+
_context.next = 2;
|
67
|
+
return tryGetDeviceId(scene);
|
68
|
+
case 2:
|
69
|
+
deviceId = _context.sent;
|
70
|
+
if (deviceId) {
|
60
71
|
clearInterval(interval);
|
61
|
-
resolve(
|
62
|
-
}
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
};
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
72
|
+
resolve(deviceId);
|
73
|
+
}
|
74
|
+
case 4:
|
75
|
+
case "end":
|
76
|
+
return _context.stop();
|
77
|
+
}
|
78
|
+
}, _callee);
|
79
|
+
}));
|
80
|
+
return function polling() {
|
81
|
+
return _ref2.apply(this, arguments);
|
82
|
+
};
|
83
|
+
}();
|
84
|
+
if (deviceId) {
|
85
|
+
resolve(deviceId);
|
86
|
+
} else {
|
87
|
+
interval = setInterval(polling, dataPollingInterval);
|
88
|
+
setTimeout(function () {
|
89
|
+
clearInterval(interval);
|
90
|
+
resolve('');
|
91
|
+
}, tokenCollectTime);
|
92
|
+
}
|
93
|
+
case 5:
|
94
|
+
case "end":
|
95
|
+
return _context2.stop();
|
96
|
+
}
|
97
|
+
}, _callee2);
|
98
|
+
}));
|
99
|
+
return function asyncFunc(_x) {
|
100
|
+
return _ref.apply(this, arguments);
|
101
|
+
};
|
102
|
+
}();
|
103
|
+
return new Promise(function (resolve) {
|
104
|
+
asyncFunc(resolve);
|
105
|
+
});
|
106
|
+
};
|
84
107
|
var tryGetDeviceId = /*#__PURE__*/function () {
|
85
|
-
var
|
86
|
-
return _regeneratorRuntime().wrap(function
|
87
|
-
while (1) switch (
|
108
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(scene) {
|
109
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
110
|
+
while (1) switch (_context3.prev = _context3.next) {
|
88
111
|
case 0:
|
89
|
-
return
|
112
|
+
return _context3.abrupt("return", new Promise(function (resolve) {
|
90
113
|
try {
|
91
|
-
APDID.getApdidToken(scene, function (tokenResult) {
|
114
|
+
APDID === null || APDID === void 0 || APDID.getApdidToken(scene, function (tokenResult) {
|
92
115
|
resolve(tokenResult === null || tokenResult === void 0 ? void 0 : tokenResult.token);
|
93
116
|
});
|
94
117
|
} catch (error) {
|
@@ -97,11 +120,11 @@ var tryGetDeviceId = /*#__PURE__*/function () {
|
|
97
120
|
}));
|
98
121
|
case 1:
|
99
122
|
case "end":
|
100
|
-
return
|
123
|
+
return _context3.stop();
|
101
124
|
}
|
102
|
-
},
|
125
|
+
}, _callee3);
|
103
126
|
}));
|
104
|
-
return function tryGetDeviceId(
|
105
|
-
return
|
127
|
+
return function tryGetDeviceId(_x2) {
|
128
|
+
return _ref3.apply(this, arguments);
|
106
129
|
};
|
107
130
|
}();
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@alipay/ams-checkout","version":"1.5.
|
1
|
+
{"name":"@alipay/ams-checkout","version":"1.5.10","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
|