A parser for RFC 7235 HTTP/1.1 Authentication headers
$ npm install rfc7235-parser
const {
parseAuthenticateHeader,
parseAuthorizationHeader
} = require('rfc7235-parser');
const challenges = parseAuthenticateHeader(
'Basic asdQWE==, Digest realm="foo@bar"'
);
console.log(challenges);
// [
// {scheme: 'basic', params: {Encoded: 'asdQWE=='}},
// {scheme: 'digest', params: {realm: 'foo@bar'}}
// ]
const credentials = parseAuthorizationHeader(
'Digest realm="foo@bar", QoP="auth,auth-int"'
);
console.log(credentials);
// {
// scheme: 'digest',
// params: {
// realm: 'foo@bar',
// qop: 'auth,auth-int'
// }
// }
Crafted with ♡ by raphinesse using the nearley parser toolkit.