You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@workos-inc/authkit-remix

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workos-inc/authkit-remix - npm Package Compare versions

Comparing version

to
0.7.0

17

dist/cjs/authkit-callback-route.js

@@ -11,3 +11,3 @@ "use strict";

return async function loader({ request }) {
const { returnPathname: returnPathnameOption = '/' } = options;
const { returnPathname: returnPathnameOption = '/', onSuccess } = options;
const url = new URL(request.url);

@@ -39,4 +39,5 @@ const code = url.searchParams.get('code');

}
// The refreshToken and oauthTokens should never be accesible publicly, hence why we encrypt it in the cookie session
// Alternatively you could persist the refresh token in a backend database
// The refreshToken should never be accesible publicly, hence why we encrypt it
// in the cookie session. Alternatively you could persist the refresh token in a
// backend database.
const encryptedSession = await (0, session_js_1.encryptSession)({

@@ -47,3 +48,2 @@ accessToken,

impersonator,
oauthTokens,
headers: {},

@@ -54,2 +54,11 @@ });

const cookie = await (0, cookie_js_1.commitSession)(session);
if (onSuccess) {
await onSuccess({
accessToken,
impersonator: impersonator !== null && impersonator !== void 0 ? impersonator : null,
oauthTokens: oauthTokens !== null && oauthTokens !== void 0 ? oauthTokens : null,
refreshToken,
user,
});
}
return (0, node_1.redirect)(url.toString(), {

@@ -56,0 +65,0 @@ headers: {

import { OauthTokens, User } from '@workos-inc/node';
export interface HandleAuthOptions {
returnPathname?: string;
onSuccess?: (data: AuthLoaderSuccessData) => void | Promise<void>;
}
export interface AuthLoaderSuccessData {
accessToken: string;
impersonator: Impersonator | null;
oauthTokens: OauthTokens | null;
refreshToken: string;
user: User;
}
export interface Impersonator {

@@ -14,3 +22,2 @@ email: string;

impersonator?: Impersonator;
oauthTokens?: OauthTokens;
headers: Record<string, string>;

@@ -42,3 +49,2 @@ }

impersonator: Impersonator | null;
oauthTokens: OauthTokens | null;
sealedSession: string;

@@ -55,4 +61,3 @@ }

impersonator: null;
oauthTokens: null;
sealedSession: null;
}

@@ -39,3 +39,2 @@ "use strict";

impersonator: session.impersonator,
oauthTokens: session.oauthTokens,
headers: {},

@@ -67,3 +66,3 @@ };

async function authkitLoader(loaderArgs, loaderOrOptions, options = {}) {
var _a, _b;
var _a;
const loader = typeof loaderOrOptions === 'function' ? loaderOrOptions : undefined;

@@ -87,3 +86,2 @@ const { ensureSignedIn = false, debug = false } = typeof loaderOrOptions === 'object' ? loaderOrOptions : options;

impersonator: null,
oauthTokens: null,
organizationId: null,

@@ -109,3 +107,2 @@ permissions: null,

impersonator: (_a = session.impersonator) !== null && _a !== void 0 ? _a : null,
oauthTokens: (_b = session.oauthTokens) !== null && _b !== void 0 ? _b : null,
sealedSession: cookieSession.get('jwt'),

@@ -112,0 +109,0 @@ };

@@ -6,3 +6,3 @@ "use strict";

const env_variables_js_1 = require("./env-variables.js");
const VERSION = '0.6.0';
const VERSION = '0.7.0';
const options = {

@@ -9,0 +9,0 @@ apiHostname: env_variables_js_1.WORKOS_API_HOSTNAME,

{
"name": "@workos-inc/authkit-remix",
"version": "0.6.0",
"version": "0.7.0",
"description": "Authentication and session helpers for using WorkOS & AuthKit with Remix",

@@ -5,0 +5,0 @@ "sideEffects": false,

@@ -69,2 +69,12 @@ # AuthKit Remix Library

If your application needs to persist `oauthTokens` or other auth-related information after the callback is successful, you can pass an `onSuccess` option:
```ts
export const loader = authLoader({
onSuccess: async ({ oauthTokens }) => {
await saveToDatabase(oauthTokens);
},
});
```
## Usage

@@ -84,6 +94,5 @@

export function App() {
// Retrieves the user from the session or returns `null` if no user is signed in
// Other supported values include sessionId, accessToken, organizationId,
// role, permissions, entitlements, impersonator and oauthTokens
// Other supported values include `sessionId`, `accessToken`, `organizationId`,
// `role`, `permissions`, `entitlements`, and `impersonator`.
const { user, signInUrl, signUpUrl } = useLoaderData<typeof loader>();

@@ -120,3 +129,2 @@

export default function HomePage() {
const { user, signInUrl, signUpUrl } = useLoaderData<typeof loader>();

@@ -123,0 +131,0 @@

@@ -10,3 +10,3 @@ import { HandleAuthOptions } from './interfaces.js';

return async function loader({ request }: LoaderFunctionArgs) {
const { returnPathname: returnPathnameOption = '/' } = options;
const { returnPathname: returnPathnameOption = '/', onSuccess } = options;

@@ -21,6 +21,7 @@ const url = new URL(request.url);

try {
const { accessToken, refreshToken, user, impersonator, oauthTokens } = await workos.userManagement.authenticateWithCode({
clientId: WORKOS_CLIENT_ID,
code,
});
const { accessToken, refreshToken, user, impersonator, oauthTokens } =
await workos.userManagement.authenticateWithCode({
clientId: WORKOS_CLIENT_ID,
code,
});

@@ -46,4 +47,5 @@ // Clean up params

// The refreshToken and oauthTokens should never be accesible publicly, hence why we encrypt it in the cookie session
// Alternatively you could persist the refresh token in a backend database
// The refreshToken should never be accesible publicly, hence why we encrypt it
// in the cookie session. Alternatively you could persist the refresh token in a
// backend database.
const encryptedSession = await encryptSession({

@@ -54,3 +56,2 @@ accessToken,

impersonator,
oauthTokens,
headers: {},

@@ -64,2 +65,12 @@ });

if (onSuccess) {
await onSuccess({
accessToken,
impersonator: impersonator ?? null,
oauthTokens: oauthTokens ?? null,
refreshToken,
user,
});
}
return redirect(url.toString(), {

@@ -66,0 +77,0 @@ headers: {

@@ -5,4 +5,13 @@ import { OauthTokens, User } from '@workos-inc/node';

returnPathname?: string;
onSuccess?: (data: AuthLoaderSuccessData) => void | Promise<void>;
}
export interface AuthLoaderSuccessData {
accessToken: string;
impersonator: Impersonator | null;
oauthTokens: OauthTokens | null;
refreshToken: string;
user: User;
}
export interface Impersonator {

@@ -18,3 +27,2 @@ email: string;

impersonator?: Impersonator;
oauthTokens?: OauthTokens;
headers: Record<string, string>;

@@ -50,3 +58,2 @@ }

impersonator: Impersonator | null;
oauthTokens: OauthTokens | null;
sealedSession: string;

@@ -64,4 +71,3 @@ }

impersonator: null;
oauthTokens: null;
sealedSession: null;
}

@@ -45,3 +45,2 @@ import { json, redirect } from '@remix-run/node';

impersonator: session.impersonator,
oauthTokens: session.oauthTokens,
headers: {},

@@ -134,3 +133,2 @@ };

impersonator: null,
oauthTokens: null,
organizationId: null,

@@ -166,3 +164,2 @@ permissions: null,

impersonator: session.impersonator ?? null,
oauthTokens: session.oauthTokens ?? null,
sealedSession: cookieSession.get('jwt'),

@@ -169,0 +166,0 @@ };

import { WorkOS } from '@workos-inc/node';
import { WORKOS_API_HOSTNAME, WORKOS_API_HTTPS, WORKOS_API_KEY, WORKOS_API_PORT } from './env-variables.js';
const VERSION = '0.6.0';
const VERSION = '0.7.0';

@@ -6,0 +6,0 @@ const options = {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet