Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update - debugger logging #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/debugger/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { prettifyTransformations, binToHex } from "./transformations.js";
import {
parseCredentials,
prettifyCredentials,
stringifyBuffers,
prettyCredentialsWithHtml,
orderCredentialsByType,
getUserPresentStatus,
Expand Down Expand Up @@ -257,6 +258,7 @@ function getCreateOptions() {
function handleRegistrationCredentials(credentials) {
lastCredentials = deepClone(credentials);
lastCredentialsParsed = parseCredentials(credentials);
console.log("navigator.credentials.create:result", stringifyBuffers(lastCredentials));

const prettyCredentials = prettifyCredentials(
orderCredentialsByType(credentials)
Expand Down Expand Up @@ -312,6 +314,7 @@ function handleCBORCredentials(credentials) {
function handleAuthenticationCredentials(credentials) {
lastCredentials = deepClone(credentials);
lastCredentialsParsed = parseCredentials(credentials);
console.log("navigator.credentials.get:result", stringifyBuffers(lastCredentials));

const prettyCredentials = prettifyCredentials(
orderCredentialsByType(credentials)
Expand Down
17 changes: 16 additions & 1 deletion src/debugger/output-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ export function prettifyCredentials(credentials) {
return splitCredentialsByType(creds);
}

export function stringifyBuffers(data) {
const object = deepClone(data);
Object.keys(object).forEach(key => {
if(object[key] instanceof ArrayBuffer){
object[key] = btoa(String.fromCharCode(...new Uint8Array(object[key])));
return;
}
if(typeof (object[key]) === 'object') {
object[key] = stringifyBuffers(object[key]);
return;
}
});
return object;
}

export function addMarkupToLine(line) {
const separator = line.indexOf(":");
const head = line.substring(0, separator);
Expand Down Expand Up @@ -262,6 +277,6 @@ export function prettyCredentialsWithHtml(prettyCredentials) {

export function getUserPresentStatus(credentials) {
const parsed = parseAttestationObject(credentials.response.attestationObject);
console.log(parsed.authData.flags);
console.log("attestation.flags:", parsed.authData.flags);
return parsed.authData.flags.userPresent;
}