import { InternalOptions } from "../../lib/types" ; interface CreateCallbackUrlParams { options : InternalOptions ; /** Try reading value from request body (POST) then from query param (GET) */ paramValue ? : string ; cookieValue ? : string ; } /**
 * Get callback URL based on query param / cookie + validation,
 * and add it to `req.options.callbackUrl`.
 */ export async function createCallbackUrl ( { options , paramValue , cookieValue , } ) { const { url , callbacks } = options ; let callbackUrl = url . origin ; if ( paramValue ) { callbackUrl = await callbacks . redirect ( { url : paramValue , baseUrl : url . origin , } ) ; } else if ( cookieValue ) { callbackUrl = await callbacks . redirect ( { url : cookieValue , baseUrl : url . origin , } ) ; } return { callbackUrl , callbackUrlCookie : callbackUrl !== cookieValue ? callbackUrl : undefined , } ; }