Skip to content

Commit

Permalink
Registration workflow make it work (#63)
Browse files Browse the repository at this point in the history
Registration workflow make it work
  • Loading branch information
cypherkitty authored Oct 21, 2024
1 parent b33a428 commit 03a7841
Show file tree
Hide file tree
Showing 87 changed files with 2,990 additions and 2,202 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM debian:bookworm

RUN apt update && apt install -y curl wget git build-essential pkg-config libssl-dev
RUN apt update && apt install -y \
build-essential pkg-config libssl-dev \
curl wget git bash-completion

#################### Installation ####################
#Earthly
Expand Down
7 changes: 2 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"name": "MetaSecret",

"build": {
"dockerfile": "Dockerfile",
"context": ".."
},

"workspaceFolder": "/meta-secret",
"workspaceMount": "source=${localWorkspaceFolder},target=/meta-secret,type=bind,consistency=cached",

"workspaceMount": "source=${localWorkspaceFolder},target=/meta-secret,type=bind",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
}
},
}
32 changes: 16 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@ exclude = [

[workspace.dependencies]
# Error handling
thiserror = "1.0.49"
anyhow = "1.0.75"
thiserror = "1.0.63"
anyhow = "1.0.89"

# Logging and tracing
tracing = "0.1"
tracing-subscriber = { version = "0.3" }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18" }

# Json
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
serde_derive = "1.0.188"
serde_json = "1.0.128"
serde_derive = "1.0.210"

# Async utils
async-std = { version = "1.12.0" }
async-trait = "0.1"
flume = "0.11"
async-mutex = "1.4"
async-std = { version = "1.13.0" }
async-trait = "0.1.82"
flume = "0.11.0"
async-mutex = "1.4.0"

# Cryptography
ed25519-dalek = "1.0.1"
crypto_box = { version = "0.8.2", features = ["std"] }
rand = "0.8.5"
getrandom = { version = "0.2.8", features = ["js"] }
sha2 = { version = "0.10.6", features = ["oid"] }
getrandom = { version = "0.2.15", features = ["js"] }
sha2 = { version = "0.10.8", features = ["oid"] }
base64 = "0.20.0"
hex = "0.4"
hex = "0.4.3"
#https://github.com/dsprenkels/sss-rs
shamirsecretsharing = "0.1"
shamirsecretsharing = "0.1.5"

# Sql
diesel = { version = "2.0.0" }
diesel_migrations = { version = "2.0.0" }
diesel = { version = "2.2.4" }
diesel_migrations = { version = "2.2.0" }
1 change: 1 addition & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct MetaSecretConfig {

///https://kerkour.com/rust-cross-compilation
fn main() -> Result<()> {

let args: CmdLine = CmdLine::parse();

let config_file = File::open("config.yaml")
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ rqrr = "0.5"
image = "0.24"

wasm-bindgen = "0.2.93"
log = "0.4.22"

[dependencies.uuid]
version = "1.3.0"
Expand Down
4 changes: 2 additions & 2 deletions core/src/crypto/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ pub mod base64 {
extern crate base64;

use std::fmt::Display;

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Base64Text(pub String);

impl Display for Base64Text {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0.clone())
Expand Down
1 change: 0 additions & 1 deletion core/src/crypto/keys.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use wasm_bindgen::prelude::wasm_bindgen;
use crate::crypto::encoding::base64::Base64Text;
use crate::crypto::key_pair::{DsaKeyPair, KeyPair, TransportDsaKeyPair};

Expand Down
6 changes: 6 additions & 0 deletions core/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,9 @@ pub enum SharesLoaderError {
#[error(transparent)]
DeserializationError(#[from] serde_json::error::Error),
}

#[derive(Debug, thiserror::Error)]
pub enum CredentialsError {
#[error("Credentials not found")]
NotFoundError(String),
}
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod meta_tests;
pub mod node;
pub mod secret;

pub type CoreResult<T> = std::result::Result<T, CoreError>;
pub type CoreResult<T> = Result<T, CoreError>;

#[derive(Debug, thiserror::Error)]
pub enum RecoveryOperationError {
Expand Down
27 changes: 0 additions & 27 deletions core/src/meta_tests/action/generate_user.rs

This file was deleted.

55 changes: 0 additions & 55 deletions core/src/meta_tests/action/global_index_action.rs

This file was deleted.

3 changes: 0 additions & 3 deletions core/src/meta_tests/action/mod.rs

This file was deleted.

38 changes: 0 additions & 38 deletions core/src/meta_tests/action/sign_up_claim_action.rs

This file was deleted.

22 changes: 0 additions & 22 deletions core/src/meta_tests/fixture/mod.rs

This file was deleted.

89 changes: 89 additions & 0 deletions core/src/meta_tests/fixture_util.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#[cfg(test)]
pub mod fixture {
use crate::meta_tests::fixture_util::fixture::states::{BaseState, EmptyState, ExtendedState};
use crate::node::app::meta_app::meta_client_service::fixture::MetaClientServiceFixture;
use crate::node::common::model::device::device_creds::fixture::DeviceCredentialsFixture;
use crate::node::common::model::user::user_creds::fixture::UserCredentialsFixture;
use crate::node::db::objects::global_index::fixture::ServerPersistentGlobalIndexFixture;
use crate::node::db::objects::persistent_object::fixture::PersistentObjectFixture;
use crate::node::db::repo::persistent_credentials::fixture::PersistentCredentialsFixture;
use crate::node::server::server_app::fixture::{ServerAppFixture, ServerDataTransferFixture};

pub struct FixtureRegistry<S> {
pub state: S,
}

impl FixtureRegistry<BaseState> {
pub fn empty() -> FixtureRegistry<EmptyState> {
let p_obj = PersistentObjectFixture::generate();
let device_creds = DeviceCredentialsFixture::generate();
let user_creds = UserCredentialsFixture::from(&device_creds);

FixtureRegistry { state: EmptyState { p_obj, device_creds, user_creds } }
}

pub async fn base() -> anyhow::Result<FixtureRegistry<BaseState>> {
let empty = FixtureRegistry::empty();
let p_creds = PersistentCredentialsFixture::init(&empty.state).await?;
let server_p_gi = ServerPersistentGlobalIndexFixture::from(&empty);

let base = BaseState {
empty: empty.state,
p_creds,
server_p_gi,
server_dt: ServerDataTransferFixture::generate()
};

Ok(FixtureRegistry { state: base })
}

//SyncGatewayFixture
pub async fn extended() -> anyhow::Result<FixtureRegistry<ExtendedState>> {
let base = FixtureRegistry::base().await?;

let server_app = ServerAppFixture::try_from(&base)?;
let meta_client_service = MetaClientServiceFixture::from(&base);

let state = ExtendedState { base: base.state, server_app, meta_client_service };
Ok(FixtureRegistry { state })
}
}

pub mod states {
use crate::node::app::meta_app::meta_client_service::fixture::MetaClientServiceFixture;
use crate::node::common::model::device::device_creds::fixture::DeviceCredentialsFixture;
use crate::node::common::model::user::user_creds::fixture::UserCredentialsFixture;
use crate::node::db::objects::global_index::fixture::ServerPersistentGlobalIndexFixture;
use crate::node::db::objects::persistent_object::fixture::PersistentObjectFixture;
use crate::node::db::repo::persistent_credentials::fixture::PersistentCredentialsFixture;
use crate::node::server::server_app::fixture::{ServerAppFixture, ServerDataTransferFixture};

pub enum Fixture {
Empty(EmptyState),
Base(BaseState),
Extended(ExtendedState),
}

pub struct EmptyState {
pub device_creds: DeviceCredentialsFixture,
pub user_creds: UserCredentialsFixture,

pub p_obj: PersistentObjectFixture,
}

pub struct BaseState {
pub empty: EmptyState,

pub p_creds: PersistentCredentialsFixture,
pub server_p_gi: ServerPersistentGlobalIndexFixture,

pub server_dt: ServerDataTransferFixture,
}

pub struct ExtendedState {
pub base: BaseState,
pub server_app: ServerAppFixture,
pub meta_client_service: MetaClientServiceFixture,
}
}
}
15 changes: 13 additions & 2 deletions core/src/meta_tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
pub mod action;
pub mod fixture;
use tracing::Level;

pub mod spec;
pub mod fixture_util;

pub fn setup_tracing() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_max_level(Level::DEBUG)
.without_time()
.compact()
.pretty()
.init();
Ok(())
}
Loading

0 comments on commit 03a7841

Please sign in to comment.