-
Notifications
You must be signed in to change notification settings - Fork 417
feat(js,shared,ui): Support needs_client_trust sign-in status
#7430
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: d6e048a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds a "client trust" sign-in step: new Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
needs_client_trust sign-in status
d46a810 to
4427de1
Compare
4427de1 to
e7c5f92
Compare
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: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
integration/presets/envs.ts(2 hunks)integration/presets/longRunningApps.ts(1 hunks)integration/tests/client-trust.test.ts(1 hunks)packages/testing/src/playwright/unstable/page-objects/common.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
All code must pass ESLint checks with the project's configuration
Files:
integration/tests/client-trust.test.tsintegration/presets/envs.tspackages/testing/src/playwright/unstable/page-objects/common.tsintegration/presets/longRunningApps.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
integration/tests/client-trust.test.tsintegration/presets/envs.tspackages/testing/src/playwright/unstable/page-objects/common.tsintegration/presets/longRunningApps.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Follow established naming conventions (PascalCase for components, camelCase for variables)
Files:
integration/tests/client-trust.test.tsintegration/presets/envs.tspackages/testing/src/playwright/unstable/page-objects/common.tsintegration/presets/longRunningApps.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features
Files:
integration/tests/client-trust.test.ts
**/*.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
Files:
integration/tests/client-trust.test.tsintegration/presets/envs.tspackages/testing/src/playwright/unstable/page-objects/common.tsintegration/presets/longRunningApps.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use real Clerk instances for integration tests
Files:
integration/tests/client-trust.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/*.{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
Implement type guards forunknowntypes using the patternfunction isType(value: unknown): value is Type
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details in classes
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like<T extends { id: string }>
Use utility types likeOmit,Partial, andPickfor data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Useconst assertionswithas constfor literal types
Usesatisfiesoperator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...
Files:
integration/tests/client-trust.test.tsintegration/presets/envs.tspackages/testing/src/playwright/unstable/page-objects/common.tsintegration/presets/longRunningApps.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use React Testing Library for component testing
Files:
integration/tests/client-trust.test.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use ESLint with custom configurations tailored for different package types
Files:
integration/tests/client-trust.test.tsintegration/presets/envs.tspackages/testing/src/playwright/unstable/page-objects/common.tsintegration/presets/longRunningApps.ts
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use Prettier for code formatting across all packages
Files:
integration/tests/client-trust.test.tsintegration/presets/envs.tspackages/testing/src/playwright/unstable/page-objects/common.tsintegration/presets/longRunningApps.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/testing/src/playwright/unstable/page-objects/common.ts
packages/**/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
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
Implement proper logging with different levels
Files:
packages/testing/src/playwright/unstable/page-objects/common.ts
🧬 Code graph analysis (2)
integration/tests/client-trust.test.ts (2)
integration/testUtils/index.ts (2)
testAgainstRunningApps(88-88)createTestUtils(24-86)integration/presets/index.ts (1)
appConfigs(14-30)
integration/presets/longRunningApps.ts (2)
integration/presets/next.ts (1)
next(52-59)integration/presets/envs.ts (1)
envs(213-243)
⏰ 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). (25)
- GitHub Check: Integration Tests (machine, chrome, RQ)
- GitHub Check: Integration Tests (machine, chrome)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (billing, chrome, RQ)
- GitHub Check: Integration Tests (quickstart, chrome, 16)
- GitHub Check: Integration Tests (nextjs, chrome, 16)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
- GitHub Check: Integration Tests (handshake:staging, chrome)
- GitHub Check: Integration Tests (quickstart, chrome, 15)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (sessions:staging, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (handshake, chrome)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
packages/testing/src/playwright/unstable/page-objects/common.ts (2)
53-62: Endpoint name is correct and verified.The
attempt_second_factorendpoint name is properly implemented and matches the actual API endpoint paths found inSession.tsand action names throughout the codebase. The addition maintains consistency withattempt_first_factorandattempt_verification.
32-41: Confirm the endpoint name forprepare_second_factoraligns with the actual API implementation.The addition of
prepare_second_factorfollows the established pattern of existing endpoints (prepare_verification,prepare_first_factor). However, since the PR notes indicate "related API changes are not yet live," verify that this endpoint name matches the final API specification when deployed. The naming is logically consistent with Clerk's MFA flow, but explicit confirmation from API documentation would reduce risk of mismatches.integration/tests/client-trust.test.ts (1)
25-62: Nice: good end-to-end coverage of “route + notice + not signed-in + OTP + known device”
The sequence of assertions is solid for validating the newneeds_client_trustrouting/UX.integration/presets/envs.ts (1)
207-212: Verify whether this env also needsCLERK_ENCRYPTION_KEY
Some other env presets setCLERK_ENCRYPTION_KEY; if the client-trust flow or the Next app under test expects it, add it here too.integration/presets/longRunningApps.ts (1)
35-35: LGTM — wiring long-running app to the new env preset looks correct
Description
We're introducing a new status of
needs_client_trust. This will supersede relying onneeds_second_factor&client_trust_state/mapping over second-factors, enabling a more concrete state for the AIO and custom flows to be in.This PR adds the
SignInClientTrustcomponent and, functionally, everything acts largely the same asSignInFactorTwo.The changes are that it ensures that the notice is visible and that only
phone_code,email_code, andemail_linkare available. Most everything outside of that file are navigational additions to ensure that whenneeds_client_trustis returned, we navigate to the correct location.This addition is non-breaking and will be offered, to existing customers, as an opt-in update via the Dashboard.
I also moved out logic shared between three components into a hook:
useSecondFactorSelection.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.