Skip to content
Myr

chore: fix typo in error class name (#393)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* chore: fix type in error class name * chore: update usages in other places

authored by Roman Hotsiy · committed by GitHub · parent ecfc81f · Browse files · 5 files+25 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+25 added−13 removed

  • tests:+5 added−5 removed
  • other:+20 added−8 removed

5 files+25 added−13 removed

modified:deno_dist/utils/jwt/jwt.ts+2 added-2 removed
modified:deno_dist/utils/jwt/types.ts+8 added-2 removed
modified:src/utils/jwt/jwt.test.ts+5 added-5 removed
1 unmodified line
2import * as JWT from './jwt'3import {4 AlgorithmTypes,5 JwtTokenSignatureMismatched,6 JwtAlorithmNotImplemented,6 JwtAlgorithmNotImplemented,7 JwtTokenInvalid,8 JwtTokenNotBefore,9 JwtTokenExpired,10} from './types'1112describe('JWT', () => {13 it('JwtAlorithmNotImplemented', async () => {13 it('JwtAlgorithmNotImplemented', async () => {14 const payload = { message: 'hello world' }15 const secret = 'a-secret'16 const alg = ''17 let tok = ''18 let err: JwtAlorithmNotImplemented18 let err: JwtAlgorithmNotImplemented19 try {20 tok = await JWT.sign(payload, secret, alg as AlgorithmTypes)21 } catch (e) {22 err = e as JwtAlorithmNotImplemented22 err = e as JwtAlgorithmNotImplemented23 }24 expect(tok).toBe('')25 // @ts-ignore26 expect(err).toEqual(new JwtAlorithmNotImplemented(alg))26 expect(err).toEqual(new JwtAlgorithmNotImplemented(alg))27 })2829 it('JwtTokenInvalid', async () => {30 const tok = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXNzYWdlIjoiaGVsbG8gd29ybGQifQ'
143 unmodified lines
modified:src/utils/jwt/jwt.ts+2 added-2 removed
8 unmodified lines
9 JwtTokenInvalid,10 JwtTokenNotBefore,11 JwtTokenExpired,12 JwtTokenSignatureMismatched,13 JwtAlorithmNotImplemented,13 JwtAlgorithmNotImplemented,14} from './types'1516interface AlgorithmParams {17 name: string
44 unmodified lines
62 name: 'SHA-512',63 },64 }65 default:66 throw new JwtAlorithmNotImplemented(name)66 throw new JwtAlgorithmNotImplemented(name)67 }68}6970const signing = async (
75 unmodified lines
modified:src/utils/jwt/types.ts+8 added-2 removed
1export class JwtAlorithmNotImplemented extends Error {1export class JwtAlgorithmNotImplemented extends Error {2 constructor(token: string) {3 super(`invalid JWT token: ${token}`)4 this.name = 'JwtAlorithmNotImplemented'4 this.name = 'JwtAlgorithmNotImplemented'5 }6}78/**9 * Export for backward compatibility10 * @deprecated Use JwtAlgorithmNotImplemented instead11**/12export const JwtAlorithmNotImplemented = JwtAlgorithmNotImplemented1314export class JwtTokenInvalid extends Error {15 constructor(token: string) {16 super(`invalid JWT token: ${token}`)17 this.name = 'JwtTokenInvalid'
30 unmodified lines