@alipay/ams-checkout 1.5.8 → 1.5.10

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.
@@ -1,2 +1,2 @@
1
- export declare const marmptMap: Record<string, string>;
1
+ export declare const marmotMap: Record<string, string>;
2
2
  export declare const sdkVersion: string;
@@ -6,7 +6,7 @@
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
- export var marmptMap = {
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',
12
12
  pre: 'https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app',
@@ -140,6 +140,18 @@ export declare const EVENT: {
140
140
  dismissLoading: {
141
141
  name: string;
142
142
  };
143
+ popupWindow: {
144
+ name: string;
145
+ };
146
+ closePopup: {
147
+ name: string;
148
+ };
149
+ threedReady: {
150
+ name: string;
151
+ };
152
+ getDeviceId: {
153
+ name: string;
154
+ };
143
155
  };
144
156
  export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
145
157
  export declare const COMPONENT_SECTION_ID = "ams-component-section";
@@ -151,6 +163,7 @@ export declare const LOADING_ID = "ams-component-loading";
151
163
  export declare const LISTENER_PREFIX = "_ams_sdk_component_listener";
152
164
  export declare const INLINE_BASE_STYLE_ID = "ams-inline-component-style";
153
165
  export declare const INLINE_IMG_CLASSNAME = "inline-loading";
166
+ export declare const AMSPOPUP_PREFIX = "ams-popup";
154
167
  export declare const LOADTIME_LIMIT = 15000;
155
168
  export declare const ANIMATION_TIME = 300;
156
169
  export declare const closeImg = "https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg";
@@ -139,6 +139,18 @@ export var EVENT = {
139
139
  },
140
140
  dismissLoading: {
141
141
  name: 'dismissLoading'
142
+ },
143
+ popupWindow: {
144
+ name: 'popupWindow'
145
+ },
146
+ closePopup: {
147
+ name: 'closePopup'
148
+ },
149
+ threedReady: {
150
+ name: 'threedReady'
151
+ },
152
+ getDeviceId: {
153
+ name: 'getDeviceId'
142
154
  }
143
155
  };
144
156
  export var COMPONENT_CONTAINER_ID = 'ams-component-container';
@@ -151,6 +163,7 @@ export var LOADING_ID = 'ams-component-loading';
151
163
  export var LISTENER_PREFIX = '_ams_sdk_component_listener';
152
164
  export var INLINE_BASE_STYLE_ID = 'ams-inline-component-style';
153
165
  export var INLINE_IMG_CLASSNAME = 'inline-loading';
166
+ export var AMSPOPUP_PREFIX = 'ams-popup';
154
167
  export var LOADTIME_LIMIT = 15000;
155
168
  export var ANIMATION_TIME = 300;
156
169
  export var closeImg = 'https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg';
@@ -72,7 +72,7 @@ var handleParams = function handleParams(params) {
72
72
  paymentSessionMetaData: {},
73
73
  renderDisplayType: renderDisplayTypeEnum.popup
74
74
  }, params);
75
- var _handleSessionData = handleSessionData(_params.sessionData),
75
+ var _handleSessionData = handleSessionData(_params.sessionData || (_params === null || _params === void 0 ? void 0 : _params.paymentSessionData)),
76
76
  _handleSessionData2 = _slicedToArray(_handleSessionData, 2),
77
77
  parseData = _handleSessionData2[0],
78
78
  sessionData = _handleSessionData2[1];
@@ -119,7 +119,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
119
119
  selector: selector,
120
120
  renderDisplayType: renderDisplayType
121
121
  }, params);
122
- if (_params && !_params.sessionData) {
122
+ if (_params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
123
123
  return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
124
124
  }
125
125
  if (this.options.networkMode === networkModeEnum.proxy) {
@@ -132,6 +132,9 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
132
132
  key: "pluginAppendIframe",
133
133
  value: function pluginAppendIframe(appendParams) {
134
134
  try {
135
+ this.logger.logInfo({
136
+ title: 'sdk_event_createComponent'
137
+ }).send();
135
138
  return this._componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams);
136
139
  } catch (error) {
137
140
  return Promise.reject(error);
@@ -1,16 +1,28 @@
1
- import type { AMSCheckoutOptions, IcheckoutState, IoptionsParams } from '../../types/index';
1
+ import { Logger } from '../../util/logger';
2
+ import type { AMSCheckoutOptions, IcheckoutState, IoptionsParams, IsecurityConfig } from '../../types/index';
2
3
  import { EventCenter } from '../../util/index';
3
4
  export default class AMSSDK {
4
5
  options: AMSCheckoutOptions;
5
6
  checkoutState: IcheckoutState;
7
+ securityConfig: IsecurityConfig;
6
8
  _eventCenter: EventCenter;
7
9
  protected plugins: Map<string, any>;
8
10
  _instanceId: string;
11
+ _storageId: string;
12
+ logger: Logger;
9
13
  constructor(options: IoptionsParams);
10
14
  /**
11
15
  * @description Destroy and process some contents of the plug-in
12
16
  */
13
17
  unmount(): void;
18
+ /**
19
+ * @description set STORAGE_ID for a user session
20
+ */
21
+ getStorageId(instanceId: string): any;
22
+ /**
23
+ * @description init initSecurity SDK
24
+ */
25
+ initSecurity(securityConfig: IsecurityConfig): void;
14
26
  /**
15
27
  * @description Set the sdk basic configuration
16
28
  */
@@ -17,25 +17,47 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
17
17
  */
18
18
  /* eslint-disable @typescript-eslint/no-explicit-any */
19
19
  import { v4 as uuid } from 'uuid';
20
+ import { LogConfig, Logger } from "../../util/logger";
20
21
  import { ERRORMESSAGE, EVENT } from "../../constant";
21
22
  import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
22
23
  import { device, EventCenter, getType, queryParse } from "../../util/index";
23
24
  import CallApp from "../../util/intl-callapp/es/main";
25
+ import { initAPSecurity } from "../../util/security";
26
+
27
+ // TODO Faster initialization of buried point tools
24
28
  var AMSSDK = /*#__PURE__*/function () {
25
29
  function AMSSDK(options) {
26
30
  _classCallCheck(this, AMSSDK);
27
31
  _defineProperty(this, "options", void 0);
28
32
  _defineProperty(this, "checkoutState", void 0);
33
+ _defineProperty(this, "securityConfig", void 0);
29
34
  _defineProperty(this, "_eventCenter", void 0);
30
35
  _defineProperty(this, "plugins", void 0);
31
36
  _defineProperty(this, "_instanceId", void 0);
37
+ _defineProperty(this, "_storageId", void 0);
38
+ _defineProperty(this, "logger", void 0);
32
39
  this._instanceId = uuid();
33
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
40
+ this._storageId = this.getStorageId(this._instanceId);
34
41
  this.options = {};
35
42
  this._eventCenter = new EventCenter();
36
43
  this._initEvent(options);
37
44
  this._setOptions(options);
38
45
  this.plugins = new Map();
46
+ this.securityConfig = null;
47
+
48
+ // TODO Consumption data analysis control parameters
49
+ this.logger = new Logger(LogConfig, (options === null || options === void 0 ? void 0 : options.environment) !== environmentEnum.prod);
50
+ this.logger.setMedta({
51
+ instanceId: this._instanceId
52
+ });
53
+ this.logger.initTracker();
54
+ this.logger.logInfo({
55
+ title: 'NEW_AMSSDK_BY_MECHANT',
56
+ msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale, "}")
57
+ }).send();
58
+ if (options !== null && options !== void 0 && options.securityConfig) {
59
+ this.initSecurity(options === null || options === void 0 ? void 0 : options.securityConfig);
60
+ }
39
61
  }
40
62
  /**
41
63
  * @description Destroy and process some contents of the plug-in
@@ -43,6 +65,9 @@ var AMSSDK = /*#__PURE__*/function () {
43
65
  _createClass(AMSSDK, [{
44
66
  key: "unmount",
45
67
  value: function unmount() {
68
+ this.logger.logInfo({
69
+ title: 'sdk_event_apiOnDestroy'
70
+ }).send();
46
71
  var _iterator = _createForOfIteratorHelper(this.plugins.values()),
47
72
  _step;
48
73
  try {
@@ -61,6 +86,54 @@ var AMSSDK = /*#__PURE__*/function () {
61
86
  _iterator.f();
62
87
  }
63
88
  }
89
+
90
+ /**
91
+ * @description set STORAGE_ID for a user session
92
+ */
93
+ }, {
94
+ key: "getStorageId",
95
+ value: function getStorageId(instanceId) {
96
+ var storageKey = 'AMSSDK_STORAGE_ID';
97
+ if (window.localStorage) {
98
+ var storageId = window.localStorage.getItem(storageKey);
99
+ if (storageId) {
100
+ return storageId;
101
+ } else {
102
+ window.localStorage.setItem(storageKey, instanceId);
103
+ }
104
+ }
105
+ return instanceId;
106
+ }
107
+
108
+ /**
109
+ * @description init initSecurity SDK
110
+ */
111
+ }, {
112
+ key: "initSecurity",
113
+ value: function initSecurity(securityConfig) {
114
+ var _this = this;
115
+ try {
116
+ this.securityConfig = securityConfig;
117
+ initAPSecurity(securityConfig, function () {
118
+ _this.logger.logInfo({
119
+ title: 'sdk_event_securitySdkPreInitSuccess'
120
+ }).send();
121
+ }, function (msg) {
122
+ _this.logger.logError({
123
+ title: 'sdk_error_securitySdkInitFailed',
124
+ msg: msg
125
+ }).send();
126
+ });
127
+ this.logger.logInfo({
128
+ title: 'sdk_event_securitySdkPreInit'
129
+ }).send();
130
+ } catch (e) {
131
+ this.logger.logError({
132
+ title: 'sdk_error_securitySdkInitFailed'
133
+ }).send();
134
+ }
135
+ }
136
+
64
137
  /**
65
138
  * @description Set the sdk basic configuration
66
139
  */
@@ -173,9 +246,9 @@ var AMSSDK = /*#__PURE__*/function () {
173
246
  }, {
174
247
  key: "_redirect",
175
248
  value: function _redirect(data) {
176
- var _this = this;
249
+ var _this2 = this;
177
250
  return new Promise(function (resolve, reject) {
178
- var isWeb = _this.options.env.terminalType === terminalTypeEnum.WEB;
251
+ var isWeb = _this2.options.env.terminalType === terminalTypeEnum.WEB;
179
252
  var normalUrl = (data === null || data === void 0 ? void 0 : data.normalUrl) || '';
180
253
  var schemeUrl = (data === null || data === void 0 ? void 0 : data.schemeUrl) || '';
181
254
  var applinkUrl = (data === null || data === void 0 ? void 0 : data.applinkUrl) || '';
@@ -18,7 +18,10 @@ export declare const getIframeUrl: (iframeParams: {
18
18
  locale: string;
19
19
  instanceId: string;
20
20
  renderDisplayType: renderDisplayTypeEnum;
21
- }) => string;
21
+ }) => {
22
+ path: string;
23
+ locationSearch: string;
24
+ };
22
25
  /**
23
26
  * @description Create iframe
24
27
  */
@@ -9,7 +9,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
9
9
  * 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
10
10
  * 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.
11
11
  */
12
- import { marmptMap, sdkVersion } from "../../config/index";
12
+ import { marmotMap, sdkVersion } from "../../config/index";
13
13
  import { componentSignEnum } from "../../types";
14
14
  import { getViewPort, queryParse, serialize } from "../../util/index";
15
15
  var getAppVersion = function getAppVersion(_extendInfo) {
@@ -46,7 +46,7 @@ export var getAppPath = function getAppPath() {
46
46
  if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
47
47
  return urlTestHost;
48
48
  }
49
- return "".concat(marmptMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
49
+ return "".concat(marmotMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
50
50
  };
51
51
  export var getAppDomain = function getAppDomain(domainParams) {
52
52
  var environment = domainParams.environment,
@@ -99,7 +99,10 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
99
99
  if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
100
100
  if (_displayType) urlParams.displayType = _displayType;
101
101
  var locationSearch = serialize(urlParams);
102
- return "".concat(path, "?").concat(locationSearch);
102
+ return {
103
+ path: path,
104
+ locationSearch: locationSearch
105
+ };
103
106
  };
104
107
 
105
108
  /**
@@ -9,6 +9,8 @@ export default class ComponentApp {
9
9
  _performanceData: any[];
10
10
  _loadAppPromiseResolve: ((value: boolean) => void) | null;
11
11
  _isInitComponent: boolean;
12
+ private _threedData?;
13
+ private popupWindow?;
12
14
  private appDomain;
13
15
  private createIframeNode;
14
16
  private _selector;
@@ -17,7 +19,7 @@ export default class ComponentApp {
17
19
  private _actionQueryPromise;
18
20
  private _renderParams;
19
21
  private _componentSign;
20
- private _clickEventName;
22
+ private _appLocationSearch;
21
23
  private _renderDisplayType;
22
24
  constructor();
23
25
  /**
@@ -28,11 +30,14 @@ export default class ComponentApp {
28
30
  * @description When SDK registers plug-ins, it is a required function to receive SDK instances
29
31
  */
30
32
  applyPlugin(AMSSDK: AMSCheckout): void;
33
+ private initLoggerMeta;
31
34
  /**
32
35
  * @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
33
36
  */
34
37
  setRender(renderFunc: IrenderFuncParams): void;
35
- initAPSecurity(): void;
38
+ private initAPSecurity;
39
+ private logDeviceId;
40
+ private getDeviceIdAndLog;
36
41
  /**
37
42
  * @description render iframe content
38
43
  */
@@ -51,6 +56,8 @@ export default class ComponentApp {
51
56
  private createApp;
52
57
  private listener;
53
58
  private resizeListener;
59
+ private createPopupWindow;
60
+ private getDeviceIdAndCallback;
54
61
  /**
55
62
  * @description Initialize subscription iframe message
56
63
  */
@@ -73,7 +80,7 @@ export default class ComponentApp {
73
80
  */
74
81
  dispatchToApp(payload: {
75
82
  context: eventPayloadContext;
76
- }): any;
83
+ }, targetElement?: any): any;
77
84
  /**
78
85
  * @description Subscribe to messages from SDK
79
86
  */