Skip to content

Commit fc79399

Browse files
chore: backup
1 parent 42aa28a commit fc79399

File tree

5 files changed

+36
-24
lines changed

5 files changed

+36
-24
lines changed

packages/core/src/App/AppContent.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import Header from './Containers/Layout/header';
3232
import AppModals from './Containers/Modals';
3333
import Routes from './Containers/Routes/routes.jsx';
3434
import Devtools from './Devtools';
35+
import { FrontChannelIframe } from 'Modules/FrontChannel';
3536

3637
const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }) => {
3738
const store = useStore();
@@ -184,6 +185,7 @@ const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }
184185
<ErrorBoundary root_store={store}>
185186
<AppModals />
186187
</ErrorBoundary>
188+
<FrontChannelIframe />
187189
{!isOAuth2Enabled && <P2PIFrame />}
188190
<AppToastMessages />
189191
<Devtools />
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const FrontChannelIframe = () => {
2+
return (
3+
<iframe
4+
src={`${window.location.origin}/front-channel.html`}
5+
style={{ display: 'none', visibility: 'hidden' }}
6+
/>
7+
);
8+
};
9+
10+
export default FrontChannelIframe;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import FrontChannelPage from './FrontChannelPage';
2+
import FrontChannelIframe from './FrontChannelIFrame';
23

3-
export default FrontChannelPage;
4+
export { FrontChannelPage, FrontChannelIframe };

packages/core/src/root_files/front-channel.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="utf-8" />
66
<meta name="referrer" content="origin" />
77
<script>
8-
localStorage.removeItem('client.accounts');
8+
if (window.parent.location.origin !== window.location.origin) localStorage.removeItem('client.accounts');
99
</script>
1010
</head>
1111

packages/hooks/src/useSilentLoginAndLogout.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ const useSilentLoginAndLogout = ({
2222
isOAuth2Enabled: boolean;
2323
oAuthLogout: () => Promise<void>;
2424
}) => {
25-
const loggedState = Cookies.get('logged_state');
26-
2725
const clientAccounts = JSON.parse(localStorage.getItem('client.accounts') || '{}');
2826
const isClientAccountsPopulated = Object.keys(clientAccounts).length > 0;
2927
const isSilentLoginExcluded =
@@ -32,37 +30,38 @@ const useSilentLoginAndLogout = ({
3230
window.location.pathname.includes('endpoint');
3331

3432
useEffect(() => {
35-
window.addEventListener(
36-
'message',
37-
message => {
38-
if (message.data?.event === 'login_required') {
39-
console.log('OIDC: prompt none says we are logged out');
40-
if (isClientAccountsPopulated) {
41-
oAuthLogout();
42-
}
43-
} else if (message.data?.event === 'sso_required') {
44-
console.log('OIDC: we need to SSO NOW');
45-
// requestOidcAuthentication({
46-
// redirectCallbackUri: `${window.location.origin}/callback`,
47-
// });
48-
}
49-
},
50-
false
51-
);
5233
// NOTE: Remove this logic once social signup is intergated with OIDC
5334
const params = new URLSearchParams(window.location.search);
5435
const isUsingLegacyFlow = params.has('token1') && params.has('acct1');
55-
if (isUsingLegacyFlow && loggedState === 'false' && isOAuth2Enabled) {
36+
if (isUsingLegacyFlow && isOAuth2Enabled) {
5637
return;
5738
}
5839

5940
if (isOAuth2Enabled && !isUsingLegacyFlow && !isClientAccountsPopulated && !isSilentLoginExcluded) {
41+
window.addEventListener(
42+
'message',
43+
message => {
44+
if (message.data?.event === 'login_required') {
45+
console.log('OIDC: prompt none says we are logged out');
46+
if (isClientAccountsPopulated) {
47+
oAuthLogout();
48+
}
49+
} else if (message.data?.event === 'sso_required' || message.data?.event === 'login_successful') {
50+
console.log('OIDC: we need to SSO NOW', message.data?.event);
51+
// requestOidcAuthentication({
52+
// redirectCallbackUri: `${window.location.origin}/callback`,
53+
// });
54+
}
55+
},
56+
false
57+
);
58+
6059
console.log('OIDC: checking if we need SSO...');
6160
const userManager = new UserManager({
6261
authority: 'https://qa20.deriv.dev',
6362
client_id: '1000005',
64-
redirect_uri: 'https://localhost:8443/callback',
65-
silent_redirect_uri: 'https://localhost:8443/silent-callback',
63+
redirect_uri: 'https://qa110.deriv.dev/callback',
64+
silent_redirect_uri: 'https://qa110.deriv.dev/silent-callback',
6665
response_type: 'code',
6766
scope: 'openid',
6867
stateStore: new WebStorageStateStore({ store: window.localStorage }),

0 commit comments

Comments
 (0)