@alipay/ams-checkout 0.0.1733198624-dev.1 → 0.0.1733711101-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,10 +5,10 @@ export declare const sdkVersion: string;
5
5
  /**
6
6
  * @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
7
7
  */
8
- export declare const AMSCheckoutAppVersion = "1.25.2";
9
- export declare const AMSAutoDebitAppVersion = "1.25.2";
10
- export declare const AMSEasyPayAppVersion = "1.25.2";
11
- export declare const AMSCashierPaymentAppVersion = "1.25.2";
12
- export declare const AMSVaultingAppVersion = "1.25.2";
8
+ export declare const AMSCheckoutAppVersion = "1.26.0";
9
+ export declare const AMSAutoDebitAppVersion = "1.26.0";
10
+ export declare const AMSEasyPayAppVersion = "1.26.0";
11
+ export declare const AMSCashierPaymentAppVersion = "1.26.0";
12
+ export declare const AMSVaultingAppVersion = "1.26.0";
13
13
  export declare const AMSPaymentElementAppVersion = "1.25.2";
14
14
  export declare const ADDRESSElementAppVersion = "1.25.2";
@@ -35,10 +35,10 @@ export var sdkVersion = json.version;
35
35
  /**
36
36
  * @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
37
37
  */
38
- export var AMSCheckoutAppVersion = '1.25.2'; // 兜底版本号
39
- export var AMSAutoDebitAppVersion = '1.25.2'; // 代扣
40
- export var AMSEasyPayAppVersion = '1.25.2'; // easypay
41
- export var AMSCashierPaymentAppVersion = '1.25.2'; // 收银台(卡、apm)
42
- export var AMSVaultingAppVersion = '1.25.2'; // 绑卡
38
+ export var AMSCheckoutAppVersion = '1.26.0'; // 兜底版本号
39
+ export var AMSAutoDebitAppVersion = '1.26.0'; // 代扣
40
+ export var AMSEasyPayAppVersion = '1.26.0'; // easypay
41
+ export var AMSCashierPaymentAppVersion = '1.26.0'; // 收银台(卡、apm)
42
+ export var AMSVaultingAppVersion = '1.26.0'; // 绑卡
43
43
  export var AMSPaymentElementAppVersion = '1.25.2'; // payment element
44
44
  export var ADDRESSElementAppVersion = '1.25.2'; // address element
@@ -16,16 +16,16 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
16
16
  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; }
17
17
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
18
  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); }
19
- import { AntomSDKCore } from "../../../foundation/core";
20
19
  import PackageJson from "../../../../package.json";
20
+ import { AntomSDKCore } from "../../../foundation/core";
21
+ import { EVENT as ConstantEvent } from "../../../constant";
21
22
  import { ConnectErrorCode, ElementPaymentEvent, ElementPaymentMethod, EventCallbackCode, ProductSceneEnum } from "../../../types";
22
23
  import { parseSessionData } from "../index";
23
24
  import { ElementAddressComponent } from "./components/address";
24
25
  import { ElementAuthComponent } from "./components/auth";
25
26
  import { ElementPaymentComponent } from "./components/payment";
26
- import { EVENT as ConstantEvent } from "../../../constant";
27
27
  // import { oneAccount, sdkAction, submitResult } from './mock';
28
-
28
+ import { v4 as uuid } from 'uuid';
29
29
  import { addressTheme, ELEMENT_ENVIRONMENT, ThemeType } from "./type";
30
30
  var ElementProcessor = /*#__PURE__*/function () {
31
31
  function ElementProcessor(options) {
@@ -515,7 +515,7 @@ export var ElementComponent = /*#__PURE__*/function () {
515
515
  value: function createIframeSrc() {
516
516
  var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ELEMENT_ENVIRONMENT.DEV;
517
517
  var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PackageJson.version;
518
- var baseUrl = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ELEMENT_ENVIRONMENT.DEV, 'http://dev.page.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.TEST, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.SIT, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PRE, 'https://pre.ac.alipay.com/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PROD, 'https://checkout.antom.com');
518
+ var baseUrl = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ELEMENT_ENVIRONMENT.DEV, 'http://dev.page.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.TEST, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.SIT, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PRE, 'https://pre.ac.alipay.com/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.SANDBOX, 'https://checkout.antom.com'), ELEMENT_ENVIRONMENT.PROD, 'https://checkout.antom.com');
519
519
  var _env = (env === null || env === void 0 ? void 0 : env.toLocaleUpperCase()) || ELEMENT_ENVIRONMENT.DEV;
520
520
  var payment = "".concat(baseUrl[_env], "/elements/").concat(version, "/pages/element_payment/index.html");
521
521
  try {
@@ -682,6 +682,7 @@ export var ElementComponent = /*#__PURE__*/function () {
682
682
  this.mountOptions[ElementPaymentMethod.AUTH_ELEMENT] = _mountParams;
683
683
  var link = renderOptions === null || renderOptions === void 0 || (_renderOptions$elemen = renderOptions.elementProps) === null || _renderOptions$elemen === void 0 ? void 0 : _renderOptions$elemen.elementLink;
684
684
  var params = window.location.href.split('?')[1];
685
+ params = "instanceId=".concat(uuid(), "&") + params;
685
686
  var url = link.indexOf('?') === -1 ? "".concat(link, "?").concat(params) : link;
686
687
  this.authBase.mount({
687
688
  selector: sdkSelector,
@@ -1,4 +1,4 @@
1
- import { ConnectErrorCode, ElementPaymentMethod, ActionForm } from '../../../types';
1
+ import { ActionForm, ConnectErrorCode, ElementPaymentMethod } from '../../../types';
2
2
  export declare enum ThemeType {
3
3
  NostalgicGray = "nostalgicGray",
4
4
  Default = "default",
@@ -20,7 +20,8 @@ export declare enum ELEMENT_ENVIRONMENT {
20
20
  TEST = "TEST",
21
21
  SIT = "SIT",
22
22
  PRE = "PRE",
23
- PROD = "PROD"
23
+ PROD = "PROD",
24
+ SANDBOX = "SANDBOX"
24
25
  }
25
26
  export type ELEMENT_ENVIRONMENT_TYPE = keyof typeof ELEMENT_ENVIRONMENT | (typeof ELEMENT_ENVIRONMENT)[keyof typeof ELEMENT_ENVIRONMENT];
26
27
  export interface IElementOptions {
@@ -23,6 +23,7 @@ export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
23
23
  ELEMENT_ENVIRONMENT["SIT"] = "SIT";
24
24
  ELEMENT_ENVIRONMENT["PRE"] = "PRE";
25
25
  ELEMENT_ENVIRONMENT["PROD"] = "PROD";
26
+ ELEMENT_ENVIRONMENT["SANDBOX"] = "SANDBOX";
26
27
  return ELEMENT_ENVIRONMENT;
27
28
  }({});
28
29
  // export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
@@ -37,6 +37,7 @@ export declare class EventCenter implements Service {
37
37
  * @param e - The message event.
38
38
  */
39
39
  private handleAppMessage;
40
+ private checkEventCompliant;
40
41
  /**
41
42
  * Processes the application message and emits the associated event.
42
43
  * @param data - Parsed EventPayload from the app.
@@ -109,7 +109,7 @@ export var EventCenter = /*#__PURE__*/function () {
109
109
  var isJson = isJsonString(e.data);
110
110
  if (isJson) {
111
111
  var eventPayload = JSON.parse(e.data);
112
- if (eventPayload.name !== MessageName.APP_TO_SDK || eventPayload.instanceId !== this.instanceId) {
112
+ if (!this.checkEventCompliant(eventPayload)) {
113
113
  return;
114
114
  }
115
115
  this._handleAppMessage(eventPayload);
@@ -117,6 +117,26 @@ export var EventCenter = /*#__PURE__*/function () {
117
117
  console.error(ERRORMESSAGE.NOT_JSON_FORMAT);
118
118
  }
119
119
  }
120
+ }, {
121
+ key: "checkEventCompliant",
122
+ value: function checkEventCompliant(eventPayload) {
123
+ // connect element场景下,多子iframes共用AntomCore中生成的instanceId,此时将发送事件方instanceId与iframes中instanceId做比较看是否在其中
124
+ // 非connect场景下,直接将发送事件方instanceId与AntomCore的instanceId做比较
125
+ if (eventPayload.name !== MessageName.APP_TO_SDK) {
126
+ return false;
127
+ }
128
+ var iframesInstanceIds = this.iframes.map(function (iframe) {
129
+ var _iframe$ref;
130
+ if (!new URL((_iframe$ref = iframe.ref) === null || _iframe$ref === void 0 ? void 0 : _iframe$ref.src)) {
131
+ return;
132
+ }
133
+ return new URL(iframe.ref.src).searchParams.get('instanceId');
134
+ }).filter(Boolean);
135
+ if (eventPayload.instanceId !== this.instanceId && !iframesInstanceIds.includes(eventPayload.instanceId)) {
136
+ return false;
137
+ }
138
+ return true;
139
+ }
120
140
 
121
141
  /**
122
142
  * Processes the application message and emits the associated event.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1733198624-dev.1",
3
+ "version": "0.0.1733711101-dev.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",