Skip to content

Commit

Permalink
Upgrade to jwt-decode@4.0.0, drop ESM workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkopiu committed Jan 18, 2024
1 parent 8c7efa5 commit 2cef8df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
11 changes: 7 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"bottleneck": "^2.19.5",
"expiry-map": "^2.0.0",
"got": "^13.0.0",
"jwt-decode": "^3.1.2",
"jwt-decode": "^4.0.0",
"moment": "^2.29.4",
"p-memoize": "^7.1.1",
"urlify": "^0.3.6"
Expand Down
7 changes: 2 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import got, {
Options,
RequestError,
} from 'got';
import _jwt_decode, { JwtPayload } from 'jwt-decode';
// TODO: Drop workaround when upstream in jwt-decode, context: https://github.com/microsoft/TypeScript/issues/50690#issuecomment-1241464619
const jwt_decode = _jwt_decode as unknown as typeof _jwt_decode.default;

import { jwtDecode, JwtPayload } from 'jwt-decode';
import moment from 'moment';

const CINODE_API_URL = 'https://api.cinode.app';
Expand All @@ -30,7 +27,7 @@ const limiter = new Bottleneck({

function isValidJwtToken(token: string): boolean {
try {
return moment.unix(jwt_decode<JwtPayload>(token).exp || 0).isAfter();
return moment.unix(jwtDecode<JwtPayload>(token).exp || 0).isAfter();
} catch (e) {
return false;
}
Expand Down

0 comments on commit 2cef8df

Please sign in to comment.