Skip to content

Commit

Permalink
Merge pull request #31 from kinde-oss/leo/refresh_decode
Browse files Browse the repository at this point in the history
fix: prevent trying to decode refresh token
  • Loading branch information
DaveOrDead authored Nov 17, 2023
2 parents d69ee34 + eb396a5 commit 699fe0b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/__tests__/sdk/oauth2-flows/ClientCredentials.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ describe('ClientCredentials', () => {
it('commits access token to memory, when a new one is fetched', async () => {
const mockAccessToken = mocks.getMockAccessToken(clientConfig.authDomain);
mocks.fetchClient.mockResolvedValue({
json: () => ({ access_token: mockAccessToken }),
json: () => ({ access_token: mockAccessToken.token }),
});

const client = new ClientCredentials(clientConfig);
await client.getToken(sessionManager);
expect(mocks.fetchClient).toHaveBeenCalledTimes(1);
expect(await sessionManager.getSessionItem('access_token')).toBe(
mockAccessToken
mockAccessToken.token
);
});
});
Expand Down
3 changes: 2 additions & 1 deletion lib/sdk/utilities/token-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ export const commitTokenToMemory = async (
token: string,
type: TokenType
): Promise<void> => {
const tokenPayload = jwtDecode(token);
await sessionManager.setSessionItem(type, token);
if (type === 'access_token') {
const tokenPayload = jwtDecode(token);
await sessionManager.setSessionItem('access_token_payload', tokenPayload);
} else if (type === 'id_token') {
const tokenPayload = jwtDecode(token);
await sessionManager.setSessionItem('id_token_payload', tokenPayload);
await commitUserToMemoryFromToken(sessionManager, token);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinde-oss/kinde-typescript-sdk",
"version": "2.2.4",
"version": "2.3.0",
"description": "Kinde Typescript SDK",
"main": "dist-cjs/index.js",
"module": "dist/index.js",
Expand Down

0 comments on commit 699fe0b

Please sign in to comment.