mailsentry-auth 0.2.5 → 0.2.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
@@ -368,7 +368,7 @@ declare class CrossTabBehaviorHandler {
368
368
  } | {
369
369
  readonly action: NavigationAction.RELOAD;
370
370
  } | {
371
- readonly action: NavigationAction.RELOAD;
371
+ readonly action: NavigationAction.RELOAD_CLEAN_URL;
372
372
  } | {
373
373
  readonly action: NavigationAction.NONE;
374
374
  } | {
@@ -424,6 +424,24 @@ declare class EmailProviderUtils {
424
424
  static getProviderName(email: string): string | null;
425
425
  }
426
426
 
427
+ /**
428
+ * URL Cleanup Handler
429
+ * Facade Pattern: Simple interface for complex strategy execution
430
+ * Static methods: No state, pure functional approach
431
+ */
432
+ declare class UrlCleanupHandler {
433
+ /**
434
+ * Execute cleanup for given event type and current URL
435
+ * @returns Cleaned URL string if changes made, null otherwise
436
+ */
437
+ static cleanup(eventType: AuthEventType, currentUrl?: string): string | null;
438
+ /**
439
+ * Find applicable strategy for event type and pathname
440
+ * DRY Principle: Centralized strategy lookup logic
441
+ */
442
+ private static findStrategy;
443
+ }
444
+
427
445
  /**
428
446
  * Token Manager Implementation
429
447
  * Handles token storage and validation using CookieUtils
@@ -1263,7 +1281,8 @@ declare enum PageType {
1263
1281
  }
1264
1282
  declare enum NavigationAction {
1265
1283
  NONE = "none",
1266
- RELOAD = "reload"
1284
+ RELOAD = "reload",
1285
+ RELOAD_CLEAN_URL = "reload_clean_url"
1267
1286
  }
1268
1287
  declare const PageTypePatterns: {
1269
1288
  readonly "/login": PageType.LOGIN;
@@ -1290,7 +1309,7 @@ declare const CrossTabBehaviorConfig: {
1290
1309
  readonly action: NavigationAction.RELOAD;
1291
1310
  };
1292
1311
  readonly "auth.logged_out": {
1293
- readonly action: NavigationAction.RELOAD;
1312
+ readonly action: NavigationAction.RELOAD_CLEAN_URL;
1294
1313
  };
1295
1314
  readonly "auth.email_verified": {
1296
1315
  readonly action: NavigationAction.NONE;
@@ -1344,6 +1363,15 @@ interface EmailProviderConfig {
1344
1363
  getUrl: (email: string, subject?: string) => string;
1345
1364
  }
1346
1365
 
1366
+ /**
1367
+ * Strategy Pattern: Interface for URL cleanup behaviors
1368
+ * Single Responsibility: Each strategy handles one cleanup concern
1369
+ */
1370
+ interface ICleanupStrategy {
1371
+ matches(pathname: string): boolean;
1372
+ clean(url: URL): URL;
1373
+ }
1374
+
1347
1375
  declare const createAuthSteps: (options?: {
1348
1376
  authIntent?: NextAction;
1349
1377
  nextAction?: NextAction;
@@ -1740,4 +1768,4 @@ declare const useAuthFlowModal: () => {
1740
1768
  openModal: () => void;
1741
1769
  };
1742
1770
 
1743
- export { AUTH_ENDPOINTS, AlertDisplay, type AlertDisplayProps, type AnyStepProps, type ApiErrorResponse, type ApiKeyConfig, type AuthActionCallbacks, type AuthActionOptions, type AuthActionResult, type AuthActionResultFailure, type AuthActionResultSuccess, type AuthActionState, type AuthEvent, AuthEventType, AuthFlowContainer, type AuthFlowContainerProps, AuthFlowModal, type AuthFlowModalProps, type AuthFlowProps, AuthFlowStep, AuthFlowVariant, AuthInitializer, AuthOrchestrator, AuthOrchestratorFactory, AuthResultFactory, AuthService, type AuthState, AuthenticatedState, type AuthenticatedStateProps, AuthenticationStatusContext, type BaseComponentProps, BaseErrorHandler, BaseEventBus, BaseForm, type BaseFormField, type BaseFormProps, type BaseResponse, BaseService, type BaseStepProps, BroadcastChannelEventBus, Channel, CookieUtils, CrossTabBehaviorConfig, CrossTabBehaviorHandler, CrossTabDemo, DevelopmentLogger, EMAIL_SUBMISSION_NAVIGATION, type EmailCheckResult, type EmailExistResponse, type EmailProviderConfig, EmailProviderUtils, EmailStep, type EmailStepProps, EndpointBuilder, type EventBus, ExistingUserLoginStrategy, type ForgotPasswordStepProps, FormFields, type FormFieldsProps, FormHeader, type FormHeaderProps, GenericErrorHandler, HttpClient, type HttpClientConfig, type HttpError, HttpMethod, type HttpRequestOptions, type HttpResponse, type IAuthOrchestrator, type IAuthService, type IAuthStatusState, type IErrorHandler, type ILogger, type ILoginFlowStrategy, type ITokenManager, LocalStorageUtils, LoggerFactory, type LoginData, LoginFlowStrategyFactory, type LoginRequest, type LoginResponse, LoginStrategyResolver, LoginVerificationStrategy, MiddlewareConfig, type MiddlewareContext, type MiddlewareHandler, NavigationAction, NetworkErrorHandler, NextAction, PASSWORD_SUBMISSION_NAVIGATION, PageType, PageTypePatterns, PasswordInputWithStrength, type PasswordInputWithStrengthProps, PasswordStep, type PasswordStepProps, type PasswordStrengthRule, ProductionLogger, ProfileStateRenderer, ProfileUIState, type PropsFactory, type PublicUserProfile, type PublicUserProfileResponse, RoleType, SignupFlowStrategy, type Step, type StepComponent, type StepComponentRetriever, type StepConfig, type StepPropsFactoryRegistry, type StepRegistry, type StepRegistryBaseProps, type StepRegistryConfigs, type StepRegistryHandlers, type StepRegistryParams, type StepRegistryState, type StepperActions, type StepperState$1 as StepperState, StrategyResolutionMode, type StrengthResult, type Subscription, TokenManager, UnauthenticatedState, UrlUtils, type UseAuthActionHandler, type UseAuthEventBusProps, type UseFormSubmissionProps, type UseStepRegistryParams, type UseStepperReturn, type UserProfile, type UserProfileResponse, type UserSession, type UserState, UserStorageManager, type UserStoreState, VERIFICATION_SUBMISSION_NAVIGATION, ValidationErrorHandler, VerificationStep, type VerificationStepProps, type VerifyEmailRequest, type VerifyEmailResponse, config, createAuthSteps, createPropsFactoryRegistry, createStepRegistry, getAuthPageStepMessage, getEmailField, getForgotPasswordField, getPasswordField, getStepForEmailSubmission, getStepForPasswordSubmission, getStepForVerificationSubmission, getStepProgressMessage, getTermsCheckboxField, getVerificationField, isPublicUser, isPublicUserEmail, middlewareMatcher, useAuth, useAuthActionHandler, useAuthEventBus, useAuthFlowModal, useAuthInitializer, useIsAuthenticated, useLogout, usePublicUserSession, useRefreshUser, useSharedEventBus, useSignInRequiredParams, useStepRegistry, useStepRenderer, useStepper, useUser, useUserActions, useUserData, useUserError, useUserLoading, useUserProfile, useUserSelectors, useUserStore, userSelectors };
1771
+ export { AUTH_ENDPOINTS, AlertDisplay, type AlertDisplayProps, type AnyStepProps, type ApiErrorResponse, type ApiKeyConfig, type AuthActionCallbacks, type AuthActionOptions, type AuthActionResult, type AuthActionResultFailure, type AuthActionResultSuccess, type AuthActionState, type AuthEvent, AuthEventType, AuthFlowContainer, type AuthFlowContainerProps, AuthFlowModal, type AuthFlowModalProps, type AuthFlowProps, AuthFlowStep, AuthFlowVariant, AuthInitializer, AuthOrchestrator, AuthOrchestratorFactory, AuthResultFactory, AuthService, type AuthState, AuthenticatedState, type AuthenticatedStateProps, AuthenticationStatusContext, type BaseComponentProps, BaseErrorHandler, BaseEventBus, BaseForm, type BaseFormField, type BaseFormProps, type BaseResponse, BaseService, type BaseStepProps, BroadcastChannelEventBus, Channel, CookieUtils, CrossTabBehaviorConfig, CrossTabBehaviorHandler, CrossTabDemo, DevelopmentLogger, EMAIL_SUBMISSION_NAVIGATION, type EmailCheckResult, type EmailExistResponse, type EmailProviderConfig, EmailProviderUtils, EmailStep, type EmailStepProps, EndpointBuilder, type EventBus, ExistingUserLoginStrategy, type ForgotPasswordStepProps, FormFields, type FormFieldsProps, FormHeader, type FormHeaderProps, GenericErrorHandler, HttpClient, type HttpClientConfig, type HttpError, HttpMethod, type HttpRequestOptions, type HttpResponse, type IAuthOrchestrator, type IAuthService, type IAuthStatusState, type ICleanupStrategy, type IErrorHandler, type ILogger, type ILoginFlowStrategy, type ITokenManager, LocalStorageUtils, LoggerFactory, type LoginData, LoginFlowStrategyFactory, type LoginRequest, type LoginResponse, LoginStrategyResolver, LoginVerificationStrategy, MiddlewareConfig, type MiddlewareContext, type MiddlewareHandler, NavigationAction, NetworkErrorHandler, NextAction, PASSWORD_SUBMISSION_NAVIGATION, PageType, PageTypePatterns, PasswordInputWithStrength, type PasswordInputWithStrengthProps, PasswordStep, type PasswordStepProps, type PasswordStrengthRule, ProductionLogger, ProfileStateRenderer, ProfileUIState, type PropsFactory, type PublicUserProfile, type PublicUserProfileResponse, RoleType, SignupFlowStrategy, type Step, type StepComponent, type StepComponentRetriever, type StepConfig, type StepPropsFactoryRegistry, type StepRegistry, type StepRegistryBaseProps, type StepRegistryConfigs, type StepRegistryHandlers, type StepRegistryParams, type StepRegistryState, type StepperActions, type StepperState$1 as StepperState, StrategyResolutionMode, type StrengthResult, type Subscription, TokenManager, UnauthenticatedState, UrlCleanupHandler, UrlUtils, type UseAuthActionHandler, type UseAuthEventBusProps, type UseFormSubmissionProps, type UseStepRegistryParams, type UseStepperReturn, type UserProfile, type UserProfileResponse, type UserSession, type UserState, UserStorageManager, type UserStoreState, VERIFICATION_SUBMISSION_NAVIGATION, ValidationErrorHandler, VerificationStep, type VerificationStepProps, type VerifyEmailRequest, type VerifyEmailResponse, config, createAuthSteps, createPropsFactoryRegistry, createStepRegistry, getAuthPageStepMessage, getEmailField, getForgotPasswordField, getPasswordField, getStepForEmailSubmission, getStepForPasswordSubmission, getStepForVerificationSubmission, getStepProgressMessage, getTermsCheckboxField, getVerificationField, isPublicUser, isPublicUserEmail, middlewareMatcher, useAuth, useAuthActionHandler, useAuthEventBus, useAuthFlowModal, useAuthInitializer, useIsAuthenticated, useLogout, usePublicUserSession, useRefreshUser, useSharedEventBus, useSignInRequiredParams, useStepRegistry, useStepRenderer, useStepper, useUser, useUserActions, useUserData, useUserError, useUserLoading, useUserProfile, useUserSelectors, useUserStore, userSelectors };
package/dist/index.d.ts CHANGED
@@ -368,7 +368,7 @@ declare class CrossTabBehaviorHandler {
368
368
  } | {
369
369
  readonly action: NavigationAction.RELOAD;
370
370
  } | {
371
- readonly action: NavigationAction.RELOAD;
371
+ readonly action: NavigationAction.RELOAD_CLEAN_URL;
372
372
  } | {
373
373
  readonly action: NavigationAction.NONE;
374
374
  } | {
@@ -424,6 +424,24 @@ declare class EmailProviderUtils {
424
424
  static getProviderName(email: string): string | null;
425
425
  }
426
426
 
427
+ /**
428
+ * URL Cleanup Handler
429
+ * Facade Pattern: Simple interface for complex strategy execution
430
+ * Static methods: No state, pure functional approach
431
+ */
432
+ declare class UrlCleanupHandler {
433
+ /**
434
+ * Execute cleanup for given event type and current URL
435
+ * @returns Cleaned URL string if changes made, null otherwise
436
+ */
437
+ static cleanup(eventType: AuthEventType, currentUrl?: string): string | null;
438
+ /**
439
+ * Find applicable strategy for event type and pathname
440
+ * DRY Principle: Centralized strategy lookup logic
441
+ */
442
+ private static findStrategy;
443
+ }
444
+
427
445
  /**
428
446
  * Token Manager Implementation
429
447
  * Handles token storage and validation using CookieUtils
@@ -1263,7 +1281,8 @@ declare enum PageType {
1263
1281
  }
1264
1282
  declare enum NavigationAction {
1265
1283
  NONE = "none",
1266
- RELOAD = "reload"
1284
+ RELOAD = "reload",
1285
+ RELOAD_CLEAN_URL = "reload_clean_url"
1267
1286
  }
1268
1287
  declare const PageTypePatterns: {
1269
1288
  readonly "/login": PageType.LOGIN;
@@ -1290,7 +1309,7 @@ declare const CrossTabBehaviorConfig: {
1290
1309
  readonly action: NavigationAction.RELOAD;
1291
1310
  };
1292
1311
  readonly "auth.logged_out": {
1293
- readonly action: NavigationAction.RELOAD;
1312
+ readonly action: NavigationAction.RELOAD_CLEAN_URL;
1294
1313
  };
1295
1314
  readonly "auth.email_verified": {
1296
1315
  readonly action: NavigationAction.NONE;
@@ -1344,6 +1363,15 @@ interface EmailProviderConfig {
1344
1363
  getUrl: (email: string, subject?: string) => string;
1345
1364
  }
1346
1365
 
1366
+ /**
1367
+ * Strategy Pattern: Interface for URL cleanup behaviors
1368
+ * Single Responsibility: Each strategy handles one cleanup concern
1369
+ */
1370
+ interface ICleanupStrategy {
1371
+ matches(pathname: string): boolean;
1372
+ clean(url: URL): URL;
1373
+ }
1374
+
1347
1375
  declare const createAuthSteps: (options?: {
1348
1376
  authIntent?: NextAction;
1349
1377
  nextAction?: NextAction;
@@ -1740,4 +1768,4 @@ declare const useAuthFlowModal: () => {
1740
1768
  openModal: () => void;
1741
1769
  };
1742
1770
 
1743
- export { AUTH_ENDPOINTS, AlertDisplay, type AlertDisplayProps, type AnyStepProps, type ApiErrorResponse, type ApiKeyConfig, type AuthActionCallbacks, type AuthActionOptions, type AuthActionResult, type AuthActionResultFailure, type AuthActionResultSuccess, type AuthActionState, type AuthEvent, AuthEventType, AuthFlowContainer, type AuthFlowContainerProps, AuthFlowModal, type AuthFlowModalProps, type AuthFlowProps, AuthFlowStep, AuthFlowVariant, AuthInitializer, AuthOrchestrator, AuthOrchestratorFactory, AuthResultFactory, AuthService, type AuthState, AuthenticatedState, type AuthenticatedStateProps, AuthenticationStatusContext, type BaseComponentProps, BaseErrorHandler, BaseEventBus, BaseForm, type BaseFormField, type BaseFormProps, type BaseResponse, BaseService, type BaseStepProps, BroadcastChannelEventBus, Channel, CookieUtils, CrossTabBehaviorConfig, CrossTabBehaviorHandler, CrossTabDemo, DevelopmentLogger, EMAIL_SUBMISSION_NAVIGATION, type EmailCheckResult, type EmailExistResponse, type EmailProviderConfig, EmailProviderUtils, EmailStep, type EmailStepProps, EndpointBuilder, type EventBus, ExistingUserLoginStrategy, type ForgotPasswordStepProps, FormFields, type FormFieldsProps, FormHeader, type FormHeaderProps, GenericErrorHandler, HttpClient, type HttpClientConfig, type HttpError, HttpMethod, type HttpRequestOptions, type HttpResponse, type IAuthOrchestrator, type IAuthService, type IAuthStatusState, type IErrorHandler, type ILogger, type ILoginFlowStrategy, type ITokenManager, LocalStorageUtils, LoggerFactory, type LoginData, LoginFlowStrategyFactory, type LoginRequest, type LoginResponse, LoginStrategyResolver, LoginVerificationStrategy, MiddlewareConfig, type MiddlewareContext, type MiddlewareHandler, NavigationAction, NetworkErrorHandler, NextAction, PASSWORD_SUBMISSION_NAVIGATION, PageType, PageTypePatterns, PasswordInputWithStrength, type PasswordInputWithStrengthProps, PasswordStep, type PasswordStepProps, type PasswordStrengthRule, ProductionLogger, ProfileStateRenderer, ProfileUIState, type PropsFactory, type PublicUserProfile, type PublicUserProfileResponse, RoleType, SignupFlowStrategy, type Step, type StepComponent, type StepComponentRetriever, type StepConfig, type StepPropsFactoryRegistry, type StepRegistry, type StepRegistryBaseProps, type StepRegistryConfigs, type StepRegistryHandlers, type StepRegistryParams, type StepRegistryState, type StepperActions, type StepperState$1 as StepperState, StrategyResolutionMode, type StrengthResult, type Subscription, TokenManager, UnauthenticatedState, UrlUtils, type UseAuthActionHandler, type UseAuthEventBusProps, type UseFormSubmissionProps, type UseStepRegistryParams, type UseStepperReturn, type UserProfile, type UserProfileResponse, type UserSession, type UserState, UserStorageManager, type UserStoreState, VERIFICATION_SUBMISSION_NAVIGATION, ValidationErrorHandler, VerificationStep, type VerificationStepProps, type VerifyEmailRequest, type VerifyEmailResponse, config, createAuthSteps, createPropsFactoryRegistry, createStepRegistry, getAuthPageStepMessage, getEmailField, getForgotPasswordField, getPasswordField, getStepForEmailSubmission, getStepForPasswordSubmission, getStepForVerificationSubmission, getStepProgressMessage, getTermsCheckboxField, getVerificationField, isPublicUser, isPublicUserEmail, middlewareMatcher, useAuth, useAuthActionHandler, useAuthEventBus, useAuthFlowModal, useAuthInitializer, useIsAuthenticated, useLogout, usePublicUserSession, useRefreshUser, useSharedEventBus, useSignInRequiredParams, useStepRegistry, useStepRenderer, useStepper, useUser, useUserActions, useUserData, useUserError, useUserLoading, useUserProfile, useUserSelectors, useUserStore, userSelectors };
1771
+ export { AUTH_ENDPOINTS, AlertDisplay, type AlertDisplayProps, type AnyStepProps, type ApiErrorResponse, type ApiKeyConfig, type AuthActionCallbacks, type AuthActionOptions, type AuthActionResult, type AuthActionResultFailure, type AuthActionResultSuccess, type AuthActionState, type AuthEvent, AuthEventType, AuthFlowContainer, type AuthFlowContainerProps, AuthFlowModal, type AuthFlowModalProps, type AuthFlowProps, AuthFlowStep, AuthFlowVariant, AuthInitializer, AuthOrchestrator, AuthOrchestratorFactory, AuthResultFactory, AuthService, type AuthState, AuthenticatedState, type AuthenticatedStateProps, AuthenticationStatusContext, type BaseComponentProps, BaseErrorHandler, BaseEventBus, BaseForm, type BaseFormField, type BaseFormProps, type BaseResponse, BaseService, type BaseStepProps, BroadcastChannelEventBus, Channel, CookieUtils, CrossTabBehaviorConfig, CrossTabBehaviorHandler, CrossTabDemo, DevelopmentLogger, EMAIL_SUBMISSION_NAVIGATION, type EmailCheckResult, type EmailExistResponse, type EmailProviderConfig, EmailProviderUtils, EmailStep, type EmailStepProps, EndpointBuilder, type EventBus, ExistingUserLoginStrategy, type ForgotPasswordStepProps, FormFields, type FormFieldsProps, FormHeader, type FormHeaderProps, GenericErrorHandler, HttpClient, type HttpClientConfig, type HttpError, HttpMethod, type HttpRequestOptions, type HttpResponse, type IAuthOrchestrator, type IAuthService, type IAuthStatusState, type ICleanupStrategy, type IErrorHandler, type ILogger, type ILoginFlowStrategy, type ITokenManager, LocalStorageUtils, LoggerFactory, type LoginData, LoginFlowStrategyFactory, type LoginRequest, type LoginResponse, LoginStrategyResolver, LoginVerificationStrategy, MiddlewareConfig, type MiddlewareContext, type MiddlewareHandler, NavigationAction, NetworkErrorHandler, NextAction, PASSWORD_SUBMISSION_NAVIGATION, PageType, PageTypePatterns, PasswordInputWithStrength, type PasswordInputWithStrengthProps, PasswordStep, type PasswordStepProps, type PasswordStrengthRule, ProductionLogger, ProfileStateRenderer, ProfileUIState, type PropsFactory, type PublicUserProfile, type PublicUserProfileResponse, RoleType, SignupFlowStrategy, type Step, type StepComponent, type StepComponentRetriever, type StepConfig, type StepPropsFactoryRegistry, type StepRegistry, type StepRegistryBaseProps, type StepRegistryConfigs, type StepRegistryHandlers, type StepRegistryParams, type StepRegistryState, type StepperActions, type StepperState$1 as StepperState, StrategyResolutionMode, type StrengthResult, type Subscription, TokenManager, UnauthenticatedState, UrlCleanupHandler, UrlUtils, type UseAuthActionHandler, type UseAuthEventBusProps, type UseFormSubmissionProps, type UseStepRegistryParams, type UseStepperReturn, type UserProfile, type UserProfileResponse, type UserSession, type UserState, UserStorageManager, type UserStoreState, VERIFICATION_SUBMISSION_NAVIGATION, ValidationErrorHandler, VerificationStep, type VerificationStepProps, type VerifyEmailRequest, type VerifyEmailResponse, config, createAuthSteps, createPropsFactoryRegistry, createStepRegistry, getAuthPageStepMessage, getEmailField, getForgotPasswordField, getPasswordField, getStepForEmailSubmission, getStepForPasswordSubmission, getStepForVerificationSubmission, getStepProgressMessage, getTermsCheckboxField, getVerificationField, isPublicUser, isPublicUserEmail, middlewareMatcher, useAuth, useAuthActionHandler, useAuthEventBus, useAuthFlowModal, useAuthInitializer, useIsAuthenticated, useLogout, usePublicUserSession, useRefreshUser, useSharedEventBus, useSignInRequiredParams, useStepRegistry, useStepRenderer, useStepper, useUser, useUserActions, useUserData, useUserError, useUserLoading, useUserProfile, useUserSelectors, useUserStore, userSelectors };
package/dist/index.js CHANGED
@@ -100,6 +100,7 @@ var PageType = /* @__PURE__ */ ((PageType4) => {
100
100
  var NavigationAction = /* @__PURE__ */ ((NavigationAction2) => {
101
101
  NavigationAction2["NONE"] = "none";
102
102
  NavigationAction2["RELOAD"] = "reload";
103
+ NavigationAction2["RELOAD_CLEAN_URL"] = "reload_clean_url";
103
104
  return NavigationAction2;
104
105
  })(NavigationAction || {});
105
106
  var PageTypePatterns = {
@@ -116,7 +117,7 @@ var CrossTabBehaviorConfig = {
116
117
  },
117
118
  ["dashboard" /* DASHBOARD */]: {
118
119
  ["auth.logged_in" /* LoggedIn */]: { action: "reload" /* RELOAD */ },
119
- ["auth.logged_out" /* LoggedOut */]: { action: "reload" /* RELOAD */ },
120
+ ["auth.logged_out" /* LoggedOut */]: { action: "reload_clean_url" /* RELOAD_CLEAN_URL */ },
120
121
  ["auth.email_verified" /* EmailVerified */]: { action: "none" /* NONE */ },
121
122
  ["auth.signin_required_modal" /* SignInRequiredModal */]: { action: "none" /* NONE */ }
122
123
  },
@@ -1005,6 +1006,104 @@ function useStepRegistry({
1005
1006
  // src/hooks/useAuthEventBus.ts
1006
1007
 
1007
1008
 
1009
+ // node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.mjs
1010
+ function assign(target) {
1011
+ for (var i = 1; i < arguments.length; i++) {
1012
+ var source = arguments[i];
1013
+ for (var key in source) {
1014
+ target[key] = source[key];
1015
+ }
1016
+ }
1017
+ return target;
1018
+ }
1019
+ var defaultConverter = {
1020
+ read: function(value) {
1021
+ if (value[0] === '"') {
1022
+ value = value.slice(1, -1);
1023
+ }
1024
+ return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
1025
+ },
1026
+ write: function(value) {
1027
+ return encodeURIComponent(value).replace(
1028
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
1029
+ decodeURIComponent
1030
+ );
1031
+ }
1032
+ };
1033
+ function init(converter, defaultAttributes) {
1034
+ function set(name, value, attributes) {
1035
+ if (typeof document === "undefined") {
1036
+ return;
1037
+ }
1038
+ attributes = assign({}, defaultAttributes, attributes);
1039
+ if (typeof attributes.expires === "number") {
1040
+ attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
1041
+ }
1042
+ if (attributes.expires) {
1043
+ attributes.expires = attributes.expires.toUTCString();
1044
+ }
1045
+ name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
1046
+ var stringifiedAttributes = "";
1047
+ for (var attributeName in attributes) {
1048
+ if (!attributes[attributeName]) {
1049
+ continue;
1050
+ }
1051
+ stringifiedAttributes += "; " + attributeName;
1052
+ if (attributes[attributeName] === true) {
1053
+ continue;
1054
+ }
1055
+ stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
1056
+ }
1057
+ return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
1058
+ }
1059
+ function get(name) {
1060
+ if (typeof document === "undefined" || arguments.length && !name) {
1061
+ return;
1062
+ }
1063
+ var cookies = document.cookie ? document.cookie.split("; ") : [];
1064
+ var jar = {};
1065
+ for (var i = 0; i < cookies.length; i++) {
1066
+ var parts = cookies[i].split("=");
1067
+ var value = parts.slice(1).join("=");
1068
+ try {
1069
+ var found = decodeURIComponent(parts[0]);
1070
+ jar[found] = converter.read(value, found);
1071
+ if (name === found) {
1072
+ break;
1073
+ }
1074
+ } catch (e) {
1075
+ }
1076
+ }
1077
+ return name ? jar[name] : jar;
1078
+ }
1079
+ return Object.create(
1080
+ {
1081
+ set,
1082
+ get,
1083
+ remove: function(name, attributes) {
1084
+ set(
1085
+ name,
1086
+ "",
1087
+ assign({}, attributes, {
1088
+ expires: -1
1089
+ })
1090
+ );
1091
+ },
1092
+ withAttributes: function(attributes) {
1093
+ return init(this.converter, assign({}, this.attributes, attributes));
1094
+ },
1095
+ withConverter: function(converter2) {
1096
+ return init(assign({}, this.converter, converter2), this.attributes);
1097
+ }
1098
+ },
1099
+ {
1100
+ attributes: { value: Object.freeze(defaultAttributes) },
1101
+ converter: { value: Object.freeze(converter) }
1102
+ }
1103
+ );
1104
+ }
1105
+ var api = init(defaultConverter, { path: "/" });
1106
+
1008
1107
  // src/config/middleware.ts
1009
1108
  var _MiddlewareConfig = class _MiddlewareConfig {
1010
1109
  // Route Protection Configuration
@@ -1122,236 +1221,6 @@ var UrlUtils = class {
1122
1221
  }
1123
1222
  };
1124
1223
 
1125
- // src/services/utils/cross-tab-behavior-handler.ts
1126
- var CrossTabBehaviorHandler = class {
1127
- /**
1128
- * Get current page type using object lookup pattern
1129
- */
1130
- static getCurrentPageType() {
1131
- var _a;
1132
- if (typeof window === "undefined") return "/" /* HOME */;
1133
- try {
1134
- const pathname = window.location.pathname;
1135
- const subdomain = UrlUtils.getSubdomain(window.location.hostname);
1136
- const pageTypeMatchers = {
1137
- ["/login" /* LOGIN */]: pathname === MiddlewareConfig.CONSTANTS.LOGIN_PATH,
1138
- ["dashboard" /* DASHBOARD */]: subdomain === MiddlewareConfig.CONSTANTS.DASHBOARD_SUBDOMAIN
1139
- };
1140
- const matchedPageType = (_a = Object.entries(pageTypeMatchers).find(([, matches]) => matches)) == null ? void 0 : _a[0];
1141
- return matchedPageType != null ? matchedPageType : "dashboard" /* DASHBOARD */;
1142
- } catch (e) {
1143
- return "dashboard" /* DASHBOARD */;
1144
- }
1145
- }
1146
- /**
1147
- * Get the action configuration for current route and event
1148
- */
1149
- static getAction(currentPageType, eventType) {
1150
- var _a, _b;
1151
- return (_b = (_a = CrossTabBehaviorConfig[currentPageType]) == null ? void 0 : _a[eventType]) != null ? _b : { action: "none" /* NONE */ };
1152
- }
1153
- };
1154
-
1155
- // src/hooks/useSharedEventBus.ts
1156
-
1157
-
1158
- // src/services/utils/event-bus.ts
1159
- var REGISTRY_KEY = "__bc_event_buses__";
1160
- function getRegistry() {
1161
- const g = globalThis;
1162
- if (!g[REGISTRY_KEY]) {
1163
- g[REGISTRY_KEY] = /* @__PURE__ */ new Map();
1164
- }
1165
- return g[REGISTRY_KEY];
1166
- }
1167
- function isBroadcastChannelSupported() {
1168
- return typeof window !== "undefined" && "BroadcastChannel" in window && typeof BroadcastChannel === "function";
1169
- }
1170
- var BroadcastChannelEventBus = class _BroadcastChannelEventBus {
1171
- constructor(name) {
1172
- this.listeners = /* @__PURE__ */ new Set();
1173
- this.name = name;
1174
- if (isBroadcastChannelSupported()) {
1175
- try {
1176
- const BC = globalThis.BroadcastChannel;
1177
- if (BC) {
1178
- const channel = new BC(name);
1179
- channel.onmessage = (ev) => this.emit(ev.data);
1180
- this.channel = channel;
1181
- }
1182
- } catch (error) {
1183
- console.warn("Failed to create BroadcastChannel:", error);
1184
- }
1185
- }
1186
- }
1187
- static getInstance(name) {
1188
- const registry = getRegistry();
1189
- let bus = registry.get(name);
1190
- if (!bus) {
1191
- bus = new _BroadcastChannelEventBus(name);
1192
- registry.set(name, bus);
1193
- }
1194
- return bus;
1195
- }
1196
- publish(event) {
1197
- var _a;
1198
- this.emit(event);
1199
- (_a = this.channel) == null ? void 0 : _a.postMessage(event);
1200
- }
1201
- subscribe(handler) {
1202
- this.listeners.add(handler);
1203
- return { unsubscribe: () => this.listeners.delete(handler) };
1204
- }
1205
- emit(e) {
1206
- for (const h of this.listeners) h(e);
1207
- }
1208
- close() {
1209
- var _a;
1210
- (_a = this.channel) == null ? void 0 : _a.close();
1211
- this.listeners.clear();
1212
- getRegistry().delete(this.name);
1213
- }
1214
- };
1215
-
1216
- // src/hooks/useSharedEventBus.ts
1217
- function useSharedEventBus() {
1218
- return _react.useMemo.call(void 0, () => BroadcastChannelEventBus.getInstance("auth-event-channel" /* AUTH */), []);
1219
- }
1220
-
1221
- // src/hooks/useAuthEventBus.ts
1222
- var useAuthEventBus = ({ onLoggedOut, onLoggedIn } = {}) => {
1223
- const eventBus = useSharedEventBus();
1224
- _react.useEffect.call(void 0, () => {
1225
- const handleEvent = (e) => {
1226
- var _a;
1227
- const currentPageType = CrossTabBehaviorHandler.getCurrentPageType();
1228
- const eventHandlers = {
1229
- ["auth.logged_out" /* LoggedOut */]: onLoggedOut,
1230
- ["auth.logged_in" /* LoggedIn */]: onLoggedIn,
1231
- ["auth.email_verified" /* EmailVerified */]: void 0,
1232
- ["auth.signin_required_modal" /* SignInRequiredModal */]: void 0
1233
- };
1234
- const handler = eventHandlers[e.type];
1235
- const action = CrossTabBehaviorHandler.getAction(currentPageType, e.type);
1236
- const actionHandlers = {
1237
- ["reload" /* RELOAD */]: () => {
1238
- window.location.replace(window.location.href);
1239
- },
1240
- ["none" /* NONE */]: () => {
1241
- }
1242
- };
1243
- (_a = actionHandlers[action.action]) == null ? void 0 : _a.call(actionHandlers);
1244
- handler == null ? void 0 : handler();
1245
- };
1246
- const subscription = eventBus.subscribe(handleEvent);
1247
- return () => {
1248
- subscription.unsubscribe();
1249
- };
1250
- }, [eventBus, onLoggedOut, onLoggedIn]);
1251
- };
1252
-
1253
- // src/hooks/useSignInRequiredParams.ts
1254
-
1255
- var _navigation = require('next/navigation');
1256
-
1257
- // node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.mjs
1258
- function assign(target) {
1259
- for (var i = 1; i < arguments.length; i++) {
1260
- var source = arguments[i];
1261
- for (var key in source) {
1262
- target[key] = source[key];
1263
- }
1264
- }
1265
- return target;
1266
- }
1267
- var defaultConverter = {
1268
- read: function(value) {
1269
- if (value[0] === '"') {
1270
- value = value.slice(1, -1);
1271
- }
1272
- return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
1273
- },
1274
- write: function(value) {
1275
- return encodeURIComponent(value).replace(
1276
- /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
1277
- decodeURIComponent
1278
- );
1279
- }
1280
- };
1281
- function init(converter, defaultAttributes) {
1282
- function set(name, value, attributes) {
1283
- if (typeof document === "undefined") {
1284
- return;
1285
- }
1286
- attributes = assign({}, defaultAttributes, attributes);
1287
- if (typeof attributes.expires === "number") {
1288
- attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
1289
- }
1290
- if (attributes.expires) {
1291
- attributes.expires = attributes.expires.toUTCString();
1292
- }
1293
- name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
1294
- var stringifiedAttributes = "";
1295
- for (var attributeName in attributes) {
1296
- if (!attributes[attributeName]) {
1297
- continue;
1298
- }
1299
- stringifiedAttributes += "; " + attributeName;
1300
- if (attributes[attributeName] === true) {
1301
- continue;
1302
- }
1303
- stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
1304
- }
1305
- return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
1306
- }
1307
- function get(name) {
1308
- if (typeof document === "undefined" || arguments.length && !name) {
1309
- return;
1310
- }
1311
- var cookies = document.cookie ? document.cookie.split("; ") : [];
1312
- var jar = {};
1313
- for (var i = 0; i < cookies.length; i++) {
1314
- var parts = cookies[i].split("=");
1315
- var value = parts.slice(1).join("=");
1316
- try {
1317
- var found = decodeURIComponent(parts[0]);
1318
- jar[found] = converter.read(value, found);
1319
- if (name === found) {
1320
- break;
1321
- }
1322
- } catch (e) {
1323
- }
1324
- }
1325
- return name ? jar[name] : jar;
1326
- }
1327
- return Object.create(
1328
- {
1329
- set,
1330
- get,
1331
- remove: function(name, attributes) {
1332
- set(
1333
- name,
1334
- "",
1335
- assign({}, attributes, {
1336
- expires: -1
1337
- })
1338
- );
1339
- },
1340
- withAttributes: function(attributes) {
1341
- return init(this.converter, assign({}, this.attributes, attributes));
1342
- },
1343
- withConverter: function(converter2) {
1344
- return init(assign({}, this.converter, converter2), this.attributes);
1345
- }
1346
- },
1347
- {
1348
- attributes: { value: Object.freeze(defaultAttributes) },
1349
- converter: { value: Object.freeze(converter) }
1350
- }
1351
- );
1352
- }
1353
- var api = init(defaultConverter, { path: "/" });
1354
-
1355
1224
  // src/services/utils/cookie-utils.ts
1356
1225
  var _CookieUtils = class _CookieUtils {
1357
1226
  /**
@@ -1658,6 +1527,94 @@ LocalStorageUtils.USER_PROFILE_STORAGE_KEY = "user_profile_data";
1658
1527
  LocalStorageUtils.USER_PROFILE_TIMESTAMP_KEY = "user_profile_timestamp";
1659
1528
  LocalStorageUtils.DEFAULT_CACHE_DURATION = 5 * 60 * 1e3;
1660
1529
 
1530
+ // src/services/utils/event-bus.ts
1531
+ var REGISTRY_KEY = "__bc_event_buses__";
1532
+ function getRegistry() {
1533
+ const g = globalThis;
1534
+ if (!g[REGISTRY_KEY]) {
1535
+ g[REGISTRY_KEY] = /* @__PURE__ */ new Map();
1536
+ }
1537
+ return g[REGISTRY_KEY];
1538
+ }
1539
+ function isBroadcastChannelSupported() {
1540
+ return typeof window !== "undefined" && "BroadcastChannel" in window && typeof BroadcastChannel === "function";
1541
+ }
1542
+ var BroadcastChannelEventBus = class _BroadcastChannelEventBus {
1543
+ constructor(name) {
1544
+ this.listeners = /* @__PURE__ */ new Set();
1545
+ this.name = name;
1546
+ if (isBroadcastChannelSupported()) {
1547
+ try {
1548
+ const BC = globalThis.BroadcastChannel;
1549
+ if (BC) {
1550
+ const channel = new BC(name);
1551
+ channel.onmessage = (ev) => this.emit(ev.data);
1552
+ this.channel = channel;
1553
+ }
1554
+ } catch (error) {
1555
+ console.warn("Failed to create BroadcastChannel:", error);
1556
+ }
1557
+ }
1558
+ }
1559
+ static getInstance(name) {
1560
+ const registry = getRegistry();
1561
+ let bus = registry.get(name);
1562
+ if (!bus) {
1563
+ bus = new _BroadcastChannelEventBus(name);
1564
+ registry.set(name, bus);
1565
+ }
1566
+ return bus;
1567
+ }
1568
+ publish(event) {
1569
+ var _a;
1570
+ this.emit(event);
1571
+ (_a = this.channel) == null ? void 0 : _a.postMessage(event);
1572
+ }
1573
+ subscribe(handler) {
1574
+ this.listeners.add(handler);
1575
+ return { unsubscribe: () => this.listeners.delete(handler) };
1576
+ }
1577
+ emit(e) {
1578
+ for (const h of this.listeners) h(e);
1579
+ }
1580
+ close() {
1581
+ var _a;
1582
+ (_a = this.channel) == null ? void 0 : _a.close();
1583
+ this.listeners.clear();
1584
+ getRegistry().delete(this.name);
1585
+ }
1586
+ };
1587
+
1588
+ // src/services/utils/cross-tab-behavior-handler.ts
1589
+ var CrossTabBehaviorHandler = class {
1590
+ /**
1591
+ * Get current page type using object lookup pattern
1592
+ */
1593
+ static getCurrentPageType() {
1594
+ var _a;
1595
+ if (typeof window === "undefined") return "/" /* HOME */;
1596
+ try {
1597
+ const pathname = window.location.pathname;
1598
+ const subdomain = UrlUtils.getSubdomain(window.location.hostname);
1599
+ const pageTypeMatchers = {
1600
+ ["/login" /* LOGIN */]: pathname === MiddlewareConfig.CONSTANTS.LOGIN_PATH,
1601
+ ["dashboard" /* DASHBOARD */]: subdomain === MiddlewareConfig.CONSTANTS.DASHBOARD_SUBDOMAIN
1602
+ };
1603
+ const matchedPageType = (_a = Object.entries(pageTypeMatchers).find(([, matches]) => matches)) == null ? void 0 : _a[0];
1604
+ return matchedPageType != null ? matchedPageType : "dashboard" /* DASHBOARD */;
1605
+ } catch (e) {
1606
+ return "dashboard" /* DASHBOARD */;
1607
+ }
1608
+ }
1609
+ /**
1610
+ * Get the action configuration for current route and event
1611
+ */
1612
+ static getAction(currentPageType, eventType) {
1613
+ var _a, _b;
1614
+ return (_b = (_a = CrossTabBehaviorConfig[currentPageType]) == null ? void 0 : _a[eventType]) != null ? _b : { action: "none" /* NONE */ };
1615
+ }
1616
+ };
1617
+
1661
1618
  // src/services/utils/email-provider-utils.ts
1662
1619
  var EMAIL_PROVIDERS = [
1663
1620
  {
@@ -1735,6 +1692,83 @@ var EmailProviderUtils = class {
1735
1692
  }
1736
1693
  };
1737
1694
 
1695
+ // src/services/utils/url-cleanup-handler.ts
1696
+ var CleanupStrategy = class {
1697
+ constructor(routes) {
1698
+ this.routes = routes;
1699
+ }
1700
+ matches(pathname) {
1701
+ return this.routes.some((route) => this.isMatch(pathname, route));
1702
+ }
1703
+ isMatch(pathname, route) {
1704
+ if (route === pathname) return true;
1705
+ if (route.endsWith("/*")) {
1706
+ return pathname.startsWith(route.slice(0, -2));
1707
+ }
1708
+ return false;
1709
+ }
1710
+ };
1711
+ var RemoveParamsStrategy = class extends CleanupStrategy {
1712
+ constructor(routes, params) {
1713
+ super(routes);
1714
+ this.params = params;
1715
+ }
1716
+ clean(url) {
1717
+ const cleaned = new URL(url);
1718
+ this.params.forEach((param) => cleaned.searchParams.delete(param));
1719
+ return cleaned;
1720
+ }
1721
+ };
1722
+ var StrategyFactory = class {
1723
+ static fromConfig(config2) {
1724
+ return Object.entries(config2).map(
1725
+ ([route, params]) => new RemoveParamsStrategy([route], params)
1726
+ );
1727
+ }
1728
+ };
1729
+ var getRouteConfig = () => {
1730
+ const envConfig = process.env.NEXT_PUBLIC_URL_CLEANUP_ROUTES;
1731
+ if (!envConfig) {
1732
+ return {};
1733
+ }
1734
+ try {
1735
+ return JSON.parse(envConfig);
1736
+ } catch (error) {
1737
+ console.error("Failed to parse NEXT_PUBLIC_URL_CLEANUP_ROUTES:", error);
1738
+ return {};
1739
+ }
1740
+ };
1741
+ var ROUTE_CONFIG = getRouteConfig();
1742
+ var EVENT_STRATEGIES = {
1743
+ ["auth.logged_out" /* LoggedOut */]: StrategyFactory.fromConfig(ROUTE_CONFIG),
1744
+ ["auth.logged_in" /* LoggedIn */]: [],
1745
+ ["auth.email_verified" /* EmailVerified */]: [],
1746
+ ["auth.signin_required_modal" /* SignInRequiredModal */]: []
1747
+ };
1748
+ var UrlCleanupHandler = class {
1749
+ /**
1750
+ * Execute cleanup for given event type and current URL
1751
+ * @returns Cleaned URL string if changes made, null otherwise
1752
+ */
1753
+ static cleanup(eventType, currentUrl) {
1754
+ if (typeof window === "undefined") return null;
1755
+ const url = new URL(currentUrl != null ? currentUrl : window.location.href);
1756
+ const strategy = this.findStrategy(eventType, url.pathname);
1757
+ if (!strategy) return null;
1758
+ const cleaned = strategy.clean(url);
1759
+ return cleaned.href !== url.href ? cleaned.href : null;
1760
+ }
1761
+ /**
1762
+ * Find applicable strategy for event type and pathname
1763
+ * DRY Principle: Centralized strategy lookup logic
1764
+ */
1765
+ static findStrategy(eventType, pathname) {
1766
+ var _a, _b;
1767
+ const strategies = (_a = EVENT_STRATEGIES[eventType]) != null ? _a : [];
1768
+ return (_b = strategies.find((s) => s.matches(pathname))) != null ? _b : null;
1769
+ }
1770
+ };
1771
+
1738
1772
  // src/services/auth/manager/token-manager.ts
1739
1773
  var TokenManager = class {
1740
1774
  constructor(cookieUtils) {
@@ -2690,7 +2724,51 @@ var AuthOrchestratorFactory = class {
2690
2724
  }
2691
2725
  };
2692
2726
 
2727
+ // src/hooks/useSharedEventBus.ts
2728
+
2729
+ function useSharedEventBus() {
2730
+ return _react.useMemo.call(void 0, () => BroadcastChannelEventBus.getInstance("auth-event-channel" /* AUTH */), []);
2731
+ }
2732
+
2733
+ // src/hooks/useAuthEventBus.ts
2734
+ var useAuthEventBus = ({ onLoggedOut, onLoggedIn } = {}) => {
2735
+ const eventBus = useSharedEventBus();
2736
+ _react.useEffect.call(void 0, () => {
2737
+ const handleEvent = (e) => {
2738
+ var _a;
2739
+ const currentPageType = CrossTabBehaviorHandler.getCurrentPageType();
2740
+ const eventHandlers = {
2741
+ ["auth.logged_out" /* LoggedOut */]: onLoggedOut,
2742
+ ["auth.logged_in" /* LoggedIn */]: onLoggedIn,
2743
+ ["auth.email_verified" /* EmailVerified */]: void 0,
2744
+ ["auth.signin_required_modal" /* SignInRequiredModal */]: void 0
2745
+ };
2746
+ const handler = eventHandlers[e.type];
2747
+ const action = CrossTabBehaviorHandler.getAction(currentPageType, e.type);
2748
+ const actionHandlers = {
2749
+ ["reload" /* RELOAD */]: () => {
2750
+ window.location.replace(window.location.href);
2751
+ },
2752
+ ["reload_clean_url" /* RELOAD_CLEAN_URL */]: () => {
2753
+ const cleanedUrl = UrlCleanupHandler.cleanup(e.type);
2754
+ window.location.replace(cleanedUrl != null ? cleanedUrl : window.location.href);
2755
+ },
2756
+ ["none" /* NONE */]: () => {
2757
+ }
2758
+ };
2759
+ (_a = actionHandlers[action.action]) == null ? void 0 : _a.call(actionHandlers);
2760
+ handler == null ? void 0 : handler();
2761
+ };
2762
+ const subscription = eventBus.subscribe(handleEvent);
2763
+ return () => {
2764
+ subscription.unsubscribe();
2765
+ };
2766
+ }, [eventBus, onLoggedOut, onLoggedIn]);
2767
+ };
2768
+
2693
2769
  // src/hooks/useSignInRequiredParams.ts
2770
+
2771
+ var _navigation = require('next/navigation');
2694
2772
  function useSignInRequiredParams() {
2695
2773
  const searchParams = _navigation.useSearchParams.call(void 0, );
2696
2774
  const eventBus = useSharedEventBus();
@@ -3840,7 +3918,8 @@ var getForgotPasswordField = (options = {}) => ({
3840
3918
 
3841
3919
 
3842
3920
 
3843
- exports.AUTH_ENDPOINTS = AUTH_ENDPOINTS; exports.AlertDisplay = AlertDisplay; exports.AuthEventType = AuthEventType; exports.AuthFlowContainer = AuthFlowContainer; exports.AuthFlowModal = AuthFlowModal; exports.AuthFlowStep = AuthFlowStep; exports.AuthFlowVariant = AuthFlowVariant; exports.AuthInitializer = AuthInitializer; exports.AuthOrchestrator = AuthOrchestrator; exports.AuthOrchestratorFactory = AuthOrchestratorFactory; exports.AuthResultFactory = AuthResultFactory; exports.AuthService = AuthService; exports.AuthenticatedState = AuthenticatedState; exports.AuthenticationStatusContext = AuthenticationStatusContext; exports.BaseErrorHandler = BaseErrorHandler; exports.BaseEventBus = BaseEventBus; exports.BaseForm = BaseForm; exports.BaseService = BaseService; exports.BroadcastChannelEventBus = BroadcastChannelEventBus; exports.Channel = Channel; exports.CookieUtils = CookieUtils; exports.CrossTabBehaviorConfig = CrossTabBehaviorConfig; exports.CrossTabBehaviorHandler = CrossTabBehaviorHandler; exports.CrossTabDemo = CrossTabDemo; exports.DevelopmentLogger = DevelopmentLogger; exports.EMAIL_SUBMISSION_NAVIGATION = EMAIL_SUBMISSION_NAVIGATION; exports.EmailProviderUtils = EmailProviderUtils; exports.EmailStep = EmailStep; exports.EndpointBuilder = EndpointBuilder; exports.ExistingUserLoginStrategy = ExistingUserLoginStrategy; exports.FormFields = FormFields; exports.FormHeader = FormHeader; exports.GenericErrorHandler = GenericErrorHandler; exports.HttpClient = HttpClient; exports.HttpMethod = HttpMethod; exports.LocalStorageUtils = LocalStorageUtils; exports.LoggerFactory = LoggerFactory; exports.LoginFlowStrategyFactory = LoginFlowStrategyFactory; exports.LoginStrategyResolver = LoginStrategyResolver; exports.LoginVerificationStrategy = LoginVerificationStrategy; exports.MiddlewareConfig = MiddlewareConfig; exports.NavigationAction = NavigationAction; exports.NetworkErrorHandler = NetworkErrorHandler; exports.NextAction = NextAction; exports.PASSWORD_SUBMISSION_NAVIGATION = PASSWORD_SUBMISSION_NAVIGATION; exports.PageType = PageType; exports.PageTypePatterns = PageTypePatterns; exports.PasswordInputWithStrength = PasswordInputWithStrength; exports.PasswordStep = PasswordStep; exports.ProductionLogger = ProductionLogger; exports.ProfileStateRenderer = ProfileStateRenderer; exports.ProfileUIState = ProfileUIState; exports.RoleType = RoleType; exports.SignupFlowStrategy = SignupFlowStrategy; exports.StrategyResolutionMode = StrategyResolutionMode; exports.TokenManager = TokenManager; exports.UnauthenticatedState = UnauthenticatedState; exports.UrlUtils = UrlUtils; exports.UserStorageManager = UserStorageManager; exports.VERIFICATION_SUBMISSION_NAVIGATION = VERIFICATION_SUBMISSION_NAVIGATION; exports.ValidationErrorHandler = ValidationErrorHandler; exports.VerificationStep = VerificationStep; exports.config = config; exports.createAuthSteps = createAuthSteps; exports.createPropsFactoryRegistry = createPropsFactoryRegistry; exports.createStepRegistry = createStepRegistry; exports.getAuthPageStepMessage = getAuthPageStepMessage; exports.getEmailField = getEmailField; exports.getForgotPasswordField = getForgotPasswordField; exports.getPasswordField = getPasswordField; exports.getStepForEmailSubmission = getStepForEmailSubmission; exports.getStepForPasswordSubmission = getStepForPasswordSubmission; exports.getStepForVerificationSubmission = getStepForVerificationSubmission; exports.getStepProgressMessage = getStepProgressMessage; exports.getTermsCheckboxField = getTermsCheckboxField; exports.getVerificationField = getVerificationField; exports.isPublicUser = isPublicUser; exports.isPublicUserEmail = isPublicUserEmail; exports.middlewareMatcher = middlewareMatcher; exports.useAuth = useAuth; exports.useAuthActionHandler = useAuthActionHandler; exports.useAuthEventBus = useAuthEventBus; exports.useAuthFlowModal = useAuthFlowModal; exports.useAuthInitializer = useAuthInitializer; exports.useIsAuthenticated = useIsAuthenticated; exports.useLogout = useLogout; exports.usePublicUserSession = usePublicUserSession; exports.useRefreshUser = useRefreshUser; exports.useSharedEventBus = useSharedEventBus; exports.useSignInRequiredParams = useSignInRequiredParams; exports.useStepRegistry = useStepRegistry; exports.useStepRenderer = useStepRenderer; exports.useStepper = useStepper; exports.useUser = useUser; exports.useUserActions = useUserActions; exports.useUserData = useUserData; exports.useUserError = useUserError; exports.useUserLoading = useUserLoading; exports.useUserProfile = useUserProfile; exports.useUserSelectors = useUserSelectors; exports.useUserStore = useUserStore; exports.userSelectors = userSelectors;
3921
+
3922
+ exports.AUTH_ENDPOINTS = AUTH_ENDPOINTS; exports.AlertDisplay = AlertDisplay; exports.AuthEventType = AuthEventType; exports.AuthFlowContainer = AuthFlowContainer; exports.AuthFlowModal = AuthFlowModal; exports.AuthFlowStep = AuthFlowStep; exports.AuthFlowVariant = AuthFlowVariant; exports.AuthInitializer = AuthInitializer; exports.AuthOrchestrator = AuthOrchestrator; exports.AuthOrchestratorFactory = AuthOrchestratorFactory; exports.AuthResultFactory = AuthResultFactory; exports.AuthService = AuthService; exports.AuthenticatedState = AuthenticatedState; exports.AuthenticationStatusContext = AuthenticationStatusContext; exports.BaseErrorHandler = BaseErrorHandler; exports.BaseEventBus = BaseEventBus; exports.BaseForm = BaseForm; exports.BaseService = BaseService; exports.BroadcastChannelEventBus = BroadcastChannelEventBus; exports.Channel = Channel; exports.CookieUtils = CookieUtils; exports.CrossTabBehaviorConfig = CrossTabBehaviorConfig; exports.CrossTabBehaviorHandler = CrossTabBehaviorHandler; exports.CrossTabDemo = CrossTabDemo; exports.DevelopmentLogger = DevelopmentLogger; exports.EMAIL_SUBMISSION_NAVIGATION = EMAIL_SUBMISSION_NAVIGATION; exports.EmailProviderUtils = EmailProviderUtils; exports.EmailStep = EmailStep; exports.EndpointBuilder = EndpointBuilder; exports.ExistingUserLoginStrategy = ExistingUserLoginStrategy; exports.FormFields = FormFields; exports.FormHeader = FormHeader; exports.GenericErrorHandler = GenericErrorHandler; exports.HttpClient = HttpClient; exports.HttpMethod = HttpMethod; exports.LocalStorageUtils = LocalStorageUtils; exports.LoggerFactory = LoggerFactory; exports.LoginFlowStrategyFactory = LoginFlowStrategyFactory; exports.LoginStrategyResolver = LoginStrategyResolver; exports.LoginVerificationStrategy = LoginVerificationStrategy; exports.MiddlewareConfig = MiddlewareConfig; exports.NavigationAction = NavigationAction; exports.NetworkErrorHandler = NetworkErrorHandler; exports.NextAction = NextAction; exports.PASSWORD_SUBMISSION_NAVIGATION = PASSWORD_SUBMISSION_NAVIGATION; exports.PageType = PageType; exports.PageTypePatterns = PageTypePatterns; exports.PasswordInputWithStrength = PasswordInputWithStrength; exports.PasswordStep = PasswordStep; exports.ProductionLogger = ProductionLogger; exports.ProfileStateRenderer = ProfileStateRenderer; exports.ProfileUIState = ProfileUIState; exports.RoleType = RoleType; exports.SignupFlowStrategy = SignupFlowStrategy; exports.StrategyResolutionMode = StrategyResolutionMode; exports.TokenManager = TokenManager; exports.UnauthenticatedState = UnauthenticatedState; exports.UrlCleanupHandler = UrlCleanupHandler; exports.UrlUtils = UrlUtils; exports.UserStorageManager = UserStorageManager; exports.VERIFICATION_SUBMISSION_NAVIGATION = VERIFICATION_SUBMISSION_NAVIGATION; exports.ValidationErrorHandler = ValidationErrorHandler; exports.VerificationStep = VerificationStep; exports.config = config; exports.createAuthSteps = createAuthSteps; exports.createPropsFactoryRegistry = createPropsFactoryRegistry; exports.createStepRegistry = createStepRegistry; exports.getAuthPageStepMessage = getAuthPageStepMessage; exports.getEmailField = getEmailField; exports.getForgotPasswordField = getForgotPasswordField; exports.getPasswordField = getPasswordField; exports.getStepForEmailSubmission = getStepForEmailSubmission; exports.getStepForPasswordSubmission = getStepForPasswordSubmission; exports.getStepForVerificationSubmission = getStepForVerificationSubmission; exports.getStepProgressMessage = getStepProgressMessage; exports.getTermsCheckboxField = getTermsCheckboxField; exports.getVerificationField = getVerificationField; exports.isPublicUser = isPublicUser; exports.isPublicUserEmail = isPublicUserEmail; exports.middlewareMatcher = middlewareMatcher; exports.useAuth = useAuth; exports.useAuthActionHandler = useAuthActionHandler; exports.useAuthEventBus = useAuthEventBus; exports.useAuthFlowModal = useAuthFlowModal; exports.useAuthInitializer = useAuthInitializer; exports.useIsAuthenticated = useIsAuthenticated; exports.useLogout = useLogout; exports.usePublicUserSession = usePublicUserSession; exports.useRefreshUser = useRefreshUser; exports.useSharedEventBus = useSharedEventBus; exports.useSignInRequiredParams = useSignInRequiredParams; exports.useStepRegistry = useStepRegistry; exports.useStepRenderer = useStepRenderer; exports.useStepper = useStepper; exports.useUser = useUser; exports.useUserActions = useUserActions; exports.useUserData = useUserData; exports.useUserError = useUserError; exports.useUserLoading = useUserLoading; exports.useUserProfile = useUserProfile; exports.useUserSelectors = useUserSelectors; exports.useUserStore = useUserStore; exports.userSelectors = userSelectors;
3844
3923
  /*! Bundled license information:
3845
3924
 
3846
3925
  js-cookie/dist/js.cookie.mjs:
package/dist/index.mjs CHANGED
@@ -100,6 +100,7 @@ var PageType = /* @__PURE__ */ ((PageType4) => {
100
100
  var NavigationAction = /* @__PURE__ */ ((NavigationAction2) => {
101
101
  NavigationAction2["NONE"] = "none";
102
102
  NavigationAction2["RELOAD"] = "reload";
103
+ NavigationAction2["RELOAD_CLEAN_URL"] = "reload_clean_url";
103
104
  return NavigationAction2;
104
105
  })(NavigationAction || {});
105
106
  var PageTypePatterns = {
@@ -116,7 +117,7 @@ var CrossTabBehaviorConfig = {
116
117
  },
117
118
  ["dashboard" /* DASHBOARD */]: {
118
119
  ["auth.logged_in" /* LoggedIn */]: { action: "reload" /* RELOAD */ },
119
- ["auth.logged_out" /* LoggedOut */]: { action: "reload" /* RELOAD */ },
120
+ ["auth.logged_out" /* LoggedOut */]: { action: "reload_clean_url" /* RELOAD_CLEAN_URL */ },
120
121
  ["auth.email_verified" /* EmailVerified */]: { action: "none" /* NONE */ },
121
122
  ["auth.signin_required_modal" /* SignInRequiredModal */]: { action: "none" /* NONE */ }
122
123
  },
@@ -1005,6 +1006,104 @@ function useStepRegistry({
1005
1006
  // src/hooks/useAuthEventBus.ts
1006
1007
  import { useEffect as useEffect4 } from "react";
1007
1008
 
1009
+ // node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.mjs
1010
+ function assign(target) {
1011
+ for (var i = 1; i < arguments.length; i++) {
1012
+ var source = arguments[i];
1013
+ for (var key in source) {
1014
+ target[key] = source[key];
1015
+ }
1016
+ }
1017
+ return target;
1018
+ }
1019
+ var defaultConverter = {
1020
+ read: function(value) {
1021
+ if (value[0] === '"') {
1022
+ value = value.slice(1, -1);
1023
+ }
1024
+ return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
1025
+ },
1026
+ write: function(value) {
1027
+ return encodeURIComponent(value).replace(
1028
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
1029
+ decodeURIComponent
1030
+ );
1031
+ }
1032
+ };
1033
+ function init(converter, defaultAttributes) {
1034
+ function set(name, value, attributes) {
1035
+ if (typeof document === "undefined") {
1036
+ return;
1037
+ }
1038
+ attributes = assign({}, defaultAttributes, attributes);
1039
+ if (typeof attributes.expires === "number") {
1040
+ attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
1041
+ }
1042
+ if (attributes.expires) {
1043
+ attributes.expires = attributes.expires.toUTCString();
1044
+ }
1045
+ name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
1046
+ var stringifiedAttributes = "";
1047
+ for (var attributeName in attributes) {
1048
+ if (!attributes[attributeName]) {
1049
+ continue;
1050
+ }
1051
+ stringifiedAttributes += "; " + attributeName;
1052
+ if (attributes[attributeName] === true) {
1053
+ continue;
1054
+ }
1055
+ stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
1056
+ }
1057
+ return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
1058
+ }
1059
+ function get(name) {
1060
+ if (typeof document === "undefined" || arguments.length && !name) {
1061
+ return;
1062
+ }
1063
+ var cookies = document.cookie ? document.cookie.split("; ") : [];
1064
+ var jar = {};
1065
+ for (var i = 0; i < cookies.length; i++) {
1066
+ var parts = cookies[i].split("=");
1067
+ var value = parts.slice(1).join("=");
1068
+ try {
1069
+ var found = decodeURIComponent(parts[0]);
1070
+ jar[found] = converter.read(value, found);
1071
+ if (name === found) {
1072
+ break;
1073
+ }
1074
+ } catch (e) {
1075
+ }
1076
+ }
1077
+ return name ? jar[name] : jar;
1078
+ }
1079
+ return Object.create(
1080
+ {
1081
+ set,
1082
+ get,
1083
+ remove: function(name, attributes) {
1084
+ set(
1085
+ name,
1086
+ "",
1087
+ assign({}, attributes, {
1088
+ expires: -1
1089
+ })
1090
+ );
1091
+ },
1092
+ withAttributes: function(attributes) {
1093
+ return init(this.converter, assign({}, this.attributes, attributes));
1094
+ },
1095
+ withConverter: function(converter2) {
1096
+ return init(assign({}, this.converter, converter2), this.attributes);
1097
+ }
1098
+ },
1099
+ {
1100
+ attributes: { value: Object.freeze(defaultAttributes) },
1101
+ converter: { value: Object.freeze(converter) }
1102
+ }
1103
+ );
1104
+ }
1105
+ var api = init(defaultConverter, { path: "/" });
1106
+
1008
1107
  // src/config/middleware.ts
1009
1108
  var _MiddlewareConfig = class _MiddlewareConfig {
1010
1109
  // Route Protection Configuration
@@ -1122,236 +1221,6 @@ var UrlUtils = class {
1122
1221
  }
1123
1222
  };
1124
1223
 
1125
- // src/services/utils/cross-tab-behavior-handler.ts
1126
- var CrossTabBehaviorHandler = class {
1127
- /**
1128
- * Get current page type using object lookup pattern
1129
- */
1130
- static getCurrentPageType() {
1131
- var _a;
1132
- if (typeof window === "undefined") return "/" /* HOME */;
1133
- try {
1134
- const pathname = window.location.pathname;
1135
- const subdomain = UrlUtils.getSubdomain(window.location.hostname);
1136
- const pageTypeMatchers = {
1137
- ["/login" /* LOGIN */]: pathname === MiddlewareConfig.CONSTANTS.LOGIN_PATH,
1138
- ["dashboard" /* DASHBOARD */]: subdomain === MiddlewareConfig.CONSTANTS.DASHBOARD_SUBDOMAIN
1139
- };
1140
- const matchedPageType = (_a = Object.entries(pageTypeMatchers).find(([, matches]) => matches)) == null ? void 0 : _a[0];
1141
- return matchedPageType != null ? matchedPageType : "dashboard" /* DASHBOARD */;
1142
- } catch (e) {
1143
- return "dashboard" /* DASHBOARD */;
1144
- }
1145
- }
1146
- /**
1147
- * Get the action configuration for current route and event
1148
- */
1149
- static getAction(currentPageType, eventType) {
1150
- var _a, _b;
1151
- return (_b = (_a = CrossTabBehaviorConfig[currentPageType]) == null ? void 0 : _a[eventType]) != null ? _b : { action: "none" /* NONE */ };
1152
- }
1153
- };
1154
-
1155
- // src/hooks/useSharedEventBus.ts
1156
- import { useMemo as useMemo5 } from "react";
1157
-
1158
- // src/services/utils/event-bus.ts
1159
- var REGISTRY_KEY = "__bc_event_buses__";
1160
- function getRegistry() {
1161
- const g = globalThis;
1162
- if (!g[REGISTRY_KEY]) {
1163
- g[REGISTRY_KEY] = /* @__PURE__ */ new Map();
1164
- }
1165
- return g[REGISTRY_KEY];
1166
- }
1167
- function isBroadcastChannelSupported() {
1168
- return typeof window !== "undefined" && "BroadcastChannel" in window && typeof BroadcastChannel === "function";
1169
- }
1170
- var BroadcastChannelEventBus = class _BroadcastChannelEventBus {
1171
- constructor(name) {
1172
- this.listeners = /* @__PURE__ */ new Set();
1173
- this.name = name;
1174
- if (isBroadcastChannelSupported()) {
1175
- try {
1176
- const BC = globalThis.BroadcastChannel;
1177
- if (BC) {
1178
- const channel = new BC(name);
1179
- channel.onmessage = (ev) => this.emit(ev.data);
1180
- this.channel = channel;
1181
- }
1182
- } catch (error) {
1183
- console.warn("Failed to create BroadcastChannel:", error);
1184
- }
1185
- }
1186
- }
1187
- static getInstance(name) {
1188
- const registry = getRegistry();
1189
- let bus = registry.get(name);
1190
- if (!bus) {
1191
- bus = new _BroadcastChannelEventBus(name);
1192
- registry.set(name, bus);
1193
- }
1194
- return bus;
1195
- }
1196
- publish(event) {
1197
- var _a;
1198
- this.emit(event);
1199
- (_a = this.channel) == null ? void 0 : _a.postMessage(event);
1200
- }
1201
- subscribe(handler) {
1202
- this.listeners.add(handler);
1203
- return { unsubscribe: () => this.listeners.delete(handler) };
1204
- }
1205
- emit(e) {
1206
- for (const h of this.listeners) h(e);
1207
- }
1208
- close() {
1209
- var _a;
1210
- (_a = this.channel) == null ? void 0 : _a.close();
1211
- this.listeners.clear();
1212
- getRegistry().delete(this.name);
1213
- }
1214
- };
1215
-
1216
- // src/hooks/useSharedEventBus.ts
1217
- function useSharedEventBus() {
1218
- return useMemo5(() => BroadcastChannelEventBus.getInstance("auth-event-channel" /* AUTH */), []);
1219
- }
1220
-
1221
- // src/hooks/useAuthEventBus.ts
1222
- var useAuthEventBus = ({ onLoggedOut, onLoggedIn } = {}) => {
1223
- const eventBus = useSharedEventBus();
1224
- useEffect4(() => {
1225
- const handleEvent = (e) => {
1226
- var _a;
1227
- const currentPageType = CrossTabBehaviorHandler.getCurrentPageType();
1228
- const eventHandlers = {
1229
- ["auth.logged_out" /* LoggedOut */]: onLoggedOut,
1230
- ["auth.logged_in" /* LoggedIn */]: onLoggedIn,
1231
- ["auth.email_verified" /* EmailVerified */]: void 0,
1232
- ["auth.signin_required_modal" /* SignInRequiredModal */]: void 0
1233
- };
1234
- const handler = eventHandlers[e.type];
1235
- const action = CrossTabBehaviorHandler.getAction(currentPageType, e.type);
1236
- const actionHandlers = {
1237
- ["reload" /* RELOAD */]: () => {
1238
- window.location.replace(window.location.href);
1239
- },
1240
- ["none" /* NONE */]: () => {
1241
- }
1242
- };
1243
- (_a = actionHandlers[action.action]) == null ? void 0 : _a.call(actionHandlers);
1244
- handler == null ? void 0 : handler();
1245
- };
1246
- const subscription = eventBus.subscribe(handleEvent);
1247
- return () => {
1248
- subscription.unsubscribe();
1249
- };
1250
- }, [eventBus, onLoggedOut, onLoggedIn]);
1251
- };
1252
-
1253
- // src/hooks/useSignInRequiredParams.ts
1254
- import { useEffect as useEffect5 } from "react";
1255
- import { useSearchParams } from "next/navigation";
1256
-
1257
- // node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.mjs
1258
- function assign(target) {
1259
- for (var i = 1; i < arguments.length; i++) {
1260
- var source = arguments[i];
1261
- for (var key in source) {
1262
- target[key] = source[key];
1263
- }
1264
- }
1265
- return target;
1266
- }
1267
- var defaultConverter = {
1268
- read: function(value) {
1269
- if (value[0] === '"') {
1270
- value = value.slice(1, -1);
1271
- }
1272
- return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
1273
- },
1274
- write: function(value) {
1275
- return encodeURIComponent(value).replace(
1276
- /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
1277
- decodeURIComponent
1278
- );
1279
- }
1280
- };
1281
- function init(converter, defaultAttributes) {
1282
- function set(name, value, attributes) {
1283
- if (typeof document === "undefined") {
1284
- return;
1285
- }
1286
- attributes = assign({}, defaultAttributes, attributes);
1287
- if (typeof attributes.expires === "number") {
1288
- attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
1289
- }
1290
- if (attributes.expires) {
1291
- attributes.expires = attributes.expires.toUTCString();
1292
- }
1293
- name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
1294
- var stringifiedAttributes = "";
1295
- for (var attributeName in attributes) {
1296
- if (!attributes[attributeName]) {
1297
- continue;
1298
- }
1299
- stringifiedAttributes += "; " + attributeName;
1300
- if (attributes[attributeName] === true) {
1301
- continue;
1302
- }
1303
- stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
1304
- }
1305
- return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
1306
- }
1307
- function get(name) {
1308
- if (typeof document === "undefined" || arguments.length && !name) {
1309
- return;
1310
- }
1311
- var cookies = document.cookie ? document.cookie.split("; ") : [];
1312
- var jar = {};
1313
- for (var i = 0; i < cookies.length; i++) {
1314
- var parts = cookies[i].split("=");
1315
- var value = parts.slice(1).join("=");
1316
- try {
1317
- var found = decodeURIComponent(parts[0]);
1318
- jar[found] = converter.read(value, found);
1319
- if (name === found) {
1320
- break;
1321
- }
1322
- } catch (e) {
1323
- }
1324
- }
1325
- return name ? jar[name] : jar;
1326
- }
1327
- return Object.create(
1328
- {
1329
- set,
1330
- get,
1331
- remove: function(name, attributes) {
1332
- set(
1333
- name,
1334
- "",
1335
- assign({}, attributes, {
1336
- expires: -1
1337
- })
1338
- );
1339
- },
1340
- withAttributes: function(attributes) {
1341
- return init(this.converter, assign({}, this.attributes, attributes));
1342
- },
1343
- withConverter: function(converter2) {
1344
- return init(assign({}, this.converter, converter2), this.attributes);
1345
- }
1346
- },
1347
- {
1348
- attributes: { value: Object.freeze(defaultAttributes) },
1349
- converter: { value: Object.freeze(converter) }
1350
- }
1351
- );
1352
- }
1353
- var api = init(defaultConverter, { path: "/" });
1354
-
1355
1224
  // src/services/utils/cookie-utils.ts
1356
1225
  var _CookieUtils = class _CookieUtils {
1357
1226
  /**
@@ -1658,6 +1527,94 @@ LocalStorageUtils.USER_PROFILE_STORAGE_KEY = "user_profile_data";
1658
1527
  LocalStorageUtils.USER_PROFILE_TIMESTAMP_KEY = "user_profile_timestamp";
1659
1528
  LocalStorageUtils.DEFAULT_CACHE_DURATION = 5 * 60 * 1e3;
1660
1529
 
1530
+ // src/services/utils/event-bus.ts
1531
+ var REGISTRY_KEY = "__bc_event_buses__";
1532
+ function getRegistry() {
1533
+ const g = globalThis;
1534
+ if (!g[REGISTRY_KEY]) {
1535
+ g[REGISTRY_KEY] = /* @__PURE__ */ new Map();
1536
+ }
1537
+ return g[REGISTRY_KEY];
1538
+ }
1539
+ function isBroadcastChannelSupported() {
1540
+ return typeof window !== "undefined" && "BroadcastChannel" in window && typeof BroadcastChannel === "function";
1541
+ }
1542
+ var BroadcastChannelEventBus = class _BroadcastChannelEventBus {
1543
+ constructor(name) {
1544
+ this.listeners = /* @__PURE__ */ new Set();
1545
+ this.name = name;
1546
+ if (isBroadcastChannelSupported()) {
1547
+ try {
1548
+ const BC = globalThis.BroadcastChannel;
1549
+ if (BC) {
1550
+ const channel = new BC(name);
1551
+ channel.onmessage = (ev) => this.emit(ev.data);
1552
+ this.channel = channel;
1553
+ }
1554
+ } catch (error) {
1555
+ console.warn("Failed to create BroadcastChannel:", error);
1556
+ }
1557
+ }
1558
+ }
1559
+ static getInstance(name) {
1560
+ const registry = getRegistry();
1561
+ let bus = registry.get(name);
1562
+ if (!bus) {
1563
+ bus = new _BroadcastChannelEventBus(name);
1564
+ registry.set(name, bus);
1565
+ }
1566
+ return bus;
1567
+ }
1568
+ publish(event) {
1569
+ var _a;
1570
+ this.emit(event);
1571
+ (_a = this.channel) == null ? void 0 : _a.postMessage(event);
1572
+ }
1573
+ subscribe(handler) {
1574
+ this.listeners.add(handler);
1575
+ return { unsubscribe: () => this.listeners.delete(handler) };
1576
+ }
1577
+ emit(e) {
1578
+ for (const h of this.listeners) h(e);
1579
+ }
1580
+ close() {
1581
+ var _a;
1582
+ (_a = this.channel) == null ? void 0 : _a.close();
1583
+ this.listeners.clear();
1584
+ getRegistry().delete(this.name);
1585
+ }
1586
+ };
1587
+
1588
+ // src/services/utils/cross-tab-behavior-handler.ts
1589
+ var CrossTabBehaviorHandler = class {
1590
+ /**
1591
+ * Get current page type using object lookup pattern
1592
+ */
1593
+ static getCurrentPageType() {
1594
+ var _a;
1595
+ if (typeof window === "undefined") return "/" /* HOME */;
1596
+ try {
1597
+ const pathname = window.location.pathname;
1598
+ const subdomain = UrlUtils.getSubdomain(window.location.hostname);
1599
+ const pageTypeMatchers = {
1600
+ ["/login" /* LOGIN */]: pathname === MiddlewareConfig.CONSTANTS.LOGIN_PATH,
1601
+ ["dashboard" /* DASHBOARD */]: subdomain === MiddlewareConfig.CONSTANTS.DASHBOARD_SUBDOMAIN
1602
+ };
1603
+ const matchedPageType = (_a = Object.entries(pageTypeMatchers).find(([, matches]) => matches)) == null ? void 0 : _a[0];
1604
+ return matchedPageType != null ? matchedPageType : "dashboard" /* DASHBOARD */;
1605
+ } catch (e) {
1606
+ return "dashboard" /* DASHBOARD */;
1607
+ }
1608
+ }
1609
+ /**
1610
+ * Get the action configuration for current route and event
1611
+ */
1612
+ static getAction(currentPageType, eventType) {
1613
+ var _a, _b;
1614
+ return (_b = (_a = CrossTabBehaviorConfig[currentPageType]) == null ? void 0 : _a[eventType]) != null ? _b : { action: "none" /* NONE */ };
1615
+ }
1616
+ };
1617
+
1661
1618
  // src/services/utils/email-provider-utils.ts
1662
1619
  var EMAIL_PROVIDERS = [
1663
1620
  {
@@ -1735,6 +1692,83 @@ var EmailProviderUtils = class {
1735
1692
  }
1736
1693
  };
1737
1694
 
1695
+ // src/services/utils/url-cleanup-handler.ts
1696
+ var CleanupStrategy = class {
1697
+ constructor(routes) {
1698
+ this.routes = routes;
1699
+ }
1700
+ matches(pathname) {
1701
+ return this.routes.some((route) => this.isMatch(pathname, route));
1702
+ }
1703
+ isMatch(pathname, route) {
1704
+ if (route === pathname) return true;
1705
+ if (route.endsWith("/*")) {
1706
+ return pathname.startsWith(route.slice(0, -2));
1707
+ }
1708
+ return false;
1709
+ }
1710
+ };
1711
+ var RemoveParamsStrategy = class extends CleanupStrategy {
1712
+ constructor(routes, params) {
1713
+ super(routes);
1714
+ this.params = params;
1715
+ }
1716
+ clean(url) {
1717
+ const cleaned = new URL(url);
1718
+ this.params.forEach((param) => cleaned.searchParams.delete(param));
1719
+ return cleaned;
1720
+ }
1721
+ };
1722
+ var StrategyFactory = class {
1723
+ static fromConfig(config2) {
1724
+ return Object.entries(config2).map(
1725
+ ([route, params]) => new RemoveParamsStrategy([route], params)
1726
+ );
1727
+ }
1728
+ };
1729
+ var getRouteConfig = () => {
1730
+ const envConfig = process.env.NEXT_PUBLIC_URL_CLEANUP_ROUTES;
1731
+ if (!envConfig) {
1732
+ return {};
1733
+ }
1734
+ try {
1735
+ return JSON.parse(envConfig);
1736
+ } catch (error) {
1737
+ console.error("Failed to parse NEXT_PUBLIC_URL_CLEANUP_ROUTES:", error);
1738
+ return {};
1739
+ }
1740
+ };
1741
+ var ROUTE_CONFIG = getRouteConfig();
1742
+ var EVENT_STRATEGIES = {
1743
+ ["auth.logged_out" /* LoggedOut */]: StrategyFactory.fromConfig(ROUTE_CONFIG),
1744
+ ["auth.logged_in" /* LoggedIn */]: [],
1745
+ ["auth.email_verified" /* EmailVerified */]: [],
1746
+ ["auth.signin_required_modal" /* SignInRequiredModal */]: []
1747
+ };
1748
+ var UrlCleanupHandler = class {
1749
+ /**
1750
+ * Execute cleanup for given event type and current URL
1751
+ * @returns Cleaned URL string if changes made, null otherwise
1752
+ */
1753
+ static cleanup(eventType, currentUrl) {
1754
+ if (typeof window === "undefined") return null;
1755
+ const url = new URL(currentUrl != null ? currentUrl : window.location.href);
1756
+ const strategy = this.findStrategy(eventType, url.pathname);
1757
+ if (!strategy) return null;
1758
+ const cleaned = strategy.clean(url);
1759
+ return cleaned.href !== url.href ? cleaned.href : null;
1760
+ }
1761
+ /**
1762
+ * Find applicable strategy for event type and pathname
1763
+ * DRY Principle: Centralized strategy lookup logic
1764
+ */
1765
+ static findStrategy(eventType, pathname) {
1766
+ var _a, _b;
1767
+ const strategies = (_a = EVENT_STRATEGIES[eventType]) != null ? _a : [];
1768
+ return (_b = strategies.find((s) => s.matches(pathname))) != null ? _b : null;
1769
+ }
1770
+ };
1771
+
1738
1772
  // src/services/auth/manager/token-manager.ts
1739
1773
  var TokenManager = class {
1740
1774
  constructor(cookieUtils) {
@@ -2690,7 +2724,51 @@ var AuthOrchestratorFactory = class {
2690
2724
  }
2691
2725
  };
2692
2726
 
2727
+ // src/hooks/useSharedEventBus.ts
2728
+ import { useMemo as useMemo5 } from "react";
2729
+ function useSharedEventBus() {
2730
+ return useMemo5(() => BroadcastChannelEventBus.getInstance("auth-event-channel" /* AUTH */), []);
2731
+ }
2732
+
2733
+ // src/hooks/useAuthEventBus.ts
2734
+ var useAuthEventBus = ({ onLoggedOut, onLoggedIn } = {}) => {
2735
+ const eventBus = useSharedEventBus();
2736
+ useEffect4(() => {
2737
+ const handleEvent = (e) => {
2738
+ var _a;
2739
+ const currentPageType = CrossTabBehaviorHandler.getCurrentPageType();
2740
+ const eventHandlers = {
2741
+ ["auth.logged_out" /* LoggedOut */]: onLoggedOut,
2742
+ ["auth.logged_in" /* LoggedIn */]: onLoggedIn,
2743
+ ["auth.email_verified" /* EmailVerified */]: void 0,
2744
+ ["auth.signin_required_modal" /* SignInRequiredModal */]: void 0
2745
+ };
2746
+ const handler = eventHandlers[e.type];
2747
+ const action = CrossTabBehaviorHandler.getAction(currentPageType, e.type);
2748
+ const actionHandlers = {
2749
+ ["reload" /* RELOAD */]: () => {
2750
+ window.location.replace(window.location.href);
2751
+ },
2752
+ ["reload_clean_url" /* RELOAD_CLEAN_URL */]: () => {
2753
+ const cleanedUrl = UrlCleanupHandler.cleanup(e.type);
2754
+ window.location.replace(cleanedUrl != null ? cleanedUrl : window.location.href);
2755
+ },
2756
+ ["none" /* NONE */]: () => {
2757
+ }
2758
+ };
2759
+ (_a = actionHandlers[action.action]) == null ? void 0 : _a.call(actionHandlers);
2760
+ handler == null ? void 0 : handler();
2761
+ };
2762
+ const subscription = eventBus.subscribe(handleEvent);
2763
+ return () => {
2764
+ subscription.unsubscribe();
2765
+ };
2766
+ }, [eventBus, onLoggedOut, onLoggedIn]);
2767
+ };
2768
+
2693
2769
  // src/hooks/useSignInRequiredParams.ts
2770
+ import { useEffect as useEffect5 } from "react";
2771
+ import { useSearchParams } from "next/navigation";
2694
2772
  function useSignInRequiredParams() {
2695
2773
  const searchParams = useSearchParams();
2696
2774
  const eventBus = useSharedEventBus();
@@ -3795,6 +3873,7 @@ export {
3795
3873
  StrategyResolutionMode,
3796
3874
  TokenManager,
3797
3875
  UnauthenticatedState,
3876
+ UrlCleanupHandler,
3798
3877
  UrlUtils,
3799
3878
  UserStorageManager,
3800
3879
  VERIFICATION_SUBMISSION_NAVIGATION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailsentry-auth",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Next.js 15 authentication package with multi-step auth flow, cross-tab sync, and Zustand state management",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",