mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-10 18:56:53 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user