Skip to content

Commit

Permalink
Add the request and credential to logging when registration fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Feb 27, 2024
1 parent bd8007d commit 58cf24c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class LoginClient {
const userId = userIdentity.sub;

// https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer/create
// Development Note: To actually test to see if this works on your local development machine, run this code on an https domain in the Web Inspector Console tab.
const publicKeyCredentialCreationOptions = {
challenge: Uint8Array.from(userId, c => c.charCodeAt(0)),
rp: {
Expand Down Expand Up @@ -230,7 +231,7 @@ class LoginClient {
type: credential.type,
userId: userId,
attestation: btoa(String.fromCharCode(...new Uint8Array(credential.response.attestationObject))),
client: JSON.parse(new TextDecoder('utf-8').decode(credential.response.clientDataJSON))
client: btoa(String.fromCharCode(...new Uint8Array(credential.response.clientDataJSON)))
};

const request = {
Expand All @@ -244,7 +245,7 @@ class LoginClient {
const deviceCreationResult = await this.httpClient.post('/session/devices', this.enableCredentials, request, { Authorization: token && `Bearer ${token}` });
return deviceCreationResult.data;
} catch (error) {
this.logger && this.logger.log({ title: 'Failed to register new device', error });
this.logger && this.logger.log({ title: 'Failed to register new device', error, request, credential });
throw error;
}
}
Expand Down

0 comments on commit 58cf24c

Please sign in to comment.