The Vault library (
@bitwarden/vault) represents the public API of the Vault team at Bitwarden. It handles all vault item operations, including cipher management, folders, and collections.Overview
The Vault library provides comprehensive functionality for managing vault items (ciphers), organizing them into folders and collections, and handling vault filtering and display. It includes both the business logic services and UI components for creating, viewing, and editing vault items.Core Concepts
Ciphers
Ciphers are the encrypted vault items that store sensitive user data. Bitwarden supports multiple cipher types:Login
Username/password credentials with URIs for autofill
Card
Payment card information with cardholder details
Identity
Personal identification information and addresses
Secure Note
Encrypted text notes and documents
SSH Key
SSH private keys and authentication credentials
Folders
Folders provide personal organization for vault items. Each user can create their own folder hierarchy to categorize their ciphers.Collections
Collections are shared organizational units within an organization. They enable teams to share specific sets of vault items with defined groups of users.Directory Structure
Key Services
CipherFormService
Manages cipher creation and modification with proper encryption handling.libs/vault/src/cipher-form/abstractions/cipher-form.service.ts
VaultFilterService
Provides filtering and organization tree functionality for the vault.libs/vault/src/abstractions/vault-filter.service.ts
VaultItemsTransferService
Handles moving vault items between collections and organizations.libs/vault/src/abstractions/vault-items-transfer.service.ts
ChangeLoginPasswordService
Manages password change operations for login ciphers.libs/vault/src/abstractions/change-login-password.service.ts
Cipher Form Components
The library provides a comprehensive set of components for cipher creation and editing:Type-Specific Sections
- LoginDetailsSection - Username, password, TOTP, and URI management
- CardDetailsSection - Card number, CVV, expiration, cardholder name
- IdentitySection - Name, address, SSN, passport information
- SshKeySection - Private key, public key, fingerprint
Common Sections
- ItemDetailsSection - Name, folder, favorites
- CustomFieldsSection - User-defined custom fields (text, hidden, boolean, linked)
- AttachmentsSection - File attachments to vault items
- AutofillOptionsSection - URI matching rules for login items
- AdditionalOptionsSection - Notes, reprompt settings
Cipher View Components
Read-only components for displaying decrypted cipher information:- LoginCredentialsView - Display username, password with copy/reveal
- CardDetailsView - Display card information securely
- ViewIdentitySections - Display identity fields
- CustomFieldsView - Display custom field values
- ItemHistoryView - Show creation/modification timestamps
Vault Filtering
The vault filter system provides hierarchical organization:Filter Sections
Type Filters
Filter by cipher type: All Items, Favorites, Logins, Cards, Identities, Secure Notes, SSH Keys, Trash
Collection Filters
Organization collections with hierarchical names (e.g., “Team/Engineering/Credentials”)
Autofill Configuration
For login ciphers, the library provides URI matching configuration:URI Matching Examples
| Match Type | URI Pattern | Matches |
|---|---|---|
| Domain | example.com | https://example.com, https://app.example.com |
| Host | app.example.com | https://app.example.com (exact host) |
| StartsWith | https://app.example.com/login | URLs starting with this prefix |
| Exact | https://app.example.com/login | Exact URL match only |
| RegularExpression | ^https://.*\.example\.com$ | Regex pattern matching |
| Never | (any) | Never suggest for autofill |
Custom Fields
Vault items support extensible custom fields:Domain Boundaries
Vault vs. Platform: The Vault library handles vault item business logic and UI components, while encryption/decryption primitives are provided by
@bitwarden/platform. The vault library uses platform services for crypto operations.Vault vs. Admin Console: Folders are personal to each user and managed in the Vault library. Collections are organizational resources managed by the Admin Console library, though the Vault library provides UI for working with assigned collections.
Vault vs. Autofill: While the Vault library defines cipher structures and URI matching rules, the actual autofill behavior (detecting fields, injecting credentials) is handled by platform-specific autofill implementations.
Usage Example
Related Libraries
- @bitwarden/platform - Encryption and state management
- @bitwarden/admin-console - Collections and organization management
- @bitwarden/auth - User authentication for vault access