@alipay/ams-checkout 0.0.1699863258-dev.0 → 0.0.1700804278-dev.1
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 +0 -1
- package/esm/config/index.js +0 -8
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/component/index.d.ts +1 -3
- package/esm/core/component/index.js +3 -10
- package/esm/core/instance/index.d.ts +10 -23
- package/esm/core/instance/index.js +57 -136
- package/esm/plugin/component/index.d.ts +3 -1
- package/esm/plugin/component/index.js +76 -78
- package/esm/request/index.js +10 -7
- package/esm/request/utils.js +4 -1
- package/esm/service/index.d.ts +8 -2
- package/esm/service/index.js +2 -38
- package/esm/types/index.d.ts +18 -19
- package/esm/types/index.js +5 -1
- package/esm/util/index.d.ts +21 -6
- package/esm/util/index.js +45 -38
- package/esm/util/security.d.ts +8 -24
- package/esm/util/security.js +112 -165
- package/package.json +1 -1
- package/esm/util/versionCompare.d.ts +0 -10
- package/esm/util/versionCompare.js +0 -50
@@ -18,9 +18,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
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
20
|
import { queryPaymentInfo } from "../../service";
|
21
|
-
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
21
|
+
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, SecuritySceneEnum, 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";
|
24
25
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
25
26
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
26
27
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
@@ -47,7 +48,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
47
48
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
48
49
|
_defineProperty(this, "_appLocationSearch", void 0);
|
49
50
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
50
|
-
this
|
51
|
+
_defineProperty(this, "_multipleCallbackEvents", void 0);
|
52
|
+
this._appVersion = '1.6.0';
|
51
53
|
this._isInitComponent = false;
|
52
54
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
53
55
|
this.createIframeNode = function () {
|
@@ -84,6 +86,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
84
86
|
key: "initLoggerMeta",
|
85
87
|
value: function initLoggerMeta() {
|
86
88
|
var _this$_renderParams, _paymentSessionMetaDa;
|
89
|
+
console.log('this._renderParams', JSON.stringify(this._renderParams), null, 3);
|
87
90
|
var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
|
88
91
|
var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
|
89
92
|
this.AMSSDK.logger.setMedta({
|
@@ -112,39 +115,39 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
112
115
|
this.createIframeNode = renderFunc;
|
113
116
|
}
|
114
117
|
}, {
|
115
|
-
key: "
|
116
|
-
value: function
|
118
|
+
key: "initAPSecurity",
|
119
|
+
value: function initAPSecurity() {
|
117
120
|
var _this$_renderParams2,
|
118
121
|
_this = this;
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
});
|
122
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD !== this._componentSign) {
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
var securityConfig = (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionMetaData) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.securityConfig;
|
126
|
+
if (!securityConfig) {
|
127
|
+
return;
|
126
128
|
}
|
127
|
-
var
|
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
|
+
}
|
137
|
+
}
|
138
|
+
this.AMSSDK.logger.logInfo({
|
139
|
+
title: 'sdk_event_securitySdkInit'
|
129
140
|
});
|
130
|
-
|
131
|
-
|
132
|
-
title: '
|
141
|
+
initSecuritySDK(appName, h5gateway, function () {
|
142
|
+
_this.AMSSDK.logger.logInfo({
|
143
|
+
title: 'sdk_event_securitySdkInitSuccess'
|
133
144
|
});
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
});
|
145
|
+
}, function () {
|
146
|
+
// TODO Distinguishing Call Scenarios of Security SDK Failures
|
147
|
+
_this.AMSSDK.logger.logError({
|
148
|
+
title: 'sdk_error_securitySdkInitFailed'
|
146
149
|
});
|
147
|
-
}
|
150
|
+
});
|
148
151
|
}
|
149
152
|
}, {
|
150
153
|
key: "logDeviceId",
|
@@ -170,47 +173,23 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
170
173
|
key: "getDeviceIdAndLog",
|
171
174
|
value: function getDeviceIdAndLog() {
|
172
175
|
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;
|
175
176
|
return new Promise(function (resolve) {
|
176
177
|
// To avoid rendering being blocked, move the logic to the next event loop for processing
|
177
178
|
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
178
179
|
var _this2$_renderParams;
|
179
|
-
var
|
180
|
+
var securityConfig, getDeviceIdStartTime, deviceId;
|
180
181
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
181
182
|
while (1) switch (_context.prev = _context.next) {
|
182
183
|
case 0:
|
183
|
-
|
184
|
+
securityConfig = (_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionMetaData) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.securityConfig;
|
184
185
|
getDeviceIdStartTime = Date.now();
|
185
|
-
|
186
|
-
|
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;
|
186
|
+
_context.next = 4;
|
187
|
+
return getApdidToken(getAppname(SecuritySceneEnum.CARD), securityConfig);
|
188
|
+
case 4:
|
189
|
+
deviceId = _context.sent;
|
210
190
|
_this2.logDeviceId(deviceId, getDeviceIdStartTime);
|
211
|
-
case 16:
|
212
191
|
resolve(deviceId);
|
213
|
-
case
|
192
|
+
case 7:
|
214
193
|
case "end":
|
215
194
|
return _context.stop();
|
216
195
|
}
|
@@ -236,7 +215,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
236
215
|
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
237
216
|
this._renderDisplayType = renderParams.renderDisplayType;
|
238
217
|
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
239
|
-
this.
|
218
|
+
this.initAPSecurity();
|
240
219
|
this.initLoggerMeta();
|
241
220
|
this._performanceData.push({
|
242
221
|
key: 'sdk_create_component',
|
@@ -359,7 +338,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
359
338
|
envInfo.deviceId = _context2.sent;
|
360
339
|
case 11:
|
361
340
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
362
|
-
_context2.next =
|
341
|
+
_context2.next = 16;
|
363
342
|
break;
|
364
343
|
}
|
365
344
|
_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;
|
@@ -373,43 +352,38 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
373
352
|
success: true
|
374
353
|
}));
|
375
354
|
case 16:
|
376
|
-
_context2.next = 18;
|
377
|
-
return _this5.getDeviceIdAndLog();
|
378
|
-
case 18:
|
379
|
-
envInfo.deviceId = _context2.sent;
|
380
|
-
case 19:
|
381
355
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
382
|
-
_context2.next =
|
356
|
+
_context2.next = 23;
|
383
357
|
break;
|
384
358
|
}
|
385
359
|
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) || {};
|
386
360
|
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;
|
387
361
|
if (!(signType === 'SMS')) {
|
388
|
-
_context2.next =
|
362
|
+
_context2.next = 21;
|
389
363
|
break;
|
390
364
|
}
|
391
365
|
return _context2.abrupt("return", resolve({
|
392
366
|
message: 'sdk no need to make query request',
|
393
367
|
success: true
|
394
368
|
}));
|
395
|
-
case
|
369
|
+
case 21:
|
396
370
|
if (!(!signType || signType !== 'REDIRECT')) {
|
397
|
-
_context2.next =
|
371
|
+
_context2.next = 23;
|
398
372
|
break;
|
399
373
|
}
|
400
374
|
return _context2.abrupt("return", resolve({
|
401
375
|
success: false
|
402
376
|
}));
|
403
|
-
case
|
377
|
+
case 23:
|
404
378
|
if (!isLocalMock()) {
|
405
|
-
_context2.next =
|
379
|
+
_context2.next = 25;
|
406
380
|
break;
|
407
381
|
}
|
408
382
|
return _context2.abrupt("return", resolve({
|
409
383
|
message: 'sdk no need to make query request',
|
410
384
|
success: true
|
411
385
|
}));
|
412
|
-
case
|
386
|
+
case 25:
|
413
387
|
queryPaymentInfo(params, {
|
414
388
|
env: _this5.AMSSDK.options.env.environment,
|
415
389
|
envInfo: envInfo
|
@@ -434,7 +408,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
434
408
|
});
|
435
409
|
reject(err);
|
436
410
|
});
|
437
|
-
case
|
411
|
+
case 26:
|
438
412
|
case "end":
|
439
413
|
return _context2.stop();
|
440
414
|
}
|
@@ -584,7 +558,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
584
558
|
break;
|
585
559
|
}
|
586
560
|
_context3.next = 3;
|
587
|
-
return this.getDeviceIdAndLog(
|
561
|
+
return this.getDeviceIdAndLog();
|
588
562
|
case 3:
|
589
563
|
deviceId = _context3.sent;
|
590
564
|
this.dispatchToApp({
|
@@ -632,7 +606,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
632
606
|
}, {
|
633
607
|
key: "_handleAppMessage",
|
634
608
|
value: function _handleAppMessage(data) {
|
635
|
-
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name];
|
609
|
+
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name, EVENT.declareEventCallbackInfo.name];
|
636
610
|
if (!eventKeyMap.includes(data.context.event)) {
|
637
611
|
return;
|
638
612
|
}
|
@@ -705,6 +679,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
705
679
|
this.handleDeclareInfo(data.context.data);
|
706
680
|
return;
|
707
681
|
}
|
682
|
+
if (data.context.event === EVENT.declareEventCallbackInfo.name) {
|
683
|
+
this._multipleCallbackEvents = data.context.data;
|
684
|
+
return;
|
685
|
+
}
|
708
686
|
if (data.context.event === EVENT.eventCallback.name) {
|
709
687
|
this.AMSSDK.logger.logInfo({
|
710
688
|
title: 'sdk_event_event_callback'
|
@@ -796,7 +774,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
796
774
|
};
|
797
775
|
var failCallback = function failCallback(type, url) {
|
798
776
|
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
799
|
-
code: eventCodeEnum.
|
777
|
+
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
800
778
|
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)
|
801
779
|
});
|
802
780
|
_this6.AMSSDK.logger.logInfo({
|
@@ -847,6 +825,24 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
847
825
|
closeDialogData: closeDialogData
|
848
826
|
});
|
849
827
|
}
|
828
|
+
}, {
|
829
|
+
key: "handleDeclarePopWindowCallback",
|
830
|
+
value: function handleDeclarePopWindowCallback() {
|
831
|
+
var eventInfoName = 'popWindowEventInfo';
|
832
|
+
if (this._multipleCallbackEvents && eventInfoName in this._multipleCallbackEvents) {
|
833
|
+
var eventInfo = this._multipleCallbackEvents[eventInfoName];
|
834
|
+
if (eventInfo.enableCallback) {
|
835
|
+
this.dispatchToSDK(EVENT.eventCallback.name, {
|
836
|
+
code: eventInfo.eventName,
|
837
|
+
result: {
|
838
|
+
result: eventInfo.eventResult
|
839
|
+
}
|
840
|
+
});
|
841
|
+
}
|
842
|
+
} else {
|
843
|
+
console.log("not valid ".concat(eventInfoName, " in "), this._multipleCallbackEvents);
|
844
|
+
}
|
845
|
+
}
|
850
846
|
}, {
|
851
847
|
key: "handleCloseBtnShow",
|
852
848
|
value: function handleCloseBtnShow(showClose) {
|
@@ -1021,6 +1017,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1021
1017
|
if (this._isRetention) this.showRetentionPopup();else {
|
1022
1018
|
this.cleanContainer();
|
1023
1019
|
this.dispatchToSDK(EVENT.close.name, {});
|
1020
|
+
this.handleDeclarePopWindowCallback();
|
1024
1021
|
}
|
1025
1022
|
}
|
1026
1023
|
}, {
|
@@ -1029,6 +1026,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1029
1026
|
this.dispatchToSDK(EVENT.close.name, {});
|
1030
1027
|
this.hideRetentionPopupFunc();
|
1031
1028
|
this.cleanContainer();
|
1029
|
+
this.handleDeclarePopWindowCallback();
|
1032
1030
|
}
|
1033
1031
|
}, {
|
1034
1032
|
key: "removeRetentionPopup",
|
package/esm/request/index.js
CHANGED
@@ -15,13 +15,12 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
15
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
16
16
|
*/
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
|
-
import axios from 'axios';
|
19
18
|
import { sdkVersion } from "../config/index";
|
20
19
|
import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
|
21
20
|
import { errorEnum } from "../types";
|
22
|
-
import { device, isPC, queryParse, safeJson } from "../util";
|
23
21
|
import { get } from "../util/get";
|
24
|
-
import
|
22
|
+
import axios from 'axios';
|
23
|
+
import { device, fomatGetwayError, isPC, queryParse, safeJson } from "../util";
|
25
24
|
var _queryParse = queryParse(),
|
26
25
|
_sandbox = _queryParse._sandbox;
|
27
26
|
function requestInstance(options) {
|
@@ -48,7 +47,7 @@ function requestInstance(options) {
|
|
48
47
|
timeout: (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 15000,
|
49
48
|
headers: _headers,
|
50
49
|
withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
|
51
|
-
method:
|
50
|
+
method: 'POST'
|
52
51
|
});
|
53
52
|
return instance.request;
|
54
53
|
}
|
@@ -89,12 +88,12 @@ function _request() {
|
|
89
88
|
// eslint-disable-next-line no-empty
|
90
89
|
} catch (error) {}
|
91
90
|
if (envInfo.terminalType === 'WAP') envInfo.osType = device.iOS ? 'IOS' : 'ANDROID';
|
92
|
-
_data = [_objectSpread(_objectSpread({}, requestData), {}, {
|
91
|
+
_data = options.needEnvInfo ? [_objectSpread(_objectSpread({}, requestData), {}, {
|
93
92
|
envInfo: envInfo,
|
94
93
|
extParams: {
|
95
94
|
refUrl: window.location.href
|
96
95
|
}
|
97
|
-
})];
|
96
|
+
})] : [requestData];
|
98
97
|
startTime = Date.now();
|
99
98
|
_context.prev = 5;
|
100
99
|
myRequest = requestInstance(options);
|
@@ -124,6 +123,8 @@ function _request() {
|
|
124
123
|
code: errorCode,
|
125
124
|
msg: errorMessage,
|
126
125
|
traceId: traceId
|
126
|
+
}, {
|
127
|
+
// TODO Concerned input data
|
127
128
|
}).send();
|
128
129
|
throw new Error(JSON.stringify({
|
129
130
|
errorMessage: errorMessage,
|
@@ -157,7 +158,9 @@ function _request() {
|
|
157
158
|
time: Date.now() - startTime,
|
158
159
|
success: false,
|
159
160
|
code: _errorCode,
|
160
|
-
msg:
|
161
|
+
msg: _error === null || _error === void 0 ? void 0 : _error.message
|
162
|
+
}, {
|
163
|
+
// TODO Concerned input data
|
161
164
|
}).send();
|
162
165
|
return _context.abrupt("return", Promise.reject({
|
163
166
|
success: false,
|
package/esm/request/utils.js
CHANGED
@@ -5,9 +5,11 @@
|
|
5
5
|
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
6
6
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
7
7
|
*/
|
8
|
-
|
8
|
+
|
9
9
|
import { errorEnum } from "../types";
|
10
10
|
import { get } from "../util/get";
|
11
|
+
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
11
13
|
export var safeJson = function safeJson(data, obj) {
|
12
14
|
try {
|
13
15
|
return JSON.parse(data) || obj;
|
@@ -17,6 +19,7 @@ export var safeJson = function safeJson(data, obj) {
|
|
17
19
|
};
|
18
20
|
|
19
21
|
// 判断header 中的resultStatus
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
20
23
|
export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
21
24
|
var resultStatus = get(headers, 'Result-Status') || get(headers, 'result-status', '');
|
22
25
|
// 请求静态数据情况
|
package/esm/service/index.d.ts
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
6
|
+
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
7
|
+
*/
|
2
8
|
import { Logger } from '../util/logger';
|
9
|
+
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, IrequestConfig } from '../types';
|
3
10
|
export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: IrequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
|
4
|
-
export declare function antomConfig(options: IrequestConfig, logger: Logger): Promise<any>;
|
package/esm/service/index.js
CHANGED
@@ -14,7 +14,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
14
14
|
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
15
15
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
16
16
|
*/
|
17
|
-
|
17
|
+
|
18
18
|
import { request } from "../request";
|
19
19
|
export function queryPaymentInfo(_x, _x2, _x3) {
|
20
20
|
return _queryPaymentInfo.apply(this, arguments);
|
@@ -28,6 +28,7 @@ function _queryPaymentInfo() {
|
|
28
28
|
hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
|
29
29
|
return _context.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
|
30
30
|
hostSign: hostSign,
|
31
|
+
needEnvInfo: true,
|
31
32
|
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
32
33
|
}), logger));
|
33
34
|
case 2:
|
@@ -37,41 +38,4 @@ function _queryPaymentInfo() {
|
|
37
38
|
}, _callee);
|
38
39
|
}));
|
39
40
|
return _queryPaymentInfo.apply(this, arguments);
|
40
|
-
}
|
41
|
-
export function antomConfig(_x4, _x5) {
|
42
|
-
return _antomConfig.apply(this, arguments);
|
43
|
-
}
|
44
|
-
function _antomConfig() {
|
45
|
-
_antomConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, logger) {
|
46
|
-
var res, json;
|
47
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
48
|
-
while (1) switch (_context2.prev = _context2.next) {
|
49
|
-
case 0:
|
50
|
-
_context2.prev = 0;
|
51
|
-
_context2.next = 3;
|
52
|
-
return fetch(marmotConfigMap[options.env]);
|
53
|
-
case 3:
|
54
|
-
res = _context2.sent;
|
55
|
-
_context2.next = 6;
|
56
|
-
return res.json();
|
57
|
-
case 6:
|
58
|
-
json = _context2.sent;
|
59
|
-
logger.logInfo({
|
60
|
-
title: 'Successfully obtained marmot emergency configuration'
|
61
|
-
});
|
62
|
-
return _context2.abrupt("return", json);
|
63
|
-
case 11:
|
64
|
-
_context2.prev = 11;
|
65
|
-
_context2.t0 = _context2["catch"](0);
|
66
|
-
logger.logError({
|
67
|
-
title: 'Abnormal acquisition of marmot emergency configuration'
|
68
|
-
});
|
69
|
-
return _context2.abrupt("return", '{}');
|
70
|
-
case 15:
|
71
|
-
case "end":
|
72
|
-
return _context2.stop();
|
73
|
-
}
|
74
|
-
}, _callee2, null, [[0, 11]]);
|
75
|
-
}));
|
76
|
-
return _antomConfig.apply(this, arguments);
|
77
41
|
}
|
package/esm/types/index.d.ts
CHANGED
@@ -22,7 +22,7 @@ export interface IoptionsParams {
|
|
22
22
|
analytics?: {
|
23
23
|
enabled: boolean;
|
24
24
|
};
|
25
|
-
|
25
|
+
securityConfig?: IsecurityConfig;
|
26
26
|
}
|
27
27
|
export type Iselector = string;
|
28
28
|
export declare enum renderDisplayTypeEnum {
|
@@ -50,21 +50,13 @@ export declare enum productSceneEnum {
|
|
50
50
|
'EASY_PAY' = "EASY_PAY",
|
51
51
|
'CASHIER_PAYMENT' = "CASHIER_PAYMENT",
|
52
52
|
'AUTO_DEBIT' = "AUTO_DEBIT",
|
53
|
-
'VAULTING' = "VAULTING"
|
54
|
-
'FLASH_BUY' = "FLASH_BUY"
|
53
|
+
'VAULTING' = "VAULTING"
|
55
54
|
}
|
56
55
|
export declare enum paymentMethodCategoryTypeEnum {
|
57
56
|
'CARD' = "CARD",
|
58
57
|
'WALLET' = "WALLET",
|
59
58
|
'BANK' = "BANK"
|
60
59
|
}
|
61
|
-
export interface DeviceIdParameter {
|
62
|
-
scene?: string;
|
63
|
-
productScene?: productSceneEnum;
|
64
|
-
paymentMethodCategoryType?: paymentMethodCategoryTypeEnum;
|
65
|
-
tokenCollectTime?: string;
|
66
|
-
dataPollingInterval?: string;
|
67
|
-
}
|
68
60
|
export interface IcreateComponent {
|
69
61
|
sessionData: string;
|
70
62
|
paymentSessionData?: string;
|
@@ -102,14 +94,6 @@ export interface IpaymentSecurityConfig {
|
|
102
94
|
dataPollingInterval?: string;
|
103
95
|
workSpaceId: string;
|
104
96
|
}
|
105
|
-
export interface IsecurityConfig {
|
106
|
-
scene: string;
|
107
|
-
h5gateway: string;
|
108
|
-
}
|
109
|
-
export interface InitSecurityConfig {
|
110
|
-
product: productSceneEnum;
|
111
|
-
region?: string;
|
112
|
-
}
|
113
97
|
export interface IpaymentSessionMetaData {
|
114
98
|
clientId?: string;
|
115
99
|
renderDisplayType?: string;
|
@@ -232,7 +216,6 @@ export interface AMSCheckoutOptions {
|
|
232
216
|
networkMode: string;
|
233
217
|
mode: string;
|
234
218
|
analytics?: Ianalytics;
|
235
|
-
product: string;
|
236
219
|
}
|
237
220
|
export interface Ianalytics {
|
238
221
|
enabled: boolean;
|
@@ -313,6 +296,14 @@ export interface ThreedData {
|
|
313
296
|
pti?: number;
|
314
297
|
pt?: number;
|
315
298
|
}
|
299
|
+
export declare enum SecuritySceneEnum {
|
300
|
+
CARD = "CARD",
|
301
|
+
EASYPAY = "EASYPAY"
|
302
|
+
}
|
303
|
+
export interface IsecurityConfig {
|
304
|
+
scene: string;
|
305
|
+
region: string;
|
306
|
+
}
|
316
307
|
export declare enum RedirectType {
|
317
308
|
ApplinkUrl = "ApplinkUrl",
|
318
309
|
SchemeUrl = "SchemeUrl",
|
@@ -324,4 +315,12 @@ declare global {
|
|
324
315
|
[key: string]: any;
|
325
316
|
}
|
326
317
|
}
|
318
|
+
export interface CallbackEventInfo {
|
319
|
+
enableCallback: boolean;
|
320
|
+
eventName: string;
|
321
|
+
eventResult?: any;
|
322
|
+
}
|
323
|
+
export interface MultipleCallbackEvents {
|
324
|
+
[key: string]: CallbackEventInfo;
|
325
|
+
}
|
327
326
|
export {};
|
package/esm/types/index.js
CHANGED
@@ -29,7 +29,6 @@ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
|
|
29
29
|
productSceneEnum["CASHIER_PAYMENT"] = "CASHIER_PAYMENT";
|
30
30
|
productSceneEnum["AUTO_DEBIT"] = "AUTO_DEBIT";
|
31
31
|
productSceneEnum["VAULTING"] = "VAULTING";
|
32
|
-
productSceneEnum["FLASH_BUY"] = "FLASH_BUY";
|
33
32
|
return productSceneEnum;
|
34
33
|
}({});
|
35
34
|
export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodCategoryTypeEnum) {
|
@@ -136,6 +135,11 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
|
|
136
135
|
eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
|
137
136
|
return eventCodeEnum;
|
138
137
|
}({});
|
138
|
+
export var SecuritySceneEnum = /*#__PURE__*/function (SecuritySceneEnum) {
|
139
|
+
SecuritySceneEnum["CARD"] = "CARD";
|
140
|
+
SecuritySceneEnum["EASYPAY"] = "EASYPAY";
|
141
|
+
return SecuritySceneEnum;
|
142
|
+
}({});
|
139
143
|
export var RedirectType = /*#__PURE__*/function (RedirectType) {
|
140
144
|
RedirectType["ApplinkUrl"] = "ApplinkUrl";
|
141
145
|
RedirectType["SchemeUrl"] = "SchemeUrl";
|
package/esm/util/index.d.ts
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
5
5
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
6
6
|
*/
|
7
|
+
import { errorEnum } from '../types';
|
7
8
|
declare const getType: (target: any) => string;
|
8
9
|
declare class EventCenter {
|
9
10
|
private events;
|
@@ -27,14 +28,28 @@ declare const device: {
|
|
27
28
|
isMobile: boolean;
|
28
29
|
};
|
29
30
|
declare const safeJson: (data: any, obj: any) => any;
|
31
|
+
declare const fomatGetwayError: (headers: Record<string, any>, traceId: string) => {
|
32
|
+
success: boolean;
|
33
|
+
traceId: string;
|
34
|
+
errorCode: errorEnum;
|
35
|
+
resultStatus: any;
|
36
|
+
errorMessage?: undefined;
|
37
|
+
result?: undefined;
|
38
|
+
} | {
|
39
|
+
success: boolean;
|
40
|
+
traceId: string;
|
41
|
+
errorCode: errorEnum;
|
42
|
+
errorMessage: string;
|
43
|
+
result: {
|
44
|
+
resultStatus: any;
|
45
|
+
tips: string;
|
46
|
+
memo: string;
|
47
|
+
};
|
48
|
+
resultStatus: any;
|
49
|
+
};
|
30
50
|
declare const isPC: () => boolean;
|
31
51
|
declare const queryParse: (url?: string) => Record<string, any>;
|
32
52
|
declare const getDesignFontSize: () => number;
|
33
53
|
declare const amsSetSize: (event?: any, dom?: any) => void;
|
34
54
|
declare const addSetFontSizeEvent: () => void;
|
35
|
-
|
36
|
-
* @description get or set STORAGE
|
37
|
-
*/
|
38
|
-
declare const getOrSetStorageId: (key: string, value?: string) => string;
|
39
|
-
declare const checkTimeElapsed: () => boolean;
|
40
|
-
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, };
|
55
|
+
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent };
|