Skip to content

Commit 79794aa

Browse files
author
Paul Asjes
authored
Adds the sealed session to the auth data (#21)
* Adds the sealed session to the auth data * Also fix error in readme
1 parent a2c0225 commit 79794aa

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Sometimes it is useful to obtain the access token directly, for instance to make
152152
```tsx
153153
import type { LoaderFunctionArgs } from '@remix-run/node';
154154
import { json } from '@remix-run/node';
155-
import { withAuth } from '@workos-inc/authkit-remix';
155+
import { authkitLoader } from '@workos-inc/authkit-remix';
156156

157157
export const loader = (args: LoaderFunctionArgs) =>
158158
authkitLoader(args, async ({ auth }) => {

src/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface AuthorizedData {
4242
role: string | null;
4343
permissions: string[];
4444
impersonator: Impersonator | null;
45+
sealedSession: string;
4546
}
4647

4748
export interface UnauthorizedData {
@@ -52,4 +53,5 @@ export interface UnauthorizedData {
5253
role: null;
5354
permissions: null;
5455
impersonator: null;
56+
sealedSession: null;
5557
}

src/session.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ async function authkitLoader<Data = unknown>(
133133
permissions: null,
134134
role: null,
135135
sessionId: null,
136+
sealedSession: null,
136137
};
137138

138139
return await handleAuthLoader(loader, loaderArgs, auth);
@@ -145,6 +146,8 @@ async function authkitLoader<Data = unknown>(
145146
permissions = [],
146147
} = getClaimsFromAccessToken(session.accessToken);
147148

149+
const cookieSession = await getSession(request.headers.get('Cookie'));
150+
148151
const auth: AuthorizedData = {
149152
user: session.user,
150153
sessionId,
@@ -153,6 +156,7 @@ async function authkitLoader<Data = unknown>(
153156
role,
154157
permissions,
155158
impersonator: session.impersonator ?? null,
159+
sealedSession: cookieSession.get('jwt'),
156160
};
157161

158162
return await handleAuthLoader(loader, loaderArgs, auth, session);

0 commit comments

Comments
 (0)