mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-24 18:09:10 +00:00
Check in trezor work
This commit is contained in:
parent
e292253454
commit
e9101516e7
@ -1,3 +1,4 @@
|
||||
import 'babel-polyfill';
|
||||
import { app } from 'electron';
|
||||
import { registerServer } from 'shared/enclave/server';
|
||||
import getWindow from './window';
|
||||
|
@ -54,6 +54,7 @@
|
||||
"redux-logger": "3.0.6",
|
||||
"redux-saga": "0.16.0",
|
||||
"scryptsy": "2.0.0",
|
||||
"trezor.js-node": "6.11.3",
|
||||
"uuid": "3.2.1",
|
||||
"wallet-address-validator": "0.1.6",
|
||||
"whatwg-fetch": "2.0.3",
|
||||
|
@ -2,5 +2,6 @@ import { webFrame } from 'electron';
|
||||
import { PROTOCOL_NAME } from 'shared/enclave/utils';
|
||||
|
||||
export function setupClient() {
|
||||
// Whitelist custom protocol
|
||||
webFrame.registerURLSchemeAsPrivileged(PROTOCOL_NAME);
|
||||
}
|
||||
|
@ -4,9 +4,11 @@ import { PROTOCOL_NAME, isValidEventType } from 'shared/enclave/utils';
|
||||
import { EnclaveMethods, EnclaveMethodParams, EnclaveResponse } from 'shared/enclave/types';
|
||||
|
||||
export function registerServer(app: App) {
|
||||
// Register protocol scheme
|
||||
protocol.registerStandardSchemes([PROTOCOL_NAME]);
|
||||
|
||||
app.on('ready', () => {
|
||||
// Register custom protocol behavior
|
||||
protocol.registerStringProtocol(PROTOCOL_NAME, async (req, cb) => {
|
||||
let res: EnclaveResponse;
|
||||
|
||||
@ -29,6 +31,23 @@ export function registerServer(app: App) {
|
||||
cb(JSON.stringify(res));
|
||||
});
|
||||
});
|
||||
|
||||
// Fix trezord requests for every new browser window
|
||||
app.on('web-contents-created', (_, webContents) => {
|
||||
const { session } = webContents;
|
||||
if (!session.webRequest) {
|
||||
return;
|
||||
}
|
||||
session.webRequest.onBeforeSendHeaders((details: any, callback: any) => {
|
||||
const url = details.url;
|
||||
if (url.startsWith('https://localback.net:21324')) {
|
||||
if (details.requestHeaders.Origin === 'null') {
|
||||
delete details.requestHeaders.Origin;
|
||||
}
|
||||
}
|
||||
callback({ cancel: false, requestHeaders: details.requestHeaders });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getMethod(req: Electron.RegisterStringProtocolRequest): EnclaveMethods {
|
||||
|
@ -1,8 +1,19 @@
|
||||
import { WalletLib } from 'shared/enclave/types';
|
||||
// TODO: Trezor not working right now, come back later
|
||||
// TODO: Type trezor lib
|
||||
// import { DeviceList } from 'trezor.js-node';
|
||||
// const deviceList = new DeviceList({ debug: true });
|
||||
|
||||
const Trezor: WalletLib = {
|
||||
async getChainCode() {
|
||||
throw new Error('Not yet supported');
|
||||
throw new Error('Not yet implemented');
|
||||
// const device = await deviceList.acquireFirstDevice(true);
|
||||
// console.log(device);
|
||||
// device.run((session: any) => {
|
||||
// return session.signMessage([1,2], "message", "bitcoin");
|
||||
// });
|
||||
//
|
||||
// return { chainCode: 'test', publicKey: 'test' };
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@ const electronConfig = {
|
||||
],
|
||||
externals: {
|
||||
'node-hid': 'commonjs node-hid',
|
||||
'@ledger/hw-transport-hid': 'commonjs @ledger/hw-transport-hid'
|
||||
'trezor.js-node': 'require("trezor.js-node")'
|
||||
},
|
||||
node: {
|
||||
__dirname: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user