Skip to content

Commit

Permalink
fix: remove left over jwt-decode
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRivers committed Oct 18, 2024
1 parent c3e89c6 commit 7edd1d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/session/getAccessToken.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jwtDecode from 'jwt-decode';
import {sessionManager} from './sessionManager';
import {config} from '../config/index';
import {jwtDecoder} from '@kinde/jwt-decoder';

/**
* @callback getAccessToken
Expand All @@ -17,7 +17,7 @@ import {config} from '../config/index';
// @ts-ignore
export const getAccessTokenFactory = (req, res) => async () => {
try {
return jwtDecode(
return jwtDecoder(
await sessionManager(req, res).getSessionItem('access_token')
);
} catch (err) {
Expand Down
6 changes: 4 additions & 2 deletions src/session/getIdToken.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jwtDecode from 'jwt-decode';
import {sessionManager} from './sessionManager';
import {config} from '../config/index';
import {jwtDecoder} from '@kinde/jwt-decoder';

/**
* @callback getIdToken
Expand All @@ -17,7 +17,9 @@ import {config} from '../config/index';
// @ts-ignore
export const getIdTokenFactory = (req, res) => async () => {
try {
return jwtDecode(await sessionManager(req, res).getSessionItem('id_token'));
return jwtDecoder(
await sessionManager(req, res).getSessionItem('id_token')
);
} catch (err) {
if (config.isDebugMode) {
console.error(err);
Expand Down
22 changes: 12 additions & 10 deletions src/session/getUserOrganizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ export const getUserOrganizationsFactory =
'id_token'
)) as {id: string; name: string}[];

const hasuraOrgCodes = (await kindeClient.getClaimValue(
session,
'x-hasura-org-codes',
'id_token'
)) as string[] ?? [];
const hasuraOrgCodes =
((await kindeClient.getClaimValue(
session,
'x-hasura-org-codes',
'id_token'
)) as string[]) ?? [];

const hasuraOrganizations = (await kindeClient.getClaimValue(
session,
'x-hasura-organizations',
'id_token'
)) as {id: string; name: string}[] ?? [];
const hasuraOrganizations =
((await kindeClient.getClaimValue(
session,
'x-hasura-organizations',
'id_token'
)) as {id: string; name: string}[]) ?? [];

return {
orgCodes: [...userOrgs.orgCodes, ...hasuraOrgCodes],
Expand Down

0 comments on commit 7edd1d2

Please sign in to comment.