Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional password to hub #865

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions interfaces/final-object.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface FinalObject {
removeTags: string[]; // tags to remove
screenshotSettings: ScreenshotSettings;
version: number; // version of this vha file
password?: string; // Optional password field
}

export interface ImageElement {
Expand Down Expand Up @@ -103,3 +104,20 @@ export interface ScreenshotSettings {
height: AllowedScreenshotHeight;
n: number;
}

//Setting the password
import bcrypt from 'bcrypt';

const saltRounds = 10;

async function setPassword(finalObject: FinalObject, plainPassword: string) {
const hashedPassword = await bcrypt.hash(plainPassword, saltRounds);
finalObject.password = hashedPassword; // Store the hashed password
}

// Verifying the password
async function verifyPassword(finalObject: FinalObject, inputPassword: string) {
if (!finalObject.password) return false; // No password set
const match = await bcrypt.compare(inputPassword, finalObject.password);
return match; // Returns true if the password matches
}