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(
78
78
}
79
79
80
80
const ONE_DAY = 24 * 60 * 60 * 1000 ;
81
+ const COOKIE_NAME_AUTH = 'atomic_session' ;
81
82
82
83
const setCookieExpires = (
83
84
name : string ,
@@ -97,10 +98,14 @@ const setCookieExpires = (
97
98
/** Sets a cookie for the current Agent, signing the Authentication. It expires after some default time. */
98
99
export const setCookieAuthentication = ( store : Store , agent : Agent ) => {
99
100
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 ) ;
101
102
} ) ;
102
103
} ;
103
104
105
+ export const removeCookieAuthentication = ( ) => {
106
+ document . cookie = `${ COOKIE_NAME_AUTH } =;Max-Age=-99999999` ;
107
+ } ;
108
+
104
109
/** Returns false if the auth cookie is not set / expired */
105
110
export const checkAuthenticationCookie = ( ) : boolean => {
106
111
const matches = document . cookie . match (
Original file line number Diff line number Diff line change 9
9
parseCommit ,
10
10
parseJsonADArray ,
11
11
parseJsonADResource ,
12
+ removeCookieAuthentication ,
12
13
Resource ,
13
14
serializeDeterministically ,
14
15
setCookieAuthentication ,
@@ -67,6 +68,8 @@ export async function fetchResource(
67
68
} else {
68
69
await signRequest ( subject , agent , requestHeaders ) ;
69
70
}
71
+ } else {
72
+ removeCookieAuthentication ( ) ;
70
73
}
71
74
72
75
let url = subject ;
You can’t perform that action at this time.
0 commit comments