mailsentry-auth 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -516,28 +516,26 @@ type AuthEvent = {
516
516
  sourcePageType?: PageType;
517
517
  };
518
518
  declare enum PageType {
519
- LOGIN = "login",
519
+ LOGIN = "/login",
520
520
  DASHBOARD = "dashboard",
521
521
  HOME = "/"
522
522
  }
523
523
  declare enum NavigationAction {
524
524
  NONE = "none",
525
- REDIRECT = "redirect",
526
- MODAL = "modal",
527
- CURRENT = "current"
525
+ RELOAD = "reload"
528
526
  }
529
527
  declare const PageTypePatterns: {
530
- readonly login: PageType.LOGIN;
528
+ readonly "/login": PageType.LOGIN;
531
529
  readonly dashboard: PageType.DASHBOARD;
530
+ readonly "/": PageType.HOME;
532
531
  };
533
532
  declare const CrossTabBehaviorConfig: {
534
- readonly login: {
533
+ readonly "/login": {
535
534
  readonly "auth.logged_in": {
536
- readonly action: NavigationAction.REDIRECT;
537
- readonly target: PageType.DASHBOARD;
535
+ readonly action: NavigationAction.RELOAD;
538
536
  };
539
537
  readonly "auth.logged_out": {
540
- readonly action: NavigationAction.NONE;
538
+ readonly action: NavigationAction.RELOAD;
541
539
  };
542
540
  readonly "auth.email_verified": {
543
541
  readonly action: NavigationAction.NONE;
@@ -548,16 +546,16 @@ declare const CrossTabBehaviorConfig: {
548
546
  };
549
547
  readonly dashboard: {
550
548
  readonly "auth.logged_in": {
551
- readonly action: NavigationAction.CURRENT;
549
+ readonly action: NavigationAction.RELOAD;
552
550
  };
553
551
  readonly "auth.logged_out": {
554
- readonly action: NavigationAction.CURRENT;
552
+ readonly action: NavigationAction.RELOAD;
555
553
  };
556
554
  readonly "auth.email_verified": {
557
- readonly action: NavigationAction.CURRENT;
555
+ readonly action: NavigationAction.RELOAD;
558
556
  };
559
557
  readonly "auth.signin_required_modal": {
560
- readonly action: NavigationAction.CURRENT;
558
+ readonly action: NavigationAction.NONE;
561
559
  };
562
560
  };
563
561
  readonly "/": {
@@ -628,15 +626,18 @@ declare const getPasswordField: (isLogin: boolean, disabled?: boolean, options?:
628
626
  declare const getVerificationField: (codeLength?: number, options?: InputProps) => BaseFormField;
629
627
 
630
628
  /**
631
- * Middleware configuration constants for subdomain-based routing
629
+ * Middleware configuration constants for routing and protection
632
630
  */
633
631
  declare class MiddlewareConfig {
634
- static readonly SUBDOMAINS: {
635
- readonly DASHBOARD: "dashboard";
632
+ static readonly CONSTANTS: {
633
+ readonly LOGIN_PATH: "/login";
634
+ readonly DASHBOARD_SUBDOMAIN: "dashboard";
635
+ readonly PUBLIC_PATH: "/public";
636
+ readonly PUBLIC_API_PATH: "/api/public";
636
637
  };
637
- static readonly ROUTES: {
638
- readonly ROOT: "/";
639
- readonly LOGIN: "/login";
638
+ static readonly PROTECTED_ROUTES: {
639
+ INCLUDE: string[];
640
+ EXCLUDE: ("/login" | "/public" | "/api/public")[];
640
641
  };
641
642
  static readonly ALLOWED_METHODS: readonly ["GET", "HEAD"];
642
643
  static readonly QUERY_PARAMS: {
@@ -656,10 +657,6 @@ declare class MiddlewareConfig {
656
657
  * Get the protocol based on environment
657
658
  */
658
659
  static getProtocol(): string;
659
- /**
660
- * Get the dashboard subdomain URL
661
- */
662
- static getDashboardUrl(path?: string): string;
663
660
  }
664
661
  /**
665
662
  * Middleware matcher patterns
@@ -679,11 +676,11 @@ declare const config: {
679
676
  */
680
677
  declare class CookieUtils {
681
678
  /**
682
- * Get the access token cookie key from environment variables
679
+ * Get the access token cookie key
683
680
  */
684
681
  static getAccessTokenKey(): string;
685
682
  /**
686
- * Get the refresh token cookie key from environment variables
683
+ * Get the refresh token cookie key
687
684
  */
688
685
  static getRefreshTokenKey(): string;
689
686
  /**
@@ -816,22 +813,21 @@ declare class CrossTabBehaviorHandler {
816
813
  * Get the action configuration for current route and event
817
814
  */
818
815
  static getAction(currentPageType: PageType, eventType: AuthEventType): {
819
- readonly action: NavigationAction.REDIRECT;
820
- readonly target: PageType.DASHBOARD;
816
+ readonly action: NavigationAction.RELOAD;
821
817
  } | {
822
- readonly action: NavigationAction.NONE;
818
+ readonly action: NavigationAction.RELOAD;
823
819
  } | {
824
820
  readonly action: NavigationAction.NONE;
825
821
  } | {
826
822
  readonly action: NavigationAction.NONE;
827
823
  } | {
828
- readonly action: NavigationAction.CURRENT;
824
+ readonly action: NavigationAction.RELOAD;
829
825
  } | {
830
- readonly action: NavigationAction.CURRENT;
826
+ readonly action: NavigationAction.RELOAD;
831
827
  } | {
832
- readonly action: NavigationAction.CURRENT;
828
+ readonly action: NavigationAction.RELOAD;
833
829
  } | {
834
- readonly action: NavigationAction.CURRENT;
830
+ readonly action: NavigationAction.NONE;
835
831
  } | {
836
832
  readonly action: NavigationAction.NONE;
837
833
  } | {
@@ -841,11 +837,6 @@ declare class CrossTabBehaviorHandler {
841
837
  } | {
842
838
  readonly action: NavigationAction.NONE;
843
839
  };
844
- /**
845
- * Check if current route requires redirect for given event
846
- * Returns PageType to redirect to, or null if no redirect needed
847
- */
848
- static shouldRedirect(currentPageType: PageType, eventType: AuthEventType): PageType | null;
849
840
  }
850
841
 
851
842
  /**
@@ -853,11 +844,16 @@ declare class CrossTabBehaviorHandler {
853
844
  */
854
845
  declare class UrlUtils {
855
846
  /**
856
- * Extract subdomain from hostname or URL
847
+ * Extract subdomain from hostname
857
848
  * Example: "dashboard.cutly.io" -> "dashboard"
858
- * Example: "dashboard.localhost" -> "dashboard"
859
849
  */
860
- static getSubdomain(url: string): string | null;
850
+ static getSubdomain(hostname: string): string | null;
851
+ /**
852
+ * Get root domain for cookie scope
853
+ * Example: "dashboard.cutly.io" -> ".cutly.io"
854
+ * Example: "cutly.io" -> ".cutly.io"
855
+ */
856
+ static getRootDomain(hostname: string): string | null;
861
857
  /**
862
858
  * Check if URL has auth-related query parameters
863
859
  */
package/dist/index.d.ts CHANGED
@@ -516,28 +516,26 @@ type AuthEvent = {
516
516
  sourcePageType?: PageType;
517
517
  };
518
518
  declare enum PageType {
519
- LOGIN = "login",
519
+ LOGIN = "/login",
520
520
  DASHBOARD = "dashboard",
521
521
  HOME = "/"
522
522
  }
523
523
  declare enum NavigationAction {
524
524
  NONE = "none",
525
- REDIRECT = "redirect",
526
- MODAL = "modal",
527
- CURRENT = "current"
525
+ RELOAD = "reload"
528
526
  }
529
527
  declare const PageTypePatterns: {
530
- readonly login: PageType.LOGIN;
528
+ readonly "/login": PageType.LOGIN;
531
529
  readonly dashboard: PageType.DASHBOARD;
530
+ readonly "/": PageType.HOME;
532
531
  };
533
532
  declare const CrossTabBehaviorConfig: {
534
- readonly login: {
533
+ readonly "/login": {
535
534
  readonly "auth.logged_in": {
536
- readonly action: NavigationAction.REDIRECT;
537
- readonly target: PageType.DASHBOARD;
535
+ readonly action: NavigationAction.RELOAD;
538
536
  };
539
537
  readonly "auth.logged_out": {
540
- readonly action: NavigationAction.NONE;
538
+ readonly action: NavigationAction.RELOAD;
541
539
  };
542
540
  readonly "auth.email_verified": {
543
541
  readonly action: NavigationAction.NONE;
@@ -548,16 +546,16 @@ declare const CrossTabBehaviorConfig: {
548
546
  };
549
547
  readonly dashboard: {
550
548
  readonly "auth.logged_in": {
551
- readonly action: NavigationAction.CURRENT;
549
+ readonly action: NavigationAction.RELOAD;
552
550
  };
553
551
  readonly "auth.logged_out": {
554
- readonly action: NavigationAction.CURRENT;
552
+ readonly action: NavigationAction.RELOAD;
555
553
  };
556
554
  readonly "auth.email_verified": {
557
- readonly action: NavigationAction.CURRENT;
555
+ readonly action: NavigationAction.RELOAD;
558
556
  };
559
557
  readonly "auth.signin_required_modal": {
560
- readonly action: NavigationAction.CURRENT;
558
+ readonly action: NavigationAction.NONE;
561
559
  };
562
560
  };
563
561
  readonly "/": {
@@ -628,15 +626,18 @@ declare const getPasswordField: (isLogin: boolean, disabled?: boolean, options?:
628
626
  declare const getVerificationField: (codeLength?: number, options?: InputProps) => BaseFormField;
629
627
 
630
628
  /**
631
- * Middleware configuration constants for subdomain-based routing
629
+ * Middleware configuration constants for routing and protection
632
630
  */
633
631
  declare class MiddlewareConfig {
634
- static readonly SUBDOMAINS: {
635
- readonly DASHBOARD: "dashboard";
632
+ static readonly CONSTANTS: {
633
+ readonly LOGIN_PATH: "/login";
634
+ readonly DASHBOARD_SUBDOMAIN: "dashboard";
635
+ readonly PUBLIC_PATH: "/public";
636
+ readonly PUBLIC_API_PATH: "/api/public";
636
637
  };
637
- static readonly ROUTES: {
638
- readonly ROOT: "/";
639
- readonly LOGIN: "/login";
638
+ static readonly PROTECTED_ROUTES: {
639
+ INCLUDE: string[];
640
+ EXCLUDE: ("/login" | "/public" | "/api/public")[];
640
641
  };
641
642
  static readonly ALLOWED_METHODS: readonly ["GET", "HEAD"];
642
643
  static readonly QUERY_PARAMS: {
@@ -656,10 +657,6 @@ declare class MiddlewareConfig {
656
657
  * Get the protocol based on environment
657
658
  */
658
659
  static getProtocol(): string;
659
- /**
660
- * Get the dashboard subdomain URL
661
- */
662
- static getDashboardUrl(path?: string): string;
663
660
  }
664
661
  /**
665
662
  * Middleware matcher patterns
@@ -679,11 +676,11 @@ declare const config: {
679
676
  */
680
677
  declare class CookieUtils {
681
678
  /**
682
- * Get the access token cookie key from environment variables
679
+ * Get the access token cookie key
683
680
  */
684
681
  static getAccessTokenKey(): string;
685
682
  /**
686
- * Get the refresh token cookie key from environment variables
683
+ * Get the refresh token cookie key
687
684
  */
688
685
  static getRefreshTokenKey(): string;
689
686
  /**
@@ -816,22 +813,21 @@ declare class CrossTabBehaviorHandler {
816
813
  * Get the action configuration for current route and event
817
814
  */
818
815
  static getAction(currentPageType: PageType, eventType: AuthEventType): {
819
- readonly action: NavigationAction.REDIRECT;
820
- readonly target: PageType.DASHBOARD;
816
+ readonly action: NavigationAction.RELOAD;
821
817
  } | {
822
- readonly action: NavigationAction.NONE;
818
+ readonly action: NavigationAction.RELOAD;
823
819
  } | {
824
820
  readonly action: NavigationAction.NONE;
825
821
  } | {
826
822
  readonly action: NavigationAction.NONE;
827
823
  } | {
828
- readonly action: NavigationAction.CURRENT;
824
+ readonly action: NavigationAction.RELOAD;
829
825
  } | {
830
- readonly action: NavigationAction.CURRENT;
826
+ readonly action: NavigationAction.RELOAD;
831
827
  } | {
832
- readonly action: NavigationAction.CURRENT;
828
+ readonly action: NavigationAction.RELOAD;
833
829
  } | {
834
- readonly action: NavigationAction.CURRENT;
830
+ readonly action: NavigationAction.NONE;
835
831
  } | {
836
832
  readonly action: NavigationAction.NONE;
837
833
  } | {
@@ -841,11 +837,6 @@ declare class CrossTabBehaviorHandler {
841
837
  } | {
842
838
  readonly action: NavigationAction.NONE;
843
839
  };
844
- /**
845
- * Check if current route requires redirect for given event
846
- * Returns PageType to redirect to, or null if no redirect needed
847
- */
848
- static shouldRedirect(currentPageType: PageType, eventType: AuthEventType): PageType | null;
849
840
  }
850
841
 
851
842
  /**
@@ -853,11 +844,16 @@ declare class CrossTabBehaviorHandler {
853
844
  */
854
845
  declare class UrlUtils {
855
846
  /**
856
- * Extract subdomain from hostname or URL
847
+ * Extract subdomain from hostname
857
848
  * Example: "dashboard.cutly.io" -> "dashboard"
858
- * Example: "dashboard.localhost" -> "dashboard"
859
849
  */
860
- static getSubdomain(url: string): string | null;
850
+ static getSubdomain(hostname: string): string | null;
851
+ /**
852
+ * Get root domain for cookie scope
853
+ * Example: "dashboard.cutly.io" -> ".cutly.io"
854
+ * Example: "cutly.io" -> ".cutly.io"
855
+ */
856
+ static getRootDomain(hostname: string): string | null;
861
857
  /**
862
858
  * Check if URL has auth-related query parameters
863
859
  */
package/dist/index.js CHANGED
@@ -83,34 +83,33 @@ var AuthEventType = /* @__PURE__ */ ((AuthEventType3) => {
83
83
  return AuthEventType3;
84
84
  })(AuthEventType || {});
85
85
  var PageType = /* @__PURE__ */ ((PageType3) => {
86
- PageType3["LOGIN"] = "login";
86
+ PageType3["LOGIN"] = "/login";
87
87
  PageType3["DASHBOARD"] = "dashboard";
88
88
  PageType3["HOME"] = "/";
89
89
  return PageType3;
90
90
  })(PageType || {});
91
91
  var NavigationAction = /* @__PURE__ */ ((NavigationAction2) => {
92
92
  NavigationAction2["NONE"] = "none";
93
- NavigationAction2["REDIRECT"] = "redirect";
94
- NavigationAction2["MODAL"] = "modal";
95
- NavigationAction2["CURRENT"] = "current";
93
+ NavigationAction2["RELOAD"] = "reload";
96
94
  return NavigationAction2;
97
95
  })(NavigationAction || {});
98
96
  var PageTypePatterns = {
99
- ["login" /* LOGIN */]: "login" /* LOGIN */,
100
- ["dashboard" /* DASHBOARD */]: "dashboard" /* DASHBOARD */
97
+ ["/login" /* LOGIN */]: "/login" /* LOGIN */,
98
+ ["dashboard" /* DASHBOARD */]: "dashboard" /* DASHBOARD */,
99
+ ["/" /* HOME */]: "/" /* HOME */
101
100
  };
102
101
  var CrossTabBehaviorConfig = {
103
- ["login" /* LOGIN */]: {
104
- ["auth.logged_in" /* LoggedIn */]: { action: "redirect" /* REDIRECT */, target: "dashboard" /* DASHBOARD */ },
105
- ["auth.logged_out" /* LoggedOut */]: { action: "none" /* NONE */ },
102
+ ["/login" /* LOGIN */]: {
103
+ ["auth.logged_in" /* LoggedIn */]: { action: "reload" /* RELOAD */ },
104
+ ["auth.logged_out" /* LoggedOut */]: { action: "reload" /* RELOAD */ },
106
105
  ["auth.email_verified" /* EmailVerified */]: { action: "none" /* NONE */ },
107
106
  ["auth.signin_required_modal" /* SignInRequiredModal */]: { action: "none" /* NONE */ }
108
107
  },
109
108
  ["dashboard" /* DASHBOARD */]: {
110
- ["auth.logged_in" /* LoggedIn */]: { action: "current" /* CURRENT */ },
111
- ["auth.logged_out" /* LoggedOut */]: { action: "current" /* CURRENT */ },
112
- ["auth.email_verified" /* EmailVerified */]: { action: "current" /* CURRENT */ },
113
- ["auth.signin_required_modal" /* SignInRequiredModal */]: { action: "current" /* CURRENT */ }
109
+ ["auth.logged_in" /* LoggedIn */]: { action: "reload" /* RELOAD */ },
110
+ ["auth.logged_out" /* LoggedOut */]: { action: "reload" /* RELOAD */ },
111
+ ["auth.email_verified" /* EmailVerified */]: { action: "reload" /* RELOAD */ },
112
+ ["auth.signin_required_modal" /* SignInRequiredModal */]: { action: "none" /* NONE */ }
114
113
  },
115
114
  ["/" /* HOME */]: {
116
115
  ["auth.logged_in" /* LoggedIn */]: { action: "none" /* NONE */ },
@@ -253,12 +252,12 @@ var getVerificationField = (codeLength = 5, options = {}) => ({
253
252
  });
254
253
 
255
254
  // src/config/middleware.ts
256
- var MiddlewareConfig = class {
255
+ var _MiddlewareConfig = class _MiddlewareConfig {
257
256
  /**
258
257
  * Get the base domain from environment or use default
259
258
  */
260
259
  static getBaseDomain() {
261
- return process.env.NEXT_PUBLIC_BASE_DOMAIN || "cutly.io";
260
+ return process.env.NEXT_PUBLIC_BASE_DOMAIN;
262
261
  }
263
262
  /**
264
263
  * Get the protocol based on environment
@@ -266,35 +265,44 @@ var MiddlewareConfig = class {
266
265
  static getProtocol() {
267
266
  return process.env.NODE_ENV === "production" ? "https" : "http";
268
267
  }
269
- /**
270
- * Get the dashboard subdomain URL
271
- */
272
- static getDashboardUrl(path = "") {
273
- return `${this.getProtocol()}://${this.SUBDOMAINS.DASHBOARD}.${this.getBaseDomain()}${path}`;
274
- }
275
268
  };
276
- // Subdomain configuration
277
- MiddlewareConfig.SUBDOMAINS = {
278
- DASHBOARD: "dashboard"
279
- };
280
- // Routes
281
- MiddlewareConfig.ROUTES = {
282
- ROOT: "/",
283
- LOGIN: "/login"
269
+ // Common constants
270
+ _MiddlewareConfig.CONSTANTS = {
271
+ LOGIN_PATH: "/login",
272
+ DASHBOARD_SUBDOMAIN: "dashboard",
273
+ PUBLIC_PATH: "/public",
274
+ PUBLIC_API_PATH: "/api/public"
275
+ };
276
+ // Route Protection Configuration
277
+ // PATTERNS_TO_PROTECT: Routes that require authentication (whitelist approach recommended for security)
278
+ // PATTERNS_TO_EXCLUDE: Routes to explicitly exclude from protection (e.g., login page, public assets)
279
+ _MiddlewareConfig.PROTECTED_ROUTES = {
280
+ // Routes that MUST be protected
281
+ INCLUDE: [
282
+ "/"
283
+ // Protect everything by default (since dashboard.cutly.io/ is the root)
284
+ ],
285
+ // Routes that should NEVER be protected (public)
286
+ EXCLUDE: [
287
+ _MiddlewareConfig.CONSTANTS.LOGIN_PATH,
288
+ _MiddlewareConfig.CONSTANTS.PUBLIC_PATH,
289
+ _MiddlewareConfig.CONSTANTS.PUBLIC_API_PATH
290
+ ]
284
291
  };
285
292
  // HTTP methods to process
286
- MiddlewareConfig.ALLOWED_METHODS = ["GET", "HEAD"];
293
+ _MiddlewareConfig.ALLOWED_METHODS = ["GET", "HEAD"];
287
294
  // Query parameters
288
- MiddlewareConfig.QUERY_PARAMS = {
295
+ _MiddlewareConfig.QUERY_PARAMS = {
289
296
  LOGIN_REQUIRED: "sign_in_required",
290
297
  AUTH_CHECKED: "auth_checked",
291
298
  REDIRECT_URL: "redirect_url"
292
299
  };
293
300
  // Query parameter values
294
- MiddlewareConfig.QUERY_VALUES = {
301
+ _MiddlewareConfig.QUERY_VALUES = {
295
302
  LOGIN_REQUIRED: "true",
296
303
  AUTH_CHECKED: "1"
297
304
  };
305
+ var MiddlewareConfig = _MiddlewareConfig;
298
306
  var middlewareMatcher = [
299
307
  "/((?!api|_next/static|_next/image|_next/webpack-hmr|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp|ico|css|js)$).*)"
300
308
  ];
@@ -406,19 +414,55 @@ function init(converter, defaultAttributes) {
406
414
  }
407
415
  var api = init(defaultConverter, { path: "/" });
408
416
 
417
+ // src/services/utils/url-utils.ts
418
+ var UrlUtils = class {
419
+ /**
420
+ * Extract subdomain from hostname
421
+ * Example: "dashboard.cutly.io" -> "dashboard"
422
+ */
423
+ static getSubdomain(hostname) {
424
+ if (!hostname || /^\d{1,3}(\.\d{1,3}){3}/.test(hostname) || hostname.startsWith(MiddlewareConfig.getBaseDomain())) {
425
+ return null;
426
+ }
427
+ const parts = hostname.split(".");
428
+ return parts.length >= 2 ? parts[0] : null;
429
+ }
430
+ /**
431
+ * Get root domain for cookie scope
432
+ * Example: "dashboard.cutly.io" -> ".cutly.io"
433
+ * Example: "cutly.io" -> ".cutly.io"
434
+ */
435
+ static getRootDomain(hostname) {
436
+ if (!hostname || /^\d+\.\d+\.\d+\.\d+$/.test(hostname)) {
437
+ return null;
438
+ }
439
+ const parts = hostname.split(".");
440
+ if (parts.length >= 2) {
441
+ return `.${parts.slice(-2).join(".")}`;
442
+ }
443
+ return null;
444
+ }
445
+ /**
446
+ * Check if URL has auth-related query parameters
447
+ */
448
+ static hasAuthParams(url) {
449
+ return url.includes(MiddlewareConfig.QUERY_PARAMS.AUTH_CHECKED);
450
+ }
451
+ };
452
+
409
453
  // src/services/utils/cookie-utils.ts
410
454
  var _CookieUtils = class _CookieUtils {
411
455
  /**
412
- * Get the access token cookie key from environment variables
456
+ * Get the access token cookie key
413
457
  */
414
458
  static getAccessTokenKey() {
415
- return process.env.AUTH_ACCESS_TOKEN_KEY || "auth_access_token";
459
+ return "auth_access_token";
416
460
  }
417
461
  /**
418
- * Get the refresh token cookie key from environment variables
462
+ * Get the refresh token cookie key
419
463
  */
420
464
  static getRefreshTokenKey() {
421
- return process.env.AUTH_REFRESH_TOKEN_KEY || "auth_refresh_token";
465
+ return "auth_refresh_token";
422
466
  }
423
467
  /**
424
468
  * Get root domain for subdomain support
@@ -426,26 +470,10 @@ var _CookieUtils = class _CookieUtils {
426
470
  */
427
471
  static getRootDomain() {
428
472
  if (typeof window === "undefined") {
429
- const baseDomain = process.env.NEXT_PUBLIC_BASE_DOMAIN;
430
- if (baseDomain && process.env.NODE_ENV === "production") {
431
- return `.${baseDomain}`;
432
- }
433
- return void 0;
434
- }
435
- const hostname = window.location.hostname;
436
- if (hostname === "localhost" || hostname === "127.0.0.1") {
437
- return void 0;
438
- }
439
- if (/^\d+\.\d+\.\d+\.\d+$/.test(hostname)) {
440
473
  return void 0;
441
474
  }
442
- const parts = hostname.split(".");
443
- if (parts.length >= 2) {
444
- return `.${parts.slice(-2).join(".")}`;
445
- }
446
- return void 0;
475
+ return UrlUtils.getRootDomain(window.location.hostname) || void 0;
447
476
  }
448
- // Use current domain in development
449
477
  /**
450
478
  * Get common cookie options
451
479
  */
@@ -644,7 +672,7 @@ var _CookieUtils = class _CookieUtils {
644
672
  }
645
673
  };
646
674
  // Domain configuration - computed once
647
- _CookieUtils.COOKIE_DOMAIN = process.env.NODE_ENV === "production" ? _CookieUtils.getRootDomain() : void 0;
675
+ _CookieUtils.COOKIE_DOMAIN = _CookieUtils.getRootDomain();
648
676
  var CookieUtils = _CookieUtils;
649
677
 
650
678
  // src/services/utils/localstorage-utils.ts
@@ -782,33 +810,6 @@ var BroadcastChannelEventBus = class _BroadcastChannelEventBus {
782
810
  }
783
811
  };
784
812
 
785
- // src/services/utils/url-utils.ts
786
- var UrlUtils = class {
787
- /**
788
- * Extract subdomain from hostname or URL
789
- * Example: "dashboard.cutly.io" -> "dashboard"
790
- * Example: "dashboard.localhost" -> "dashboard"
791
- */
792
- static getSubdomain(url) {
793
- try {
794
- const domain = new URL(`http://${url}`).hostname;
795
- const parts = domain.split(".");
796
- if (parts.length < 2 || domain === "localhost" || /^\d{1,3}(\.\d{1,3}){3}/.test(domain) || domain.startsWith(MiddlewareConfig.getBaseDomain())) {
797
- return null;
798
- }
799
- return parts[0] || null;
800
- } catch (e) {
801
- return null;
802
- }
803
- }
804
- /**
805
- * Check if URL has auth-related query parameters
806
- */
807
- static hasAuthParams(url) {
808
- return url.includes(MiddlewareConfig.QUERY_PARAMS.AUTH_CHECKED);
809
- }
810
- };
811
-
812
813
  // src/services/utils/cross-tab-behavior-handler.ts
813
814
  var CrossTabBehaviorHandler = class {
814
815
  /**
@@ -821,8 +822,8 @@ var CrossTabBehaviorHandler = class {
821
822
  const pathname = window.location.pathname;
822
823
  const subdomain = UrlUtils.getSubdomain(window.location.hostname);
823
824
  const pageTypeMatchers = {
824
- ["login" /* LOGIN */]: pathname === MiddlewareConfig.ROUTES.LOGIN,
825
- ["dashboard" /* DASHBOARD */]: subdomain === MiddlewareConfig.SUBDOMAINS.DASHBOARD
825
+ ["/login" /* LOGIN */]: pathname === MiddlewareConfig.CONSTANTS.LOGIN_PATH,
826
+ ["dashboard" /* DASHBOARD */]: subdomain === MiddlewareConfig.CONSTANTS.DASHBOARD_SUBDOMAIN
826
827
  };
827
828
  const matchedPageType = (_a = Object.entries(pageTypeMatchers).find(([, matches]) => matches)) == null ? void 0 : _a[0];
828
829
  return matchedPageType != null ? matchedPageType : "dashboard" /* DASHBOARD */;
@@ -837,14 +838,6 @@ var CrossTabBehaviorHandler = class {
837
838
  var _a, _b;
838
839
  return (_b = (_a = CrossTabBehaviorConfig[currentPageType]) == null ? void 0 : _a[eventType]) != null ? _b : { action: "none" /* NONE */ };
839
840
  }
840
- /**
841
- * Check if current route requires redirect for given event
842
- * Returns PageType to redirect to, or null if no redirect needed
843
- */
844
- static shouldRedirect(currentPageType, eventType) {
845
- const action = this.getAction(currentPageType, eventType);
846
- return action.action === "redirect" /* REDIRECT */ ? action.target : null;
847
- }
848
841
  };
849
842
 
850
843
  // src/services/auth/manager/token-manager.ts
@@ -2376,23 +2369,8 @@ var useAuthEventBus = ({ onLoggedOut, onLoggedIn } = {}) => {
2376
2369
  const handler = eventHandlers[e.type];
2377
2370
  const action = CrossTabBehaviorHandler.getAction(currentPageType, e.type);
2378
2371
  const actionHandlers = {
2379
- ["redirect" /* REDIRECT */]: () => {
2380
- const target = CrossTabBehaviorHandler.shouldRedirect(currentPageType, e.type);
2381
- if (target) {
2382
- window.location.replace(target);
2383
- }
2384
- },
2385
- ["current" /* CURRENT */]: () => {
2386
- const isAuthAction = e.type === "auth.logged_in" /* LoggedIn */ || e.type === "auth.logged_out" /* LoggedOut */;
2387
- const hasParams = UrlUtils.hasAuthParams(window.location.href);
2388
- if (isAuthAction || !hasParams) {
2389
- window.location.reload();
2390
- }
2391
- },
2392
- ["modal" /* MODAL */]: () => {
2393
- if (e.type === "auth.logged_in" /* LoggedIn */) {
2394
- window.location.replace(window.location.href);
2395
- }
2372
+ ["reload" /* RELOAD */]: () => {
2373
+ window.location.replace(window.location.href);
2396
2374
  },
2397
2375
  ["none" /* NONE */]: () => {
2398
2376
  }