@alipay/ams-checkout 0.0.1730107332-dev.25 → 0.0.1730107332-dev.27

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 (94) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/component.inline.style.js +1 -1
  3. package/esm/config/index.d.ts +7 -7
  4. package/esm/config/index.js +7 -7
  5. package/esm/constant/index.d.ts +3 -0
  6. package/esm/constant/index.js +3 -0
  7. package/esm/core/bus/ability/callback.d.ts +9 -0
  8. package/esm/core/bus/ability/callback.js +55 -0
  9. package/esm/core/bus/ability/security.d.ts +10 -0
  10. package/esm/core/bus/ability/security.js +104 -0
  11. package/esm/core/bus/ability/tracker.d.ts +9 -0
  12. package/esm/core/bus/ability/tracker.js +77 -0
  13. package/esm/core/bus/index.d.ts +125 -0
  14. package/esm/core/bus/index.js +366 -0
  15. package/esm/core/bus/interface.d.ts +36 -0
  16. package/esm/core/bus/interface.js +40 -0
  17. package/esm/core/component/address.d.ts +8 -0
  18. package/esm/core/component/address.js +72 -0
  19. package/esm/core/component/appPreloadProcessing.d.ts +1 -0
  20. package/esm/core/component/appPreloadProcessing.js +89 -0
  21. package/esm/core/component/ckp/index.d.ts +27 -0
  22. package/esm/core/component/ckp/index.js +166 -0
  23. package/esm/core/component/index.d.ts +51 -0
  24. package/esm/core/component/index.js +531 -0
  25. package/esm/core/drop-in/index.d.ts +22 -0
  26. package/esm/core/drop-in/index.js +104 -0
  27. package/esm/core/instance/index.d.ts +89 -0
  28. package/esm/core/instance/index.js +499 -0
  29. package/esm/foundation/core/index.d.ts +2 -2
  30. package/esm/foundation/index.d.ts +5 -5
  31. package/esm/foundation/product-processor/easysafepay/deps.d.ts +2 -2
  32. package/esm/foundation/product-processor/easysafepay/deps.js +1 -1
  33. package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -2
  34. package/esm/foundation/service/api-bus/index.d.ts +2 -2
  35. package/esm/foundation/service/container/index.d.ts +2 -2
  36. package/esm/foundation/service/event-center.d.ts +4 -4
  37. package/esm/foundation/service/event-center.js +10 -10
  38. package/esm/foundation/service/global-data/index.d.ts +2 -2
  39. package/esm/foundation/service/index.d.ts +2 -2
  40. package/esm/foundation/service/log/index.d.ts +2 -2
  41. package/esm/foundation/service/requester/deps.d.ts +1 -1
  42. package/esm/foundation/service/requester/requester.d.ts +2 -2
  43. package/esm/foundation/service/security/index.d.ts +2 -2
  44. package/esm/foundation/utils/redirect_utils.d.ts +5 -0
  45. package/esm/foundation/utils/redirect_utils.js +135 -1
  46. package/esm/foundation/utils/web_app_url_utils.js +1 -1
  47. package/esm/index.d.ts +27 -2
  48. package/esm/index.js +131 -6
  49. package/esm/plugin/applepay/component.d.ts +50 -0
  50. package/esm/plugin/applepay/component.js +339 -0
  51. package/esm/plugin/applepay/index.d.ts +17 -0
  52. package/esm/plugin/applepay/index.js +117 -0
  53. package/esm/plugin/applepay/interface.d.ts +161 -0
  54. package/esm/plugin/applepay/interface.js +69 -0
  55. package/esm/plugin/applepay/service.d.ts +54 -0
  56. package/esm/plugin/applepay/service.js +289 -0
  57. package/esm/plugin/component/cashierApp.d.ts +34 -0
  58. package/esm/plugin/component/cashierApp.js +237 -0
  59. package/esm/plugin/component/channel.d.ts +21 -0
  60. package/esm/plugin/component/channel.js +89 -0
  61. package/esm/plugin/component/component.inline.style.d.ts +10 -0
  62. package/esm/plugin/component/component.inline.style.js +119 -0
  63. package/esm/plugin/component/component.popup.style.d.ts +16 -0
  64. package/esm/plugin/component/component.popup.style.js +174 -0
  65. package/esm/plugin/component/index.d.ts +126 -0
  66. package/esm/plugin/component/index.js +1839 -0
  67. package/esm/plugin/component/popupWindow.style.d.ts +11 -0
  68. package/esm/plugin/component/popupWindow.style.js +121 -0
  69. package/esm/plugin/const.d.ts +2 -0
  70. package/esm/plugin/const.js +33 -0
  71. package/esm/plugin/drop-in/index.d.ts +71 -0
  72. package/esm/plugin/drop-in/index.js +324 -0
  73. package/esm/plugin/payment-element/utils.d.ts +2 -0
  74. package/esm/plugin/payment-element/utils.js +6 -0
  75. package/esm/plugin/paypal/index.d.ts +20 -0
  76. package/esm/plugin/paypal/index.js +390 -0
  77. package/esm/plugin/type.d.ts +34 -0
  78. package/esm/plugin/type.js +1 -0
  79. package/esm/plugin/utils.d.ts +6 -0
  80. package/esm/plugin/utils.js +21 -0
  81. package/esm/types/index.d.ts +28 -9
  82. package/esm/types/index.js +5 -1
  83. package/esm/util/createIframeNode.d.ts +6 -0
  84. package/esm/util/createIframeNode.js +48 -0
  85. package/esm/util/getBackScheme.d.ts +2 -2
  86. package/esm/util/getBackScheme.js +2 -2
  87. package/esm/util/index.d.ts +11 -1
  88. package/esm/util/index.js +84 -3
  89. package/esm/util/intl-callapp/es/index.js +0 -1
  90. package/esm/util/security.d.ts +33 -0
  91. package/esm/util/security.js +182 -0
  92. package/package.json +2 -2
  93. package/esm/foundation/types/index.d.ts +0 -4
  94. package/esm/foundation/types/index.js +0 -4
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
3
+ * 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:
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
+ * 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
+ */
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ import { getType } from '.';
9
+ import { ERRORMESSAGE, EVENT } from "../constant";
10
+ import { MessageName, DisplayTypeEnum } from "../types";
11
+ /**
12
+ * @description context中需要包含app节点,用于插入selector中
13
+ */
14
+ export var createIframeNode = function createIframeNode(context, selector, renderDisplayType) {
15
+ return new Promise(function (resolve, reject) {
16
+ var dorpinDom = null;
17
+ if (getType(selector) === 'string') {
18
+ dorpinDom = document.querySelector(selector);
19
+ }
20
+ if (dorpinDom === null) {
21
+ var error = {
22
+ code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
23
+ message: "Failed to execute 'querySelector' on 'Document': ".concat(selector, " is not a valid selector")
24
+ };
25
+ reject(error);
26
+ context._dispatchToSDK({
27
+ name: MessageName.APP_TO_SDK,
28
+ instanceId: context.AMSSDK._instanceId,
29
+ context: {
30
+ event: EVENT.error.name,
31
+ data: error
32
+ }
33
+ });
34
+ return;
35
+ }
36
+ if (renderDisplayType === DisplayTypeEnum.popup) dorpinDom.innerHTML = '';
37
+ if (context.app) {
38
+ dorpinDom.appendChild(context.app);
39
+ }
40
+ resolve();
41
+ });
42
+ };
43
+ export var createPreloadIframeNode = function createPreloadIframeNode(virtualPreloadIframe) {
44
+ var body = document.body || null;
45
+ if (body) {
46
+ body.appendChild(virtualPreloadIframe);
47
+ }
48
+ };
@@ -1,5 +1,5 @@
1
- import { LogService } from "../foundation/service/log";
1
+ import { Logger } from './logger';
2
2
  /**
3
3
  * 通过配置规则检测 UA 和获得回跳 scheme
4
4
  */
5
- export declare function getBackScheme(mockUa?: string, logger?: LogService): any;
5
+ export declare function getBackScheme(mockUa?: string, logger?: Logger): any;
@@ -1,4 +1,4 @@
1
- var RULES = [{
1
+ var UA_MATCH_RULES = [{
2
2
  matchRule: 'AppleWebKit\\/([0-9\\.]+).* Version\\/([0-9\\._]+) Mobile\\/([0-9\\._A-Z]+) Safari\\/([0-9\\._]+)$',
3
3
  iosScheme: 'https',
4
4
  andScheme: ''
@@ -82,7 +82,7 @@ var RULES = [{
82
82
  export function getBackScheme(mockUa, logger) {
83
83
  var ua = mockUa || window.navigator.userAgent || '';
84
84
  // 获取规则
85
- var uaMatchedRule = RULES;
85
+ var uaMatchedRule = UA_MATCH_RULES;
86
86
  var matchedRule;
87
87
  var matched = null;
88
88
  for (var i = 0; i < uaMatchedRule.length; i++) {
@@ -5,6 +5,16 @@
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
7
  declare const getType: (target: any) => string;
8
+ declare class EventCenter {
9
+ private events;
10
+ private eventsKey;
11
+ constructor();
12
+ on(name: string, func: any, key?: string): void;
13
+ off(name: string, func: any, key?: string): void;
14
+ emit(name: string, ...rest: any): void;
15
+ once(name: string, func: any, key?: string): void;
16
+ isExist(name: string): boolean;
17
+ }
8
18
  declare const getViewPort: (key: string) => any;
9
19
  declare const getOrigin: () => string;
10
20
  declare const serialize: (obj: Record<string, string>) => string;
@@ -36,4 +46,4 @@ declare function loadSDKScript({ src, attrOptions, timeOut, loadCallback }: {
36
46
  timeOut?: number;
37
47
  loadCallback?: any;
38
48
  }, logger: any): Promise<unknown>;
39
- export { getType, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript, };
49
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript, };
package/esm/util/index.js CHANGED
@@ -1,4 +1,10 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
2
8
  /**
3
9
  * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
4
10
  * 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:
@@ -10,6 +16,81 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
10
16
  var getType = function getType(target) {
11
17
  return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
12
18
  };
19
+ var EventCenter = /*#__PURE__*/function () {
20
+ function EventCenter() {
21
+ _classCallCheck(this, EventCenter);
22
+ _defineProperty(this, "events", void 0);
23
+ _defineProperty(this, "eventsKey", void 0);
24
+ this.events = new Map();
25
+ this.eventsKey = new Map();
26
+ }
27
+ _createClass(EventCenter, [{
28
+ key: "on",
29
+ value: function on(name, func) {
30
+ var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
31
+ if (key) {
32
+ if (this.eventsKey.has("".concat(name, "-").concat(key))) {
33
+ // eslint-disable-next-line no-console
34
+ console.warn("".concat(key, "\uFF1AHas been registered. Please use another key or do not pass the key"));
35
+ return;
36
+ }
37
+ this.eventsKey.set("".concat(name, "-").concat(key), true);
38
+ }
39
+ var eventList = this.events.get(name) || [];
40
+ eventList.push({
41
+ func: func,
42
+ key: key || ''
43
+ });
44
+ this.events.set(name, eventList);
45
+ }
46
+ }, {
47
+ key: "off",
48
+ value: function off(name, func) {
49
+ var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
50
+ if (key && this.eventsKey.has("".concat(name, "-").concat(key))) {
51
+ this.eventsKey.delete("".concat(name, "-").concat(key));
52
+ }
53
+ if (this.events.has(name)) {
54
+ var eventList = this.events.get(name);
55
+ eventList = eventList.filter(function (item) {
56
+ if (func === item.func && item.key === key) return false;
57
+ if (item.key && item.key === key) return false;
58
+ return true;
59
+ });
60
+ this.events.set(name, eventList);
61
+ }
62
+ }
63
+ }, {
64
+ key: "emit",
65
+ value: function emit(name) {
66
+ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
67
+ rest[_key - 1] = arguments[_key];
68
+ }
69
+ if (this.events.has(name)) {
70
+ var eventList = this.events.get(name);
71
+ eventList.forEach(function (item) {
72
+ item.func.apply(item, rest);
73
+ });
74
+ }
75
+ }
76
+ }, {
77
+ key: "once",
78
+ value: function once(name, func, key) {
79
+ var _this = this;
80
+ var onceF = function onceF() {
81
+ func.apply(void 0, arguments);
82
+ _this.off(name, onceF, key);
83
+ };
84
+ this.on(name, onceF, key);
85
+ }
86
+ }, {
87
+ key: "isExist",
88
+ value: function isExist(name) {
89
+ return this.events.has(name);
90
+ }
91
+ }]);
92
+ return EventCenter;
93
+ }();
13
94
  var getViewPort = function getViewPort(key) {
14
95
  var meta = document.getElementsByTagName('meta');
15
96
  // HTMLMetaElement
@@ -186,7 +267,7 @@ function parseBase64ToString(base64) {
186
267
  }
187
268
  }
188
269
  function loadSDKScript(_ref, logger) {
189
- var _this = this;
270
+ var _this2 = this;
190
271
  var src = _ref.src,
191
272
  _ref$attrOptions = _ref.attrOptions,
192
273
  attrOptions = _ref$attrOptions === void 0 ? {} : _ref$attrOptions,
@@ -235,7 +316,7 @@ function loadSDKScript(_ref, logger) {
235
316
  reject(false);
236
317
  };
237
318
  timer = setTimeout(function () {
238
- _this.logger.logError({
319
+ _this2.logger.logError({
239
320
  title: 'load_item_sdk_timeout'
240
321
  }, {
241
322
  src: src,
@@ -251,4 +332,4 @@ function loadSDKScript(_ref, logger) {
251
332
  document.head.appendChild(script);
252
333
  });
253
334
  }
254
- export { getType, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript };
335
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript };
@@ -138,7 +138,6 @@ var CallApp = /*#__PURE__*/function () {
138
138
  fallback = _this$options.fallback;
139
139
  if (!scheme && !link && !intent) {
140
140
  console.error('请至少填一个链接');
141
- if (fallback) fallback();
142
141
  return;
143
142
  }
144
143
  if (link && checkIsHttpUrl(link)) {
@@ -0,0 +1,33 @@
1
+ import { IsecurityConfig, ProductSceneEnum, DeviceIdParameter } from '../types';
2
+ export declare const getSecurityConfigStorageKey: (scene: ProductSceneEnum) => string;
3
+ export declare enum SecurityRegionEnum {
4
+ SG = "SG",
5
+ US = "US",
6
+ DE = "DE"
7
+ }
8
+ export declare const securityHost: {
9
+ SG: string;
10
+ US: string;
11
+ DE: string;
12
+ };
13
+ export declare const sceneMap: {
14
+ CASHIER_PAYMENT: string;
15
+ AUTO_DEBIT: string;
16
+ VAULTING: string;
17
+ CARD_APPLE_PAY: string;
18
+ EASYPAY: string;
19
+ EASY_PAY: string;
20
+ FLASH_BUY: string;
21
+ ELEMENT_PAYMENT: string;
22
+ };
23
+ export declare const getSecurityHost: (region: string) => string;
24
+ export declare const getSecurityScene: (product: string) => string;
25
+ export declare class Security {
26
+ scene: string;
27
+ h5gateway: string;
28
+ constructor(options: IsecurityConfig);
29
+ initSecurity(successCallback: any, failCallback: any): void;
30
+ private initToken;
31
+ pollingGetApdidToken(config?: DeviceIdParameter): Promise<string>;
32
+ getApdidToken(): Promise<string>;
33
+ }
@@ -0,0 +1,182 @@
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 _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
+ 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
+ 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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ 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); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ 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; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ import { ProductSceneEnum } from "../types";
12
+ import APDID from "./jshield-apdid/apdid-core.umd.min";
13
+ export var getSecurityConfigStorageKey = function getSecurityConfigStorageKey(scene) {
14
+ return "AMSSDK_SECURITY_CONFIG_".concat(scene);
15
+ };
16
+ export var SecurityRegionEnum = /*#__PURE__*/function (SecurityRegionEnum) {
17
+ SecurityRegionEnum["SG"] = "SG";
18
+ SecurityRegionEnum["US"] = "US";
19
+ SecurityRegionEnum["DE"] = "DE";
20
+ return SecurityRegionEnum;
21
+ }({});
22
+ export var securityHost = {
23
+ SG: 'https://open-sea-global.alipay.com/api/open/risk_client',
24
+ US: 'https://open-na-global.alipay.com/api/open/risk_client',
25
+ DE: 'https://open-de-global.alipay.com/api/open/risk_client'
26
+ };
27
+ export var sceneMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ProductSceneEnum.CASHIER_PAYMENT, 'Acquirer'), ProductSceneEnum.AUTO_DEBIT, 'Acquirer'), ProductSceneEnum.VAULTING, 'Acquirer'), ProductSceneEnum.CARD_APPLE_PAY, 'Acquirer'), "EASYPAY", 'EasyPay'), ProductSceneEnum.EASY_PAY, 'EasyPay'), ProductSceneEnum.FLASH_BUY, 'OneAccount'), ProductSceneEnum.ELEMENT_PAYMENT, 'Acquirer');
28
+ export var getSecurityHost = function getSecurityHost(region) {
29
+ return securityHost[region] || securityHost[SecurityRegionEnum.SG];
30
+ };
31
+ export var getSecurityScene = function getSecurityScene(product) {
32
+ return sceneMap[product] || '';
33
+ };
34
+ export var Security = /*#__PURE__*/function () {
35
+ function Security(options) {
36
+ _classCallCheck(this, Security);
37
+ _defineProperty(this, "scene", void 0);
38
+ _defineProperty(this, "h5gateway", void 0);
39
+ this.scene = options.scene;
40
+ this.h5gateway = options.h5gateway || securityHost[SecurityRegionEnum.SG];
41
+ }
42
+ _createClass(Security, [{
43
+ key: "initSecurity",
44
+ value: function initSecurity(successCallback, failCallback) {
45
+ if (!this.scene) {
46
+ throw new Error('securityConfig parameter error');
47
+ }
48
+ if (!Object.values(sceneMap).includes(this.scene) || !Object.values(securityHost).includes(this.h5gateway)) {
49
+ var errorMsg = "scene:".concat(this.scene, " or h5gateway:").concat(this.h5gateway, " do not supported");
50
+ console.error(errorMsg);
51
+ throw new Error(errorMsg);
52
+ }
53
+ this.initToken(successCallback, failCallback);
54
+ }
55
+ }, {
56
+ key: "initToken",
57
+ value: function initToken(successCallback, failCallback) {
58
+ try {
59
+ APDID === null || APDID === void 0 || APDID.initToken(this.scene, {
60
+ host: this.h5gateway
61
+ }, function (success, tokenResult, msg) {
62
+ if (success) {
63
+ successCallback && successCallback();
64
+ } else {
65
+ failCallback && failCallback(msg);
66
+ }
67
+ console.log('initToken result tokenResult', JSON.stringify(tokenResult), msg);
68
+ });
69
+ } catch (error) {
70
+ failCallback && failCallback(error === null || error === void 0 ? void 0 : error.toString());
71
+ }
72
+ }
73
+ }, {
74
+ key: "pollingGetApdidToken",
75
+ value: function () {
76
+ var _pollingGetApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(config) {
77
+ var _this = this;
78
+ var tokenCollectTime, dataPollingInterval, asyncFunc;
79
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
80
+ while (1) switch (_context3.prev = _context3.next) {
81
+ case 0:
82
+ tokenCollectTime = parseInt((config === null || config === void 0 ? void 0 : config.tokenCollectTime) || '0', 10);
83
+ dataPollingInterval = parseInt((config === null || config === void 0 ? void 0 : config.dataPollingInterval) || '500', 10);
84
+ asyncFunc = /*#__PURE__*/function () {
85
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
86
+ var deviceId, interval, polling;
87
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
88
+ while (1) switch (_context2.prev = _context2.next) {
89
+ case 0:
90
+ _context2.next = 2;
91
+ return _this.getApdidToken();
92
+ case 2:
93
+ deviceId = _context2.sent;
94
+ if (!deviceId) {
95
+ _context2.next = 5;
96
+ break;
97
+ }
98
+ return _context2.abrupt("return", resolve(deviceId));
99
+ case 5:
100
+ polling = /*#__PURE__*/function () {
101
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
102
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
103
+ while (1) switch (_context.prev = _context.next) {
104
+ case 0:
105
+ _context.next = 2;
106
+ return _this.getApdidToken();
107
+ case 2:
108
+ deviceId = _context.sent;
109
+ if (deviceId) {
110
+ clearInterval(interval);
111
+ resolve(deviceId);
112
+ }
113
+ case 4:
114
+ case "end":
115
+ return _context.stop();
116
+ }
117
+ }, _callee);
118
+ }));
119
+ return function polling() {
120
+ return _ref2.apply(this, arguments);
121
+ };
122
+ }();
123
+ interval = setInterval(polling, dataPollingInterval);
124
+ setTimeout(function () {
125
+ clearInterval(interval);
126
+ resolve(deviceId);
127
+ }, tokenCollectTime);
128
+ case 8:
129
+ case "end":
130
+ return _context2.stop();
131
+ }
132
+ }, _callee2);
133
+ }));
134
+ return function asyncFunc(_x2) {
135
+ return _ref.apply(this, arguments);
136
+ };
137
+ }();
138
+ return _context3.abrupt("return", new Promise(function (resolve) {
139
+ asyncFunc(resolve);
140
+ }));
141
+ case 4:
142
+ case "end":
143
+ return _context3.stop();
144
+ }
145
+ }, _callee3);
146
+ }));
147
+ function pollingGetApdidToken(_x) {
148
+ return _pollingGetApdidToken.apply(this, arguments);
149
+ }
150
+ return pollingGetApdidToken;
151
+ }()
152
+ }, {
153
+ key: "getApdidToken",
154
+ value: function () {
155
+ var _getApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
156
+ var _this2 = this;
157
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
158
+ while (1) switch (_context4.prev = _context4.next) {
159
+ case 0:
160
+ return _context4.abrupt("return", new Promise(function (resolve) {
161
+ try {
162
+ APDID === null || APDID === void 0 || APDID.getApdidToken(_this2.scene, function (tokenResult) {
163
+ resolve(tokenResult === null || tokenResult === void 0 ? void 0 : tokenResult.token);
164
+ });
165
+ } catch (error) {
166
+ resolve('');
167
+ }
168
+ }));
169
+ case 1:
170
+ case "end":
171
+ return _context4.stop();
172
+ }
173
+ }, _callee4);
174
+ }));
175
+ function getApdidToken() {
176
+ return _getApdidToken.apply(this, arguments);
177
+ }
178
+ return getApdidToken;
179
+ }()
180
+ }]);
181
+ return Security;
182
+ }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1730107332-dev.25",
3
+ "version": "0.0.1730107332-dev.27",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "build": "father build",
18
- "build:w": "father dev",
18
+ "dev": "father dev",
19
19
  "ci": "npm run lint",
20
20
  "cov": "jest --coverage",
21
21
  "format": "prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"",
@@ -1,4 +0,0 @@
1
- /**
2
- * @author 谦彧 <zhangmian.zm@alipay.com>
3
- * @date 2024/9/17
4
- */
@@ -1,4 +0,0 @@
1
- /**
2
- * @author 谦彧 <zhangmian.zm@alipay.com>
3
- * @date 2024/9/17
4
- */