Skip to content

Commit

Permalink
split out verifyPassword into two functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mymindstorm committed Jul 29, 2024
1 parent 0023143 commit 5b32b32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/Popup/SetPasswordPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</template>
<script lang="ts">
import Vue from "vue";
import { verifyPassword } from "../../models/password";
import { verifyPasswordUsingKeyID } from "../../models/password";
export default Vue.extend({
data: function () {
Expand Down Expand Up @@ -70,7 +70,7 @@ export default Vue.extend({
this.$store.commit("currentView/changeView", "LoadingPage");
if (this.defaultEncryption) {
const isCorrectPassword = await verifyPassword(
const isCorrectPassword = await verifyPasswordUsingKeyID(
this.defaultEncryption,
this.currentPhrase
);
Expand Down
10 changes: 9 additions & 1 deletion src/models/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export async function argonVerify(
return argonPromise;
}

export async function verifyPassword(
// Verify a password using keys in BrowserStorage
export async function verifyPasswordUsingKeyID(
keyId: string,
password: string
): Promise<boolean> {
Expand All @@ -69,6 +70,13 @@ export async function verifyPassword(
throw new Error(`Key ${keyId} not in BrowserStorage`);
}

return verifyPasswordUsingKey(key, password);
}

export async function verifyPasswordUsingKey(
key: Key,
password: string
): Promise<boolean> {
// Hash password with argon
const rawHash = await argonHash(password, key.salt);
if (!rawHash) {
Expand Down

0 comments on commit 5b32b32

Please sign in to comment.