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