Skip to content

Add client-side entitlement layer and feature-flag system #8

Description

@PAMulligan

Description

Add a client-side module to the extension that holds the current entitlement, verifies its signature against the bundled public key, caches it in chrome.storage.local, refreshes it before expiry, and exposes simple feature flags (for example canUseAI, aiQuotaRemaining, isPro) that the UI reads. The rest of the app should never look at raw license data, only these flags.

Why

Gating logic scattered across components is hard to reason about and easy to get wrong. A single entitlement layer gives one well-tested place that decides what is unlocked, keeps the signature check in one spot, and makes the free/Pro split a matter of reading a flag. It also degrades gracefully offline by trusting the last valid, unexpired entitlement.

Acceptance Criteria

  • Entitlement store added (Zustand, matching app/src/lib/store.ts) with typed flags
  • Signed entitlement verified against a bundled public key before being trusted
  • Cached in chrome.storage.local via the existing storage.ts helpers
  • Auto-refresh before expiry; on failure, fall back to last valid unexpired entitlement
  • Expired or missing entitlement resolves to the free tier, never Pro
  • Feature flags exposed: isPro, canUseAI, aiQuotaRemaining, advanced-options gate
  • Unit tests cover valid, expired, tampered, and offline cases
  • CI passes

Resources

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions