-
Notifications
You must be signed in to change notification settings - Fork 3
Upgrade to Remix Auth v4 for React Router 7 #8
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
base: main
Are you sure you want to change the base?
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. |
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. |
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