Add read-only-auth example for pre-generating authentication tokens #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add read-only-auth example for pre-generating authentication tokens
Summary
Adds a new example in
examples/read-only-auth/that enables users to pre-generate authentication tokens for read-only operations. This addresses the use case where users want to avoid exposing API private keys at runtime.What's included:
setup.py- Configures API key 253 for all accounts associated with an L1 addressgenerate.py- Pre-generates auth tokens at 6-hour intervals with 8-hour expiryREADME.md- Comprehensive documentation with usage examples and security considerationsKey features:
unix_timestamp // (6 * 3600) * (6 * 3600){account_index: {timestamp: token_string}}Review & Testing Checklist for Human
This PR contains untested code that requires end-to-end verification. Please complete the following:
python3 setup.py > config.jsonthenpython3 generate.pyto verify both scripts work correctlyauth-tokens.jsonhave timestamps aligned to 6-hour boundaries (divisible by 21600) and confirm the token lookup logic in README workssetup.pyand confirm that old tokens no longer work (validates the invalidation mechanism)Notes
examples/system_setup.pybut haven't been tested with real Lighter credentials(current_time // (6 * 3600)) * (6 * 3600)is critical - please verify tokens are generated for correct future time periodsasyncio.gather()with error handling, but edge cases might existcreate_auth_token_for_timestamp()is a local wrapper that doesn't modify the SignerClient class as requiredLink to Devin run: https://app.devin.ai/sessions/31ad4881808f461cb48c651583f49ace
Requested by: @alexvelea