@ollaid/native-sso 1.0.0 → 1.0.3

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.js CHANGED
@@ -452,7 +452,8 @@ let config = {
452
452
  saasApiUrl: "",
453
453
  iamApiUrl: "",
454
454
  timeout: 3e4,
455
- debug: false
455
+ debug: false,
456
+ configPrefix: "iam"
456
457
  };
457
458
  const setNativeAuthConfig = (newConfig) => {
458
459
  config = { ...config, ...newConfig };
@@ -479,7 +480,8 @@ const STORAGE = {
479
480
  AUTH_TOKEN: "auth_token",
480
481
  TOKEN: "token",
481
482
  USER: "user",
482
- ACCOUNT_TYPE: "account_type"
483
+ ACCOUNT_TYPE: "account_type",
484
+ ALIAS_REFERENCE: "alias_reference"
483
485
  };
484
486
  const setAuthToken = (token) => {
485
487
  if (typeof localStorage !== "undefined") {
@@ -497,6 +499,7 @@ const clearAuthToken = () => {
497
499
  localStorage.removeItem(STORAGE.TOKEN);
498
500
  localStorage.removeItem(STORAGE.USER);
499
501
  localStorage.removeItem(STORAGE.ACCOUNT_TYPE);
502
+ localStorage.removeItem(STORAGE.ALIAS_REFERENCE);
500
503
  }
501
504
  };
502
505
  const setAuthUser = (user) => {
@@ -570,7 +573,7 @@ async function fetchWithTimeout(url, options, timeout) {
570
573
  throw new ApiError("Erreur inattendue", "unknown");
571
574
  }
572
575
  }
573
- function getHeaders(token) {
576
+ function getHeaders(token, includeConfigPrefix = false) {
574
577
  const headers = {
575
578
  "Content-Type": "application/json",
576
579
  "Accept": "application/json"
@@ -579,12 +582,19 @@ function getHeaders(token) {
579
582
  if (deviceId) {
580
583
  headers["X-Device-Id"] = deviceId;
581
584
  }
585
+ if (includeConfigPrefix && config.configPrefix) {
586
+ headers["X-IAM-Config-Prefix"] = config.configPrefix;
587
+ }
582
588
  if (token) {
583
589
  headers["Authorization"] = `Bearer ${token}`;
584
590
  }
585
591
  return headers;
586
592
  }
587
593
  let credentials = null;
594
+ let credentialsLoadedAt = 0;
595
+ let credentialsTtl = 300;
596
+ const DEFAULT_TTL = 300;
597
+ const REFRESH_MARGIN = 30;
588
598
  const nativeAuthService = {
589
599
  hasCredentials() {
590
600
  return credentials !== null;
@@ -592,6 +602,26 @@ const nativeAuthService = {
592
602
  getCredentials() {
593
603
  return credentials ? { ...credentials } : null;
594
604
  },
605
+ getCredentialsTtl() {
606
+ return credentialsTtl;
607
+ },
608
+ getCredentialsAge() {
609
+ if (!credentialsLoadedAt) return Infinity;
610
+ return (Date.now() - credentialsLoadedAt) / 1e3;
611
+ },
612
+ areCredentialsExpiringSoon() {
613
+ if (!credentials || !credentialsLoadedAt) return true;
614
+ const age = this.getCredentialsAge();
615
+ return age >= credentialsTtl - REFRESH_MARGIN;
616
+ },
617
+ async ensureFreshCredentials() {
618
+ if (!credentials || this.areCredentialsExpiringSoon()) {
619
+ if (isDebugMode()) {
620
+ console.log("🔄 [Native] Credentials expirés ou proches — auto-refresh");
621
+ }
622
+ await this.loadCredentials();
623
+ }
624
+ },
595
625
  async loadCredentials() {
596
626
  const config2 = getNativeAuthConfig();
597
627
  if (!config2.saasApiUrl) {
@@ -602,7 +632,7 @@ const nativeAuthService = {
602
632
  }
603
633
  const response = await fetchWithTimeout(
604
634
  `${config2.saasApiUrl}/native/config`,
605
- { method: "GET", headers: getHeaders() },
635
+ { method: "GET", headers: getHeaders(void 0, true) },
606
636
  config2.timeout || 3e4
607
637
  );
608
638
  if (!response.success || !response.encrypted_credentials || !response.app_key) {
@@ -612,6 +642,8 @@ const nativeAuthService = {
612
642
  appKey: response.app_key,
613
643
  encryptedCredentials: response.encrypted_credentials
614
644
  };
645
+ credentialsLoadedAt = Date.now();
646
+ credentialsTtl = response.credentials_ttl || DEFAULT_TTL;
615
647
  if (typeof response.debug === "boolean") {
616
648
  const currentConfig = getNativeAuthConfig();
617
649
  if (currentConfig.debug !== true) {
@@ -619,11 +651,12 @@ const nativeAuthService = {
619
651
  }
620
652
  }
621
653
  if (isDebugMode()) {
622
- console.log("✅ [SaaS] Credentials chargés (debug:", response.debug ?? "non défini", ")");
654
+ console.log("✅ [SaaS] Credentials chargés (ttl:", credentialsTtl, "s, debug:", response.debug ?? "non défini", ")");
623
655
  }
624
656
  return credentials;
625
657
  },
626
658
  async encrypt(type, data) {
659
+ await this.ensureFreshCredentials();
627
660
  if (!credentials) {
628
661
  throw new ApiError("Credentials non chargés. Appelez loadCredentials() d'abord.", "auth");
629
662
  }
@@ -774,7 +807,7 @@ const nativeAuthService = {
774
807
  `${config2.saasApiUrl}/native/exchange`,
775
808
  {
776
809
  method: "POST",
777
- headers: getHeaders(),
810
+ headers: getHeaders(void 0, true),
778
811
  body: JSON.stringify({ callback_token: callbackToken })
779
812
  },
780
813
  config2.timeout || 3e4
@@ -803,7 +836,7 @@ const nativeAuthService = {
803
836
  `${cfg.saasApiUrl}/native/check-token`,
804
837
  {
805
838
  method: "POST",
806
- headers: getHeaders(token)
839
+ headers: getHeaders(token, true)
807
840
  },
808
841
  1e4
809
842
  );
@@ -825,21 +858,24 @@ const nativeAuthService = {
825
858
  `${config2.saasApiUrl}/native/logout`,
826
859
  {
827
860
  method: "POST",
828
- headers: getHeaders(token)
861
+ headers: getHeaders(token, true)
829
862
  },
830
863
  config2.timeout || 3e4
831
864
  );
832
865
  clearAuthToken();
833
866
  credentials = null;
867
+ credentialsLoadedAt = 0;
834
868
  return response;
835
869
  } catch {
836
870
  clearAuthToken();
837
871
  credentials = null;
872
+ credentialsLoadedAt = 0;
838
873
  return { success: true };
839
874
  }
840
875
  },
841
876
  clearCredentials() {
842
877
  credentials = null;
878
+ credentialsLoadedAt = 0;
843
879
  },
844
880
  // ============================================
845
881
  // High-level methods
@@ -1022,14 +1058,14 @@ function getErrorMessage$2(err, context) {
1022
1058
  return { message: `Erreur lors de ${context}`, type: "unknown" };
1023
1059
  }
1024
1060
  function useMobilePassword(options) {
1025
- const { saasApiUrl, iamApiUrl, autoLoadCredentials = true, debug = false } = options;
1061
+ const { saasApiUrl, iamApiUrl, autoLoadCredentials = true } = options;
1026
1062
  const configuredRef = useRef(false);
1027
1063
  useEffect(() => {
1028
1064
  if (!configuredRef.current) {
1029
- setNativeAuthConfig({ saasApiUrl, iamApiUrl, debug });
1065
+ setNativeAuthConfig({ saasApiUrl, iamApiUrl });
1030
1066
  configuredRef.current = true;
1031
1067
  }
1032
- }, [saasApiUrl, iamApiUrl, debug]);
1068
+ }, [saasApiUrl, iamApiUrl]);
1033
1069
  const [state, setState] = useState({
1034
1070
  credentialsLoaded: false,
1035
1071
  processToken: null,
@@ -1265,7 +1301,7 @@ const backBtnStyle$2 = {
1265
1301
  color: C$3.gray700,
1266
1302
  zIndex: 10
1267
1303
  };
1268
- function PasswordRecoveryModal({ open, onOpenChange, onSuccess, saasApiUrl, iamApiUrl, debug = false }) {
1304
+ function PasswordRecoveryModal({ open, onOpenChange, onSuccess, saasApiUrl, iamApiUrl }) {
1269
1305
  const {
1270
1306
  status,
1271
1307
  loading: pwLoading,
@@ -1280,7 +1316,7 @@ function PasswordRecoveryModal({ open, onOpenChange, onSuccess, saasApiUrl, iamA
1280
1316
  resendOtp,
1281
1317
  reset: resetHook,
1282
1318
  clearError
1283
- } = useMobilePassword({ saasApiUrl, iamApiUrl, debug });
1319
+ } = useMobilePassword({ saasApiUrl, iamApiUrl });
1284
1320
  const [step, setStep] = useState("email");
1285
1321
  const [email, setEmail] = useState("");
1286
1322
  const [otp, setOtp] = useState("");
@@ -1567,11 +1603,22 @@ function useTokenHealthCheck(options) {
1567
1603
  }, [enabled, saasApiUrl, performCheck, debug]);
1568
1604
  }
1569
1605
  function saveSession(exchangeResult, accountType) {
1606
+ var _a, _b;
1570
1607
  const sanctumToken = exchangeResult.auth_token || exchangeResult.token;
1571
1608
  localStorage.setItem(STORAGE.AUTH_TOKEN, sanctumToken);
1572
1609
  localStorage.setItem(STORAGE.TOKEN, sanctumToken);
1573
- const userToStore = exchangeResult.user_infos ? { ...exchangeResult.user, ...exchangeResult.user_infos } : exchangeResult.user;
1574
- const acctType = accountType === "phone-only" ? "client" : "user";
1610
+ const baseUser = exchangeResult.user_infos ? { ...exchangeResult.user, ...exchangeResult.user_infos } : exchangeResult.user;
1611
+ const aliasRef = ((_a = exchangeResult.user) == null ? void 0 : _a.alias_reference) || exchangeResult.alias_reference || "";
1612
+ const iamRef = ((_b = exchangeResult.user) == null ? void 0 : _b.reference) || "";
1613
+ const userToStore = {
1614
+ ...baseUser,
1615
+ iam_reference: iamRef,
1616
+ alias_reference: aliasRef
1617
+ };
1618
+ if (aliasRef) {
1619
+ localStorage.setItem(STORAGE.ALIAS_REFERENCE, aliasRef);
1620
+ }
1621
+ const acctType = typeof accountType === "string" ? accountType : "user";
1575
1622
  localStorage.setItem(STORAGE.USER, JSON.stringify(userToStore));
1576
1623
  localStorage.setItem(STORAGE.ACCOUNT_TYPE, acctType);
1577
1624
  return { token: sanctumToken, user: userToStore };
@@ -1581,6 +1628,7 @@ function clearSession() {
1581
1628
  localStorage.removeItem(STORAGE.TOKEN);
1582
1629
  localStorage.removeItem(STORAGE.USER);
1583
1630
  localStorage.removeItem(STORAGE.ACCOUNT_TYPE);
1631
+ localStorage.removeItem(STORAGE.ALIAS_REFERENCE);
1584
1632
  }
1585
1633
  function getErrorMessage$1(err, context) {
1586
1634
  if (err instanceof Error) {
@@ -1595,14 +1643,15 @@ function getErrorMessage$1(err, context) {
1595
1643
  return { message: `Erreur lors de ${context}`, type: "unknown" };
1596
1644
  }
1597
1645
  function useNativeAuth(options) {
1598
- const { saasApiUrl, iamApiUrl, autoLoadCredentials = true, debug = false } = options;
1646
+ const { saasApiUrl, iamApiUrl, autoLoadCredentials = true, defaultAccountType = "user", configPrefix = "iam" } = options;
1599
1647
  const configuredRef = useRef(false);
1648
+ const [isDebug, setIsDebug] = useState(isDebugMode());
1600
1649
  useEffect(() => {
1601
1650
  if (!configuredRef.current) {
1602
- setNativeAuthConfig({ saasApiUrl, iamApiUrl, debug });
1651
+ setNativeAuthConfig({ saasApiUrl, iamApiUrl, configPrefix });
1603
1652
  configuredRef.current = true;
1604
1653
  }
1605
- }, [saasApiUrl, iamApiUrl, debug]);
1654
+ }, [saasApiUrl, iamApiUrl, configPrefix]);
1606
1655
  const [state, setState] = useState({
1607
1656
  credentialsLoaded: false,
1608
1657
  processToken: null,
@@ -1620,7 +1669,7 @@ function useNativeAuth(options) {
1620
1669
  });
1621
1670
  const [accountType, setAccountType] = useState("email");
1622
1671
  const handleTokenInvalid = useCallback(() => {
1623
- if (debug) console.log("🔐 [HealthCheck] Token invalide — déconnexion locale");
1672
+ if (isDebug) console.log("🔐 [HealthCheck] Token invalide — déconnexion locale");
1624
1673
  clearSession();
1625
1674
  setState({
1626
1675
  credentialsLoaded: false,
@@ -1637,7 +1686,7 @@ function useNativeAuth(options) {
1637
1686
  otpMethod: null,
1638
1687
  otpSentTo: null
1639
1688
  });
1640
- }, [debug]);
1689
+ }, [isDebug]);
1641
1690
  const handleUserUpdated = useCallback((userInfos) => {
1642
1691
  const storedRaw = localStorage.getItem(STORAGE.USER);
1643
1692
  if (storedRaw) {
@@ -1655,7 +1704,7 @@ function useNativeAuth(options) {
1655
1704
  saasApiUrl,
1656
1705
  onTokenInvalid: handleTokenInvalid,
1657
1706
  onUserUpdated: handleUserUpdated,
1658
- debug
1707
+ debug: isDebug
1659
1708
  });
1660
1709
  useEffect(() => {
1661
1710
  const storedToken = localStorage.getItem(STORAGE.AUTH_TOKEN) || localStorage.getItem(STORAGE.TOKEN);
@@ -1674,10 +1723,29 @@ function useNativeAuth(options) {
1674
1723
  loadCredentials();
1675
1724
  }
1676
1725
  }, [autoLoadCredentials, state.credentialsLoaded, state.user]);
1726
+ useEffect(() => {
1727
+ if (state.status === "completed" || !state.credentialsLoaded) return;
1728
+ const ttl = nativeAuthService.getCredentialsTtl();
1729
+ const refreshInterval = Math.max((ttl - 30) * 1e3, 3e4);
1730
+ if (isDebug) {
1731
+ console.log(`🔄 [Native] Auto-refresh credentials every ${refreshInterval / 1e3}s (TTL: ${ttl}s)`);
1732
+ }
1733
+ const timer = setInterval(async () => {
1734
+ try {
1735
+ await nativeAuthService.loadCredentials();
1736
+ setIsDebug(isDebugMode());
1737
+ if (isDebugMode()) console.log("✅ [Native] Credentials auto-refreshed");
1738
+ } catch (err) {
1739
+ if (isDebugMode()) console.warn("⚠️ [Native] Auto-refresh failed:", err);
1740
+ }
1741
+ }, refreshInterval);
1742
+ return () => clearInterval(timer);
1743
+ }, [state.status, state.credentialsLoaded, isDebug]);
1677
1744
  const loadCredentials = useCallback(async () => {
1678
1745
  setState((prev) => ({ ...prev, loading: true, error: null }));
1679
1746
  try {
1680
1747
  await nativeAuthService.loadCredentials();
1748
+ setIsDebug(isDebugMode());
1681
1749
  setState((prev) => ({ ...prev, credentialsLoaded: true, loading: false }));
1682
1750
  return { success: true };
1683
1751
  } catch (err) {
@@ -1901,7 +1969,7 @@ function useNativeAuth(options) {
1901
1969
  if (response.success && response.callback_token) {
1902
1970
  const exchangeResult = await nativeAuthService.exchange(response.callback_token);
1903
1971
  if (exchangeResult.success) {
1904
- const { user: savedUser } = saveSession(exchangeResult, accountType);
1972
+ const { user: savedUser } = saveSession(exchangeResult, defaultAccountType);
1905
1973
  setState((prev) => ({
1906
1974
  ...prev,
1907
1975
  status: "completed",
@@ -1962,7 +2030,7 @@ function useNativeAuth(options) {
1962
2030
  if (response.success && response.callback_token) {
1963
2031
  const exchangeResult = await nativeAuthService.exchange(response.callback_token);
1964
2032
  if (exchangeResult.success) {
1965
- const { user: savedUser } = saveSession(exchangeResult, accountType);
2033
+ const { user: savedUser } = saveSession(exchangeResult, defaultAccountType);
1966
2034
  setState((prev) => ({
1967
2035
  ...prev,
1968
2036
  status: "completed",
@@ -2023,7 +2091,7 @@ function useNativeAuth(options) {
2023
2091
  if (response.success && response.callback_token) {
2024
2092
  const exchangeResult = await nativeAuthService.exchange(response.callback_token);
2025
2093
  if (exchangeResult.success) {
2026
- const { user: savedUser } = saveSession(exchangeResult, accountType);
2094
+ const { user: savedUser } = saveSession(exchangeResult, defaultAccountType);
2027
2095
  setState((prev) => ({
2028
2096
  ...prev,
2029
2097
  status: "completed",
@@ -2057,7 +2125,7 @@ function useNativeAuth(options) {
2057
2125
  if (response.success && response.callback_token) {
2058
2126
  const exchangeResult = await nativeAuthService.exchange(response.callback_token);
2059
2127
  if (exchangeResult.success) {
2060
- const { user: savedUser } = saveSession(exchangeResult, accountType);
2128
+ const { user: savedUser } = saveSession(exchangeResult, defaultAccountType);
2061
2129
  setState((prev) => ({
2062
2130
  ...prev,
2063
2131
  status: "completed",
@@ -2102,14 +2170,14 @@ function useNativeAuth(options) {
2102
2170
  }
2103
2171
  }, [state.processToken]);
2104
2172
  const setSession = useCallback((data) => {
2105
- const { user: savedUser } = saveSession(data, accountType);
2173
+ const { user: savedUser } = saveSession(data, defaultAccountType);
2106
2174
  setState((prev) => ({
2107
2175
  ...prev,
2108
2176
  user: savedUser,
2109
2177
  status: "completed",
2110
2178
  processToken: null
2111
2179
  }));
2112
- }, [accountType]);
2180
+ }, [defaultAccountType]);
2113
2181
  const logout = useCallback(async () => {
2114
2182
  const token = localStorage.getItem(STORAGE.AUTH_TOKEN) || localStorage.getItem(STORAGE.TOKEN);
2115
2183
  try {
@@ -2165,6 +2233,8 @@ function useNativeAuth(options) {
2165
2233
  error: state.error,
2166
2234
  errorType: state.errorType,
2167
2235
  isAuthenticated: state.status === "completed" && state.user !== null,
2236
+ /** Debug réactif — mis à jour après loadCredentials */
2237
+ isDebug,
2168
2238
  accountType,
2169
2239
  isPhoneOnly: accountType === "phone-only",
2170
2240
  otpMethod: state.otpMethod,
@@ -2269,7 +2339,7 @@ function LoginModal({
2269
2339
  iamApiUrl,
2270
2340
  loading,
2271
2341
  showSwitchToSignup = true,
2272
- debug = false
2342
+ defaultAccountType
2273
2343
  }) {
2274
2344
  const {
2275
2345
  status,
@@ -2288,7 +2358,7 @@ function LoginModal({
2288
2358
  setSession,
2289
2359
  reset: resetAuth,
2290
2360
  clearError
2291
- } = useNativeAuth({ saasApiUrl, iamApiUrl, debug });
2361
+ } = useNativeAuth({ saasApiUrl, iamApiUrl, defaultAccountType });
2292
2362
  const [step, setStep] = useState("choice");
2293
2363
  const [email, setEmail] = useState("");
2294
2364
  const [password, setPassword] = useState("");
@@ -2797,8 +2867,7 @@ function LoginModal({
2797
2867
  onOpenChange: setShowPasswordRecovery,
2798
2868
  onSuccess: () => setShowPasswordRecovery(false),
2799
2869
  saasApiUrl,
2800
- iamApiUrl,
2801
- debug
2870
+ iamApiUrl
2802
2871
  }
2803
2872
  )
2804
2873
  ] });
@@ -2883,17 +2952,18 @@ function PhoneInput({
2883
2952
  ] })
2884
2953
  ] });
2885
2954
  }
2886
- function AppsLogoSlider({ speed = "normal", className = "" }) {
2955
+ function AppsLogoSlider({ speed = "normal", className = "", iamApiUrl: iamApiUrlProp }) {
2887
2956
  const scrollRef = useRef(null);
2888
2957
  const [isPaused, setIsPaused] = useState(false);
2889
2958
  const [applications, setApplications] = useState([]);
2890
2959
  const [isLoading, setIsLoading] = useState(true);
2891
2960
  const speedMap = { slow: 50, normal: 30, fast: 15 };
2892
2961
  useEffect(() => {
2962
+ const resolvedIamApiUrl = iamApiUrlProp || getNativeAuthConfig().iamApiUrl;
2963
+ if (!resolvedIamApiUrl) return;
2893
2964
  const fetchApps = async () => {
2894
2965
  try {
2895
- const config2 = getNativeAuthConfig();
2896
- const iamBaseUrl = config2.iamApiUrl.replace("/api", "");
2966
+ const iamBaseUrl = resolvedIamApiUrl.replace("/api", "");
2897
2967
  const response = await fetch(`${iamBaseUrl}/api/public/applications`, { headers: { "Accept": "application/json" } });
2898
2968
  if (response.ok) {
2899
2969
  const data = await response.json();
@@ -2905,7 +2975,7 @@ function AppsLogoSlider({ speed = "normal", className = "" }) {
2905
2975
  }
2906
2976
  };
2907
2977
  fetchApps();
2908
- }, []);
2978
+ }, [iamApiUrlProp]);
2909
2979
  useEffect(() => {
2910
2980
  const container = scrollRef.current;
2911
2981
  if (!container || applications.length === 0) return;
@@ -2922,8 +2992,8 @@ function AppsLogoSlider({ speed = "normal", className = "" }) {
2922
2992
  const getLogoUrl = (logo) => {
2923
2993
  if (!logo) return null;
2924
2994
  if (logo.startsWith("http")) return logo;
2925
- const config2 = getNativeAuthConfig();
2926
- return `${config2.iamApiUrl.replace("/api", "")}/storage/applications/${logo}`;
2995
+ const resolvedUrl = iamApiUrlProp || getNativeAuthConfig().iamApiUrl;
2996
+ return `${resolvedUrl.replace("/api", "")}/storage/applications/${logo}`;
2927
2997
  };
2928
2998
  if (isLoading) {
2929
2999
  return /* @__PURE__ */ jsx("div", { className, style: { overflow: "hidden" }, children: /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "1rem", padding: "0.5rem 0" }, children: [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ jsxs("div", { style: { flexShrink: 0, display: "flex", flexDirection: "column", alignItems: "center", gap: "0.5rem" }, children: [
@@ -3056,8 +3126,7 @@ function useMobileRegistration(options) {
3056
3126
  if (options && !configuredRef.current) {
3057
3127
  setNativeAuthConfig({
3058
3128
  saasApiUrl: options.saasApiUrl,
3059
- iamApiUrl: options.iamApiUrl,
3060
- debug: options.debug
3129
+ iamApiUrl: options.iamApiUrl
3061
3130
  });
3062
3131
  configuredRef.current = true;
3063
3132
  }
@@ -3356,7 +3425,7 @@ function SuccessOrbit() {
3356
3425
  })
3357
3426
  ] });
3358
3427
  }
3359
- function SignupModal({ open, onOpenChange, onSwitchToLogin, onSignupSuccess, saasApiUrl, iamApiUrl, debug = false }) {
3428
+ function SignupModal({ open, onOpenChange, onSwitchToLogin, onSignupSuccess, saasApiUrl, iamApiUrl, defaultAccountType }) {
3360
3429
  const {
3361
3430
  status,
3362
3431
  formData,
@@ -3372,7 +3441,7 @@ function SignupModal({ open, onOpenChange, onSwitchToLogin, onSignupSuccess, saa
3372
3441
  resendOtp,
3373
3442
  reset: resetReg,
3374
3443
  clearError
3375
- } = useMobileRegistration({ saasApiUrl, iamApiUrl, debug });
3444
+ } = useMobileRegistration({ saasApiUrl, iamApiUrl });
3376
3445
  const [step, setStep] = useState("intro");
3377
3446
  const [otpCode, setOtpCode] = useState("");
3378
3447
  const [password, setPassword] = useState("");
@@ -3519,7 +3588,7 @@ function SignupModal({ open, onOpenChange, onSwitchToLogin, onSignupSuccess, saa
3519
3588
  /* @__PURE__ */ jsx(DialogTitle, { children: "Ouvrez un compte Ollaid" }),
3520
3589
  /* @__PURE__ */ jsx(DialogDescription, { children: "Un compte unique qui vous donne accès à toutes les applications" })
3521
3590
  ] }),
3522
- /* @__PURE__ */ jsx(AppsLogoSlider, {}),
3591
+ /* @__PURE__ */ jsx(AppsLogoSlider, { iamApiUrl }),
3523
3592
  /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem", fontSize: "0.875rem", color: C$1.gray500, margin: "1rem 0" }, children: ["Un seul compte pour toutes les applications", "Plus besoin de multiples mots de passe", "Connexion simplifiée et sécurisée"].map((text) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.75rem" }, children: [
3524
3593
  /* @__PURE__ */ jsx(IconCheckCircle2, { style: { width: "1.25rem", height: "1.25rem", color: C$1.green, flexShrink: 0 } }),
3525
3594
  text
@@ -4073,7 +4142,8 @@ function NativeSSOPage({
4073
4142
  onLoginSuccess,
4074
4143
  onLogout,
4075
4144
  onOnboardingComplete,
4076
- debug,
4145
+ accountType = "user",
4146
+ configPrefix = "iam",
4077
4147
  title = "Un compte, plusieurs accès",
4078
4148
  description = "Connectez-vous avec votre compte Ollaid pour accéder à toutes les applications partenaires.",
4079
4149
  logoUrl,
@@ -4091,7 +4161,7 @@ function NativeSSOPage({
4091
4161
  }
4092
4162
  return null;
4093
4163
  });
4094
- const resolvedDebug = debug !== void 0 ? debug : isDebugMode();
4164
+ const { isDebug: resolvedDebug } = useNativeAuth({ saasApiUrl, iamApiUrl, configPrefix, autoLoadCredentials: true });
4095
4165
  useEffect(() => {
4096
4166
  const root = document.documentElement;
4097
4167
  const originalValues = {};
@@ -4170,6 +4240,7 @@ function NativeSSOPage({
4170
4240
  localStorage.removeItem(STORAGE.TOKEN);
4171
4241
  localStorage.removeItem(STORAGE.USER);
4172
4242
  localStorage.removeItem(STORAGE.ACCOUNT_TYPE);
4243
+ localStorage.removeItem(STORAGE.ALIAS_REFERENCE);
4173
4244
  setSession(null);
4174
4245
  onLogout == null ? void 0 : onLogout();
4175
4246
  }, [onLogout]);
@@ -4207,7 +4278,7 @@ function NativeSSOPage({
4207
4278
  ] }) });
4208
4279
  if (session) {
4209
4280
  return /* @__PURE__ */ jsxs("div", { style: containerStyle, children: [
4210
- /* @__PURE__ */ jsx("div", { style: { width: "100%", maxWidth: "28rem", marginBottom: "1.5rem" }, children: /* @__PURE__ */ jsx(AppsLogoSlider, {}) }),
4281
+ /* @__PURE__ */ jsx("div", { style: { width: "100%", maxWidth: "28rem", marginBottom: "1.5rem" }, children: /* @__PURE__ */ jsx(AppsLogoSlider, { iamApiUrl }) }),
4211
4282
  /* @__PURE__ */ jsx("div", { style: cardStyle, children: /* @__PURE__ */ jsxs("div", { style: { padding: "2rem 1.5rem 1.5rem" }, children: [
4212
4283
  /* @__PURE__ */ jsx(BrandingHeader, {}),
4213
4284
  /* @__PURE__ */ jsxs("h2", { style: { fontSize: "1.25rem", fontWeight: 600, textAlign: "center", color: COLORS.cardForeground }, children: [
@@ -4227,7 +4298,7 @@ function NativeSSOPage({
4227
4298
  ] });
4228
4299
  }
4229
4300
  return /* @__PURE__ */ jsxs("div", { style: containerStyle, children: [
4230
- /* @__PURE__ */ jsx("div", { style: { width: "100%", maxWidth: "28rem", marginBottom: "1.5rem" }, children: logoUrl ? /* @__PURE__ */ jsx("img", { src: logoUrl, alt: "Logo", style: { height: "3rem", margin: "0 auto" } }) : /* @__PURE__ */ jsx(AppsLogoSlider, {}) }),
4301
+ /* @__PURE__ */ jsx("div", { style: { width: "100%", maxWidth: "28rem", marginBottom: "1.5rem" }, children: logoUrl ? /* @__PURE__ */ jsx("img", { src: logoUrl, alt: "Logo", style: { height: "3rem", margin: "0 auto" } }) : /* @__PURE__ */ jsx(AppsLogoSlider, { iamApiUrl }) }),
4231
4302
  /* @__PURE__ */ jsx("div", { style: cardStyle, children: /* @__PURE__ */ jsxs("div", { style: { padding: "2rem 1.5rem 1.5rem" }, children: [
4232
4303
  /* @__PURE__ */ jsx(BrandingHeader, {}),
4233
4304
  /* @__PURE__ */ jsx("h2", { style: { fontSize: "1.25rem", fontWeight: 600, textAlign: "center", color: COLORS.cardForeground, marginBottom: "0.5rem" }, children: title }),
@@ -4268,7 +4339,7 @@ function NativeSSOPage({
4268
4339
  onLoginSuccess: handleLoginSuccess,
4269
4340
  saasApiUrl,
4270
4341
  iamApiUrl,
4271
- debug: resolvedDebug
4342
+ defaultAccountType: accountType
4272
4343
  }
4273
4344
  ),
4274
4345
  /* @__PURE__ */ jsx(
@@ -4282,7 +4353,7 @@ function NativeSSOPage({
4282
4353
  onSignupSuccess: handleLoginSuccess,
4283
4354
  saasApiUrl,
4284
4355
  iamApiUrl,
4285
- debug: resolvedDebug
4356
+ defaultAccountType: accountType
4286
4357
  }
4287
4358
  ),
4288
4359
  pendingSession && /* @__PURE__ */ jsx(