+1
-1
| export * from "./legacy-version.js"; | ||
| export declare function expose(apiHandlers: Record<string, Function>, originVertify?: (origin: string) => boolean): () => void; | ||
| export declare function expose(apiHandlers: Record<string, any>, originVertify?: (origin: string) => boolean): () => void; | ||
| export declare function callMethodResponseListener(e: any): void; | ||
@@ -4,0 +4,0 @@ export declare function excute<T>(frameID: string, actionName: string, ...params: any): Promise<T>; |
+6
-9
@@ -5,3 +5,3 @@ export * from "./legacy-version.js"; | ||
| try { | ||
| window.parent.postMessage(JSON.stringify(resp), window.parent.location.origin); | ||
| window.parent.postMessage(JSON.stringify(resp), "*"); | ||
| } | ||
@@ -44,3 +44,3 @@ catch (e) { | ||
| return false; | ||
| const iframes = document.querySelectorAll("iframe"); | ||
| const iframes = Array.from(document.querySelectorAll("iframe")); | ||
| const source = e.origin; | ||
@@ -57,4 +57,6 @@ for (const f of iframes) { | ||
| function listener(e) { | ||
| if (!e || !e.origin || e.origin !== window.parent.location.origin) | ||
| if (!e || !e.origin) | ||
| return; | ||
| if (originVertify && !originVertify(e.origin)) | ||
| return; | ||
| let data = null; | ||
@@ -70,6 +72,2 @@ try { | ||
| const id = data.id; | ||
| if (originVertify && !originVertify(e.origin)) { | ||
| response(id, null, "illegal origin"); | ||
| return; | ||
| } | ||
| const handler = apiHandlers[data.actionName]; | ||
@@ -135,4 +133,3 @@ if (!handler) { | ||
| try { | ||
| const target = window.parent.location.origin; | ||
| window.parent.postMessage(JSON.stringify(event), target); | ||
| window.parent.postMessage(JSON.stringify(event), "*"); | ||
| } | ||
@@ -139,0 +136,0 @@ catch (error) { |
+6
-11
@@ -6,3 +6,3 @@ export * from "./legacy-version.js"; | ||
| try { | ||
| window.parent.postMessage(JSON.stringify(resp), window.parent.location.origin); | ||
| window.parent.postMessage(JSON.stringify(resp), "*"); | ||
| } catch (e) { | ||
@@ -66,3 +66,3 @@ return; | ||
| if (!e || !e.origin) return false; | ||
| const iframes = document.querySelectorAll("iframe"); | ||
| const iframes = Array.from(document.querySelectorAll("iframe")); | ||
| const source = e.origin; | ||
@@ -77,5 +77,6 @@ for (const f of iframes) { | ||
| // 暴露API接口供业务系统调用 | ||
| export function expose(apiHandlers: Record<string, Function>, originVertify?: (origin: string) => boolean) { | ||
| export function expose(apiHandlers: Record<string, any>, originVertify?: (origin: string) => boolean) { | ||
| function listener(e: any) { | ||
| if (!e || !e.origin || e.origin !== window.parent.location.origin) return; | ||
| if (!e || !e.origin) return; | ||
| if (originVertify && !originVertify(e.origin)) return; | ||
| let data: IframeRequest | null = null; | ||
@@ -89,7 +90,2 @@ try { | ||
| const id = data.id; | ||
| if (originVertify && !originVertify(e.origin)) { | ||
| response(id, null, "illegal origin"); | ||
| return; | ||
| } | ||
| const handler = apiHandlers[data.actionName]; | ||
@@ -156,4 +152,3 @@ if (!handler) { | ||
| try { | ||
| const target = window.parent.location.origin; | ||
| window.parent.postMessage(JSON.stringify(event), target); | ||
| window.parent.postMessage(JSON.stringify(event), "*"); | ||
| } catch (error) { | ||
@@ -160,0 +155,0 @@ return; |
+1
-1
| { | ||
| "name": "ifapi", | ||
| "version": "3.0.0", | ||
| "version": "3.0.2", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
15636
-2.23%390
-1.76%