src/index.js
/**
 * Return with information to the server about the error that occured.
 */
Return with information to the server about the error that occured.
Return with information to the server about the error that occured .
function exitWithErrorCode(res, retVal, clientProvidedSession = false, transientSession = false) {
    response = [];
    response.push("ver=1");
    response.push("tif=" + dechex(retVal));
    response.push("sin=0");
    if(transientSession) {
        pathLenParam = getPathLength();
        nut = generateNut();
        transientSessions[nut] = transientSession;
        adminPostPath = parse_url(admin_url('admin-post.php'), PHP_URL_PATH);
        response.push("nut=" + $nut);
        response.push("qry=" + adminPostPath + "?action=sqrl_auth&nut=" + nut + pathLenParam);
    }
    if(clientProvidedSession) {
        response.push("url=" + getServerUrlWithoutPath() + adminPostPath + '?action=sqrl_logout&message=' + MESSAGE_ERROR);
    }
    console.log("Failed response: ", response);
    content = base64url_encode(response.join("\r\n") + "\r\n");
    header('Content-Type: application/x-www-form-urlencoded');
    header('Content-Length: ' + content.length);
    res.send(content);
    exit();
}
function exitWithErrorCode ( res , retVal , clientProvidedSession = false , transientSession = false ) { response = [ ] ; response . push ( "ver=1" ) ; response . push ( "tif=" + dechex ( retVal ) ) ; response . push ( "sin=0" ) ; if ( transientSession ) { pathLenParam = getPathLength ( ) ; nut = generateNut ( ) ; transientSessions [ nut ] = transientSession ; adminPostPath = parse_url ( admin_url ( 'admin-post.php' ) , PHP_URL_PATH ) ; response . push ( "nut=" + $nut ) ; response . push ( "qry=" + adminPostPath + "?action=sqrl_auth&nut=" + nut + pathLenParam ) ; } if ( clientProvidedSession ) { response . push ( "url=" + getServerUrlWithoutPath ( ) + adminPostPath + '?action=sqrl_logout&message=' + MESSAGE_ERROR ) ; } console . log ( "Failed response: " , response ) ; content = base64url_encode ( response . join ( "\r\n" ) + "\r\n" ) ; header ( 'Content-Type: application/x-www-form-urlencoded' ) ; header ( 'Content-Length: ' + content . length ) ; res . send ( content ) ; exit ( ) ; }
Return with information to the server about the error that occured.
Return with information to the server about the error that occured .