Compare commits

..

6 Commits

Author SHA1 Message Date
Sosthene
252bba2cdb Download the backup json as a file 2025-07-16 12:57:55 +02:00
Sosthene
108c27fc48 Add import profile step in login 2025-07-16 12:57:55 +02:00
Sosthene
23a75b68c6 Add create backup button in my account 2025-07-16 12:57:55 +02:00
Sosthene
e4b9b0a56d Add exportBackupFile in MessageBus 2025-07-16 12:57:55 +02:00
Sosthene
9e0f3d3b73 Add StepImportProfile component 2025-07-16 12:57:55 +02:00
Sosthene
97e86308ce [bug] make MessageBus more reliable 2025-07-16 12:56:02 +02:00
3 changed files with 6 additions and 11 deletions

View File

@ -12,9 +12,6 @@ function Iframe({ showIframe = false }: IframeProps) {
if (iframeRef.current) { if (iframeRef.current) {
IframeReference.setIframe(iframeRef.current); IframeReference.setIframe(iframeRef.current);
} }
return () => {
IframeReference.setIframe(null);
};
}, [iframeRef.current]); }, [iframeRef.current]);
return ( return (

View File

@ -5,6 +5,11 @@ export default class IframeReference {
private constructor() { } private constructor() { }
public static setTargetOrigin(targetOrigin: string): void { public static setTargetOrigin(targetOrigin: string): void {
if (this.targetOrigin) {
console.debug("targetOrigin is already set");
return;
}
try { try {
new URL(targetOrigin); new URL(targetOrigin);
this.targetOrigin = targetOrigin; this.targetOrigin = targetOrigin;

View File

@ -809,17 +809,10 @@ export default class MessageBus {
} }
try { try {
const iframe = IframeReference.getIframe();
if (event.source !== iframe.contentWindow) {
console.error('[MessageBus] handleMessage: source not match');
return;
}
const targetOrigin = IframeReference.getTargetOrigin(); const targetOrigin = IframeReference.getTargetOrigin();
if (event.origin !== targetOrigin) { 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') { if (!event.data || typeof event.data !== 'object') {