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
Provenance
- Commit
c63d7ed- Tree
d6f7a38- Author
Roman Hotsiy <gotsijroman@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
ecfc81f
5 files changed+25 added−13 removed
modified:deno_dist/utils/jwt/jwt.ts+2 added-2 removed
8 unmodified lines910111213131415161744 unmodified lines6263646566666768697075 unmodified lines8 unmodified lines JwtTokenInvalid, JwtTokenNotBefore, JwtTokenExpired, JwtTokenSignatureMismatched, JwtAlorithmNotImplemented, JwtAlgorithmNotImplemented,} from './types.ts'
interface AlgorithmParams { name: string44 unmodified lines name: 'SHA-512', }, } default: throw new JwtAlorithmNotImplemented(name) throw new JwtAlgorithmNotImplemented(name) }}
const signing = async (75 unmodified linesmodified:deno_dist/utils/jwt/types.ts+8 added-2 removed
11234456789101112131415161730 unmodified linesexport class JwtAlorithmNotImplemented extends Error {export class JwtAlgorithmNotImplemented extends Error { constructor(token: string) { super(`invalid JWT token: ${token}`) this.name = 'JwtAlorithmNotImplemented' this.name = 'JwtAlgorithmNotImplemented' }}
/** * Export for backward compatibility * @deprecated Use JwtAlgorithmNotImplemented instead**/export const JwtAlorithmNotImplemented = JwtAlgorithmNotImplemented
export class JwtTokenInvalid extends Error { constructor(token: string) { super(`invalid JWT token: ${token}`) this.name = 'JwtTokenInvalid'30 unmodified linesmodified:src/utils/jwt/jwt.test.ts+5 added-5 removed
1 unmodified line2 import * as JWT from './jwt'3 import {4 AlgorithmTypes,5 JwtTokenSignatureMismatched,6- JwtAlorithmNotImplemented,6+ JwtAlgorithmNotImplemented,7 JwtTokenInvalid,8 JwtTokenNotBefore,9 JwtTokenExpired,10 } from './types'11 12 describe('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 })28 29 it('JwtTokenInvalid', async () => {30 const tok = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXNzYWdlIjoiaGVsbG8gd29ybGQifQ'143 unmodified linesmodified:src/utils/jwt/jwt.ts+2 added-2 removed
8 unmodified lines9 JwtTokenInvalid,10 JwtTokenNotBefore,11 JwtTokenExpired,12 JwtTokenSignatureMismatched,13- JwtAlorithmNotImplemented,13+ JwtAlgorithmNotImplemented,14 } from './types'15 16 interface AlgorithmParams {17 name: string44 unmodified lines62 name: 'SHA-512',63 },64 }65 default:66- throw new JwtAlorithmNotImplemented(name)66+ throw new JwtAlgorithmNotImplemented(name)67 }68 }69 70 const signing = async (75 unmodified linesmodified:src/utils/jwt/types.ts+8 added-2 removed
1-export class JwtAlorithmNotImplemented extends Error {1+export class JwtAlgorithmNotImplemented extends Error {2 constructor(token: string) {3 super(`invalid JWT token: ${token}`)4- this.name = 'JwtAlorithmNotImplemented'4+ this.name = 'JwtAlgorithmNotImplemented'5 }6 }7 8+/**9+ * Export for backward compatibility10+ * @deprecated Use JwtAlgorithmNotImplemented instead11+**/12+export const JwtAlorithmNotImplemented = JwtAlgorithmNotImplemented13+14 export class JwtTokenInvalid extends Error {15 constructor(token: string) {16 super(`invalid JWT token: ${token}`)17 this.name = 'JwtTokenInvalid'30 unmodified lines