peer-devicer - v0.1.3
    Preparing search index...

    Class PeerManager

    PeerManager — passive peer reputation networking for the FP-Devicer Suite.

    Builds and maintains a peer graph linking device identifiers that share common signals (IP subnet, user account, JA4 fingerprint, canvas/WebGL hash). After each identify() call the reputation signals produced by ip-devicer and tls-devicer are cached against the device node so that taint can propagate through the graph to connected peers.

    // Register ip-devicer and tls-devicer FIRST so their enrichmentInfo is
    // available when peer-devicer runs.
    ipManager.registerWith(deviceManager);
    tlsManager.registerWith(deviceManager);
    peerManager.registerWith(deviceManager);

    const result = await deviceManager.identify(req.body, req.peerContext);
    // result.peerReputation and result.peerConfidenceBoost are now available

    Implements

    • DeviceManagerPlugin
    Index

    Constructors

    • Create a peer-reputation manager with optional graph, storage, and license configuration.

      When a license key is supplied the constructor optimistically uses the paid-tier edge-history depth until init validates the key. If validation fails, the instance falls back to the free-tier limits.

      Parameters

      • opts: PeerManagerOptions = {}

        Optional runtime configuration.

        • OptionalconfidenceBoostWeight?: number

          Weight applied when adjusting DeviceManager confidence. Range 0–1. Default: 0.2.

        • OptionalenabledEdgeTypes?: PeerEdgeType[]

          Edge types to include. Defaults to all five types when not specified. Free-tier callers always have shared_tls_ja4, shared_canvas, and shared_webgl silently filtered out regardless of this setting.

        • OptionallicenseKey?: string

          Polar license key that unlocks Pro or Enterprise tier features.

          Tier Price Device limit Servers Edge types
          Free $0/mo 10,000 user + subnet
          Pro $49/mo Unlimited 1 server all 5 types
          Enterprise $299/mo Unlimited Unlimited all + custom

          Obtain a key at https://polar.sh.

        • OptionalmaxPeersPerDevice?: number

          Maximum peer edges stored per device. Default: 50 (10 on the free tier). Optimistic provisioning when a key is provided — downgraded to FREE_TIER_MAX_HISTORY if Polar rejects the key.

        • Optionalstorage?: PeerStorage | AsyncPeerStorage

          Custom storage backend. Defaults to the built-in in-memory store. Use createSqliteAdapter, createPostgresAdapter, or createRedisAdapter to supply a persistent backend.

          Async adapters (AsyncPeerStorage) must be initialised separately via their own init() before being passed here.

      Returns PeerManager

    Accessors

    Methods

    • Assess the peer reputation of a device based on signals from the current request and cached reputation data from previously seen peers.

      Parameters

      • incoming: Record<string, unknown>

        Raw fingerprint payload (FPDataSet or compatible object).

      • context: PeerIdentifyContext

        Peer identity context (ip, userId, tlsProfile).

      • deviceId: string

        Resolved device identifier from DeviceManager.

      • enrichmentDetails: Record<string, Record<string, unknown>>

        result.enrichmentInfo.details from DeviceManager, used to cache ip/tls signals for this device.

      Returns Promise<PeerReputationResult>

    • Clear stored edges — all devices when deviceId is omitted.

      Parameters

      • OptionaldeviceId: string

      Returns Promise<void>

    • Return the stored peer edges for a device.

      Parameters

      • deviceId: string

        Device identifier.

      • Optionallimit: number

        Maximum edges to return.

      Returns Promise<PeerEdge[]>

    • Validate the Polar license key if one was supplied.

      Call once at application startup before processing requests. Safe to await multiple times — subsequent calls return the cached promise.

      Returns Promise<void>

    • Remove edges older than olderThanMs milliseconds. Returns the count of pruned edges.

      Parameters

      • olderThanMs: number

      Returns Promise<number>

    • Patch deviceManager.identify() to automatically assess peer reputation on every call and attach peerReputation and peerConfidenceBoost to the result.

      Register this after IpManager and TlsManager so that their enrichmentInfo.details entries are available when peer-devicer runs.

      Failures inside the peer analysis are non-fatal — the original result is returned unchanged when an error occurs.

      Parameters

      • deviceManager: DeviceManagerLike

      Returns void | (() => void)