Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace package for publish #178

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
[package]
name = "trustchain"
version = "0.2.0"
authors = ["Trustchain Devs"]
license = "MIT OR Apache-2.0"
description = "Trustchain decentralised PKI reference implementation."
homepage = "https://alan-turing-institute.github.io/trustchain/"
repository = "https://github.com/alan-turing-institute/trustchain/"
keywords = ["pki", "did", "vc", "vp"]
edition = "2021"

[workspace]
members = [
"trustchain-core",
Expand All @@ -8,3 +19,10 @@ members = [
"trustchain-ffi"
]
resolver = "2"

[dependencies]
trustchain-api = { path = "./trustchain-api", version = "0.1.0"}
trustchain-core = { path = "./trustchain-core", version = "0.2.0"}
trustchain-ffi = { path = "./trustchain-ffi", version = "0.1.0"}
trustchain-http = { path = "./trustchain-http", version = "0.1.0"}
trustchain-ion = { path = "./trustchain-ion", version = "0.2.0"}
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Trustchain reference implementation.

pub use trustchain_api as api;
pub use trustchain_core as core;
pub use trustchain_ffi as ffi;
pub use trustchain_http as http;
pub use trustchain_ion as ion;
5 changes: 3 additions & 2 deletions trustchain-api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use trustchain_ion::{
attest::attest_operation, attestor::IONAttestor, create::create_operation, trustchain_resolver,
};

/// API for Trustchain CLI DID functionality.
/// API for Trustchain DID functionality.
#[async_trait]
pub trait TrustchainDIDAPI {
/// Creates a controlled DID from a passed document state, writing the associated create
Expand Down Expand Up @@ -79,7 +79,7 @@ pub trait TrustchainDIDAPI {
// }
}

/// API for Trustchain CLI VC functionality.
/// API for Trustchain VC functionality.
#[async_trait]
pub trait TrustchainVCAPI {
/// Signs a credential.
Expand Down Expand Up @@ -135,6 +135,7 @@ pub trait TrustchainVCAPI {
}
}

/// API for Trustchain VP functionality.
#[async_trait]
pub trait TrustchainVPAPI {
/// Signs a presentation constructing a verifiable presentation.
Expand Down
1 change: 1 addition & 0 deletions trustchain-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! API for DID, VC and VP functionality.
pub mod api;
use crate::api::{TrustchainDIDAPI, TrustchainVCAPI, TrustchainVPAPI};

Expand Down
3 changes: 1 addition & 2 deletions trustchain-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[package]
name = "trustchain-core"
version = "0.1.0"
version = "0.2.0"
authors = ["Trustchain Devs"]
edition = "2021"


[dependencies]
ps_sig = { git = "https://github.com/alan-turing-institute/RSS.git", rev = "ec9386e125d87c5f54898b34fbe0883b3b36ffd4" }

Expand Down
2 changes: 1 addition & 1 deletion trustchain-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Trustchain library.
//! Core traits and logic (data layer independent).
pub mod attestor;
pub mod chain;
pub mod commitment;
Expand Down
2 changes: 1 addition & 1 deletion trustchain-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Trustchain Devs"]
edition = "2021"

[lib]
crate-type = ["cdylib", "staticlib"]
crate-type = ["cdylib", "staticlib", "lib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
1 change: 1 addition & 0 deletions trustchain-ffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! FFI bindings for flutter/dart.
pub mod config;
// pub mod gui;
pub mod mobile;
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Trustchain HTTP configuration types and utilities.
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use std::fs;
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/data.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions trustchain-http/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Error type and conversions.
use axum::{response::IntoResponse, Json};
use hyper::StatusCode;
use serde_json::json;
Expand All @@ -8,6 +9,7 @@ use trustchain_core::{
};
use trustchain_ion::root::TrustchainRootError;

/// Trustchain HTTP error type.
// TODO: refine and add doc comments for error variants
#[derive(Error, Debug)]
pub enum TrustchainHTTPError {
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/ion.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Handlers for communicating with an ION node.
use crate::{errors::TrustchainHTTPError, state::AppState};
use axum::{
response::{IntoResponse, Response},
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/issuer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Handlers and trait for issuing VCs and providing credential offers.
use crate::config::http_config;
use crate::errors::TrustchainHTTPError;
use crate::qrcode::{str_to_qr_code_html, DIDQRCode};
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Trustchain HTTP server functionality.
pub mod config;
#[cfg(test)]
pub(crate) mod data;
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/qrcode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! QR code functionality for encoding credential offers and presentation requests.
use base64::engine::general_purpose;
use base64::write::EncoderWriter;
use image::Luma;
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/resolver.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Handlers and trait for resolving Trustchain DIDs, chains and bundles.
use crate::errors::TrustchainHTTPError;
use crate::state::AppState;
use async_trait::async_trait;
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/root.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Handler and trait for identifying root DID candidates from a naive date.
use crate::state::AppState;
use async_trait::async_trait;
use axum::extract::{Path, Query, State};
Expand Down
5 changes: 4 additions & 1 deletion trustchain-http/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Trustchain HTTP router type and functionality for spawning HTTP and HTTPS servers.
use crate::config::http_config;
use crate::middleware::validate_did;
use crate::{
Expand All @@ -11,7 +12,9 @@ use std::path::PathBuf;
use std::sync::Arc;
use tower::ServiceBuilder;

/// A wrapped axum router.
/// A wrapped axum router combining Trustchain HTTP handlers for resolution (DIDs, chains, bundles),
/// verification (VCs and VPs), issuance (VCs), root candidate retrieval and communication with an
/// ION node.
pub struct TrustchainRouter {
router: Router,
}
Expand Down
4 changes: 3 additions & 1 deletion trustchain-http/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Trustchain HTTP router shared state.
use crate::root::RootCandidatesResult;
use crate::store::CredentialStoreItem;
use crate::{config::HTTPConfig, verifier::PresentationRequest};
Expand All @@ -13,7 +14,8 @@ use trustchain_ion::verifier::TrustchainVerifier;

const DEFAULT_VERIFIER_ENDPOINT: &str = "http://localhost:3000/";

/// A shared app state for handlers.
/// A shared app state for the router providing configuration, verifier, credential offer store,
/// presentation request store and root candidates cache for handlers.
pub struct AppState<T = HTTPSidetreeDIDResolver<ION>>
where
T: DIDResolver + Send + Sync,
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/static_handlers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Static handlers for front-end.
use axum::response::Html;

pub async fn index() -> Html<String> {
Expand Down
2 changes: 2 additions & 0 deletions trustchain-http/src/store.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Types for store items.
use serde::{Deserialize, Serialize};
use ssi::vc::Credential;

/// Credential store item.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CredentialStoreItem {
#[serde(rename = "did")]
Expand Down
1 change: 1 addition & 0 deletions trustchain-http/src/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Handlers and trait for verifying VCs and VPs and providing presentation requests.
use crate::config::http_config;
use crate::errors::TrustchainHTTPError;
use crate::qrcode::{str_to_qr_code_html, DIDQRCode};
Expand Down
2 changes: 1 addition & 1 deletion trustchain-ion/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trustchain-ion"
version = "0.1.0"
version = "0.2.0"
authors = ["Trustchain Devs"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion trustchain-ion/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Trustchain library for ION DID method.
//! Trustchain implementation for [ION](https://identity.foundation/ion/) DID method.
pub mod attest;
pub mod attestor;
pub mod commitment;
Expand Down
Loading