forked from cerc-io/laconic-wallet-web
Return message data to event origin
This commit is contained in:
parent
392d961ab7
commit
b5005b8e47
@ -3,7 +3,7 @@ import React, { useEffect } from 'react'
|
|||||||
export const WalletEmbed = () => {
|
export const WalletEmbed = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleMessage = (event: MessageEvent) => {
|
const handleMessage = (event: MessageEvent) => {
|
||||||
if (event.origin !== 'http://localhost:3000') return;
|
// Not checking for event origin as only account addresses are returned
|
||||||
|
|
||||||
if (event.data.type === 'REQUEST_WALLET_ACCOUNTS') {
|
if (event.data.type === 'REQUEST_WALLET_ACCOUNTS') {
|
||||||
try {
|
try {
|
||||||
@ -35,14 +35,14 @@ export const WalletEmbed = () => {
|
|||||||
type: 'WALLET_ACCOUNTS_DATA',
|
type: 'WALLET_ACCOUNTS_DATA',
|
||||||
data: addresses,
|
data: addresses,
|
||||||
},
|
},
|
||||||
'http://localhost:3000'
|
event.origin
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
(event.source as Window)?.postMessage({
|
(event.source as Window)?.postMessage({
|
||||||
type: 'ERROR',
|
type: 'ERROR',
|
||||||
message: 'Error accessing wallet accounts data'
|
message: 'Error accessing wallet accounts data'
|
||||||
}, 'http://localhost:3000');
|
}, event.origin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user