Skip to main content
The Generator library (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 in libs/tools/generator/core/src/abstractions/credential-generator-service.abstraction.ts Key Methods:

GeneratorStrategy

Base abstraction for all generator strategies. Located in libs/tools/generator/core/src/abstractions/generator-strategy.abstraction.ts

Generator Strategies

Located in libs/tools/generator/core/src/strategies/

Password Generator

File: password-generator-strategy.ts Generates random passwords with configurable character sets. Options:
Example:

Passphrase Generator

File: passphrase-generator-strategy.ts Generates passphrases using random words from the EFF word list. Options:
Example:

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 in libs/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 in libs/tools/generator/extensions/

History Extension

Package: @bitwarden/generator-history Stores and manages generation history for users. 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 the PolicyEvaluator system. Policies can enforce:
  • Minimum password length
  • Required character types (uppercase, lowercase, numbers, special)
  • Minimum character counts per type
  • Passphrase complexity requirements
Example Policy:

Integration

The generator library is used across all Bitwarden client applications:
  • Web Vault
  • Desktop Application
  • Browser Extension
  • CLI
Example Integration: