Skip to main content

bitwarden_importers/importers/onepassword/
mod.rs

1//! 1Password importer.
2//!
3//! [`access`] is the Bitwarden-agnostic client that logs in and downloads the vaults.
4//! [`convert`] maps what it returns onto the importer's parsed shape.
5
6// Both are `pub` for the `test-utils` re-export.
7// TODO: Make them `pub(crate)` once the out-of-tree CLI is retired.
8pub mod access;
9pub mod convert;
10
11use access::OnePasswordError;
12
13use crate::ImportError;
14
15impl From<OnePasswordError> for ImportError {
16    fn from(error: OnePasswordError) -> Self {
17        match error {
18            OnePasswordError::BadCredentials => ImportError::OnePasswordBadCredentials,
19            OnePasswordError::InvalidSignInAddress(_) => {
20                ImportError::OnePasswordInvalidSignInAddress
21            }
22            OnePasswordError::TwoFactorRequired => ImportError::OnePasswordTwoFactorRequired,
23            OnePasswordError::TwoFactorFailed => ImportError::OnePasswordTwoFactorFailed,
24            OnePasswordError::Unsupported(what) => ImportError::OnePasswordUnsupported(what),
25            OnePasswordError::Network(what) => ImportError::OnePasswordNetwork(what),
26            // A payload that will not decrypt or parse is the same story to a user: the account
27            // came back unreadable.
28            OnePasswordError::Decryption | OnePasswordError::Parse => {
29                ImportError::OnePasswordDecryption
30            }
31            // Neither of these can reach a caller as anything actionable, so they read as a
32            // transport failure with the detail kept.
33            OnePasswordError::NotFound => {
34                ImportError::OnePasswordNetwork("the account or vault was not found".to_string())
35            }
36            OnePasswordError::Internal(what) => ImportError::OnePasswordNetwork(what),
37        }
38    }
39}