Skip to content

Commit

Permalink
chore: remove stale TODO comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stmio committed Apr 1, 2024
1 parent 0eaa6e2 commit 03f4ac4
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
2 changes: 0 additions & 2 deletions knox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ if ! which node > /dev/null
fi

# Check script is running from knox's base directory
# TODO: Check for package.json as well
pkgName=$(npm pkg get name 2>/dev/null | tr -d '"')
if [ "$pkgName" != "knox" ]
then
Expand All @@ -58,7 +57,6 @@ if [ "$pkgName" != "knox" ]
fi

# Install npm packages
# TODO: Ask user for confirmation?
echo "Installing required packages for Knox..."
npm install > /dev/null

Expand Down
4 changes: 3 additions & 1 deletion src/client/pages/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import knoxLogo from "/knox.svg";
import loadingIcon from "/loading.svg";

import * as auth from "~/scripts/auth.js";
import { delKey } from "~/scripts/keys.js";
import { isEmail } from "@/utils.js";

document.querySelector(".logo").src = knoxLogo;
Expand Down Expand Up @@ -65,7 +66,8 @@ document.getElementById("confirm").addEventListener("click", () => {
document.forms["login"].reset();
});

document.getElementById("uncache").addEventListener("click", () => {
document.getElementById("uncache").addEventListener("click", async () => {
localStorage.removeItem("user");
await delKey("AUK");
window.location.reload();
});
4 changes: 0 additions & 4 deletions src/client/scripts/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ export function login(email, pwd, secret_key) {
const B = hex.toBigInt(res.data.B);
const u = core.derive_u(A, B);

// TODO: abort if safeguards fail
// TODO: change buffer.from to hex

const x = secret_key
? await keys.two_sk_derivation(
pwd,
Expand Down Expand Up @@ -105,7 +102,6 @@ export function login(email, pwd, secret_key) {
["encrypt", "decrypt", "wrapKey", "unwrapKey"]
);

// TOOD: how long to store AUK?
await keys.storeKey("AUK", AUK);

localStorage.setItem(
Expand Down
11 changes: 11 additions & 0 deletions src/client/scripts/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ export async function getKey(name) {
return key;
}

export async function delKey(name) {
const db = await openDB("knox", 1, {
upgrade(db) {
db.createObjectStore("keys");
},
});

await db.delete("keys", name);
db.close();
}

export function generateKeychain(AUK) {
const webCrypto = window.crypto.subtle;

Expand Down
2 changes: 0 additions & 2 deletions src/server/controllers/keychainsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { User as UserModel } from "../models/user.model.js";
const Keychain = KeychainModel(db);
const User = UserModel(db);

// TODO: edge cases?

export const getKeychain = async (req, res, next) => {
const { keychainUuid, email } = req.body;

Expand Down
7 changes: 5 additions & 2 deletions src/server/controllers/loginController.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const loginUser = async (req, res) => {
if (!identity || !A) {
return res.status(400).json({ err: "Missing a required field." });
}
// TODO: check A mod N

const user = await User.findOne({
where: {
Expand Down Expand Up @@ -49,6 +48,10 @@ export const loginUser = async (req, res) => {

export const authenticateUser = async (req, res) => {
const { identity, deviceID } = req.body;
if (!identity || !deviceID || !req.body.challenge) {
return res.status(400).json({ err: "Missing a required field." });
}

const M1 = hex.toBigInt(req.body.challenge);

const cacheID = `${identity}:${deviceID}`;
Expand All @@ -64,7 +67,7 @@ export const authenticateUser = async (req, res) => {
const { v, s } = { v: hex.toBigInt(user.srp_v), s: hex.toBigInt(user.srp_s) };

const cache = await redis.hGetAll(cacheID);
// TODO: fail if no result or missing req params. clean up types so less conversion?
if (!cache) res.status(401).json({ err: "Authentication was unsuccessful." });

const B = server.derive_B(hex.toBigInt(cache.b), v, core.derive_k());
const u = core.derive_u(hex.toBigInt(cache.A), B);
Expand Down
2 changes: 0 additions & 2 deletions src/server/controllers/usersController.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export const putName = async (req, res, next) => {
next();
};

// TODO: get name

export const getUserKeychainUUIDs = async (req, res, next) => {
const { email } = req.body;

Expand Down
2 changes: 0 additions & 2 deletions src/server/controllers/vaultsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { User as UserModel } from "../models/user.model.js";
const Vault = VaultModel(db);
const User = UserModel(db);

// TODO: edge cases?

export const getVault = async (req, res, next) => {
const { vaultUuid, email } = req.body;

Expand Down

0 comments on commit 03f4ac4

Please sign in to comment.