Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-auth-utils

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-auth-utils - npm Package Compare versions

Comparing version 5.0.1 to 6.0.0

9

CHANGELOG.md

@@ -0,1 +1,10 @@

# [6.0.0](https://github.com/nfroidure/http-auth-utils/compare/v5.0.1...v6.0.0) (2024-01-14)
### Bug Fixes
* **src/utils.ts:** add the ability to use empty values ([cd2cd54](https://github.com/nfroidure/http-auth-utils/commit/cd2cd54abeecd8a881db2ed3f00a2099b0ed4b49))
## [5.0.1](https://github.com/nfroidure/http-auth-utils/compare/v5.0.0...v5.0.1) (2023-08-16)

@@ -2,0 +11,0 @@

6

dist/utils.js

@@ -39,3 +39,3 @@ import { YError } from 'yerror';

* " = The first double quote
* .+ = One or more characters of any kind
* .* = Characters of any kind
* (?="$) = Zero-width (as in not captured) positive lookahead assertion.

@@ -47,3 +47,3 @@ * The previous match will only be valid if it's followed by a " literal

*/
const strippedValue = value.replace(/^"(.+(?="$))"$/, '$1');
const strippedValue = value.replace(/^"(.*(?="$))"$/, '$1');
parsedValues[normalizedName] = valuesToNormalize.includes(normalizedName)

@@ -60,3 +60,3 @@ ? strippedValue.toLowerCase()

return authorizedKeys.reduce(function (contents, key) {
if (data[key]) {
if (data[key] !== undefined) {
return (contents +

@@ -63,0 +63,0 @@ (contents ? SEPARATOR : '') +

@@ -18,2 +18,17 @@ import { describe, test } from '@jest/globals';

});
test('should work with empty opaque', () => {
neatequal(parseHTTPHeadersQuotedKeyValueSet('qop="auth", ' +
'realm="DS-DD8D92DB", ' +
'nonce="NzhiYWNkMGY3ZmVjZGZkNjA1NzE0NzcxYzA4MTBmNjM=", ' +
'stale="false", ' +
'opaque="", ' +
'domain="::"', ['realm', 'qop', 'nonce', 'opaque', 'stale', 'domain'], ['realm', 'qop', 'nonce', 'opaque', 'stale', 'domain']), {
realm: 'DS-DD8D92DB',
qop: 'auth',
nonce: 'NzhiYWNkMGY3ZmVjZGZkNjA1NzE0NzcxYzA4MTBmNjM=',
opaque: '',
stale: 'false',
domain: '::',
});
});
test('should work with equals in key values', () => {

@@ -60,3 +75,3 @@ neatequal(parseHTTPHeadersQuotedKeyValueSet('realm="testrealm@host.com", ' +

'stale=TRUE', ['realm', 'qop', 'nonce', 'opaque', 'stale'], ['realm', 'qop', 'nonce', 'opaque', 'stale'], ['stale']), {
realm: 'testrealm-UPPERCASE@host.com',
realm: 'testrealm-UPPERCASE@host.com', // should not be changed
qop: 'auth, auth-int',

@@ -93,2 +108,9 @@ nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',

});
test('should work with empty value', () => {
assert.equal(buildHTTPHeadersQuotedKeyValueSet({
realm: 'testrealm@host.com',
qop: 'auth, auth-int',
opaque: '',
}, ['realm', 'qop', 'nonce', 'opaque'], ['realm', 'qop', 'opaque']), 'realm="testrealm@host.com", ' + 'qop="auth, auth-int", ' + 'opaque=""');
});
test('should work with unused keys', () => {

@@ -95,0 +117,0 @@ assert.equal(buildHTTPHeadersQuotedKeyValueSet({

@@ -28,3 +28,3 @@ {

"name": "http-auth-utils",
"version": "5.0.1",
"version": "6.0.0",
"description": "Parse, build and deal with HTTP authorization headers.",

@@ -79,24 +79,24 @@ "main": "dist/index.js",

"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.77",
"@swc/helpers": "^0.5.1",
"@swc/core": "^1.3.94",
"@swc/helpers": "^0.5.3",
"@swc/jest": "^0.2.29",
"@types/node": "^18.14.6",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"commitizen": "^4.3.0",
"conventional-changelog-cli": "^3.0.0",
"conventional-changelog-cli": "^4.1.0",
"coveralls": "^3.1.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.47.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.2",
"jsarch": "^6.0.1",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.7.0",
"jsarch": "^6.0.3",
"jsdoc-to-markdown": "^8.0.0",
"metapak": "^5.1.6",
"metapak-nfroidure": "15.0.2",
"metapak": "^5.1.7",
"metapak-nfroidure": "15.0.4",
"neatequal": "^1.0.0",
"prettier": "^3.0.2",
"rimraf": "^5.0.1",
"typescript": "^5.1.6"
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"typescript": "^5.2.2"
},

@@ -147,2 +147,7 @@ "dependencies": {

"url": "https://github.com/Drarig29"
},
{
"name": "Roman Sokolov",
"email": "calm@adguard.com",
"url": "https://github.com/Stillness-2"
}

@@ -149,0 +154,0 @@ ],

@@ -671,4 +671,5 @@ [//]: # ( )

- [Corentin Girard](https://github.com/Drarig29)
- [Roman Sokolov](https://github.com/Stillness-2)
# License
[MIT](https://github.com/nfroidure/http-auth-utils/blob/main/LICENSE)

@@ -30,2 +30,25 @@ import { describe, test } from '@jest/globals';

test('should work with empty opaque', () => {
neatequal(
parseHTTPHeadersQuotedKeyValueSet(
'qop="auth", ' +
'realm="DS-DD8D92DB", ' +
'nonce="NzhiYWNkMGY3ZmVjZGZkNjA1NzE0NzcxYzA4MTBmNjM=", ' +
'stale="false", ' +
'opaque="", ' +
'domain="::"',
['realm', 'qop', 'nonce', 'opaque', 'stale', 'domain'],
['realm', 'qop', 'nonce', 'opaque', 'stale', 'domain'],
),
{
realm: 'DS-DD8D92DB',
qop: 'auth',
nonce: 'NzhiYWNkMGY3ZmVjZGZkNjA1NzE0NzcxYzA4MTBmNjM=',
opaque: '',
stale: 'false',
domain: '::',
},
);
});
test('should work with equals in key values', () => {

@@ -158,2 +181,17 @@ neatequal(

test('should work with empty value', () => {
assert.equal(
buildHTTPHeadersQuotedKeyValueSet(
{
realm: 'testrealm@host.com',
qop: 'auth, auth-int',
opaque: '',
},
['realm', 'qop', 'nonce', 'opaque'],
['realm', 'qop', 'opaque'],
),
'realm="testrealm@host.com", ' + 'qop="auth, auth-int", ' + 'opaque=""',
);
});
test('should work with unused keys', () => {

@@ -160,0 +198,0 @@ assert.equal(

@@ -48,3 +48,3 @@ import { YError } from 'yerror';

* " = The first double quote
* .+ = One or more characters of any kind
* .* = Characters of any kind
* (?="$) = Zero-width (as in not captured) positive lookahead assertion.

@@ -56,3 +56,3 @@ * The previous match will only be valid if it's followed by a " literal

*/
const strippedValue = value.replace(/^"(.+(?="$))"$/, '$1');
const strippedValue = value.replace(/^"(.*(?="$))"$/, '$1');

@@ -78,3 +78,3 @@ parsedValues[normalizedName] = valuesToNormalize.includes(normalizedName)

return authorizedKeys.reduce(function (contents, key) {
if (data[key]) {
if (data[key] !== undefined) {
return (

@@ -81,0 +81,0 @@ contents +

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc