@alipay/ams-checkout 0.0.1699863258-dev.1 → 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.
@@ -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._appVersion = '1.6.2';
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: "initSecurity",
116
- value: function initSecurity() {
118
+ key: "initAPSecurity",
119
+ value: function initAPSecurity() {
117
120
  var _this$_renderParams2,
118
121
  _this = this;
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
- });
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 securitySDK = this.AMSSDK._getSecuritySDKByProductScene({
128
- product: product
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
- if (!securitySDK) {
131
- this.AMSSDK.logger.logInfo({
132
- title: 'sdk_event_securitySdkInit'
141
+ initSecuritySDK(appName, h5gateway, function () {
142
+ _this.AMSSDK.logger.logInfo({
143
+ title: 'sdk_event_securitySdkInitSuccess'
133
144
  });
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
- });
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 productScene, getDeviceIdStartTime, securitySDK, deviceId;
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
- 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;
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
- 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;
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 17:
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.initSecurity();
218
+ this.initAPSecurity();
240
219
  this.initLoggerMeta();
241
220
  this._performanceData.push({
242
221
  key: 'sdk_create_component',
@@ -323,8 +302,8 @@ var ComponentApp = /*#__PURE__*/function () {
323
302
  // eslint-disable-next-line no-async-promise-executor
324
303
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
325
304
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
326
- var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3;
327
- var envInfo, params, _this5$_renderParams4, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams5, _action$web, _action$wap, action, signType;
305
+ var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
306
+ 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;
328
307
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
329
308
  while (1) switch (_context2.prev = _context2.next) {
330
309
  case 0:
@@ -339,68 +318,72 @@ var ComponentApp = /*#__PURE__*/function () {
339
318
  /**
340
319
  * @description card
341
320
  */
342
- if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
343
- _context2.next = 7;
321
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign) {
322
+ params.paymentMethodType = 'CARD';
323
+ }
324
+ 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;
325
+ if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign && securityConfig)) {
326
+ _context2.next = 11;
344
327
  break;
345
328
  }
346
- params.paymentMethodType = 'CARD';
347
- _context2.next = 6;
329
+ 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) || '{}';
330
+ info = JSON.parse(extendInfo);
331
+ if (!((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false')) {
332
+ _context2.next = 11;
333
+ break;
334
+ }
335
+ _context2.next = 10;
348
336
  return _this5.getDeviceIdAndLog();
349
- case 6:
337
+ case 10:
350
338
  envInfo.deviceId = _context2.sent;
351
- case 7:
339
+ case 11:
352
340
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
353
- _context2.next = 15;
341
+ _context2.next = 16;
354
342
  break;
355
343
  }
356
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;
357
- _ref4 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.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;
345
+ _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
346
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
359
- _context2.next = 12;
347
+ _context2.next = 16;
360
348
  break;
361
349
  }
362
350
  return _context2.abrupt("return", resolve({
363
351
  message: 'sdk no need to make query request',
364
352
  success: true
365
353
  }));
366
- case 12:
367
- _context2.next = 14;
368
- return _this5.getDeviceIdAndLog();
369
- case 14:
370
- envInfo.deviceId = _context2.sent;
371
- case 15:
354
+ case 16:
372
355
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
373
- _context2.next = 22;
356
+ _context2.next = 23;
374
357
  break;
375
358
  }
376
- action = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.action) || {};
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) || {};
377
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;
378
361
  if (!(signType === 'SMS')) {
379
- _context2.next = 20;
362
+ _context2.next = 21;
380
363
  break;
381
364
  }
382
365
  return _context2.abrupt("return", resolve({
383
366
  message: 'sdk no need to make query request',
384
367
  success: true
385
368
  }));
386
- case 20:
369
+ case 21:
387
370
  if (!(!signType || signType !== 'REDIRECT')) {
388
- _context2.next = 22;
371
+ _context2.next = 23;
389
372
  break;
390
373
  }
391
374
  return _context2.abrupt("return", resolve({
392
375
  success: false
393
376
  }));
394
- case 22:
377
+ case 23:
395
378
  if (!isLocalMock()) {
396
- _context2.next = 24;
379
+ _context2.next = 25;
397
380
  break;
398
381
  }
399
382
  return _context2.abrupt("return", resolve({
400
383
  message: 'sdk no need to make query request',
401
384
  success: true
402
385
  }));
403
- case 24:
386
+ case 25:
404
387
  queryPaymentInfo(params, {
405
388
  env: _this5.AMSSDK.options.env.environment,
406
389
  envInfo: envInfo
@@ -425,7 +408,7 @@ var ComponentApp = /*#__PURE__*/function () {
425
408
  });
426
409
  reject(err);
427
410
  });
428
- case 25:
411
+ case 26:
429
412
  case "end":
430
413
  return _context2.stop();
431
414
  }
@@ -575,7 +558,7 @@ var ComponentApp = /*#__PURE__*/function () {
575
558
  break;
576
559
  }
577
560
  _context3.next = 3;
578
- return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
561
+ return this.getDeviceIdAndLog();
579
562
  case 3:
580
563
  deviceId = _context3.sent;
581
564
  this.dispatchToApp({
@@ -623,7 +606,7 @@ var ComponentApp = /*#__PURE__*/function () {
623
606
  }, {
624
607
  key: "_handleAppMessage",
625
608
  value: function _handleAppMessage(data) {
626
- 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];
627
610
  if (!eventKeyMap.includes(data.context.event)) {
628
611
  return;
629
612
  }
@@ -696,6 +679,10 @@ var ComponentApp = /*#__PURE__*/function () {
696
679
  this.handleDeclareInfo(data.context.data);
697
680
  return;
698
681
  }
682
+ if (data.context.event === EVENT.declareEventCallbackInfo.name) {
683
+ this._multipleCallbackEvents = data.context.data;
684
+ return;
685
+ }
699
686
  if (data.context.event === EVENT.eventCallback.name) {
700
687
  this.AMSSDK.logger.logInfo({
701
688
  title: 'sdk_event_event_callback'
@@ -787,7 +774,7 @@ var ComponentApp = /*#__PURE__*/function () {
787
774
  };
788
775
  var failCallback = function failCallback(type, url) {
789
776
  _this6.dispatchToSDK(EVENT.eventCallback.name, {
790
- code: eventCodeEnum.SDK_CALL_URL_ERROR,
777
+ code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
791
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)
792
779
  });
793
780
  _this6.AMSSDK.logger.logInfo({
@@ -838,6 +825,24 @@ var ComponentApp = /*#__PURE__*/function () {
838
825
  closeDialogData: closeDialogData
839
826
  });
840
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
+ }
841
846
  }, {
842
847
  key: "handleCloseBtnShow",
843
848
  value: function handleCloseBtnShow(showClose) {
@@ -1012,6 +1017,7 @@ var ComponentApp = /*#__PURE__*/function () {
1012
1017
  if (this._isRetention) this.showRetentionPopup();else {
1013
1018
  this.cleanContainer();
1014
1019
  this.dispatchToSDK(EVENT.close.name, {});
1020
+ this.handleDeclarePopWindowCallback();
1015
1021
  }
1016
1022
  }
1017
1023
  }, {
@@ -1020,6 +1026,7 @@ var ComponentApp = /*#__PURE__*/function () {
1020
1026
  this.dispatchToSDK(EVENT.close.name, {});
1021
1027
  this.hideRetentionPopupFunc();
1022
1028
  this.cleanContainer();
1029
+ this.handleDeclarePopWindowCallback();
1023
1030
  }
1024
1031
  }, {
1025
1032
  key: "removeRetentionPopup",
@@ -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 { fomatGetwayError } from "./utils";
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: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
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: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t0)
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,
@@ -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
- /* eslint-disable @typescript-eslint/no-explicit-any */
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
  // 请求静态数据情况
@@ -1,4 +1,10 @@
1
- import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, IrequestConfig } from '../types';
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>;
@@ -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
- import { marmotConfigMap } from "../config";
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
  }
@@ -22,7 +22,7 @@ export interface IoptionsParams {
22
22
  analytics?: {
23
23
  enabled: boolean;
24
24
  };
25
- product?: string;
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 {};
@@ -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";
@@ -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 };