260508_11_ENH: 새로고침 시 로그인 풀리는 문제 수정 중

This commit is contained in:
2026-05-08 11:23:54 +09:00
parent e528f6a67e
commit b9642961ac
2 changed files with 29 additions and 7 deletions

View File

@@ -165,8 +165,7 @@ export class Security {
}
public static encodeBase64(input: WordArray): string {
const base64 = CryptoJS.enc.Base64.stringify(input);
return this.convertToSpecialChars(base64);
return CryptoJS.enc.Base64.stringify(input);
}
public static decodeBase64(input: string): WordArray {

View File

@@ -22,9 +22,20 @@ const parseStoredValue = (value: string): StorageValue => {
const stringifyStorageValue = (value: StorageValue): string => {
const stringifyValue = JSON.stringify(value);
return stringifyValue;
return clientEnv.ENV === "prod" ? Security.encryptBase64(stringifyValue) : stringifyValue;
};
const isPlainJsonValue = (value: string) => {
const trimmed = value.trim();
return trimmed.startsWith("{") || trimmed.startsWith("[");
};
const isLegacyEncryptedStorageValue = (value: string) =>
value.includes("\u200b") || value.includes("\u200c");
const shouldMigrateStorageValue = (value: string) =>
isPlainJsonValue(value) || isLegacyEncryptedStorageValue(value);
export const setLocalStorage = (key: string, value: StorageValue): void => {
try {
localStorage.setItem(key, stringifyStorageValue(value));
@@ -41,10 +52,16 @@ export const getLocalStorage = (key: string): StorageValue => {
}
try {
return parseStoredValue(storedValue);
const parsedValue = parseStoredValue(storedValue);
if (parsedValue != null && shouldMigrateStorageValue(storedValue)) {
localStorage.setItem(key, stringifyStorageValue(parsedValue));
}
return parsedValue;
} catch (decryptError) {
try {
return JSON.parse(storedValue);
const parsedValue = JSON.parse(storedValue);
localStorage.setItem(key, stringifyStorageValue(parsedValue));
return parsedValue;
} catch (fallbackError) {
console.warn("[storage] localStorage parse failed", {
key,
@@ -84,10 +101,16 @@ export const getSessionStorage = (key: string): StorageValue => {
}
try {
return parseStoredValue(storedValue);
const parsedValue = parseStoredValue(storedValue);
if (parsedValue != null && shouldMigrateStorageValue(storedValue)) {
sessionStorage.setItem(key, stringifyStorageValue(parsedValue));
}
return parsedValue;
} catch (decryptError) {
try {
return JSON.parse(storedValue);
const parsedValue = JSON.parse(storedValue);
sessionStorage.setItem(key, stringifyStorageValue(parsedValue));
return parsedValue;
} catch (fallbackError) {
console.warn("[storage] sessionStorage parse failed", {
key,