d126d8e5a0
* placeholder handling of wg registration with upgrade mode token * include upgrade mode credentials as part of credential storage * introduce helper for decoding JWT payload * expose methods for removing emergency credentials from the storage * don't allow duplicate emergency credentials with the same content * added authenticator ClientMessage for upgrade mode check * retrieve credentials with longest expiration first * post rebasing fixes * fixed gateway config * feat: allow specifying minimum node performance for client init * nym-node UM improvements * fixed upgrade mode bandwidth on initial authentication * fix: logs and thresholds * expose attestation information from nym-node http api * additional logs * post rebasing fixes * make @simonwicky happy by removing empty lines in emergency_credential table definition * chore: remove '_' prefix for internal counters within in-mem ecash storage * improved import of 'UpgradeModeState' within the nym-node * use explicit time dependency within credential-storage * re-order imports within the gateway-client * moved 'AvailableBandwidth' definition to the monorepo
69 lines
2.3 KiB
Rust
69 lines
2.3 KiB
Rust
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use nym_credential_storage::error::StorageError;
|
|
use nym_credentials::error::Error as CredentialsError;
|
|
use nym_credentials_interface::CompactEcashError;
|
|
use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError;
|
|
use nym_crypto::asymmetric::x25519::KeyRecoveryError;
|
|
use nym_validator_client::coconut::EcashApiError;
|
|
use nym_validator_client::error::ValidatorClientError;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum BandwidthControllerError {
|
|
#[error("Nyxd error: {0}")]
|
|
Nyxd(#[from] nym_validator_client::nyxd::error::NyxdError),
|
|
|
|
#[error("coconut api query failure: {0}")]
|
|
CoconutApiError(#[from] EcashApiError),
|
|
|
|
#[error("There was a credential storage error - {0}")]
|
|
CredentialStorageError(Box<dyn std::error::Error + Send + Sync>),
|
|
|
|
#[error("retrieved upgrade mode token is not a valid String")]
|
|
MalformedUpgradeModeToken,
|
|
|
|
#[error("the credential storage does not contain any usable credentials")]
|
|
NoCredentialsAvailable,
|
|
|
|
// this should really be fully incorporated into the above, but messing with coconut is the last thing I want to do now
|
|
#[error(transparent)]
|
|
StorageError(#[from] StorageError),
|
|
|
|
#[error("Ecash error - {0}")]
|
|
EcashError(#[from] CompactEcashError),
|
|
|
|
#[error("Validator client error - {0}")]
|
|
ValidatorError(#[from] ValidatorClientError),
|
|
|
|
#[error("Credential error - {0}")]
|
|
CredentialError(#[from] CredentialsError),
|
|
|
|
#[error("Could not parse Ed25519 data")]
|
|
Ed25519ParseError(#[from] Ed25519RecoveryError),
|
|
|
|
#[error("Could not parse X25519 data")]
|
|
X25519ParseError(#[from] KeyRecoveryError),
|
|
|
|
#[error("The tx hash provided is not valid")]
|
|
InvalidTxHash,
|
|
|
|
#[error("Threshold not set yet")]
|
|
NoThreshold,
|
|
|
|
#[error("can't handle recovering storage with revision {stored}. {expected} was expected")]
|
|
UnsupportedCredentialStorageRevision { stored: u8, expected: u8 },
|
|
|
|
#[error("did not receive a valid response for aggregated data ({typ}) from ANY nym-api")]
|
|
ExhaustedApiQueries { typ: String },
|
|
}
|
|
|
|
impl BandwidthControllerError {
|
|
pub fn credential_storage_error(
|
|
source: impl std::error::Error + Send + Sync + 'static,
|
|
) -> Self {
|
|
BandwidthControllerError::CredentialStorageError(Box::new(source))
|
|
}
|
|
}
|