@alipay/ams-checkout 0.0.1733198624-dev.1 → 0.0.1733198624-dev.2
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.
@@ -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 (
|
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.
|