@alipay/ams-checkout 0.0.1699585541-dev.2 → 0.0.1699863258-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/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +1 -0
- package/esm/config/index.js +8 -0
- package/esm/core/component/index.d.ts +3 -1
- package/esm/core/component/index.js +10 -3
- package/esm/core/instance/index.d.ts +23 -10
- package/esm/core/instance/index.js +136 -57
- package/esm/plugin/component/index.d.ts +1 -3
- package/esm/plugin/component/index.js +144 -188
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +6 -9
- package/esm/request/utils.js +1 -4
- package/esm/service/index.d.ts +3 -3
- package/esm/service/index.js +29 -15
- package/esm/types/index.d.ts +21 -63
- package/esm/types/index.js +1 -11
- package/esm/util/index.d.ts +6 -21
- package/esm/util/index.js +38 -45
- package/esm/util/security.d.ts +24 -8
- package/esm/util/security.js +165 -112
- package/esm/util/versionCompare.d.ts +10 -0
- package/esm/util/versionCompare.js +50 -0
- package/package.json +1 -1
@@ -17,11 +17,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
18
|
import { marmotMap } from "../../config/index";
|
19
19
|
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
20
|
-
import { queryPaymentInfo
|
21
|
-
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum,
|
20
|
+
import { queryPaymentInfo } from "../../service";
|
21
|
+
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
22
22
|
import { getType, isJsonString, isPC } from "../../util";
|
23
23
|
import { isLocalMock } from "../../util/mock";
|
24
|
-
import { getApdidToken, getAppname, getSecurityHost, initSecuritySDK } from "../../util/security";
|
25
24
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
26
25
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
27
26
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
@@ -44,12 +43,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
44
43
|
_defineProperty(this, "_appVersion", void 0);
|
45
44
|
_defineProperty(this, "_isRetention", void 0);
|
46
45
|
_defineProperty(this, "_actionQueryPromise", null);
|
47
|
-
_defineProperty(this, "_actionSubmitPromise", null);
|
48
46
|
_defineProperty(this, "_renderParams", null);
|
49
47
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
50
48
|
_defineProperty(this, "_appLocationSearch", void 0);
|
51
49
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
52
|
-
this._appVersion = '1.6.
|
50
|
+
this._appVersion = '1.6.1';
|
53
51
|
this._isInitComponent = false;
|
54
52
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
55
53
|
this.createIframeNode = function () {
|
@@ -86,7 +84,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
86
84
|
key: "initLoggerMeta",
|
87
85
|
value: function initLoggerMeta() {
|
88
86
|
var _this$_renderParams, _paymentSessionMetaDa;
|
89
|
-
console.log('this._renderParams', JSON.stringify(this._renderParams), null, 3);
|
90
87
|
var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
|
91
88
|
var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
|
92
89
|
this.AMSSDK.logger.setMedta({
|
@@ -115,39 +112,39 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
115
112
|
this.createIframeNode = renderFunc;
|
116
113
|
}
|
117
114
|
}, {
|
118
|
-
key: "
|
119
|
-
value: function
|
115
|
+
key: "initSecurity",
|
116
|
+
value: function initSecurity() {
|
120
117
|
var _this$_renderParams2,
|
121
118
|
_this = this;
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
|
130
|
-
var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
|
131
|
-
|
132
|
-
// if merchant have init securitySDK and same as service paymentSessionMetaData, no need init again
|
133
|
-
if (this.AMSSDK.securityConfig) {
|
134
|
-
if (appName === getAppname(this.AMSSDK.securityConfig.scene) && h5gateway === getSecurityHost(this.AMSSDK.securityConfig.region)) {
|
135
|
-
return;
|
136
|
-
}
|
119
|
+
var product = (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionMetaData) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionConfig) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.productScene;
|
120
|
+
if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
|
121
|
+
this.AMSSDK.logger.logInfo({
|
122
|
+
title: 'sdk_event_security_unneeded_scenarios'
|
123
|
+
}, {
|
124
|
+
product: product
|
125
|
+
});
|
137
126
|
}
|
138
|
-
this.AMSSDK.
|
139
|
-
|
127
|
+
var securitySDK = this.AMSSDK._getSecuritySDKByProductScene({
|
128
|
+
product: product
|
140
129
|
});
|
141
|
-
|
142
|
-
|
143
|
-
title: '
|
130
|
+
if (!securitySDK) {
|
131
|
+
this.AMSSDK.logger.logInfo({
|
132
|
+
title: 'sdk_event_securitySdkInit'
|
144
133
|
});
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
134
|
+
this.AMSSDK._newSecuritySDKByScene({
|
135
|
+
product: product
|
136
|
+
}, function () {
|
137
|
+
_this.AMSSDK.logger.logInfo({
|
138
|
+
title: 'sdk_event_securitySdkInitSuccess'
|
139
|
+
});
|
140
|
+
}, function () {
|
141
|
+
_this.AMSSDK.logger.logError({
|
142
|
+
title: 'sdk_error_securitySdkInitFailed'
|
143
|
+
}, {
|
144
|
+
sign: 'SDK internal initialization'
|
145
|
+
});
|
149
146
|
});
|
150
|
-
}
|
147
|
+
}
|
151
148
|
}
|
152
149
|
}, {
|
153
150
|
key: "logDeviceId",
|
@@ -171,25 +168,49 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
171
168
|
}
|
172
169
|
}, {
|
173
170
|
key: "getDeviceIdAndLog",
|
174
|
-
value: function getDeviceIdAndLog(
|
171
|
+
value: function getDeviceIdAndLog() {
|
175
172
|
var _this2 = this;
|
173
|
+
var deviceIdParameter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
174
|
+
var isPolling = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
176
175
|
return new Promise(function (resolve) {
|
177
176
|
// To avoid rendering being blocked, move the logic to the next event loop for processing
|
178
177
|
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
179
178
|
var _this2$_renderParams;
|
180
|
-
var
|
179
|
+
var productScene, getDeviceIdStartTime, securitySDK, deviceId;
|
181
180
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
182
181
|
while (1) switch (_context.prev = _context.next) {
|
183
182
|
case 0:
|
184
|
-
|
183
|
+
productScene = (_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionMetaData) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionConfig) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.productScene;
|
185
184
|
getDeviceIdStartTime = Date.now();
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
deviceId =
|
185
|
+
securitySDK = _this2.AMSSDK._getSecuritySDKByProductScene({
|
186
|
+
product: (deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.productScene) || productScene
|
187
|
+
});
|
188
|
+
deviceId = '';
|
189
|
+
if (!securitySDK) {
|
190
|
+
_context.next = 16;
|
191
|
+
break;
|
192
|
+
}
|
193
|
+
if (!(isPolling && parseInt(deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.tokenCollectTime) > 0)) {
|
194
|
+
_context.next = 11;
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
_context.next = 8;
|
198
|
+
return securitySDK.pollingGetApdidToken(deviceIdParameter);
|
199
|
+
case 8:
|
200
|
+
_context.t0 = _context.sent;
|
201
|
+
_context.next = 14;
|
202
|
+
break;
|
203
|
+
case 11:
|
204
|
+
_context.next = 13;
|
205
|
+
return securitySDK.getApdidToken();
|
206
|
+
case 13:
|
207
|
+
_context.t0 = _context.sent;
|
208
|
+
case 14:
|
209
|
+
deviceId = _context.t0;
|
190
210
|
_this2.logDeviceId(deviceId, getDeviceIdStartTime);
|
211
|
+
case 16:
|
191
212
|
resolve(deviceId);
|
192
|
-
case
|
213
|
+
case 17:
|
193
214
|
case "end":
|
194
215
|
return _context.stop();
|
195
216
|
}
|
@@ -215,7 +236,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
215
236
|
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
216
237
|
this._renderDisplayType = renderParams.renderDisplayType;
|
217
238
|
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
218
|
-
this.
|
239
|
+
this.initSecurity();
|
219
240
|
this.initLoggerMeta();
|
220
241
|
this._performanceData.push({
|
221
242
|
key: 'sdk_create_component',
|
@@ -236,7 +257,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
236
257
|
this.renderPopupLoading(renderParams);
|
237
258
|
}
|
238
259
|
this.createApp(renderParams);
|
239
|
-
return Promise.all([this.createActionQueryPromise(), this.
|
260
|
+
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
|
240
261
|
_this3.AMSSDK.logger.logInfo({
|
241
262
|
title: 'sdk_event_successfully_created_app_process'
|
242
263
|
}).send();
|
@@ -302,8 +323,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
302
323
|
// eslint-disable-next-line no-async-promise-executor
|
303
324
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
304
325
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
305
|
-
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4
|
306
|
-
var envInfo, params, securityConfig, _this5$
|
326
|
+
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
|
327
|
+
var envInfo, params, securityConfig, _this5$_renderParams5, extendInfo, info, _this5$_renderParams6, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams7, _action$web, _action$wap, action, signType;
|
307
328
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
308
329
|
while (1) switch (_context2.prev = _context2.next) {
|
309
330
|
case 0:
|
@@ -315,78 +336,80 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
315
336
|
paymentSessionConfig: (_this5$_renderParams2 = _this5._renderParams) === null || _this5$_renderParams2 === void 0 || (_this5$_renderParams2 = _this5$_renderParams2.paymentSessionMetaData) === null || _this5$_renderParams2 === void 0 ? void 0 : _this5$_renderParams2.paymentSessionConfig,
|
316
337
|
notRedirectAfterComplete: ((_this5$_renderParams3 = _this5._renderParams) === null || _this5$_renderParams3 === void 0 ? void 0 : _this5$_renderParams3.notRedirectAfterComplete) === true
|
317
338
|
};
|
318
|
-
/**
|
319
|
-
* @description Simulated or unnecessary scenarios
|
320
|
-
*/
|
321
|
-
if (!(isLocalMock() || (_this5$_renderParams4 = _this5._renderParams) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) !== null && _this5$_renderParams4 !== void 0 && _this5$_renderParams4.action.skipSdkQuery)) {
|
322
|
-
_context2.next = 4;
|
323
|
-
break;
|
324
|
-
}
|
325
|
-
return _context2.abrupt("return", resolve({
|
326
|
-
message: 'sdk no need to make query request',
|
327
|
-
success: true
|
328
|
-
}));
|
329
|
-
case 4:
|
330
339
|
/**
|
331
340
|
* @description card
|
332
341
|
*/
|
333
342
|
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign) {
|
334
343
|
params.paymentMethodType = 'CARD';
|
335
344
|
}
|
336
|
-
securityConfig = (_this5$
|
345
|
+
securityConfig = (_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 || (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.securityConfig;
|
337
346
|
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign && securityConfig)) {
|
338
|
-
_context2.next =
|
347
|
+
_context2.next = 11;
|
339
348
|
break;
|
340
349
|
}
|
341
|
-
extendInfo = ((_this5$
|
350
|
+
extendInfo = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.extendInfo) || '{}';
|
342
351
|
info = JSON.parse(extendInfo);
|
343
352
|
if (!((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false')) {
|
344
|
-
_context2.next =
|
353
|
+
_context2.next = 11;
|
345
354
|
break;
|
346
355
|
}
|
347
|
-
_context2.next =
|
356
|
+
_context2.next = 10;
|
348
357
|
return _this5.getDeviceIdAndLog();
|
349
|
-
case
|
358
|
+
case 10:
|
350
359
|
envInfo.deviceId = _context2.sent;
|
351
|
-
case
|
360
|
+
case 11:
|
352
361
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
353
|
-
_context2.next =
|
362
|
+
_context2.next = 19;
|
354
363
|
break;
|
355
364
|
}
|
356
365
|
_ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
|
357
|
-
_ref4 = ((_this5$
|
366
|
+
_ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
358
367
|
if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
|
359
|
-
_context2.next =
|
368
|
+
_context2.next = 16;
|
360
369
|
break;
|
361
370
|
}
|
362
371
|
return _context2.abrupt("return", resolve({
|
363
372
|
message: 'sdk no need to make query request',
|
364
373
|
success: true
|
365
374
|
}));
|
375
|
+
case 16:
|
376
|
+
_context2.next = 18;
|
377
|
+
return _this5.getDeviceIdAndLog();
|
366
378
|
case 18:
|
379
|
+
envInfo.deviceId = _context2.sent;
|
380
|
+
case 19:
|
367
381
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
368
|
-
_context2.next =
|
382
|
+
_context2.next = 26;
|
369
383
|
break;
|
370
384
|
}
|
371
|
-
action = ((_this5$
|
385
|
+
action = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 || (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.action) || {};
|
372
386
|
signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
373
387
|
if (!(signType === 'SMS')) {
|
374
|
-
_context2.next =
|
388
|
+
_context2.next = 24;
|
375
389
|
break;
|
376
390
|
}
|
377
391
|
return _context2.abrupt("return", resolve({
|
378
392
|
message: 'sdk no need to make query request',
|
379
393
|
success: true
|
380
394
|
}));
|
381
|
-
case
|
395
|
+
case 24:
|
382
396
|
if (!(!signType || signType !== 'REDIRECT')) {
|
383
|
-
_context2.next =
|
397
|
+
_context2.next = 26;
|
384
398
|
break;
|
385
399
|
}
|
386
400
|
return _context2.abrupt("return", resolve({
|
387
401
|
success: false
|
388
402
|
}));
|
389
|
-
case
|
403
|
+
case 26:
|
404
|
+
if (!isLocalMock()) {
|
405
|
+
_context2.next = 28;
|
406
|
+
break;
|
407
|
+
}
|
408
|
+
return _context2.abrupt("return", resolve({
|
409
|
+
message: 'sdk no need to make query request',
|
410
|
+
success: true
|
411
|
+
}));
|
412
|
+
case 28:
|
390
413
|
queryPaymentInfo(params, {
|
391
414
|
env: _this5.AMSSDK.options.env.environment,
|
392
415
|
envInfo: envInfo
|
@@ -411,7 +434,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
411
434
|
});
|
412
435
|
reject(err);
|
413
436
|
});
|
414
|
-
case
|
437
|
+
case 29:
|
415
438
|
case "end":
|
416
439
|
return _context2.stop();
|
417
440
|
}
|
@@ -423,68 +446,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
423
446
|
}());
|
424
447
|
return this._actionQueryPromise;
|
425
448
|
}
|
426
|
-
}, {
|
427
|
-
key: "createSubmitPromise",
|
428
|
-
value: function createSubmitPromise() {
|
429
|
-
var _this$_renderParams3,
|
430
|
-
_this$_renderParams4,
|
431
|
-
_this6 = this;
|
432
|
-
this._performanceData.push({
|
433
|
-
key: 'sdk_submit_start',
|
434
|
-
value: Date.now()
|
435
|
-
});
|
436
|
-
var envInfo = {
|
437
|
-
locale: this.AMSSDK.options.locale
|
438
|
-
};
|
439
|
-
var params = {
|
440
|
-
paymentSessionData: this._renderParams && ((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData) || '',
|
441
|
-
paymentSessionConfig: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionMetaData) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionConfig
|
442
|
-
};
|
443
|
-
|
444
|
-
// eslint-disable-next-line no-async-promise-executor
|
445
|
-
this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
|
446
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
447
|
-
var _this6$_renderParams;
|
448
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
449
|
-
while (1) switch (_context3.prev = _context3.next) {
|
450
|
-
case 0:
|
451
|
-
if (!(!((_this6$_renderParams = _this6._renderParams) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.paymentSessionMetaData) !== null && _this6$_renderParams !== void 0 && _this6$_renderParams.action.skipSdkQuery) && componentSignEnum.EASY_PAY_WALLET !== _this6._componentSign)) {
|
452
|
-
_context3.next = 2;
|
453
|
-
break;
|
454
|
-
}
|
455
|
-
return _context3.abrupt("return", resolve({
|
456
|
-
message: 'sdk no need to make submitPay request',
|
457
|
-
success: true
|
458
|
-
}));
|
459
|
-
case 2:
|
460
|
-
submitPayInfo(params, {
|
461
|
-
timeout: 15000
|
462
|
-
}, _this6.AMSSDK.logger).then(function (res) {
|
463
|
-
_this6._performanceData.push({
|
464
|
-
key: 'sdk_submit_end',
|
465
|
-
value: Date.now()
|
466
|
-
});
|
467
|
-
if (res !== null && res !== void 0 && res.success) {
|
468
|
-
resolve(res);
|
469
|
-
} else {
|
470
|
-
resolve(res);
|
471
|
-
}
|
472
|
-
}).catch(function () {
|
473
|
-
return resolve({
|
474
|
-
success: false
|
475
|
-
});
|
476
|
-
});
|
477
|
-
case 3:
|
478
|
-
case "end":
|
479
|
-
return _context3.stop();
|
480
|
-
}
|
481
|
-
}, _callee3);
|
482
|
-
}));
|
483
|
-
return function (_x3) {
|
484
|
-
return _ref5.apply(this, arguments);
|
485
|
-
};
|
486
|
-
}());
|
487
|
-
}
|
488
449
|
}, {
|
489
450
|
key: "cleanElement",
|
490
451
|
value: function cleanElement() {
|
@@ -601,9 +562,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
601
562
|
}, {
|
602
563
|
key: "createPopupWindow",
|
603
564
|
value: function createPopupWindow(data) {
|
604
|
-
var _this$
|
565
|
+
var _this$_renderParams3;
|
605
566
|
this._threedData = data;
|
606
|
-
var sessionData = encodeURIComponent((_this$
|
567
|
+
var sessionData = encodeURIComponent((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData);
|
607
568
|
var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&").concat(this._appLocationSearch);
|
608
569
|
this.popupWindow = createModal({
|
609
570
|
device: this.platform,
|
@@ -613,19 +574,19 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
613
574
|
}, {
|
614
575
|
key: "getDeviceIdAndCallback",
|
615
576
|
value: function () {
|
616
|
-
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
577
|
+
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(eventContext) {
|
617
578
|
var deviceId;
|
618
|
-
return _regeneratorRuntime().wrap(function
|
619
|
-
while (1) switch (
|
579
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
580
|
+
while (1) switch (_context3.prev = _context3.next) {
|
620
581
|
case 0:
|
621
582
|
if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
|
622
|
-
|
583
|
+
_context3.next = 5;
|
623
584
|
break;
|
624
585
|
}
|
625
|
-
|
626
|
-
return this.getDeviceIdAndLog();
|
586
|
+
_context3.next = 3;
|
587
|
+
return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
|
627
588
|
case 3:
|
628
|
-
deviceId =
|
589
|
+
deviceId = _context3.sent;
|
629
590
|
this.dispatchToApp({
|
630
591
|
context: {
|
631
592
|
event: 'appEventCallback',
|
@@ -637,11 +598,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
637
598
|
});
|
638
599
|
case 5:
|
639
600
|
case "end":
|
640
|
-
return
|
601
|
+
return _context3.stop();
|
641
602
|
}
|
642
|
-
},
|
603
|
+
}, _callee3, this);
|
643
604
|
}));
|
644
|
-
function getDeviceIdAndCallback(
|
605
|
+
function getDeviceIdAndCallback(_x3) {
|
645
606
|
return _getDeviceIdAndCallback.apply(this, arguments);
|
646
607
|
}
|
647
608
|
return getDeviceIdAndCallback;
|
@@ -806,7 +767,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
806
767
|
}, {
|
807
768
|
key: "handleRedirect",
|
808
769
|
value: function handleRedirect(data) {
|
809
|
-
var
|
770
|
+
var _this6 = this;
|
810
771
|
var _data = typeof data === 'string' ? {
|
811
772
|
normalUrl: data
|
812
773
|
} : {
|
@@ -821,11 +782,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
821
782
|
redirectInfo: JSON.stringify(_data)
|
822
783
|
}).send();
|
823
784
|
var successCallback = function successCallback(type, url) {
|
824
|
-
|
785
|
+
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
825
786
|
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
826
787
|
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
827
788
|
});
|
828
|
-
|
789
|
+
_this6.AMSSDK.logger.logInfo({
|
829
790
|
title: 'sdk_event_call_url_success'
|
830
791
|
}, {
|
831
792
|
redirectInfo: JSON.stringify(_data),
|
@@ -834,11 +795,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
834
795
|
}).send();
|
835
796
|
};
|
836
797
|
var failCallback = function failCallback(type, url) {
|
837
|
-
|
838
|
-
code: eventCodeEnum.
|
798
|
+
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
799
|
+
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
839
800
|
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
|
840
801
|
});
|
841
|
-
|
802
|
+
_this6.AMSSDK.logger.logInfo({
|
842
803
|
title: 'sdk_error_call_url_failed'
|
843
804
|
}, {
|
844
805
|
redirectInfo: JSON.stringify(_data),
|
@@ -861,14 +822,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
861
822
|
successCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
862
823
|
}).catch(function () {
|
863
824
|
failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
864
|
-
return
|
825
|
+
return _this6.AMSSDK._redirect({
|
865
826
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
866
827
|
});
|
867
828
|
}).then(function () {
|
868
829
|
successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
869
830
|
}).catch(function () {
|
870
831
|
failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
871
|
-
return
|
832
|
+
return _this6.AMSSDK._redirect({
|
872
833
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
873
834
|
});
|
874
835
|
}).then(function () {
|
@@ -879,9 +840,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
879
840
|
}
|
880
841
|
}, {
|
881
842
|
key: "handleDeclareInfo",
|
882
|
-
value: function handleDeclareInfo(
|
883
|
-
var
|
884
|
-
closeDialogData =
|
843
|
+
value: function handleDeclareInfo(_ref5) {
|
844
|
+
var _ref5$closeDialogData = _ref5.closeDialogData,
|
845
|
+
closeDialogData = _ref5$closeDialogData === void 0 ? {} : _ref5$closeDialogData;
|
885
846
|
_handleDeclareInfo({
|
886
847
|
closeDialogData: closeDialogData
|
887
848
|
});
|
@@ -955,26 +916,22 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
955
916
|
}, {
|
956
917
|
key: "sendRenderEvent",
|
957
918
|
value: function () {
|
958
|
-
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
959
|
-
var _this$
|
960
|
-
return _regeneratorRuntime().wrap(function
|
961
|
-
while (1) switch (
|
919
|
+
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
920
|
+
var _this$_renderParams4, _this$_renderParams5, _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, res;
|
921
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
922
|
+
while (1) switch (_context4.prev = _context4.next) {
|
962
923
|
case 0:
|
963
|
-
|
964
|
-
if (
|
965
|
-
|
924
|
+
_context4.prev = 0;
|
925
|
+
if (this._actionQueryPromise) {
|
926
|
+
_context4.next = 3;
|
966
927
|
break;
|
967
928
|
}
|
968
|
-
return
|
929
|
+
return _context4.abrupt("return");
|
969
930
|
case 3:
|
970
|
-
|
931
|
+
_context4.next = 5;
|
971
932
|
return this._actionQueryPromise;
|
972
933
|
case 5:
|
973
|
-
res =
|
974
|
-
_context5.next = 8;
|
975
|
-
return this._actionSubmitPromise;
|
976
|
-
case 8:
|
977
|
-
submitRes = _context5.sent;
|
934
|
+
res = _context4.sent;
|
978
935
|
this._performanceData.push({
|
979
936
|
key: 'sdk_render_component',
|
980
937
|
value: Date.now()
|
@@ -984,13 +941,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
984
941
|
event: 'renderComponent',
|
985
942
|
data: {
|
986
943
|
queryResult: res,
|
987
|
-
|
988
|
-
|
989
|
-
paymentSessionData: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.sessionData,
|
944
|
+
sessionResult: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionMetaData,
|
945
|
+
paymentSessionData: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData,
|
990
946
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
991
|
-
renderDisplayType: (_this$
|
992
|
-
appearance: (_this$
|
993
|
-
notRedirectAfterComplete: ((_this$
|
947
|
+
renderDisplayType: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.renderDisplayType,
|
948
|
+
appearance: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.appearance,
|
949
|
+
notRedirectAfterComplete: ((_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.notRedirectAfterComplete) === true,
|
994
950
|
envInfo: {
|
995
951
|
screenHeight: screen.height,
|
996
952
|
screenWidth: screen.width
|
@@ -1007,16 +963,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1007
963
|
}
|
1008
964
|
});
|
1009
965
|
// eslint-disable-next-line no-empty
|
1010
|
-
|
966
|
+
_context4.next = 13;
|
1011
967
|
break;
|
1012
|
-
case
|
1013
|
-
|
1014
|
-
|
1015
|
-
case
|
968
|
+
case 11:
|
969
|
+
_context4.prev = 11;
|
970
|
+
_context4.t0 = _context4["catch"](0);
|
971
|
+
case 13:
|
1016
972
|
case "end":
|
1017
|
-
return
|
973
|
+
return _context4.stop();
|
1018
974
|
}
|
1019
|
-
},
|
975
|
+
}, _callee4, this, [[0, 11]]);
|
1020
976
|
}));
|
1021
977
|
function sendRenderEvent() {
|
1022
978
|
return _sendRenderEvent.apply(this, arguments);
|
@@ -1030,7 +986,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1030
986
|
key: "cleanContainer",
|
1031
987
|
value: function cleanContainer() {
|
1032
988
|
var _document$getElementB4,
|
1033
|
-
|
989
|
+
_this7 = this;
|
1034
990
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1035
991
|
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
1036
992
|
this._performanceData = [];
|
@@ -1042,7 +998,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1042
998
|
mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
|
1043
999
|
if (immediately) this.cleanElement();else {
|
1044
1000
|
setTimeout(function () {
|
1045
|
-
|
1001
|
+
_this7.cleanElement();
|
1046
1002
|
}, 300);
|
1047
1003
|
}
|
1048
1004
|
}
|
package/esm/request/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { IrequestConfig } from '../types';
|
2
2
|
import { Logger } from '../util/logger';
|
3
3
|
/**
|
4
4
|
*
|
@@ -6,4 +6,4 @@ import { Logger } from '../util/logger';
|
|
6
6
|
* @param options 请求配置
|
7
7
|
* @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
|
8
8
|
*/
|
9
|
-
export declare function request<T>(requestData: Record<string, any> | undefined, options:
|
9
|
+
export declare function request<T>(requestData: Record<string, any> | undefined, options: IrequestConfig, logger: Logger): Promise<T>;
|