docs: add authorize options

This commit is contained in:
divlo 2021-02-18 20:14:56 +01:00
parent 55a5f71b6e
commit d01bcc29fa
2 changed files with 5 additions and 2 deletions

View File

@ -87,6 +87,11 @@ io.on('connection', async (socket) => {
}) })
``` ```
### `authorize` options
- `secret` is a string containing the secret for HMAC algorithms, or a function that should fetch the secret or public key as shown in the example with `jwks-rsa`.
- `algorithms` (default: `HS256`)
### Client side ### Client side
```ts ```ts

View File

@ -59,7 +59,6 @@ export const authorize = (options: AuthorizeOptions): SocketIOMiddleware => {
}) })
) )
} }
// Store encoded JWT
socket.encodedToken = encodedToken socket.encodedToken = encodedToken
let keySecret: string | null = null let keySecret: string | null = null
let decodedToken: any let decodedToken: any
@ -78,7 +77,6 @@ export const authorize = (options: AuthorizeOptions): SocketIOMiddleware => {
}) })
) )
} }
// Store decoded JWT
socket.decodedToken = decodedToken socket.decodedToken = decodedToken
return next() return next()
} }