| 1 |
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 |
// Copyright by contributors to this project. |
| 3 |
// SPDX-License-Identifier: (Apache-2.0 OR MIT) |
| 4 |
|
| 5 |
use mls_rs_core::identity::IdentityProvider; |
| 6 |
|
| 7 |
use crate::{ |
| 8 |
crypto::SignaturePublicKey, |
| 9 |
extension::ExtensionType, |
| 10 |
group::{mls_rules::MlsRules, proposal::ProposalType}, |
| 11 |
identity::CredentialType, |
| 12 |
protocol_version::ProtocolVersion, |
| 13 |
tree_kem::Capabilities, |
| 14 |
CryptoProvider, |
| 15 |
}; |
| 16 |
|
| 17 |
pub trait ExternalClientConfig: Send + Sync + Clone { |
| 18 |
type IdentityProvider: IdentityProvider + Clone; |
| 19 |
type MlsRules: MlsRules + Clone; |
| 20 |
type CryptoProvider: CryptoProvider; |
| 21 |
|
| 22 |
fn supported_extensions(&self) -> Vec<ExtensionType>; |
| 23 |
fn supported_custom_proposals(&self) -> Vec<ProposalType>; |
| 24 |
fn supported_protocol_versions(&self) -> Vec<ProtocolVersion>; |
| 25 |
fn identity_provider(&self) -> Self::IdentityProvider; |
| 26 |
fn crypto_provider(&self) -> Self::CryptoProvider; |
| 27 |
fn external_signing_key(&self, external_key_id: &[u8]) -> Option<SignaturePublicKey>; |
| 28 |
|
| 29 |
fn mls_rules(&self) -> Self::MlsRules; |
| 30 |
|
| 31 |
fn cache_proposals(&self) -> bool; |
| 32 |
|
| 33 |
fn max_epoch_jitter(&self) -> Option<u64> { |
| 34 |
None |
| 35 |
} |
| 36 |
|
| 37 |
fn capabilities(&self) -> Capabilities { |
| 38 |
Capabilities { |
| 39 |
protocol_versions: self.supported_protocol_versions(), |
| 40 |
cipher_suites: self.crypto_provider().supported_cipher_suites(), |
| 41 |
extensions: self.supported_extensions(), |
| 42 |
proposals: self.supported_custom_proposals(), |
| 43 |
credentials: self.supported_credentials(), |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
fn version_supported(&self, version: ProtocolVersion) -> bool { |
| 48 |
self.supported_protocol_versions().contains(&version) |
| 49 |
} |
| 50 |
|
| 51 |
fn supported_credentials(&self) -> Vec<CredentialType> { |
| 52 |
self.identity_provider().supported_types() |
| 53 |
} |
| 54 |
} |