mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Latest changes
This commit is contained in:
parent
c3a17c430f
commit
c44a80f9d1
2 changed files with 23 additions and 6 deletions
|
|
@ -856,7 +856,7 @@ window.addEventListener('message', async (ev) => {
|
|||
|
||||
const ret = await sendMessage('webauthn-register', [ ev.data.publicKey, ev.origin ]);
|
||||
if (ret.response) {
|
||||
window.postMessage({ action: 'webauthn-create-response', data: ret.response.response }, window.location.origin);
|
||||
window.postMessage({ action: 'webauthn-create-response', data: ret.response }, window.location.origin);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const postMessageToExtension = function(request) {
|
|||
const handler = (msg) => {
|
||||
if (msg && msg.data && msg.data.action === messageRequest + '-response') {
|
||||
messageEvent.removeEventListener('message', listener);
|
||||
resolve(msg.data);
|
||||
resolve(msg.data.data);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
@ -22,6 +22,20 @@ const postMessageToExtension = function(request) {
|
|||
});
|
||||
};
|
||||
|
||||
const stringToArrayBuffer = function(str) {
|
||||
const arr = Uint8Array.from(str, c => c.charCodeAt(0));
|
||||
return arr.buffer;
|
||||
};
|
||||
|
||||
const arrayToArrayBuffer = function(arr) {
|
||||
const buf = Uint8Array.from(arr);
|
||||
return buf.buffer;
|
||||
}
|
||||
|
||||
const base64ToArrayBuffer = function(str) {
|
||||
return stringToArrayBuffer(atob(str));
|
||||
};
|
||||
|
||||
(async () => {
|
||||
const webauthnCredentials = {
|
||||
async create(options) {
|
||||
|
|
@ -37,13 +51,16 @@ const postMessageToExtension = function(request) {
|
|||
publicKey.user = options.publicKey.user;
|
||||
publicKey.user.id = window.btoa(options.publicKey.user.id); // Use b64 instead
|
||||
|
||||
const response = await postMessageToExtension({ action: 'webauthn-create', publicKey: publicKey });
|
||||
console.log('Response: ', response);
|
||||
const publicKeyCredential = await postMessageToExtension({ action: 'webauthn-create', publicKey: publicKey });
|
||||
console.log('Response: ', publicKeyCredential);
|
||||
|
||||
// Parse the response and change needed variables from b64 to ArrayBuffer/UInt8Array etc.
|
||||
publicKeyCredential.rawId = base64ToArrayBuffer(publicKeyCredential.id);
|
||||
publicKeyCredential.response.attestationObject.authData = arrayToArrayBuffer(publicKeyCredential.response.attestationObject.authData);
|
||||
publicKeyCredential.response.clientDataJSON = stringToArrayBuffer(JSON.stringify(publicKeyCredential.response.clientDataJSON));
|
||||
|
||||
|
||||
return [];
|
||||
console.log('Final response: ', publicKeyCredential);
|
||||
return publicKeyCredential;
|
||||
},
|
||||
async get(options) {
|
||||
console.log('Overridden get');
|
||||
|
|
|
|||
Loading…
Reference in a new issue