@ollaid/native-sso 2.7.3 → 2.7.4
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 +59 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7399,15 +7399,22 @@ const getAuthToken = () => {
|
|
|
7399
7399
|
};
|
|
7400
7400
|
const clearAuthToken = () => {
|
|
7401
7401
|
const storage = getNativeStorage();
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7402
|
+
[
|
|
7403
|
+
STORAGE.AUTH_TOKEN,
|
|
7404
|
+
STORAGE.TOKEN,
|
|
7405
|
+
STORAGE.USER,
|
|
7406
|
+
STORAGE.ACCOUNT_TYPE,
|
|
7407
|
+
STORAGE.ALIAS_REFERENCE,
|
|
7408
|
+
STORAGE.APP_ACCESS_TOKEN_REF,
|
|
7409
|
+
STORAGE.REFRESH_TOKEN,
|
|
7410
|
+
STORAGE.TOKEN_EXPIRES_AT,
|
|
7411
|
+
STORAGE.REFRESH_EXPIRES_AT
|
|
7412
|
+
].forEach((key) => {
|
|
7413
|
+
try {
|
|
7414
|
+
storage.removeItem(key);
|
|
7415
|
+
} catch {
|
|
7416
|
+
}
|
|
7417
|
+
});
|
|
7411
7418
|
};
|
|
7412
7419
|
const clearNativeSsoStorage = (options) => {
|
|
7413
7420
|
const storage = getNativeStorage();
|
|
@@ -7416,30 +7423,44 @@ const clearNativeSsoStorage = (options) => {
|
|
|
7416
7423
|
if (preserveDeviceIdentity && (key === DEVICE_ID_KEY || key === SESSION_UUID_KEY || key === STORAGE_SEED_KEY)) {
|
|
7417
7424
|
return;
|
|
7418
7425
|
}
|
|
7419
|
-
|
|
7426
|
+
try {
|
|
7427
|
+
storage.removeItem(key);
|
|
7428
|
+
} catch {
|
|
7429
|
+
}
|
|
7420
7430
|
});
|
|
7421
7431
|
};
|
|
7422
7432
|
const repairNativeSsoStorage = () => {
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7433
|
+
try {
|
|
7434
|
+
const storage = getNativeStorage();
|
|
7435
|
+
const authToken = getAuthToken();
|
|
7436
|
+
const userRaw = storage.getItem(STORAGE.USER);
|
|
7437
|
+
if (userRaw && !authToken) {
|
|
7438
|
+
clearNativeSsoStorage();
|
|
7439
|
+
return { cleaned: true, reason: "incomplete_session" };
|
|
7440
|
+
}
|
|
7441
|
+
if (authToken && !userRaw) {
|
|
7442
|
+
clearNativeSsoStorage();
|
|
7443
|
+
return { cleaned: true, reason: "incomplete_session" };
|
|
7444
|
+
}
|
|
7445
|
+
if (userRaw) {
|
|
7446
|
+
try {
|
|
7447
|
+
JSON.parse(userRaw);
|
|
7448
|
+
} catch {
|
|
7449
|
+
clearNativeSsoStorage();
|
|
7450
|
+
return { cleaned: true, reason: "invalid_user_json" };
|
|
7451
|
+
}
|
|
7452
|
+
}
|
|
7453
|
+
return { cleaned: false, reason: null };
|
|
7454
|
+
} catch (error) {
|
|
7455
|
+
if (isDebugMode()) {
|
|
7456
|
+
console.warn("⚠️ [native-sso] Storage repair failed, forcing cleanup", error);
|
|
7457
|
+
}
|
|
7435
7458
|
try {
|
|
7436
|
-
JSON.parse(userRaw);
|
|
7437
|
-
} catch {
|
|
7438
7459
|
clearNativeSsoStorage();
|
|
7439
|
-
|
|
7460
|
+
} catch {
|
|
7440
7461
|
}
|
|
7462
|
+
return { cleaned: true, reason: "incomplete_session" };
|
|
7441
7463
|
}
|
|
7442
|
-
return { cleaned: false, reason: null };
|
|
7443
7464
|
};
|
|
7444
7465
|
const logout = async () => {
|
|
7445
7466
|
const { nativeAuthService: nativeAuthService2 } = await Promise.resolve().then(() => nativeAuth);
|
|
@@ -8273,6 +8294,12 @@ function getErrorMessage$2(err, context) {
|
|
|
8273
8294
|
function useMobilePassword(options) {
|
|
8274
8295
|
const { saasApiUrl, iamApiUrl, autoLoadCredentials = true } = options;
|
|
8275
8296
|
const configuredRef = useRef(false);
|
|
8297
|
+
useEffect(() => {
|
|
8298
|
+
const repairResult = repairNativeSsoStorage();
|
|
8299
|
+
if (repairResult.cleaned && isDebugMode()) {
|
|
8300
|
+
console.warn("🔧 [useMobilePassword] Storage SSO réparé", repairResult.reason);
|
|
8301
|
+
}
|
|
8302
|
+
}, []);
|
|
8276
8303
|
useEffect(() => {
|
|
8277
8304
|
if (!configuredRef.current) {
|
|
8278
8305
|
setNativeAuthConfig({ saasApiUrl, iamApiUrl });
|
|
@@ -8918,6 +8945,12 @@ function useNativeAuth(options) {
|
|
|
8918
8945
|
setNativeStorage(storage);
|
|
8919
8946
|
}
|
|
8920
8947
|
const configuredRef = useRef(false);
|
|
8948
|
+
useEffect(() => {
|
|
8949
|
+
const repairResult = repairNativeSsoStorage();
|
|
8950
|
+
if (repairResult.cleaned && isDebugMode()) {
|
|
8951
|
+
console.warn("🔧 [useNativeAuth] Storage SSO réparé", repairResult.reason);
|
|
8952
|
+
}
|
|
8953
|
+
}, []);
|
|
8921
8954
|
const [isDebug, setIsDebug] = useState(isDebugMode());
|
|
8922
8955
|
useEffect(() => {
|
|
8923
8956
|
if (!configuredRef.current) {
|