@alipay/ams-checkout 1.5.8 → 1.5.9
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 +4 -4
- 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.js +2 -2
- package/esm/plugin/component/index.d.ts +9 -2
- package/esm/plugin/component/index.js +379 -170
- 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/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 +96 -73
- package/package.json +1 -1
package/esm/util/security.js
CHANGED
@@ -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.9","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":{"@alipay/jshield-apdid":"^2.0.3","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"}}
|