@alipay/ams-checkout 0.0.1783663570-dev.6 → 0.0.1784095668-dev.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/ams-checkout.js +3 -4
- package/dist/ams-checkout.min.js +1 -2
- package/esm/config/index.d.ts +0 -7
- package/esm/config/index.js +2 -2
- package/esm/constant/element.d.ts +1 -2
- package/esm/constant/element.js +0 -1
- package/esm/constant/index.d.ts +21 -4
- package/esm/core/component/element/elementController/index.d.ts +3 -3
- package/esm/core/component/element/elementController/index.js +42 -66
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +10 -13
- package/esm/core/component/element/index.d.ts +1 -4
- package/esm/core/component/element/index.js +4 -19
- package/esm/core/component/element/type.d.ts +18 -16
- package/esm/core/instance/index.d.ts +4 -12
- package/esm/core/instance/index.js +26 -152
- package/esm/foundation/service/event-center.js +1 -1
- package/esm/foundation/service/security/index.d.ts +4 -9
- package/esm/foundation/service/security/index.js +35 -158
- package/esm/foundation/service/security/security.d.ts +1 -22
- package/esm/foundation/service/security/security.js +37 -150
- package/esm/foundation/utils/preload_helper.d.ts +3 -6
- package/esm/foundation/utils/preload_helper.js +32 -122
- package/esm/main.js +4 -4
- package/esm/modern/index.d.ts +1 -5
- package/esm/modern/index.js +51 -1
- package/esm/modern/stageName.d.ts +3 -0
- package/esm/modern/stageName.js +1 -0
- package/esm/plugin/component/channel.d.ts +2 -2
- package/esm/plugin/component/channel.js +18 -18
- package/esm/plugin/component/index.js +29 -36
- package/esm/types/index.d.ts +0 -1
- package/esm/util/beforeConfirm.d.ts +2 -4
- package/esm/util/beforeConfirm.js +14 -15
- package/esm/util/logger.js +2 -1
- package/esm/util/security.d.ts +1 -22
- package/esm/util/security.js +39 -150
- package/package.json +9 -15
- package/types.d.ts +94 -785
- package/types.untrimmed.d.ts +108 -929
- package/dist/ams-checkout.min.js.map +0 -1
- package/esm/core/component/element/modernElementController/adapter.d.ts +0 -19
- package/esm/core/component/element/modernElementController/adapter.js +0 -73
- package/esm/core/component/element/modernElementController/index.d.ts +0 -149
- package/esm/core/component/element/modernElementController/index.js +0 -1665
- package/esm/modern/global.d.ts +0 -3
- package/esm/modern/tools.js +0 -1
- package/esm/util/jshield-apdid/apdid-loader.js +0 -340
- package/esm/util/jshield-apdid/index.js +0 -21
- package/esm/util/security-registry.d.ts +0 -72
- package/esm/util/security-registry.js +0 -175
package/esm/util/security.js
CHANGED
|
@@ -9,7 +9,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
9
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
11
|
import { ProductSceneEnum } from "../types";
|
|
12
|
-
import
|
|
12
|
+
import APDID from "./jshield-apdid/apdid-core.umd.min";
|
|
13
13
|
export var getSecurityConfigStorageKey = function getSecurityConfigStorageKey(scene) {
|
|
14
14
|
return "AMSSDK_SECURITY_CONFIG_".concat(scene);
|
|
15
15
|
};
|
|
@@ -29,110 +29,21 @@ export var getSecurityHost = function getSecurityHost(region) {
|
|
|
29
29
|
return securityHost[region] || securityHost[SecurityRegionEnum.SG];
|
|
30
30
|
};
|
|
31
31
|
export var getSecurityScene = function getSecurityScene(product) {
|
|
32
|
+
console.log('getSecurityScene', product);
|
|
32
33
|
return sceneMap[product] || '';
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Map SDK environment string to ApdidEnvironment for CDN URL selection.
|
|
37
|
-
*/
|
|
38
|
-
export var mapEnvironment = function mapEnvironment(env) {
|
|
39
|
-
if (!env) return 'production';
|
|
40
|
-
var lower = env.toLowerCase();
|
|
41
|
-
if (lower === 'pre' || lower === 'light_sandbox') return 'pre';
|
|
42
|
-
if (lower === 'dev' || lower === 'test' || lower === 'local') return 'dev';
|
|
43
|
-
return 'production';
|
|
44
|
-
};
|
|
45
35
|
export var Security = /*#__PURE__*/function () {
|
|
46
36
|
function Security(options) {
|
|
47
37
|
_classCallCheck(this, Security);
|
|
48
38
|
_defineProperty(this, "scene", void 0);
|
|
49
39
|
_defineProperty(this, "h5gateway", void 0);
|
|
50
|
-
_defineProperty(this, "environment", void 0);
|
|
51
|
-
_defineProperty(this, "apdidLoaded", false);
|
|
52
|
-
_defineProperty(this, "apdidLoadFailed", false);
|
|
53
40
|
this.scene = options.scene;
|
|
54
41
|
this.h5gateway = options.h5gateway || securityHost[SecurityRegionEnum.SG];
|
|
55
|
-
this.environment = options.environment;
|
|
56
42
|
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Ensure the apdid-core script is loaded async.
|
|
60
|
-
* Returns true if loaded successfully, false otherwise.
|
|
61
|
-
* On failure, sets apdidLoadFailed flag for graceful degradation.
|
|
62
|
-
*/
|
|
63
43
|
_createClass(Security, [{
|
|
64
|
-
key: "ensureApdidLoaded",
|
|
65
|
-
value: (function () {
|
|
66
|
-
var _ensureApdidLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
67
|
-
var loader, apdidEnv;
|
|
68
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
69
|
-
while (1) switch (_context.prev = _context.next) {
|
|
70
|
-
case 0:
|
|
71
|
-
if (!this.apdidLoaded) {
|
|
72
|
-
_context.next = 2;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
return _context.abrupt("return", true);
|
|
76
|
-
case 2:
|
|
77
|
-
if (!this.apdidLoadFailed) {
|
|
78
|
-
_context.next = 4;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
return _context.abrupt("return", false);
|
|
82
|
-
case 4:
|
|
83
|
-
loader = ApdidLoader.getInstance();
|
|
84
|
-
apdidEnv = mapEnvironment(this.environment);
|
|
85
|
-
_context.prev = 6;
|
|
86
|
-
_context.next = 9;
|
|
87
|
-
return loader.load({
|
|
88
|
-
environment: apdidEnv,
|
|
89
|
-
callbacks: {
|
|
90
|
-
onLoad: function onLoad(duration) {
|
|
91
|
-
console.log("[Security] apdid-core script loaded in ".concat(duration, "ms"));
|
|
92
|
-
},
|
|
93
|
-
onLoadFailed: function onLoadFailed(error) {
|
|
94
|
-
console.error('[Security] apdid-core script load failed:', error.message);
|
|
95
|
-
},
|
|
96
|
-
onLoadTimeout: function onLoadTimeout() {
|
|
97
|
-
console.error('[Security] apdid-core script load timeout');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
case 9:
|
|
102
|
-
this.apdidLoaded = true;
|
|
103
|
-
return _context.abrupt("return", true);
|
|
104
|
-
case 13:
|
|
105
|
-
_context.prev = 13;
|
|
106
|
-
_context.t0 = _context["catch"](6);
|
|
107
|
-
console.error('[Security] apdid-core load error, degrading:', _context.t0);
|
|
108
|
-
this.apdidLoadFailed = true;
|
|
109
|
-
return _context.abrupt("return", false);
|
|
110
|
-
case 18:
|
|
111
|
-
case "end":
|
|
112
|
-
return _context.stop();
|
|
113
|
-
}
|
|
114
|
-
}, _callee, this, [[6, 13]]);
|
|
115
|
-
}));
|
|
116
|
-
function ensureApdidLoaded() {
|
|
117
|
-
return _ensureApdidLoaded.apply(this, arguments);
|
|
118
|
-
}
|
|
119
|
-
return ensureApdidLoaded;
|
|
120
|
-
}()
|
|
121
|
-
/**
|
|
122
|
-
* Get the APDID module from the loader.
|
|
123
|
-
* Returns undefined if not loaded.
|
|
124
|
-
*/
|
|
125
|
-
)
|
|
126
|
-
}, {
|
|
127
|
-
key: "getAPDIDModule",
|
|
128
|
-
value: function getAPDIDModule() {
|
|
129
|
-
var loader = ApdidLoader.getInstance();
|
|
130
|
-
return loader.getApdidModule();
|
|
131
|
-
}
|
|
132
|
-
}, {
|
|
133
44
|
key: "initSecurity",
|
|
134
45
|
value: function initSecurity(successCallback, failCallback) {
|
|
135
|
-
|
|
46
|
+
console.log(this.scene, 'preloadSecuritySDK');
|
|
136
47
|
if (!this.scene) {
|
|
137
48
|
throw new Error('securityConfig parameter error');
|
|
138
49
|
}
|
|
@@ -141,23 +52,12 @@ export var Security = /*#__PURE__*/function () {
|
|
|
141
52
|
console.error(errorMsg);
|
|
142
53
|
throw new Error(errorMsg);
|
|
143
54
|
}
|
|
144
|
-
|
|
145
|
-
// Async: ensure script is loaded before calling initToken
|
|
146
|
-
this.ensureApdidLoaded().then(function (loaded) {
|
|
147
|
-
if (!loaded) {
|
|
148
|
-
failCallback && failCallback('apdid-core script load failed');
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
_this.initToken(successCallback, failCallback);
|
|
152
|
-
}).catch(function () {
|
|
153
|
-
failCallback && failCallback('apdid-core script load failed');
|
|
154
|
-
});
|
|
55
|
+
this.initToken(successCallback, failCallback);
|
|
155
56
|
}
|
|
156
57
|
}, {
|
|
157
58
|
key: "initToken",
|
|
158
59
|
value: function initToken(successCallback, failCallback) {
|
|
159
60
|
try {
|
|
160
|
-
var APDID = this.getAPDIDModule();
|
|
161
61
|
APDID === null || APDID === void 0 || APDID.initToken(this.scene, {
|
|
162
62
|
host: this.h5gateway
|
|
163
63
|
}, function (success, tokenResult, msg) {
|
|
@@ -166,6 +66,7 @@ export var Security = /*#__PURE__*/function () {
|
|
|
166
66
|
} else {
|
|
167
67
|
failCallback && failCallback(msg);
|
|
168
68
|
}
|
|
69
|
+
console.log('initToken result tokenResult', JSON.stringify(tokenResult), msg);
|
|
169
70
|
});
|
|
170
71
|
} catch (error) {
|
|
171
72
|
failCallback && failCallback(error === null || error === void 0 ? void 0 : error.toString());
|
|
@@ -174,48 +75,48 @@ export var Security = /*#__PURE__*/function () {
|
|
|
174
75
|
}, {
|
|
175
76
|
key: "pollingGetApdidToken",
|
|
176
77
|
value: function () {
|
|
177
|
-
var _pollingGetApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
178
|
-
var
|
|
78
|
+
var _pollingGetApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(config) {
|
|
79
|
+
var _this = this;
|
|
179
80
|
var tokenCollectTime, dataPollingInterval, asyncFunc;
|
|
180
|
-
return _regeneratorRuntime().wrap(function
|
|
181
|
-
while (1) switch (
|
|
81
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
82
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
182
83
|
case 0:
|
|
183
84
|
tokenCollectTime = parseInt((config === null || config === void 0 ? void 0 : config.tokenCollectTime) || '0', 10);
|
|
184
85
|
dataPollingInterval = parseInt((config === null || config === void 0 ? void 0 : config.dataPollingInterval) || '500', 10);
|
|
185
86
|
asyncFunc = /*#__PURE__*/function () {
|
|
186
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
87
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
|
|
187
88
|
var deviceId, interval, polling;
|
|
188
|
-
return _regeneratorRuntime().wrap(function
|
|
189
|
-
while (1) switch (
|
|
89
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
90
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
190
91
|
case 0:
|
|
191
|
-
|
|
192
|
-
return
|
|
92
|
+
_context2.next = 2;
|
|
93
|
+
return _this.getApdidToken();
|
|
193
94
|
case 2:
|
|
194
|
-
deviceId =
|
|
95
|
+
deviceId = _context2.sent;
|
|
195
96
|
if (!deviceId) {
|
|
196
|
-
|
|
97
|
+
_context2.next = 5;
|
|
197
98
|
break;
|
|
198
99
|
}
|
|
199
|
-
return
|
|
100
|
+
return _context2.abrupt("return", resolve(deviceId));
|
|
200
101
|
case 5:
|
|
201
102
|
polling = /*#__PURE__*/function () {
|
|
202
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
203
|
-
return _regeneratorRuntime().wrap(function
|
|
204
|
-
while (1) switch (
|
|
103
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
104
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
105
|
+
while (1) switch (_context.prev = _context.next) {
|
|
205
106
|
case 0:
|
|
206
|
-
|
|
207
|
-
return
|
|
107
|
+
_context.next = 2;
|
|
108
|
+
return _this.getApdidToken();
|
|
208
109
|
case 2:
|
|
209
|
-
deviceId =
|
|
110
|
+
deviceId = _context.sent;
|
|
210
111
|
if (deviceId) {
|
|
211
112
|
clearInterval(interval);
|
|
212
113
|
resolve(deviceId);
|
|
213
114
|
}
|
|
214
115
|
case 4:
|
|
215
116
|
case "end":
|
|
216
|
-
return
|
|
117
|
+
return _context.stop();
|
|
217
118
|
}
|
|
218
|
-
},
|
|
119
|
+
}, _callee);
|
|
219
120
|
}));
|
|
220
121
|
return function polling() {
|
|
221
122
|
return _ref2.apply(this, arguments);
|
|
@@ -228,22 +129,22 @@ export var Security = /*#__PURE__*/function () {
|
|
|
228
129
|
}, tokenCollectTime);
|
|
229
130
|
case 8:
|
|
230
131
|
case "end":
|
|
231
|
-
return
|
|
132
|
+
return _context2.stop();
|
|
232
133
|
}
|
|
233
|
-
},
|
|
134
|
+
}, _callee2);
|
|
234
135
|
}));
|
|
235
136
|
return function asyncFunc(_x2) {
|
|
236
137
|
return _ref.apply(this, arguments);
|
|
237
138
|
};
|
|
238
139
|
}();
|
|
239
|
-
return
|
|
140
|
+
return _context3.abrupt("return", new Promise(function (resolve) {
|
|
240
141
|
asyncFunc(resolve);
|
|
241
142
|
}));
|
|
242
143
|
case 4:
|
|
243
144
|
case "end":
|
|
244
|
-
return
|
|
145
|
+
return _context3.stop();
|
|
245
146
|
}
|
|
246
|
-
},
|
|
147
|
+
}, _callee3);
|
|
247
148
|
}));
|
|
248
149
|
function pollingGetApdidToken(_x) {
|
|
249
150
|
return _pollingGetApdidToken.apply(this, arguments);
|
|
@@ -253,37 +154,25 @@ export var Security = /*#__PURE__*/function () {
|
|
|
253
154
|
}, {
|
|
254
155
|
key: "getApdidToken",
|
|
255
156
|
value: function () {
|
|
256
|
-
var _getApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
257
|
-
var
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
157
|
+
var _getApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
158
|
+
var _this2 = this;
|
|
159
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
160
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
261
161
|
case 0:
|
|
262
|
-
|
|
263
|
-
return this.ensureApdidLoaded();
|
|
264
|
-
case 2:
|
|
265
|
-
loaded = _context5.sent;
|
|
266
|
-
if (loaded) {
|
|
267
|
-
_context5.next = 5;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
return _context5.abrupt("return", '');
|
|
271
|
-
case 5:
|
|
272
|
-
return _context5.abrupt("return", new Promise(function (resolve) {
|
|
162
|
+
return _context4.abrupt("return", new Promise(function (resolve) {
|
|
273
163
|
try {
|
|
274
|
-
|
|
275
|
-
APDID === null || APDID === void 0 || APDID.getApdidToken(_this3.scene, function (tokenResult) {
|
|
164
|
+
APDID === null || APDID === void 0 || APDID.getApdidToken(_this2.scene, function (tokenResult) {
|
|
276
165
|
resolve(tokenResult === null || tokenResult === void 0 ? void 0 : tokenResult.token);
|
|
277
166
|
});
|
|
278
167
|
} catch (error) {
|
|
279
168
|
resolve('');
|
|
280
169
|
}
|
|
281
170
|
}));
|
|
282
|
-
case
|
|
171
|
+
case 1:
|
|
283
172
|
case "end":
|
|
284
|
-
return
|
|
173
|
+
return _context4.stop();
|
|
285
174
|
}
|
|
286
|
-
},
|
|
175
|
+
}, _callee4);
|
|
287
176
|
}));
|
|
288
177
|
function getApdidToken() {
|
|
289
178
|
return _getApdidToken.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alipay/ams-checkout",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1784095668-dev.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"exports": {
|
|
@@ -36,15 +36,14 @@
|
|
|
36
36
|
"README.md"
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
|
-
"build": "opensdk update && npm run build:father:pre && npm run extract && npm run build:father
|
|
39
|
+
"build": "opensdk update && npm run build:father:pre && npm run extract && npm run build:father && npm run build:father:umd && npm run build:react",
|
|
40
40
|
"build:analyze": "ANALYZE=1 father build",
|
|
41
|
-
"build:father
|
|
42
|
-
"build:father:
|
|
43
|
-
"build:father:
|
|
44
|
-
"build:father:tools:local": "STAGE_NAME=LOCAL FATHER_BUILD_TYPE=only-umd-tools father build --no-clean",
|
|
41
|
+
"build:father": "FATHER_TSCONFIG_NAME=tsconfig.build.json father build",
|
|
42
|
+
"build:father:local": "STAGE_NAME=LOCAL FATHER_TSCONFIG_NAME=tsconfig.build.json father build",
|
|
43
|
+
"build:father:pre": "FATHER_BUILD_TYPE=prebuild father build",
|
|
45
44
|
"build:father:umd": "FATHER_BUILD_TYPE=only-umd father build",
|
|
46
45
|
"build:father:umd:local": "STAGE_NAME=LOCAL FATHER_BUILD_TYPE=only-umd father build",
|
|
47
|
-
"build:local": "opensdk update && npm run build:father:pre && npm run extract && npm run build:father:
|
|
46
|
+
"build:local": "opensdk update && npm run build:father:pre && npm run extract && npm run build:father:local && npm run build:father:umd:local && npm run build:react",
|
|
48
47
|
"build:react": "tsc --project tsconfig.cjs.json && mv react-js.js react-js.cjs && tsc --project tsconfig.esm.json",
|
|
49
48
|
"build:type": "dts-bundle-generator -o ./types/antom-web-sdk.d.ts ./src/index.ts --no-banner --silent --no-check",
|
|
50
49
|
"build:w": "FATHER_BUILD_TYPE=only-umd STAGE_NAME=LOCAL father dev",
|
|
@@ -54,7 +53,7 @@
|
|
|
54
53
|
"e2e": "nyc playwright test",
|
|
55
54
|
"e2e:create": "node scripts/e2e-create.js",
|
|
56
55
|
"e2e:ui": "playwright test --ui",
|
|
57
|
-
"extract": "opensdk extract
|
|
56
|
+
"extract": "opensdk extract -p esm/modern/sdk",
|
|
58
57
|
"format": "prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"",
|
|
59
58
|
"generateApi": "intl-oneapi generate && prettier --write src/modern/sdk/oneapi",
|
|
60
59
|
"lint": "eslint ./src",
|
|
@@ -86,15 +85,12 @@
|
|
|
86
85
|
]
|
|
87
86
|
},
|
|
88
87
|
"dependencies": {
|
|
88
|
+
"@antglobal/create-sdk-loader": "^1.0.5",
|
|
89
89
|
"axios": "^1.3.4",
|
|
90
90
|
"proxy-polyfill": "^0.3.2",
|
|
91
91
|
"uuid": "^9.0.0"
|
|
92
92
|
},
|
|
93
|
-
"opensdk": {
|
|
94
|
-
"name": "Antom"
|
|
95
|
-
},
|
|
96
93
|
"devDependencies": {
|
|
97
|
-
"@antglobal/create-sdk-loader": "^1.0.5",
|
|
98
94
|
"@babel/core": "^7.20.7",
|
|
99
95
|
"@babel/preset-env": "^7.20.2",
|
|
100
96
|
"@commitlint/cli": "^17.3.0",
|
|
@@ -126,9 +122,7 @@
|
|
|
126
122
|
"serve": "^14.2.5",
|
|
127
123
|
"ts-jest": "^29.0.3",
|
|
128
124
|
"ts-node": "^10.9.1",
|
|
129
|
-
"
|
|
130
|
-
"typescript": "^5.x",
|
|
131
|
-
"typescript-transform-paths": "^3.5.6"
|
|
125
|
+
"typescript": "^5.x"
|
|
132
126
|
},
|
|
133
127
|
"engines": {
|
|
134
128
|
"install-node": "20"
|