bookshelf-secure-password
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
360
19225
7
+ Addedabbrev@1.1.1(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedaproba@1.2.0(transitive)
+ Addedare-we-there-yet@1.1.7(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbcrypt@3.0.8(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconsole-control-strings@1.1.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addedfs-minipass@1.2.7(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedgauge@2.7.4(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedhas-unicode@2.0.1(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedignore-walk@3.0.4(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedminipass@2.9.0(transitive)
+ Addedminizlib@1.3.3(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.1.3(transitive)
+ Addednan@2.14.0(transitive)
+ Addedneedle@2.9.1(transitive)
+ Addednode-pre-gyp@0.14.0(transitive)
+ Addednopt@4.0.3(transitive)
+ Addednpm-bundled@1.1.2(transitive)
+ Addednpm-normalize-package-bin@1.0.1(transitive)
+ Addednpm-packlist@1.4.8(transitive)
+ Addednpmlog@4.1.2(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedos-homedir@1.0.2(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedosenv@0.1.5(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsafe-buffer@5.1.25.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar@4.4.19(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwide-align@1.1.5(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedyallist@3.1.1(transitive)
- Removedbcrypt@2.0.1(transitive)
- Removednan@2.10.0(transitive)
Updatedbcrypt@^3.0.6