Step 0 of /release: the site's edition table follows a module that changes edition, a module added, a lock set or lifted, whether in ENTITLEMENTS, in FEATURE_TIERS or in a Free page (#369). It names the full key products.simplresultat_detail_desc and gives the commands that spot such a change, run from the repository root: a wide git log -G over src and src-tauri/src outside tests, and a git diff of the two matrix files. A result is a lead to read, not a verdict. From src-tauri/, the pathspecs resolve under src-tauri/: the log loses the front end and the diff comes out empty with exit code 0. The site PR is merged, like it is deployed, only after the release is published, since the site deploys by hand and a PR merged early would leave with the next deploy. Step 9: after VERDICT : OK, merge the site PR, then deploy from the merged main commit. Nothing to deploy for the next release: the site PR that carries the table (la-compagnie-maximus, PR 298) is in production since 2026-10-16 and the matrix is unchanged since v0.17.2. Headers of src/shared/entitlements.ts and src-tauri/src/commands/entitlements.rs point to la-compagnie-maximus/src/data/editions.ts and to the section « Matrice des éditions — Simpl-Résultat » of the site's CLAUDE.md (comments only). Skill frontmatter and changelog updated. Resolves #466 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.6 KiB
TypeScript
67 lines
2.6 KiB
TypeScript
import type { Edition } from "../services/licenseService";
|
|
|
|
/**
|
|
* UI entitlements matrix — single front-end source of truth for feature gating.
|
|
*
|
|
* Keys are kebab-case because the JWT `features[]` array is a namespace shared
|
|
* between the Rust override and this TS layer (cf. `auto-update` string on the
|
|
* Rust side). Enforcement is UI-only (soft-paywall, GPL assumed) — the edition
|
|
* itself is still resolved by the Rust `current_edition()`, from the license key
|
|
* alone since #347 (the activation token binds the key to a machine on the
|
|
* server only).
|
|
*
|
|
* Modules that stay Free (dashboard, import, transactions, categories,
|
|
* reports/trends, export, changelog, docs) have NO key here → never gated as
|
|
* pages. One action inside a Free page is gated: the Répartition (split) button
|
|
* of the Transactions page belongs to `adjustments` (#369, splitGate.ts).
|
|
*
|
|
* The website's edition table copies this matrix
|
|
* (`la-compagnie-maximus/src/data/editions.ts`): report a change there as the
|
|
* site's `CLAUDE.md` says, section « Matrice des éditions — Simpl-Résultat ».
|
|
*/
|
|
export type FeatureKey =
|
|
| "budget"
|
|
| "adjustments"
|
|
| "reports-advanced"
|
|
| "multi-profile"
|
|
| "balance";
|
|
|
|
export const ENTITLEMENTS: Record<FeatureKey, Edition[]> = {
|
|
budget: ["base", "premium"],
|
|
adjustments: ["base", "premium"],
|
|
"reports-advanced": ["base", "premium"],
|
|
"multi-profile": ["base", "premium"],
|
|
balance: ["premium"],
|
|
};
|
|
|
|
/**
|
|
* Pure entitlement check.
|
|
*
|
|
* Fail-closed in Free (CWE-863): a key that no longer validates (invalid or
|
|
* expired) resolves `edition` → "free", yet its JWT still lists signed
|
|
* `features[]`. We must NOT re-grant those features to a license that resolves
|
|
* to free, so the Free short-circuit runs BEFORE the `features[]` override.
|
|
*
|
|
* `licenseFeatures` is the JWT override namespace. An unknown feature (not in
|
|
* the matrix — the namespace is shared with Rust and may drift) is deny-all
|
|
* unless explicitly present in the signed override.
|
|
*/
|
|
export function isEntitled(
|
|
f: FeatureKey,
|
|
edition: Edition,
|
|
licenseFeatures: string[],
|
|
): boolean {
|
|
if (edition === "free") return false;
|
|
const tiers = ENTITLEMENTS[f];
|
|
if (!tiers) return licenseFeatures.includes(f);
|
|
return tiers.includes(edition) || licenseFeatures.includes(f);
|
|
}
|
|
|
|
/**
|
|
* Minimum paid tier that unlocks a feature — drives the upsell copy
|
|
* ("Obtenir Base" vs "Obtenir Premium"). Derived from matrix MEMBERSHIP, not
|
|
* array order, so reordering an ENTITLEMENTS row can never change the answer.
|
|
*/
|
|
export function requiredTierFor(f: FeatureKey): Edition {
|
|
return ENTITLEMENTS[f].includes("base") ? "base" : "premium";
|
|
}
|