Commit b3ce154
Add offline JWT-based license validation system for React on Rails Pro (#1857)
* Add offline JWT-based license validation system for React on Rails Pro
Implements a pure offline license validation system using JWT tokens signed
with RSA-256. No internet connectivity required for validation.
Key features:
- JWT-based licenses verified with embedded public key (RSA-256)
- Offline validation in Ruby gem and Node renderer
- Environment variable or config file support
- Development-friendly (warnings) vs production (errors)
- Zero impact on browser bundle size
- Comprehensive test coverage
Changes:
- Add JWT dependencies (Ruby jwt gem, Node jsonwebtoken)
- Create license validation modules for Ruby and Node
- Integrate validation into Rails context (rorPro field)
- Add license check on Node renderer startup
- Update .gitignore for license file
- Add comprehensive tests for both Ruby and Node
- Create LICENSE_SETUP.md documentation
The system validates licenses at:
1. Ruby gem initialization (Rails startup)
2. Node renderer startup
3. Browser relies on server validation (railsContext.rorPro)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add React on Rails Pro license file to .gitignore in multiple locations
* add needed licence rake tasks
* Require exp field in license validation
* Add tests for required exp field validation
* Require valid license in all environments (dev, test, prod)
Breaking Change: All environments now require valid licenses
* Add license validation on startup for both Rails and Node renderer
* Change license field from 'license_type' to 'plan' and add 'issued_by' support
* Remove obsolete license key file from the dummy config
* Add React on Rails Pro license file to .gitignore and Gemfile.lock
* Fix require statement in license validator spec to use spec_helper
* update yarn.lock
* Fix license validator spec by stubbing Rails.logger and Rails.root
* Fix Node.js license validator tests and disable auto-expiration check
- Add ignoreExpiration: true to jwt.verify() to match Ruby behavior
- Mock process.exit globally in tests to prevent actual exit
- Mock console.error and console.log to suppress test output
- Update all invalid license tests to check process.exit was called
- Simplify file-based license test to use ENV variable
- All 9 Node.js tests now passing
Changes align Node.js validator with Ruby validator:
- Both manually check expiration after disabling auto-check
- Both call exit/raise on invalid licenses
- Both provide consistent error messages
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Remove react_on_rails_pro_licence_valid? and consolidate to react_on_rails_pro?
* Make react_on_rails_pro? actively validate license and remove backward compatibility
* Remove redundant 'before: :load_config_initializers' hook from license validation
* Rename validation methods to use ! convention for exception-throwing
* Update license public key documentation and source URL
* Refactor license validation to remove unnecessary conditional logging
* Refactor LicensePublicKey module documentation for clarity and consistency
* Refactor LicenseValidator to simplify validation logic and remove unnecessary checks
* Refactor Node.js license validator from singleton class to functional pattern
* Enhance license data structure and improve security in license validation
* Refactor validateLicense to void function for clearer API semantics
* Enhance public key update task with local URL handling and add usage instructions
* Enhance ReactOnRailsHelper spec by mocking additional utility methods for improved test coverage
* Enhance pro features context by allowing multiple message stubs for improved test flexibility
* Enhance pro features context by adding support for RSC in immediate hydration
* fix TS problems
* Enhance license validation test by generating a separate key pair for invalid signature scenario
* Refactor license claims in JWT to use standard 'iss' identifier and update related tests for improved clarity and consistency
* Implement license expiration handling with a 1-month grace period for production environments and update related tests for clarity and coverage
* Add license attribution comment and refactor license validation methods for clarity
* Refactor license validation methods to use 'validated_license_data!' for improved clarity and consistency
* Add tests for react_on_rails_attribution_comment to verify Pro and open source license comments
* Add tests for Pro and open source attribution comments in rendered output
* Add tests for single attribution comment inclusion in React on Rails Pro and non-Pro scenarios
* Refactor license evaluation logic and improve error handling for missing license
* Remove unnecessary setup in pro_attribution_comment tests for cleaner context
* Stub ReactOnRailsPro::Utils.pro_attribution_comment for consistent test behavior across all contexts
* Update tests to expect HTML comments instead of script tags for React components
* Stub ReactOnRailsPro::Utils.pro_attribution_comment for consistent test behavior
* Update documentation to clarify license usage and add HTML comment attribution for React on Rails
* Refactor license validation logic to use getValidatedLicenseData and update tests for consistency
* Update grace period message format to use "day(s)" for consistency in attribution comments
---------
Co-authored-by: Claude <[email protected]>1 parent 5edfa62 commit b3ce154
File tree
33 files changed
+2587
-54
lines changed- lib/react_on_rails
- react_on_rails_pro
- lib
- react_on_rails_pro
- packages/node-renderer
- src
- tests
- rakelib
- spec
- dummy
- spec/helpers
- execjs-compatible-dummy
- react_on_rails_pro
- spec
- dummy/spec
- helpers
- system
- react_on_rails/react_component
33 files changed
+2587
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
68 | | - | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
627 | 640 | | |
628 | 641 | | |
629 | 642 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
236 | 244 | | |
237 | 245 | | |
238 | 246 | | |
| |||
246 | 254 | | |
247 | 255 | | |
248 | 256 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | 257 | | |
265 | 258 | | |
266 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
0 commit comments