-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from shayan-deriv/shayan/feq-2228/add-iframe-t…
…o-recieve-messages-from-deriv-app feat: added iframe with eventListener for coming messages
- Loading branch information
Showing
5 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Deriv</title> | ||
<meta charset="utf-8" /> | ||
<meta name="referrer" content="origin" /> | ||
<script> | ||
window.addEventListener('message', function (message) { | ||
var allowed_origins = [ | ||
'https://deriv.app', | ||
'https://staging.deriv.app', | ||
'https://app.deriv.com', | ||
'https://app.deriv.me', | ||
'https://app.deriv.be', | ||
'https://staging-app.deriv.com', | ||
'https://staging-app.deriv.me', | ||
'https://staging-app.deriv.be', | ||
'https://test-app.deriv.com', | ||
]; | ||
|
||
if (allowed_origins.includes(message.origin)) { | ||
switch (message.data.key) { | ||
case 'active_loginid': { | ||
if (localStorage.getItem(message.data.key) !== message.data.value) { | ||
localStorage.setItem(message.data.key, message.data.value); | ||
} | ||
break; | ||
} | ||
case 'client.accounts': { | ||
if (localStorage.getItem(message.data.key) !== message.data.value) { | ||
localStorage.setItem(message.data.key, message.data.value); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
}); | ||
</script> | ||
</head> | ||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const DerivIframe = () => ( | ||
<iframe | ||
id='localstorage-sync' | ||
sandbox='allow-scripts' | ||
src='../../../../localstorage-sync.html' | ||
style={{ display: 'none', visibility: 'hidden' }} | ||
/> | ||
); | ||
|
||
export default DerivIframe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as DerivIframe } from './DerivIframe'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters