-
Notifications
You must be signed in to change notification settings - Fork 35
Expire old openrouter key #182
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
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 |
|---|---|---|
|
|
@@ -23,12 +23,19 @@ export function useApiKey() { | |
| if (storedKey) { | ||
| try { | ||
| const keyData = JSON.parse(storedKey); | ||
| // Make sure we have a valid key object | ||
| if (keyData.key && typeof keyData.key === 'string' && keyData.hash) { | ||
| return keyData; // Return the full stored object if valid | ||
| const epochStart = 1753747200000; // 2025-07-29T00:00:00.000Z | ||
|
|
||
| const isValid = keyData.key && typeof keyData.key === 'string' && keyData.hash; | ||
| const isFromBefore = keyData.createdAt && keyData.createdAt < epochStart; | ||
|
|
||
| if (!isValid) { | ||
|
Comment on lines
+28
to
+31
Contributor
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. If Suggestionconst isFromBefore = !keyData.createdAt || keyData.createdAt < epochStart;Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion.
Contributor
Author
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. No, the approach you're proposing is too aggressive. I don't want to delete keys I don't understand. |
||
| throw new Error('Invalid key data'); | ||
| } | ||
| // If key is invalid, remove it | ||
| localStorage.removeItem(storageKey); | ||
| if (isFromBefore) { | ||
| throw new Error('Key is from before the current epoch'); | ||
| } | ||
|
|
||
| return keyData; | ||
| } catch (e) { | ||
| localStorage.removeItem(storageKey); // Corrupted data | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
epochStartis documented in the PR as “today” (2024-07-29) but the timestamp here corresponds to 2025-07-29. Any key created between now and July 2025 will never be rotated, which contradicts the stated goal of expiring older keys.Double-check the intended date; this looks like an off-by-one-year bug that could leave affected users stranded for another year.
Suggestion
Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nobody said 2024. Go back to sleep.