@@ -13,8 +13,25 @@ import type { DevBrowser } from './devBrowser';
13
13
import { createDevBrowser } from './devBrowser' ;
14
14
import { SessionCookiePoller } from './SessionCookiePoller' ;
15
15
16
- // TODO: make AuthCookieService singleton since it handles updating cookies using a poller
16
+ // TODO(@dimkl) : make AuthCookieService singleton since it handles updating cookies using a poller
17
17
// and we need to avoid updating them concurrently.
18
+ /**
19
+ * The AuthCookieService class is a service responsible to handle
20
+ * all operations and helpers required in a standard browser context
21
+ * based on the cookies to remove the dependency between cookies
22
+ * and auth from the Clerk instance.
23
+ * This service is responsible to:
24
+ * - refresh the session cookie using a poller
25
+ * - refresh the session cookie on tab visibility change
26
+ * - update the related cookies listening to the `token:update` event
27
+ * - initialize auth related cookies for development instances (eg __client_uat, __clerk_db_jwt)
28
+ * - cookie setup for production / development instances
29
+ * It also provides the following helpers:
30
+ * - isSignedOut(): check if the current user is signed-out using cookies
31
+ * - urlWithAuth(): decorates url with auth related info (eg dev browser jwt)
32
+ * - handleUnauthenticatedDevBrowser(): resets dev browser in case of invalid dev browser
33
+ * - setEnvironment(): update cookies (eg client_uat) related to environment
34
+ */
18
35
export class AuthCookieService {
19
36
private environment : EnvironmentResource | undefined ;
20
37
private poller : SessionCookiePoller | null = null ;
@@ -40,6 +57,7 @@ export class AuthCookieService {
40
57
} ) ;
41
58
}
42
59
60
+ // TODO(@dimkl): Replace this method call with an event listener to decouple Clerk with setEnvironment
43
61
public setEnvironment ( environment : EnvironmentResource ) {
44
62
this . environment = environment ;
45
63
this . setClientUatCookieForDevelopmentInstances ( ) ;
0 commit comments