@ollaid/native-sso 1.0.7 → 2.1.2

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.
@@ -16,6 +16,8 @@ export interface LoginModalProps {
16
16
  showSwitchToSignup?: boolean;
17
17
  /** Type de compte par défaut à persister dans localStorage */
18
18
  defaultAccountType?: 'user' | 'client';
19
+ /** Pre-fill phone number and go directly to phone-input step */
20
+ initialPhone?: string;
19
21
  }
20
- export declare function LoginModal({ open, onOpenChange, onSwitchToSignup, onLoginSuccess, saasApiUrl, iamApiUrl, loading, showSwitchToSignup, defaultAccountType, }: LoginModalProps): import("react/jsx-runtime").JSX.Element;
22
+ export declare function LoginModal({ open, onOpenChange, onSwitchToSignup, onLoginSuccess, saasApiUrl, iamApiUrl, loading, showSwitchToSignup, defaultAccountType, initialPhone, }: LoginModalProps): import("react/jsx-runtime").JSX.Element;
21
23
  export default LoginModal;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Phone Input component for @ollaid/native-sso
3
- * Uses complete world countries list
3
+ * Custom select overlay: dropdown shows ISO code, selected display shows only flag + dialCode
4
4
  */
5
5
  interface PhoneInputProps {
6
6
  value: string;
@@ -14,6 +14,8 @@ export interface SignupModalProps {
14
14
  iamApiUrl: string;
15
15
  /** Type de compte par défaut à persister dans localStorage */
16
16
  defaultAccountType?: 'user' | 'client';
17
+ /** Called when conflict resolution wants to switch to login with a pre-filled phone */
18
+ onSwitchToLoginWithPhone?: (phone: string) => void;
17
19
  }
18
- export declare function SignupModal({ open, onOpenChange, onSwitchToLogin, onSignupSuccess, saasApiUrl, iamApiUrl, defaultAccountType }: SignupModalProps): import("react/jsx-runtime").JSX.Element;
20
+ export declare function SignupModal({ open, onOpenChange, onSwitchToLogin, onSignupSuccess, saasApiUrl, iamApiUrl, defaultAccountType, onSwitchToLoginWithPhone }: SignupModalProps): import("react/jsx-runtime").JSX.Element;
19
21
  export default SignupModal;
@@ -34,6 +34,16 @@ export declare function DialogContent({ children, className }: {
34
34
  children: React.ReactNode;
35
35
  className?: string;
36
36
  }): import("react/jsx-runtime").JSX.Element;
37
+ export declare function DialogBody({ children, className, style }: {
38
+ children: React.ReactNode;
39
+ className?: string;
40
+ style?: React.CSSProperties;
41
+ }): import("react/jsx-runtime").JSX.Element;
42
+ export declare function DialogFooter({ children, className, style }: {
43
+ children: React.ReactNode;
44
+ className?: string;
45
+ style?: React.CSSProperties;
46
+ }): import("react/jsx-runtime").JSX.Element;
37
47
  export declare function DialogHeader({ children, className, style }: {
38
48
  children: React.ReactNode;
39
49
  className?: string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Hook React pour la déconnexion sécurisée.
3
+ *
4
+ * Wrape `logout()` avec gestion d'état (loading, error)
5
+ * et callbacks (onSuccess, onError) pour une intégration UX simple.
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * import { useLogout } from '@ollaid/native-sso';
10
+ *
11
+ * const LogoutButton = () => {
12
+ * const { logout, loading, error } = useLogout({
13
+ * onSuccess: () => navigate('/auth/login'),
14
+ * onError: (err) => toast.error(err.message),
15
+ * });
16
+ *
17
+ * return (
18
+ * <button onClick={logout} disabled={loading}>
19
+ * {loading ? 'Déconnexion...' : 'Se déconnecter'}
20
+ * </button>
21
+ * );
22
+ * };
23
+ * ```
24
+ *
25
+ * @version 1.0.0
26
+ */
27
+ export interface UseLogoutOptions {
28
+ /** Callback appelé après une déconnexion réussie (redirection, toast, etc.) */
29
+ onSuccess?: () => void;
30
+ /** Callback appelé en cas d'erreur (notification, log, etc.) */
31
+ onError?: (error: Error) => void;
32
+ }
33
+ export interface UseLogoutReturn {
34
+ /** Déclenche la déconnexion complète (double revocation SaaS + IAM) */
35
+ logout: () => Promise<void>;
36
+ /** `true` pendant l'appel de déconnexion */
37
+ loading: boolean;
38
+ /** Message d'erreur si la déconnexion a échoué, `null` sinon */
39
+ error: string | null;
40
+ }
41
+ export declare const useLogout: (options?: UseLogoutOptions) => UseLogoutReturn;
@@ -41,7 +41,7 @@ export declare function useMobileRegistration(options?: UseMobileRegistrationOpt
41
41
  error_type?: undefined;
42
42
  } | {
43
43
  success: boolean;
44
- error_type: string | undefined;
44
+ error_type: any;
45
45
  otp_code_dev?: undefined;
46
46
  otp_method?: undefined;
47
47
  otp_sent_to?: undefined;
@@ -1,12 +1,16 @@
1
1
  /**
2
- * Hook de vérification périodique du token Sanctum
2
+ * Hook de vérification périodique du token Sanctum (Auth Check)
3
3
  *
4
- * - Premier check 2 min après login
5
- * - Checks suivants toutes les 5 min
4
+ * Le package consulte l'endpoint POST /api/native/check-token du SaaS
5
+ * pour vérifier si l'utilisateur est toujours connecté.
6
+ *
7
+ * - Premier check 60s après login
8
+ * - Checks suivants toutes les 2 min
9
+ * - Si status === 'connected' → met à jour user_infos en localStorage
10
+ * - Si 401 → révoque l'IAM (POST /iam/disconnect) + nettoie le frontend
6
11
  * - Ne déconnecte PAS si offline ou serveur inaccessible
7
- * - Déconnecte UNIQUEMENT si le backend retourne 401 (token invalide)
8
12
  *
9
- * @version 1.0.0
13
+ * @version 2.0.0
10
14
  */
11
15
  import type { UserInfos } from '../types/native';
12
16
  export interface UseTokenHealthCheckOptions {
@@ -14,6 +18,8 @@ export interface UseTokenHealthCheckOptions {
14
18
  enabled: boolean;
15
19
  /** SaaS API base URL */
16
20
  saasApiUrl: string;
21
+ /** IAM API base URL (for revocation on 401) */
22
+ iamApiUrl: string;
17
23
  /** Called when the backend explicitly invalidates the token (401) */
18
24
  onTokenInvalid: () => void;
19
25
  /** Called when fresh user_infos are received */