Skip to content

Instantly share code, notes, and snippets.

@demesne
Created March 31, 2026 18:43
Show Gist options
  • Select an option

  • Save demesne/dc19fd2b8732c8e2eedfb403b655f2f3 to your computer and use it in GitHub Desktop.

Select an option

Save demesne/dc19fd2b8732c8e2eedfb403b655f2f3 to your computer and use it in GitHub Desktop.
passkey debug.js
(function() {
const origCreate = navigator.credentials.create.bind(navigator.credentials);
const origGet = navigator.credentials.get.bind(navigator.credentials);
// Helper: Converts nested ArrayBuffers to Base64 so JSON.stringify can "see" them
const prepareForString = (obj) => {
if (obj instanceof ArrayBuffer || ArrayBuffer.isView(obj)) {
return btoa(String.fromCharCode(...new Uint8Array(obj)));
}
if (Array.isArray(obj)) return obj.map(prepareForString);
if (typeof obj === 'object' && obj !== null) {
return Object.fromEntries(
Object.entries(obj).map(([k, v]) => [k, prepareForString(v)])
);
}
return obj;
};
navigator.credentials.create = async function(options) {
const optionsString = JSON.stringify(prepareForString(options));
console.log('[Passkey] CREATE OPTIONS STRING: ' + optionsString);
try {
const result = await origCreate(options);
// Manually map the result components to ensure they are captured in the string
const resultData = {
id: result.id,
rawId: result.rawId,
type: result.type,
attestation: result.response
};
console.log('[Passkey] CREATE RESULT STRING: ' + JSON.stringify(prepareForString(resultData)));
return result;
} catch (error) {
console.error('[Passkey] CREATE FAILED: ' + error.message);
throw error;
}
};
navigator.credentials.get = async function(options) {
const optionsString = JSON.stringify(prepareForString(options));
console.log('[Passkey] GET OPTIONS STRING: ' + optionsString);
try {
const result = await origGet(options);
const resultData = {
id: result.id,
rawId: result.rawId,
assertion: result.response
};
console.log('[Passkey] GET RESULT STRING: ' + JSON.stringify(prepareForString(resultData)));
return result;
} catch (error) {
console.error('[Passkey] GET FAILED: ' + error.message);
throw error;
}
};
console.log('[Passkey] Monitoring active. All intercepts will print as full strings.');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment