@@ -13,8 +13,25 @@ import type { DevBrowser } from './devBrowser';
1313import { createDevBrowser } from './devBrowser' ;
1414import { SessionCookiePoller } from './SessionCookiePoller' ;
1515
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
1717// 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+ */
1835export class AuthCookieService {
1936 private environment : EnvironmentResource | undefined ;
2037 private poller : SessionCookiePoller | null = null ;
@@ -40,6 +57,7 @@ export class AuthCookieService {
4057 } ) ;
4158 }
4259
60+ // TODO(@dimkl): Replace this method call with an event listener to decouple Clerk with setEnvironment
4361 public setEnvironment ( environment : EnvironmentResource ) {
4462 this . environment = environment ;
4563 this . setClientUatCookieForDevelopmentInstances ( ) ;
0 commit comments