@ollaid/native-sso 2.7.9 → 2.8.1

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.
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Version réécrite from scratch pour éviter les états qui bloquent le bouton Valider.
5
5
  *
6
- * @version 2.7.0
6
+ * @version 2.7.9
7
7
  */
8
8
  export interface AvatarCropModalProps {
9
9
  open: boolean;
@@ -2,7 +2,7 @@
2
2
  * DebugPanel — Panneau de debug flottant pour @ollaid/native-sso
3
3
  * Affiche l'historique des appels API en temps réel (style terminal)
4
4
  * N'apparaît que quand debug=true
5
- * @version 2.7.0
5
+ * @version 2.7.9
6
6
  */
7
7
  export type DebugOnboardingPreset = 'current' | 'photo' | 'phone' | 'email' | 'all';
8
8
  interface DebugPanelProps {
@@ -2,7 +2,7 @@
2
2
  * Login Modal for @ollaid/native-sso
3
3
  * Complete login flow aligned with Native SSO design
4
4
  *
5
- * @version 2.7.8
5
+ * @version 2.7.9
6
6
  */
7
7
  import type { UserInfos } from '../types/native';
8
8
  export interface LoginModalProps {
@@ -15,7 +15,7 @@ export interface LoginModalProps {
15
15
  logoUrl?: string;
16
16
  loading?: boolean;
17
17
  showSwitchToSignup?: boolean;
18
- /** Type de compte par défaut à persister dans localStorage */
18
+ /** Type de compte par défaut à persister dans le storage du package */
19
19
  defaultAccountType?: 'user' | 'client';
20
20
  /** Pre-fill phone number and go directly to phone-input step */
21
21
  initialPhone?: string;
@@ -2,7 +2,7 @@
2
2
  * NativeSSOPage — Page autonome complète pour @ollaid/native-sso
3
3
  * Design aligné sur le parcours Native SSO (fond primary, card blanche, ShieldCheck branding)
4
4
  *
5
- * @version 2.7.8
5
+ * @version 2.7.9
6
6
  */
7
7
  import type { UserInfos } from '../types/native';
8
8
  import type { NativeStorageAdapter } from '../services/api';
@@ -3,7 +3,7 @@
3
3
  * Mode `missing` : champs absents uniquement
4
4
  * Mode `edit` : édition complète du profil depuis le SaaS
5
5
  *
6
- * @version 2.7.8
6
+ * @version 2.7.9
7
7
  */
8
8
  import type { NativeUser, UserInfos } from '../types/native';
9
9
  export interface OnboardingModalProps {
@@ -3,7 +3,7 @@
3
3
  * Flow: email → method-choice → OTP → new password → success
4
4
  * Design aligned with web SSO
5
5
  *
6
- * @version 2.7.0
6
+ * @version 2.7.9
7
7
  */
8
8
  export interface PasswordRecoveryModalProps {
9
9
  open: boolean;
@@ -2,7 +2,7 @@
2
2
  * Signup Modal for @ollaid/native-sso — Design aligned with web SSO
3
3
  * Full signup flow: intro → account-type → info → OTP → password → confirm → success
4
4
  *
5
- * @version 2.7.8
5
+ * @version 2.7.9
6
6
  */
7
7
  import type { UserInfos } from '../types/native';
8
8
  export interface SignupModalProps {
@@ -13,7 +13,7 @@ export interface SignupModalProps {
13
13
  saasApiUrl: string;
14
14
  iamApiUrl: string;
15
15
  logoUrl?: string;
16
- /** Type de compte par défaut à persister dans localStorage */
16
+ /** Type de compte par défaut à persister dans le storage du package */
17
17
  defaultAccountType?: 'user' | 'client';
18
18
  /** Called when conflict resolution wants to switch to login with a pre-filled phone */
19
19
  onSwitchToLoginWithPhone?: (phone: string) => void;
@@ -3,7 +3,7 @@
3
3
  * Lightweight replacements for shadcn/ui components + inline SVG icons
4
4
  * No external dependencies required
5
5
  *
6
- * @version 2.7.0
6
+ * @version 2.7.9
7
7
  */
8
8
  import React from 'react';
9
9
  export declare function IconShieldCheck(props: React.SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
@@ -22,7 +22,7 @@
22
22
  * };
23
23
  * ```
24
24
  *
25
- * @version 2.7.0
25
+ * @version 2.7.9
26
26
  */
27
27
  export interface UseLogoutOptions {
28
28
  /** Callback appelé après une déconnexion réussie (redirection, toast, etc.) */
@@ -2,7 +2,7 @@
2
2
  * Hook de récupération de mot de passe v1.0
3
3
  * Architecture Frontend-First avec appels directs à l'IAM
4
4
  *
5
- * @version 2.7.0
5
+ * @version 2.7.9
6
6
  */
7
7
  export interface UseMobilePasswordOptions {
8
8
  saasApiUrl: string;
@@ -2,7 +2,7 @@
2
2
  * Hook d'inscription Mobile SSO v1.0
3
3
  * Gère le flow: init → verify-otp → complete
4
4
  *
5
- * @version 2.7.0
5
+ * @version 2.7.9
6
6
  */
7
7
  import type { MobileRegistrationFormData, AccountType } from '../types/mobile';
8
8
  interface RegistrationConflict {
@@ -2,10 +2,10 @@
2
2
  * Hook d'authentification Native SSO v1.0
3
3
  * Architecture Frontend-First avec appels directs à l'IAM
4
4
  *
5
- * @version 2.7.0
5
+ * @version 2.7.9
6
6
  */
7
7
  import { type NativeStorageAdapter } from '../services/api';
8
- import type { NativeAuthStatus, NativeExchangeResponse, AccountType } from '../types/native';
8
+ import type { NativeAuthStatus, NativeExchangeResponse, AccountType, NativeUser } from '../types/native';
9
9
  export interface UseNativeAuthOptions {
10
10
  /** URL du Backend SaaS */
11
11
  saasApiUrl: string;
@@ -27,7 +27,7 @@ export declare function useNativeAuth(options: UseNativeAuthOptions): {
27
27
  credentialsLoaded: boolean;
28
28
  processToken: string | null;
29
29
  status: NativeAuthStatus | null;
30
- user: import("..").NativeUser | null;
30
+ user: NativeUser | null;
31
31
  application: {
32
32
  id: number;
33
33
  name: string;
@@ -6,11 +6,11 @@
6
6
  *
7
7
  * - Premier check 60s après login
8
8
  * - Checks suivants toutes les 2 min
9
- * - Si status === 'connected' → met à jour user_infos en localStorage
9
+ * - Si status === 'connected' → met à jour user_infos via le storage du package
10
10
  * - Si 401 → révoque l'IAM (POST /iam/disconnect) + nettoie le frontend
11
11
  * - Ne déconnecte PAS si offline ou serveur inaccessible
12
12
  *
13
- * @version 2.7.0
13
+ * @version 2.7.9
14
14
  */
15
15
  import type { UserInfos } from '../types/native';
16
16
  export interface UseTokenHealthCheckOptions {
package/dist/index.cjs CHANGED
@@ -8890,6 +8890,25 @@ function useTokenHealthCheck(options) {
8890
8890
  };
8891
8891
  }, [enabled, saasApiUrl, performCheck, debug]);
8892
8892
  }
8893
+ function normalizeNativeUser(user) {
8894
+ if (!user) return null;
8895
+ const input = user;
8896
+ return {
8897
+ reference: input.reference ?? input.iam_reference ?? input.alias_reference ?? "",
8898
+ name: input.name ?? "",
8899
+ email: input.email ?? void 0,
8900
+ phone: input.phone,
8901
+ ccphone: input.ccphone,
8902
+ image_url: input.image_url ?? input.image,
8903
+ account_type: input.account_type,
8904
+ town: input.town,
8905
+ country: input.country,
8906
+ address: input.address,
8907
+ auth_2fa: input.auth_2fa,
8908
+ alias_reference: input.alias_reference,
8909
+ iam_reference: input.iam_reference
8910
+ };
8911
+ }
8893
8912
  function saveSession(exchangeResult, accountType) {
8894
8913
  var _a, _b;
8895
8914
  const storage = getNativeStorage();
@@ -9006,7 +9025,8 @@ function useNativeAuth(options) {
9006
9025
  if (storedRaw) {
9007
9026
  try {
9008
9027
  const stored = JSON.parse(storedRaw);
9009
- const merged = { ...stored, ...userInfos };
9028
+ const merged = normalizeNativeUser({ ...stored, ...userInfos });
9029
+ if (!merged) return;
9010
9030
  getNativeStorage().setItem(STORAGE.USER, JSON.stringify(merged));
9011
9031
  setState((prev) => ({ ...prev, user: merged }));
9012
9032
  } catch {
@@ -9029,13 +9049,10 @@ function useNativeAuth(options) {
9029
9049
  }
9030
9050
  const res = await nativeAuthService.refresh();
9031
9051
  if (res.success) {
9032
- const storedUser = getNativeStorage().getItem(STORAGE.USER);
9033
- if (storedUser) {
9034
- try {
9035
- const user = JSON.parse(storedUser);
9036
- setState((prev) => ({ ...prev, user, status: "completed" }));
9037
- } catch {
9038
- }
9052
+ const snapshot = getSsoSessionSnapshot();
9053
+ const user = normalizeNativeUser(snapshot.user);
9054
+ if (user) {
9055
+ setState((prev) => ({ ...prev, user, status: "completed" }));
9039
9056
  }
9040
9057
  return "recovered";
9041
9058
  }
@@ -9074,16 +9091,10 @@ function useNativeAuth(options) {
9074
9091
  return () => clearTimeout(t);
9075
9092
  }, [state.status, state.user, tryRefreshSession]);
9076
9093
  react.useEffect(() => {
9077
- const storage2 = getNativeStorage();
9078
- const storedToken = storage2.getItem(STORAGE.AUTH_TOKEN) || storage2.getItem(STORAGE.TOKEN);
9079
- const storedUser = storage2.getItem(STORAGE.USER);
9080
- if (storedToken && storedUser) {
9081
- try {
9082
- const user = JSON.parse(storedUser);
9083
- setState((prev) => ({ ...prev, user, status: "completed" }));
9084
- } catch {
9085
- clearSession();
9086
- }
9094
+ const snapshot = getSsoSessionSnapshot();
9095
+ const user = normalizeNativeUser(snapshot.user);
9096
+ if (snapshot.authToken && user) {
9097
+ setState((prev) => ({ ...prev, user, status: "completed" }));
9087
9098
  }
9088
9099
  }, []);
9089
9100
  react.useEffect(() => {
@@ -13496,8 +13507,8 @@ const PasswordRedirectModal = ({ open, onOpenChange, saasApiUrl, iamApiUrl }) =>
13496
13507
  /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { style: { maxWidth: "28rem", borderRadius: "16px", background: "#fff" }, children: [
13497
13508
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
13498
13509
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: { margin: "0 auto 12px", width: 56, height: 56, borderRadius: "50%", background: "rgba(232, 67, 10, 0.1)", display: "flex", alignItems: "center", justifyContent: "center", color: "#e8430a" }, children: /* @__PURE__ */ jsxRuntime.jsx(LockKeyhole, { size: 28 }) }),
13499
- /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { style: { textAlign: "center" }, children: "Mot de passe géré par OLLAID SSO" }),
13500
- /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { style: { textAlign: "center" }, children: "Ce bouton sert à tester la redirection vers IAM et l'ouverture du modal de changement de mot de passe." })
13510
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-center", children: "Mot de passe géré par OLLAID SSO" }),
13511
+ /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { className: "text-center", children: "Ce bouton sert à tester la redirection vers IAM et l'ouverture du modal de changement de mot de passe." })
13501
13512
  ] }),
13502
13513
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { border: "1px solid #e5e7eb", borderRadius: 12, padding: 16, background: "#f8fafc", color: "#475569", fontSize: 13, display: "grid", gap: 8 }, children: [
13503
13514
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: 8, alignItems: "flex-start" }, children: [
@@ -13523,8 +13534,8 @@ const PasswordRedirectModal = ({ open, onOpenChange, saasApiUrl, iamApiUrl }) =>
13523
13534
  }
13524
13535
  }, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { style: { maxWidth: "26rem", borderRadius: "16px", background: "#fff" }, children: [
13525
13536
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
13526
- /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Êtes-vous sûr de rediriger vers le SSO ?" }),
13527
- /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: "Cette action ouvre IAM dans un nouvel onglet et prépare l'auto-connexion pour tester le changement de mot de passe." })
13537
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-center", children: "Êtes-vous sûr de rediriger vers le SSO ?" }),
13538
+ /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { className: "text-center", children: "Cette action ouvre IAM dans un nouvel onglet et prépare l'auto-connexion pour tester le changement de mot de passe." })
13528
13539
  ] }),
13529
13540
  errorMessage && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { border: "1px solid #fecaca", background: "#fef2f2", color: "#b91c1c", borderRadius: 12, padding: 12, fontSize: 13 }, children: errorMessage }),
13530
13541
  loading && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 10, padding: "8px 0 4px" }, children: [