diff options
author | 2023-08-21 17:06:09 +0000 | |
---|---|---|
committer | 2023-08-21 17:06:09 +0000 | |
commit | 0f1f6590c598d5ae2e25b062bc12515701b69fb5 (patch) | |
tree | 847bc1416a05b7b1e0655b36e304acbab70ff36f /src/tools/jwt-parser/jwt-parser.service.ts | |
parent | 2bcb77a9f950e98c93c57de59a74848f0648ab00 (diff) | |
download | it-tools-0f1f6590c598d5ae2e25b062bc12515701b69fb5.tar.gz it-tools-0f1f6590c598d5ae2e25b062bc12515701b69fb5.tar.zst it-tools-0f1f6590c598d5ae2e25b062bc12515701b69fb5.zip |
chore(deps): removed ts-pattern (#565)
* fix(deps): update dependency ts-pattern to v5
* chore(deps): removed ts-pattern
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
Diffstat (limited to 'src/tools/jwt-parser/jwt-parser.service.ts')
-rw-r--r-- | src/tools/jwt-parser/jwt-parser.service.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/tools/jwt-parser/jwt-parser.service.ts b/src/tools/jwt-parser/jwt-parser.service.ts index 19edc5f..cc39145 100644 --- a/src/tools/jwt-parser/jwt-parser.service.ts +++ b/src/tools/jwt-parser/jwt-parser.service.ts @@ -1,6 +1,5 @@ import jwtDecode, { type JwtHeader, type JwtPayload } from 'jwt-decode'; import _ from 'lodash'; -import { match } from 'ts-pattern'; import { ALGORITHM_DESCRIPTIONS, CLAIM_DESCRIPTIONS } from './jwt-parser.constants'; export { decodeJwt }; @@ -32,10 +31,15 @@ function parseClaims({ claim, value }: { claim: string; value: unknown }) { } function getFriendlyValue({ claim, value }: { claim: string; value: unknown }) { - return match(claim) - .with('exp', 'nbf', 'iat', () => dateFormatter(value)) - .with('alg', () => (_.isString(value) ? ALGORITHM_DESCRIPTIONS[value] : undefined)) - .otherwise(() => undefined); + if (['exp', 'nbf', 'iat'].includes(claim)) { + return dateFormatter(value); + } + + if (claim === 'alg' && _.isString(value)) { + return ALGORITHM_DESCRIPTIONS[value]; + } + + return undefined; } function dateFormatter(value: unknown) { |