@alipay/ams-checkout 0.0.1783663570-dev.6 → 0.0.1784095668-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/ams-checkout.js +3 -4
  2. package/dist/ams-checkout.min.js +1 -2
  3. package/esm/config/index.d.ts +0 -7
  4. package/esm/config/index.js +2 -2
  5. package/esm/constant/element.d.ts +1 -2
  6. package/esm/constant/element.js +0 -1
  7. package/esm/constant/index.d.ts +21 -4
  8. package/esm/core/component/element/elementController/index.d.ts +3 -3
  9. package/esm/core/component/element/elementController/index.js +42 -66
  10. package/esm/core/component/element/elementProcessor/paymentProcessor.js +10 -13
  11. package/esm/core/component/element/index.d.ts +1 -4
  12. package/esm/core/component/element/index.js +4 -19
  13. package/esm/core/component/element/type.d.ts +18 -16
  14. package/esm/core/instance/index.d.ts +4 -12
  15. package/esm/core/instance/index.js +26 -152
  16. package/esm/foundation/service/event-center.js +1 -1
  17. package/esm/foundation/service/security/index.d.ts +4 -9
  18. package/esm/foundation/service/security/index.js +35 -158
  19. package/esm/foundation/service/security/security.d.ts +1 -22
  20. package/esm/foundation/service/security/security.js +37 -150
  21. package/esm/foundation/utils/preload_helper.d.ts +3 -6
  22. package/esm/foundation/utils/preload_helper.js +32 -122
  23. package/esm/main.js +4 -4
  24. package/esm/modern/index.d.ts +1 -5
  25. package/esm/modern/index.js +51 -1
  26. package/esm/modern/stageName.d.ts +3 -0
  27. package/esm/modern/stageName.js +1 -0
  28. package/esm/plugin/component/channel.d.ts +2 -2
  29. package/esm/plugin/component/channel.js +18 -18
  30. package/esm/plugin/component/index.js +29 -36
  31. package/esm/types/index.d.ts +0 -1
  32. package/esm/util/beforeConfirm.d.ts +2 -4
  33. package/esm/util/beforeConfirm.js +14 -15
  34. package/esm/util/logger.js +2 -1
  35. package/esm/util/security.d.ts +1 -22
  36. package/esm/util/security.js +39 -150
  37. package/package.json +9 -15
  38. package/types.d.ts +94 -785
  39. package/types.untrimmed.d.ts +108 -929
  40. package/dist/ams-checkout.min.js.map +0 -1
  41. package/esm/core/component/element/modernElementController/adapter.d.ts +0 -19
  42. package/esm/core/component/element/modernElementController/adapter.js +0 -73
  43. package/esm/core/component/element/modernElementController/index.d.ts +0 -149
  44. package/esm/core/component/element/modernElementController/index.js +0 -1665
  45. package/esm/modern/global.d.ts +0 -3
  46. package/esm/modern/tools.js +0 -1
  47. package/esm/util/jshield-apdid/apdid-loader.js +0 -340
  48. package/esm/util/jshield-apdid/index.js +0 -21
  49. package/esm/util/security-registry.d.ts +0 -72
  50. package/esm/util/security-registry.js +0 -175
@@ -1,10 +1,3 @@
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
- */
8
1
  export declare const marmotMap: Record<string, string>;
9
2
  export declare const marmotConfigMap: Record<string, string>;
10
3
  export declare const v2AppMarmotMap: Record<string, string>;
@@ -5,7 +5,7 @@
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
+ import json from "../../package.json";
9
9
  export var marmotMap = {
10
10
  dev: 'http://page.alipay.net/page/antom-web-checkout/src/component-app',
11
11
  sit: 'http://page.test.alipay.net/page/antom-web-checkout/src/component-app',
@@ -30,7 +30,7 @@ export var v2AppMarmotMap = {
30
30
  light_sandbox: 'https://checkout.antom.com',
31
31
  prod: 'https://checkout.antom.com'
32
32
  };
33
- export var sdkVersion = "0.0.1783663570-dev.6";
33
+ export var sdkVersion = json.version;
34
34
 
35
35
  /**
36
36
  * @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
@@ -22,6 +22,5 @@ export declare enum ELEMENT_PAGE_URL {
22
22
  INSTRUCTION_GUIDE = "/elements/pages/instruction-guide/index.html",
23
23
  THREED_PAGE = "/elements/pages/threed-page/index.html",
24
24
  ELEMENT_AUTH = "/auth-element/pages/element_auth/index.html",
25
- ADDRESS = "/element-address/pages/address/index.html",
26
- NEW_ELEMENT_PAYMENT = "/elements2/pages/element_payment/index.html"
25
+ ADDRESS = "/element-address/pages/address/index.html"
27
26
  }
@@ -26,6 +26,5 @@ export var ELEMENT_PAGE_URL = /*#__PURE__*/function (ELEMENT_PAGE_URL) {
26
26
  ELEMENT_PAGE_URL["THREED_PAGE"] = "/elements/pages/threed-page/index.html";
27
27
  ELEMENT_PAGE_URL["ELEMENT_AUTH"] = "/auth-element/pages/element_auth/index.html";
28
28
  ELEMENT_PAGE_URL["ADDRESS"] = "/element-address/pages/address/index.html";
29
- ELEMENT_PAGE_URL["NEW_ELEMENT_PAYMENT"] = "/elements2/pages/element_payment/index.html";
30
29
  return ELEMENT_PAGE_URL;
31
30
  }({});
@@ -325,7 +325,24 @@ export declare const LOADINGIMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA
325
325
  /**
326
326
  * @description Promise回调code映射
327
327
  */
328
- export declare const PROMISE_CALLBACK_CODE: Record<string, {
329
- code: string;
330
- message?: string;
331
- }>;
328
+ export declare const PROMISE_CALLBACK_CODE: {
329
+ SUCCESS: {
330
+ code: string;
331
+ };
332
+ UNKNOWN_EXCEPTION: {
333
+ code: string;
334
+ message: string;
335
+ };
336
+ REPEAT_REQ_REJECT: {
337
+ code: string;
338
+ message: string;
339
+ };
340
+ PROCESS_FAIL: {
341
+ code: string;
342
+ message: string;
343
+ };
344
+ INQUIRY_PAYMENT_SESSION_FAILED: {
345
+ code: string;
346
+ message: string;
347
+ };
348
+ };
@@ -1,5 +1,5 @@
1
- import { AddressMountOptions, EventDataMap, EVENTNAME, ICommonApiResponse, IElementController, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions, SubmitFuncParams } from '../type';
2
- declare class ElementController implements IElementController {
1
+ import { AddressMountOptions, EventDataMap, EVENTNAME, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions, SubmitFuncParams } from '../type';
2
+ declare class ElementController {
3
3
  private options;
4
4
  private elementContainer;
5
5
  private serviceMap;
@@ -44,7 +44,7 @@ declare class ElementController implements IElementController {
44
44
  private getErrorFromResponse;
45
45
  private areAllContainersReady;
46
46
  private sendReady;
47
- updatePayment(paymentSessionData: string): Promise<boolean>;
47
+ updatePayment(paymentSessionData: any): Promise<unknown>;
48
48
  private destroyHandle;
49
49
  destroy(): void;
50
50
  private setControllerStatusOrView;
@@ -37,7 +37,7 @@ import { ServiceProvider } from "../../../../foundation/service";
37
37
  import { convertPaymentSession } from "../../../../foundation/utils/payment_context_utils";
38
38
  import { ProductSceneEnum } from "../../../../types";
39
39
  import { ELEMENT_SPM_MAP } from "../../../../util/spm-map";
40
- import { executeWithTimeout, BEFORE_CONFIRM_TIMEOUT_MS, MERCHANT_CONFIRM_ABORT_CODE, MERCHANT_CONFIRM_TIMEOUT_CODE } from "../../../../util/beforeConfirm";
40
+ import { executeWithTimeout, BEFORE_CONFIRM_TIMEOUT_MS } from "../../../../util/beforeConfirm";
41
41
  import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
42
42
  import { IContainerStatus } from "../elementContainerService/containerService";
43
43
  import { EventCenter as ElementEventCenter } from "../EventCenter/index";
@@ -233,7 +233,6 @@ var ElementController = /*#__PURE__*/function () {
233
233
  }, {
234
234
  key: "initializeAndMountProcessor",
235
235
  value: function initializeAndMountProcessor(type, selector, options) {
236
- var _this$serviceMap$Log, _options$appearance;
237
236
  this.initElementProcessors(type);
238
237
  // 创建 iframe,拉起应用页面,同时监听全局的数据更新和获取事件
239
238
  this.elementContainerService.mount({
@@ -249,12 +248,6 @@ var ElementController = /*#__PURE__*/function () {
249
248
  ServiceProvider.getInstance(newInstanceId).update(paymentContext);
250
249
  // 更新埋点service
251
250
  this.serviceMap.Log = ServiceProvider.getInstance(newInstanceId).getService('Log');
252
- (_this$serviceMap$Log = this.serviceMap.Log) === null || _this$serviceMap$Log === void 0 || _this$serviceMap$Log.logInfo({
253
- title: 'sdk_event_appearance'
254
- }, {
255
- variables: options !== null && options !== void 0 && (_options$appearance = options.appearance) !== null && _options$appearance !== void 0 && _options$appearance.variables ? true : false,
256
- theme: options === null || options === void 0 ? void 0 : options.theme
257
- });
258
251
  this.elementProcessors[type].beforeMount();
259
252
  }
260
253
  // 处理业务流程启动失败
@@ -382,7 +375,7 @@ var ElementController = /*#__PURE__*/function () {
382
375
  value: function () {
383
376
  var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(submitParams) {
384
377
  var _this3 = this;
385
- var startEventId, res, logParams, isApplePay, paymentMethodType, startTime, _yield$executeWithTim, shouldContinue, timedOut, isTimeout, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
378
+ var startEventId, res, logParams, isApplePay, paymentMethodType, startTime, _yield$executeWithTim, shouldContinue, timedOut, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
386
379
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
387
380
  while (1) switch (_context4.prev = _context4.next) {
388
381
  case 0:
@@ -412,7 +405,7 @@ var ElementController = /*#__PURE__*/function () {
412
405
  isApplePay = this.currentPaymentMethodType === 'APPLEPAY';
413
406
  paymentMethodType = this.currentPaymentMethodType || 'UNKNOWN';
414
407
  if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm && !isApplePay)) {
415
- _context4.next = 40;
408
+ _context4.next = 34;
416
409
  break;
417
410
  }
418
411
  this.serviceMap.Log.logInfo({
@@ -431,65 +424,49 @@ var ElementController = /*#__PURE__*/function () {
431
424
  _yield$executeWithTim = _context4.sent;
432
425
  shouldContinue = _yield$executeWithTim.result;
433
426
  timedOut = _yield$executeWithTim.timedOut;
434
- isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS;
435
- if (!isTimeout) {
436
- _context4.next = 24;
427
+ if (!(timedOut || !shouldContinue || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS)) {
428
+ _context4.next = 23;
437
429
  break;
438
430
  }
439
- this.serviceMap.Log.logError({
440
- title: 'sdk_before_confirm_timeout'
441
- }, {
442
- paymentMethodType: paymentMethodType,
443
- path: 'nonApplePay_sync'
444
- });
445
- this.changeLoading(false);
446
- this.elementEventCenter.endEvent(startEventId, {
447
- eventCode: PaymentStatus.FAIL,
448
- errorName: MERCHANT_CONFIRM_TIMEOUT_CODE
449
- });
450
- return _context4.abrupt("return", {
451
- status: PaymentStatus.FAIL,
452
- error: {
453
- code: MERCHANT_CONFIRM_TIMEOUT_CODE,
454
- message: 'Merchant confirmation timed out.',
455
- needChangeSessionForRetry: false
456
- }
457
- });
458
- case 24:
459
- if (shouldContinue) {
460
- _context4.next = 29;
461
- break;
431
+ if (timedOut) {
432
+ this.serviceMap.Log.logError({
433
+ title: 'sdk_before_confirm_timeout'
434
+ }, {
435
+ paymentMethodType: paymentMethodType,
436
+ path: 'nonApplePay_sync'
437
+ });
438
+ } else {
439
+ this.serviceMap.Log.logInfo({
440
+ title: 'sdk_before_confirm_abort'
441
+ }, {
442
+ paymentMethodType: paymentMethodType,
443
+ path: 'nonApplePay_sync'
444
+ });
462
445
  }
463
- this.serviceMap.Log.logInfo({
464
- title: 'sdk_before_confirm_abort'
465
- }, {
466
- paymentMethodType: paymentMethodType,
467
- path: 'nonApplePay_sync'
468
- });
469
446
  this.changeLoading(false);
470
447
  this.elementEventCenter.endEvent(startEventId, {
471
448
  eventCode: PaymentStatus.FAIL,
472
- errorName: MERCHANT_CONFIRM_ABORT_CODE
449
+ errorName: 'MERCHANT_CONFIRM_ABORT'
473
450
  });
474
451
  return _context4.abrupt("return", {
475
452
  status: PaymentStatus.FAIL,
476
453
  error: {
477
- code: MERCHANT_CONFIRM_ABORT_CODE,
478
- message: 'Payment was cancelled by merchant before confirmation.',
454
+ code: 'MERCHANT_CONFIRM_ABORT',
455
+ message: 'Merchant canceled payment.',
479
456
  needChangeSessionForRetry: false
480
457
  }
481
458
  });
482
- case 29:
459
+ case 23:
483
460
  this.serviceMap.Log.logInfo({
484
461
  title: 'sdk_before_confirm_success'
485
462
  }, {
486
463
  paymentMethodType: paymentMethodType,
487
464
  path: 'nonApplePay_sync'
488
465
  });
489
- _context4.next = 38;
466
+ _context4.next = 32;
490
467
  break;
491
- case 32:
492
- _context4.prev = 32;
468
+ case 26:
469
+ _context4.prev = 26;
493
470
  _context4.t0 = _context4["catch"](11);
494
471
  this.serviceMap.Log.logError({
495
472
  title: 'sdk_before_confirm_error'
@@ -501,20 +478,20 @@ var ElementController = /*#__PURE__*/function () {
501
478
  this.changeLoading(false);
502
479
  this.elementEventCenter.endEvent(startEventId, {
503
480
  eventCode: PaymentStatus.FAIL,
504
- errorName: MERCHANT_CONFIRM_ABORT_CODE
481
+ errorName: 'MERCHANT_CONFIRM_ABORT'
505
482
  });
506
483
  return _context4.abrupt("return", {
507
484
  status: PaymentStatus.FAIL,
508
485
  error: {
509
- code: MERCHANT_CONFIRM_ABORT_CODE,
510
- message: 'Payment was cancelled by merchant before confirmation.',
486
+ code: 'MERCHANT_CONFIRM_ABORT',
487
+ message: 'Merchant canceled payment.',
511
488
  needChangeSessionForRetry: false
512
489
  }
513
490
  });
514
- case 38:
515
- _context4.next = 41;
491
+ case 32:
492
+ _context4.next = 35;
516
493
  break;
517
- case 40:
494
+ case 34:
518
495
  if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm)) {
519
496
  this.serviceMap.Log.logInfo({
520
497
  title: 'sdk_before_confirm_skip'
@@ -523,10 +500,10 @@ var ElementController = /*#__PURE__*/function () {
523
500
  path: isApplePay ? 'applePay_eventBridge' : 'nonApplePay_sync'
524
501
  });
525
502
  }
526
- case 41:
503
+ case 35:
527
504
  recordResult = null;
528
- _context4.prev = 42;
529
- _context4.next = 45;
505
+ _context4.prev = 36;
506
+ _context4.next = 39;
530
507
  return new Promise( /*#__PURE__*/function () {
531
508
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
532
509
  var that, recordResultCallback, params, processStep, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, _yield$_this3$onValid2, _data, errorString, errorResult;
@@ -615,8 +592,7 @@ var ElementController = /*#__PURE__*/function () {
615
592
  }, {
616
593
  msg: safeStringify({
617
594
  hasBeforeConfirmForApplePay: hasBeforeConfirmForApplePay,
618
- isApplePay: isApplePay,
619
- amount: "".concat(submitParams === null || submitParams === void 0 ? void 0 : submitParams.amount, ", ").concat(submitParams === null || submitParams === void 0 ? void 0 : submitParams.currency)
595
+ isApplePay: isApplePay
620
596
  })
621
597
  });
622
598
  _this3.elementProcessors[ElementType.payment].setOnBeforeConfirm(hasBeforeConfirmForApplePay ? submitParams.onBeforeConfirm : null);
@@ -684,10 +660,10 @@ var ElementController = /*#__PURE__*/function () {
684
660
  return _ref3.apply(this, arguments);
685
661
  };
686
662
  }());
687
- case 45:
663
+ case 39:
688
664
  return _context4.abrupt("return", _context4.sent);
689
- case 46:
690
- _context4.prev = 46;
665
+ case 40:
666
+ _context4.prev = 40;
691
667
  _logParams = {
692
668
  eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
693
669
  errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
@@ -698,12 +674,12 @@ var ElementController = /*#__PURE__*/function () {
698
674
  };
699
675
  this.elementEventCenter.endEvent(startEventId, _logParams);
700
676
  this.changeLoading(false);
701
- return _context4.finish(46);
702
- case 51:
677
+ return _context4.finish(40);
678
+ case 45:
703
679
  case "end":
704
680
  return _context4.stop();
705
681
  }
706
- }, _callee4, this, [[11, 32], [42,, 46, 51]]);
682
+ }, _callee4, this, [[11, 26], [36,, 40, 45]]);
707
683
  }));
708
684
  function submitPayment(_x) {
709
685
  return _submitPayment.apply(this, arguments);
@@ -230,7 +230,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
230
230
  // requests SDK layer to execute merchant's onBeforeConfirm callback via beforeConfirm event,
231
231
  // and returns the result (continue/abort) to iframe via dispatchToApp.
232
232
  this.eventCenter.listen(EVENT.beforeConfirm.name, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
233
- var paymentMethodType, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue, isTimeout;
233
+ var paymentMethodType, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue;
234
234
  return _regeneratorRuntime().wrap(function _callee$(_context) {
235
235
  while (1) switch (_context.prev = _context.next) {
236
236
  case 0:
@@ -270,9 +270,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
270
270
  _yield$executeWithTim = _context.sent;
271
271
  rawResult = _yield$executeWithTim.result;
272
272
  timedOut = _yield$executeWithTim.timedOut;
273
- shouldContinue = rawResult;
274
- isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS; // 双重校验:timedOut(Promise race) + startTime(实际时间差),防止竞态误判
275
- if (isTimeout) {
273
+ shouldContinue = rawResult; // 双重校验:timedOut(Promise race) + startTime(实际时间差),防止竞态误判
274
+ if (timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
276
275
  logger.logError({
277
276
  title: 'sdk_before_confirm_timeout'
278
277
  });
@@ -285,17 +284,15 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
285
284
  });
286
285
  _this2.eventCenter.dispatchToApp({
287
286
  event: EVENT.beforeConfirm.name,
288
- data: _objectSpread({
287
+ data: {
289
288
  success: true,
290
289
  result: !!shouldContinue
291
- }, isTimeout ? {
292
- isTimeout: true
293
- } : {})
290
+ }
294
291
  });
295
- _context.next = 24;
292
+ _context.next = 23;
296
293
  break;
297
- case 20:
298
- _context.prev = 20;
294
+ case 19:
295
+ _context.prev = 19;
299
296
  _context.t0 = _context["catch"](6);
300
297
  logger.logError({
301
298
  title: 'sdk_before_confirm_error'
@@ -311,11 +308,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
311
308
  result: false
312
309
  }
313
310
  });
314
- case 24:
311
+ case 23:
315
312
  case "end":
316
313
  return _context.stop();
317
314
  }
318
- }, _callee, null, [[6, 20]]);
315
+ }, _callee, null, [[6, 19]]);
319
316
  })));
320
317
  }
321
318
  }, {
@@ -3,10 +3,7 @@ export declare class ElementComponent {
3
3
  private options;
4
4
  private controller;
5
5
  constructor(options: IElementOptions);
6
- /**
7
- * @deprecated 不要使用,internal experiment方法
8
- */
9
- updatePayment(paymentSessionData: any): Promise<boolean>;
6
+ updatePayment(paymentSessionData: any): Promise<unknown>;
10
7
  mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<import("./type").ICommonApiResponse>;
11
8
  validateFields(): Promise<{
12
9
  isValid: boolean;
@@ -1,18 +1,16 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
6
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
8
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
9
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- import { adjustSessionData, isElements2 } from "../../../modern/tools";
14
13
  import ElementController from "./elementController";
15
- import { ModernElementController } from "./modernElementController";
16
14
  import { InvalidElementConfigError } from "./type";
17
15
  import { formatElementOption, validateElementOption } from "./util";
18
16
  export var ElementComponent = /*#__PURE__*/function () {
@@ -25,23 +23,11 @@ export var ElementComponent = /*#__PURE__*/function () {
25
23
  throw new InvalidElementConfigError(validate.errors);
26
24
  }
27
25
  this.options = formatElementOption(options);
28
-
29
- // 核心分流逻辑
30
- if (isElements2(options.sessionData)) {
31
- this.controller = new ModernElementController(_objectSpread(_objectSpread({}, this.options), {}, {
32
- sessionData: adjustSessionData(this.options.sessionData)
33
- }));
34
- } else {
35
- this.controller = new ElementController(this.options);
36
- }
26
+ this.controller = new ElementController(options);
37
27
  }
38
-
39
- /**
40
- * @deprecated 不要使用,internal experiment方法
41
- */
42
28
  _createClass(ElementComponent, [{
43
29
  key: "updatePayment",
44
- value: (function () {
30
+ value: function () {
45
31
  var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentSessionData) {
46
32
  return _regeneratorRuntime().wrap(function _callee$(_context) {
47
33
  while (1) switch (_context.prev = _context.next) {
@@ -61,7 +47,6 @@ export var ElementComponent = /*#__PURE__*/function () {
61
47
  // mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
62
48
  // mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
63
49
  // mount(renderOptions: PaymentMountOptions, sdkSelector: string);
64
- )
65
50
  }, {
66
51
  key: "mount",
67
52
  value: function mount(renderOptions, sdkSelector) {
@@ -1,4 +1,3 @@
1
- import type { ShippingInfo } from "../../../modern/index";
2
1
  import { ActionForm, ConnectErrorCode, IAmount, IAmountView, IMerchantAppointParam, IPaymentMethod } from '../../../types';
3
2
  import AddressProcessor from './elementProcessor/addressProcessor';
4
3
  import AuthProcessor from './elementProcessor/authProcessor';
@@ -293,6 +292,23 @@ export interface PaymentSubmitData {
293
292
  paymentMethodId?: string;
294
293
  };
295
294
  }
295
+ export interface ShippingInfo {
296
+ shippingName: {
297
+ firstName: string;
298
+ lastName: string;
299
+ middleName?: string;
300
+ fullName?: string;
301
+ };
302
+ shippingPhoneNo: string;
303
+ shippingAddress: {
304
+ region: string;
305
+ address1: string;
306
+ address2: string;
307
+ city?: string;
308
+ state?: string;
309
+ zipCode: string;
310
+ };
311
+ }
296
312
  export interface AddressSubmitData {
297
313
  shippingName: {
298
314
  firstName: string;
@@ -336,8 +352,7 @@ export interface SubmitFuncParams {
336
352
  * - Only effective when payment method is Apple Pay
337
353
  * - Invoked via event bridge after user FaceID/TouchID authorization on the payment sheet
338
354
  * - Return true: proceed with charge
339
- * - Return false / throw error: abort payment, returns MERCHANT_CONFIRM_ABORT error code
340
- * - Timeout: abort payment, returns MERCHANT_CONFIRM_TIMEOUT error code
355
+ * - Return false / timeout / throw error: abort payment, returns MERCHANT_CONFIRM_ABORT error code
341
356
  */
342
357
  onBeforeConfirm?: () => Promise<boolean>;
343
358
  }
@@ -570,17 +585,4 @@ export interface EventDataMap {
570
585
  [EVENTNAME.PAYMENTMETHODCHANGED]: PaymentMethodChangedData;
571
586
  [EVENTNAME.BILLINGADDRESSCHANGED]: BillingAddressChangedData;
572
587
  }
573
- export interface IElementController {
574
- mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<ICommonApiResponse>;
575
- submitPayment(params: SubmitFuncParams): Promise<IPaymentApiResponse>;
576
- validateFields(): Promise<{
577
- isValid: boolean;
578
- }>;
579
- /**
580
- * @deprecated 不要使用,internal experiment方法
581
- */
582
- updatePayment(paymentSessionData: string): Promise<boolean>;
583
- destroy(): void;
584
- on<T extends EVENTNAME>(event: T, callback: (data: EventDataMap[T]) => void): void;
585
- }
586
588
  export {};
@@ -11,7 +11,6 @@ import type { AMSCheckoutOptions, IAppendParams, InitSecurityConfig, IoptionsPar
11
11
  import { EventCenter } from '../../util/index';
12
12
  import { Logger } from '../../util/logger';
13
13
  import { Security } from '../../util/security';
14
- import type { ISecurity } from '../../util/security-registry';
15
14
  export default class AMSSDK {
16
15
  options: AMSCheckoutOptions;
17
16
  originOptions: IoptionsParams;
@@ -38,20 +37,13 @@ export default class AMSSDK {
38
37
  scene?: string;
39
38
  }): void;
40
39
  /**
41
- * @description Obtain security SDK through scenario identification (async-aware)
42
- * Handles three states: ready, loading, not found
40
+ * @description Obtain security SDK through scenario identification
43
41
  */
44
- _getSecuritySDKByProductScene(securityConfig: InitSecurityConfig): ISecurity;
42
+ _getSecuritySDKByProductScene(securityConfig: InitSecurityConfig): Security;
45
43
  /**
46
- * @description Await security SDK by product scene (async)
47
- * Returns the Security instance even if currently loading
44
+ * @description New security SDK through scenario identification
48
45
  */
49
- _awaitSecuritySDKByProductScene(securityConfig: InitSecurityConfig): Promise<Security | undefined>;
50
- /**
51
- * @description New security SDK through scenario identification (async-aware)
52
- * Uses shared SecuritySdkRegistry and triggers ApdidLoader
53
- */
54
- _newSecuritySDKByScene(securityConfig: InitSecurityConfig, successCallback?: () => void, failCallback?: (errMsg?: string) => void): void;
46
+ _newSecuritySDKByScene(securityConfig: InitSecurityConfig, successCallback?: () => void, failCallback?: (errMsg?: string) => void): Security;
55
47
  /**
56
48
  * @description Obtain risk control configuration in local storage
57
49
  */