diff --git a/Cargo.lock b/Cargo.lock index 4cd52f0..d8fbc00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,6 +119,13 @@ dependencies = [ "zeroize", ] +[[package]] +name = "client" +version = "0.1.0" +dependencies = [ + "libchat", +] + [[package]] name = "const-oid" version = "0.9.6" diff --git a/Cargo.toml b/Cargo.toml index 274eb12..ca37bad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,15 +3,17 @@ resolver = "3" members = [ - "conversations", - "crypto", - "double-ratchets", - "storage", + "core/conversations", + "core/crypto", + "core/double-ratchets", + "core/storage", + "crates/client", ] [workspace.dependencies] blake2 = "0.10" -storage = { path = "storage" } +libchat = { path = "core/conversations" } +storage = { path = "core/storage" } # Panicking across FFI boundaries is UB; abort is the correct strategy for a # C FFI library. diff --git a/core/README.md b/core/README.md new file mode 100644 index 0000000..0115b00 --- /dev/null +++ b/core/README.md @@ -0,0 +1,7 @@ +# Core + +Crates in this directory will one day be separated into a separate shared repository. + +They could be moved now, but it's desirable to have a monorepo setup at this time. + +These crates MUST not depend on any code outside of this folder. \ No newline at end of file diff --git a/conversations/Cargo.toml b/core/conversations/Cargo.toml similarity index 100% rename from conversations/Cargo.toml rename to core/conversations/Cargo.toml diff --git a/conversations/src/api.rs b/core/conversations/src/api.rs similarity index 100% rename from conversations/src/api.rs rename to core/conversations/src/api.rs diff --git a/conversations/src/context.rs b/core/conversations/src/context.rs similarity index 100% rename from conversations/src/context.rs rename to core/conversations/src/context.rs diff --git a/conversations/src/conversation.rs b/core/conversations/src/conversation.rs similarity index 100% rename from conversations/src/conversation.rs rename to core/conversations/src/conversation.rs diff --git a/conversations/src/conversation/group_test.rs b/core/conversations/src/conversation/group_test.rs similarity index 100% rename from conversations/src/conversation/group_test.rs rename to core/conversations/src/conversation/group_test.rs diff --git a/conversations/src/conversation/privatev1.rs b/core/conversations/src/conversation/privatev1.rs similarity index 100% rename from conversations/src/conversation/privatev1.rs rename to core/conversations/src/conversation/privatev1.rs diff --git a/conversations/src/crypto.rs b/core/conversations/src/crypto.rs similarity index 100% rename from conversations/src/crypto.rs rename to core/conversations/src/crypto.rs diff --git a/conversations/src/errors.rs b/core/conversations/src/errors.rs similarity index 100% rename from conversations/src/errors.rs rename to core/conversations/src/errors.rs diff --git a/conversations/src/ffi/mod.rs b/core/conversations/src/ffi/mod.rs similarity index 100% rename from conversations/src/ffi/mod.rs rename to core/conversations/src/ffi/mod.rs diff --git a/conversations/src/ffi/utils.rs b/core/conversations/src/ffi/utils.rs similarity index 100% rename from conversations/src/ffi/utils.rs rename to core/conversations/src/ffi/utils.rs diff --git a/conversations/src/identity.rs b/core/conversations/src/identity.rs similarity index 100% rename from conversations/src/identity.rs rename to core/conversations/src/identity.rs diff --git a/conversations/src/inbox.rs b/core/conversations/src/inbox.rs similarity index 100% rename from conversations/src/inbox.rs rename to core/conversations/src/inbox.rs diff --git a/conversations/src/inbox/handler.rs b/core/conversations/src/inbox/handler.rs similarity index 100% rename from conversations/src/inbox/handler.rs rename to core/conversations/src/inbox/handler.rs diff --git a/conversations/src/inbox/handshake.rs b/core/conversations/src/inbox/handshake.rs similarity index 100% rename from conversations/src/inbox/handshake.rs rename to core/conversations/src/inbox/handshake.rs diff --git a/conversations/src/inbox/introduction.rs b/core/conversations/src/inbox/introduction.rs similarity index 100% rename from conversations/src/inbox/introduction.rs rename to core/conversations/src/inbox/introduction.rs diff --git a/conversations/src/lib.rs b/core/conversations/src/lib.rs similarity index 96% rename from conversations/src/lib.rs rename to core/conversations/src/lib.rs index 5490629..d81eb91 100644 --- a/conversations/src/lib.rs +++ b/core/conversations/src/lib.rs @@ -12,6 +12,8 @@ mod types; mod utils; pub use api::*; +pub use context::{Context, Introduction}; +pub use errors::ChatError; #[cfg(test)] mod tests { diff --git a/conversations/src/proto.rs b/core/conversations/src/proto.rs similarity index 100% rename from conversations/src/proto.rs rename to core/conversations/src/proto.rs diff --git a/conversations/src/storage/db.rs b/core/conversations/src/storage/db.rs similarity index 100% rename from conversations/src/storage/db.rs rename to core/conversations/src/storage/db.rs diff --git a/conversations/src/storage/migrations.rs b/core/conversations/src/storage/migrations.rs similarity index 100% rename from conversations/src/storage/migrations.rs rename to core/conversations/src/storage/migrations.rs diff --git a/conversations/src/storage/migrations/001_initial_schema.sql b/core/conversations/src/storage/migrations/001_initial_schema.sql similarity index 100% rename from conversations/src/storage/migrations/001_initial_schema.sql rename to core/conversations/src/storage/migrations/001_initial_schema.sql diff --git a/conversations/src/storage/mod.rs b/core/conversations/src/storage/mod.rs similarity index 100% rename from conversations/src/storage/mod.rs rename to core/conversations/src/storage/mod.rs diff --git a/conversations/src/storage/types.rs b/core/conversations/src/storage/types.rs similarity index 100% rename from conversations/src/storage/types.rs rename to core/conversations/src/storage/types.rs diff --git a/conversations/src/types.rs b/core/conversations/src/types.rs similarity index 100% rename from conversations/src/types.rs rename to core/conversations/src/types.rs diff --git a/conversations/src/utils.rs b/core/conversations/src/utils.rs similarity index 100% rename from conversations/src/utils.rs rename to core/conversations/src/utils.rs diff --git a/crypto/Cargo.toml b/core/crypto/Cargo.toml similarity index 100% rename from crypto/Cargo.toml rename to core/crypto/Cargo.toml diff --git a/crypto/src/keys.rs b/core/crypto/src/keys.rs similarity index 100% rename from crypto/src/keys.rs rename to core/crypto/src/keys.rs diff --git a/crypto/src/lib.rs b/core/crypto/src/lib.rs similarity index 100% rename from crypto/src/lib.rs rename to core/crypto/src/lib.rs diff --git a/crypto/src/x3dh.rs b/core/crypto/src/x3dh.rs similarity index 100% rename from crypto/src/x3dh.rs rename to core/crypto/src/x3dh.rs diff --git a/crypto/src/xeddsa_sign.rs b/core/crypto/src/xeddsa_sign.rs similarity index 100% rename from crypto/src/xeddsa_sign.rs rename to core/crypto/src/xeddsa_sign.rs diff --git a/double-ratchets/Cargo.toml b/core/double-ratchets/Cargo.toml similarity index 100% rename from double-ratchets/Cargo.toml rename to core/double-ratchets/Cargo.toml diff --git a/double-ratchets/README.md b/core/double-ratchets/README.md similarity index 100% rename from double-ratchets/README.md rename to core/double-ratchets/README.md diff --git a/double-ratchets/examples/double_ratchet_basic.rs b/core/double-ratchets/examples/double_ratchet_basic.rs similarity index 100% rename from double-ratchets/examples/double_ratchet_basic.rs rename to core/double-ratchets/examples/double_ratchet_basic.rs diff --git a/double-ratchets/examples/out_of_order_demo.rs b/core/double-ratchets/examples/out_of_order_demo.rs similarity index 100% rename from double-ratchets/examples/out_of_order_demo.rs rename to core/double-ratchets/examples/out_of_order_demo.rs diff --git a/double-ratchets/examples/serialization_demo.rs b/core/double-ratchets/examples/serialization_demo.rs similarity index 100% rename from double-ratchets/examples/serialization_demo.rs rename to core/double-ratchets/examples/serialization_demo.rs diff --git a/double-ratchets/examples/storage_demo.rs b/core/double-ratchets/examples/storage_demo.rs similarity index 100% rename from double-ratchets/examples/storage_demo.rs rename to core/double-ratchets/examples/storage_demo.rs diff --git a/double-ratchets/ffi-nim-example/ffi_nim_example.nimble b/core/double-ratchets/ffi-nim-example/ffi_nim_example.nimble similarity index 100% rename from double-ratchets/ffi-nim-example/ffi_nim_example.nimble rename to core/double-ratchets/ffi-nim-example/ffi_nim_example.nimble diff --git a/double-ratchets/ffi-nim-example/src/ffi_nim_example.nim b/core/double-ratchets/ffi-nim-example/src/ffi_nim_example.nim similarity index 100% rename from double-ratchets/ffi-nim-example/src/ffi_nim_example.nim rename to core/double-ratchets/ffi-nim-example/src/ffi_nim_example.nim diff --git a/double-ratchets/src/aead.rs b/core/double-ratchets/src/aead.rs similarity index 100% rename from double-ratchets/src/aead.rs rename to core/double-ratchets/src/aead.rs diff --git a/double-ratchets/src/bin/generate-headers.rs b/core/double-ratchets/src/bin/generate-headers.rs similarity index 100% rename from double-ratchets/src/bin/generate-headers.rs rename to core/double-ratchets/src/bin/generate-headers.rs diff --git a/double-ratchets/src/errors.rs b/core/double-ratchets/src/errors.rs similarity index 100% rename from double-ratchets/src/errors.rs rename to core/double-ratchets/src/errors.rs diff --git a/double-ratchets/src/ffi/doubleratchet.rs b/core/double-ratchets/src/ffi/doubleratchet.rs similarity index 100% rename from double-ratchets/src/ffi/doubleratchet.rs rename to core/double-ratchets/src/ffi/doubleratchet.rs diff --git a/double-ratchets/src/ffi/key.rs b/core/double-ratchets/src/ffi/key.rs similarity index 100% rename from double-ratchets/src/ffi/key.rs rename to core/double-ratchets/src/ffi/key.rs diff --git a/double-ratchets/src/ffi/mod.rs b/core/double-ratchets/src/ffi/mod.rs similarity index 100% rename from double-ratchets/src/ffi/mod.rs rename to core/double-ratchets/src/ffi/mod.rs diff --git a/double-ratchets/src/ffi/utils.rs b/core/double-ratchets/src/ffi/utils.rs similarity index 100% rename from double-ratchets/src/ffi/utils.rs rename to core/double-ratchets/src/ffi/utils.rs diff --git a/double-ratchets/src/hkdf.rs b/core/double-ratchets/src/hkdf.rs similarity index 100% rename from double-ratchets/src/hkdf.rs rename to core/double-ratchets/src/hkdf.rs diff --git a/double-ratchets/src/keypair.rs b/core/double-ratchets/src/keypair.rs similarity index 100% rename from double-ratchets/src/keypair.rs rename to core/double-ratchets/src/keypair.rs diff --git a/double-ratchets/src/lib.rs b/core/double-ratchets/src/lib.rs similarity index 100% rename from double-ratchets/src/lib.rs rename to core/double-ratchets/src/lib.rs diff --git a/double-ratchets/src/reader.rs b/core/double-ratchets/src/reader.rs similarity index 100% rename from double-ratchets/src/reader.rs rename to core/double-ratchets/src/reader.rs diff --git a/double-ratchets/src/state.rs b/core/double-ratchets/src/state.rs similarity index 100% rename from double-ratchets/src/state.rs rename to core/double-ratchets/src/state.rs diff --git a/double-ratchets/src/storage/db.rs b/core/double-ratchets/src/storage/db.rs similarity index 100% rename from double-ratchets/src/storage/db.rs rename to core/double-ratchets/src/storage/db.rs diff --git a/double-ratchets/src/storage/errors.rs b/core/double-ratchets/src/storage/errors.rs similarity index 100% rename from double-ratchets/src/storage/errors.rs rename to core/double-ratchets/src/storage/errors.rs diff --git a/double-ratchets/src/storage/mod.rs b/core/double-ratchets/src/storage/mod.rs similarity index 100% rename from double-ratchets/src/storage/mod.rs rename to core/double-ratchets/src/storage/mod.rs diff --git a/double-ratchets/src/storage/session.rs b/core/double-ratchets/src/storage/session.rs similarity index 100% rename from double-ratchets/src/storage/session.rs rename to core/double-ratchets/src/storage/session.rs diff --git a/double-ratchets/src/storage/types.rs b/core/double-ratchets/src/storage/types.rs similarity index 100% rename from double-ratchets/src/storage/types.rs rename to core/double-ratchets/src/storage/types.rs diff --git a/double-ratchets/src/types.rs b/core/double-ratchets/src/types.rs similarity index 100% rename from double-ratchets/src/types.rs rename to core/double-ratchets/src/types.rs diff --git a/storage/Cargo.toml b/core/storage/Cargo.toml similarity index 100% rename from storage/Cargo.toml rename to core/storage/Cargo.toml diff --git a/storage/src/errors.rs b/core/storage/src/errors.rs similarity index 100% rename from storage/src/errors.rs rename to core/storage/src/errors.rs diff --git a/storage/src/lib.rs b/core/storage/src/lib.rs similarity index 100% rename from storage/src/lib.rs rename to core/storage/src/lib.rs diff --git a/storage/src/sqlite.rs b/core/storage/src/sqlite.rs similarity index 100% rename from storage/src/sqlite.rs rename to core/storage/src/sqlite.rs diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml new file mode 100644 index 0000000..d3cfb2a --- /dev/null +++ b/crates/client/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "client" +version = "0.1.0" +edition = "2024" + +[lib] +crate-type = ["rlib"] + +[dependencies] +libchat = { workspace = true } diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs new file mode 100644 index 0000000..a26908a --- /dev/null +++ b/crates/client/src/client.rs @@ -0,0 +1,18 @@ +use libchat::ChatError; +use libchat::Context; + +pub struct ChatClient { + ctx: Context, +} + +impl ChatClient { + pub fn new(name: impl Into) -> Self { + Self { + ctx: Context::new_with_name(name), + } + } + + pub fn create_bundle(&mut self) -> Result, ChatError> { + self.ctx.create_intro_bundle() + } +} diff --git a/crates/client/src/lib.rs b/crates/client/src/lib.rs new file mode 100644 index 0000000..008d68a --- /dev/null +++ b/crates/client/src/lib.rs @@ -0,0 +1,3 @@ +mod client; + +pub use client::ChatClient;