Skip to content

Security round 1 and plan limits - #52

Draft
iman-nebulr wants to merge 3 commits into
feat/v1-alphafrom
security/review-fixes-r1
Draft

iman-nebulr wants to merge 3 commits into
feat/v1-alphafrom
security/review-fixes-r1

Conversation

@iman-nebulr

Copy link
Copy Markdown
Contributor

Brings back the plan limit and plan feature gates of 0.9, on the 1.0 line and auth-core's quota store:

  • QuotaGate, Entitled, useEntitlements (the flag bridge:billing.entitlement.<key>, never the plan)
  • useQuota with loading, unlimited, used, limit, remaining, warningLevel, kind, snapshot; QuotaBanner (also as BridgeQuotaBanner); live on quota and access notices
  • the billing lock: BillingNotice for every role, mode="hard" lockscreen, useBillingGate, at once on a 402 BILLING_GATE_ENGAGED through bridgeFetch
  • onBridgeQuotaExceeded, and the upgrade dialog on a 402 QUOTA_EXCEEDED

Needs the auth-core release with plan limits, entitlements and the billing lock (not published yet). Stacked on the open 1.0 PR (#51), which is why the base is feat/v1-alpha: v1 still holds the 0.9 code.

Tested: 68 unit tests, build, typecheck, demo check, publint, docs links; the demo's 54 Playwright specs on the local issuer.

https://claude.ai/code/session_01G1bV8Xv8bNjMNToHyYYCgW

QuotaGate, Entitled and useEntitlements are back with 0.9's names, props and
behaviour, built on auth-core's quota store and entitlements (the flag
bridge:billing.entitlement.<key>, never the plan).

- useQuota reads auth-core's quota snapshots and follows billing.quota_updated /
  access_changed: loading, unlimited, used, limit, remaining, warningLevel, kind
  and snapshot, plus ratio and state. It always returns an object.
- QuotaBanner shows approaching, critical, reached, over and a metered limit's
  overage, with 0.9's copy; BridgeQuotaBanner and BridgeUpgradeDialog are aliases.
- BillingNotice follows the billing lock (every role, and at once on a 402
  BILLING_GATE_ENGAGED through bridgeFetch); mode="hard" is 0.9's lockscreen.
  useBillingGate / useBillingLocked.
- onBridgeQuotaExceeded / parseQuotaRefusal for apps with their own dialog; the
  upgrade dialog still opens on a 402 QUOTA_EXCEEDED.
- Unit tests against the fake issuer, a Playwright spec on the local issuer, docs.

No-ticket: public repo, the work is tracked internally
Claude-Session: https://claude.ai/code/session_01G1bV8Xv8bNjMNToHyYYCgW
…useBridgeBilling

0.9 exported these; they are exported again so an app written for 0.9 still
compiles.

- BridgeBillingNotice (and its props type BridgeBillingNoticeProps) is
  BillingNotice.
- dismissQuotaRefusal() closes the upgrade dialog a plan-limit refusal
  opened, as in 0.9; it is closeUpgrade().
- useBridgeBilling() is the 0.9 billing handle: quota(metric), quotas,
  entitlements, handle, isLocked(), gateState() and assertNotLocked(). It is
  not a React hook, always answers, and follows the page's client. It has no
  `subscription`; useBilling() has the billing facts.

No-ticket: public repo
Claude-Session: https://claude.ai/code/session_01G1bV8Xv8bNjMNToHyYYCgW
…ed (TBP-909)

Raise the auth-core pin from alpha.8 to alpha.11. No version bump or tag:
this PR waits for the PR it is stacked on.

Refs: TBP-909
Claude-Session: https://claude.ai/code/session_01G1bV8Xv8bNjMNToHyYYCgW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant