@web3auth/no-modal
Version:
Multi chain wallet aggregator for web3Auth
22 lines (19 loc) • 642 B
JavaScript
import { WEB3AUTH_STATE_STORAGE_KEY } from './constants.js';
import { deserialize } from './deserialize.js';
function cookieToWeb3AuthState(cookie) {
if (!cookie) return undefined;
const parsed = parseCookie(cookie, WEB3AUTH_STATE_STORAGE_KEY);
if (!parsed) return undefined;
return deserialize(parsed);
}
function parseCookie(cookie, key) {
const keyValue = cookie.split("; ").find(x => x.startsWith(`${key}=`));
if (!keyValue) return undefined;
const value = keyValue.substring(key.length + 1);
try {
return decodeURIComponent(value);
} catch {
return value;
}
}
export { cookieToWeb3AuthState, parseCookie };