Socket
Socket
Sign inDemoInstall

digest-fetch

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

digest-fetch - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

29

digest-fetch-src.js

@@ -9,2 +9,10 @@ const canRequire = typeof(require) == 'function'

const parse = (raw, field) => {
const regex = new RegExp(`${field}=("[^"]*"|[^,]*)`, "i")
const match = regex.exec(raw)
if (match)
return match[1].replace(/[\s"]/g, '')
return null
}
class DigestClient {

@@ -97,3 +105,3 @@ constructor(user, password, options={}) {

const opaqueString = this.digest.opaque ? `opaque="${this.digest.opaque}",` : ''
const opaqueString = this.digest.opaque !== null ? `opaque="${this.digest.opaque}",` : ''
const qopString = this.digest.qop ? `qop="${this.digest.qop}",` : ''

@@ -126,12 +134,9 @@ const digest = `${this.digest.scheme} username="${this.user}",realm="${this.digest.realm}",\

const _realm = /realm=\"([^\"]+)\"/i.exec(h)
if (_realm) this.digest.realm = _realm[1]
this.digest.realm = parse(h, 'realm') || ''
this.digest.qop = this.parseQop(h)
const _opaque = /opaque=\"([^\"]+)\"/i.exec(h)
if (_opaque) this.digest.opaque = _opaque[1]
this.digest.opaque = parse(h, 'opaque')
const _nonce = /nonce=\"([^\"]+)\"/i.exec(h)
if (_nonce) this.digest.nonce = _nonce[1]
this.digest.nonce = parse(h, 'nonce') || ''

@@ -148,5 +153,6 @@ this.digest.cnonce = this.makeNonce()

// : qop=auth,realm=
const _qop = /qop=(\"[^\"]+\"|[^,]+)/i.exec(rawAuth)
if (_qop) {
const qops = _qop[1].replace(/[\s"]/g, '').split(',')
const _qop = parse(rawAuth, 'qop')
if (_qop !== null) {
const qops = _qop.split(',')
if (qops.includes('auth')) return 'auth'

@@ -167,2 +173,5 @@ else if (qops.includes('auth-int')) return 'auth-int'

static parse(raw, field) {
return parse(raw, field)
}
}

@@ -169,0 +178,0 @@

{
"name": "digest-fetch",
"version": "1.0.4",
"version": "1.0.5",
"description": "digest auth request plugin for fetch/node-fetch also support http basic auth authentication",

@@ -5,0 +5,0 @@ "main": "digest-fetch-src.js",

@@ -20,2 +20,10 @@ process.env.NO_DEPRECATION = 'digest-fetch';

it('test parse string fields', function () {
assert.equal(DigestFetch.parse('a=,', 'a'), '')
assert.equal(DigestFetch.parse('a=v1,', 'a'), 'v1')
assert.equal(DigestFetch.parse('a=""', 'b'), null)
assert.equal(DigestFetch.parse('a="v2",', 'a'), 'v2')
assert.equal(DigestFetch.parse('a="v1,v2"', 'a'), 'v1,v2')
})
it('test qop parsing', function () {

@@ -22,0 +30,0 @@ var client = new DigestFetch('test', '123')

Sorry, the diff of this file is too big to display

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