Skip to content

Commit

Permalink
fix: error handling on createKey call
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho112 committed Oct 25, 2023
1 parent 6a67ce3 commit e8e3316
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/biometric-ed25519/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ function setBufferIfUndefined() {
}
}

export class PasskeyProcessCanceled extends Error {
constructor(message) {
super(message);
this.name = "PasskeyProcessCanceled";
}
}

export const createKey = async (username: string): Promise<KeyPair> => {
const cleanUserName = validateUsername(username);
if (!f2l.f2l) {
Expand All @@ -52,8 +59,7 @@ export const createKey = async (username: string): Promise<KeyPair> => {
return navigator.credentials.create({ publicKey })
.then(async (res) => {
if (!res) {
alert('Passkey process was cancelled, retry to continue account setup.');
throw new Error('Fail to retrieve respnose from navigator.credentials.create');
throw new PasskeyProcessCanceled('Failed to retrieve response from navigator.credentials.create');
}

const result = await f2l.attestation({
Expand Down

0 comments on commit e8e3316

Please sign in to comment.