Skip to content

Commit

Permalink
Update to latest ssi (#316)
Browse files Browse the repository at this point in the history
* Remove features for did-tz
* Clean up features
* Fix WASM
  • Loading branch information
sbihel authored Oct 25, 2022
1 parent 9e3393c commit 62c55ef
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 62 deletions.
9 changes: 0 additions & 9 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,13 @@ exclude = [
"/tests"
]

[features]
default = ["ring"]
ring = ["ssi/ring"]

[dependencies]
chrono = { version = "0.4", features = ["serde"] }
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
didkit = { version = "0.4", path = "../lib", features = ["http-did"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
clap = { version = "3.0", features = ["derive", "env"] }
did-method-key = { version = "0.1", path = "../../ssi/did-key" }
ssi = { version = "0.4", path = "../../ssi", default-features = false }
thiserror = "1.0"
bytes = "1.0"
base64 = "0.12"
sshkeys = "0.3"
anyhow = "1.0"

Expand Down
23 changes: 12 additions & 11 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ use serde::Serialize;
use serde_json::Value;
use sshkeys::PublicKey;

use did_method_key::DIDKey;
use didkit::generate_proof;
use didkit::{
dereference, get_verification_method, runtime, DIDCreate, DIDDeactivate, DIDDocumentOperation,
DIDMethod, DIDRecover, DIDResolver, DIDUpdate, DereferencingInputMetadata, Error,
LinkedDataProofOptions, Metadata, ProofFormat, ResolutionInputMetadata, ResolutionResult,
Source, VerifiableCredential, VerifiablePresentation, VerificationRelationship, DIDURL,
DID_METHODS, JWK, URI,
dereference, generate_proof, get_verification_method, runtime,
ssi::{
self,
did::{DIDMethodTransaction, Service, ServiceEndpoint},
one_or_many::OneOrMany,
},
DIDCreate, DIDDeactivate, DIDDocumentOperation, DIDMethod, DIDRecover, DIDResolver, DIDUpdate,
DereferencingInputMetadata, Error, LinkedDataProofOptions, Metadata, ProofFormat,
ResolutionInputMetadata, ResolutionResult, Source, VerifiableCredential,
VerifiablePresentation, VerificationRelationship, DIDURL, DID_METHODS, JWK, URI,
};
use didkit_cli::opts::ResolverOptions;
use ssi::did::{DIDMethodTransaction, Service, ServiceEndpoint};
use ssi::one_or_many::OneOrMany;

#[derive(StructOpt, Debug)]
pub enum DIDKit {
Expand Down Expand Up @@ -747,8 +748,8 @@ fn main() -> AResult<()> {
// Deprecated in favor of KeyToDID
eprintln!("didkit: use key-to-did instead of key-to-did-key");
let jwk = key.get_jwk();
let did = DIDKey
.generate(&Source::Key(&jwk))
let did = DID_METHODS
.generate(&Source::KeyAndPattern(&jwk, "key"))
.ok_or(Error::UnableToGenerateDID)
.unwrap();
println!("{}", did);
Expand Down
2 changes: 2 additions & 0 deletions cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use serde_json::Value;
use std::io::Write;
use std::process::{Command, Stdio};

use didkit::ssi;

static BIN: &str = env!("CARGO_BIN_EXE_didkit");

const DID_KEY_K256: &'static str = "did:key:zQ3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme";
Expand Down
1 change: 0 additions & 1 deletion http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude = [
]

[features]
default = ["ring"]
ring = ["ssi/ring"]

[dependencies]
Expand Down
16 changes: 8 additions & 8 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ include = [
]

[features]
default = ["w3c", "eip"]
default = ["w3c", "ed25519", "rsa", "ripemd-160", "eip", "tezos"]

w3c = ["ssi/w3c", "secp256k1", "secp256r1", "ed25519", "rsa"]
secp256k1 = ["ssi/secp256k1", "did-tz/secp256k1", "did-method-key/secp256k1", "did-ion/secp256k1"]
secp256r1 = ["ssi/secp256r1", "did-tz/secp256r1", "did-webkey/secp256r1", "did-method-key/secp256r1", "did-ion/secp256r1"]
ed25519 = ["ssi/ed25519", "did-tz/ed25519", "did-ion/ed25519"]
rsa = ["ssi/rsa", "did-ion/rsa"]
w3c = ["ssi/w3c"]
secp256k1 = ["ssi/secp256k1"]
secp256r1 = ["ssi/secp256r1"]
ed25519 = ["ssi/ed25519"]
rsa = ["ssi/rsa"]
ripemd-160 = ["ssi/ripemd-160"]

aleo = ["ssi/aleo"]
eip = ["ssi/eip"]
Expand All @@ -34,14 +35,13 @@ solana = ["ssi/solana"]

http-did = ["ssi/http-did"]

wasm = []
ring = ["ssi/ring"]
openssl = ["ssi/openssl"]

[dependencies]
ssi = { version = "0.4", path = "../../ssi", default-features = false }
did-method-key = { version = "^0.1.2", path = "../../ssi/did-key", default-features = false }
did-tz = { version = "^0.1.1", path = "../../ssi/did-tezos", default-features = false }
did-tz = { version = "^0.1.1", path = "../../ssi/did-tezos" }
did-ethr = { version = "0.1", path = "../../ssi/did-ethr", default-features = false }
did-pkh = { version = "0.1", path = "../../ssi/did-pkh", default-features = false }
#did-sol = { version = "0.0.1", path = "../../ssi/did-sol" }
Expand Down
24 changes: 13 additions & 11 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
#[cfg(not(feature = "wasm"))]
#[cfg(not(target_arch = "wasm32"))]
pub mod c;
mod did_methods;
pub mod error;
#[cfg(not(feature = "wasm"))]
#[cfg(not(target_arch = "wasm32"))]
pub mod jni;
#[cfg(not(feature = "wasm"))]
#[cfg(not(target_arch = "wasm32"))]
pub mod runtime;
#[cfg(not(any(feature = "wasm", target_os = "windows")))]
#[cfg(not(any(target_arch = "wasm32", target_os = "windows")))]
pub mod ssh_agent;

#[macro_use]
extern crate lazy_static;

pub use crate::did_methods::DID_METHODS;
pub use crate::error::Error;

pub use ssi;
pub use ssi::did::VerificationRelationship;
pub use ssi::did::{
DIDCreate, DIDDeactivate, DIDDocumentOperation, DIDMethod, DIDRecover, DIDUpdate, Document,
Source, DIDURL,
};
pub use ssi::did_resolve::resolve_key;
#[cfg(feature = "http-did")]
pub use ssi::did_resolve::HTTPDIDResolver;
pub use ssi::did_resolve::{
Expand All @@ -27,15 +31,13 @@ pub use ssi::did_resolve::{
};
pub use ssi::jsonld::ContextLoader;
pub use ssi::jwk::JWK;
pub use ssi::did_resolve::resolve_key;
pub use ssi::ldp::ProofPreparation;
pub use ssi::tzkey::jwk_from_tezos_key;
pub use ssi::vc::get_verification_method;
pub use ssi::vc::Credential as VerifiableCredential;
pub use ssi::vc::CredentialOrJWT;
pub use ssi::vc::LinkedDataProofOptions;
pub use ssi::vc::Presentation as VerifiablePresentation;
pub use ssi::did::VerificationRelationship;
pub use ssi::vc::VerificationResult;
pub use ssi::vc::URI;
pub use ssi::zcap::{Delegation, Invocation};
Expand Down Expand Up @@ -109,7 +111,7 @@ impl FromStr for ProofFormat {

#[derive(thiserror::Error, Debug)]
pub enum GenerateProofError {
#[cfg(not(any(feature = "wasm", target_os = "windows")))]
#[cfg(not(any(target_arch = "wasm32", target_os = "windows")))]
#[error("Unable to sign: {0}")]
Sign(#[from] crate::ssh_agent::SignError),
#[error("SSI Linked Data Proof: {0}")]
Expand All @@ -132,15 +134,15 @@ pub async fn generate_proof(
) -> Result<ssi::ldp::Proof, GenerateProofError> {
use ssi::ldp::LinkedDataProofs;
let proof = match ssh_agent_sock_path_opt {
#[cfg(feature = "wasm")]
Some(sock_path) => {
#[cfg(target_arch = "wasm32")]
Some(_) => {
return Err(GenerateProofError::NoWASM);
}
#[cfg(target_os = "windows")]
Some(sock_path) => {
Some(_) => {
return Err(GenerateProofError::NoWindows);
}
#[cfg(not(any(feature = "wasm", target_os = "windows")))]
#[cfg(not(any(target_arch = "wasm32", target_os = "windows")))]
Some(sock_path) => {
use tokio::net::UnixStream;
let mut ssh_agent_sock = UnixStream::connect(sock_path).await?;
Expand Down
22 changes: 0 additions & 22 deletions lib/web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,6 @@ chrono = { version = "0.4", features = ["wasmbind"] }

[dependencies.didkit]
path = "../"
default-features = false
features = ["wasm", "w3c", "tezos", "eip"]

# TODO remove dependency on ssi
[dependencies.ssi]
path = "../../../ssi"
default-features = false
features = ["w3c", "tezos", "eip"]

[dependencies.did-method-key]
path = "../../../ssi/did-key"
default-features = false
features = ["secp256k1", "secp256r1"]

[dependencies.did-tz]
path = "../../../ssi/did-tezos"
default-features = false
features = ["secp256k1", "ed25519", "secp256r1"]

[dependencies.did-webkey]
path = "../../../ssi/did-webkey"
default-features = false

[dev-dependencies]
wasm-bindgen-test = "0.2"
Expand Down
1 change: 1 addition & 0 deletions lib/web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use didkit::error::Error;
#[cfg(doc)]
use didkit::error::{didkit_error_code, didkit_error_message};
use didkit::get_verification_method;
use didkit::ssi;
use didkit::LinkedDataProofOptions;
use didkit::ProofPreparation;
use didkit::Source;
Expand Down

0 comments on commit 62c55ef

Please sign in to comment.