@ollaid/native-sso 2.7.1 → 2.7.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.cjs +211 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +211 -51
- package/dist/index.js.map +1 -1
- package/dist/services/api.d.ts +22 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7108,6 +7108,27 @@ function isRawStorageKey(key) {
|
|
|
7108
7108
|
function getLegacyStorageKey(key) {
|
|
7109
7109
|
return LEGACY_STORAGE_KEYS[key] || null;
|
|
7110
7110
|
}
|
|
7111
|
+
function normalizeStorageValue(value) {
|
|
7112
|
+
if (typeof value === "string") return value;
|
|
7113
|
+
if (value === null || value === void 0) return "";
|
|
7114
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
7115
|
+
return String(value);
|
|
7116
|
+
}
|
|
7117
|
+
try {
|
|
7118
|
+
const serialized = JSON.stringify(value);
|
|
7119
|
+
return serialized ?? "";
|
|
7120
|
+
} catch {
|
|
7121
|
+
return String(value);
|
|
7122
|
+
}
|
|
7123
|
+
}
|
|
7124
|
+
function safeJSONStringify(value) {
|
|
7125
|
+
try {
|
|
7126
|
+
const serialized = JSON.stringify(value);
|
|
7127
|
+
return serialized ?? "null";
|
|
7128
|
+
} catch {
|
|
7129
|
+
return "null";
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7111
7132
|
function migrateLegacyValue(base, key, legacyKey, rawValue) {
|
|
7112
7133
|
base.setItem(key, encryptStorageValue(rawValue));
|
|
7113
7134
|
base.removeItem(legacyKey);
|
|
@@ -7116,31 +7137,44 @@ function migrateLegacyValue(base, key, legacyKey, rawValue) {
|
|
|
7116
7137
|
function getStorageEncryptionSecret() {
|
|
7117
7138
|
var _a;
|
|
7118
7139
|
const storage = rawStorageAdapter;
|
|
7119
|
-
let seed = storage.getItem(
|
|
7140
|
+
let seed = storage.getItem(STORAGE_SEED_KEY);
|
|
7120
7141
|
if (!seed) {
|
|
7121
7142
|
seed = `seed_${Date.now()}_${Math.random().toString(36).substring(2, 15)}_${Math.random().toString(36).substring(2, 15)}`;
|
|
7122
|
-
storage.setItem(
|
|
7143
|
+
storage.setItem(STORAGE_SEED_KEY, seed);
|
|
7123
7144
|
}
|
|
7124
7145
|
const origin = typeof window !== "undefined" && ((_a = window.location) == null ? void 0 : _a.origin) ? window.location.origin : "unknown-origin";
|
|
7125
7146
|
const prefix = config.configPrefix || "iam";
|
|
7126
7147
|
return `${STORAGE_ENCRYPTION_SECRET_PREFIX}::${origin}::${prefix}::${seed}`;
|
|
7127
7148
|
}
|
|
7128
7149
|
function encryptStorageValue(value) {
|
|
7129
|
-
const
|
|
7130
|
-
|
|
7131
|
-
|
|
7150
|
+
const normalizedValue = normalizeStorageValue(value);
|
|
7151
|
+
try {
|
|
7152
|
+
const secret = getStorageEncryptionSecret();
|
|
7153
|
+
const ciphertext = cryptoJsExports.AES.encrypt(normalizedValue, secret).toString();
|
|
7154
|
+
return `${STORAGE_ENCRYPTION_PREFIX}${ciphertext}`;
|
|
7155
|
+
} catch (error) {
|
|
7156
|
+
if (isDebugMode()) {
|
|
7157
|
+
console.warn("⚠️ [native-sso] Encryption storage fallback to plain value", error);
|
|
7158
|
+
}
|
|
7159
|
+
return normalizedValue;
|
|
7160
|
+
}
|
|
7132
7161
|
}
|
|
7133
7162
|
function decryptStorageValue(value) {
|
|
7134
|
-
|
|
7135
|
-
|
|
7163
|
+
const normalizedValue = normalizeStorageValue(value);
|
|
7164
|
+
if (!normalizedValue.startsWith(STORAGE_ENCRYPTION_PREFIX)) {
|
|
7165
|
+
return normalizedValue;
|
|
7136
7166
|
}
|
|
7137
|
-
const
|
|
7138
|
-
|
|
7167
|
+
const ciphertext = normalizedValue.slice(STORAGE_ENCRYPTION_PREFIX.length);
|
|
7168
|
+
if (!ciphertext) return null;
|
|
7139
7169
|
try {
|
|
7170
|
+
const secret = getStorageEncryptionSecret();
|
|
7140
7171
|
const bytes = cryptoJsExports.AES.decrypt(ciphertext, secret);
|
|
7141
7172
|
const plaintext = bytes.toString(cryptoJsExports.enc.Utf8);
|
|
7142
7173
|
return plaintext || null;
|
|
7143
|
-
} catch {
|
|
7174
|
+
} catch (error) {
|
|
7175
|
+
if (isDebugMode()) {
|
|
7176
|
+
console.warn("⚠️ [native-sso] Failed to decrypt storage value, clearing corrupted entry", error);
|
|
7177
|
+
}
|
|
7144
7178
|
return null;
|
|
7145
7179
|
}
|
|
7146
7180
|
}
|
|
@@ -7156,8 +7190,9 @@ function createEncryptedStorageAdapter(base) {
|
|
|
7156
7190
|
if (decrypted !== null) {
|
|
7157
7191
|
return decrypted;
|
|
7158
7192
|
}
|
|
7159
|
-
if (rawValue.
|
|
7160
|
-
base.
|
|
7193
|
+
if (normalizeStorageValue(rawValue).startsWith(STORAGE_ENCRYPTION_PREFIX)) {
|
|
7194
|
+
base.removeItem(key);
|
|
7195
|
+
return null;
|
|
7161
7196
|
}
|
|
7162
7197
|
return rawValue;
|
|
7163
7198
|
}
|
|
@@ -7178,7 +7213,7 @@ function createEncryptedStorageAdapter(base) {
|
|
|
7178
7213
|
},
|
|
7179
7214
|
setItem: (key, value) => {
|
|
7180
7215
|
if (isRawStorageKey(key)) {
|
|
7181
|
-
base.setItem(key, value);
|
|
7216
|
+
base.setItem(key, normalizeStorageValue(value));
|
|
7182
7217
|
return;
|
|
7183
7218
|
}
|
|
7184
7219
|
base.setItem(key, encryptStorageValue(value));
|
|
@@ -7230,6 +7265,7 @@ const getIamApiBaseUrl = () => {
|
|
|
7230
7265
|
};
|
|
7231
7266
|
const DEVICE_ID_KEY = "sso_device_id";
|
|
7232
7267
|
const SESSION_UUID_KEY = "sso_session_uuid";
|
|
7268
|
+
const STORAGE_SEED_KEY = "native_sso_storage_seed";
|
|
7233
7269
|
function generateUuid() {
|
|
7234
7270
|
const globalCrypto = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
|
|
7235
7271
|
if (globalCrypto && typeof globalCrypto.randomUUID === "function") {
|
|
@@ -7337,8 +7373,26 @@ const PROFILE_STORAGE = {
|
|
|
7337
7373
|
IMAGE_LAST_CHECK: "sso_image_last_check",
|
|
7338
7374
|
IMAGE_RECHECK_AT: "sso_image_recheck_at"
|
|
7339
7375
|
};
|
|
7376
|
+
const ALL_SESSION_STORAGE_KEYS = [
|
|
7377
|
+
STORAGE.AUTH_TOKEN,
|
|
7378
|
+
STORAGE.TOKEN,
|
|
7379
|
+
STORAGE.USER,
|
|
7380
|
+
STORAGE.ACCOUNT_TYPE,
|
|
7381
|
+
STORAGE.ALIAS_REFERENCE,
|
|
7382
|
+
STORAGE.APP_ACCESS_TOKEN_REF,
|
|
7383
|
+
STORAGE.REFRESH_TOKEN,
|
|
7384
|
+
STORAGE.TOKEN_EXPIRES_AT,
|
|
7385
|
+
STORAGE.REFRESH_EXPIRES_AT,
|
|
7386
|
+
PROFILE_STORAGE.IMAGE_LAST_STATUS,
|
|
7387
|
+
PROFILE_STORAGE.IMAGE_LAST_CHECK,
|
|
7388
|
+
PROFILE_STORAGE.IMAGE_RECHECK_AT,
|
|
7389
|
+
DEVICE_ID_KEY,
|
|
7390
|
+
SESSION_UUID_KEY,
|
|
7391
|
+
STORAGE_SEED_KEY
|
|
7392
|
+
];
|
|
7340
7393
|
const setAuthToken = (token) => {
|
|
7341
7394
|
const storage = getNativeStorage();
|
|
7395
|
+
if (typeof token !== "string" || token.length === 0) return;
|
|
7342
7396
|
storage.setItem(STORAGE.AUTH_TOKEN, token);
|
|
7343
7397
|
};
|
|
7344
7398
|
const getAuthToken = () => {
|
|
@@ -7357,13 +7411,45 @@ const clearAuthToken = () => {
|
|
|
7357
7411
|
storage.removeItem(STORAGE.TOKEN_EXPIRES_AT);
|
|
7358
7412
|
storage.removeItem(STORAGE.REFRESH_EXPIRES_AT);
|
|
7359
7413
|
};
|
|
7414
|
+
const clearNativeSsoStorage = (options) => {
|
|
7415
|
+
const storage = getNativeStorage();
|
|
7416
|
+
const preserveDeviceIdentity = (options == null ? void 0 : options.preserveDeviceIdentity) === true;
|
|
7417
|
+
ALL_SESSION_STORAGE_KEYS.forEach((key) => {
|
|
7418
|
+
if (preserveDeviceIdentity && (key === DEVICE_ID_KEY || key === SESSION_UUID_KEY || key === STORAGE_SEED_KEY)) {
|
|
7419
|
+
return;
|
|
7420
|
+
}
|
|
7421
|
+
storage.removeItem(key);
|
|
7422
|
+
});
|
|
7423
|
+
};
|
|
7424
|
+
const repairNativeSsoStorage = () => {
|
|
7425
|
+
const storage = getNativeStorage();
|
|
7426
|
+
const authToken = getAuthToken();
|
|
7427
|
+
const userRaw = storage.getItem(STORAGE.USER);
|
|
7428
|
+
if (userRaw && !authToken) {
|
|
7429
|
+
clearNativeSsoStorage();
|
|
7430
|
+
return { cleaned: true, reason: "incomplete_session" };
|
|
7431
|
+
}
|
|
7432
|
+
if (authToken && !userRaw) {
|
|
7433
|
+
clearNativeSsoStorage();
|
|
7434
|
+
return { cleaned: true, reason: "incomplete_session" };
|
|
7435
|
+
}
|
|
7436
|
+
if (userRaw) {
|
|
7437
|
+
try {
|
|
7438
|
+
JSON.parse(userRaw);
|
|
7439
|
+
} catch {
|
|
7440
|
+
clearNativeSsoStorage();
|
|
7441
|
+
return { cleaned: true, reason: "invalid_user_json" };
|
|
7442
|
+
}
|
|
7443
|
+
}
|
|
7444
|
+
return { cleaned: false, reason: null };
|
|
7445
|
+
};
|
|
7360
7446
|
const logout = async () => {
|
|
7361
7447
|
const { nativeAuthService: nativeAuthService2 } = await Promise.resolve().then(() => nativeAuth);
|
|
7362
7448
|
const token = getAuthToken();
|
|
7363
7449
|
return nativeAuthService2.logout(token || void 0);
|
|
7364
7450
|
};
|
|
7365
7451
|
const setAuthUser = (user) => {
|
|
7366
|
-
getNativeStorage().setItem(STORAGE.USER,
|
|
7452
|
+
getNativeStorage().setItem(STORAGE.USER, safeJSONStringify(user));
|
|
7367
7453
|
};
|
|
7368
7454
|
const getAuthUser = () => {
|
|
7369
7455
|
const user = getNativeStorage().getItem(STORAGE.USER);
|
|
@@ -9617,6 +9703,8 @@ function LoginModal({
|
|
|
9617
9703
|
const [loginSuccess, setLoginSuccess] = react.useState(false);
|
|
9618
9704
|
const [loginData, setLoginData] = react.useState(null);
|
|
9619
9705
|
const [showPasswordRecovery, setShowPasswordRecovery] = react.useState(false);
|
|
9706
|
+
const [passwordSubmitting, setPasswordSubmitting] = react.useState(false);
|
|
9707
|
+
const successCallbackTimerRef = react.useRef(null);
|
|
9620
9708
|
const CCPHONE = "+221";
|
|
9621
9709
|
const isSubmitting = authLoading || loading;
|
|
9622
9710
|
const error = localError || authError;
|
|
@@ -9634,15 +9722,11 @@ function LoginModal({
|
|
|
9634
9722
|
setResendCooldown(60);
|
|
9635
9723
|
}
|
|
9636
9724
|
}, [status, step]);
|
|
9637
|
-
react.useEffect(() => {
|
|
9638
|
-
if (loginSuccess && loginData) {
|
|
9639
|
-
const timer = setTimeout(() => {
|
|
9640
|
-
onLoginSuccess == null ? void 0 : onLoginSuccess(loginData.token, loginData.user);
|
|
9641
|
-
}, 1e3);
|
|
9642
|
-
return () => clearTimeout(timer);
|
|
9643
|
-
}
|
|
9644
|
-
}, [loginSuccess, loginData, onLoginSuccess]);
|
|
9645
9725
|
const resetState = react.useCallback(() => {
|
|
9726
|
+
if (successCallbackTimerRef.current) {
|
|
9727
|
+
clearTimeout(successCallbackTimerRef.current);
|
|
9728
|
+
successCallbackTimerRef.current = null;
|
|
9729
|
+
}
|
|
9646
9730
|
setStep("choice");
|
|
9647
9731
|
setEmail("");
|
|
9648
9732
|
setPassword("");
|
|
@@ -9656,6 +9740,7 @@ function LoginModal({
|
|
|
9656
9740
|
setLoginSuccess(false);
|
|
9657
9741
|
setLoginData(null);
|
|
9658
9742
|
setResendCooldown(0);
|
|
9743
|
+
setPasswordSubmitting(false);
|
|
9659
9744
|
resetAuth();
|
|
9660
9745
|
}, [resetAuth]);
|
|
9661
9746
|
react.useEffect(() => {
|
|
@@ -9668,12 +9753,34 @@ function LoginModal({
|
|
|
9668
9753
|
}
|
|
9669
9754
|
}, [open, initialPhone]);
|
|
9670
9755
|
const finalizeLogin = (result) => {
|
|
9671
|
-
if (result.success
|
|
9756
|
+
if (result.success) {
|
|
9672
9757
|
const token = getAuthToken() || "";
|
|
9673
|
-
|
|
9674
|
-
|
|
9758
|
+
const resolvedUser = result.user || user;
|
|
9759
|
+
if (resolvedUser) {
|
|
9760
|
+
setLoginData({ token, user: resolvedUser });
|
|
9761
|
+
setLoginSuccess(true);
|
|
9762
|
+
}
|
|
9675
9763
|
}
|
|
9676
9764
|
};
|
|
9765
|
+
react.useEffect(() => {
|
|
9766
|
+
if (!loginSuccess || !loginData || !onLoginSuccess) return;
|
|
9767
|
+
if (successCallbackTimerRef.current) {
|
|
9768
|
+
clearTimeout(successCallbackTimerRef.current);
|
|
9769
|
+
}
|
|
9770
|
+
successCallbackTimerRef.current = setTimeout(() => {
|
|
9771
|
+
try {
|
|
9772
|
+
onLoginSuccess(loginData.token, loginData.user);
|
|
9773
|
+
} catch (callbackError) {
|
|
9774
|
+
console.error("Erreur dans onLoginSuccess", callbackError);
|
|
9775
|
+
}
|
|
9776
|
+
}, 900);
|
|
9777
|
+
return () => {
|
|
9778
|
+
if (successCallbackTimerRef.current) {
|
|
9779
|
+
clearTimeout(successCallbackTimerRef.current);
|
|
9780
|
+
successCallbackTimerRef.current = null;
|
|
9781
|
+
}
|
|
9782
|
+
};
|
|
9783
|
+
}, [loginSuccess, loginData, onLoginSuccess]);
|
|
9677
9784
|
const handleEmailCheck = async () => {
|
|
9678
9785
|
setLocalError(null);
|
|
9679
9786
|
clearError();
|
|
@@ -9690,18 +9797,24 @@ function LoginModal({
|
|
|
9690
9797
|
};
|
|
9691
9798
|
const handleEmailPasswordSubmit = async (e) => {
|
|
9692
9799
|
e.preventDefault();
|
|
9800
|
+
if (passwordSubmitting || isSubmitting) return;
|
|
9801
|
+
setPasswordSubmitting(true);
|
|
9693
9802
|
setLocalError(null);
|
|
9694
9803
|
clearError();
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9804
|
+
try {
|
|
9805
|
+
if (!password) {
|
|
9806
|
+
setLocalError("Le mot de passe est requis");
|
|
9807
|
+
return;
|
|
9808
|
+
}
|
|
9809
|
+
if (password.length < 8) {
|
|
9810
|
+
setLocalError("Le mot de passe doit contenir au moins 8 caractères");
|
|
9811
|
+
return;
|
|
9812
|
+
}
|
|
9813
|
+
const result = await submitPassword(password);
|
|
9814
|
+
finalizeLogin(result);
|
|
9815
|
+
} finally {
|
|
9816
|
+
setPasswordSubmitting(false);
|
|
9702
9817
|
}
|
|
9703
|
-
const result = await submitPassword(password);
|
|
9704
|
-
finalizeLogin(result);
|
|
9705
9818
|
};
|
|
9706
9819
|
const handleEmailOtpVerify = async () => {
|
|
9707
9820
|
setLocalError(null);
|
|
@@ -9965,7 +10078,7 @@ function LoginModal({
|
|
|
9965
10078
|
placeholder: "••••••••",
|
|
9966
10079
|
value: password,
|
|
9967
10080
|
onChange: (e) => setPassword(e.target.value),
|
|
9968
|
-
disabled: isSubmitting,
|
|
10081
|
+
disabled: isSubmitting || passwordSubmitting,
|
|
9969
10082
|
style: { paddingRight: "2.5rem" }
|
|
9970
10083
|
}
|
|
9971
10084
|
),
|
|
@@ -9981,7 +10094,7 @@ function LoginModal({
|
|
|
9981
10094
|
] })
|
|
9982
10095
|
] })
|
|
9983
10096
|
] }) }),
|
|
9984
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", disabled: isSubmitting || !password, style: { width: "100%" }, children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
10097
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", disabled: isSubmitting || passwordSubmitting || !password, style: { width: "100%" }, children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
9985
10098
|
/* @__PURE__ */ jsxRuntime.jsx(IconLoader2, { style: { width: "1rem", height: "1rem" } }),
|
|
9986
10099
|
"Connexion..."
|
|
9987
10100
|
] }) : "Se connecter" }) })
|
|
@@ -13237,6 +13350,8 @@ function NativeSSOPage({
|
|
|
13237
13350
|
const [showOnboarding, setShowOnboarding] = react.useState(false);
|
|
13238
13351
|
const [pendingSession, setPendingSession] = react.useState(null);
|
|
13239
13352
|
const [debugOnboardingState, setDebugOnboardingState] = react.useState(null);
|
|
13353
|
+
const [redirectingTarget, setRedirectingTarget] = react.useState(null);
|
|
13354
|
+
const [redirectingReason, setRedirectingReason] = react.useState(null);
|
|
13240
13355
|
const [session, setSession] = react.useState(() => {
|
|
13241
13356
|
try {
|
|
13242
13357
|
const storage2 = getNativeStorage();
|
|
@@ -13259,6 +13374,27 @@ function NativeSSOPage({
|
|
|
13259
13374
|
react.useEffect(() => {
|
|
13260
13375
|
sessionRef.current = session;
|
|
13261
13376
|
}, [session]);
|
|
13377
|
+
react.useEffect(() => {
|
|
13378
|
+
const repairResult = repairNativeSsoStorage();
|
|
13379
|
+
if (repairResult.cleaned) {
|
|
13380
|
+
setSession(null);
|
|
13381
|
+
const isDev = Boolean(false);
|
|
13382
|
+
if (isDev) {
|
|
13383
|
+
console.warn("🔧 [NativeSSOPage] Storage SSO réparé", repairResult.reason);
|
|
13384
|
+
}
|
|
13385
|
+
}
|
|
13386
|
+
}, []);
|
|
13387
|
+
react.useEffect(() => {
|
|
13388
|
+
if (!redirectingTarget) return;
|
|
13389
|
+
const timer = window.setTimeout(() => {
|
|
13390
|
+
const redirected = safeRedirect(redirectingTarget);
|
|
13391
|
+
if (!redirected) {
|
|
13392
|
+
setRedirectingTarget(null);
|
|
13393
|
+
setRedirectingReason(null);
|
|
13394
|
+
}
|
|
13395
|
+
}, 200);
|
|
13396
|
+
return () => window.clearTimeout(timer);
|
|
13397
|
+
}, [redirectingTarget]);
|
|
13262
13398
|
const clearOnboardingTimers = react.useCallback(() => {
|
|
13263
13399
|
if (onboardingPromptTimerRef.current) {
|
|
13264
13400
|
clearTimeout(onboardingPromptTimerRef.current);
|
|
@@ -13426,6 +13562,12 @@ function NativeSSOPage({
|
|
|
13426
13562
|
setLoginInitialPhone(phone);
|
|
13427
13563
|
setTimeout(() => setModal("login"), 150);
|
|
13428
13564
|
}, []);
|
|
13565
|
+
const beginRedirect = react.useCallback((target, reason = "login") => {
|
|
13566
|
+
if (!target) return false;
|
|
13567
|
+
setRedirectingReason(reason);
|
|
13568
|
+
setRedirectingTarget(target);
|
|
13569
|
+
return true;
|
|
13570
|
+
}, []);
|
|
13429
13571
|
const handleLoginSuccess = react.useCallback((token, user) => {
|
|
13430
13572
|
const userObj = {
|
|
13431
13573
|
reference: "",
|
|
@@ -13442,10 +13584,14 @@ function NativeSSOPage({
|
|
|
13442
13584
|
void refreshSessionProfile(true);
|
|
13443
13585
|
if (!needsOnboarding(userObj)) {
|
|
13444
13586
|
markProfilePromptComplete();
|
|
13445
|
-
|
|
13446
|
-
|
|
13587
|
+
try {
|
|
13588
|
+
onLoginSuccess == null ? void 0 : onLoginSuccess(token, user);
|
|
13589
|
+
} catch (callbackError) {
|
|
13590
|
+
console.error("Erreur dans le callback onLoginSuccess du wrapper SSO", callbackError);
|
|
13591
|
+
}
|
|
13592
|
+
beginRedirect(redirectAfterLogin, "login");
|
|
13447
13593
|
}
|
|
13448
|
-
}, [onLoginSuccess, redirectAfterLogin, persistSessionUser, syncProfilePrompt, refreshSessionProfile, accountType]);
|
|
13594
|
+
}, [onLoginSuccess, redirectAfterLogin, persistSessionUser, syncProfilePrompt, refreshSessionProfile, accountType, beginRedirect]);
|
|
13449
13595
|
const handleOnboardingComplete = react.useCallback((data) => {
|
|
13450
13596
|
const activeSession = debugOnboardingState || pendingSession;
|
|
13451
13597
|
if (!activeSession) return;
|
|
@@ -13489,11 +13635,15 @@ function NativeSSOPage({
|
|
|
13489
13635
|
if (!debugOnboardingState) {
|
|
13490
13636
|
persistSessionUser(activeSession.token, activeSession.user);
|
|
13491
13637
|
snoozeProfilePrompt(PROFILE_PROMPT_SNOOZE_MS / (60 * 60 * 1e3));
|
|
13492
|
-
|
|
13493
|
-
|
|
13638
|
+
try {
|
|
13639
|
+
onLoginSuccess == null ? void 0 : onLoginSuccess(activeSession.token, activeSession.user);
|
|
13640
|
+
} catch (callbackError) {
|
|
13641
|
+
console.error("Erreur dans le callback onLoginSuccess du wrapper SSO", callbackError);
|
|
13642
|
+
}
|
|
13643
|
+
beginRedirect(redirectAfterLogin, "login");
|
|
13494
13644
|
return;
|
|
13495
13645
|
}
|
|
13496
|
-
}, [pendingSession, debugOnboardingState, onLoginSuccess, redirectAfterLogin, persistSessionUser]);
|
|
13646
|
+
}, [pendingSession, debugOnboardingState, onLoginSuccess, redirectAfterLogin, persistSessionUser, beginRedirect]);
|
|
13497
13647
|
const handleOnboardingDismiss = react.useCallback(() => {
|
|
13498
13648
|
setShowOnboarding(false);
|
|
13499
13649
|
setPendingSession(null);
|
|
@@ -13506,8 +13656,8 @@ function NativeSSOPage({
|
|
|
13506
13656
|
setDebugOnboardingState(null);
|
|
13507
13657
|
clearOnboardingTimers();
|
|
13508
13658
|
onLogout == null ? void 0 : onLogout();
|
|
13509
|
-
|
|
13510
|
-
}, [onLogout, redirectAfterLogout, clearOnboardingTimers]);
|
|
13659
|
+
beginRedirect(redirectAfterLogout, "logout");
|
|
13660
|
+
}, [onLogout, redirectAfterLogout, clearOnboardingTimers, beginRedirect]);
|
|
13511
13661
|
const openDebugLogin = react.useCallback(() => {
|
|
13512
13662
|
clearOnboardingTimers();
|
|
13513
13663
|
setShowOnboarding(false);
|
|
@@ -13522,6 +13672,10 @@ function NativeSSOPage({
|
|
|
13522
13672
|
setDebugOnboardingState(null);
|
|
13523
13673
|
setModal("signup");
|
|
13524
13674
|
}, [clearOnboardingTimers]);
|
|
13675
|
+
react.useEffect(() => {
|
|
13676
|
+
if (!(session == null ? void 0 : session.token) || !redirectAfterLogin || redirectingTarget) return;
|
|
13677
|
+
beginRedirect(redirectAfterLogin, "already-authenticated");
|
|
13678
|
+
}, [session == null ? void 0 : session.token, redirectAfterLogin, redirectingTarget, beginRedirect]);
|
|
13525
13679
|
const openDebugOnboarding = react.useCallback((preset = "current") => {
|
|
13526
13680
|
if (!session) return;
|
|
13527
13681
|
clearOnboardingTimers();
|
|
@@ -13644,14 +13798,18 @@ function NativeSSOPage({
|
|
|
13644
13798
|
overflow: "hidden"
|
|
13645
13799
|
}, children: /* @__PURE__ */ jsxRuntime.jsx(AppsLogoSlider, { iamApiUrl, speed: "normal" }) }) })
|
|
13646
13800
|
] }) });
|
|
13801
|
+
if (redirectingTarget) {
|
|
13802
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: containerStyle, children: [
|
|
13803
|
+
/* @__PURE__ */ jsxRuntime.jsx(TopBranding, { subtitle: title }),
|
|
13804
|
+
/* @__PURE__ */ jsxRuntime.jsx(SliderBadge, {}),
|
|
13805
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: cardStyle, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: "2rem 1.5rem 1.5rem", textAlign: "center" }, children: [
|
|
13806
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { fontSize: "1.25rem", fontWeight: 600, color: COLORS.cardForeground }, children: redirectingReason === "logout" ? "Déconnexion réussie" : redirectingReason === "already-authenticated" ? "Session déjà valide" : "Connexion réussie" }),
|
|
13807
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "0.875rem", color: COLORS.muted, marginTop: "0.5rem" }, children: "Redirection en cours..." })
|
|
13808
|
+
] }) }),
|
|
13809
|
+
/* @__PURE__ */ jsxRuntime.jsx(Footer, { hideFooter })
|
|
13810
|
+
] });
|
|
13811
|
+
}
|
|
13647
13812
|
if (session) {
|
|
13648
|
-
if (redirectAfterLogin) {
|
|
13649
|
-
safeRedirect(redirectAfterLogin);
|
|
13650
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: containerStyle, children: [
|
|
13651
|
-
/* @__PURE__ */ jsxRuntime.jsx(TopBranding, { subtitle: title }),
|
|
13652
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "rgba(255,255,255,0.7)", fontSize: "0.875rem" }, children: "Redirection en cours..." })
|
|
13653
|
-
] });
|
|
13654
|
-
}
|
|
13655
13813
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: containerStyle, children: [
|
|
13656
13814
|
/* @__PURE__ */ jsxRuntime.jsx(TopBranding, { subtitle: title }),
|
|
13657
13815
|
/* @__PURE__ */ jsxRuntime.jsx(SliderBadge, {}),
|
|
@@ -13973,6 +14131,7 @@ exports.PhoneInput = PhoneInput;
|
|
|
13973
14131
|
exports.STORAGE_KEYS = STORAGE;
|
|
13974
14132
|
exports.SignupModal = SignupModal;
|
|
13975
14133
|
exports.clearAuthToken = clearAuthToken;
|
|
14134
|
+
exports.clearNativeSsoStorage = clearNativeSsoStorage;
|
|
13976
14135
|
exports.getAccountType = getAccountType;
|
|
13977
14136
|
exports.getAuthToken = getAuthToken;
|
|
13978
14137
|
exports.getAuthUser = getAuthUser;
|
|
@@ -13993,6 +14152,7 @@ exports.mobilePasswordService = mobilePasswordService;
|
|
|
13993
14152
|
exports.nativeAuthService = nativeAuthService;
|
|
13994
14153
|
exports.profileChangeService = profileChangeService;
|
|
13995
14154
|
exports.profileMediaService = profileMediaService;
|
|
14155
|
+
exports.repairNativeSsoStorage = repairNativeSsoStorage;
|
|
13996
14156
|
exports.searchCountries = searchCountries;
|
|
13997
14157
|
exports.setNativeAuthConfig = setNativeAuthConfig;
|
|
13998
14158
|
exports.setNativeStorage = setNativeStorage;
|