Skip to main content

Module hydra

Module hydra 

Source
Expand description

The hydra device JWT.

Grab’s web app gates its menu and quote/order endpoints behind an x-hydra-jwt header. It is an RS256 JWT whose claims are a browser fingerprint, signed with a key the web app carries. The token has a ~10 minute TTL, so it is re-minted often.

Two ways to obtain one:

  • native (mint_native): sign the claims locally with an RS256 key loaded from a PEM file the user supplies (<config>/hydra-key.pem). The key is NOT shipped with grabcli; see docs/hydra.md. The fingerprint claims are opaque strings — the server validates the signature, not their content — so we generate stable-looking values.
  • CDP (crate::cdp): drive a logged-in browser over the Chrome DevTools Protocol, let it mint a token the normal way, and sniff the header off the wire.

The constants below (issuer, audience, version, TTL) describe the token shape Grab expects. They are protocol facts, not secrets.

Structs§

DeviceFields
Opaque browser-fingerprint claims. Any stable values are accepted because the server checks the signature, not the fingerprint.

Constants§

DEFAULT_VER
Hydra web app version claim (ver). Bump if Grab rotates it.

Functions§

mint_native
Mint a hydra JWT natively by signing claims with the given RS256 key (PEM). Returns (token, exp).