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

bookshelf-secure-password

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-secure-password - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

6

lib/secure-password.js

@@ -95,3 +95,3 @@ 'use strict'

function enablePasswordHashing (model) {
let field = passwordDigestField(model)
const field = passwordDigestField(model)

@@ -107,3 +107,3 @@ model.virtuals = model.virtuals || {}

model.on('saving', (model) => {
let value = model[PRIVATE_PASSWORD_FIELD]
const value = model[PRIVATE_PASSWORD_FIELD]

@@ -140,3 +140,3 @@ return hash(bcryptRounds(model), value).then((_hashed) => {

authenticate: function authenticate (password) {
let digest = this.get(passwordDigestField(this))
const digest = this.get(passwordDigestField(this))

@@ -143,0 +143,0 @@ if (!this.hasSecurePassword) {

{
"name": "bookshelf-secure-password",
"version": "3.1.0",
"version": "4.0.0",
"description": "A Bookshelf.js plugin for handling secure passwords",

@@ -33,14 +33,14 @@ "main": "lib/secure-password.js",

"dependencies": {
"bcrypt": "^2.0.0"
"bcrypt": "^3.0.6"
},
"devDependencies": {
"bookshelf": "^0.10.3",
"chai": "^3.5.0",
"coveralls": "^2.11.16",
"knex": "^0.12.6",
"mocha": "^3.2.0",
"mock-knex": "^0.3.7",
"nyc": "^10.1.2",
"standard": "^8.6.0"
"bookshelf": "^0.15.1",
"chai": "^4.2.0",
"coveralls": "^3.0.6",
"knex": "^0.19.1",
"mocha": "^6.2.0",
"mock-knex": "^0.4.6",
"nyc": "^14.1.1",
"standard": "^13.1.0"
}
}
'use strict'
/* eslint-disable no-unused-expressions */
const Bookshelf = require('bookshelf')

@@ -74,3 +76,3 @@ const expect = require('chai').expect

it('does not change the password digest if given undefined', function () {
let originalString = model.get('password_digest')
const originalString = model.get('password_digest')
model.set('password', undefined)

@@ -84,3 +86,3 @@

it('does not change the password digest if given an empty string', function () {
let originalString = model.get('password_digest')
const originalString = model.get('password_digest')
model.set('password', '')

@@ -94,3 +96,3 @@

it('changes the password digest if given a blank (spaces-only) string', function () {
let originalString = model.get('password_digest')
const originalString = model.get('password_digest')
model.set('password', ' ')

@@ -113,15 +115,21 @@ return model.save().then(() => {

.save()
.then(() => {
expect(false).to.be.true
}, () => {
expect(model.get('password')).to.be.undefined
expect(model.get('password_digest')).to.be.a.string
digest = model.get('password_digest')
return model.save()
})
.then(() => {
expect(false).to.be.true
}, () => {
expect(model.get('password_digest')).to.equal(digest)
})
.then(
() => {
expect(false).to.be.true
},
() => {
expect(model.get('password')).to.be.undefined
expect(model.get('password_digest')).to.be.a.string
digest = model.get('password_digest')
return model.save()
}
)
.then(
() => {
expect(false).to.be.true
},
() => {
expect(model.get('password_digest')).to.equal(digest)
}
)
})

@@ -178,9 +186,12 @@ })

it('does not authenticate until the record is saved', function () {
return model.authenticate('testing').then((model) => {
expect(false).to.be.true
}, (err) => {
expect(err).to.be.defined
expect(err).to.be.an.instanceof(PasswordMismatchError)
expect(err.name).to.equal('PasswordMismatchError')
})
return model.authenticate('testing').then(
model => {
expect(false).to.be.true
},
err => {
expect(err).not.to.be.undefined
expect(err).to.be.an.instanceof(PasswordMismatchError)
expect(err.name).to.equal('PasswordMismatchError')
}
)
})

@@ -195,27 +206,36 @@ })

it('resolves the Model if the password matches', function () {
return model.authenticate('testing').then((model) => {
expect(model).to.be.defined
}, (err) => {
expect(err).to.be.undefined
})
return model.authenticate('testing').then(
model => {
expect(model).not.to.be.undefined
},
err => {
expect(err).to.be.undefined
}
)
})
it('rejects with a PasswordMismatchError if the password does not match', function () {
return model.authenticate('invalid').then((model) => {
expect(false).to.be.true
}, (err) => {
expect(err).to.be.defined
expect(err).to.be.an.instanceof(PasswordMismatchError)
expect(err.name).to.equal('PasswordMismatchError')
})
return model.authenticate('invalid').then(
model => {
expect(false).to.be.true
},
err => {
expect(err).not.to.be.undefined
expect(err).to.be.an.instanceof(PasswordMismatchError)
expect(err.name).to.equal('PasswordMismatchError')
}
)
})
it('rejects with a PasswordMismatchError if the no password is provided', function () {
return model.authenticate().then((model) => {
expect(model).to.be.defined
}, (err) => {
expect(err).to.be.defined
expect(err).to.be.an.instanceof(PasswordMismatchError)
expect(err.name).to.equal('PasswordMismatchError')
})
return model.authenticate().then(
model => {
expect(model).to.be.defined
},
err => {
expect(err).not.to.be.undefined
expect(err).to.be.an.instanceof(PasswordMismatchError)
expect(err.name).to.equal('PasswordMismatchError')
}
)
})

@@ -233,3 +253,3 @@ })

} catch (err) {
expect(err).to.be.defined
expect(err).not.to.be.undefined
expect(err).to.be.an.instanceof(TypeError)

@@ -236,0 +256,0 @@ }

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