@alipay/ams-checkout 1.24.0 → 1.25.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 (106) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +19 -0
  3. package/esm/component/channel.js +87 -0
  4. package/esm/component/component.inline.style.d.ts +10 -0
  5. package/esm/component/component.inline.style.js +121 -0
  6. package/esm/component/component.popup.style.d.ts +23 -0
  7. package/esm/component/component.popup.style.js +190 -0
  8. package/esm/component/popupWindow.style.d.ts +11 -0
  9. package/esm/component/popupWindow.style.js +121 -0
  10. package/esm/config/index.d.ts +7 -7
  11. package/esm/config/index.js +7 -7
  12. package/esm/constant/index.d.ts +3 -5
  13. package/esm/constant/index.js +4 -78
  14. package/esm/core/bus/interface.d.ts +0 -12
  15. package/esm/core/bus/interface.js +2 -16
  16. package/esm/core/component/address.d.ts +2 -2
  17. package/esm/core/component/appPreloadProcessing.js +0 -2
  18. package/esm/core/component/ckp/index.d.ts +3 -3
  19. package/esm/core/component/element/components/address.js +1 -1
  20. package/esm/core/component/element/components/auth.d.ts +1 -1
  21. package/esm/core/component/element/components/payment.js +1 -1
  22. package/esm/core/component/element/index.js +19 -19
  23. package/esm/core/component/element/type.d.ts +6 -0
  24. package/esm/core/component/index.d.ts +2 -2
  25. package/esm/core/component/index.js +2 -6
  26. package/esm/core/drop-in/index.d.ts +2 -2
  27. package/esm/core/instance/index.d.ts +5 -5
  28. package/esm/core/instance/index.js +1 -2
  29. package/esm/foundation/core/index.d.ts +5 -5
  30. package/esm/foundation/core/index.js +117 -52
  31. package/esm/foundation/index.d.ts +10 -7
  32. package/esm/foundation/product-processor/easysafepay/deps.d.ts +8 -5
  33. package/esm/foundation/product-processor/easysafepay/deps.js +5 -2
  34. package/esm/foundation/product-processor/easysafepay/index.d.ts +6 -6
  35. package/esm/foundation/product-processor/easysafepay/index.js +192 -265
  36. package/esm/foundation/service/{event-bus → api-bus}/ability/callback.js +1 -1
  37. package/esm/foundation/service/{event-bus → api-bus}/ability/globalData.d.ts +1 -1
  38. package/esm/{core/bus → foundation/service/api-bus}/ability/globalData.js +2 -2
  39. package/esm/{core/bus → foundation/service/api-bus}/ability/request.d.ts +1 -1
  40. package/esm/{core/bus → foundation/service/api-bus}/ability/request.js +2 -2
  41. package/esm/foundation/service/{event-bus → api-bus}/ability/security.js +29 -19
  42. package/esm/foundation/service/{event-bus → api-bus}/ability/tracker.js +1 -1
  43. package/esm/foundation/service/{event-bus → api-bus}/busManager.js +1 -1
  44. package/esm/foundation/service/{event-bus → api-bus}/index.d.ts +2 -2
  45. package/esm/foundation/service/api-bus/interface.d.ts +48 -0
  46. package/esm/foundation/service/api-bus/interface.js +54 -0
  47. package/esm/foundation/service/container/index.d.ts +4 -2
  48. package/esm/foundation/service/container/index.js +47 -5
  49. package/esm/foundation/service/container/popup.js +1 -1
  50. package/esm/foundation/service/event-center.d.ts +6 -5
  51. package/esm/foundation/service/event-center.js +16 -17
  52. package/esm/foundation/service/global-data/index.d.ts +2 -2
  53. package/esm/foundation/service/global-data/index.js +4 -5
  54. package/esm/foundation/service/index.d.ts +2 -2
  55. package/esm/foundation/service/index.js +1 -1
  56. package/esm/foundation/service/log/index.d.ts +2 -2
  57. package/esm/foundation/service/log/index.js +1 -1
  58. package/esm/foundation/service/requester/deps.d.ts +1 -1
  59. package/esm/foundation/service/requester/requester.d.ts +2 -2
  60. package/esm/foundation/service/requester/requester.js +14 -11
  61. package/esm/foundation/service/security/index.d.ts +11 -9
  62. package/esm/foundation/service/security/index.js +114 -44
  63. package/esm/foundation/utils/payment_product_utils.d.ts +13 -0
  64. package/esm/foundation/utils/payment_product_utils.js +38 -0
  65. package/esm/foundation/utils/redirect_utils.d.ts +5 -0
  66. package/esm/foundation/utils/redirect_utils.js +209 -45
  67. package/esm/foundation/utils/system_events.js +0 -5
  68. package/esm/foundation/utils/web_app_url_utils.d.ts +11 -2
  69. package/esm/foundation/utils/web_app_url_utils.js +18 -3
  70. package/esm/index.d.ts +12 -12
  71. package/esm/index.js +31 -31
  72. package/esm/plugin/component/cashierApp.d.ts +3 -3
  73. package/esm/plugin/component/cashierApp.js +9 -10
  74. package/esm/plugin/component/component.inline.style.d.ts +1 -1
  75. package/esm/plugin/component/component.inline.style.js +2 -3
  76. package/esm/plugin/component/component.popup.style.d.ts +1 -10
  77. package/esm/plugin/component/component.popup.style.js +10 -28
  78. package/esm/plugin/component/index.d.ts +1 -1
  79. package/esm/plugin/component/index.js +64 -62
  80. package/esm/plugin/payment-element/utils.d.ts +1 -1
  81. package/esm/plugin/payment-element/utils.js +1 -2
  82. package/esm/plugin/type.d.ts +1 -1
  83. package/esm/types/index.d.ts +17 -11
  84. package/esm/types/index.js +7 -1
  85. package/esm/util/getBackScheme.js +95 -3
  86. package/esm/util/index.d.ts +1 -1
  87. package/esm/util/index.js +4 -3
  88. package/esm/util/security.d.ts +33 -0
  89. package/esm/{foundation/service/event-bus/ability/request.js → util/security.js} +153 -122
  90. package/package.json +1 -1
  91. package/esm/core/bus/ability/globalData.d.ts +0 -10
  92. package/esm/foundation/service/event-bus/ability/globalData.js +0 -89
  93. package/esm/foundation/service/event-bus/ability/request.d.ts +0 -10
  94. package/esm/foundation/types/index.d.ts +0 -4
  95. package/esm/foundation/types/index.js +0 -4
  96. package/esm/util/ua/index.d.ts +0 -2
  97. package/esm/util/ua/index.js +0 -2
  98. package/esm/util/ua/isAndroid.d.ts +0 -4
  99. package/esm/util/ua/isAndroid.js +0 -7
  100. package/esm/util/ua/isIOS.d.ts +0 -4
  101. package/esm/util/ua/isIOS.js +0 -7
  102. /package/esm/foundation/service/{event-bus → api-bus}/ability/callback.d.ts +0 -0
  103. /package/esm/foundation/service/{event-bus → api-bus}/ability/security.d.ts +0 -0
  104. /package/esm/foundation/service/{event-bus → api-bus}/ability/tracker.d.ts +0 -0
  105. /package/esm/foundation/service/{event-bus → api-bus}/busManager.d.ts +0 -0
  106. /package/esm/foundation/service/{event-bus → api-bus}/index.js +0 -0
@@ -1,12 +1,88 @@
1
- import { isAndroid, isIOS } from "./ua";
2
- import { RULES } from "../constant/index";
1
+ var UA_MATCH_RULES = [{
2
+ matchRule: 'AppleWebKit\\/([0-9\\.]+).* Version\\/([0-9\\._]+) Mobile\\/([0-9\\._A-Z]+) Safari\\/([0-9\\._]+)$',
3
+ iosScheme: 'https',
4
+ andScheme: ''
5
+ }, {
6
+ matchRule: 'HeyTapBrowser',
7
+ iosScheme: '',
8
+ andScheme: ''
9
+ }, {
10
+ matchRule: 'HuaweiBrowser',
11
+ iosScheme: '',
12
+ andScheme: ''
13
+ }, {
14
+ matchRule: 'Kwai',
15
+ iosScheme: 'kwai',
16
+ andScheme: ''
17
+ }, {
18
+ matchRule: 'MQQBrowser',
19
+ iosScheme: 'mttbrowser',
20
+ andScheme: ''
21
+ }, {
22
+ matchRule: 'MicroMessenger',
23
+ iosScheme: '',
24
+ andScheme: ''
25
+ }, {
26
+ matchRule: 'MiuiBrowser',
27
+ iosScheme: '',
28
+ andScheme: ''
29
+ }, {
30
+ matchRule: 'Mozilla\\/([0-9\\.]+).* AppleWebKit\\/([0-9\\.]+).* CriOS\\/([0-9\\._]+) Mobile\\/([0-9\\._A-Z\\._a-z]+) Safari\\/([0-9\\._]+)$',
31
+ iosScheme: 'googlechrome',
32
+ andScheme: ''
33
+ }, {
34
+ matchRule: 'Mozilla\\/([0-9\\.]+).* AppleWebKit\\/([0-9\\.]+).* Version\\/([0-9\\._]+) Mobile Safari\\/([0-9\\._]+)$',
35
+ iosScheme: 'googlechrome',
36
+ andScheme: ''
37
+ }, {
38
+ matchRule: 'NewsArticle',
39
+ iosScheme: 'snssdk141',
40
+ andScheme: ''
41
+ }, {
42
+ matchRule: 'UCBrowser',
43
+ iosScheme: 'ucbrowser',
44
+ andScheme: ''
45
+ }, {
46
+ matchRule: 'VideoArticle',
47
+ iosScheme: 'snssdk32',
48
+ andScheme: ''
49
+ }, {
50
+ matchRule: 'VivoBrowser',
51
+ iosScheme: '',
52
+ andScheme: ''
53
+ }, {
54
+ matchRule: 'ZhongAnWebView',
55
+ iosScheme: 'zaapp',
56
+ andScheme: ''
57
+ }, {
58
+ matchRule: 'aweme',
59
+ iosScheme: 'snssdk1128',
60
+ andScheme: ''
61
+ }, {
62
+ matchRule: 'aweme_lite',
63
+ iosScheme: 'snssdk2329',
64
+ andScheme: ''
65
+ }, {
66
+ matchRule: 'com.xs.fm',
67
+ iosScheme: 'novelfm3040',
68
+ andScheme: ''
69
+ }, {
70
+ matchRule: 'netdisk',
71
+ iosScheme: '',
72
+ andScheme: ''
73
+ }, {
74
+ matchRule: 'qqnews',
75
+ iosScheme: 'qqnews',
76
+ andScheme: ''
77
+ }];
78
+
3
79
  /**
4
80
  * 通过配置规则检测 UA 和获得回跳 scheme
5
81
  */
6
82
  export function getBackScheme(mockUa, logger) {
7
83
  var ua = mockUa || window.navigator.userAgent || '';
8
84
  // 获取规则
9
- var uaMatchedRule = RULES;
85
+ var uaMatchedRule = UA_MATCH_RULES;
10
86
  var matchedRule;
11
87
  var matched = null;
12
88
  for (var i = 0; i < uaMatchedRule.length; i++) {
@@ -39,4 +115,20 @@ function logBackScheme(logger, userAgent, scheme) {
39
115
  backScheme: scheme
40
116
  });
41
117
  }
118
+ }
119
+
120
+ /**
121
+ * 当前运行环境是否 Android
122
+ */
123
+ function isAndroid(mockUA) {
124
+ var ua = (mockUA || navigator.userAgent).toLowerCase();
125
+ return /android|adr|linux/.test(ua);
126
+ }
127
+
128
+ /**
129
+ * 当前运行环境是否 IOS
130
+ */
131
+ function isIOS(mockUA) {
132
+ var ua = (mockUA || navigator.userAgent).toLowerCase();
133
+ return /iphone|ipad|ipod|ios|macintosh/.test(ua);
42
134
  }
@@ -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
+ declare const getType: (target: any) => string;
7
8
  declare class EventCenter {
8
9
  private events;
9
10
  private eventsKey;
@@ -14,7 +15,6 @@ declare class EventCenter {
14
15
  once(name: string, func: any, key?: string): void;
15
16
  isExist(name: string): boolean;
16
17
  }
17
- declare const getType: (target: any) => string;
18
18
  declare const getViewPort: (key: string) => any;
19
19
  declare const getOrigin: () => string;
20
20
  declare const serialize: (obj: Record<string, string>) => string;
package/esm/util/index.js CHANGED
@@ -12,6 +12,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
12
12
  * 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.
13
13
  */
14
14
  /* eslint-disable @typescript-eslint/no-explicit-any */
15
+
16
+ var getType = function getType(target) {
17
+ return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
18
+ };
15
19
  var EventCenter = /*#__PURE__*/function () {
16
20
  function EventCenter() {
17
21
  _classCallCheck(this, EventCenter);
@@ -87,9 +91,6 @@ var EventCenter = /*#__PURE__*/function () {
87
91
  }]);
88
92
  return EventCenter;
89
93
  }();
90
- var getType = function getType(target) {
91
- return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
92
- };
93
94
  var getViewPort = function getViewPort(key) {
94
95
  var meta = document.getElementsByTagName('meta');
95
96
  // HTMLMetaElement
@@ -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
+ }
@@ -5,147 +5,178 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
5
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
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
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
9
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
12
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15
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; }
16
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
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); }
18
- import { RequestActiontEnum } from "../../../../core/bus/interface";
19
- import { BusSubscriber } from "../../../../foundation/service/event-bus/busManager";
20
- import { ServiceProvider } from "../../../../foundation/service";
21
- export var RequestBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
22
- _inherits(RequestBusSubscriber, _BusSubscriber);
23
- var _super = _createSuper(RequestBusSubscriber);
24
- function RequestBusSubscriber(instanceId) {
25
- var _this;
26
- _classCallCheck(this, RequestBusSubscriber);
27
- _this = _super.call(this);
28
- _defineProperty(_assertThisInitialized(_this), "instanceId", void 0);
29
- _this.instanceId = instanceId;
30
- return _this;
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];
31
41
  }
32
- _createClass(RequestBusSubscriber, [{
33
- key: "actionNames",
34
- value: function actionNames() {
35
- return Object.values(RequestActiontEnum);
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
+ }
36
72
  }
37
73
  }, {
38
- key: "request",
74
+ key: "pollingGetApdidToken",
39
75
  value: function () {
40
- var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(context, message) {
41
- var data, requestService, resData, error;
42
- return _regeneratorRuntime().wrap(function _callee$(_context) {
43
- while (1) switch (_context.prev = _context.next) {
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) {
44
81
  case 0:
45
- data = message.getJSONObject();
46
- console.log("request", message);
47
- _context.prev = 2;
48
- requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
49
- if (!(data && data !== null && data !== void 0 && data.options)) {
50
- _context.next = 11;
51
- break;
52
- }
53
- _context.next = 7;
54
- return requestService.request(data.requestData, data.options);
55
- case 7:
56
- resData = _context.sent;
57
- context === null || context === void 0 || context.onCallBack(message.result(resData));
58
- _context.next = 13;
59
- break;
60
- case 11:
61
- error = Error('Request Failed: No Request Options');
62
- context === null || context === void 0 || context.onCallBack(message.result(error));
63
- case 13:
64
- _context.next = 18;
65
- break;
66
- case 15:
67
- _context.prev = 15;
68
- _context.t0 = _context["catch"](2);
69
- context === null || context === void 0 || context.onCallBack(message.result(_context.t0));
70
- case 18:
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:
71
142
  case "end":
72
- return _context.stop();
143
+ return _context3.stop();
73
144
  }
74
- }, _callee, this, [[2, 15]]);
145
+ }, _callee3);
75
146
  }));
76
- function request(_x, _x2) {
77
- return _request.apply(this, arguments);
147
+ function pollingGetApdidToken(_x) {
148
+ return _pollingGetApdidToken.apply(this, arguments);
78
149
  }
79
- return request;
150
+ return pollingGetApdidToken;
80
151
  }()
81
152
  }, {
82
- key: "getEnvInfo",
153
+ key: "getApdidToken",
83
154
  value: function () {
84
- var _getEnvInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(context, message) {
85
- var data, requestService, envInfo, error;
86
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
87
- while (1) switch (_context2.prev = _context2.next) {
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) {
88
159
  case 0:
89
- data = message.getJSONObject();
90
- console.log("getEnvInfo", message);
91
- _context2.prev = 2;
92
- requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
93
- if (!(data && data !== null && data !== void 0 && data.options)) {
94
- _context2.next = 11;
95
- break;
96
- }
97
- _context2.next = 7;
98
- return requestService.getEnvInfo(data.options);
99
- case 7:
100
- envInfo = _context2.sent;
101
- context === null || context === void 0 || context.onCallBack(message.result(envInfo));
102
- _context2.next = 13;
103
- break;
104
- case 11:
105
- error = Error('GetEnvInfo Failed: No Request Options');
106
- context === null || context === void 0 || context.onCallBack(message.result(error));
107
- case 13:
108
- _context2.next = 18;
109
- break;
110
- case 15:
111
- _context2.prev = 15;
112
- _context2.t0 = _context2["catch"](2);
113
- context === null || context === void 0 || context.onCallBack(message.result(_context2.t0));
114
- case 18:
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:
115
170
  case "end":
116
- return _context2.stop();
171
+ return _context4.stop();
117
172
  }
118
- }, _callee2, this, [[2, 15]]);
173
+ }, _callee4);
119
174
  }));
120
- function getEnvInfo(_x3, _x4) {
121
- return _getEnvInfo.apply(this, arguments);
175
+ function getApdidToken() {
176
+ return _getApdidToken.apply(this, arguments);
122
177
  }
123
- return getEnvInfo;
178
+ return getApdidToken;
124
179
  }()
125
- }, {
126
- key: "getUserAgent",
127
- value: function getUserAgent(context, message) {
128
- console.log("getUserAgent", message);
129
- var userAgent = window.navigator.userAgent;
130
- context === null || context === void 0 || context.onCallBack(message.result(userAgent));
131
- }
132
- }, {
133
- key: "onMessage",
134
- value: function onMessage(context, message) {
135
- switch (message.getAction()) {
136
- case RequestActiontEnum.request:
137
- this.request(context, message);
138
- break;
139
- case RequestActiontEnum.getEnvInfo:
140
- this.getEnvInfo(context, message);
141
- break;
142
- case RequestActiontEnum.getUserAgent:
143
- this.getUserAgent(context, message);
144
- break;
145
- default:
146
- console.log("Unknown action: " + message.getAction());
147
- }
148
- }
149
180
  }]);
150
- return RequestBusSubscriber;
151
- }(BusSubscriber);
181
+ return Security;
182
+ }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
@@ -1,10 +0,0 @@
1
- import { BusContext, BusMessage, BusSubscriber } from "../../../foundation/service/event-bus/busManager";
2
- export declare class DataBusSubscriber extends BusSubscriber {
3
- private instanceId;
4
- constructor(instanceId: string);
5
- actionNames(): string[];
6
- protected getGlobalData(context: BusContext, message: BusMessage): void;
7
- protected setGlobalData(context: BusContext, message: BusMessage): void;
8
- protected clearGlobalData(context: BusContext, message: BusMessage): void;
9
- onMessage(context: BusContext, message: BusMessage): void;
10
- }
@@ -1,89 +0,0 @@
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
7
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
9
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12
- 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; }
13
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
- 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); }
15
- import { ServiceProvider } from "../../../../foundation/service";
16
- import { BusSubscriber } from "../../../../foundation/service/event-bus/busManager";
17
- import { DataActiontEnum } from "../../../../core/bus/interface";
18
- export var DataBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
19
- _inherits(DataBusSubscriber, _BusSubscriber);
20
- var _super = _createSuper(DataBusSubscriber);
21
- function DataBusSubscriber(instanceId) {
22
- var _this;
23
- _classCallCheck(this, DataBusSubscriber);
24
- _this = _super.call(this);
25
- _defineProperty(_assertThisInitialized(_this), "instanceId", void 0);
26
- _this.instanceId = instanceId;
27
- return _this;
28
- }
29
- _createClass(DataBusSubscriber, [{
30
- key: "actionNames",
31
- value: function actionNames() {
32
- return Object.values(DataActiontEnum);
33
- }
34
- }, {
35
- key: "getGlobalData",
36
- value: function getGlobalData(context, message) {
37
- var data = message.getJSONObject();
38
- console.log("getGlobalData", message);
39
- if (data && data !== null && data !== void 0 && data.dataKey) {
40
- var dataService = ServiceProvider.getInstance(this.instanceId).getService('GlobalData');
41
- var resData = dataService.getGlobalData(data.dataKey);
42
- context === null || context === void 0 || context.onCallBack(message.result(resData));
43
- } else {
44
- var error = Error('GetGlobalData Failed: Data Key is null');
45
- context === null || context === void 0 || context.onCallBack(message.result(error));
46
- }
47
- }
48
- }, {
49
- key: "setGlobalData",
50
- value: function setGlobalData(context, message) {
51
- var data = message.getJSONObject();
52
- console.log("getGlobalData", message);
53
- if (data && data !== null && data !== void 0 && data.dataKey && data !== null && data !== void 0 && data.data) {
54
- var dataService = ServiceProvider.getInstance(this.instanceId).getService('GlobalData');
55
- dataService.setGlobalData(data.dataKey, data.data);
56
- context === null || context === void 0 || context.onCallBack(message.result(true));
57
- } else {
58
- var error = Error('SetGlobalData Failed: Data Key or Data is null');
59
- context === null || context === void 0 || context.onCallBack(message.result(error));
60
- }
61
- }
62
- }, {
63
- key: "clearGlobalData",
64
- value: function clearGlobalData(context, message) {
65
- console.log("clearGlobalData", message);
66
- var dataService = ServiceProvider.getInstance(this.instanceId).getService('GlobalData');
67
- dataService.clearGlobalData();
68
- context === null || context === void 0 || context.onCallBack(message.result(true));
69
- }
70
- }, {
71
- key: "onMessage",
72
- value: function onMessage(context, message) {
73
- switch (message.getAction()) {
74
- case DataActiontEnum.getGlobalData:
75
- this.getGlobalData(context, message);
76
- break;
77
- case DataActiontEnum.setGlobalData:
78
- this.setGlobalData(context, message);
79
- break;
80
- case DataActiontEnum.clearGlobalData:
81
- this.clearGlobalData(context, message);
82
- break;
83
- default:
84
- console.log("Unknown action: " + message.getAction());
85
- }
86
- }
87
- }]);
88
- return DataBusSubscriber;
89
- }(BusSubscriber);
@@ -1,10 +0,0 @@
1
- import { BusContext, BusMessage, BusSubscriber } from "../../../../foundation/service/event-bus/busManager";
2
- export declare class RequestBusSubscriber extends BusSubscriber {
3
- private instanceId;
4
- constructor(instanceId: string);
5
- actionNames(): string[];
6
- protected request(context: BusContext, message: BusMessage): Promise<void>;
7
- protected getEnvInfo(context: BusContext, message: BusMessage): Promise<void>;
8
- protected getUserAgent(context: BusContext, message: BusMessage): void;
9
- onMessage(context: BusContext, message: BusMessage): void;
10
- }
@@ -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
- */
@@ -1,2 +0,0 @@
1
- export * from './isAndroid';
2
- export * from './isIOS';
@@ -1,2 +0,0 @@
1
- export * from "./isAndroid";
2
- export * from "./isIOS";
@@ -1,4 +0,0 @@
1
- /**
2
- * 当前运行环境是否 Android
3
- */
4
- export declare function isAndroid(mockUA?: string): boolean;
@@ -1,7 +0,0 @@
1
- /**
2
- * 当前运行环境是否 Android
3
- */
4
- export function isAndroid(mockUA) {
5
- var ua = (mockUA || navigator.userAgent).toLowerCase();
6
- return /android|adr|linux/.test(ua);
7
- }