-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d3b619f
Showing
13 changed files
with
1,263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
name: REUSE Compliance Check | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: REUSE Compliance Check | ||
uses: fsfe/reuse-action@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
*/target | ||
target | ||
Cargo.lock | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
[workspace] | ||
members = ["api_client", "types"] | ||
resolver = "2" | ||
|
||
[workspace.package] | ||
authors = ["Phoenix R&D <[email protected]>"] | ||
edition = "2021" | ||
license = "AGPL-3.0-or-later" | ||
version = "0.1.0" | ||
homepage = "https://phnx.im" | ||
repository = "https://github.com/phnx-im/minimal-ds-client" | ||
readme = "README.md" |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Minimal DS Client | ||
|
||
This repository contains a Rust implementation of an API client for a minimal | ||
Delivery Service for use with MLS. | ||
|
||
See the module documentation of the `api_client` crate for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
[package] | ||
name = "api_client" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
minimal-ds-types = { path = "../types" } | ||
mls-assist = { git = "https://github.com/phnx-im/mls-assist", branch = "konrad/towards_openmls_main" } | ||
reqwest = { version = "0.11" } | ||
openmls = { git = "https://github.com/openmls/openmls" } | ||
thiserror = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
use minimal_ds_types::DsClientIdError; | ||
use openmls::prelude::tls_codec; | ||
use reqwest::StatusCode; | ||
use thiserror::Error; | ||
|
||
/// Errors that can occur when sending a message to the DS. | ||
#[derive(Error, Debug)] | ||
pub enum SendMessageError { | ||
#[error(transparent)] | ||
ReqwestError(#[from] reqwest::Error), | ||
#[error("Network error: {0}")] | ||
NetworkError(StatusCode), | ||
#[error("DS error: {0}")] | ||
MinimalDsError(String), | ||
#[error(transparent)] | ||
PayloadSerializationError(#[from] tls_codec::Error), | ||
} | ||
|
||
/// Errors that can occur when registering a client with the DS. | ||
#[derive(Error, Debug)] | ||
pub enum RegisterClientError { | ||
#[error("Invalid input : {0}")] | ||
InvalidInput(&'static str), | ||
#[error(transparent)] | ||
InvalidClientId(#[from] DsClientIdError), | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
RegisterClientError(#[from] SendMessageError), | ||
} | ||
|
||
/// Errors that can occur when requesting a list of clients from the DS. | ||
#[derive(Error, Debug)] | ||
pub enum ListClientsError { | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
RegisterClientError(#[from] SendMessageError), | ||
} | ||
|
||
/// Errors that can occur when fetching messages from the DS. | ||
#[derive(Error, Debug)] | ||
pub enum FetchMessagesError { | ||
#[error(transparent)] | ||
FetchMessagesError(#[from] SendMessageError), | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error("Error deserializing response: {0}")] | ||
DeserializationError(#[from] tls_codec::Error), | ||
} | ||
|
||
/// Errors that can occur when uploading key packages to the DS. | ||
#[derive(Error, Debug)] | ||
pub enum UploadKeyPackagesError { | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
UploadKeyPackageError(#[from] SendMessageError), | ||
} | ||
|
||
/// Errors that can occur when creating a group on the DS. | ||
#[derive(Error, Debug)] | ||
pub enum CreateGroupError { | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
CreateGroupError(#[from] SendMessageError), | ||
} | ||
|
||
/// Errors that can occur when fetching a key package from the DS. | ||
#[derive(Error, Debug)] | ||
pub enum FetchKeyPackageError { | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
FetchKeyPackageError(#[from] SendMessageError), | ||
} | ||
|
||
/// Errors that can occur when distributing a group message through the DS. | ||
#[derive(Error, Debug)] | ||
pub enum DistributeGroupMessageError { | ||
#[error("Invalid input : {0}")] | ||
InvalidInput(&'static str), | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
DistributeGroupMessageError(#[from] SendMessageError), | ||
} | ||
|
||
/// Errors that can occur when distributing a welcome message through the DS. | ||
#[derive(Error, Debug)] | ||
pub enum DistributeWelcomeError { | ||
#[error("Invalid input : {0}")] | ||
InvalidInput(&'static str), | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
DistributeWelcomeError(#[from] SendMessageError), | ||
} | ||
|
||
/// Errors that can occur when deleting a group on the DS. | ||
#[derive(Error, Debug)] | ||
pub enum DeleteGroupError { | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
DeleteGroupError(#[from] SendMessageError), | ||
} | ||
|
||
/// Errors that can occur when deleting a client from the DS. | ||
#[derive(Error, Debug)] | ||
pub enum DeleteClientError { | ||
#[error("Received an unexpected response.")] | ||
UnexpectedResponse, | ||
#[error(transparent)] | ||
DeleteClientError(#[from] SendMessageError), | ||
} |
Oops, something went wrong.