UNPKG

@web3auth/no-modal

Version:
25 lines (21 loc) 703 B
'use strict'; var constants = require('./constants.js'); var deserialize = require('./deserialize.js'); function cookieToWeb3AuthState(cookie) { if (!cookie) return undefined; const parsed = parseCookie(cookie, constants.WEB3AUTH_STATE_STORAGE_KEY); if (!parsed) return undefined; return deserialize.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; } } exports.cookieToWeb3AuthState = cookieToWeb3AuthState; exports.parseCookie = parseCookie;