File tree Expand file tree Collapse file tree 4 files changed +21
-4
lines changed
Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export default async function main() {
1515 setup_blue_death_screen ( ) ,
1616 setup_history ( ) ,
1717 setup_polyfill ( ) ,
18+ setup_iframe ( ) ,
1819 ] ) ;
1920
2021 await Promise . all ( [ // procedure with dependency on config
@@ -106,3 +107,22 @@ async function setup_polyfill() {
106107 await loadJS ( import . meta. url , "../lib/polyfill.js" ) ;
107108 }
108109}
110+
111+ // In safari and duck duck go browser, cross domain iframe cannot inject cookies,
112+ // see https://support.apple.com/en-au/guide/safari/sfri40732/mac
113+ // hopefully one day, they provide support for partitioned cookie and we can remove this code
114+ // but until that happens we had to find a way to inject authorisation within ../lib/ajax.js
115+ async function setup_iframe ( ) {
116+ if ( window . self === window . top ) return ;
117+
118+ window . addEventListener ( "pagechange" , async ( ) => {
119+ if ( location . hash === "" ) return ; // happy path
120+
121+ const token = new URLSearchParams ( location . hash . replace ( new RegExp ( "^#" ) , "?" ) ) . get ( "bearer" ) ;
122+ if ( token ) window . BEARER_TOKEN = token ;
123+
124+ if ( location . pathname === toHref ( "/logout" ) ) {
125+ delete window . BEARER_TOKEN ;
126+ }
127+ } ) ;
128+ }
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ export default async function(render) {
199199 rxjs . tap ( ( ) => toggleLoader ( true ) ) ,
200200 rxjs . mergeMap ( ( ) => createSession ( formData ) ) ,
201201 rxjs . tap ( ( { responseJSON, responseHeaders } ) => {
202- if ( responseHeaders . bearer ) window . BEARER_TOKEN = responseHeaders . bearer ; // fix https://support.apple.com/en-au/guide/safari/sfri40732/mac
202+ if ( responseHeaders . bearer ) window . BEARER_TOKEN = responseHeaders . bearer ; // see ctrl_boot_frontoffice.js -> setup_iframe
203203 let redirectURL = toHref ( "/files/" ) ;
204204 const GET = getURLParams ( ) ;
205205 if ( GET [ "next" ] ) redirectURL = GET [ "next" ] ;
Original file line number Diff line number Diff line change @@ -24,8 +24,6 @@ export default function(render) {
2424 }
2525
2626 // feature2: redirect user where it makes most sense
27- const token = new URLSearchParams ( location . hash . replace ( new RegExp ( "^#" ) , "?" ) ) . get ( "bearer" ) ;
28- if ( token ) window . BEARER_TOKEN = token ;
2927 effect ( getSession ( ) . pipe (
3028 rxjs . catchError ( ( err ) => {
3129 if ( err instanceof AjaxError && err . err ( ) . status === 401 ) {
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ export default function(render) {
1313 effect ( deleteSession ( ) . pipe (
1414 rxjs . mergeMap ( setup_config ) ,
1515 rxjs . tap ( ( ) => {
16- delete window . BEARER_TOKEN ;
1716 window . CONFIG [ "logout" ] ? location . href = window . CONFIG [ "logout" ] : navigate ( toHref ( "/" ) )
1817 } ) ,
1918 rxjs . catchError ( ctrlError ( render ) ) ,
You can’t perform that action at this time.
0 commit comments