File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ export async function signRequest(
7878}
7979
8080const ONE_DAY = 24 * 60 * 60 * 1000 ;
81+ const COOKIE_NAME_AUTH = 'atomic_session' ;
8182
8283const setCookieExpires = (
8384 name : string ,
@@ -97,10 +98,14 @@ const setCookieExpires = (
9798/** Sets a cookie for the current Agent, signing the Authentication. It expires after some default time. */
9899export const setCookieAuthentication = ( store : Store , agent : Agent ) => {
99100 createAuthentication ( store . getServerUrl ( ) , agent ) . then ( auth => {
100- setCookieExpires ( 'atomic_session' , btoa ( JSON . stringify ( auth ) ) , store ) ;
101+ setCookieExpires ( COOKIE_NAME_AUTH , btoa ( JSON . stringify ( auth ) ) , store ) ;
101102 } ) ;
102103} ;
103104
105+ export const removeCookieAuthentication = ( ) => {
106+ document . cookie = `${ COOKIE_NAME_AUTH } =;Max-Age=-99999999` ;
107+ } ;
108+
104109/** Returns false if the auth cookie is not set / expired */
105110export const checkAuthenticationCookie = ( ) : boolean => {
106111 const matches = document . cookie . match (
Original file line number Diff line number Diff line change 99 parseCommit ,
1010 parseJsonADArray ,
1111 parseJsonADResource ,
12+ removeCookieAuthentication ,
1213 Resource ,
1314 serializeDeterministically ,
1415 setCookieAuthentication ,
@@ -67,6 +68,8 @@ export async function fetchResource(
6768 } else {
6869 await signRequest ( subject , agent , requestHeaders ) ;
6970 }
71+ } else {
72+ removeCookieAuthentication ( ) ;
7073 }
7174
7275 let url = subject ;
You can’t perform that action at this time.
0 commit comments