/** * @module http-auth-utils/mechanisms/bearer */ declare const AUTHORIZED_ERROR_CODES: readonly ["invalid_request", "invalid_token", "insufficient_scope"]; declare type BearerWWWAuthenticateData = { realm: string; scope?: string; error?: typeof AUTHORIZED_ERROR_CODES[number]; error_description?: string; }; declare type BearerAuthorizationData = { hash: string; }; /** * Bearer authentication mechanism. * @type {Object} * @see https://tools.ietf.org/html/rfc6750#section-3 */ declare const BEARER: { /** * The Bearer auth mechanism prefix. * @type {String} */ type: string; /** * Parse the WWW Authenticate header rest. * @param {String} rest The header rest (string after the authentication mechanism prefix). * @return {Object} Object representing the result of the parse operation. * @example * assert.deepEqual( * BEARER.parseWWWAuthenticateRest( * 'realm="testrealm@host.com", ' + * 'scope="openid profile email"' * ), { * realm: 'testrealm@host.com', * scope: 'openid profile email', * } * ); * @api public */ parseWWWAuthenticateRest: (rest: string) => BearerWWWAuthenticateData; /** * Build the WWW Authenticate header rest. * @param {Object} data The content from wich to build the rest. * @return {String} The built rest. * @example * assert.equal( * BEARER.buildWWWAuthenticateRest({ * realm: 'testrealm@host.com', * error: 'invalid_request', * error_description: 'The access token expired', * }), * 'realm="testrealm@host.com", ' + * 'error="invalid_request", ' + * 'error_description="The access token expired"' * ); * @api public */ buildWWWAuthenticateRest: (data: BearerWWWAuthenticateData) => string; /** * Parse the Authorization header rest. * @param {String} rest The header rest (string after the authentication mechanism prefix).) * @return {Object} Object representing the result of the parse operation {hash}. * @example * assert.deepEqual( * BEARER.parseAuthorizationRest('mF_9.B5f-4.1JqM'), { * hash: 'mF_9.B5f-4.1JqM', * } * ); * @api public */ parseAuthorizationRest: (rest: string) => BearerAuthorizationData; /** * Build the Authorization header rest. * @param {Object} content The content from wich to build the rest. * @return {String} The rest built. * @example * assert.equal( * BEARER.buildAuthorizationRest({ * hash: 'mF_9.B5f-4.1JqM' * }), * 'mF_9.B5f-4.1JqM==' * ); * @api public */ buildAuthorizationRest: ({ hash, }: BearerAuthorizationData) => string; }; export default BEARER;