Latest changes

This commit is contained in:
varjolintu 2022-10-14 15:28:08 +03:00
parent 653cca7419
commit a70ee7431f
3 changed files with 10 additions and 11 deletions

View file

@ -624,20 +624,23 @@ keepass.requestAutotype = async function(tab, args = []) {
}
};
keepass.webauthnRegister = async function(tab, publicKey) {
keepass.webauthnRegister = async function(tab, args = []) {
try {
const taResponse = await keepass.testAssociation(tab, [ false ]);
if (!taResponse || !keepass.isConnected) {
if (!taResponse || !keepass.isConnected || args.length < 2) {
browserAction.showDefault(tab);
return [];
}
const kpAction = kpActions.WEBAUTHN_REGISTER;
const nonce = keepassClient.getNonce();
const publicKey = args[0];
const origin = args[1];
const messageData = {
action: kpAction,
publicKey: JSON.parse(JSON.stringify(publicKey))
publicKey: JSON.parse(JSON.stringify(publicKey)),
origin: origin
};
const response = await keepassClient.sendMessage(kpAction, tab, messageData, nonce);

View file

@ -854,7 +854,7 @@ window.addEventListener('message', (ev) => {
console.log('Request from: ', ev.origin);
console.log(ev.data.publicKey);
sendMessage('webauthn-register', ev.data.publicKey);
sendMessage('webauthn-register', [ ev.data.publicKey, ev.origin ]);
// Send a test response after a delay. webauthn.js should wait for this.
setTimeout(() => {

View file

@ -8,19 +8,15 @@
const publicKey = {};
publicKey.attestation = options.publicKey.attestation;
publicKey.authenticatorSelection = options.publicKey.authenticatorSelection;
publicKey.challenge = new Uint8Array(options.publicKey.challenge).toString();
publicKey.challenge = window.btoa(options.publicKey.challenge); // Use b64 instead
publicKey.pubKeyCredParams = options.publicKey.pubKeyCredParams;
publicKey.rp = options.publicKey.rp;
publicKey.timeout = options.publicKey.timeout;
publicKey.user = options.publicKey.user;
publicKey.user.id = options.publicKey.user.id.toString();
/*const credential = await navigator.credentials.create({
publicKey: publicKey
});*/
publicKey.user.id = window.btoa(options.publicKey.user.id); // Use b64 instead
window.postMessage({ action: 'webauthn-create', publicKey: publicKey }, window.location.origin);
//await waitForCreateResponse();
//await waitForCreateResponse(); // How to do this?
},
async get(options) {
console.log('Overridden get');