feat(license): distributed license enforcement across multi-node setups (#359)

* feat(license): distributed license enforcement across multi-node setups

The primary instance's license tier is now asserted to remote nodes on
every proxied HTTP and WebSocket request via trusted headers. Remote
nodes honor the assertion only when the request carries a valid
node_proxy JWT, preventing unauthorized elevation from browsers or API
tokens. Falls back to local license tier for direct access.

* fix(test): remove unused vi import in distributed-license tests
This commit is contained in:
Anso
2026-04-03 11:31:14 -04:00
committed by GitHub
parent 9e87e14d62
commit 6c26ae3f50
7 changed files with 324 additions and 9 deletions
+15
View File
@@ -7,6 +7,21 @@ export type LicenseStatus = 'community' | 'trial' | 'active' | 'expired' | 'disa
export type LicenseVariant = 'personal' | 'team' | null;
const VALID_TIERS: readonly string[] = ['community', 'pro'] satisfies readonly LicenseTier[];
const VALID_VARIANTS: readonly string[] = ['personal', 'team'] satisfies readonly LicenseVariant[];
export function isLicenseTier(value: unknown): value is LicenseTier {
return typeof value === 'string' && (VALID_TIERS as readonly string[]).includes(value);
}
export function isLicenseVariant(value: unknown): value is Exclude<LicenseVariant, null> {
return typeof value === 'string' && (VALID_VARIANTS as readonly string[]).includes(value);
}
/** Header names used for Distributed License Enforcement between nodes. */
export const PROXY_TIER_HEADER = 'x-sencho-tier';
export const PROXY_VARIANT_HEADER = 'x-sencho-variant';
export interface LicenseInfo {
tier: LicenseTier;
status: LicenseStatus;