From 48997c6debe65dc80cdf2f12e4e916025a32f88d Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Wed, 11 May 2022 15:25:02 -0700 Subject: [PATCH] authUserAdd script now references argon2 through authentication-module --- bin/authUserAdd.js | 7 +++++-- bin/dumpConfig.js | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 bin/authUserAdd.js mode change 100644 => 100755 bin/dumpConfig.js diff --git a/bin/authUserAdd.js b/bin/authUserAdd.js old mode 100644 new mode 100755 index 1c33be8..d47635f --- a/bin/authUserAdd.js +++ b/bin/authUserAdd.js @@ -1,8 +1,10 @@ +#!/usr/bin/env node +/* eslint-disable node/shebang */ 'use strict'; -const argon2 = require('argon2'); const readline = require('readline'); const stream = require('stream'); +const { Authenticator } = require('@squeep/authentication-module'); const DB = require('../src/db'); const Logger = require('../src/logger'); const Config = require('../config'); @@ -10,6 +12,7 @@ const config = new Config(process.env.NODE_ENV); const logger = new Logger(config); const db = new DB(logger, config); +const authenticator = new Authenticator(logger, db, config); const identifier = process.argv[2]; @@ -46,7 +49,7 @@ async function readPassword(prompt) { (async () => { await db.initialize(); const password = await readPassword('password: '); - const credential = await argon2.hash(password, { type: argon2.argon2id }); + const credential = await authenticator.authn.argon2.hash(password, { type: authenticator.authn.argon2.argon2id }); console.log(`\t${identifier}:${credential}`); await db.context(async (dbCtx) => { const result = await db.authenticationUpsert(dbCtx, identifier, credential); diff --git a/bin/dumpConfig.js b/bin/dumpConfig.js old mode 100644 new mode 100755 index 6a8450a..12bb9ce --- a/bin/dumpConfig.js +++ b/bin/dumpConfig.js @@ -1,3 +1,6 @@ +#!/usr/bin/env node +/* eslint-disable node/shebang */ + 'use strict'; const Config = require('../config'); -- 2.43.2