What You’ll Build
This quickstart walks you through the full offline authorization lifecycle for a Gemma 4 on-device agent:- Create a consent bundle while online (one API call)
- Verify grant tokens offline using the JWKS snapshot in the bundle
- Log actions to a tamper-evident audit log (hash-chained, Ed25519-signed)
- Sync the audit log back to the Grantex cloud when connectivity returns
Prerequisites
- Node.js 18+ (TypeScript) or Python 3.10+ (Python)
- A Grantex developer account and API key (sign up free)
- A registered agent with the scopes your Gemma 4 model needs
Step 1: Install
Step 2: Create a Consent Bundle (Online)
The consent bundle packages everything the device needs to operate offline: a signed grant token, a JWKS snapshot for signature verification, and an Ed25519 key pair for audit signing.This is the only step that requires network connectivity. Everything after this runs entirely on-device.
Step 3: Create an Offline Verifier
Load the bundle and create a verifier that uses the embedded JWKS snapshot.Step 4: Verify a Token Offline
Every time the Gemma 4 agent attempts an action, verify the grant token before allowing it. No network call is made.Step 5: Create an Offline Audit Log
Every authorized action should be recorded. The audit log is append-only, Ed25519-signed, and hash-chained so tampering is detectable at sync time.Step 6: Sync When Back Online
When connectivity returns, upload the offline audit entries to the Grantex cloud. The server verifies the hash chain and Ed25519 signatures, then reconciles the entries with the cloud audit log.Expected Output
Environment Variables
| Variable | Default | Description |
|---|---|---|
GRANTEX_API_KEY | — | Developer API key from the Grantex portal |
BUNDLE_KEY | — | Passphrase for AES-256-GCM bundle encryption |
Next Steps
- Offline Authorization — architecture deep-dive and security model
- Consent Bundles — full ConsentBundle reference and lifecycle
- Gemma 4 SDK Reference — complete API docs for every export
- Raspberry Pi Guide — run a Gemma 4 agent on a Pi 5 with offline auth
- Android Guide — integrate into an Android app
- iOS Guide — integrate into an iOS app with CryptoKit