mailsentry-auth 0.2.7 → 0.2.8

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
@@ -518,6 +518,10 @@ declare abstract class BaseService {
518
518
  * Create generic API error as fallback
519
519
  */
520
520
  private createGenericApiError;
521
+ /**
522
+ * Helper method for common request logic
523
+ */
524
+ private executeRequest;
521
525
  /**
522
526
  * GET request
523
527
  */
@@ -743,9 +747,10 @@ declare abstract class BaseErrorHandler implements IErrorHandler {
743
747
  }
744
748
 
745
749
  /**
746
- * Validation Error Handler
750
+ * API Error Handler
751
+ * Handles specific ApiError instances thrown by the HTTP client
747
752
  */
748
- declare class ValidationErrorHandler extends BaseErrorHandler {
753
+ declare class ApiErrorHandler extends BaseErrorHandler {
749
754
  protected canHandle(error: unknown): boolean;
750
755
  protected handleError(error: unknown, context: string): AuthActionResult;
751
756
  }
@@ -758,14 +763,6 @@ declare class NetworkErrorHandler extends BaseErrorHandler {
758
763
  protected handleError(error: unknown, context: string): AuthActionResult;
759
764
  }
760
765
 
761
- /**
762
- * Generic Error Handler
763
- */
764
- declare class GenericErrorHandler extends BaseErrorHandler {
765
- protected canHandle(): boolean;
766
- protected handleError(error: unknown, context: string): AuthActionResult;
767
- }
768
-
769
766
  /**
770
767
  * Development Logger Implementation
771
768
  */
@@ -1781,4 +1778,4 @@ declare const useAuthFlowModal: () => {
1781
1778
  openModal: () => void;
1782
1779
  };
1783
1780
 
1784
- 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 ProtectionRule, 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 };
1781
+ export { AUTH_ENDPOINTS, AlertDisplay, type AlertDisplayProps, type AnyStepProps, ApiErrorHandler, 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, 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 ProtectionRule, 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, 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
@@ -518,6 +518,10 @@ declare abstract class BaseService {
518
518
  * Create generic API error as fallback
519
519
  */
520
520
  private createGenericApiError;
521
+ /**
522
+ * Helper method for common request logic
523
+ */
524
+ private executeRequest;
521
525
  /**
522
526
  * GET request
523
527
  */
@@ -743,9 +747,10 @@ declare abstract class BaseErrorHandler implements IErrorHandler {
743
747
  }
744
748
 
745
749
  /**
746
- * Validation Error Handler
750
+ * API Error Handler
751
+ * Handles specific ApiError instances thrown by the HTTP client
747
752
  */
748
- declare class ValidationErrorHandler extends BaseErrorHandler {
753
+ declare class ApiErrorHandler extends BaseErrorHandler {
749
754
  protected canHandle(error: unknown): boolean;
750
755
  protected handleError(error: unknown, context: string): AuthActionResult;
751
756
  }
@@ -758,14 +763,6 @@ declare class NetworkErrorHandler extends BaseErrorHandler {
758
763
  protected handleError(error: unknown, context: string): AuthActionResult;
759
764
  }
760
765
 
761
- /**
762
- * Generic Error Handler
763
- */
764
- declare class GenericErrorHandler extends BaseErrorHandler {
765
- protected canHandle(): boolean;
766
- protected handleError(error: unknown, context: string): AuthActionResult;
767
- }
768
-
769
766
  /**
770
767
  * Development Logger Implementation
771
768
  */
@@ -1781,4 +1778,4 @@ declare const useAuthFlowModal: () => {
1781
1778
  openModal: () => void;
1782
1779
  };
1783
1780
 
1784
- 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 ProtectionRule, 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 };
1781
+ export { AUTH_ENDPOINTS, AlertDisplay, type AlertDisplayProps, type AnyStepProps, ApiErrorHandler, 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, 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 ProtectionRule, 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, 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
@@ -91,11 +91,11 @@ var AuthEventType = /* @__PURE__ */ ((AuthEventType3) => {
91
91
  AuthEventType3["SignInRequiredModal"] = "auth.signin_required_modal";
92
92
  return AuthEventType3;
93
93
  })(AuthEventType || {});
94
- var PageType = /* @__PURE__ */ ((PageType4) => {
95
- PageType4["LOGIN"] = "/login";
96
- PageType4["DASHBOARD"] = "dashboard";
97
- PageType4["HOME"] = "/";
98
- return PageType4;
94
+ var PageType = /* @__PURE__ */ ((PageType3) => {
95
+ PageType3["LOGIN"] = "/login";
96
+ PageType3["DASHBOARD"] = "dashboard";
97
+ PageType3["HOME"] = "/";
98
+ return PageType3;
99
99
  })(PageType || {});
100
100
  var NavigationAction = /* @__PURE__ */ ((NavigationAction2) => {
101
101
  NavigationAction2["NONE"] = "none";
@@ -803,8 +803,8 @@ var useAuthActionHandler = () => {
803
803
  const clearAll = _react.useCallback.call(void 0, () => {
804
804
  setState((prev) => __spreadProps(__spreadValues({}, prev), { error: null, success: null }));
805
805
  }, []);
806
- const setSuccess = _react.useCallback.call(void 0, (message) => {
807
- setState((prev) => __spreadProps(__spreadValues({}, prev), { success: message, error: null }));
806
+ const setSuccess = _react.useCallback.call(void 0, (message2) => {
807
+ setState((prev) => __spreadProps(__spreadValues({}, prev), { success: message2, error: null }));
808
808
  }, []);
809
809
  const setError = _react.useCallback.call(void 0, (error) => {
810
810
  setState((prev) => __spreadProps(__spreadValues({}, prev), { error, success: null }));
@@ -1828,6 +1828,33 @@ var TokenManager = class {
1828
1828
  }
1829
1829
  };
1830
1830
 
1831
+ // src/services/api/api-error-mapper.ts
1832
+ var API_ERROR_CODES = {
1833
+ // Auth Errors
1834
+ 5207: "The password you entered is incorrect. Please try again.",
1835
+ 5070: "Password must be strong. Please use a stronger password."
1836
+ };
1837
+ function getErrorMessage(code, defaultMessage = "An unexpected error occurred") {
1838
+ const numericCode = Number(code);
1839
+ return API_ERROR_CODES[numericCode] || defaultMessage;
1840
+ }
1841
+ function parseNestedApiError(data) {
1842
+ if (!data || typeof data !== "object") {
1843
+ return null;
1844
+ }
1845
+ const errorData = data;
1846
+ if (errorData.message && typeof errorData.message === "object" && "statusCode" in errorData.message) {
1847
+ const customCode = errorData.message.statusCode;
1848
+ const technicalMessage = errorData.message.message;
1849
+ return {
1850
+ code: customCode,
1851
+ message: getErrorMessage(customCode, technicalMessage),
1852
+ originalError: errorData
1853
+ };
1854
+ }
1855
+ return null;
1856
+ }
1857
+
1831
1858
  // src/services/api/base-service.ts
1832
1859
  var HttpClient = class {
1833
1860
  constructor(config2) {
@@ -1898,12 +1925,13 @@ var HttpClient = class {
1898
1925
  }
1899
1926
  };
1900
1927
  var ApiError = class extends Error {
1901
- constructor(message, status, statusText, apiError) {
1902
- super(message);
1903
- this.name = "ApiError";
1928
+ constructor(message2, status, statusText, apiError) {
1929
+ super(message2);
1930
+ this.message = message2;
1904
1931
  this.status = status;
1905
1932
  this.statusText = statusText;
1906
1933
  this.apiError = apiError;
1934
+ this.name = "ApiError";
1907
1935
  }
1908
1936
  };
1909
1937
  var BaseService = class {
@@ -1947,16 +1975,21 @@ var BaseService = class {
1947
1975
  */
1948
1976
  createApiErrorFromResponse(response) {
1949
1977
  const parsedError = this.tryParseApiErrorResponse(response.data);
1950
- if (parsedError) {
1951
- return parsedError;
1952
- }
1953
- return this.createGenericApiError(response);
1978
+ return parsedError || this.createGenericApiError(response);
1954
1979
  }
1955
1980
  /**
1956
1981
  * Try to parse API error response from response data
1957
1982
  */
1958
1983
  tryParseApiErrorResponse(data) {
1959
1984
  try {
1985
+ const nestedError = parseNestedApiError(data);
1986
+ if (nestedError) {
1987
+ return {
1988
+ message: nestedError.message,
1989
+ error: "ApiError",
1990
+ statusCode: nestedError.code
1991
+ };
1992
+ }
1960
1993
  const responseData = data;
1961
1994
  if (this.isValidApiErrorResponse(responseData)) {
1962
1995
  return __spreadValues({
@@ -1987,62 +2020,46 @@ var BaseService = class {
1987
2020
  };
1988
2021
  }
1989
2022
  /**
1990
- * GET request
2023
+ * Helper method for common request logic
1991
2024
  */
1992
- async get(endpoint, headers) {
2025
+ async executeRequest(method, endpoint, body, headers) {
1993
2026
  const response = await this.httpClient.request(endpoint, {
1994
- method: "GET" /* GET */,
2027
+ method,
1995
2028
  url: endpoint,
1996
- headers
2029
+ headers,
2030
+ body
1997
2031
  });
1998
2032
  return this.handleResponse(response);
1999
2033
  }
2034
+ /**
2035
+ * GET request
2036
+ */
2037
+ async get(endpoint, headers) {
2038
+ return this.executeRequest("GET" /* GET */, endpoint, void 0, headers);
2039
+ }
2000
2040
  /**
2001
2041
  * POST request
2002
2042
  */
2003
2043
  async post(endpoint, body, headers) {
2004
- const response = await this.httpClient.request(endpoint, {
2005
- method: "POST" /* POST */,
2006
- url: endpoint,
2007
- headers,
2008
- body
2009
- });
2010
- return this.handleResponse(response);
2044
+ return this.executeRequest("POST" /* POST */, endpoint, body, headers);
2011
2045
  }
2012
2046
  /**
2013
2047
  * PUT request
2014
2048
  */
2015
2049
  async put(endpoint, body, headers) {
2016
- const response = await this.httpClient.request(endpoint, {
2017
- method: "PUT" /* PUT */,
2018
- url: endpoint,
2019
- headers,
2020
- body
2021
- });
2022
- return this.handleResponse(response);
2050
+ return this.executeRequest("PUT" /* PUT */, endpoint, body, headers);
2023
2051
  }
2024
2052
  /**
2025
2053
  * DELETE request
2026
2054
  */
2027
2055
  async delete(endpoint, headers) {
2028
- const response = await this.httpClient.request(endpoint, {
2029
- method: "DELETE" /* DELETE */,
2030
- url: endpoint,
2031
- headers
2032
- });
2033
- return this.handleResponse(response);
2056
+ return this.executeRequest("DELETE" /* DELETE */, endpoint, void 0, headers);
2034
2057
  }
2035
2058
  /**
2036
2059
  * PATCH request
2037
2060
  */
2038
2061
  async patch(endpoint, body, headers) {
2039
- const response = await this.httpClient.request(endpoint, {
2040
- method: "PATCH" /* PATCH */,
2041
- url: endpoint,
2042
- headers,
2043
- body
2044
- });
2045
- return this.handleResponse(response);
2062
+ return this.executeRequest("PATCH" /* PATCH */, endpoint, body, headers);
2046
2063
  }
2047
2064
  };
2048
2065
 
@@ -2203,14 +2220,14 @@ var AuthResultFactory = class {
2203
2220
 
2204
2221
  // src/services/auth/patterns/logger/development-logger.ts
2205
2222
  var DevelopmentLogger = class {
2206
- log(message, data) {
2207
- console.log(message, data);
2223
+ log(message2, data) {
2224
+ console.log(message2, data);
2208
2225
  }
2209
- warn(message, data) {
2210
- console.warn(message, data);
2226
+ warn(message2, data) {
2227
+ console.warn(message2, data);
2211
2228
  }
2212
- error(message, data) {
2213
- console.error(message, data);
2229
+ error(message2, data) {
2230
+ console.error(message2, data);
2214
2231
  }
2215
2232
  };
2216
2233
 
@@ -2445,14 +2462,19 @@ var BaseErrorHandler = class {
2445
2462
  }
2446
2463
  };
2447
2464
 
2448
- // src/services/auth/patterns/chain/validation-error-handler.ts
2449
- var ValidationErrorHandler = class extends BaseErrorHandler {
2465
+ // src/services/auth/patterns/chain/api-error-handler.ts
2466
+ var ApiErrorHandler = class extends BaseErrorHandler {
2450
2467
  canHandle(error) {
2451
- return error instanceof Error && error.message.includes("validation");
2468
+ return error instanceof ApiError;
2452
2469
  }
2453
2470
  handleError(error, context) {
2454
- console.error(`${context} validation error:`, error);
2455
- return AuthResultFactory.createFailure(error);
2471
+ const apiError = error;
2472
+ console.error(`${context} API error:`, {
2473
+ message: apiError.message,
2474
+ status: apiError.status,
2475
+ code: apiError.apiError.statusCode
2476
+ });
2477
+ return AuthResultFactory.createFailure(apiError.message);
2456
2478
  }
2457
2479
  };
2458
2480
 
@@ -2467,17 +2489,6 @@ var NetworkErrorHandler = class extends BaseErrorHandler {
2467
2489
  }
2468
2490
  };
2469
2491
 
2470
- // src/services/auth/patterns/chain/generic-error-handler.ts
2471
- var GenericErrorHandler = class extends BaseErrorHandler {
2472
- canHandle() {
2473
- return true;
2474
- }
2475
- handleError(error, context) {
2476
- console.error(`${context} error:`, error);
2477
- return AuthResultFactory.createFailure(error);
2478
- }
2479
- };
2480
-
2481
2492
  // src/services/auth/auth-orchestrator.ts
2482
2493
  var AuthOrchestrator = class {
2483
2494
  constructor(authService, tokenManager) {
@@ -2492,11 +2503,10 @@ var AuthOrchestrator = class {
2492
2503
  * Setup Chain of Responsibility for error handling
2493
2504
  */
2494
2505
  setupErrorHandlerChain() {
2495
- const validationHandler = new ValidationErrorHandler();
2506
+ const apiHandler = new ApiErrorHandler();
2496
2507
  const networkHandler = new NetworkErrorHandler();
2497
- const genericHandler = new GenericErrorHandler();
2498
- validationHandler.setNext(networkHandler).setNext(genericHandler);
2499
- return validationHandler;
2508
+ apiHandler.setNext(networkHandler);
2509
+ return apiHandler;
2500
2510
  }
2501
2511
  /**
2502
2512
  * Validate that cookies are supported in the current environment
@@ -2605,7 +2615,7 @@ var AuthOrchestrator = class {
2605
2615
  if (isVerified) {
2606
2616
  return AuthResultFactory.createSuccess({ isVerified: true });
2607
2617
  }
2608
- return AuthResultFactory.createFailure("Email verification failed");
2618
+ return AuthResultFactory.createFailure("Your verification code is wrong");
2609
2619
  } catch (error) {
2610
2620
  return this.errorHandler.handle(error, "Email verification");
2611
2621
  }
@@ -3271,6 +3281,7 @@ function AuthFlowContainer({
3271
3281
  stepperActions.goToStep(nextStep);
3272
3282
  },
3273
3283
  onError: (error) => {
3284
+ _antd.message.error(error);
3274
3285
  console.error(error);
3275
3286
  }
3276
3287
  }
@@ -3310,6 +3321,7 @@ function AuthFlowContainer({
3310
3321
  (_a = actionPipeline.find((action) => action.condition())) == null ? void 0 : _a.execute();
3311
3322
  },
3312
3323
  onError: (error) => {
3324
+ _antd.message.error(error);
3313
3325
  console.error(error);
3314
3326
  }
3315
3327
  }
@@ -3327,6 +3339,7 @@ function AuthFlowContainer({
3327
3339
  setPassword("");
3328
3340
  },
3329
3341
  onError: (error) => {
3342
+ _antd.message.error(error);
3330
3343
  console.error(error);
3331
3344
  }
3332
3345
  }
@@ -3345,6 +3358,7 @@ function AuthFlowContainer({
3345
3358
  handleSuccess();
3346
3359
  },
3347
3360
  onError: (error) => {
3361
+ _antd.message.error(error);
3348
3362
  console.error(error);
3349
3363
  }
3350
3364
  }
@@ -3362,6 +3376,7 @@ function AuthFlowContainer({
3362
3376
  handleSuccess();
3363
3377
  },
3364
3378
  onError: (error) => {
3379
+ _antd.message.error(error);
3365
3380
  console.error(error);
3366
3381
  }
3367
3382
  }
@@ -3376,6 +3391,7 @@ function AuthFlowContainer({
3376
3391
  onSuccess: () => {
3377
3392
  },
3378
3393
  onError: (error) => {
3394
+ _antd.message.error(error);
3379
3395
  console.error(error);
3380
3396
  }
3381
3397
  }
@@ -3413,6 +3429,7 @@ function AuthFlowContainer({
3413
3429
  onSuccess: () => {
3414
3430
  },
3415
3431
  onError: (error) => {
3432
+ _antd.message.error(error);
3416
3433
  console.error(error);
3417
3434
  }
3418
3435
  }
@@ -3939,8 +3956,7 @@ var getForgotPasswordField = (options = {}) => ({
3939
3956
 
3940
3957
 
3941
3958
 
3942
-
3943
- 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;
3959
+ exports.AUTH_ENDPOINTS = AUTH_ENDPOINTS; exports.AlertDisplay = AlertDisplay; exports.ApiErrorHandler = ApiErrorHandler; 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.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.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;
3944
3960
  /*! Bundled license information:
3945
3961
 
3946
3962
  js-cookie/dist/js.cookie.mjs:
package/dist/index.mjs CHANGED
@@ -91,11 +91,11 @@ var AuthEventType = /* @__PURE__ */ ((AuthEventType3) => {
91
91
  AuthEventType3["SignInRequiredModal"] = "auth.signin_required_modal";
92
92
  return AuthEventType3;
93
93
  })(AuthEventType || {});
94
- var PageType = /* @__PURE__ */ ((PageType4) => {
95
- PageType4["LOGIN"] = "/login";
96
- PageType4["DASHBOARD"] = "dashboard";
97
- PageType4["HOME"] = "/";
98
- return PageType4;
94
+ var PageType = /* @__PURE__ */ ((PageType3) => {
95
+ PageType3["LOGIN"] = "/login";
96
+ PageType3["DASHBOARD"] = "dashboard";
97
+ PageType3["HOME"] = "/";
98
+ return PageType3;
99
99
  })(PageType || {});
100
100
  var NavigationAction = /* @__PURE__ */ ((NavigationAction2) => {
101
101
  NavigationAction2["NONE"] = "none";
@@ -772,7 +772,7 @@ var useStepRenderer = () => {
772
772
 
773
773
  // src/components/auth/auth-flow-container.tsx
774
774
  import React5, { useState as useState7 } from "react";
775
- import { Steps, Col, Button as Button5, Flex as Flex3, Row, Space as Space4 } from "antd";
775
+ import { Steps, Col, Button as Button5, Flex as Flex3, Row, Space as Space4, message } from "antd";
776
776
  import { ArrowLeftOutlined as ArrowLeftOutlined2 } from "@ant-design/icons";
777
777
  import Image from "next/image";
778
778
  import { cva } from "class-variance-authority";
@@ -803,8 +803,8 @@ var useAuthActionHandler = () => {
803
803
  const clearAll = useCallback2(() => {
804
804
  setState((prev) => __spreadProps(__spreadValues({}, prev), { error: null, success: null }));
805
805
  }, []);
806
- const setSuccess = useCallback2((message) => {
807
- setState((prev) => __spreadProps(__spreadValues({}, prev), { success: message, error: null }));
806
+ const setSuccess = useCallback2((message2) => {
807
+ setState((prev) => __spreadProps(__spreadValues({}, prev), { success: message2, error: null }));
808
808
  }, []);
809
809
  const setError = useCallback2((error) => {
810
810
  setState((prev) => __spreadProps(__spreadValues({}, prev), { error, success: null }));
@@ -1828,6 +1828,33 @@ var TokenManager = class {
1828
1828
  }
1829
1829
  };
1830
1830
 
1831
+ // src/services/api/api-error-mapper.ts
1832
+ var API_ERROR_CODES = {
1833
+ // Auth Errors
1834
+ 5207: "The password you entered is incorrect. Please try again.",
1835
+ 5070: "Password must be strong. Please use a stronger password."
1836
+ };
1837
+ function getErrorMessage(code, defaultMessage = "An unexpected error occurred") {
1838
+ const numericCode = Number(code);
1839
+ return API_ERROR_CODES[numericCode] || defaultMessage;
1840
+ }
1841
+ function parseNestedApiError(data) {
1842
+ if (!data || typeof data !== "object") {
1843
+ return null;
1844
+ }
1845
+ const errorData = data;
1846
+ if (errorData.message && typeof errorData.message === "object" && "statusCode" in errorData.message) {
1847
+ const customCode = errorData.message.statusCode;
1848
+ const technicalMessage = errorData.message.message;
1849
+ return {
1850
+ code: customCode,
1851
+ message: getErrorMessage(customCode, technicalMessage),
1852
+ originalError: errorData
1853
+ };
1854
+ }
1855
+ return null;
1856
+ }
1857
+
1831
1858
  // src/services/api/base-service.ts
1832
1859
  var HttpClient = class {
1833
1860
  constructor(config2) {
@@ -1898,12 +1925,13 @@ var HttpClient = class {
1898
1925
  }
1899
1926
  };
1900
1927
  var ApiError = class extends Error {
1901
- constructor(message, status, statusText, apiError) {
1902
- super(message);
1903
- this.name = "ApiError";
1928
+ constructor(message2, status, statusText, apiError) {
1929
+ super(message2);
1930
+ this.message = message2;
1904
1931
  this.status = status;
1905
1932
  this.statusText = statusText;
1906
1933
  this.apiError = apiError;
1934
+ this.name = "ApiError";
1907
1935
  }
1908
1936
  };
1909
1937
  var BaseService = class {
@@ -1947,16 +1975,21 @@ var BaseService = class {
1947
1975
  */
1948
1976
  createApiErrorFromResponse(response) {
1949
1977
  const parsedError = this.tryParseApiErrorResponse(response.data);
1950
- if (parsedError) {
1951
- return parsedError;
1952
- }
1953
- return this.createGenericApiError(response);
1978
+ return parsedError || this.createGenericApiError(response);
1954
1979
  }
1955
1980
  /**
1956
1981
  * Try to parse API error response from response data
1957
1982
  */
1958
1983
  tryParseApiErrorResponse(data) {
1959
1984
  try {
1985
+ const nestedError = parseNestedApiError(data);
1986
+ if (nestedError) {
1987
+ return {
1988
+ message: nestedError.message,
1989
+ error: "ApiError",
1990
+ statusCode: nestedError.code
1991
+ };
1992
+ }
1960
1993
  const responseData = data;
1961
1994
  if (this.isValidApiErrorResponse(responseData)) {
1962
1995
  return __spreadValues({
@@ -1987,62 +2020,46 @@ var BaseService = class {
1987
2020
  };
1988
2021
  }
1989
2022
  /**
1990
- * GET request
2023
+ * Helper method for common request logic
1991
2024
  */
1992
- async get(endpoint, headers) {
2025
+ async executeRequest(method, endpoint, body, headers) {
1993
2026
  const response = await this.httpClient.request(endpoint, {
1994
- method: "GET" /* GET */,
2027
+ method,
1995
2028
  url: endpoint,
1996
- headers
2029
+ headers,
2030
+ body
1997
2031
  });
1998
2032
  return this.handleResponse(response);
1999
2033
  }
2034
+ /**
2035
+ * GET request
2036
+ */
2037
+ async get(endpoint, headers) {
2038
+ return this.executeRequest("GET" /* GET */, endpoint, void 0, headers);
2039
+ }
2000
2040
  /**
2001
2041
  * POST request
2002
2042
  */
2003
2043
  async post(endpoint, body, headers) {
2004
- const response = await this.httpClient.request(endpoint, {
2005
- method: "POST" /* POST */,
2006
- url: endpoint,
2007
- headers,
2008
- body
2009
- });
2010
- return this.handleResponse(response);
2044
+ return this.executeRequest("POST" /* POST */, endpoint, body, headers);
2011
2045
  }
2012
2046
  /**
2013
2047
  * PUT request
2014
2048
  */
2015
2049
  async put(endpoint, body, headers) {
2016
- const response = await this.httpClient.request(endpoint, {
2017
- method: "PUT" /* PUT */,
2018
- url: endpoint,
2019
- headers,
2020
- body
2021
- });
2022
- return this.handleResponse(response);
2050
+ return this.executeRequest("PUT" /* PUT */, endpoint, body, headers);
2023
2051
  }
2024
2052
  /**
2025
2053
  * DELETE request
2026
2054
  */
2027
2055
  async delete(endpoint, headers) {
2028
- const response = await this.httpClient.request(endpoint, {
2029
- method: "DELETE" /* DELETE */,
2030
- url: endpoint,
2031
- headers
2032
- });
2033
- return this.handleResponse(response);
2056
+ return this.executeRequest("DELETE" /* DELETE */, endpoint, void 0, headers);
2034
2057
  }
2035
2058
  /**
2036
2059
  * PATCH request
2037
2060
  */
2038
2061
  async patch(endpoint, body, headers) {
2039
- const response = await this.httpClient.request(endpoint, {
2040
- method: "PATCH" /* PATCH */,
2041
- url: endpoint,
2042
- headers,
2043
- body
2044
- });
2045
- return this.handleResponse(response);
2062
+ return this.executeRequest("PATCH" /* PATCH */, endpoint, body, headers);
2046
2063
  }
2047
2064
  };
2048
2065
 
@@ -2203,14 +2220,14 @@ var AuthResultFactory = class {
2203
2220
 
2204
2221
  // src/services/auth/patterns/logger/development-logger.ts
2205
2222
  var DevelopmentLogger = class {
2206
- log(message, data) {
2207
- console.log(message, data);
2223
+ log(message2, data) {
2224
+ console.log(message2, data);
2208
2225
  }
2209
- warn(message, data) {
2210
- console.warn(message, data);
2226
+ warn(message2, data) {
2227
+ console.warn(message2, data);
2211
2228
  }
2212
- error(message, data) {
2213
- console.error(message, data);
2229
+ error(message2, data) {
2230
+ console.error(message2, data);
2214
2231
  }
2215
2232
  };
2216
2233
 
@@ -2445,14 +2462,19 @@ var BaseErrorHandler = class {
2445
2462
  }
2446
2463
  };
2447
2464
 
2448
- // src/services/auth/patterns/chain/validation-error-handler.ts
2449
- var ValidationErrorHandler = class extends BaseErrorHandler {
2465
+ // src/services/auth/patterns/chain/api-error-handler.ts
2466
+ var ApiErrorHandler = class extends BaseErrorHandler {
2450
2467
  canHandle(error) {
2451
- return error instanceof Error && error.message.includes("validation");
2468
+ return error instanceof ApiError;
2452
2469
  }
2453
2470
  handleError(error, context) {
2454
- console.error(`${context} validation error:`, error);
2455
- return AuthResultFactory.createFailure(error);
2471
+ const apiError = error;
2472
+ console.error(`${context} API error:`, {
2473
+ message: apiError.message,
2474
+ status: apiError.status,
2475
+ code: apiError.apiError.statusCode
2476
+ });
2477
+ return AuthResultFactory.createFailure(apiError.message);
2456
2478
  }
2457
2479
  };
2458
2480
 
@@ -2467,17 +2489,6 @@ var NetworkErrorHandler = class extends BaseErrorHandler {
2467
2489
  }
2468
2490
  };
2469
2491
 
2470
- // src/services/auth/patterns/chain/generic-error-handler.ts
2471
- var GenericErrorHandler = class extends BaseErrorHandler {
2472
- canHandle() {
2473
- return true;
2474
- }
2475
- handleError(error, context) {
2476
- console.error(`${context} error:`, error);
2477
- return AuthResultFactory.createFailure(error);
2478
- }
2479
- };
2480
-
2481
2492
  // src/services/auth/auth-orchestrator.ts
2482
2493
  var AuthOrchestrator = class {
2483
2494
  constructor(authService, tokenManager) {
@@ -2492,11 +2503,10 @@ var AuthOrchestrator = class {
2492
2503
  * Setup Chain of Responsibility for error handling
2493
2504
  */
2494
2505
  setupErrorHandlerChain() {
2495
- const validationHandler = new ValidationErrorHandler();
2506
+ const apiHandler = new ApiErrorHandler();
2496
2507
  const networkHandler = new NetworkErrorHandler();
2497
- const genericHandler = new GenericErrorHandler();
2498
- validationHandler.setNext(networkHandler).setNext(genericHandler);
2499
- return validationHandler;
2508
+ apiHandler.setNext(networkHandler);
2509
+ return apiHandler;
2500
2510
  }
2501
2511
  /**
2502
2512
  * Validate that cookies are supported in the current environment
@@ -2605,7 +2615,7 @@ var AuthOrchestrator = class {
2605
2615
  if (isVerified) {
2606
2616
  return AuthResultFactory.createSuccess({ isVerified: true });
2607
2617
  }
2608
- return AuthResultFactory.createFailure("Email verification failed");
2618
+ return AuthResultFactory.createFailure("Your verification code is wrong");
2609
2619
  } catch (error) {
2610
2620
  return this.errorHandler.handle(error, "Email verification");
2611
2621
  }
@@ -3271,6 +3281,7 @@ function AuthFlowContainer({
3271
3281
  stepperActions.goToStep(nextStep);
3272
3282
  },
3273
3283
  onError: (error) => {
3284
+ message.error(error);
3274
3285
  console.error(error);
3275
3286
  }
3276
3287
  }
@@ -3310,6 +3321,7 @@ function AuthFlowContainer({
3310
3321
  (_a = actionPipeline.find((action) => action.condition())) == null ? void 0 : _a.execute();
3311
3322
  },
3312
3323
  onError: (error) => {
3324
+ message.error(error);
3313
3325
  console.error(error);
3314
3326
  }
3315
3327
  }
@@ -3327,6 +3339,7 @@ function AuthFlowContainer({
3327
3339
  setPassword("");
3328
3340
  },
3329
3341
  onError: (error) => {
3342
+ message.error(error);
3330
3343
  console.error(error);
3331
3344
  }
3332
3345
  }
@@ -3345,6 +3358,7 @@ function AuthFlowContainer({
3345
3358
  handleSuccess();
3346
3359
  },
3347
3360
  onError: (error) => {
3361
+ message.error(error);
3348
3362
  console.error(error);
3349
3363
  }
3350
3364
  }
@@ -3362,6 +3376,7 @@ function AuthFlowContainer({
3362
3376
  handleSuccess();
3363
3377
  },
3364
3378
  onError: (error) => {
3379
+ message.error(error);
3365
3380
  console.error(error);
3366
3381
  }
3367
3382
  }
@@ -3376,6 +3391,7 @@ function AuthFlowContainer({
3376
3391
  onSuccess: () => {
3377
3392
  },
3378
3393
  onError: (error) => {
3394
+ message.error(error);
3379
3395
  console.error(error);
3380
3396
  }
3381
3397
  }
@@ -3413,6 +3429,7 @@ function AuthFlowContainer({
3413
3429
  onSuccess: () => {
3414
3430
  },
3415
3431
  onError: (error) => {
3432
+ message.error(error);
3416
3433
  console.error(error);
3417
3434
  }
3418
3435
  }
@@ -3839,6 +3856,7 @@ var getForgotPasswordField = (options = {}) => ({
3839
3856
  export {
3840
3857
  AUTH_ENDPOINTS,
3841
3858
  AlertDisplay,
3859
+ ApiErrorHandler,
3842
3860
  AuthEventType,
3843
3861
  AuthFlowContainer,
3844
3862
  AuthFlowModal,
@@ -3869,7 +3887,6 @@ export {
3869
3887
  ExistingUserLoginStrategy,
3870
3888
  FormFields,
3871
3889
  FormHeader,
3872
- GenericErrorHandler,
3873
3890
  HttpClient,
3874
3891
  HttpMethod,
3875
3892
  LocalStorageUtils,
@@ -3898,7 +3915,6 @@ export {
3898
3915
  UrlUtils,
3899
3916
  UserStorageManager,
3900
3917
  VERIFICATION_SUBMISSION_NAVIGATION,
3901
- ValidationErrorHandler,
3902
3918
  VerificationStep,
3903
3919
  config,
3904
3920
  createAuthSteps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailsentry-auth",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
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",