lib/authorization/index.js
function __validate_authorization_request(authorize_request) {
    return new Promise((resolve, reject) => {
        let error_object = {
            error: "invlalid_request",
            error_description: ""
        };

        if (authorize_request.state) {
            error_object.state = authorize_request.state;
        }

        if (authorize_request.nonce) {
            error_object.nonce = authorize_request.nonce;
        }

        let openid_scope_found = authorize_request
            .scope
            .split(" ")
            .find((element, idx, arr) => {
                if (element.trim() === "openid") {
                    return true;
                }
            });

        if (!openid_scope_found) {
            error_object.error = "invalid_scope";
            error_object.error_description = "scope must include openid";
            return reject(error_object);
        }

        if ((!authorize_request.response_type) || (authorize_request.response_type.trim() !== "code")) {
            error_object.error = "unsupported_response_type";
            error_object.error_description = "Only Authorization Code Flow is supported.";
            return reject(error_object);
        }

        return resolve(authorize_request);
    });
}
function __validate_authorization_request(authorize_request) {
    return new Promise((resolve, reject) => {
        let error_object = {
            error: "invlalid_request",
            error_description: ""
        };

        if (authorize_request.state) {
            error_object.state = authorize_request.state;
        }

        if (authorize_request.nonce) {
            error_object.nonce = authorize_request.nonce;
        }

        let openid_scope_found = authorize_request
            .scope
            .split(" ")
            .find((element, idx, arr) => {
                if (element.trim() === "openid") {
                    return true;
                }
            });

        if (!openid_scope_found) {
            error_object.error = "invalid_scope";
            error_object.error_description = "scope must include openid";
            return reject(error_object);
        }

        if ((!authorize_request.response_type) || (authorize_request.response_type.trim() !== "code")) {
            error_object.error = "unsupported_response_type";
            error_object.error_description = "Only Authorization Code Flow is supported.";
            return reject(error_object);
        }

        return resolve(authorize_request);
    });
}
function __validate_authorization_request ( authorize_request ) { return new Promise ( ( resolve , reject ) => { let error_object = { error : "invlalid_request" , error_description : "" } ; if ( authorize_request . state ) { error_object . state = authorize_request . state ; } if ( authorize_request . nonce ) { error_object . nonce = authorize_request . nonce ; } let openid_scope_found = authorize_request . scope . split ( " " ) . find ( ( element , idx , arr ) => { if ( element . trim ( ) === "openid" ) { return true ; } } ) ; if ( ! openid_scope_found ) { error_object . error = "invalid_scope" ; error_object . error_description = "scope must include openid" ; return reject ( error_object ) ; } if ( ( ! authorize_request . response_type ) || ( authorize_request . response_type . trim ( ) !== "code" ) ) { error_object . error = "unsupported_response_type" ; error_object . error_description = "Only Authorization Code Flow is supported." ; return reject ( error_object ) ; } return resolve ( authorize_request ) ; } ) ; }
Returns an error descriptor object with the error code if validation fails.

@param       {[type]} authorize_request
@return      {[type]}
Returns an error descriptor object with the error code if validation fails .