Skip to content

Commit

Permalink
rename cookie to sessionStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
nicknisi committed Feb 2, 2025
1 parent 4b9da3e commit 2e57c56
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/authkit-callback-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HandleAuthOptions } from './interfaces.js';
import { WORKOS_CLIENT_ID } from './env-variables.js';
import { workos } from './workos.js';
import { encryptSession } from './session.js';
import { getSessionStorage } from './cookie.js';
import { getSessionStorage } from './sessionStorage.js';
import { redirect, json, LoaderFunctionArgs } from '@remix-run/node';

export function authLoader(options: HandleAuthOptions = {}) {
Expand Down
14 changes: 5 additions & 9 deletions src/session.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { json, redirect } from '@remix-run/node';
import type { LoaderFunctionArgs, SessionData, TypedResponse } from '@remix-run/node';
import { json, redirect } from '@remix-run/node';
import { WORKOS_CLIENT_ID, WORKOS_COOKIE_PASSWORD } from './env-variables.js';
import type { AccessToken, AuthorizedData, UnauthorizedData, AuthKitLoaderOptions, Session } from './interfaces.js';
import { getAuthorizationUrl } from './get-authorization-url.js';
import type { AccessToken, AuthKitLoaderOptions, AuthorizedData, Session, UnauthorizedData } from './interfaces.js';
import { workos } from './workos.js';

import { sealData, unsealData } from 'iron-session';
import { jwtVerify, createRemoteJWKSet, decodeJwt } from 'jose';
import { configureSessionStorage, getSessionStorage } from './cookie.js';
import { createRemoteJWKSet, decodeJwt, jwtVerify } from 'jose';
import { configureSessionStorage, getSessionStorage } from './sessionStorage.js';

const JWKS = createRemoteJWKSet(new URL(workos.userManagement.getJwksUrl(WORKOS_CLIENT_ID)));

Expand Down Expand Up @@ -86,10 +86,6 @@ type AuthLoader<Data> = (
args: LoaderFunctionArgs & { auth: AuthorizedData | UnauthorizedData },
) => LoaderReturnValue<Data>;

interface AuthKitConfig<Data = unknown> extends AuthKitLoaderOptions {
loader?: AuthLoader<Data> | AuthorizedAuthLoader<Data>;
}

type AuthorizedAuthLoader<Data> = (args: LoaderFunctionArgs & { auth: AuthorizedData }) => LoaderReturnValue<Data>;

async function authkitLoader(
Expand Down Expand Up @@ -300,4 +296,4 @@ function getReturnPathname(url: string): string {
return `${newUrl.pathname}${newUrl.searchParams.size > 0 ? '?' + newUrl.searchParams.toString() : ''}`;
}

export { encryptSession, terminateSession, authkitLoader };
export { authkitLoader, encryptSession, terminateSession };
File renamed without changes.
File renamed without changes.

0 comments on commit 2e57c56

Please sign in to comment.