Coder Social home page Coder Social logo

trezor-graveyard / trezor-chrome-extension Goto Github PK

View Code? Open in Web Editor NEW
29.0 15.0 19.0 8.21 MB

:warning: OBSOLETE. DO NOT USE!

License: GNU General Public License v3.0

JavaScript 70.08% Python 0.70% Makefile 0.83% HTML 23.78% CSS 4.61%
bitcoin trezor chrome-extension chrome

trezor-chrome-extension's Introduction

TREZOR Chrome Extension

Build Status gitter

Chrome extension for Bitcoin TREZOR by SatoshiLabs.

About

TREZOR Chrome Extension has two different purposes.

First, it has a built-in device management functionality, for wiping/recovery/initialization/.... It doesn't connect to any outside sources, all the data (including TREZOR firmware) is bundled with the app, so it works completely offline (if you somehow manage to install Chrome without an internet connection).

Second, it's a transport layer between websites (such as our own webwallet TREZOR Wallet) and TREZOR devices. It's possible to send Chrome messages (see chrome messages API documentation) to the extension, and the extension resends it to TREZOR hardware and back.

The messages are encoded through protobuf.js library and sent to the actual hardware via Chrome USB HID API.

The API of the extensions is described below. For development of web apps for TREZOR, it is recommended to use trezor.js javascript API, which has separate javascript calls for most common usecases; or TREZOR Connect, which is even more high level. However, the end user still needs to install either the extension or trezord.

Install via Web store

Extension is available for download at Google Web store (and is automatically offered on webwallet TREZOR Wallet).

Install via ZIP

If you don't trust Google Web store (or want to use an offline machine), you can download the ZIP file extension.zip, unzip it, go to chrome://extensions/ in Chrome, enable "Developer mode", click "Load upacked extension" and find the directory.

The ZIP file in the repo will be updated simultaneously with the updates in Google Web Store; it might not be up-to-date with the master branch.

Install from source

Checking out sources

git clone --recursive https://github.com/trezor/chrome-extension.git

Or, if you already cloned the repository but not the submodules

git submodule update --init --recursive

Building

Building works on OS X and Linux and uses make.

You need to have flow installed for type checking. If you don't want to install it, edit the flow-check in Makefile to something like true.

You also need python3 and npm and have them in $PATH.

(You need to be online for the build because of npm install and git update that happen in the build.)

make npm-install # needed only the first time
make clear # if you built before
make zip

Source

The source code of the transport layer is using flow type annotations and some features of ECMAScript 6.

Most of the logic is now in trezor-link npm package, the extension just do data validation and so on.

The source code of the device management is an angular app. If it seems a little "over-blown", it's because it was created as a clone of the whole myTREZOR app, which handles more than device management, and then functionality was stripped off.

Caveats

On Mac OS X, Windows and Chrome OS, installing the extension should work without any root privileges. Unfortunately, on GNU/Linux, you have install so-called udev rules as a root.

If you are using wallet.trezor.io, we are trying to detect the errors and offer you an easy package for the two most popular packaging systems (DEB and RPM).

If you don't want to or can't install that, please refer to our documentation

http://doc.satoshilabs.com/trezor-user/settingupchromeonlinux.html

UDP connection

Connect to UDP TREZOR emulator (will be released soon-ish) by opening extension background page in chrome://extensions and typing into console

window.setUdp([21324, ...])

with the list of ports of the virtual devices. The devices are immediately added and are registered as connected; if an app (like myTREZOR) is running, it will see them and try to communicate with them. To simulate disconnect, just type

window.setUdp([])

and the device are marked as disconnected.

Allowed ports are 21324, 21325 and 21326.

Note: there is a known bug - if you set up UDP connection, but turn off the emulator, the HID device listing might get stuck on webpage reloads. If you notice this, set wuindow.setUdp([]) or turn on the emulator.

API

If installed using some of the described methods, the extension has an id jcjjhjgimijdkoamemaghajlhegmoclj.

You send the messages to the extension using chrome messages API (read the note about whitelisting below).

The messages are javacript Objects with type property and body property; type is always string, body varies depending on the type.

The response is a javascript Object with type property, which is either "response" or "error"; in the response case, the object has body with type depending on message; in the error case, the object has message with error message.

So, the code, communicating with the extension, might look like this:

chrome.runtime.sendMessage('jcjjhjgimijdkoamemaghajlhegmoclj', {type: "info"},
  function(response) {
    if (response.type === "error") {
      handleError(response.type);
    } else {
      handleInfo(response.body);
    }
  }
);

The possible messages are:

type body response type description
info {version: string,
configured: boolean}
Returns current version of bridge and info about configuration.
See configure for more info.
configure config, as hex string "Success" Before any advanced call, configuration file needs to be loaded to extension.
Configuration file is signed by SatoshiLabs and the validity of the signature is limited.
Current config should be in this repo, or on AWS here.
enumerate Array<{path: number,
session: number | null}>
Lists devices.
path uniquely defines device between more connected devices. It usually increases on reconnect until restart of browser, but there is no guarantee.
If session is null, nobody else is using the device; if it's number, it identifies who is using it.
listen previous, as JSON like enumerate Listen to changes and returns either on change or after 30 second timeout. Compares change from previous that is sent as a parameter. "Change" is both connecting/disconnecting and session change.

previous must be exactly the output from the previous enumerate, even if the devices have additional properties that are not described above
acquire {path: path of device,
previous: previous session (or null)
{session: number} Acquires the device at path. By "acquiring" the device, you are claiming the device for yourself.
Before acquiring, checks that the current session is previous.
If two applications call acquire on a newly connected device at the same time, only one of them succeed.
release {session: session to release} "Success" Releases the device with the given session.
By "releasing" the device, you claim that you don't want to use the device anymore.
call {id: session to call,
type: string,
message: object}
{type: string, body: object} Calls the message and returns the response from TREZOR.
Messages are defined in this protobuf file.
type in request is, for example, GetFeatures; type in response is, for example, Features

Whitelisting

You cannot connect to the extension from anywhere on the internet. Your URL needs to be specifically whitelisted; whitelist is baked-in in the extension manifest.

localhost is specifically whitelisted, so you can experiment on http://localhost. If you want to add your url in order to make a TREZOR web app, make a pull request to this file.

License

GPLv3

some code from sowbug/trhid and throughnothing/chrome-trezor

trezor-chrome-extension's People

Contributors

dependabot[bot] avatar karelbilek avatar prusnak avatar sjaakvandenberg avatar slush0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trezor-chrome-extension's Issues

Some error when try to build from sources

Repository pulled from instructions in docs.
Commands:
make npm-install
make clear
make zip

rm -rf .tmp rm -rf ../extension/management cp -r dist ../extension/management rm -rf ../extension/data python3 firmware_copy.py Traceback (most recent call last): File "firmware_copy.py", line 8, in <module> with open('data/firmware/releases.json') as data_file: FileNotFoundError: [Errno 2] No such file or directory: 'data/firmware/releases.json' Makefile:41: ошибка выполнения рецепта для цели «copy-data» make[1]: *** [copy-data] Ошибка 1 make[1]: выход из каталога «/home/matroskinb/crypto/chrome-extension/management» Makefile:33: ошибка выполнения рецепта для цели «management_make» make: *** [management_make] Ошибка 2

Can no longer pay Bitpay Invoices as they switch to BIP 70 Payment Protocol

Bit pay has started switching to BIP 70 for payments. They have started with loading their visa card. Without BIP 70 support, there is no way to send money now from my Trezor to my Bitpay Visa. https://blog.bitpay.com/payment-protocol-card-orders/

Please add payment protocol support to Trezor wallets. With non SegWit fees so high, I exclusively use my Trezor now, but it is an issue I can no longer send payments to Bitpay.

Trezor connection hierarchy

If I have the browser plugin, and/or a chrome extension and/or the Trezor bridge installed onto a system which will take precedence over the other? Will the different methods interfere with another method of connection? Should an install of one automatically check for and remove the others?

Unable to Setup New Trezor: "Update failed"

2017 MacBook Pro. macOS High Siera 10.13.2. Chrome 63.0.3239.132 (64-bit).

I'm setting up this trezor for the first time and I always get this error at trezor.io/start:
screen shot 2018-01-05 at 01 18 20

When I open the Chrome app directly:
screen shot 2018-01-05 at 01 21 42
screen shot 2018-01-05 at 01 21 27

Note that I have Strict site isolation turned on in Chrome.
Note also that I've been unable to setup the device using trezorctl. See here.

Documentation Updates

On OSX I had to run the snippet below instead of npm run prepare as the default npm run prepare did not work. I had to add the bak arg as the extension for the interactive edit backup file, and also change all the \\ to \.

I also think it would be good to default the documentation to use ./node_modules/protobufjs/bin/proto2js instead of assuming proto2js is available globally (or add installing that globally to the setup docs).

sed -i bak 's/\(google\/protobuf\)/\.\/\1/' trezor-common/protob/config.proto && ./node_modules/protobufjs/bin/proto2js trezor-common/protob/config.proto -commonjs > config_proto_compiled.js

recovery fails with cannot read property message

Using the Chrome extension (downloaded from the chrome store today), I wipe the Trezor and then attempt to run the recovery.

Every time, without regard to the input values, I receive a "Cannot read property 'name' of undefined" message when I click continue (see screenshot). This is easiest to reproduce when the PIN protection is unchecked because then you don't have to enter a PIN to get the failure.

bug

["log","Mon, 09 Jan 2017 02:08:23 GMT","[trezor] Sending","RecoveryDevice",{"pin_protection":false,"word_count":24,"enforce_wordlist":true}]
["log","Mon, 09 Jan 2017 02:08:23 GMT","[trezor.js event session] send : ","RecoveryDevice",{"pin_protection":false,"word_count":24,"enforce_wordlist":true}]
["error","Mon, 09 Jan 2017 02:08:24 GMT","[trezor] Error received",{"type":"error","message":"Cannot read property 'name' of undefined"}]
["log","Mon, 09 Jan 2017 02:08:24 GMT","[trezord] Received error",{}]
["log","Mon, 09 Jan 2017 02:08:24 GMT","[trezor.js event session] error : ",{}]

Google Chrome Version 55.0.2883.87 (64-bit)
Ubuntu 16.04.1 LTS
1.4.0 Trezor firmware

Modify whitelist in Chrome Extension

I want to create my own chrome extension based on yours. But I need to modify the whitelist on it so that my site can comunicate with the trezor device. But when modifying the whitelist in manifest.json nothing happens.

After searching a bit I found that there is a config_signed.bin file that is generated in trezor-common. I tried to modify the config.json file in the signer and sign it with my own private key. What I do not know is where exactly I have to import my modified config_signed.bin and also where should I put my public key in the extension code so that the config_signed.bin it can be decrypted.

I would also apreciate if you could tell me any other (easier or not) way that can allow me to achieve my goal.

p.s. I cannot use trezor connect because it does not provide enough functionalities for my website.

Chrome extension opens Chrome, then opens wallet in a different browser.

I think this is default behavior with what I have set as the "default browser" (Safari). But kind of expect from a user perspective that it would open in Chrome, since the browser is already being used via the extension.

Additionally, Safari when "sending", does not allow me to scan a QR code via the laptop camera (Chrome does however, hence it would be nice if the wallet opened in Chrome).

I am a first time user of the Trezor so this is one of my initial impressions.

UI improvement requests for usability

UI improvement requests for usability

As a power user of password managers for many years (10+) with a very large password database that I use all day long and every day I highly recommend the following user interface improvements:

  1. On the edit entry view, the fields are very small / short. While there is so much unused space to the right, users can not see the full contents in the fields (e.g. long URL, long passphrase, long username, lots of text in the secret note field) Screenshot: http://imgur.com/alo8X1l

People put a lot of content into the free text area, so it should be using as much space as possible.
The fields should use a large percentage of the available space on the page, not a fixed value.

  1. On the left "Tags" navigation bar, decrease the font size and space used by each tag. People who really store all their passwords will have so many categories, and they will not like to scroll down very far the screen to reach them all.

  2. On the left "Tags" navigation bar, the most important feature would be to have the "Tags" Categories expand with [+] and allow the user to see a list of entries in that category in the left navigation bar itself! This is a feature many current popular password managers are missing, but it is crucial for speed of usability.
    People can open their most used categories on the left navigation bar with the [+] sign, and access their entries with 1 click, instead of 2 clicks (Tag and then find the entry on the right, click to edit it), VERY big usability difference! Please do not underestimate this, this is the most important change needed in this application. People will be able to see all their entries all the time, even while looking at the edit details screen of one entry on the right. Make the application remember which categories were expanded last time it was open, if possible.

  3. Make the edit details screen the default view on the right. Do not make people click to see their information, people want to see their information all the time especially that in the custom text entry field. People need to get to this info quickly to copy paste data from it all the time, it takes too long to click on edit all the time and enter the Trezor PIN every time.

  4. Allow creation of custom fields / templates

Setting up the Chrome extension on ubuntu, no deb packages offered.

"
After you install the Chrome extension in TREZOR Wallet on Linux, you will be asked to install additional package (DEB or RPM), which configures UDEV rules of your system.
"
Not offered the option to install these deb packages on ubuntu install, so a link to where to down load them in docs might be useful.

Add configurable timeout

When using password manager heavily, the 10 minutes automatic lock becomes very annoying. Configurable timeout would be much appreciated.

kill config_signed.bin usage

Is this still used in the extension? On 15th of August, I will remove this from our server infrastructure. We need to make sure this file is no longer required in the chrome extension.

Maybe @karel-3d can provide more info

HID transport stuck when UDP turned on, but emulator turned off

There is a bug with UDP

If you turn on UDP, but you turn off the trezor-core emulator, the listing of HID devices is stuck and delayed

It seems it's because I use window.setTimeout to detect turned off emulator, but Chrome delays the timeout in background tab, and the enumerating gets stuck.

I will not correct this, since Chrome will ax apps soon anyway, and using UDP transport for emulator is too nerdy anyway

Electron.js app?

When will you annouce and offer a Electron.js app(for Mac OS,Linux & Windows)?

Add configurable timeout

This was promised to be part of new release (issue closed), which I just installed and it's not there. I also advice development managers not to close issues before they are actually done. If it's part of next release, putting appropriate label is recommended.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.