260508_11_ENH: 새로고침 시 로그인 풀리는 문제 수정 중
This commit is contained in:
@@ -165,8 +165,7 @@ export class Security {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static encodeBase64(input: WordArray): string {
|
public static encodeBase64(input: WordArray): string {
|
||||||
const base64 = CryptoJS.enc.Base64.stringify(input);
|
return CryptoJS.enc.Base64.stringify(input);
|
||||||
return this.convertToSpecialChars(base64);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static decodeBase64(input: string): WordArray {
|
public static decodeBase64(input: string): WordArray {
|
||||||
|
|||||||
@@ -22,9 +22,20 @@ const parseStoredValue = (value: string): StorageValue => {
|
|||||||
|
|
||||||
const stringifyStorageValue = (value: StorageValue): string => {
|
const stringifyStorageValue = (value: StorageValue): string => {
|
||||||
const stringifyValue = JSON.stringify(value);
|
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 => {
|
export const setLocalStorage = (key: string, value: StorageValue): void => {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(key, stringifyStorageValue(value));
|
localStorage.setItem(key, stringifyStorageValue(value));
|
||||||
@@ -41,10 +52,16 @@ export const getLocalStorage = (key: string): StorageValue => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return parseStoredValue(storedValue);
|
const parsedValue = parseStoredValue(storedValue);
|
||||||
|
if (parsedValue != null && shouldMigrateStorageValue(storedValue)) {
|
||||||
|
localStorage.setItem(key, stringifyStorageValue(parsedValue));
|
||||||
|
}
|
||||||
|
return parsedValue;
|
||||||
} catch (decryptError) {
|
} catch (decryptError) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(storedValue);
|
const parsedValue = JSON.parse(storedValue);
|
||||||
|
localStorage.setItem(key, stringifyStorageValue(parsedValue));
|
||||||
|
return parsedValue;
|
||||||
} catch (fallbackError) {
|
} catch (fallbackError) {
|
||||||
console.warn("[storage] localStorage parse failed", {
|
console.warn("[storage] localStorage parse failed", {
|
||||||
key,
|
key,
|
||||||
@@ -84,10 +101,16 @@ export const getSessionStorage = (key: string): StorageValue => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return parseStoredValue(storedValue);
|
const parsedValue = parseStoredValue(storedValue);
|
||||||
|
if (parsedValue != null && shouldMigrateStorageValue(storedValue)) {
|
||||||
|
sessionStorage.setItem(key, stringifyStorageValue(parsedValue));
|
||||||
|
}
|
||||||
|
return parsedValue;
|
||||||
} catch (decryptError) {
|
} catch (decryptError) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(storedValue);
|
const parsedValue = JSON.parse(storedValue);
|
||||||
|
sessionStorage.setItem(key, stringifyStorageValue(parsedValue));
|
||||||
|
return parsedValue;
|
||||||
} catch (fallbackError) {
|
} catch (fallbackError) {
|
||||||
console.warn("[storage] sessionStorage parse failed", {
|
console.warn("[storage] sessionStorage parse failed", {
|
||||||
key,
|
key,
|
||||||
|
|||||||
Reference in New Issue
Block a user