Support for decryption in Signer (#2421)

* Adding some tests

* Implementing decrypt in queue

* Removing code duplication.

* Printing public key in ethstore

* Bump UI

* Normalizing dapps format for signer.

* Fixing tests compilation

* fix whitespace

[ci:skip]
This commit is contained in:
Tomasz Drwięga
2016-10-15 14:44:08 +02:00
committed by Gav Wood
parent 85eeb3ea6e
commit 03c1559ead
27 changed files with 457 additions and 278 deletions

View File

@@ -20,11 +20,12 @@ ethcore-util = { path = "../util" }
ethcore-io = { path = "../util/io" }
ethcore-rpc = { path = "../rpc" }
ethcore-devtools = { path = "../devtools" }
parity-dapps = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4", optional = true}
parity-dapps-signer = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4", optional = true}
clippy = { version = "0.0.90", optional = true}
[features]
dev = ["clippy"]
ui = ["parity-dapps-signer"]
ui = ["parity-dapps", "parity-dapps-signer"]
use-precompiled-js = ["parity-dapps-signer/use-precompiled-js"]

View File

@@ -54,6 +54,8 @@ extern crate jsonrpc_core;
extern crate ws;
#[cfg(feature = "ui")]
extern crate parity_dapps_signer as signer;
#[cfg(feature = "ui")]
extern crate parity_dapps as dapps;
#[cfg(test)]
extern crate ethcore_devtools as devtools;

View File

@@ -26,21 +26,39 @@ use util::{H256, Mutex, version};
#[cfg(feature = "ui")]
mod signer {
use signer;
use signer::SignerApp;
use dapps::{self, WebApp};
pub fn handle(req: &str) -> Option<signer::File> {
signer::handle(req)
#[derive(Default)]
pub struct Handler {
signer: SignerApp,
}
impl Handler {
pub fn handle(&self, req: &str) -> Option<&dapps::File> {
let file = match req {
"" | "/" => "index.html",
path => &path[1..],
};
self.signer.file(file)
}
}
}
#[cfg(not(feature = "ui"))]
mod signer {
pub struct File {
pub content: String,
pub mime: String,
pub content: &'static str,
pub content_type: &'static str,
}
pub fn handle(_req: &str) -> Option<File> {
None
#[derive(Default)]
pub struct Handler {
}
impl Handler {
pub fn handle(&self, _req: &str) -> Option<&File> {
None
}
}
}
@@ -107,6 +125,7 @@ pub struct Session {
self_origin: String,
authcodes_path: PathBuf,
handler: Arc<IoHandler>,
file_handler: Arc<signer::Handler>,
}
impl ws::Handler for Session {
@@ -152,12 +171,12 @@ impl ws::Handler for Session {
}
// Otherwise try to serve a page.
Ok(signer::handle(req.resource())
Ok(self.file_handler.handle(req.resource())
.map_or_else(
// return 404 not found
|| error(ErrorType::NotFound, "Not found", "Requested file was not found.", None),
// or serve the file
|f| add_headers(ws::Response::ok(f.content.into()), &f.mime)
|f| add_headers(ws::Response::ok_raw(f.content.to_vec()), f.content_type)
))
}
@@ -181,6 +200,7 @@ pub struct Factory {
skip_origin_validation: bool,
self_origin: String,
authcodes_path: PathBuf,
file_handler: Arc<signer::Handler>,
}
impl Factory {
@@ -190,6 +210,7 @@ impl Factory {
skip_origin_validation: skip_origin_validation,
self_origin: self_origin,
authcodes_path: authcodes_path,
file_handler: Arc::new(signer::Handler::default()),
}
}
}
@@ -204,6 +225,7 @@ impl ws::Factory for Factory {
skip_origin_validation: self.skip_origin_validation,
self_origin: self.self_origin.clone(),
authcodes_path: self.authcodes_path.clone(),
file_handler: self.file_handler.clone(),
}
}
}