@alipay/ams-checkout 0.0.1697942541-dev.6 → 0.0.1697942541-dev.8

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.
@@ -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);
@@ -38,6 +38,13 @@ var AMSSDK = /*#__PURE__*/function () {
38
38
  _defineProperty(this, "logger", void 0);
39
39
  this._instanceId = uuid();
40
40
  this._storageId = this.getStorageId(this._instanceId);
41
+ this.options = {};
42
+ this._eventCenter = new EventCenter();
43
+ this._initEvent(options);
44
+ this._setOptions(options);
45
+ this.plugins = new Map();
46
+ this.securityConfig = null;
47
+
41
48
  // TODO Consumption data analysis control parameters
42
49
  this.logger = new Logger(LogConfig, (options === null || options === void 0 ? void 0 : options.environment) !== environmentEnum.prod);
43
50
  this.logger.setMedta({
@@ -47,16 +54,10 @@ var AMSSDK = /*#__PURE__*/function () {
47
54
  this.logger.logInfo({
48
55
  title: 'NEW_AMSSDK_BY_MECHANT',
49
56
  msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale, "}")
50
- });
51
-
52
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
53
- this.options = {};
54
- this._eventCenter = new EventCenter();
55
- this._initEvent(options);
56
- this._setOptions(options);
57
- this.plugins = new Map();
58
- this.securityConfig = null;
59
- this.logger.send();
57
+ }).send();
58
+ if (options !== null && options !== void 0 && options.securityConfig) {
59
+ this.initSecurity(options === null || options === void 0 ? void 0 : options.securityConfig);
60
+ }
60
61
  }
61
62
  /**
62
63
  * @description Destroy and process some contents of the plug-in
@@ -64,6 +65,9 @@ var AMSSDK = /*#__PURE__*/function () {
64
65
  _createClass(AMSSDK, [{
65
66
  key: "unmount",
66
67
  value: function unmount() {
68
+ this.logger.logInfo({
69
+ title: 'sdk_event_apiOnDestroy'
70
+ }).send();
67
71
  var _iterator = _createForOfIteratorHelper(this.plugins.values()),
68
72
  _step;
69
73
  try {
@@ -109,7 +113,6 @@ var AMSSDK = /*#__PURE__*/function () {
109
113
  value: function initSecurity(securityConfig) {
110
114
  var _this = this;
111
115
  try {
112
- console.log("-----------Risk control project test: \u4E3B\u52A8\u521D\u59CB\u5316\u5B89\u5168sdk");
113
116
  this.securityConfig = securityConfig;
114
117
  initAPSecurity(securityConfig, function () {
115
118
  _this.logger.logInfo({
@@ -125,7 +128,9 @@ var AMSSDK = /*#__PURE__*/function () {
125
128
  title: 'sdk_event_securitySdkPreInit'
126
129
  }).send();
127
130
  } catch (e) {
128
- console.log("-----------Risk control project test: \u4E3B\u52A8\u521D\u59CB\u5316\u5B89\u5168sdk\u5931\u8D25");
131
+ this.logger.logError({
132
+ title: 'sdk_error_securitySdkInitFailed'
133
+ }).send();
129
134
  }
130
135
  }
131
136
 
@@ -131,11 +131,9 @@ var ComponentApp = /*#__PURE__*/function () {
131
131
 
132
132
  // if merchant have init securitySDK and same as service paymentSessionMetaData, no need init again
133
133
  if (this.AMSSDK.securityConfig) {
134
- if (appName === getAppname(this.AMSSDK.securityConfig.sence) && h5gateway === getSecurityHost(this.AMSSDK.securityConfig.region)) {
135
- console.log("-----------Risk control project test: \u5DF2\u7ECF\u4E3B\u52A8\u521D\u59CB\u5316\uFF0C\u4E14\u914D\u7F6E\u4E0EsecurityConfig\u4E00\u81F4");
134
+ if (appName === getAppname(this.AMSSDK.securityConfig.scene) && h5gateway === getSecurityHost(this.AMSSDK.securityConfig.region)) {
136
135
  return;
137
136
  }
138
- console.log("-----------Risk control project test: \u5DF2\u7ECF\u4E3B\u52A8\u521D\u59CB\u5316\uFF0C\u4E0EsecurityConfig\u914D\u7F6E\u4E0D\u4E00\u81F4\uFF0C\u4F7F\u7528paymentSessionMetaData.securityConfig\u91CD\u65B0\u521D\u59CB\u5316");
139
137
  }
140
138
  this.AMSSDK.logger.logInfo({
141
139
  title: 'sdk_event_securitySdkInit'
@@ -237,19 +235,13 @@ var ComponentApp = /*#__PURE__*/function () {
237
235
  createMockup();
238
236
  this.renderPopupLoading(renderParams);
239
237
  }
240
- this.AMSSDK.logger.logInfo({
241
- title: 'sdk_event_createComponent'
242
- }).send();
243
238
  this.createApp(renderParams);
244
239
  return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
245
240
  _this3.AMSSDK.logger.logInfo({
246
- title: 'AMSSDK_BEGIN_CREATE_APP_SUCCESS'
241
+ title: 'sdk_event_successfully_created_app_process'
247
242
  }).send();
248
243
  return Promise.resolve();
249
244
  }).catch(function (error) {
250
- _this3.AMSSDK.logger.logError({
251
- title: 'AMSSDK_BEGIN_CREATE_APP_FAIL'
252
- }).send();
253
245
  _this3._isInitComponent = false;
254
246
  _this3.cleanContainer();
255
247
  return Promise.reject(error);
@@ -288,6 +280,9 @@ var ComponentApp = /*#__PURE__*/function () {
288
280
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
289
281
  message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
290
282
  });
283
+ _this4.AMSSDK.logger.logError({
284
+ title: 'sdk_error_web_app_timeout'
285
+ }).send();
291
286
  return Promise.reject(error);
292
287
  });
293
288
  }
@@ -328,69 +323,67 @@ var ComponentApp = /*#__PURE__*/function () {
328
323
  }
329
324
  securityConfig = (_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 || (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.securityConfig;
330
325
  if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign && securityConfig)) {
331
- _context2.next = 12;
326
+ _context2.next = 11;
332
327
  break;
333
328
  }
334
329
  extendInfo = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.extendInfo) || '{}';
335
330
  info = JSON.parse(extendInfo);
336
331
  if (!((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false')) {
337
- _context2.next = 12;
332
+ _context2.next = 11;
338
333
  break;
339
334
  }
340
- // old card cardTokenPay: 'true'|| true null ; new card = 'false'
341
- console.log("-----------Risk control project test: \u8BC6\u522B\u5230\u5361\u573A\u666F\uFF0C\u4E14\u662F\u5B58\u5361\u3002\u53BB\u83B7\u53D6deviceId");
342
- _context2.next = 11;
335
+ _context2.next = 10;
343
336
  return _this5.getDeviceIdAndLog();
344
- case 11:
337
+ case 10:
345
338
  envInfo.deviceId = _context2.sent;
346
- case 12:
339
+ case 11:
347
340
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
348
- _context2.next = 17;
341
+ _context2.next = 16;
349
342
  break;
350
343
  }
351
344
  _ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
352
345
  _ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
353
346
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
354
- _context2.next = 17;
347
+ _context2.next = 16;
355
348
  break;
356
349
  }
357
350
  return _context2.abrupt("return", resolve({
358
351
  message: 'sdk no need to make query request',
359
352
  success: true
360
353
  }));
361
- case 17:
354
+ case 16:
362
355
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
363
- _context2.next = 24;
356
+ _context2.next = 23;
364
357
  break;
365
358
  }
366
359
  action = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 || (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.action) || {};
367
360
  signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
368
361
  if (!(signType === 'SMS')) {
369
- _context2.next = 22;
362
+ _context2.next = 21;
370
363
  break;
371
364
  }
372
365
  return _context2.abrupt("return", resolve({
373
366
  message: 'sdk no need to make query request',
374
367
  success: true
375
368
  }));
376
- case 22:
369
+ case 21:
377
370
  if (!(!signType || signType !== 'REDIRECT')) {
378
- _context2.next = 24;
371
+ _context2.next = 23;
379
372
  break;
380
373
  }
381
374
  return _context2.abrupt("return", resolve({
382
375
  success: false
383
376
  }));
384
- case 24:
377
+ case 23:
385
378
  if (!isLocalMock()) {
386
- _context2.next = 26;
379
+ _context2.next = 25;
387
380
  break;
388
381
  }
389
382
  return _context2.abrupt("return", resolve({
390
383
  message: 'sdk no need to make query request',
391
384
  success: true
392
385
  }));
393
- case 26:
386
+ case 25:
394
387
  queryPaymentInfo(params, {
395
388
  env: _this5.AMSSDK.options.env.environment,
396
389
  envInfo: envInfo
@@ -415,7 +408,7 @@ var ComponentApp = /*#__PURE__*/function () {
415
408
  });
416
409
  reject(err);
417
410
  });
418
- case 27:
411
+ case 26:
419
412
  case "end":
420
413
  return _context2.stop();
421
414
  }
@@ -614,7 +607,6 @@ var ComponentApp = /*#__PURE__*/function () {
614
607
  return;
615
608
  }
616
609
  if (data.context.event === EVENT.getDeviceId.name) {
617
- console.log("-----------Risk control project test: \u6536\u94F6\u53F0\u8C03\u7528\u83B7\u53D6deviceId");
618
610
  this.getDeviceIdAndCallback(data.context);
619
611
  return;
620
612
  }
@@ -852,6 +844,11 @@ var ComponentApp = /*#__PURE__*/function () {
852
844
  appId: COMPONENTPLUGINID,
853
845
  instanceId: this.AMSSDK._instanceId
854
846
  });
847
+ this.AMSSDK.logger.logInfo({
848
+ title: 'sdk_event_send_message_to_web'
849
+ }, {
850
+ event: data === null || data === void 0 ? void 0 : data.context.event
851
+ }).send();
855
852
  if (targetElement && targetElement.contentWindow) {
856
853
  return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
857
854
  }
@@ -22,6 +22,7 @@ export interface IoptionsParams {
22
22
  analytics?: {
23
23
  enabled: boolean;
24
24
  };
25
+ securityConfig?: IsecurityConfig;
25
26
  }
26
27
  export type Iselector = string;
27
28
  export declare enum renderDisplayTypeEnum {
@@ -300,7 +301,7 @@ export declare enum SecuritySceneEnum {
300
301
  EASYPAY = "EASYPAY"
301
302
  }
302
303
  export interface IsecurityConfig {
303
- sence: string;
304
+ scene: string;
304
305
  region: string;
305
306
  }
306
307
  declare global {
@@ -32,6 +32,7 @@ interface Config {
32
32
  batchCount: number;
33
33
  productId: string;
34
34
  mdata?: LogMetaData;
35
+ version?: string;
35
36
  }
36
37
  export declare class Logger {
37
38
  private logs;
@@ -88,21 +88,25 @@ export var Logger = /*#__PURE__*/function () {
88
88
  logInfo = _window$iTracker.logInfo,
89
89
  reportRPC = _window$iTracker.reportRPC;
90
90
  var logs = this.logs;
91
- var fsDuration = Date.now() - this.componentStartTime;
91
+ var now = Date.now();
92
+ var fsDuration = now - this.componentStartTime;
92
93
  while (logs.length > 0) {
93
94
  try {
94
95
  var log = logs.pop();
95
96
  if (log.type === 'error') {
96
97
  logError(log.logPayload, _objectSpread({
97
- fsDuration: fsDuration
98
+ fsDuration: fsDuration,
99
+ timeStamp: now
98
100
  }, log === null || log === void 0 ? void 0 : log.extra));
99
101
  } else if (log.type === 'info') {
100
102
  logInfo(log.logPayload, _objectSpread({
101
- fsDuration: fsDuration
103
+ fsDuration: fsDuration,
104
+ timeStamp: now
102
105
  }, log === null || log === void 0 ? void 0 : log.extra));
103
106
  } else if (log.type === 'rpc') {
104
107
  reportRPC(log.logPayload, _objectSpread({
105
- fsDuration: fsDuration
108
+ fsDuration: fsDuration,
109
+ timeStamp: now
106
110
  }, log === null || log === void 0 ? void 0 : log.extra));
107
111
  }
108
112
  } catch (error) {
@@ -166,6 +170,7 @@ export var LogConfig = {
166
170
  server: 'https://imdap-sea.alipay.com/loggw/dwcookieLogGet.do',
167
171
  bizType: 'antom_sdk',
168
172
  productId: 'ANTOM_SDK',
173
+ version: 'iteration/20231021',
169
174
  mdata: {
170
175
  fistLogTime: Date.now()
171
176
  }
@@ -16,13 +16,13 @@ export var appName = {
16
16
  EASYPAY: 'EasyPay'
17
17
  };
18
18
  export var initAPSecurity = function initAPSecurity(securityConfig, successCallback, failCallback) {
19
- if (!securityConfig || !(securityConfig !== null && securityConfig !== void 0 && securityConfig.sence) || !(securityConfig !== null && securityConfig !== void 0 && securityConfig.region)) {
19
+ if (!securityConfig || !(securityConfig !== null && securityConfig !== void 0 && securityConfig.scene) || !(securityConfig !== null && securityConfig !== void 0 && securityConfig.region)) {
20
20
  throw new Error('securityConfig parameter error');
21
21
  }
22
- var curAppName = getAppname(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.sence);
22
+ var curAppName = getAppname(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.scene);
23
23
  var h5gateway = getSecurityHost(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.region);
24
24
  if (!curAppName || !h5gateway) {
25
- throw new Error("appName:".concat(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.sence, " or region:").concat(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.region, " do not supported"));
25
+ throw new Error("appName:".concat(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.scene, " or region:").concat(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.region, " do not supported"));
26
26
  }
27
27
  initSecuritySDK(curAppName, h5gateway, successCallback, failCallback);
28
28
  };
@@ -31,10 +31,8 @@ export var initSecuritySDK = function initSecuritySDK(appName, h5gateway, succes
31
31
  host: h5gateway
32
32
  }, function (success, tokenResult, msg) {
33
33
  if (success) {
34
- console.log("-----------Risk control project test: \u521D\u59CB\u5316\u5B89\u5168sdk\u6210\u529F");
35
34
  successCallback && successCallback();
36
35
  } else {
37
- console.log("-----------Risk control project test: \u521D\u59CB\u5316\u5B89\u5168sdk\u5931\u8D25");
38
36
  failCallback && failCallback(msg);
39
37
  }
40
38
  console.log('initToken result tokenResult', JSON.stringify(tokenResult), msg);
@@ -52,27 +50,24 @@ export var getApdidToken = function getApdidToken(scene, securityConfig) {
52
50
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
53
51
  while (1) switch (_context2.prev = _context2.next) {
54
52
  case 0:
55
- console.log("-----------Risk control project test: \u5FAA\u73AF\u83B7\u53D6deviceId\uFF0C\u95F4\u9694".concat(dataPollingInterval));
56
- _context2.next = 3;
53
+ _context2.next = 2;
57
54
  return tryGetDeviceId(scene);
58
- case 3:
55
+ case 2:
59
56
  deviceId = _context2.sent;
60
57
  polling = /*#__PURE__*/function () {
61
58
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
62
59
  return _regeneratorRuntime().wrap(function _callee$(_context) {
63
60
  while (1) switch (_context.prev = _context.next) {
64
61
  case 0:
65
- console.log("-----------Risk control project test: \u5FAA\u73AF\u83B7\u53D6deviceId\uFF0C\u95F4\u9694".concat(dataPollingInterval));
66
- _context.next = 3;
62
+ _context.next = 2;
67
63
  return tryGetDeviceId(scene);
68
- case 3:
64
+ case 2:
69
65
  deviceId = _context.sent;
70
66
  if (deviceId) {
71
67
  clearInterval(interval);
72
- console.log("-----------Risk control project test: \u83B7\u53D6deviceId\u6210\u529F".concat(deviceId));
73
68
  resolve(deviceId);
74
69
  }
75
- case 5:
70
+ case 4:
76
71
  case "end":
77
72
  return _context.stop();
78
73
  }
@@ -83,17 +78,15 @@ export var getApdidToken = function getApdidToken(scene, securityConfig) {
83
78
  };
84
79
  }();
85
80
  if (deviceId) {
86
- console.log("-----------Risk control project test: \u6210\u529F\u83B7\u53D6deviceId\uFF1A".concat(deviceId));
87
81
  resolve(deviceId);
88
82
  } else {
89
83
  interval = setInterval(polling, dataPollingInterval);
90
84
  setTimeout(function () {
91
85
  clearInterval(interval);
92
- console.log("-----------Risk control project test: \u83B7\u53D6deviceId\u5931\u8D25");
93
86
  resolve('');
94
87
  }, tokenCollectTime);
95
88
  }
96
- case 6:
89
+ case 5:
97
90
  case "end":
98
91
  return _context2.stop();
99
92
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@alipay/ams-checkout","version":"0.0.1697942541-dev.6","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@alipay/jshield-apdid":"^2.0.3","@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
1
+ {"name":"@alipay/ams-checkout","version":"0.0.1697942541-dev.8","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@alipay/jshield-apdid":"^2.0.3","@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}