libs/tools/generator) provides comprehensive credential generation functionality for the Bitwarden client applications. This library enables users to create secure passwords, passphrases, and usernames across all Bitwarden platforms.
Overview
The generator library is split into multiple packages:- @bitwarden/generator-core - Core generation logic, types, and services
- @bitwarden/generator-components - Angular UI components for credential generation
- @bitwarden/generator-extensions - Extension modules (history, navigation, legacy)
Architecture
The generator library follows a strategy pattern, with each credential type having its own generator strategy implementation.Core Abstractions
CredentialGeneratorService
The main service interface for generating credentials. Located inlibs/tools/generator/core/src/abstractions/credential-generator-service.abstraction.ts
Key Methods:
GeneratorStrategy
Base abstraction for all generator strategies. Located inlibs/tools/generator/core/src/abstractions/generator-strategy.abstraction.ts
Generator Strategies
Located inlibs/tools/generator/core/src/strategies/
Password Generator
File:password-generator-strategy.ts
Generates random passwords with configurable character sets.
Options:
Passphrase Generator
File:passphrase-generator-strategy.ts
Generates passphrases using random words from the EFF word list.
Options:
Username Generators
The library includes several username generation strategies:- CatchallGeneratorStrategy - Generates email addresses using catchall domains
- SubaddressGeneratorStrategy - Creates email subaddresses (plus addressing)
- EffUsernameGeneratorStrategy - Generates random usernames from word lists
- ForwarderGeneratorStrategy - Integrates with email forwarding services
Components
Located inlibs/tools/generator/components/src/
CredentialGeneratorComponent
File:credential-generator.component.ts
Main component for the credential generator UI. Provides a complete interface for generating passwords, passphrases, and usernames.
Usage:
PasswordGeneratorComponent
File:password-generator.component.ts
Legacy password generator component for backwards compatibility.
Settings Components
Configurable UI components for each generator type:- PasswordSettingsComponent - Password generator settings
- PassphraseSettingsComponent - Passphrase generator settings
- UsernameSettingsComponent - Username generator settings
- ForwarderSettingsComponent - Email forwarder settings
- CatchallSettingsComponent - Catchall email settings
- SubaddressSettingsComponent - Subaddress settings
Extensions
Located inlibs/tools/generator/extensions/
History Extension
Package:@bitwarden/generator-history
Stores and manages generation history for users.
Navigation Extension
Package:@bitwarden/generator-navigation
Manages navigation state and routing for generator UI.
Legacy Extension
Package:@bitwarden/generator-legacy
Provides backwards compatibility with older generator implementations.
Policy Enforcement
The generator supports enterprise policy enforcement through thePolicyEvaluator system. Policies can enforce:
- Minimum password length
- Required character types (uppercase, lowercase, numbers, special)
- Minimum character counts per type
- Passphrase complexity requirements
Integration
The generator library is used across all Bitwarden client applications:- Web Vault
- Desktop Application
- Browser Extension
- CLI
Related
- Send Library - Secure sharing functionality
- Export Library - Vault import/export