Upgrade to Remix Auth v4 for React Router 7#8
Open
ttpss930141011 wants to merge 11 commits into
Open
Conversation
…newest remix-auth-strategy-template - Upgrade to ESM module - Update package dependencies - Refactor project structure - Add new build and quality scripts - Update Node.js engine requirement to >=20.0.0 - Switch to new authentication library (arctic) - Add type exports and sideEffects configuration
…y following the newest remix-auth-strategy-template - Add Biome.json for linting and formatting - Update ESLint configuration - Modify TypeScript configuration - Add TypeDoc configuration - Create exports validation script
…ion approach - Migrate from OAuth2Strategy to custom Strategy implementation - Add comprehensive authentication flow with state management - Implement token refresh and improved error handling - Update type definitions and constructor options - Add debug logging and more robust profile retrieval
- Add console logging for better script visibility and debugging - Modify entrypoint detection to target 'remix-auth-linkedin' - Include more informative console output for export problems - Improve error handling and script flow
- Integrate Arctic's LinkedIn OAuth client for improved authentication - Simplify token exchange and validation logic - Add support for generating state and handling OAuth errors - Update type definitions and method implementations - Enhance debug logging and error handling
- Migrate from Jest to Bun test framework - Update fetch mocking to handle dynamic URL inputs - Enhance scope and state validation tests - Improve token refresh test with more realistic mock - Simplify test assertions and error handling checks - Replace global fetch with more flexible mocking approach
- Implement robust callback route for LinkedIn authentication - Add comprehensive error handling and parameter validation - Improve session creation and user authentication flow - Update token retrieval methods to handle potential undefined tokens - Enhance redirect logic with detailed error scenarios
- Update package.json to include multiple authors
4505475 to
0ce98d3
Compare
- Update GitHub workflows to use Node.js 20 - Replace npm test with bun test in CI pipeline - Add Bun setup for testing and quality checks - Update publish workflow with npm pkg fix and automation token
|
Hello, I wanted to check on the status of this PR. Could you provide an update on when we might expect the merge to be completed? Looking forward to this. |
Author
During the time for waiting review, I've push this version to npm for my personal development work. Welcome to take it a try. |
|
Thank you! It works like a charm. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Upgrade to Remix Auth v4 for React Router 7
This PR upgrades the LinkedIn strategy to support Remix Auth v4 and React Router 7, bringing major improvements and modern architecture.
Key Changes
API Changes
clientID→clientIdclientSecret(unchanged)callbackURL→redirectURIscope→scopes(array or string){ profile, tokens, request }objecttokens.accessToken()andtokens.refreshToken()Migration Example (v2.x to v3.x)
new LinkedInStrategy( { - clientID: "YOUR_CLIENT_ID", + clientId: "YOUR_CLIENT_ID", - callbackURL: "https://example.com/callback", + redirectURI: "https://example.com/callback", - scope: "r_emailaddress r_liteprofile", + scopes: "r_emailaddress r_liteprofile", }, - async ({ accessToken, refreshToken, profile }) => { + async ({ profile, tokens }) => { return { ...user, - accessToken, + accessToken: tokens.accessToken(), - refreshToken, + refreshToken: tokens.refreshToken ? tokens.refreshToken() : null, }; } )Routes must now manually handle session management:
export async function loader({ request }) { - return authenticator.authenticate("linkedin", request, { - successRedirect: "/dashboard", - failureRedirect: "/login", - }); + try { + const user = await authenticator.authenticate("linkedin", request); + const session = await sessionStorage.getSession(request.headers.get("cookie")); + session.set("user", user); + const headers = new Headers(); + headers.append("Set-Cookie", await sessionStorage.commitSession(session)); + return redirect("/dashboard", { headers }); + } catch (error) { + return redirect("/login?error=auth_failed"); + } }Version Compatibility
Issue
#6