From f07c35dfbe45d7bf8d57adfcbd5840e1f2bedff9 Mon Sep 17 00:00:00 2001 From: Aaron Tainter Date: Wed, 17 Sep 2025 16:27:59 -0700 Subject: [PATCH 1/2] Add roles from jwt payload --- .gitignore | 1 + src/provider.tsx | 3 +++ src/state.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 8225baa..af5c3ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /node_modules /dist +.idea diff --git a/src/provider.tsx b/src/provider.tsx index 375fdd4..56630cc 100644 --- a/src/provider.tsx +++ b/src/provider.tsx @@ -43,6 +43,7 @@ export function AuthKitProvider(props: AuthKitProviderProps) { } = response; const { role = null, + roles = null, permissions = [], feature_flags: featureFlags = [], } = getClaims(accessToken); @@ -52,6 +53,7 @@ export function AuthKitProvider(props: AuthKitProviderProps) { user, organizationId, role, + roles, permissions, featureFlags, impersonator, @@ -117,6 +119,7 @@ function isEquivalentWorkOSSession( a.user?.updatedAt === b.user?.updatedAt && a.organizationId === b.organizationId && a.role === b.role && + a.roles === b.roles && a.permissions.length === b.permissions.length && a.permissions.every((perm, i) => perm === b.permissions[i]) && a.featureFlags.length === b.featureFlags.length && diff --git a/src/state.ts b/src/state.ts index 22c186f..a030451 100644 --- a/src/state.ts +++ b/src/state.ts @@ -9,6 +9,7 @@ export interface State { isLoading: boolean; user: User | null; role: string | null; + roles: string[] | null; organizationId: string | null; permissions: string[]; featureFlags: string[]; @@ -19,6 +20,7 @@ export const initialState: State = { isLoading: true, user: null, role: null, + roles: null, organizationId: null, permissions: [], featureFlags: [], From 7153e17248720aec23cecf0b6150d3bdfc8f59e4 Mon Sep 17 00:00:00 2001 From: Aaron Tainter Date: Wed, 17 Sep 2025 16:39:04 -0700 Subject: [PATCH 2/2] Bump @workos-inc/authkit-js to 0.14.0 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index af12dc7..6179333 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.12.0", "license": "MIT", "dependencies": { - "@workos-inc/authkit-js": "0.13.0" + "@workos-inc/authkit-js": "0.14.0" }, "devDependencies": { "@types/react": "18.3.3", @@ -794,9 +794,9 @@ } }, "node_modules/@workos-inc/authkit-js": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@workos-inc/authkit-js/-/authkit-js-0.13.0.tgz", - "integrity": "sha512-iA0Dt7D1BmY2/1s4oeA36W/aRt8/b5iyH6rP4AlgnjrcH2lUGkBgDXL76NXc0M7repkDQTMcJJ2NhCSo2rcWmg==" + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@workos-inc/authkit-js/-/authkit-js-0.14.0.tgz", + "integrity": "sha512-Wt6rKoZdZnuAgiEBlvMDKhleU9DAwpyyy1SibacrnOWQgF4rcNlC+NTnHiiXu6OiOjQo6pPxhW42kCL+Gi+fjw==" }, "node_modules/acorn": { "version": "8.12.1", diff --git a/package.json b/package.json index d3465f0..419666e 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "react": ">=17" }, "dependencies": { - "@workos-inc/authkit-js": "0.13.0" + "@workos-inc/authkit-js": "0.14.0" } }