-
Notifications
You must be signed in to change notification settings - Fork 419
chore(clerk-js): Prefer popup flow for .lp.dev origins #6686
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
Conversation
🦋 Changeset detectedLatest commit: c393a1a The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughExtends the popup-preferred origin list by adding the .lp.dev suffix in originPrefersPopup(). Updates tests to cover .lp.dev subdomains. Adds a changeset entry to bump @clerk/clerk-js with a patch. No API or signature changes; only a small logic addition and corresponding tests. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant Utils as originPrefersPopup()
Caller->>Utils: Check if popup should be preferred
rect rgba(200,230,255,0.3)
note right of Utils: Evaluate environment
Utils->>Utils: Is in iframe?
alt In iframe
Utils-->>Caller: true
else Not in iframe
Utils->>Utils: Does origin end with any suffix?<br/>(..., .v0.dev, .lp.dev)
alt Matches preferred suffix
Utils-->>Caller: true
else No match
Utils-->>Caller: false
end
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
.changeset/shy-places-grab.md (1)
5-5: Polish the changeset wording.Add the article and brief context.
-Add `.lp.dev` to list of origins that prefer the popup SSO flow. +Add `.lp.dev` to the list of origins that prefer the popup SSO flow (leap.new preview environments).packages/clerk-js/src/ui/utils/originPrefersPopup.ts (2)
19-19: Match against hostname (not origin) to handle ports and SSR safely.Using origin fails when a port is present (e.g., https://app.lp.dev:3000) and throws on SSR. Prefer hostname and guard window.
-export function originPrefersPopup(): boolean { - return inIframe() || POPUP_PREFERRED_ORIGINS.some(origin => window.location.origin.endsWith(origin)); -} +export function originPrefersPopup(): boolean { + const hostname = typeof window !== 'undefined' ? window.location.hostname : ''; + return inIframe() || POPUP_PREFERRED_ORIGINS.some(suffix => hostname.endsWith(suffix)); +}
13-17: Doc comment no longer only about iframes.Reflect that we also prefer popup on specific preview domains.
- * Returns `true` if the current origin is one that is typically embedded via an iframe, which would benefit from the - * popup flow. + * Returns `true` if running in an iframe or the current hostname matches a known preview/embedded domain + * that benefits from the popup flow.packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts (1)
108-114: Good positive coverage for .lp.dev.Consider adding negatives and a port case (will pass after hostname change): apex, lookalikes, and ported origins.
it('should return true for .lp.dev domains', () => { mockLocationOrigin('https://preview.lp.dev'); expect(originPrefersPopup()).toBe(true); mockLocationOrigin('https://app.lp.dev'); expect(originPrefersPopup()).toBe(true); }); + + // Follow-ups (optional): + // - After switching to hostname in impl, add: + // mockLocationOrigin('https://app.lp.dev:3000'); expect(originPrefersPopup()).toBe(true); + // - Negative lookalikes: + // mockLocationOrigin('https://lp.dev'); expect(originPrefersPopup()).toBe(false); + // mockLocationOrigin('https://evil.lp.dev.malicious.com'); expect(originPrefersPopup()).toBe(false); + // mockLocationOrigin('https://app.lp.de'); expect(originPrefersPopup()).toBe(false);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.changeset/shy-places-grab.md(1 hunks)packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts(1 hunks)packages/clerk-js/src/ui/utils/originPrefersPopup.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/utils/originPrefersPopup.tspackages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/utils/originPrefersPopup.tspackages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/utils/originPrefersPopup.tspackages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/utils/originPrefersPopup.tspackages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/utils/originPrefersPopup.tspackages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/utils/originPrefersPopup.tspackages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/utils/originPrefersPopup.tspackages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Visual regression testing should be performed for UI components.
Files:
packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/shy-places-grab.md
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/utils/__tests__/originPrefersPopup.spec.ts (1)
packages/clerk-js/src/ui/utils/originPrefersPopup.ts (1)
originPrefersPopup(18-20)
🪛 LanguageTool
.changeset/shy-places-grab.md
[grammar] ~5-~5: There might be a mistake here.
Context: ...erk/clerk-js': patch --- Add .lp.dev to list of origins that prefer the popup S...
(QB_NEW_EN)
[grammar] ~5-~5: There might be a mistake here.
Context: ... origins that prefer the popup SSO flow.
(QB_NEW_EN)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/clerk-js/src/ui/utils/originPrefersPopup.ts (1)
10-10: Addition of .lp.dev looks good.
Description
Prefer the popup flow for
.lp.devorigins, which are previews for apps generated via leap.new.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit