import base64url from 'base64url' ; import createDebug from '../utils/debug' ; import { GetLoginState } from '../config' ; const debug = createDebug ( 'get-login-state' ) ; param { IncomingMessage } _req param { LoginOptions } options return { object } export const getLoginState = ( _req , options ) => { const state = { returnTo : options . returnTo } ; debug ( 'adding default state %O' , state ) ; return state ; } ; param { object } stateObject return { string } export function encodeState ( stateObject ) { const { nonce , code_verifier , max_age , ... filteredState } = stateObject ; return base64url . encode ( JSON . stringify ( filteredState ) ) ; } param { string } stateValue return { object } export function decodeState ( stateValue ) { return JSON . parse ( base64url . decode ( stateValue ) ) ; }