Skip to content

Commit

Permalink
Improve logic
Browse files Browse the repository at this point in the history
  • Loading branch information
klydra committed Jun 30, 2024
1 parent 6121703 commit b3d3605
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 4 additions & 4 deletions api/elysia/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default new Elysia({ prefix: "/users" })
body: t.Object({
username: t.String({ format: "regex", regex: UserUsername }),
secretKey: t.String({
minLength: SECRET_KEY_LENGTH,
maxLength: SECRET_KEY_LENGTH,
minLength: SECRET_KEY_LENGTH * 2,
maxLength: SECRET_KEY_LENGTH * 2,
}),
}),
},
Expand Down Expand Up @@ -90,8 +90,8 @@ export default new Elysia({ prefix: "/users" })
body: t.Object({
username: t.String({ format: "regex", regex: UserUsername }),
derived: t.String({
minLength: SECRET_LOCK_DERIVED_LENGTH,
maxLength: SECRET_LOCK_DERIVED_LENGTH,
minLength: SECRET_LOCK_DERIVED_LENGTH * 2,
maxLength: SECRET_LOCK_DERIVED_LENGTH * 2,
}),
}),
},
Expand Down
2 changes: 1 addition & 1 deletion encryption/models/secret-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { decryptIV, encryptIV, pbkdf2, randomBytes } from "../crypto.ts";
export const SECRET_KEY_IV_LENGTH = 16;
export const SECRET_KEY_PASSPORT_LENGTH = 32;
export const SECRET_KEY_PASSPORT_ITERATIONS = 100000;
export const SECRET_KEY_BLOB_LENGTH = 32;
export const SECRET_KEY_BLOB_LENGTH = 80;
export const SECRET_KEY_LENGTH =
SECRET_KEY_IV_LENGTH + SECRET_KEY_PASSPORT_LENGTH + SECRET_KEY_BLOB_LENGTH;

Expand Down
2 changes: 0 additions & 2 deletions web/pages/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ function Action({
disabled={!password.match(VerifyPassword)}
onClick={async () => {
const secretLock = await SecretLock.withPassword(password);
console.log(secretLock.nc);
console.log(secretLock.toString());
const secretKey = await SecretKey.withLock(secretLock);
api.users.create.post({ username, secretKey: secretKey.toString() });
}}
Expand Down

0 comments on commit b3d3605

Please sign in to comment.