mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
clean warnings on unit test
This commit is contained in:
parent
3c060766e7
commit
0210752ea5
3 changed files with 8 additions and 8 deletions
12
lib/auth.js
12
lib/auth.js
|
@ -195,9 +195,9 @@ Auth.prototype.basic_middleware = function() {
|
||||||
|
|
||||||
var scheme = parts[0]
|
var scheme = parts[0]
|
||||||
if (scheme === 'Basic') {
|
if (scheme === 'Basic') {
|
||||||
var credentials = Buffer(parts[1], 'base64').toString()
|
var credentials = new Buffer(parts[1], 'base64').toString()
|
||||||
} else if (scheme === 'Bearer') {
|
} else if (scheme === 'Bearer') {
|
||||||
var credentials = self.aes_decrypt(Buffer(parts[1], 'base64')).toString('utf8')
|
var credentials = self.aes_decrypt(new Buffer(parts[1], 'base64')).toString('utf8')
|
||||||
if (!credentials) return next()
|
if (!credentials) return next()
|
||||||
} else {
|
} else {
|
||||||
return next()
|
return next()
|
||||||
|
@ -286,7 +286,7 @@ Auth.prototype.cookie_middleware = function() {
|
||||||
req.remote_user = AuthenticatedUser(user.u, user.g)
|
req.remote_user = AuthenticatedUser(user.u, user.g)
|
||||||
req.remote_user.token = token
|
req.remote_user.token = token
|
||||||
next()*/
|
next()*/
|
||||||
var credentials = self.aes_decrypt(Buffer(token, 'base64')).toString('utf8')
|
var credentials = self.aes_decrypt(new Buffer(token, 'base64')).toString('utf8')
|
||||||
if (!credentials) return next()
|
if (!credentials) return next()
|
||||||
|
|
||||||
var index = credentials.indexOf(':')
|
var index = credentials.indexOf(':')
|
||||||
|
@ -314,13 +314,13 @@ Auth.prototype.issue_token = function(user) {
|
||||||
t: ~~(Date.now()/1000),
|
t: ~~(Date.now()/1000),
|
||||||
}, { indent: false })
|
}, { indent: false })
|
||||||
|
|
||||||
data = Buffer(data, 'utf8')
|
data = new Buffer(data, 'utf8')
|
||||||
var mac = Crypto.createHmac('sha256', this.secret).update(data).digest()
|
var mac = Crypto.createHmac('sha256', this.secret).update(data).digest()
|
||||||
return Buffer.concat([ data, mac ]).toString('base64')
|
return Buffer.concat([ data, mac ]).toString('base64')
|
||||||
}
|
}
|
||||||
|
|
||||||
Auth.prototype.decode_token = function(str, expire_time) {
|
Auth.prototype.decode_token = function(str, expire_time) {
|
||||||
var buf = Buffer(str, 'base64')
|
var buf = new Buffer(str, 'base64')
|
||||||
if (buf.length <= 32) throw Error[401]('invalid token')
|
if (buf.length <= 32) throw Error[401]('invalid token')
|
||||||
|
|
||||||
var data = buf.slice(0, buf.length - 32)
|
var data = buf.slice(0, buf.length - 32)
|
||||||
|
@ -355,7 +355,7 @@ Auth.prototype.aes_decrypt = function(buf) {
|
||||||
var b1 = c.update(buf)
|
var b1 = c.update(buf)
|
||||||
var b2 = c.final()
|
var b2 = c.final()
|
||||||
} catch(_) {
|
} catch(_) {
|
||||||
return Buffer(0)
|
return new Buffer(0)
|
||||||
}
|
}
|
||||||
return Buffer.concat([ b1, b2 ])
|
return Buffer.concat([ b1, b2 ])
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,7 +364,7 @@ module.exports = function(config, auth, storage) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// this is dumb and memory-consuming, but what choices do we have?
|
// this is dumb and memory-consuming, but what choices do we have?
|
||||||
stream.end(Buffer(data.data, 'base64'))
|
stream.end(new Buffer(data.data, 'base64'))
|
||||||
stream.done()
|
stream.done()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ Server.prototype.request = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.prototype.auth = function(user, pass) {
|
Server.prototype.auth = function(user, pass) {
|
||||||
this.authstr = 'Basic '+(Buffer(user+':'+pass)).toString('base64')
|
this.authstr = 'Basic '+(new Buffer(user+':'+pass)).toString('base64')
|
||||||
return this.request({
|
return this.request({
|
||||||
uri: '/-/user/org.couchdb.user:'+encodeURIComponent(user)+'/-rev/undefined',
|
uri: '/-/user/org.couchdb.user:'+encodeURIComponent(user)+'/-rev/undefined',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
|
|
Loading…
Reference in a new issue