{"id":15570006,"url":"https://github.com/nfroidure/http-auth-utils","last_synced_at":"2025-10-26T19:03:58.459Z","repository":{"id":32782158,"uuid":"36374164","full_name":"nfroidure/http-auth-utils","owner":"nfroidure","description":"Parse, build and deal with HTTP auth headers.","archived":false,"fork":false,"pushed_at":"2024-07-15T15:00:41.000Z","size":1251,"stargazers_count":10,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-17T00:55:57.004Z","etag":null,"topics":["auth","basic","bearer","digest","hacktoberfest","http"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nfroidure.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["nfroidure"]}},"created_at":"2015-05-27T14:54:37.000Z","updated_at":"2024-07-15T15:00:42.000Z","dependencies_parsed_at":"2025-04-14T16:17:08.254Z","dependency_job_id":"510b745d-2fff-4fb6-a231-a1bff6baad84","html_url":"https://github.com/nfroidure/http-auth-utils","commit_stats":{"total_commits":80,"total_committers":5,"mean_commits":16.0,"dds":0.5,"last_synced_commit":"b373830d90273e9eb21fb498c5e9b51852408052"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/nfroidure/http-auth-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fhttp-auth-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fhttp-auth-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fhttp-auth-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fhttp-auth-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nfroidure","download_url":"https://codeload.github.com/nfroidure/http-auth-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fhttp-auth-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260274644,"owners_count":22984629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth","basic","bearer","digest","hacktoberfest","http"],"created_at":"2024-10-02T17:40:48.982Z","updated_at":"2025-10-26T19:03:53.415Z","avatar_url":"https://github.com/nfroidure.png","language":"TypeScript","funding_links":["https://github.com/sponsors/nfroidure"],"categories":[],"sub_categories":[],"readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# http-auth-utils\n\u003e Parse, build and deal with HTTP authorization headers.\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/http-auth-utils/blob/main/LICENSE)\n\n\n[//]: # (::contents:start)\n\nThis library provide several utilities to parse and build WWW-Authenticate and\nAuthorization headers as described per the HTTP RFC.\n\nIt is intended to be framework agnostic and could be used either on the server\nand the client side. It is also pure functions only, no side effect here. The\nfunctions are synchronous since only parsing headers of small size so no need\nfor streams or anything asynchronous.\n\nThe module is easily extensible with new mechanisms, one very common way to\nextend it is to create a `FAKE_TOKEN` mechanism for development only that allows\nto directly provide the userId that should be authenticated. You can find\n[an sample implementation](https://github.com/nfroidure/whook/blob/master/packages/whook-example/src/services/MECHANISMS.ts)\nin the Whook's framework repository.\n\n[//]: # (::contents:end)\n\n# API\n## Modules\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#module_http-auth-utils\"\u003ehttp-auth-utils\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_http-auth-utils/mechanisms/basic\"\u003ehttp-auth-utils/mechanisms/basic\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_http-auth-utils/mechanisms/bearer\"\u003ehttp-auth-utils/mechanisms/bearer\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_http-auth-utils/mechanisms/digest\"\u003ehttp-auth-utils/mechanisms/digest\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"module_http-auth-utils\"\u003e\u003c/a\u003e\n\n## http-auth-utils\n\n* [http-auth-utils](#module_http-auth-utils)\n    * _static_\n        * [.parseWWWAuthenticateHeader(header, [authMechanisms], [options])](#module_http-auth-utils.parseWWWAuthenticateHeader) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.parseAuthorizationHeader(header, [authMechanisms], [options])](#module_http-auth-utils.parseAuthorizationHeader) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.buildWWWAuthenticateHeader(authMechanism, The)](#module_http-auth-utils.buildWWWAuthenticateHeader) ⇒ \u003ccode\u003estring\u003c/code\u003e\n        * [.buildAuthorizationHeader(authMechanism, The)](#module_http-auth-utils.buildAuthorizationHeader) ⇒ \u003ccode\u003estring\u003c/code\u003e\n    * _inner_\n        * [~mechanisms](#module_http-auth-utils..mechanisms) : \u003ccode\u003eArray\u003c/code\u003e\n\n\u003ca name=\"module_http-auth-utils.parseWWWAuthenticateHeader\"\u003e\u003c/a\u003e\n\n### http-auth-utils.parseWWWAuthenticateHeader(header, [authMechanisms], [options]) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParse HTTP WWW-Authenticate header contents.\n\n**Kind**: static method of [\u003ccode\u003ehttp-auth-utils\u003c/code\u003e](#module_http-auth-utils)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Result of the contents parse.  \n**Api**: public  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| header | \u003ccode\u003estring\u003c/code\u003e |  | The WWW-Authenticate header contents |\n| [authMechanisms] | \u003ccode\u003eArray\u003c/code\u003e | \u003ccode\u003e[BASIC, DIGEST, BEARER]\u003c/code\u003e | Allow providing custom authentication mechanisms. |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  | Parsing options |\n| [options.strict] | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003etrue\u003c/code\u003e | Strictly detect the mechanism type (case sensitive) |\n\n**Example**  \n```js\nassert.deepEqual(\n  parseWWWAuthenticateHeader('Basic realm=\"test\"'), {\n    type: 'Basic',\n    data: {\n      realm: 'test'\n    }\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils.parseAuthorizationHeader\"\u003e\u003c/a\u003e\n\n### http-auth-utils.parseAuthorizationHeader(header, [authMechanisms], [options]) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParse HTTP Authorization header contents.\n\n**Kind**: static method of [\u003ccode\u003ehttp-auth-utils\u003c/code\u003e](#module_http-auth-utils)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Result of the contents parse.  \n**Api**: public  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| header | \u003ccode\u003estring\u003c/code\u003e |  | The Authorization header contents |\n| [authMechanisms] | \u003ccode\u003eArray\u003c/code\u003e | \u003ccode\u003e[BASIC, DIGEST, BEARER]\u003c/code\u003e | Allow custom authentication mechanisms. |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  | Parsing options |\n| [options.strict] | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003etrue\u003c/code\u003e | Strictly detect the mechanism type (case sensitive) |\n\n**Example**  \n```js\nassert.deepEqual(\n  parseAuthorizationHeader('Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='), {\n    type: 'Basic',\n    data: {\n      hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='\n    }\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils.buildWWWAuthenticateHeader\"\u003e\u003c/a\u003e\n\n### http-auth-utils.buildWWWAuthenticateHeader(authMechanism, The) ⇒ \u003ccode\u003estring\u003c/code\u003e\nBuild HTTP WWW-Authenticate header value.\n\n**Kind**: static method of [\u003ccode\u003ehttp-auth-utils\u003c/code\u003e](#module_http-auth-utils)  \n**Returns**: \u003ccode\u003estring\u003c/code\u003e - The header value.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| authMechanism | \u003ccode\u003eObject\u003c/code\u003e | The mechanism to use |\n| The | \u003ccode\u003eObject\u003c/code\u003e | WWW-Authenticate header contents to base the value on. |\n\n**Example**  \n```js\nassert.deepEqual(\n  buildWWWAuthenticateHeader(BASIC, {\n    realm: 'test'\n  }),\n  'Basic realm=\"test\"'\n);\n```\n\u003ca name=\"module_http-auth-utils.buildAuthorizationHeader\"\u003e\u003c/a\u003e\n\n### http-auth-utils.buildAuthorizationHeader(authMechanism, The) ⇒ \u003ccode\u003estring\u003c/code\u003e\nBuild HTTP Authorization header value.\n\n**Kind**: static method of [\u003ccode\u003ehttp-auth-utils\u003c/code\u003e](#module_http-auth-utils)  \n**Returns**: \u003ccode\u003estring\u003c/code\u003e - The header value.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| authMechanism | \u003ccode\u003eObject\u003c/code\u003e | The mechanism to use |\n| The | \u003ccode\u003eObject\u003c/code\u003e | Authorization header contents to base the value on. |\n\n**Example**  \n```js\nassert.deepEqual(\n  buildAuthorizationHeader(BASIC, {\n    realm: 'test'\n  }),\n  'Basic realm=\"test\"'\n);\n```\n\u003ca name=\"module_http-auth-utils..mechanisms\"\u003e\u003c/a\u003e\n\n### http-auth-utils~mechanisms : \u003ccode\u003eArray\u003c/code\u003e\nNatively supported authentication mechanisms.\n\n**Kind**: inner constant of [\u003ccode\u003ehttp-auth-utils\u003c/code\u003e](#module_http-auth-utils)  \n\u003ca name=\"module_http-auth-utils/mechanisms/basic\"\u003e\u003c/a\u003e\n\n## http-auth-utils/mechanisms/basic\n\n* [http-auth-utils/mechanisms/basic](#module_http-auth-utils/mechanisms/basic)\n    * [~BASIC](#module_http-auth-utils/mechanisms/basic..BASIC) : \u003ccode\u003eObject\u003c/code\u003e\n        * [.type](#module_http-auth-utils/mechanisms/basic..BASIC.type) : \u003ccode\u003eString\u003c/code\u003e\n        * [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mechanisms/basic..BASIC.parseWWWAuthenticateRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mechanisms/basic..BASIC.buildWWWAuthenticateRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n        * [.parseAuthorizationRest(rest)](#module_http-auth-utils/mechanisms/basic..BASIC.parseAuthorizationRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.buildAuthorizationRest(content)](#module_http-auth-utils/mechanisms/basic..BASIC.buildAuthorizationRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n        * [.computeHash(credentials)](#module_http-auth-utils/mechanisms/basic..BASIC.computeHash) ⇒ \u003ccode\u003eString\u003c/code\u003e\n        * [.decodeHash(hash)](#module_http-auth-utils/mechanisms/basic..BASIC.decodeHash) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\n\u003ca name=\"module_http-auth-utils/mechanisms/basic..BASIC\"\u003e\u003c/a\u003e\n\n### http-auth-utils/mechanisms/basic~BASIC : \u003ccode\u003eObject\u003c/code\u003e\nBasic authentication mechanism.\n\n**Kind**: inner constant of [\u003ccode\u003ehttp-auth-utils/mechanisms/basic\u003c/code\u003e](#module_http-auth-utils/mechanisms/basic)  \n**See**: http://tools.ietf.org/html/rfc2617#section-2  \n\n* [~BASIC](#module_http-auth-utils/mechanisms/basic..BASIC) : \u003ccode\u003eObject\u003c/code\u003e\n    * [.type](#module_http-auth-utils/mechanisms/basic..BASIC.type) : \u003ccode\u003eString\u003c/code\u003e\n    * [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mechanisms/basic..BASIC.parseWWWAuthenticateRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n    * [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mechanisms/basic..BASIC.buildWWWAuthenticateRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n    * [.parseAuthorizationRest(rest)](#module_http-auth-utils/mechanisms/basic..BASIC.parseAuthorizationRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n    * [.buildAuthorizationRest(content)](#module_http-auth-utils/mechanisms/basic..BASIC.buildAuthorizationRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n    * [.computeHash(credentials)](#module_http-auth-utils/mechanisms/basic..BASIC.computeHash) ⇒ \u003ccode\u003eString\u003c/code\u003e\n    * [.decodeHash(hash)](#module_http-auth-utils/mechanisms/basic..BASIC.decodeHash) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\n\u003ca name=\"module_http-auth-utils/mechanisms/basic..BASIC.type\"\u003e\u003c/a\u003e\n\n#### BASIC.type : \u003ccode\u003eString\u003c/code\u003e\nThe Basic auth mechanism prefix.\n\n**Kind**: static property of [\u003ccode\u003eBASIC\u003c/code\u003e](#module_http-auth-utils/mechanisms/basic..BASIC)  \n\u003ca name=\"module_http-auth-utils/mechanisms/basic..BASIC.parseWWWAuthenticateRest\"\u003e\u003c/a\u003e\n\n#### BASIC.parseWWWAuthenticateRest(rest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParse the WWW Authenticate header rest.\n\n**Kind**: static method of [\u003ccode\u003eBASIC\u003c/code\u003e](#module_http-auth-utils/mechanisms/basic..BASIC)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Object representing the result of the parse operation.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| rest | \u003ccode\u003eString\u003c/code\u003e | The header rest (string after the authentication mechanism prefix). |\n\n**Example**  \n```js\nassert.deepEqual(\n  BASIC.parseWWWAuthenticateRest('realm=\"perlinpinpin\"'), {\n    realm: 'perlinpinpin'\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/basic..BASIC.buildWWWAuthenticateRest\"\u003e\u003c/a\u003e\n\n#### BASIC.buildWWWAuthenticateRest(data) ⇒ \u003ccode\u003eString\u003c/code\u003e\nBuild the WWW Authenticate header rest.\n\n**Kind**: static method of [\u003ccode\u003eBASIC\u003c/code\u003e](#module_http-auth-utils/mechanisms/basic..BASIC)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - The built rest.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| data | \u003ccode\u003eObject\u003c/code\u003e | The content from wich to build the rest. |\n\n**Example**  \n```js\nassert.equal(\n  BASIC.buildWWWAuthenticateRest({\n    realm: 'perlinpinpin'\n  }),\n  'realm=\"perlinpinpin\"'\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/basic..BASIC.parseAuthorizationRest\"\u003e\u003c/a\u003e\n\n#### BASIC.parseAuthorizationRest(rest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParse the Authorization header rest.\n\n**Kind**: static method of [\u003ccode\u003eBASIC\u003c/code\u003e](#module_http-auth-utils/mechanisms/basic..BASIC)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Object representing the result of the parse operation {hash}.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| rest | \u003ccode\u003eString\u003c/code\u003e | The header rest (string after the authentication mechanism prefix).) |\n\n**Example**  \n```js\nassert.deepEqual(\n  BASIC.parseAuthorizationRest('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {\n    hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',\n    username: 'Ali Baba',\n    password: 'open sesame'\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/basic..BASIC.buildAuthorizationRest\"\u003e\u003c/a\u003e\n\n#### BASIC.buildAuthorizationRest(content) ⇒ \u003ccode\u003eString\u003c/code\u003e\nBuild the Authorization header rest.\n\n**Kind**: static method of [\u003ccode\u003eBASIC\u003c/code\u003e](#module_http-auth-utils/mechanisms/basic..BASIC)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - The rest built.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| content | \u003ccode\u003eObject\u003c/code\u003e | The content from wich to build the rest. |\n\n**Example**  \n```js\nassert.equal(\n  BASIC.buildAuthorizationRest({\n    hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='\n  }),\n  'QWxpIEJhYmE6b3BlbiBzZXNhbWU='\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/basic..BASIC.computeHash\"\u003e\u003c/a\u003e\n\n#### BASIC.computeHash(credentials) ⇒ \u003ccode\u003eString\u003c/code\u003e\nCompute the Basic authentication hash from the given credentials.\n\n**Kind**: static method of [\u003ccode\u003eBASIC\u003c/code\u003e](#module_http-auth-utils/mechanisms/basic..BASIC)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - The hash representing the credentials.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| credentials | \u003ccode\u003eObject\u003c/code\u003e | The credentials to encode {username, password}. |\n\n**Example**  \n```js\nassert.equal(\n  BASIC.computeHash({\n    username: 'Ali Baba',\n    password: 'open sesame'\n  }),\n  'QWxpIEJhYmE6b3BlbiBzZXNhbWU='\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/basic..BASIC.decodeHash\"\u003e\u003c/a\u003e\n\n#### BASIC.decodeHash(hash) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nDecode the Basic hash and return the corresponding credentials.\n\n**Kind**: static method of [\u003ccode\u003eBASIC\u003c/code\u003e](#module_http-auth-utils/mechanisms/basic..BASIC)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Object representing the credentials {username, password}.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| hash | \u003ccode\u003eString\u003c/code\u003e | The hash. |\n\n**Example**  \n```js\nassert.deepEqual(\n  BASIC.decodeHash('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {\n    username: 'Ali Baba',\n    password: 'open sesame'\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/bearer\"\u003e\u003c/a\u003e\n\n## http-auth-utils/mechanisms/bearer\n\n* [http-auth-utils/mechanisms/bearer](#module_http-auth-utils/mechanisms/bearer)\n    * [~BEARER](#module_http-auth-utils/mechanisms/bearer..BEARER) : \u003ccode\u003eObject\u003c/code\u003e\n        * [.type](#module_http-auth-utils/mechanisms/bearer..BEARER.type) : \u003ccode\u003eString\u003c/code\u003e\n        * [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mechanisms/bearer..BEARER.parseWWWAuthenticateRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mechanisms/bearer..BEARER.buildWWWAuthenticateRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n        * [.parseAuthorizationRest(rest)](#module_http-auth-utils/mechanisms/bearer..BEARER.parseAuthorizationRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.buildAuthorizationRest(content)](#module_http-auth-utils/mechanisms/bearer..BEARER.buildAuthorizationRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n\n\u003ca name=\"module_http-auth-utils/mechanisms/bearer..BEARER\"\u003e\u003c/a\u003e\n\n### http-auth-utils/mechanisms/bearer~BEARER : \u003ccode\u003eObject\u003c/code\u003e\nBearer authentication mechanism.\n\n**Kind**: inner constant of [\u003ccode\u003ehttp-auth-utils/mechanisms/bearer\u003c/code\u003e](#module_http-auth-utils/mechanisms/bearer)  \n**See**: https://tools.ietf.org/html/rfc6750#section-3  \n\n* [~BEARER](#module_http-auth-utils/mechanisms/bearer..BEARER) : \u003ccode\u003eObject\u003c/code\u003e\n    * [.type](#module_http-auth-utils/mechanisms/bearer..BEARER.type) : \u003ccode\u003eString\u003c/code\u003e\n    * [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mechanisms/bearer..BEARER.parseWWWAuthenticateRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n    * [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mechanisms/bearer..BEARER.buildWWWAuthenticateRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n    * [.parseAuthorizationRest(rest)](#module_http-auth-utils/mechanisms/bearer..BEARER.parseAuthorizationRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n    * [.buildAuthorizationRest(content)](#module_http-auth-utils/mechanisms/bearer..BEARER.buildAuthorizationRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n\n\u003ca name=\"module_http-auth-utils/mechanisms/bearer..BEARER.type\"\u003e\u003c/a\u003e\n\n#### BEARER.type : \u003ccode\u003eString\u003c/code\u003e\nThe Bearer auth mechanism prefix.\n\n**Kind**: static property of [\u003ccode\u003eBEARER\u003c/code\u003e](#module_http-auth-utils/mechanisms/bearer..BEARER)  \n\u003ca name=\"module_http-auth-utils/mechanisms/bearer..BEARER.parseWWWAuthenticateRest\"\u003e\u003c/a\u003e\n\n#### BEARER.parseWWWAuthenticateRest(rest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParse the WWW Authenticate header rest.\n\n**Kind**: static method of [\u003ccode\u003eBEARER\u003c/code\u003e](#module_http-auth-utils/mechanisms/bearer..BEARER)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Object representing the result of the parse operation.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| rest | \u003ccode\u003eString\u003c/code\u003e | The header rest (string after the authentication mechanism prefix). |\n\n**Example**  \n```js\nassert.deepEqual(\n  BEARER.parseWWWAuthenticateRest(\n    'realm=\"testrealm@host.com\", ' +\n    'scope=\"openid profile email\"'\n  ), {\n    realm: 'testrealm@host.com',\n    scope: 'openid profile email',\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/bearer..BEARER.buildWWWAuthenticateRest\"\u003e\u003c/a\u003e\n\n#### BEARER.buildWWWAuthenticateRest(data) ⇒ \u003ccode\u003eString\u003c/code\u003e\nBuild the WWW Authenticate header rest.\n\n**Kind**: static method of [\u003ccode\u003eBEARER\u003c/code\u003e](#module_http-auth-utils/mechanisms/bearer..BEARER)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - The built rest.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| data | \u003ccode\u003eObject\u003c/code\u003e | The content from wich to build the rest. |\n\n**Example**  \n```js\nassert.equal(\n  BEARER.buildWWWAuthenticateRest({\n    realm: 'testrealm@host.com',\n    error: 'invalid_request',\n    error_description: 'The access token expired',\n  }),\n  'realm=\"testrealm@host.com\", ' +\n  'error=\"invalid_request\", ' +\n  'error_description=\"The access token expired\"'\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/bearer..BEARER.parseAuthorizationRest\"\u003e\u003c/a\u003e\n\n#### BEARER.parseAuthorizationRest(rest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParse the Authorization header rest.\n\n**Kind**: static method of [\u003ccode\u003eBEARER\u003c/code\u003e](#module_http-auth-utils/mechanisms/bearer..BEARER)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Object representing the result of the parse operation {hash}.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| rest | \u003ccode\u003eString\u003c/code\u003e | The header rest (string after the authentication mechanism prefix).) |\n\n**Example**  \n```js\nassert.deepEqual(\n  BEARER.parseAuthorizationRest('mF_9.B5f-4.1JqM'), {\n    hash: 'mF_9.B5f-4.1JqM',\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/bearer..BEARER.buildAuthorizationRest\"\u003e\u003c/a\u003e\n\n#### BEARER.buildAuthorizationRest(content) ⇒ \u003ccode\u003eString\u003c/code\u003e\nBuild the Authorization header rest.\n\n**Kind**: static method of [\u003ccode\u003eBEARER\u003c/code\u003e](#module_http-auth-utils/mechanisms/bearer..BEARER)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - The rest built.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| content | \u003ccode\u003eObject\u003c/code\u003e | The content from wich to build the rest. |\n\n**Example**  \n```js\nassert.equal(\n  BEARER.buildAuthorizationRest({\n    hash: 'mF_9.B5f-4.1JqM'\n  }),\n  'mF_9.B5f-4.1JqM=='\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/digest\"\u003e\u003c/a\u003e\n\n## http-auth-utils/mechanisms/digest\n\n* [http-auth-utils/mechanisms/digest](#module_http-auth-utils/mechanisms/digest)\n    * [~DIGEST](#module_http-auth-utils/mechanisms/digest..DIGEST) : \u003ccode\u003eObject\u003c/code\u003e\n        * [.type](#module_http-auth-utils/mechanisms/digest..DIGEST.type) : \u003ccode\u003eString\u003c/code\u003e\n        * [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mechanisms/digest..DIGEST.parseWWWAuthenticateRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mechanisms/digest..DIGEST.buildWWWAuthenticateRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n        * [.parseAuthorizationRest(rest)](#module_http-auth-utils/mechanisms/digest..DIGEST.parseAuthorizationRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.buildAuthorizationRest(data)](#module_http-auth-utils/mechanisms/digest..DIGEST.buildAuthorizationRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n        * [.computeHash(data)](#module_http-auth-utils/mechanisms/digest..DIGEST.computeHash) ⇒ \u003ccode\u003eString\u003c/code\u003e\n\n\u003ca name=\"module_http-auth-utils/mechanisms/digest..DIGEST\"\u003e\u003c/a\u003e\n\n### http-auth-utils/mechanisms/digest~DIGEST : \u003ccode\u003eObject\u003c/code\u003e\nDigest authentication mechanism.\n\n**Kind**: inner constant of [\u003ccode\u003ehttp-auth-utils/mechanisms/digest\u003c/code\u003e](#module_http-auth-utils/mechanisms/digest)  \n**See**\n\n- http://tools.ietf.org/html/rfc2617#section-3\n- http://tools.ietf.org/html/rfc2069#section-2\n\n\n* [~DIGEST](#module_http-auth-utils/mechanisms/digest..DIGEST) : \u003ccode\u003eObject\u003c/code\u003e\n    * [.type](#module_http-auth-utils/mechanisms/digest..DIGEST.type) : \u003ccode\u003eString\u003c/code\u003e\n    * [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mechanisms/digest..DIGEST.parseWWWAuthenticateRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n    * [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mechanisms/digest..DIGEST.buildWWWAuthenticateRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n    * [.parseAuthorizationRest(rest)](#module_http-auth-utils/mechanisms/digest..DIGEST.parseAuthorizationRest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n    * [.buildAuthorizationRest(data)](#module_http-auth-utils/mechanisms/digest..DIGEST.buildAuthorizationRest) ⇒ \u003ccode\u003eString\u003c/code\u003e\n    * [.computeHash(data)](#module_http-auth-utils/mechanisms/digest..DIGEST.computeHash) ⇒ \u003ccode\u003eString\u003c/code\u003e\n\n\u003ca name=\"module_http-auth-utils/mechanisms/digest..DIGEST.type\"\u003e\u003c/a\u003e\n\n#### DIGEST.type : \u003ccode\u003eString\u003c/code\u003e\nThe Digest auth mechanism prefix.\n\n**Kind**: static property of [\u003ccode\u003eDIGEST\u003c/code\u003e](#module_http-auth-utils/mechanisms/digest..DIGEST)  \n\u003ca name=\"module_http-auth-utils/mechanisms/digest..DIGEST.parseWWWAuthenticateRest\"\u003e\u003c/a\u003e\n\n#### DIGEST.parseWWWAuthenticateRest(rest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParse the WWW Authenticate header rest.\n\n**Kind**: static method of [\u003ccode\u003eDIGEST\u003c/code\u003e](#module_http-auth-utils/mechanisms/digest..DIGEST)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Object representing the result of the parse operation.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| rest | \u003ccode\u003eString\u003c/code\u003e | The header rest (string after the authentication mechanism prefix). |\n\n**Example**  \n```js\nassert.deepEqual(\n  DIGEST.parseWWWAuthenticateRest(\n    'realm=\"testrealm@host.com\", ' +\n    'qop=\"auth, auth-int\", ' +\n    'nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", ' +\n    'opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"'\n  ), {\n    realm: 'testrealm@host.com',\n    qop: 'auth, auth-int',\n    nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',\n    opaque: '5ccc069c403ebaf9f0171e9517f40e41'\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/digest..DIGEST.buildWWWAuthenticateRest\"\u003e\u003c/a\u003e\n\n#### DIGEST.buildWWWAuthenticateRest(data) ⇒ \u003ccode\u003eString\u003c/code\u003e\nBuild the WWW Authenticate header rest.\n\n**Kind**: static method of [\u003ccode\u003eDIGEST\u003c/code\u003e](#module_http-auth-utils/mechanisms/digest..DIGEST)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - The built rest.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| data | \u003ccode\u003eObject\u003c/code\u003e | The content from which to build the rest. |\n\n**Example**  \n```js\nassert.equal(\n  DIGEST.buildWWWAuthenticateRest({\n    realm: 'testrealm@host.com',\n    qop: 'auth, auth-int',\n    nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',\n    opaque: '5ccc069c403ebaf9f0171e9517f40e41'\n  }),\n  'realm=\"testrealm@host.com\", ' +\n  'qop=\"auth, auth-int\", ' +\n  'nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", ' +\n  'opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"'\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/digest..DIGEST.parseAuthorizationRest\"\u003e\u003c/a\u003e\n\n#### DIGEST.parseAuthorizationRest(rest) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParse the Authorization header rest.\n\n**Kind**: static method of [\u003ccode\u003eDIGEST\u003c/code\u003e](#module_http-auth-utils/mechanisms/digest..DIGEST)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Object representing the result of the parse operation {hash}.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| rest | \u003ccode\u003eString\u003c/code\u003e | The header rest (string after the authentication mechanism prefix).) |\n\n**Example**  \n```js\nassert.deepEqual(\n  DIGEST.parseAuthorizationRest(\n    'username=\"Mufasa\",' +\n    'realm=\"testrealm@host.com\",' +\n    'nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\",' +\n    'uri=\"/dir/index.html\",' +\n    'qop=\"auth\",' +\n    'nc=\"00000001\",' +\n    'cnonce=\"0a4f113b\",' +\n    'response=\"6629fae49393a05397450978507c4ef1\",' +\n    'opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"'\n  ), {\n    username: \"Mufasa\",\n    realm: 'testrealm@host.com',\n    nonce: \"dcd98b7102dd2f0e8b11d0f600bfb0c093\",\n    uri: \"/dir/index.html\",\n    qop: 'auth',\n    nc: '00000001',\n    cnonce: \"0a4f113b\",\n    response: \"6629fae49393a05397450978507c4ef1\",\n    opaque: \"5ccc069c403ebaf9f0171e9517f40e41\"\n  }\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/digest..DIGEST.buildAuthorizationRest\"\u003e\u003c/a\u003e\n\n#### DIGEST.buildAuthorizationRest(data) ⇒ \u003ccode\u003eString\u003c/code\u003e\nBuild the Authorization header rest.\n\n**Kind**: static method of [\u003ccode\u003eDIGEST\u003c/code\u003e](#module_http-auth-utils/mechanisms/digest..DIGEST)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - The rest built.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| data | \u003ccode\u003eObject\u003c/code\u003e | The content from which to build the rest. |\n\n**Example**  \n```js\nassert.equal(\n  DIGEST.buildAuthorizationRest({\n    username: \"Mufasa\",\n    realm: 'testrealm@host.com',\n    nonce: \"dcd98b7102dd2f0e8b11d0f600bfb0c093\",\n    uri: \"/dir/index.html\",\n    qop: 'auth',\n    nc: '00000001',\n    cnonce: \"0a4f113b\",\n    response: \"6629fae49393a05397450978507c4ef1\",\n    opaque: \"5ccc069c403ebaf9f0171e9517f40e41\"\n  }),\n  'username=\"Mufasa\", ' +\n  'realm=\"testrealm@host.com\", ' +\n  'nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", ' +\n  'uri=\"/dir/index.html\", ' +\n  'response=\"6629fae49393a05397450978507c4ef1\", ' +\n  'cnonce=\"0a4f113b\", ' +\n  'opaque=\"5ccc069c403ebaf9f0171e9517f40e41\", ' +\n  'qop=\"auth\", ' +\n  'nc=\"00000001\"'\n);\n```\n\u003ca name=\"module_http-auth-utils/mechanisms/digest..DIGEST.computeHash\"\u003e\u003c/a\u003e\n\n#### DIGEST.computeHash(data) ⇒ \u003ccode\u003eString\u003c/code\u003e\nCompute the Digest authentication hash from the given credentials.\n\n**Kind**: static method of [\u003ccode\u003eDIGEST\u003c/code\u003e](#module_http-auth-utils/mechanisms/digest..DIGEST)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - The hash representing the credentials.  \n**Api**: public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| data | \u003ccode\u003eObject\u003c/code\u003e | The credentials to encode and other encoding details. |\n\n**Example**  \n```js\nassert.equal(\n  DIGEST.computeHash({\n    username: 'Mufasa',\n    realm: 'testrealm@host.com',\n    password: 'Circle Of Life',\n    method: 'GET',\n    uri: '/dir/index.html',\n    nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',\n    nc: '00000001',\n    cnonce: '0a4f113b',\n    qop: 'auth',\n    algorithm: 'md5'\n  }),\n  '6629fae49393a05397450978507c4ef1'\n);\n```\n\n# Authors\n- [Nicolas Froidure](https://insertafter.com/en/index.html)\n- [Jake Pruitt](https://github.com/jakepruitt)\n- [Corentin Girard](https://github.com/Drarig29)\n- [Roman Sokolov](https://github.com/Stillness-2)\n\n# License\n[MIT](https://github.com/nfroidure/http-auth-utils/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfroidure%2Fhttp-auth-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnfroidure%2Fhttp-auth-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfroidure%2Fhttp-auth-utils/lists"}