authUserAdd script now references argon2 through authentication-module
authorJustin Wind <justin.wind+git@gmail.com>
Wed, 11 May 2022 22:25:02 +0000 (15:25 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Wed, 11 May 2022 22:25:02 +0000 (15:25 -0700)
bin/authUserAdd.js [changed mode: 0644->0755]
bin/dumpConfig.js [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 1c33be8..d47635f
@@ -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);
old mode 100644 (file)
new mode 100755 (executable)
index 6a8450a..12bb9ce
@@ -1,3 +1,6 @@
+#!/usr/bin/env node
+/* eslint-disable node/shebang */
+
 'use strict';
 
 const Config = require('../config');