File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ export async function signRequest(
7777}
7878
7979const ONE_DAY = 24 * 60 * 60 * 1000 ;
80+ const COOKIE_NAME_AUTH = 'atomic_session' ;
8081
8182const setCookieExpires = (
8283 name : string ,
@@ -94,12 +95,16 @@ const setCookieExpires = (
9495} ;
9596
9697/** Sets a cookie for the current Agent, signing the Authentication. It expires after some default time. */
97- export const setCookieAuthentication = ( serverUrl : string , agent : Agent ) => {
98- createAuthentication ( serverUrl , agent ) . then ( auth => {
99- setCookieExpires ( 'atomic_session' , btoa ( JSON . stringify ( auth ) ) , serverUrl ) ;
98+ export const setCookieAuthentication = ( store : Store , agent : Agent ) => {
99+ createAuthentication ( store . getServerUrl ( ) , agent ) . then ( auth => {
100+ setCookieExpires ( COOKIE_NAME_AUTH , btoa ( JSON . stringify ( auth ) ) , store ) ;
100101 } ) ;
101102} ;
102103
104+ export const removeCookieAuthentication = ( ) => {
105+ document . cookie = `${ COOKIE_NAME_AUTH } =;Max-Age=-99999999` ;
106+ } ;
107+
103108/** Returns false if the auth cookie is not set / expired */
104109export const checkAuthenticationCookie = ( ) : boolean => {
105110 const matches = document . cookie . match (
Original file line number Diff line number Diff line change 99 ErrorType ,
1010 JSONADParser ,
1111 parseCommit ,
12+ parseJsonADArray ,
13+ parseJsonADResource ,
14+ removeCookieAuthentication ,
1215 Resource ,
1316 serializeDeterministically ,
1417 setCookieAuthentication ,
You can’t perform that action at this time.
0 commit comments