mirror of
https://github.com/Thream/socketio-jwt.git
synced 2024-11-09 22:20:08 +01:00
style: run npm run format
This commit is contained in:
parent
6ea9d6f933
commit
243a598f37
@ -2,7 +2,7 @@ import jwt from 'jsonwebtoken'
|
|||||||
|
|
||||||
class UnauthorizedError extends Error {
|
class UnauthorizedError extends Error {
|
||||||
public inner: { message: string }
|
public inner: { message: string }
|
||||||
public data: { message: string; code: string; type: 'UnauthorizedError' }
|
public data: { message: string, code: string, type: 'UnauthorizedError' }
|
||||||
|
|
||||||
constructor (code: string, error: { message: string }) {
|
constructor (code: string, error: { message: string }) {
|
||||||
super(error.message)
|
super(error.message)
|
||||||
@ -190,8 +190,8 @@ export function authorize(options: any) {
|
|||||||
if (authorization_header) {
|
if (authorization_header) {
|
||||||
const parts = authorization_header.split(' ')
|
const parts = authorization_header.split(' ')
|
||||||
if (parts.length == 2) {
|
if (parts.length == 2) {
|
||||||
const scheme = parts[0],
|
const scheme = parts[0]
|
||||||
credentials = parts[1]
|
const credentials = parts[1]
|
||||||
|
|
||||||
if (scheme.toLowerCase() === 'bearer') {
|
if (scheme.toLowerCase() === 'bearer') {
|
||||||
token = credentials
|
token = credentials
|
||||||
@ -282,7 +282,7 @@ function getSecret(request: any, secret: any, token: any, callback: Function) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let decodedToken: any = jwt.decode(token, { complete: true })
|
const decodedToken: any = jwt.decode(token, { complete: true })
|
||||||
|
|
||||||
if (!decodedToken) {
|
if (!decodedToken) {
|
||||||
return callback({ code: 'invalid_token', message: 'jwt malformed' })
|
return callback({ code: 'invalid_token', message: 'jwt malformed' })
|
||||||
|
Loading…
Reference in New Issue
Block a user