
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
highoutput-auth
Advanced tools
The Auth constructor accepts the following configuration
string
Secret key to use in generating the JWT.model
User model.import mongoose, { Schema } from 'mongoose';
import Auth from 'highoutput-auth';
const AccountModel = {
async findByUsername(username) => { ... },
async findById(id) => { ... },
async updatePassword(id, password) => { ... },
};
const auth = new Auth({
secretKey: '4fb473f82ba47bf6acbab33e7529fb96',
model: AccountModel
});
Create an access token.
string
Username.string
Password.string
(Optional) Amount of time before the accessToken expires. Must be compatible to the ms
package.object
(Optional) Additional claims to include in the JWT.Promise<string>
INVALID_CREDENTIALS
await auth.createAccessToken({
username: 'roger',
password: '123456Seven',
});
Verify a json web token.
string
Access token.string | number
(Optional) ID of the owner of the accessToken.Promise<object>
Claims stored in the JWT.INVALID_TOKEN
await auth.verifyAccessToken({
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWQ3MTZlZjc1ZTZhODc1MTQ0Y2Q0NDQiLCJpYXQiOjE1MjQ2MjYzNjMsImV4cCI6MTUyNTIzMTE2M30.z2xgs0BeLQsTBiG9sphjkP_JljYht2o4AgI4ClWgZqw',
});
Change the user password.
string
Access token.string | number
(Optional) ID of the owner of the accessToken.string
Old password.string
New Password.INVALID_TOKEN
INVALID_CREDENTIALS
await auth.changePassword({
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWQ3MTZlZjc1ZTZhODc1MTQ0Y2Q0NDQiLCJpYXQiOjE1MjQ2MjYzNjMsImV4cCI6MTUyNTIzMTE2M30.z2xgs0BeLQsTBiG9sphjkP_JljYht2o4AgI4ClWgZqw',
oldPassword: 'password',
newPassword: '123456Seven',
});
Request for a password reset.
string | number
ID of the user requesting the password reset.string
(Optional) Amount of time before the requestToken expires.Promise<string>
USER_NOT_FOUND
await auth.requestResetPassword({
subject: '507f1f77bcf86cd799439011',
});
Reset password.
string
Request token.string | number
(Optional) ID of the owner of the requestToken.string
New Password.INVALID_TOKEN
await auth.resetPassword({
requestToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWQ3MTZlZjc1ZTZhODc1MTQ0Y2Q0NDQiLCJpYXQiOjE1MjQ2MjYzNjMsImV4cCI6MTUyNTIzMTE2M30.z2xgs0BeLQsTBiG9sphjkP_JljYht2o4AgI4ClWgZqw',
password: '123456Seven',
});
The model should have the following methods
Promise<{ id: string | number, username: string, password: string }>
Promise<{ id: string | number, username: string, password: string }>
Promise<void>
const { bcrypt } = require('highoutput-auth');
const R = require('ramda');
class Model {
constructor() {
this.users = [];
}
/* additional method for the sake of context */
async insertUser(user) {
this.users.push({
...user,
password: await bcrypt.hash(user.password),
});
}
async findByUsername(username) {
return R.find(R.propEq('username', username))(this.users);
}
async findById(id) {
return R.find(R.propEq('id', id))(this.users);
}
async updatePassword(id, password) {
const user = R.find(R.propEq('id', id))(this.users);
if (!user) {
return;
}
user.password = password;
}
}
FAQs
Authentication and authorization module
The npm package highoutput-auth receives a total of 70 weekly downloads. As such, highoutput-auth popularity was classified as not popular.
We found that highoutput-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.