five-bells-shared
Advanced tools
Comparing version 8.3.0 to 8.4.0
'use strict' | ||
const url = require('url') | ||
const tweetnacl = require('tweetnacl') | ||
@@ -112,4 +113,35 @@ /** | ||
} | ||
/** | ||
* Load configuration of this process' keypair. | ||
*/ | ||
parseKeyConfig () { | ||
this.keys = {} | ||
this.keys.ed25519 = { | ||
secret: process.env.ED25519_SECRET_KEY, | ||
public: process.env.ED25519_PUBLIC_KEY | ||
} | ||
let keyPair | ||
if (!this.keys.ed25519.secret) { | ||
if (process.env.NODE_ENV === 'production') { | ||
throw new Error('No ED25519_SECRET_KEY provided.') | ||
} | ||
keyPair = tweetnacl.sign.keyPair() | ||
this.keys.ed25519.secret = tweetnacl.util.encodeBase64(keyPair.secretKey) | ||
this.keys.ed25519.public = tweetnacl.util.encodeBase64(keyPair.publicKey) | ||
} | ||
if (!this.keys.ed25519.public) { | ||
if (!keyPair) { | ||
keyPair = tweetnacl.sign.keyPair.fromSecretKey( | ||
tweetnacl.util.decodeBase64(this.keys.ed25519.secret)) | ||
} | ||
this.keys.ed25519.public = | ||
tweetnacl.util.encodeBase64(keyPair.publicKey) | ||
} | ||
} | ||
} | ||
module.exports = Config |
@@ -8,6 +8,9 @@ 'use strict' | ||
module.exports = function (Sequelize, log) { | ||
if (typeof log === 'object') { | ||
log.warn('DEPRECATED: Do not pass a logger to five-bells-shared Database constructor. Instead, please pass it via the logging config option.') | ||
} | ||
return class DB extends Sequelize { | ||
constructor (uri, options) { | ||
options = _.merge({ | ||
logging: log.debug, | ||
logging: typeof log === 'object' ? log.debug : false, | ||
omitNull: true | ||
@@ -27,3 +30,3 @@ }, options) | ||
sync () { | ||
log.info('synchronizing database schema') | ||
this.options.logging('synchronizing database schema') | ||
return super.sync() | ||
@@ -30,0 +33,0 @@ } |
{ | ||
"name": "five-bells-shared", | ||
"version": "8.3.0", | ||
"version": "8.4.0", | ||
"description": "Shared components for Five Bells projects.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
1694079
2919
7