Compare commits
6 Commits
2e2754a41f
...
252bba2cdb
Author | SHA1 | Date | |
---|---|---|---|
![]() |
252bba2cdb | ||
![]() |
108c27fc48 | ||
![]() |
23a75b68c6 | ||
![]() |
e4b9b0a56d | ||
![]() |
9e0f3d3b73 | ||
![]() |
97e86308ce |
@ -12,9 +12,6 @@ function Iframe({ showIframe = false }: IframeProps) {
|
||||
if (iframeRef.current) {
|
||||
IframeReference.setIframe(iframeRef.current);
|
||||
}
|
||||
return () => {
|
||||
IframeReference.setIframe(null);
|
||||
};
|
||||
}, [iframeRef.current]);
|
||||
|
||||
return (
|
||||
|
@ -5,6 +5,11 @@ export default class IframeReference {
|
||||
private constructor() { }
|
||||
|
||||
public static setTargetOrigin(targetOrigin: string): void {
|
||||
if (this.targetOrigin) {
|
||||
console.debug("targetOrigin is already set");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
new URL(targetOrigin);
|
||||
this.targetOrigin = targetOrigin;
|
||||
|
@ -809,17 +809,10 @@ export default class MessageBus {
|
||||
}
|
||||
|
||||
try {
|
||||
const iframe = IframeReference.getIframe();
|
||||
|
||||
if (event.source !== iframe.contentWindow) {
|
||||
console.error('[MessageBus] handleMessage: source not match');
|
||||
return;
|
||||
}
|
||||
|
||||
const targetOrigin = IframeReference.getTargetOrigin();
|
||||
|
||||
if (event.origin !== targetOrigin) {
|
||||
throw new Error('origin not match');
|
||||
throw new Error(`origin don't match: expected ${targetOrigin}, got ${event.origin} with type ${event.data.type}`);
|
||||
}
|
||||
|
||||
if (!event.data || typeof event.data !== 'object') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user