Skip to content

Commit 2bbba2f

Browse files
authored
Add documentation to public members (#205)
1 parent b99e954 commit 2bbba2f

25 files changed

+189
-34
lines changed

crates/bitwarden-cli/src/color.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
use clap::ValueEnum;
22

3+
/// Color configuration for the CLI
34
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)]
45
pub enum Color {
6+
/// Force colors off
57
No,
8+
/// Force colors on
69
Yes,
10+
/// Automatically detect if colors are supported in the terminal.
711
Auto,
812
}
913

crates/bitwarden-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ internal = ["dep:zxcvbn"]
1919
no-memory-hardening = [
2020
"bitwarden-crypto/no-memory-hardening"
2121
] # Disable memory hardening features
22-
uniffi = ["bitwarden-crypto/uniffi", "dep:uniffi"] # Uniffi bindings
2322
secrets = [] # Secrets manager API
23+
uniffi = ["bitwarden-crypto/uniffi", "dep:uniffi"] # Uniffi bindings
2424
wasm = [
2525
"bitwarden-error/wasm",
2626
"dep:wasm-bindgen",

crates/bitwarden-core/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# Bitwarden Core
22

3-
Contains core functionality used by the feature crates.
3+
Contains core functionality used by the feature crates. For an introduction to the Bitwarden SDK and
4+
the `bitwarden-core` create please refer to the
5+
[SDK Architecture](https://contributing.bitwarden.com/architecture/sdk/) documentation.
46

57
<div class="warning">
68
Generally you should <b>not</b> find yourself needing to edit this crate! When possible, please use the feature crates instead.
79
</div>
10+
11+
## Features
12+
13+
- `internal` - Internal unstable APIs that should only be consumed by internal Bitwarden clients.
14+
- `no-memory-hardening` - Disables `bitwarden-crypto` memory hardening.
15+
- `secrets` - Secrets Manager specific functionality.
16+
- `uniffi` - Mobile bindings.
17+
- `wasm` - WebAssembly bindings.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Admin console module for Bitwarden Core.
2+
//!
3+
//! Contains policies.
4+
15
mod policy;
26

37
pub use policy::Policy;

crates/bitwarden-core/src/admin_console/policy.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use uuid::Uuid;
88

99
use crate::{require, MissingFieldError};
1010

11+
/// Represents a policy that can be applied to an organization.
1112
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
1213
pub struct Policy {
1314
id: Uuid,
@@ -20,20 +21,30 @@ pub struct Policy {
2021
#[derive(Serialize_repr, Deserialize_repr, Debug, JsonSchema)]
2122
#[repr(u8)]
2223
pub enum PolicyType {
23-
TwoFactorAuthentication = 0, // Requires users to have 2fa enabled
24-
MasterPassword = 1, // Sets minimum requirements for master password complexity
25-
PasswordGenerator = 2, /* Sets minimum requirements/default type for generated
26-
* passwords/passphrases */
27-
SingleOrg = 3, // Allows users to only be apart of one organization
28-
RequireSso = 4, // Requires users to authenticate with SSO
29-
PersonalOwnership = 5, // Disables personal vault ownership for adding/cloning items
30-
DisableSend = 6, // Disables the ability to create and edit Bitwarden Sends
31-
SendOptions = 7, // Sets restrictions or defaults for Bitwarden Sends
32-
ResetPassword = 8, /* Allows orgs to use reset password : also can enable
33-
* auto-enrollment during invite flow */
34-
MaximumVaultTimeout = 9, // Sets the maximum allowed vault timeout
35-
DisablePersonalVaultExport = 10, // Disable personal vault export
36-
ActivateAutofill = 11, // Activates autofill with page load on the browser extension
24+
/// Requires users to have 2fa enabled
25+
TwoFactorAuthentication = 0,
26+
/// Sets minimum requirements for master password complexity
27+
MasterPassword = 1,
28+
/// Sets minimum requirements/default type for generated passwords/passphrases
29+
PasswordGenerator = 2,
30+
/// Allows users to only be apart of one organization
31+
SingleOrg = 3,
32+
/// Requires users to authenticate with SSO
33+
RequireSso = 4,
34+
/// Disables personal vault ownership for adding/cloning items
35+
PersonalOwnership = 5,
36+
/// Disables the ability to create and edit Bitwarden Sends
37+
DisableSend = 6,
38+
/// Sets restrictions or defaults for Bitwarden Sends
39+
SendOptions = 7,
40+
/// Allows orgs to use reset password : also can enable auto-enrollment during invite flow
41+
ResetPassword = 8,
42+
/// Sets the maximum allowed vault timeout
43+
MaximumVaultTimeout = 9,
44+
/// Disable personal vault export
45+
DisablePersonalVaultExport = 10,
46+
/// Activates autofill with page load on the browser extension
47+
ActivateAutofill = 11,
3748
AutomaticAppLogIn = 12,
3849
FreeFamiliesSponsorshipPolicy = 13,
3950
RemoveUnlockWithPin = 14,

crates/bitwarden-core/src/auth/access_token.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use zeroize::Zeroizing;
88

99
use crate::util::STANDARD_INDIFFERENT;
1010

11+
#[allow(missing_docs)]
1112
#[derive(Debug, Error)]
1213
pub enum AccessTokenInvalidError {
1314
#[error("Doesn't contain a decryption key")]
@@ -26,9 +27,13 @@ pub enum AccessTokenInvalidError {
2627
InvalidBase64Length { expected: usize, got: usize },
2728
}
2829

30+
/// Access Token
2931
pub struct AccessToken {
32+
/// The ID of the access token
3033
pub access_token_id: Uuid,
34+
/// The client secret
3135
pub client_secret: String,
36+
/// The encryption key used to decrypt a payload to retrieve the organization key.
3237
pub encryption_key: SymmetricCryptoKey,
3338
}
3439

crates/bitwarden-core/src/auth/auth_request.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use thiserror::Error;
1111
use crate::client::encryption_settings::EncryptionSettingsError;
1212
use crate::{key_management::SymmetricKeyId, Client, VaultLockedError};
1313

14+
/// Response for `new_auth_request`.
1415
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
1516
pub struct AuthRequestResponse {
1617
/// Base64 encoded private key
@@ -75,6 +76,7 @@ pub(crate) fn auth_request_decrypt_master_key(
7576
Ok(master_key.decrypt_user_key(user_key)?)
7677
}
7778

79+
#[allow(missing_docs)]
7880
#[derive(Debug, Error)]
7981
pub enum ApproveAuthRequestError {
8082
#[error(transparent)]

crates/bitwarden-core/src/auth/jwt_token.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ use thiserror::Error;
1212
/// TODO: We need to expand this to support user based JWT tokens.
1313
#[derive(serde::Deserialize)]
1414
pub struct JwtToken {
15+
/// Expiration Time.
1516
pub exp: u64,
17+
/// Subject.
1618
pub sub: String,
19+
/// User's email.
1720
pub email: Option<String>,
21+
/// Used by Service Accounts to denote the organization.
1822
pub organization: Option<String>,
23+
/// The scopes the token has access to.
1924
pub scope: Vec<String>,
2025
}
2126

27+
/// Error when parsing JWT tokens.
28+
#[allow(missing_docs)]
2229
#[derive(Debug, Error)]
2330
pub enum JwtTokenParseError {
2431
#[error("JWT token parse error: {0}")]

crates/bitwarden-core/src/auth/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Authentication module
2+
//!
3+
//! Contains all the authentication related functionality for registering and logging in.
4+
15
use thiserror::Error;
26

37
use crate::{NotAuthenticatedError, VaultLockedError, WrongPasswordError};
@@ -36,6 +40,8 @@ mod key_connector;
3640
#[cfg(feature = "internal")]
3741
pub use key_connector::KeyConnectorResponse;
3842

43+
/// Error for authentication related operations
44+
#[allow(missing_docs)]
3945
#[derive(Debug, Error)]
4046
pub enum AuthValidateError {
4147
#[error(transparent)]

crates/bitwarden-core/src/error.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ macro_rules! impl_bitwarden_error {
2525
};
2626
}
2727

28+
/// Errors from performing network requests.
29+
#[allow(missing_docs)]
2830
#[derive(Debug, Error)]
2931
pub enum ApiError {
3032
#[error(transparent)]
@@ -41,22 +43,27 @@ pub enum ApiError {
4143
impl_bitwarden_error!(ApiApisError, ApiError);
4244
impl_bitwarden_error!(IdentityError, ApiError);
4345

46+
/// Client is not authenticated or the session has expired.
4447
#[derive(Debug, Error)]
4548
#[error("The client is not authenticated or the session has expired")]
4649
pub struct NotAuthenticatedError;
4750

51+
/// Missing required field.
4852
#[derive(Debug, Error)]
4953
#[error("The response received was missing a required field: {0}")]
5054
pub struct MissingFieldError(pub &'static str);
5155

56+
/// Client vault is locked.
5257
#[derive(Debug, Error)]
5358
#[error("The client vault is locked and needs to be unlocked before use")]
5459
pub struct VaultLockedError;
5560

61+
/// Wrong password.
5662
#[derive(Debug, thiserror::Error)]
5763
#[error("Wrong password")]
5864
pub struct WrongPasswordError;
5965

66+
/// Missing private key.
6067
#[derive(Debug, thiserror::Error)]
6168
#[error("Missing private key")]
6269
pub struct MissingPrivateKeyError;

0 commit comments

Comments
 (0)