File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 33 getTimestampNow ,
44 HeadersObject ,
55 signToBase64 ,
6+ Store ,
67} from './index.js' ;
78
89/** Returns a JSON-AD resource of an Authentication */
@@ -91,10 +92,13 @@ const setCookieExpires = (
9192 document . cookie = cookieString ;
9293} ;
9394
95+ const COOKIE_NAME_AUTH = 'atomic_session' ;
96+
9497/** Sets a cookie for the current Agent, signing the Authentication. It expires after some default time. */
95- export const setCookieAuthentication = ( serverUrl : string , agent : Agent ) => {
96- createAuthentication ( serverUrl , agent ) . then ( auth => {
97- setCookieExpires ( 'atomic_session' , btoa ( JSON . stringify ( auth ) ) , serverUrl ) ;
98+ export const setCookieAuthentication = ( store : Store , agent : Agent ) => {
99+ const serverURL = store . getServerUrl ( ) ;
100+ createAuthentication ( serverURL , agent ) . then ( auth => {
101+ setCookieExpires ( COOKIE_NAME_AUTH , btoa ( JSON . stringify ( auth ) ) , serverURL ) ;
98102 } ) ;
99103} ;
100104
Original file line number Diff line number Diff line change 1- import { setCookieAuthentication } from './authentication.js' ;
1+ import {
2+ removeCookieAuthentication ,
3+ setCookieAuthentication ,
4+ } from './authentication.js' ;
25import { EventManager } from './EventManager.js' ;
36import {
47 Agent ,
@@ -504,6 +507,8 @@ export class Store {
504507 this . fetchResourceFromServer ( r . getSubject ( ) ) ;
505508 }
506509 } ) ;
510+ } else {
511+ removeCookieAuthentication ( ) ;
507512 }
508513
509514 this . eventManager . emit ( StoreEvents . AgentChanged , agent ) ;
You can’t perform that action at this time.
0 commit comments