File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export const polyfillWindow = () => {
1717 return this . href . replace ( / ^ [ ^ # ] + / , '' )
1818 } ,
1919 set hash ( value ) {
20- this . href = this . href . replace ( / # .* / , value )
20+ this . href = this . href . replace ( / # .* | $ / , value )
2121 }
2222 }
2323 } )
Original file line number Diff line number Diff line change @@ -29,20 +29,26 @@ export async function currentSession(
2929 storage : AsyncStorage = defaultStorage ( )
3030) : Promise < ?webIdOidcSession > {
3131 try {
32+ // Obtain the Relying Party
3233 const rp = await getStoredRp ( storage )
3334 if ( ! rp ) {
3435 return null
3536 }
37+
38+ // Obtain and clear the OIDC URL fragment
3639 const url = currentUrl ( )
3740 if ( ! / # ( .* & ) ? a c c e s s _ t o k e n = / . test ( url ) ) {
3841 return null
3942 }
43+ window . location . hash = ''
44+ await restoreAppHashFragment ( storage )
45+
46+ // Obtain a session from the Relying Party
4047 const storeData = await getData ( storage )
4148 const session = await rp . validateResponse ( url , storeData )
4249 if ( ! session ) {
4350 return null
4451 }
45- await restoreAppHashFragment ( storage )
4652 return {
4753 ...session ,
4854 webId : session . idClaims . sub ,
@@ -161,9 +167,8 @@ async function saveAppHashFragment(store: AsyncStorage): Promise<void> {
161167}
162168
163169async function restoreAppHashFragment(store: AsyncStorage): Promise< void > {
164- await updateStorage ( store , data => {
165- window . location . hash = data . appHashFragment
166- delete data . appHashFragment
170+ await updateStorage ( store , ( { appHashFragment = '' , ...data } ) => {
171+ window . location . hash = appHashFragment
167172 return data
168173 } )
169174}
You can’t perform that action at this time.
0 commit comments