caelum0x 514086bdda feat: Phase 3 enterprise hardening — gateway chain, XDR threat detection, compliance ops, plan tiers
- lib/security/gatewayChain.ts: composable ordered front-door (ip-allowlist -> authN -> authZ ->
  provenance -> rate/quota) as an additive primitive + docs/gateway-rollout.md (BUILD not fork Envoy)
- XDR: 0064 security_events + lib/security/threatDetection.ts (4 deterministic detectors) +
  securityScan + /console/admin/security dashboard
- Compliance ops: retention purge (with SQL-identifier guard), nightly chain-integrity verifyChain,
  access-review snapshot; folded into the daily /api/cron/tick (one Vercel-Hobby cron)
- Plan tiers: 0065 Researcher/Team/Pharma-Enterprise + plan_features entitlements + requireFeature +
  /console/billing/tier (Part-11 e-sign, audit export, SSO/SCIM gated to Enterprise)
- docs/compliance-controls.md (SOC2/HIPAA/21 CFR Part 11 controls matrix)
- Fixed: honest new-active-key threat description; removed duplicate /security page

migrations 0064/0065/0066 applied to Neon; tsc + build green.
2026-07-11 00:18:36 +03:00

40 lines
1.1 KiB
TypeScript

"use client";
import { useCallback, useEffect, useState } from "react";
import { getJson } from "@/components/billing/apiClient";
import type { TierResponse } from "./types";
interface TierState {
data: TierResponse | null;
loading: boolean;
error: string | null;
reload: () => void;
}
// Loads the org's current tier + entitlements + catalog from GET /api/billing/tier.
// Uses the shared billing apiClient so the active org id is sent via x-org-id and
// the { success, data, error } envelope is unwrapped consistently.
export function useTier(): TierState {
const [data, setData] = useState<TierResponse | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const load = useCallback(async () => {
setLoading(true);
setError(null);
const res = await getJson<TierResponse>("/api/billing/tier");
setLoading(false);
if (!res.success || !res.data) {
setError(res.error ?? "Failed to load tier entitlements.");
return;
}
setData(res.data);
}, []);
useEffect(() => {
load();
}, [load]);
return { data, loading, error, reload: load };
}