From 3435e8cfb93b6266fb2fc8af9a2c559ddd5f4881 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 17 Jan 2024 21:31:02 +0100 Subject: [PATCH] Fixed bun runtime. --- src/node/security/SecretRotator.js | 6 +++--- src/node/security/crypto.js | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/node/security/SecretRotator.js b/src/node/security/SecretRotator.js index 3cc08a01c..4077c6f64 100644 --- a/src/node/security/SecretRotator.js +++ b/src/node/security/SecretRotator.js @@ -1,7 +1,8 @@ 'use strict'; const {Buffer} = require('buffer'); -const crypto = require('./crypto'); +const crypto = require('node:crypto') +const cryptoHelper = require('./crypto') const db = require('../db/DB'); const log4js = require('log4js'); @@ -30,8 +31,7 @@ class Hkdf extends Kdf { } async derive(p, info) { - return Buffer.from( - await crypto.hkdf(p.digest, p.secret, p.salt, info, p.keyLen)).toString('hex'); + return Buffer.from(await cryptoHelper.hkdf(p.digest, p.secret, p.salt, info, p.keyLen)).toString('hex'); } } diff --git a/src/node/security/crypto.js b/src/node/security/crypto.js index 95b3986fe..428804cc3 100644 --- a/src/node/security/crypto.js +++ b/src/node/security/crypto.js @@ -2,7 +2,13 @@ const crypto = require('crypto'); -const newMethod = async (...args) => new Promise((resolve) => crypto.hkdf(...args, resolve)); +const newMethod = async (...args) => new Promise((resolve, reject) => crypto.hkdf(...args, (err, result)=>{ + if(err){ + return reject(err) + } else { + return resolve(result) + } +})); /** * Promisified version of Node.js's crypto.hkdf.