Skip to content

Commit 496b263

Browse files
committed
update library for react-router 7
1 parent 1b1d4ca commit 496b263

9 files changed

+66
-542
lines changed

package-lock.json

Lines changed: 48 additions & 529 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"jose": "^5.2.3"
2929
},
3030
"peerDependencies": {
31-
"@remix-run/node": "^2.4.1",
31+
"react-router": "^7.2.0",
3232
"react": "^18.0 || ^19.0.0",
3333
"react-dom": "^18.0 || ^19.0.0"
3434
},

src/authkit-callback-route.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { LoaderFunction } from '@remix-run/node';
1+
import type { LoaderFunction } from 'react-router';
22
import { getWorkOS } from './workos.js';
33
import { authLoader } from './authkit-callback-route.js';
44
import {

src/authkit-callback-route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LoaderFunctionArgs, json, redirect } from '@remix-run/node';
1+
import { LoaderFunctionArgs, data as json, redirect } from 'react-router';
22
import { getConfig } from './config.js';
33
import { HandleAuthOptions } from './interfaces.js';
44
import { encryptSession } from './session.js';

src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SessionStorage, SessionIdStorageStrategy } from '@remix-run/node';
1+
import type { SessionStorage, SessionIdStorageStrategy } from 'react-router';
22
import type { OauthTokens, User } from '@workos-inc/node';
33

44
export interface HandleAuthOptions {

src/session.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LoaderFunctionArgs, Session as RemixSession, redirect } from '@remix-run/node';
1+
import { LoaderFunctionArgs, Session as RemixSession, redirect } from 'react-router';
22
import { AuthenticationResponse } from '@workos-inc/node';
33
import * as ironSession from 'iron-session';
44
import * as jose from 'jose';

src/session.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { LoaderFunctionArgs, SessionData, TypedResponse } from '@remix-run/node';
2-
import { json, redirect } from '@remix-run/node';
1+
import { data as json, redirect, type LoaderFunctionArgs, type SessionData } from 'react-router';
32
import { getAuthorizationUrl } from './get-authorization-url.js';
43
import type { AccessToken, AuthKitLoaderOptions, AuthorizedData, Session, UnauthorizedData } from './interfaces.js';
54
import { getWorkOS } from './workos.js';
@@ -9,6 +8,12 @@ import { createRemoteJWKSet, decodeJwt, jwtVerify } from 'jose';
98
import { getConfig } from './config.js';
109
import { configureSessionStorage, getSessionStorage } from './sessionStorage.js';
1110

11+
// must be a type since this is a subtype of response
12+
// interfaces must conform to the types they extend
13+
export type TypedResponse<T> = Response & {
14+
json(): Promise<T>;
15+
};
16+
1217
async function updateSession(request: Request, debug: boolean) {
1318
const session = await getSessionFromCookie(request.headers.get('Cookie') as string);
1419
const { commitSession, getSession, destroySession } = await getSessionStorage();

src/sessionStorage.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createCookie, createMemorySessionStorage } from '@remix-run/node';
1+
import { createCookie, createMemorySessionStorage } from 'react-router';
22
import { SessionStorageManager, errors } from './sessionStorage.js';
33
import { configure } from './config.js';
44

@@ -81,7 +81,7 @@ describe('SessionStorageManager', () => {
8181
});
8282

8383
describe('storageManager', () => {
84-
type CreateCookieSessionStorageType = (typeof import('@remix-run/node'))['createCookieSessionStorage'];
84+
type CreateCookieSessionStorageType = (typeof import('react-router'))['createCookieSessionStorage'];
8585
let createCookieSessionStorage: jest.MockedFunction<CreateCookieSessionStorageType>;
8686

8787
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -97,16 +97,16 @@ describe('SessionStorageManager', () => {
9797
});
9898

9999
// Mock first, before any imports
100-
jest.doMock('@remix-run/node', () => ({
101-
...jest.requireActual('@remix-run/node'),
100+
jest.doMock('react-router', () => ({
101+
...jest.requireActual('react-router'),
102102
createCookieSessionStorage: jest.fn().mockReturnValue({
103103
getSession: jest.fn(),
104104
commitSession: jest.fn(),
105105
destroySession: jest.fn(),
106106
}),
107107
}));
108108

109-
createCookieSessionStorage = (await import('@remix-run/node'))
109+
createCookieSessionStorage = (await import('react-router'))
110110
.createCookieSessionStorage as jest.MockedFunction<CreateCookieSessionStorageType>;
111111

112112
const { SessionStorageManager } = await import('./sessionStorage.js');

src/sessionStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createCookieSessionStorage, type SessionIdStorageStrategy, type SessionStorage } from '@remix-run/node';
1+
import { createCookieSessionStorage, type SessionIdStorageStrategy, type SessionStorage } from 'react-router';
22
import { getConfig } from './config.js';
33

44
type SessionStorageConfig = { storage?: never; cookieName?: string } | { storage: SessionStorage; cookieName: string };

0 commit comments

Comments
 (0)