X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=bin%2FauthUserAdd.js;h=d47635f6623997d6d24d31be1168601e81f06be8;hb=3839577f7cdab67b4591bc827e037d6c173c9dae;hp=4eaff65b9597995bc1dd5bb2ff08b804c22ac62b;hpb=9696c012e6b9a6c58904baa397ca0ebf78112316;p=websub-hub diff --git a/bin/authUserAdd.js b/bin/authUserAdd.js old mode 100644 new mode 100755 index 4eaff65..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]; @@ -44,8 +47,9 @@ 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);