Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 974 Bytes

README.md

File metadata and controls

43 lines (34 loc) · 974 Bytes

rfc7235-parser Build Status

A parser for RFC 7235 HTTP/1.1 Authentication headers

Install

$ npm install rfc7235-parser

Usage

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.