Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
'use client';
"use client";
import React, { useState } from 'react';
import { decrypt } from "../security_components/tools/AES_tool";
import { calculatePassword } from '../security_components/components/password_generator';
import { parse } from "tldts";

export async function getEncryptedUuid(uuid: string): Promise<string> {
const API_URL = "https://8fy84busdk.execute-api.us-east-1.amazonaws.com/API/getUserInfo";

try {
const response = await fetch(API_URL, {
method: "POST", // or GET if your endpoint supports it
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ UUID: uuid }),
});

if (!response.ok) {
throw new Error(`API error: ${response.status} ${response.statusText}`);
}

// Expecting an array of rows: [{ enc_uuid, enc_email, ... }, …]
const rows: Array<{ enc_uuid: string }> = await response.json();

if (!Array.isArray(rows) || rows.length === 0) {
throw new Error("No user found for the given UUID");
}

return rows[0].enc_uuid;
} catch (err) {
console.error("getEncryptedUuid error:", err);
throw err;
}
}

export default function Site_LogIn() {
const userId = "testuserid"; // This value will be the user's id in plaintext (retrieved from DB)
const userIdEncrypted = "8gb2BSJbvxtRs53WGHs6jBoVBztcA03gIFv8t8Bm/CLt6fGKkEY="; // This value will be the user's id in ciphertext (retrieved from DB)
const userId = "randomuuid"; // This value will be the user's id in plaintext (retrieved from cache)
//const userIdEncrypted = "8gb2BSJbvxtRs53WGHs6jBoVBztcA03gIFv8t8Bm/CLt6fGKkEY="; // This value will be the user's id in ciphertext (retrieved from DB)


const [keyString, setKeyString] = useState("");
const [loading, setLoading] = useState(false);
Expand All @@ -18,10 +48,19 @@ export default function Site_LogIn() {
setSpinnerMessage('Generating Password...');

try {
const userIdEncrypted = await getEncryptedUuid(userId);
console.log("User ID encrypted: ",userIdEncrypted);
const domain = parse(window.location.href).domain ?? "";
const decryptedText = await decrypt(userIdEncrypted, keyString);
if (decryptedText === userId) {
const password = await calculatePassword(keyString, "test", "test");
const password = await calculatePassword(keyString, domain, userIdEncrypted);
setGeneratedPassword(password);
chrome.runtime.sendMessage({
action: "fillPassword",
passphrase: password
}, (response) => {
console.log("Message acknowledged by service worker", response);
});
} else {
console.log("Invalid Simple Passphrase");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import React, { useState } from 'react';
import { decrypt } from "../security_components/tools/AES_tool";
import { calculatePassword } from '../security_components/components/password_generator';
import { parse } from "tldts";
import { getEncryptedUuid } from '../site_login_popup/site_login_component';

export default function Site_SignUp() {
const UUID = "f98699a0-d010-4a68-833e-fc9cbbcdf800";
const userIdEncrypted = "W3CeGzefGlIYyBS5RjiZnFmBI0RdTc8EJDQmwLM1LyUw3zTfGa6botvDVJvE2JlMM5/P8FZOjPRPC7TXJ/B02A==";
const userId = "randomuuid";

const [keyString, setKeyString] = useState("");
const [loading, setLoading] = useState(false);
Expand All @@ -19,11 +19,12 @@ export default function Site_SignUp() {
setSpinnerMessage('Generating Password...');

try {
const userIdEncrypted = await getEncryptedUuid(userId);
const decryptedText = await decrypt(userIdEncrypted, keyString);
if (decryptedText === UUID) {
if (decryptedText === userId) {
console.log("Valid Simple passphrase: User Authenticated");

const domain = parse(window.location.href).domain;
const domain = parse(window.location.href).domain ?? "";
console.log("Parsed Domain:", domain);

try {
Expand All @@ -32,7 +33,7 @@ export default function Site_SignUp() {
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ UUID, domain })
body: JSON.stringify({ userId, domain })
});

if (!response.ok) {
Expand All @@ -45,7 +46,7 @@ export default function Site_SignUp() {
}

// Generate password after success
const password = await calculatePassword(keyString, "test", "test");
const password = await calculatePassword(keyString, domain, userIdEncrypted);
setGeneratedPassword(password);
chrome.runtime.sendMessage({
action: "fillPassword",
Expand Down
198 changes: 114 additions & 84 deletions extension/src/hashpass/public/dist/components.bundle.js

Large diffs are not rendered by default.

Loading