From eca1621568172756c92ee843737c31e7098eed9c Mon Sep 17 00:00:00 2001 From: Danny Cho Date: Thu, 12 Oct 2023 15:33:01 +1300 Subject: [PATCH] feat: handling null response from navigator.credentials.create --- packages/biometric-ed25519/package.json | 2 +- packages/biometric-ed25519/src/index.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/biometric-ed25519/package.json b/packages/biometric-ed25519/package.json index d846d51fcb..6941767de5 100644 --- a/packages/biometric-ed25519/package.json +++ b/packages/biometric-ed25519/package.json @@ -1,7 +1,7 @@ { "name": "@near-js/biometric-ed25519", "description": "JavaScript library to handle webauthn and biometric keys", - "version": "0.3.0", + "version": "0.4.0", "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { diff --git a/packages/biometric-ed25519/src/index.ts b/packages/biometric-ed25519/src/index.ts index 4076e1fb94..111fc4be71 100644 --- a/packages/biometric-ed25519/src/index.ts +++ b/packages/biometric-ed25519/src/index.ts @@ -51,6 +51,11 @@ export const createKey = async (username: string): Promise => { setBufferIfUndefined(); 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'); + } + const result = await f2l.attestation({ clientAttestationResponse: res, origin,