forked from bmatusiak/FIDO2Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preload.js
39 lines (35 loc) · 1.36 KB
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
let {ipcRenderer} = require('electron');
/**
* Optional.
*/
window.require = require;
process.once('loaded', () => {
global.ipcRenderer = ipcRenderer;
if (process.platform === 'win32') return;
if (!navigator.credentials) return;
console.log('FIDO2 client preload');
navigator.credentials.create = (publicCreateOptions) => {
return ipcRenderer.invoke('navigator.credentials.create', publicCreateOptions).then((x) => {
x.getClientExtensionResults = () => {
return {}
};
x.rawId = x.rawId?.buffer;
x.response.clientDataJSON = x.response.clientDataJSON?.buffer;
x.response.attestationObject = x.response.attestationObject?.buffer;
return x;
});
};
navigator.credentials.get = (publicGetOptions) => {
return ipcRenderer.invoke('navigator.credentials.get', publicGetOptions).then((x) => {
x.getClientExtensionResults = () => {
return {}
};
x.rawId = x.rawId?.buffer;
x.response.clientDataJSON = x.response.clientDataJSON?.buffer;
x.response.authenticatorData = x.response.authenticatorData?.buffer;
x.response.signature = x.response.signature?.buffer;
x.response.userHandle = x.response.userHandle?.buffer;
return x;
});
};
});