Firefox Application Services

repository·main·Indexed 20 days ago

https://github.com/mozilla/application-services

A collection of Rust components that enable Firefox applications on Android, iOS, and Desktop to integrate with services such as Firefox Accounts (fxa-client), Sync, and experimentation. It includes specialized libraries like the Mozilla Ads Client (MAC) for ad placement and reporting, breach-alerts for managing HIBP breach dismissals, a context_id mechanism to mitigate click fraud, and Crash Testing Helper APIs for debugging crash reporting systems.

Tokens
171K
Snippets
526
Records
807
Agent score
71%

What's inside mozilla-application-services

  1. Overview of nss_sys low-level NSS bindings

    main
    The nss_sys crate provides low-level FFI (Foreign Function Interface) bindings for NSS (Network Security Services) in Rust. These bindings are maintained manually and are designed to mirror the structure of the NSS library itself. Each NSS header file has a corresponding .rs file within the nss_sys::bindings module that declares the relevant functions and data types.
  2. Overview of Mozilla Ads Client (MAC)

    main

    Mozilla Ads Client (MAC) is a library designed to integrate with the Mozilla Ads Routing Service (MARS). It is primarily intended for mobile surfaces like Firefox for iOS and Android, though it can be used by any surface capable of ingesting Application Services components.

    Key Capabilities:

    • Request and display standard ad placements.
    • Automatically call callback URLs to send anonymized impressions and clicks to Mozilla.
    • Report user dissatisfaction with ads.

    Privacy Model: MAC is privacy-first. It does not track user information or send sensitive identifiable information to Mozilla. Data shared with advertisers is aggregated or de-identified to preserve privacy.

  3. Overview of the Synced Tabs Component

    main

    The Synced Tabs Component provides a storage and syncing engine for remote tabs. It enables cross-platform synchronization of tab data (including URLs, titles, and window/group associations) and supports "tab commands" (e.g., requesting to close a remote tab).

    Key characteristics:

    • Storage: Uses a SQLite database, which is lazily initialized only when remote tabs need to be stored.
    • Platforms: Designed for Desktop and Mobile.
    • Interoperability: Uses UniFFI to provide bindings for non-Rust platforms.
    • Commands: Implements a mechanism where requested tab closures are treated as non-existent for a period to allow remote devices to process the request and re-upload their state.
  4. Overview of the rc_crypto crate

    main

    The rc_crypto crate provides a centralized cryptographic interface for Application Services components. It is designed to be idiomatic to the ring crate API while being backed by Mozilla's NSS (Network Security Services) library via the nss crate. This approach ensures the use of Mozilla-audited primitives and provides stability by decoupling from ring's versioning policies.

    Key capabilities include:

    • Randomness: Cryptographically secure pseudorandom number generation.
    • Hashing & MACs: Digests, HMAC, and HKDF.
    • Encryption: Authenticated encryption (AEAD) and ECDH key agreement.
    • Signatures: ECDSA signature verification.
    • Authentication: HTTP Hawk Authentication and HTTP Encrypted Content-Encoding (ECE).
    • Utilities: Constant-time string comparison.
  5. Overview of the Search Rust component

    main

    The Search Rust component provides search service functions for Firefox Desktop, Android, and iOS.

    Architecture

    The component follows the standard Application Services architecture: a cross-platform Rust core with platform-specific bindings for Desktop, Android, and iOS. These bindings are automatically generated using UniFFI.

    Core Logic

    Currently, the module provides the filter_engine_configuration function. This function takes configurations from remote settings and details of the user's environment as input and returns a list of search engines to be presented to the user.

  6. Overview of nimbus-cli

    main

    nimbus-cli is a command-line tool for Mozilla Nimbus designed for mobile app testing. It provides a unified interface for QA and developers to enroll and unenroll from experiments (including first-run experiments) on Android (device or emulator) and iOS (simulator only).

    Supported Apps

    • Firefox for Android (fenix)
    • Firefox for iOS (firefox_ios)
    • Focus for Android (focus_android)
    • Focus for iOS (focus_ios)
  7. Overview of Application Services Rust Components

    main

    Application Services is a collection of Rust components designed to enable Firefox and related applications to integrate with Firefox accounts, sync data, and enable experimentation.

    Each component is constructed using a core of shared Rust code, which is then wrapped with native language bindings to support various platforms.

  8. Integrate with the Firefox Accounts client

    main

    The fxa-client component allows applications to integrate with the Firefox Accounts (FxA) identity service. It supports user sign-in via email-and-password OAuth flows or QR-code-based pairing, accessing user profile information, obtaining OAuth access tokens and client-side encryption keys (e.g., for Firefox Sync), managing connected applications, sending tabs to other apps, and managing device records for the signed-in application.

    Note: This component does not provide cloud data storage for user accounts.

  9. Use the Merino Rust client

    main
    Merino is a cross-platform Rust client for Mozilla's Merino service. It provides a CuratedRecommendationsClient which interacts with the Merino backend REST API at the /api/v1/curated-recommendations endpoint to fetch curated information. The library uses UniFFI to provide cross-platform bindings for consumption by other platforms.