Merge pull request #2963 from farhan787/issue-#2961
https://github.com/mozilla/fxa-auth-server/pull/2963 r=philbooth
This commit is contained in:
Коммит
c36e9c1242
|
@ -14,12 +14,6 @@ const DEFAULT_R = 8
|
|||
const MAXMEM_MULTIPLIER = 256
|
||||
const DEFAULT_MAXMEM = MAXMEM_MULTIPLIER * DEFAULT_N * DEFAULT_R
|
||||
|
||||
let scryptHash
|
||||
try {
|
||||
scryptHash = require('scrypt-hash')
|
||||
} catch (err) {
|
||||
}
|
||||
|
||||
// The maximum numer of hash operations allowed concurrently.
|
||||
// This can be customized by setting the `maxPending` attribute on the
|
||||
// exported object, or by setting the `scrypt.maxPending` config option.
|
||||
|
@ -56,26 +50,16 @@ module.exports = function(log, config) {
|
|||
if (scrypt.numPending > scrypt.numPendingHWM) {
|
||||
scrypt.numPendingHWM = scrypt.numPending
|
||||
}
|
||||
if (scryptHash) {
|
||||
scryptHash(input, salt, N, r, p, len, (err, hash) => {
|
||||
scrypt.numPending -= 1
|
||||
return err ? d.reject(err) : d.resolve(hash.toString('hex'))
|
||||
})
|
||||
} else if (crypto.scrypt) {
|
||||
let maxmem = DEFAULT_MAXMEM
|
||||
if (N > DEFAULT_N || r > DEFAULT_R) {
|
||||
// Conservatively prevent `memory limit exceeded` errors. See the docs for more info:
|
||||
// https://nodejs.org/api/crypto.html#crypto_crypto_scrypt_password_salt_keylen_options_callback
|
||||
maxmem = MAXMEM_MULTIPLIER * (N || DEFAULT_N) * (r || DEFAULT_R)
|
||||
}
|
||||
crypto.scrypt(input, salt, len, { N, r, p, maxmem }, (err, hash) => {
|
||||
scrypt.numPending -= 1
|
||||
return err ? d.reject(err) : d.resolve(hash.toString('hex'))
|
||||
})
|
||||
} else {
|
||||
scrypt.numPending -= 1
|
||||
d.reject(new Error('missing scrypt implementation'))
|
||||
let maxmem = DEFAULT_MAXMEM
|
||||
if (N > DEFAULT_N || r > DEFAULT_R) {
|
||||
// Conservatively prevent `memory limit exceeded` errors. See the docs for more info:
|
||||
// https://nodejs.org/api/crypto.html#crypto_crypto_scrypt_password_salt_keylen_options_callback
|
||||
maxmem = MAXMEM_MULTIPLIER * (N || DEFAULT_N) * (r || DEFAULT_R)
|
||||
}
|
||||
crypto.scrypt(input, salt, len, { N, r, p, maxmem }, (err, hash) => {
|
||||
scrypt.numPending -= 1
|
||||
return err ? d.reject(err) : d.resolve(hash.toString('hex'))
|
||||
})
|
||||
}
|
||||
return d.promise
|
||||
}
|
||||
|
|
|
@ -217,9 +217,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@sinonjs/samsam": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.2.0.tgz",
|
||||
"integrity": "sha512-j5F1rScewLtx6pbTK0UAjA3jJj4RYiSKOix53YWv+Jzy/AZ69qHxUpU8fwVLjyKbEEud9QrLpv6Ggs7WqTimYw==",
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.0.tgz",
|
||||
"integrity": "sha512-beHeJM/RRAaLLsMJhsCvHK31rIqZuobfPLa/80yGH5hnD8PV1hyh9xJBJNFfNmO7yWqm+zomijHsXpI6iTQJfQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@sinonjs/commons": "^1.0.2",
|
||||
|
@ -695,12 +695,6 @@
|
|||
"through": "~2.3.4"
|
||||
}
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz",
|
||||
"integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=",
|
||||
"optional": true
|
||||
},
|
||||
"bluebird": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.2.tgz",
|
||||
|
@ -1972,14 +1966,14 @@
|
|||
}
|
||||
},
|
||||
"es5-ext": {
|
||||
"version": "0.10.48",
|
||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.48.tgz",
|
||||
"integrity": "sha512-CdRvPlX/24Mj5L4NVxTs4804sxiS2CjVprgCmrgoDkdmjdY4D+ySHa7K3jJf8R40dFg0tIm3z/dk326LrnuSGw==",
|
||||
"version": "0.10.49",
|
||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.49.tgz",
|
||||
"integrity": "sha512-3NMEhi57E31qdzmYp2jwRArIUsj1HI/RxbQ4bgnSB+AIKIxsAmTiK83bYMifIcpWvEc3P1X30DhUKOqEtF/kvg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es6-iterator": "~2.0.3",
|
||||
"es6-symbol": "~3.1.1",
|
||||
"next-tick": "1"
|
||||
"next-tick": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"es6-iterator": {
|
||||
|
@ -12872,9 +12866,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"pngjs": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.3.3.tgz",
|
||||
"integrity": "sha512-1n3Z4p3IOxArEs1VRXnZ/RXdfEniAUS9jb68g58FIXMNkPJeZd+Qh4Uq7/e0LVxAQGos1eIUrqrt4FpjdnEd+Q=="
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz",
|
||||
"integrity": "sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w=="
|
||||
},
|
||||
"po2json": {
|
||||
"version": "0.4.5",
|
||||
|
@ -13472,24 +13466,6 @@
|
|||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz",
|
||||
"integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o="
|
||||
},
|
||||
"scrypt-hash": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/scrypt-hash/-/scrypt-hash-1.1.14.tgz",
|
||||
"integrity": "sha1-dNwlQl7V4ERiiAz829++IOhZtc4=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"bindings": "1.2.1",
|
||||
"nan": "2.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"nan": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.4.0.tgz",
|
||||
"integrity": "sha1-+zxZ1F/k7/4hXwuJD4rfbrMtIjI=",
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
|
||||
|
@ -14027,9 +14003,9 @@
|
|||
}
|
||||
},
|
||||
"teamwork": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/teamwork/-/teamwork-3.0.3.tgz",
|
||||
"integrity": "sha512-OCB56z+G70iA1A1OFoT+51TPzfcgN0ks75uN3yhxA+EU66WTz2BevNDK4YzMqfaL5tuAvxy4iFUn35/u8pxMaQ=="
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/teamwork/-/teamwork-3.1.0.tgz",
|
||||
"integrity": "sha512-h5d6RTsMmFzcuYnCP33rep1VxG5T7Izd6b1MDMTHrVoXYhJbeFwByNEXGthce7wmCKZluuFWbCKPamXKviRQpQ=="
|
||||
},
|
||||
"text-extensions": {
|
||||
"version": "1.9.0",
|
||||
|
@ -14214,7 +14190,7 @@
|
|||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"uap-core": {
|
||||
"version": "git://github.com/ua-parser/uap-core.git#add7bafbb3ba57256d1b919103add1b2cab97aa7",
|
||||
"version": "git://github.com/ua-parser/uap-core.git#b4a50d040ad03b163b675d468d7ee011e9ad5436",
|
||||
"from": "git://github.com/ua-parser/uap-core.git"
|
||||
},
|
||||
"uap-ref-impl": {
|
||||
|
@ -14340,9 +14316,9 @@
|
|||
}
|
||||
},
|
||||
"upath": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/upath/-/upath-1.1.1.tgz",
|
||||
"integrity": "sha512-D0yetkpIOKiZQquxjM2Syvy48Y1DbZ0SWxgsZiwd9GCWRpc75vN8ytzem14WDSg+oiX6+Qt31FpiS/ExODCrLg==",
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz",
|
||||
"integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==",
|
||||
"optional": true
|
||||
},
|
||||
"uri-js": {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
"url": "git://github.com/mozilla/fxa-auth-server.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
"node": ">=10"
|
||||
},
|
||||
"bugs": "https://github.com/mozilla/fxa-auth-server/issues/",
|
||||
"homepage": "https://github.com/mozilla/fxa-auth-server/",
|
||||
|
@ -93,9 +93,6 @@
|
|||
"uuid": "1.4.1",
|
||||
"web-push": "3.3.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"scrypt-hash": "1.1.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"acorn": "^5.7.3",
|
||||
"audit-filter": "0.3.0",
|
||||
|
|
Загрузка…
Ссылка в новой задаче