Skip to content

Commit

Permalink
Upgrade to new Stronghold interface (#787)
Browse files Browse the repository at this point in the history
* Rename stronghold module

* Postfix old stronghold with `_old`

* Migrate to new stronghold interface

* Impl did_create properly with client syncing

* Add context to `StrongholdError`s

* Add `Stronghold` wrapper test

* Add `test_key_delete`

* Add storage_test_suite setup & did_create test

* Re-export test suite feature

* Expose test suite in Wasm

* Extend `did_create` test, fix index persistence

* Test `key_generate`

* Move `key_delete` to test suite

* Remove test suite from this branch

* Add initial test suite and expose to Wasm

* rm `Error` postfix from `StrongholdError` variants

* Remove duplicate `mod tests` in Wasm

* Handle client sync error; document syncing

* Use updated stronghold

* Use dedicated `load_snapshot` function

* Purge client in `did_purge`

* Revert cfg_attr shenanigans

* Make `Stronghold::client` not async

* Remove asyncness from fns where not necessary

* Make `mutate_client` not async either

* Move test_util mod where it belongs

* Remove `source` errors from `Display` impl

* Remove `RecordHint` everywhere

* Use base crate `MemoryError`; remove engine dep

* Revert temporary send/sync change

* Document `Stronghold` wrapper

* Use same export style as other crates

* Create parent directories if they don't exist

* Remove outdated TODO

* Fix index writing in purge; update stronghold rev

* Remove old stronghold wrapper

* Reactivate multi identity example

* Add `dropsave` getter/setter

* Fully qualify `std::any::type_name`

* Remove tests which are already in test suite

* Reactivate `Send`-assertion test

* Return `Stronghold` instance from test `storages`

* Test incorrect password returns error

* Use `OsRng` instead of `thread_rng`

* Bump stronghold revision

* Remove unused `getrandom` depenency

* Remove unused `actix` dependency

* Remove tokio `rt-multi-thread` feature

* Prefer `sample_string` over `sample_iter`

* Enable `didPurge` test for NAPI stronghold

* Simplify `did_create` by using `mutate_client`

* Rename doc/state client paths to store keys

* Add procedure_error fn to reduce err map code

* Remove unnecessary clone

* Disable multiple identities example temporarily

* Disable musl build

* Remove musl target from stronghold-nodejs

* use local workflow file

* Revert "use local workflow file"

This reverts commit 2f12afd.

Co-authored-by: Eike Haß <eike-hass@web.de>
  • Loading branch information
PhilippGackstatter and eike-hass committed May 13, 2022
1 parent a349888 commit 8d3bd59
Show file tree
Hide file tree
Showing 24 changed files with 703 additions and 1,575 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/shared-build-and-test-stronghold-nodejs.yml
Expand Up @@ -63,17 +63,18 @@ jobs:
npm run build && strip dist/*.node
test: |
npm run test
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
architecture: x64
setup: |
sudo apt-get install -y musl-tools
build: |
export NPM_BUILD_NAPI_ARGS=--target=x86_64-unknown-linux-musl
npm run build && strip dist/*.node
test-docker: |
docker build -f .github/Dockerfile.alpine -t tester .github
docker run --rm -v $(pwd):/build -w /build/bindings/stronghold-nodejs tester sh -c "ldd dist/identity-stronghold-nodejs.linux-x64-musl.node || true && npm run test:examples"
# TODO: Disabled until we have a fix for building Rust code for musl that includes rand::thread_rng.
# - host: ubuntu-latest
# target: x86_64-unknown-linux-musl
# architecture: x64
# setup: |
# sudo apt-get install -y musl-tools
# build: |
# export NPM_BUILD_NAPI_ARGS=--target=x86_64-unknown-linux-musl
# npm run build && strip dist/*.node
# test-docker: |
# docker build -f .github/Dockerfile.alpine -t tester .github
# docker run --rm -v $(pwd):/build -w /build/bindings/stronghold-nodejs tester sh -c "ldd dist/identity-stronghold-nodejs.linux-x64-musl.node || true && npm run test:examples"
- host: macos-latest
target: aarch64-apple-darwin
build: |
Expand Down
Expand Up @@ -4,6 +4,7 @@ import { stronghold } from '../stronghold';
// Only verifies that no uncaught exceptions are thrown, including syntax errors etc.
describe("Test Stronghold Node.js examples", function () {
it("Multiple Identities", async () => {
await multipleIdentities(await stronghold());
// TODO: Temporarily disabled until iotaledger/stronghold.rs#353 is fixed.
// await multipleIdentities(await stronghold());
});
})
Expand Up @@ -24,9 +24,7 @@ describe("Test Stronghold Node.js", function () {
it("keySignEd25519", async () => {
await StorageTestSuite.keySignEd25519Test(await stronghold());
});
// TODO: Deliberately exclude didPurge test because key deletion
// is not implemented properly in stronghold. Should be activated with #757.
// it("didPurge", async () => {
// await StorageTestSuite.didPurgeTest(await stronghold());
// });
it("didPurge", async () => {
await StorageTestSuite.didPurgeTest(await stronghold());
});
});
3 changes: 1 addition & 2 deletions bindings/stronghold-nodejs/package.json
Expand Up @@ -14,8 +14,7 @@
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl"
"x86_64-unknown-linux-gnu"
]
}
},
Expand Down
7 changes: 4 additions & 3 deletions examples/Cargo.toml
Expand Up @@ -34,9 +34,10 @@ path = "account/lazy.rs"
name = "account_signing"
path = "account/signing.rs"

[[example]]
name = "account_multiple"
path = "account/multiple_identities.rs"
# TODO: Temporarily disabled until iotaledger/stronghold.rs#353 is fixed.
# [[example]]
# name = "account_multiple"
# path = "account/multiple_identities.rs"

[[example]]
name = "account_unchecked"
Expand Down
16 changes: 4 additions & 12 deletions identity-account-storage/Cargo.toml
Expand Up @@ -11,7 +11,6 @@ repository = "https://github.com/iotaledger/identity.rs"
description = "Secure storage for Decentralized Identifiers and Verifiable Credentials."

[dependencies]
actix = { version = "0.12.0", optional = true }
anyhow = { version = "1.0", default-features = false, features = ["std"], optional = true }
async-trait = { version = "0.1", default-features = false }
function_name = { version = "0.2", default-features = false, optional = true }
Expand All @@ -27,22 +26,17 @@ seahash = { version = "4.1.0", default-features = false }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
strum = { version = "0.24.0", default-features = false, features = ["std", "derive"] }
thiserror = { version = "1.0" }
tokio = { version = "1.17.0", default-features = false, features = ["sync"], optional = true }
tokio = { version = "1.17.0", default-features = false, features = ["sync", "fs"], optional = true }
zeroize = { version = "1.4" }

[dependencies.iota-crypto]
version = ">=0.7, <0.10"
default-features = false
features = ["blake2b", "hmac", "pbkdf", "sha", "std"]
features = ["hmac", "pbkdf", "sha", "std"]

[dependencies.iota_stronghold]
git = "https://github.com/iotaledger/stronghold.rs"
rev = "969df405661ba4977f2cf30e9909cef7e30cefa2"
optional = true

[dependencies.stronghold_engine]
git = "https://github.com/iotaledger/stronghold.rs"
rev = "969df405661ba4977f2cf30e9909cef7e30cefa2"
rev = "629466da83a677925904b2e733ef7bfad5a42864"
optional = true

[dev-dependencies]
Expand All @@ -53,9 +47,7 @@ tokio = { version = "1.17.0", default-features = false, features = ["macros", "r
default = ["stronghold", "send-sync-storage", "storage-test-suite"]
stronghold = [
"iota_stronghold",
"stronghold_engine",
"actix",
"tokio/rt-multi-thread",
"tokio",
"futures",
"once_cell",
"rand",
Expand Down
4 changes: 2 additions & 2 deletions identity-account-storage/src/storage/mod.rs
Expand Up @@ -9,8 +9,8 @@ mod test_suite;
mod traits;

pub use self::memstore::*;
#[cfg(feature = "stronghold")]
pub use self::stronghold::*;
pub use self::traits::*;
#[cfg(feature = "stronghold")]
pub use crate::stronghold::Stronghold;
#[cfg(feature = "storage-test-suite")]
pub use test_suite::StorageTestSuite;

0 comments on commit 8d3bd59

Please sign in to comment.