Skip to content

Commit

Permalink
Merge pull request #103 from kinde-oss/peter/remove-payload
Browse files Browse the repository at this point in the history
fix: remove payload cookies
  • Loading branch information
peterphanouvong authored Dec 8, 2023
2 parents 2008241 + 369578e commit bd9a7e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/handlers/setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import jwtDecode from 'jwt-decode';
import RouterClient from '../routerClients/RouterClient';

/**
Expand All @@ -8,17 +9,17 @@ import RouterClient from '../routerClients/RouterClient';
export const setup = async (routerClient) => {
const user = await routerClient.sessionManager.getSessionItem('user');
if (user) {
const accessToken = await routerClient.sessionManager.getSessionItem(
'access_token_payload'
const accessTokenEncoded = await routerClient.sessionManager.getSessionItem(
'access_token'
);

const idToken = await routerClient.sessionManager.getSessionItem(
'id_token_payload'
const idTokenEncoded = await routerClient.sessionManager.getSessionItem(
'id_token'
);

const accessTokenEncoded = await routerClient.sessionManager.getSessionItem(
'access_token'
);
const accessToken = jwtDecode(accessTokenEncoded);

const idToken = jwtDecode(idTokenEncoded);

const permissions = await routerClient.kindeClient.getClaimValue(
routerClient.sessionManager,
Expand Down
5 changes: 4 additions & 1 deletion src/session/getAccessToken.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import jwtDecode from 'jwt-decode';
import {sessionManager} from './sessionManager';

/**
Expand All @@ -14,5 +15,7 @@ import {sessionManager} from './sessionManager';
*/
// @ts-ignore
export const getAccessTokenFactory = (req, res) => async () => {
return await sessionManager(req, res).getSessionItem('access_token_payload');
return jwtDecode(
await sessionManager(req, res).getSessionItem('access_token')
);
};
3 changes: 2 additions & 1 deletion src/session/getIdToken.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import jwtDecode from 'jwt-decode';
import {sessionManager} from './sessionManager';

/**
Expand All @@ -14,5 +15,5 @@ import {sessionManager} from './sessionManager';

// @ts-ignore
export const getIdTokenFactory = (req, res) => async () => {
return await sessionManager(req, res).getSessionItem('id_token_payload');
return jwtDecode(await sessionManager(req, res).getSessionItem('id_token'));
};

0 comments on commit bd9a7e6

Please sign in to comment.