-
-
Notifications
You must be signed in to change notification settings - Fork 632
Remove Pro license key-file fallback and add migration guidance #2454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4a06a7c
d3e8763
9d67759
7ab5be3
d980b88
039b06e
1608a94
1227dd9
2bd6c08
b5f209a
e825c05
4c7aa53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,4 @@ | ||||||||||||
| import * as jwt from 'jsonwebtoken'; | ||||||||||||
| import * as fs from 'fs'; | ||||||||||||
| import * as path from 'path'; | ||||||||||||
| import { PUBLIC_KEY } from './licensePublicKey.js'; | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
|
|
@@ -54,39 +52,24 @@ export type LicenseStatus = 'valid' | 'expired' | 'invalid' | 'missing'; | |||||||||||
| // intentional - license validation happens once per worker on first access, and | ||||||||||||
| // the result is cached for the lifetime of that worker process. | ||||||||||||
| // | ||||||||||||
| // The caching here is deterministic - given the same environment/config file, every | ||||||||||||
| // The caching here is deterministic - given the same environment variable value, every | ||||||||||||
| // worker will compute the same cached values. Redundant computation across workers | ||||||||||||
| // is acceptable since license validation is infrequent (once per worker startup). | ||||||||||||
| let cachedLicenseStatus: LicenseStatus | undefined; | ||||||||||||
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The This inconsistency works today only because
Suggested change
And update |
||||||||||||
| let cachedLicenseOrganization: string | undefined; | ||||||||||||
| let cachedLicensePlan: ValidPlan | undefined; | ||||||||||||
| const UNINITIALIZED = Symbol('uninitialized'); | ||||||||||||
| let cachedLicenseOrganization: string | undefined | typeof UNINITIALIZED = UNINITIALIZED; | ||||||||||||
| let cachedLicensePlan: ValidPlan | undefined | typeof UNINITIALIZED = UNINITIALIZED; | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Loads the license string from environment variable or config file. | ||||||||||||
| * Loads the license string from environment variable. | ||||||||||||
| * @returns License string or undefined if not found | ||||||||||||
| * @private | ||||||||||||
| */ | ||||||||||||
| function loadLicenseString(): string | undefined { | ||||||||||||
| // First try environment variable | ||||||||||||
| const envLicense = process.env.REACT_ON_RAILS_PRO_LICENSE?.trim(); | ||||||||||||
| if (envLicense) { | ||||||||||||
| return envLicense; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Then try config file (relative to project root) | ||||||||||||
| try { | ||||||||||||
| const configPath = path.join(process.cwd(), 'config', 'react_on_rails_pro_license.key'); | ||||||||||||
| if (fs.existsSync(configPath)) { | ||||||||||||
| const content = fs.readFileSync(configPath, 'utf8').trim(); | ||||||||||||
| if (content) { | ||||||||||||
| return content; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| } catch { | ||||||||||||
| // File read error - return undefined to indicate missing license | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| return undefined; | ||||||||||||
| // `|| undefined` converts an empty/whitespace-only env var to undefined, | ||||||||||||
| // so it is reported as 'missing' rather than 'invalid'. | ||||||||||||
| return envLicense || undefined; | ||||||||||||
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is slightly inaccurate:
Suggested change
|
||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
|
|
@@ -251,7 +234,7 @@ function determineLicenseOrganization(): string | undefined { | |||||||||||
| * @returns The organization name or undefined if not available | ||||||||||||
| */ | ||||||||||||
| export function getLicenseOrganization(): string | undefined { | ||||||||||||
| if (cachedLicenseOrganization !== undefined) { | ||||||||||||
| if (cachedLicenseOrganization !== UNINITIALIZED) { | ||||||||||||
| return cachedLicenseOrganization; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
@@ -289,7 +272,7 @@ function determineLicensePlan(): ValidPlan | undefined { | |||||||||||
| * @returns The plan type (e.g., "paid", "startup") or undefined if not available | ||||||||||||
| */ | ||||||||||||
| export function getLicensePlan(): ValidPlan | undefined { | ||||||||||||
| if (cachedLicensePlan !== undefined) { | ||||||||||||
| if (cachedLicensePlan !== UNINITIALIZED) { | ||||||||||||
| return cachedLicensePlan; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
@@ -302,6 +285,6 @@ export function getLicensePlan(): ValidPlan | undefined { | |||||||||||
| */ | ||||||||||||
| export function reset(): void { | ||||||||||||
| cachedLicenseStatus = undefined; | ||||||||||||
| cachedLicenseOrganization = undefined; | ||||||||||||
| cachedLicensePlan = undefined; | ||||||||||||
| cachedLicenseOrganization = UNINITIALIZED; | ||||||||||||
| cachedLicensePlan = UNINITIALIZED; | ||||||||||||
| } | ||||||||||||
Uh oh!
There was an error while loading. Please reload this page.