-
Notifications
You must be signed in to change notification settings - Fork 424
feat(tanstack-react-start): Add keyless mode support #7518
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
Open
brkalow
wants to merge
13
commits into
main
Choose a base branch
from
brk.feat/keyless-tanstack-start
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f6d652a
abstract out keyless logic into shared, use shared helpers
brkalow 072dc5c
add keyless to tanstack-react-start
brkalow fbea181
initial review
brkalow fc34af4
fix next util
brkalow ff86a23
fix(tanstack-react-start,nextjs): fix lint and test issues
brkalow e8be442
Address PR feedback
brkalow 8511436
adds missing files
brkalow c61d238
Adds changeset
brkalow c9a3576
adds integration test
brkalow 18a8558
fix(integration): use correct tanstack preset name
brkalow 7e41375
fix(integration): resolve multiple React versions and improve keyless…
brkalow a8054d3
use completeOnboarding()
brkalow 57e621a
Remove logs
brkalow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
528 changes: 0 additions & 528 deletions
528
packages/nextjs/src/__tests__/keyless-custom-headers.test.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,10 @@ | ||
| import type { AccountlessApplication } from '@clerk/backend'; | ||
| import { isDevelopmentEnvironment } from '@clerk/shared/utils'; | ||
| // 10 minutes in milliseconds | ||
| const THROTTLE_DURATION_MS = 10 * 60 * 1000; | ||
|
|
||
| function createClerkDevCache() { | ||
| if (!isDevelopmentEnvironment()) { | ||
| return; | ||
| } | ||
|
|
||
| if (!global.__clerk_internal_keyless_logger) { | ||
| global.__clerk_internal_keyless_logger = { | ||
| __cache: new Map<string, { expiresAt: number; data?: unknown }>(), | ||
|
|
||
| log: function ({ cacheKey, msg }) { | ||
| if (this.__cache.has(cacheKey) && Date.now() < (this.__cache.get(cacheKey)?.expiresAt || 0)) { | ||
| return; | ||
| } | ||
|
|
||
| console.log(msg); | ||
|
|
||
| this.__cache.set(cacheKey, { | ||
| expiresAt: Date.now() + THROTTLE_DURATION_MS, | ||
| }); | ||
| }, | ||
| run: async function ( | ||
| callback, | ||
| { cacheKey, onSuccessStale = THROTTLE_DURATION_MS, onErrorStale = THROTTLE_DURATION_MS }, | ||
| ) { | ||
| if (this.__cache.has(cacheKey) && Date.now() < (this.__cache.get(cacheKey)?.expiresAt || 0)) { | ||
| return this.__cache.get(cacheKey)?.data; | ||
| } | ||
|
|
||
| try { | ||
| const result = await callback(); | ||
|
|
||
| this.__cache.set(cacheKey, { | ||
| expiresAt: Date.now() + onSuccessStale, | ||
| data: result, | ||
| }); | ||
| return result; | ||
| } catch (e) { | ||
| this.__cache.set(cacheKey, { | ||
| expiresAt: Date.now() + onErrorStale, | ||
| }); | ||
|
|
||
| throw e; | ||
| } | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| return globalThis.__clerk_internal_keyless_logger; | ||
| } | ||
|
|
||
| export const createKeylessModeMessage = (keys: AccountlessApplication) => { | ||
| return `\n\x1b[35m\n[Clerk]:\x1b[0m You are running in keyless mode.\nYou can \x1b[35mclaim your keys\x1b[0m by visiting ${keys.claimUrl}\n`; | ||
| }; | ||
|
|
||
| export const createConfirmationMessage = () => { | ||
| return `\n\x1b[35m\n[Clerk]:\x1b[0m Your application is running with your claimed keys.\nYou can safely remove the \x1b[35m.clerk/\x1b[0m from your project.\n`; | ||
| }; | ||
|
|
||
| export const clerkDevelopmentCache = createClerkDevCache(); | ||
| /** | ||
| * Re-export keyless development cache utilities from shared. | ||
| * This maintains backward compatibility with existing imports. | ||
| */ | ||
| export { | ||
| clerkDevelopmentCache, | ||
| createClerkDevCache, | ||
| createConfirmationMessage, | ||
| createKeylessModeMessage, | ||
| } from '@clerk/shared/keyless'; |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
fyi dynamic imports should be able to be replaced with static ones with the drop of support for next 13