Skip to content

Commit

Permalink
Merge branch 'master' into test/node-wrapper-nonsecrets
Browse files Browse the repository at this point in the history
  • Loading branch information
jovfer authored Sep 17, 2020
2 parents dddebf0 + 4110694 commit 7f401d1
Show file tree
Hide file tree
Showing 92 changed files with 2,148 additions and 1,481 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile.cd
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ def shell(command) {
}

def setupRust() {
shell("rustup default 1.39.0")
shell("rustup default 1.46.0")
}

def androidPublishing() {
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def shell(command) {
}

def setupRust() {
shell("rustup default 1.39.0")
shell("rustup default 1.46.0")
}

def setupBrewPackages() {
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Indy SDK provides libindy wrappers for the following programming languages and p
[Libnullpay](/libnullpay/README.md) is a libindy plugin that can be used for development of applications that use the Payments API of Indy SDK.

### Libvcx

[Libvcx](/vcx/README.md) is a c-callable library built on top of libindy that provides a high-level
credential exchange protocol. It simplifies creation of agent applications and provides
better agent-2-agent interoperability for [Hyperledger Indy](https://www.hyperledger.org/projects/hyperledger-indy)
Expand All @@ -82,16 +81,19 @@ Indy SDK provides libvcx wrappers for the following programming languages and pl
These wrappers are currently in **experimental** state and it is not part of official releases.

##### Example use
For the main workflow example check [VCX Python demo](https://github.com/hyperledger/indy-sdk/tree/master/vcx/wrappers/python3/demo).

### Dummy Cloud Agent
[Dummy Cloud Agent](/vcx/dummy-cloud-agent/README.md) is simple implementation of VCX compatible Cloud Agent.
- For the main workflow example check [VCX Python demo](https://github.com/hyperledger/indy-sdk/tree/master/vcx/wrappers/python3/demo).
- Another libvcx example is available as [VCX NodeJS demo](https://github.com/hyperledger/indy-sdk/tree/master/vcx/wrappers/node#run-demo).
- For mobile see [iOS Demo project](https://github.com/sktston/vcx-demo-ios)

### LibVCX Agency
LibVCX can be used with
[mediator agency](https://github.com/hyperledger/aries-rfcs/blob/master/concepts/0046-mediators-and-relays/README.md)
which enables asynchronous communication between 2 parties.
- [Dummy Cloud Agent](/vcx/dummy-cloud-agent/README.md) is simple implementation of VCX compatible Cloud Agent.
The main purpose of this implementation is VCX testing, demos and documentation of VCX protocol.
There is an parallel work on providing reference implementation of Agent2Agent protocol in indy-agent repo.
We plan to migrate to this protocol and implementation soon.
- [NodeVCXAgency](https://github.com/AbsaOSS/vcxagencynode) is alternative implementation in NodeJS.

## How-To Tutorials

Short, simple tutorials that demonstrate how to accomplish common tasks
are also available. See the [docs/how-tos](docs/how-tos) folder.

Expand Down
3 changes: 1 addition & 2 deletions cli/src/command_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use unescape::unescape;
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::error::Error;

use linefeed::{Reader, ReadResult};

Expand Down Expand Up @@ -868,7 +867,7 @@ impl CommandExecutor {
}
}
Err(err) => {
println_err!("{}", err.description().to_string());
println_err!("{}", err.to_string());
println!("Please enter value for {}:", param);
}
}
Expand Down
3 changes: 1 addition & 2 deletions cli/src/utils/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ extern crate log4rs;
extern crate log;
extern crate libc;

use std::error::Error;
use indy;

pub struct IndyCliLogger;

impl IndyCliLogger {
pub fn init(path: &str) -> Result<(), String> {
log4rs::init_file(path, Default::default())
.map_err(|err| format!("Cannot init Indy CLI logger: {}", err.description()))?;
.map_err(|err| format!("Cannot init Indy CLI logger: {}", err.to_string()))?;

indy::logger::set_logger(log::logger())
.map_err(|_| "Cannot init Libindy logger".to_string())
Expand Down
4 changes: 2 additions & 2 deletions docs/build-guides/mac-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Automated build: clone the repo and run `mac.build.sh` in the `libindy` folder.
## Manual steps

1. Install Rust and rustup (https://www.rust-lang.org/install.html).
2. Install required native libraries and utilities (libsodium is added with URL to homebrew since version<1.0.15 is required)
2. Install required native libraries and utilities
```
brew install pkg-config
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/65effd2b617bade68a8a2c5b39e1c3089cc0e945/Formula/libsodium.rb
brew install libsodium
brew install automake
brew install autoconf
brew install cmake
Expand Down
8 changes: 6 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,15 @@ Almost all of them are optional and depend on the way you use Vcx (with agency o
* `threadpool_size` - size of thread pool used for command execution (8 by default).
* `protocol_version` - message protocol to use for agent to agency and agent to agent communication.
* `protocol_type` - message protocol to use for agent to agency and agent to agent communication.
Can be one of:
* "1.0" - use bundled messages, auth/anon cryptography.
* "2.0" - use aries cross domain message format, pack/unpack functions.
* "3.0" - use aries cross domain message format, pack/unpack functions and aries communication protocols (is alternative to the combination of settings "protocol_version":"2.0" and "communication_method":"aries").
* "3.0" - use aries cross domain message format, pack/unpack functions and aries communication protocols
(is alternative to the combination of settings "protocol_version":"2.0" and "communication_method":"aries").
Functions return messages in the `proprietary` format.
* "4.0" - use aries cross domain message format, pack/unpack functions and aries communication protocols.
Functions return messages in the `aries` format.
* `author_agreement` - accept and use transaction author agreement data containing the following fields:
* `acceptanceMechanismType` - (string) mechanism how user has accepted the TAA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const _CREATE_SCHEMA: [&str; 12] = [
ON UPDATE CASCADE
)",
"CREATE INDEX IF NOT EXISTS ix_tags_encrypted_name ON tags_encrypted(name)",
"CREATE INDEX IF NOT EXISTS ix_tags_encrypted_value ON tags_encrypted(value)",
"CREATE INDEX IF NOT EXISTS ix_tags_encrypted_value ON tags_encrypted(sha256(value))",
"CREATE INDEX IF NOT EXISTS ix_tags_encrypted_item_id ON tags_encrypted(item_id)",
"CREATE TABLE IF NOT EXISTS tags_plaintext(
name BYTEA NOT NULL,
Expand Down
15 changes: 1 addition & 14 deletions libindy/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions libindy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ only_high_cases = []
fatal_warnings = []

[dependencies]
env_logger = "0.6.2"
env_logger = "0.7"
etcommon-rlp = "0.2.4"
failure = "0.1.6"
failure = "0.1.7"
hex = "0.3.2"
libc = "0.2.66"
log = "0.4.8"
Expand All @@ -55,7 +55,7 @@ regex = "1.2.1"
indy-api-types = { path = "./indy-api-types"}
indy-utils = { path = "./indy-utils"}
indy-wallet = { path = "./indy-wallet"}
quote = "=1.0.2"
quote = "=1.0.7"

[dependencies.uuid]
version = "0.7.4"
Expand Down
2 changes: 1 addition & 1 deletion libindy/ci/centos.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN wget https://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-mav
RUN sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
RUN yum install -y apache-maven

ENV RUST_ARCHIVE=rust-1.39.0-x86_64-unknown-linux-gnu.tar.gz
ENV RUST_ARCHIVE=rust-1.46.0-x86_64-unknown-linux-gnu.tar.gz
ENV RUST_DOWNLOAD_URL=https://static.rust-lang.org/dist/$RUST_ARCHIVE

RUN mkdir -p /rust
Expand Down
2 changes: 1 addition & 1 deletion libindy/ci/ubuntu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN useradd -ms /bin/bash -u $uid indy
USER indy

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.39.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.46.0
ENV PATH /home/indy/.cargo/bin:$PATH

RUN cargo install cargo-deb
Expand Down
2 changes: 1 addition & 1 deletion libindy/ci/ubuntu18.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN apt-get install -y wget
RUN useradd -ms /bin/bash -u $uid indy
USER indy

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.39.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.46.0
ENV PATH /home/indy/.cargo/bin:$PATH

RUN cargo install cargo-deb
Expand Down
6 changes: 3 additions & 3 deletions libindy/include/indy_non_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ extern "C" {
/// {
/// retrieveType: (optional, false by default) Retrieve record type,
/// retrieveValue: (optional, true by default) Retrieve record value,
/// retrieveTags: (optional, true by default) Retrieve record tags
/// retrieveTags: (optional, false by default) Retrieve record tags
/// }
/// #Returns
/// wallet record json:
Expand Down Expand Up @@ -199,7 +199,7 @@ extern "C" {
/// retrieveTotalCount: (optional, false by default) Calculate total count,
/// retrieveType: (optional, false by default) Retrieve record type,
/// retrieveValue: (optional, true by default) Retrieve record value,
/// retrieveTags: (optional, true by default) Retrieve record tags,
/// retrieveTags: (optional, false by default) Retrieve record tags,
/// }
/// #Returns
/// search_handle: Wallet search handle that can be used later
Expand All @@ -226,7 +226,7 @@ extern "C" {
/// {
/// retrieveType: (optional, false by default) Retrieve record type,
/// retrieveValue: (optional, true by default) Retrieve record value,
/// retrieveTags: (optional, true by default) Retrieve record tags
/// retrieveTags: (optional, false by default) Retrieve record tags
/// }
/// #Returns
/// wallet record json:
Expand Down
4 changes: 2 additions & 2 deletions libindy/indy-api-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ pub mod wallet {
/// {
/// retrieveType: (optional, false by default) Retrieve record type,
/// retrieveValue: (optional, true by default) Retrieve record value,
/// retrieveTags: (optional, true by default) Retrieve record tags
/// retrieveTags: (optional, false by default) Retrieve record tags
/// }
/// record_handle_p: pointer to store retrieved record handle
pub type WalletGetRecord = extern fn(storage_handle: StorageHandle,
Expand Down Expand Up @@ -537,7 +537,7 @@ pub mod wallet {
/// retrieveTotalCount: (optional, false by default) Calculate total count,
/// retrieveType: (optional, false by default) Retrieve record type,
/// retrieveValue: (optional, true by default) Retrieve record value,
/// retrieveTags: (optional, true by default) Retrieve record tags,
/// retrieveTags: (optional, false by default) Retrieve record tags,
/// }
/// search_handle_p: pointer to store wallet search handle
pub type WalletSearchRecords = extern fn(storage_handle: StorageHandle,
Expand Down
18 changes: 13 additions & 5 deletions libindy/indy-wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate serde;
extern crate serde_derive;

use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::fs;
use std::io::BufReader;
use std::path::PathBuf;
Expand Down Expand Up @@ -47,6 +47,7 @@ mod wallet;
pub struct WalletService {
storage_types: RefCell<HashMap<String, Box<dyn WalletStorageType>>>,
wallets: RefCell<HashMap<WalletHandle, Box<Wallet>>>,
wallet_ids: RefCell<HashSet<String>>,
pending_for_open: RefCell<HashMap<WalletHandle, (String /* id */, Box<dyn WalletStorage>, Metadata, Option<KeyDerivationData>)>>,
pending_for_import: RefCell<HashMap<WalletHandle, (BufReader<::std::fs::File>, chacha20poly1305_ietf::Nonce, usize, Vec<u8>, KeyDerivationData)>>,
}
Expand All @@ -62,6 +63,7 @@ impl WalletService {
WalletService {
storage_types,
wallets: RefCell::new(HashMap::new()),
wallet_ids: RefCell::new(HashSet::new()),
pending_for_open: RefCell::new(HashMap::new()),
pending_for_import: RefCell::new(HashMap::new()),
}
Expand Down Expand Up @@ -152,7 +154,7 @@ impl WalletService {
pub fn delete_wallet_prepare(&self, config: &Config, credentials: &Credentials) -> IndyResult<(Metadata, KeyDerivationData)> {
trace!("delete_wallet >>> config: {:?}, credentials: {:?}", config, secret!(credentials));

if self.wallets.borrow_mut().values().any(|ref wallet| wallet.get_id() == WalletService::_get_wallet_id(config)) {
if self.wallet_ids.borrow_mut().contains(&WalletService::_get_wallet_id(config)) {
return Err(err_msg(IndyErrorKind::InvalidState, format!("Wallet has to be closed before deleting: {:?}", WalletService::_get_wallet_id(config))));
}

Expand Down Expand Up @@ -217,10 +219,12 @@ impl WalletService {
storage.set_storage_metadata(&metadata)?;
}

let wallet = Wallet::new(id, storage, Rc::new(keys));
let wallet = Wallet::new(id.clone(), storage, Rc::new(keys));

let mut wallets = self.wallets.borrow_mut();
wallets.insert(wallet_handle, Box::new(wallet));
let mut wallet_ids = self.wallet_ids.borrow_mut();
wallet_ids.insert(id.to_string());

trace!("open_wallet <<< res: {:?}", wallet_handle);
Ok(wallet_handle)
Expand All @@ -241,7 +245,10 @@ impl WalletService {
trace!("close_wallet >>> handle: {:?}", handle);

match self.wallets.borrow_mut().remove(&handle) {
Some(mut wallet) => wallet.close(),
Some(mut wallet) => {
self.wallet_ids.borrow_mut().remove(wallet.get_id());
wallet.close()
},
None => Err(err_msg(IndyErrorKind::InvalidWalletHandle, "Unknown wallet handle"))
}?;

Expand Down Expand Up @@ -536,7 +543,8 @@ impl WalletService {
}

fn _is_id_from_config_not_used(&self, config: &Config) -> IndyResult<()> {
if self.wallets.borrow_mut().values().any(|ref wallet| wallet.get_id() == WalletService::_get_wallet_id(config)) {
let id = WalletService::_get_wallet_id(config);
if self.wallet_ids.borrow_mut().contains(&id) {
return Err(err_msg(IndyErrorKind::WalletAlreadyOpened, format!("Wallet {} already opened", WalletService::_get_wallet_id(config))));
}

Expand Down
5 changes: 1 addition & 4 deletions libindy/mac.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
export CARGO_INCREMENTAL=1
export RUST_LOG=indy=trace
export RUST_TEST_THREADS=1
for version in `ls -t /usr/local/Cellar/openssl/`; do
export OPENSSL_DIR=/usr/local/Cellar/openssl/$version
break
done
export OPENSSL_DIR=/usr/local/opt/`ls /usr/local/opt/ | grep openssl | sort | tail -1`
cargo build
export LIBRARY_PATH=$(pwd)/target/debug
cd ../cli
Expand Down
11 changes: 10 additions & 1 deletion libindy/src/services/anoncreds/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ pub fn parse_cred_rev_id(cred_rev_id: &str) -> IndyResult<u32> {
pub fn get_non_revoc_interval(global_interval: &Option<NonRevocedInterval>, local_interval: &Option<NonRevocedInterval>) -> Option<NonRevocedInterval> {
trace!("get_non_revoc_interval >>> global_interval: {:?}, local_interval: {:?}", global_interval, local_interval);

let interval = local_interval.clone().or_else(|| global_interval.clone().or(None));
let interval = local_interval
.clone()
.or_else(|| global_interval.clone().or(None))
.filter(|x| x.to.is_some() || x.from.is_some());

trace!("get_non_revoc_interval <<< interval: {:?}", interval);

Expand Down Expand Up @@ -178,6 +181,12 @@ mod tests {
assert_eq!(None, res);
}

#[test]
fn get_non_revoc_interval_for_empty_interval() {
let res = get_non_revoc_interval(&Some(NonRevocedInterval { from: None, to: None }), &None);
assert_eq!(None, res);
}

mod to_unqualified {
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion vcx/ci/ubuntu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ARG uid=1000
RUN useradd -ms /bin/bash -u $uid vcx
USER vcx

ARG RUST_VER="1.39.0"
ARG RUST_VER="1.46.0"
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUST_VER
ENV PATH /home/vcx/.cargo/bin:$PATH

Expand Down
13 changes: 13 additions & 0 deletions vcx/dummy-cloud-agent/src/actors/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ impl Agent {
A2AMessageV2::UpdateConfigs(msg) => self.handle_update_configs_v2(msg),
A2AMessageV2::GetConfigs(msg) => self.handle_get_configs_v2(msg),
A2AMessageV2::RemoveConfigs(msg) => self.handle_remove_configs_v2(msg),
A2AMessageV2::UpdateComMethod(msg) => self.handle_update_com_method_v2(msg),
_ => err_act!(self, err_msg("Unsupported message"))
}
.and_then(move |msg, slf, _|
Expand Down Expand Up @@ -697,6 +698,18 @@ impl Agent {
ok_act!(self, messages)
}

fn handle_update_com_method_v2(&mut self, msg: UpdateComMethod) -> ResponseActFuture<Self, A2AMessageV2, Error> {
trace!("UpdateComMethodV2 (msg={:?})", msg);
match msg.com_method.e_type {
ComMethodType::Webhook => {
self.configs.insert(String::from("notificationWebhookUrl"), String::from(msg.com_method.value));
}
_ => warn!("Agent was trying to handle unsupported communication type {:?}", msg.com_method.e_type)
};
let message = A2AMessageV2::ComMethodUpdated(ComMethodUpdated { id: msg.com_method.id });
ok_act!(self, message)
}

fn handle_update_configs_v1(&mut self, msg: UpdateConfigs) -> ResponseActFuture<Self, Vec<A2AMessage>, Error> {
self.handle_update_configs(msg)
.map(|_, _, _| {
Expand Down
Loading

0 comments on commit 7f401d1

Please sign in to comment.