summaryrefslogtreecommitdiff
path: root/lib/models
diff options
context:
space:
mode:
authorClaudius2019-05-13 12:55:03 +0200
committerClaudius2019-05-13 19:37:21 +0200
commit4833f300c527b96cc5d6d16c605df8cf04d06c1d (patch)
treebd7e65d1ebf0edf41cd5de625a0f7fef79a3b8f7 /lib/models
parent1d403e183d50001bf0f20113d15994007b14696b (diff)
polyfilling scrypt for node 8.5+
Signed-off-by: Claudius <opensource@amenthes.de>
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/user.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/models/user.js b/lib/models/user.js
index 8da12b83..76e20a32 100644
--- a/lib/models/user.js
+++ b/lib/models/user.js
@@ -1,11 +1,20 @@
'use strict'
// external modules
-var Sequelize = require('sequelize')
-var scrypt = require('scrypt-kdf')
+const Sequelize = require('sequelize')
+const crypto = require('crypto')
+if (!crypto.scrypt) {
+ // polyfill for node.js 8.0, see https://github.com/chrisveness/scrypt-kdf#openssl-implementation
+ const scryptAsync = require('scrypt-async')
+ crypto.scrypt = function (password, salt, keylen, options, callback) {
+ const opt = Object.assign({}, options, { dkLen: keylen })
+ scryptAsync(password, salt, opt, (derivedKey) => callback(null, Buffer.from(derivedKey)))
+ }
+}
+const scrypt = require('scrypt-kdf')
// core
-var logger = require('../logger')
-var { generateAvatarURL } = require('../letter-avatars')
+const logger = require('../logger')
+const { generateAvatarURL } = require('../letter-avatars')
module.exports = function (sequelize, DataTypes) {
var User = sequelize.define('User', {