1
0

Updated readme

This commit is contained in:
2021-05-23 18:16:04 +02:00
parent f905176573
commit 187bd60b57

View File

@@ -25,53 +25,52 @@ const payload = jwt.decode(token)
``` ```
<hr>
### `jwt.sign(payload, secret, [algorithm])` ### `jwt.sign(payload, secret, [algorithm])`
Signs a payload and returns the token. Signs a payload and returns the token.
#### Arguments
`payload` Argument | Type | Satus | Default | Description
----------- | -------- | -------- | ------- | -----------
`payload` | `object` | required | - | The payload object
`secret` | `string` | required | - | A string which is used to sign the payload.
`algorithm` | `string` | optional | `HS256` | The algorithm used to sign the payload, possible values: `HS256` or `HS512`
The payload object. #### `return`
returns token as a `string`
`secret`
A string which is used to sign the payload.
`algorithm` (optional, default: `HS256`)
The algorithm used to sign the payload, possible values: `HS256` or `HS512`
<hr>
### `jwt.verify(token, secret, [algorithm])` ### `jwt.verify(token, secret, [algorithm])`
Verifies the integrity of the token and returns a boolean value. Verifies the integrity of the token and returns a boolean value.
Argument | Type | Satus | Default | Description
----------- | -------- | -------- | ------- | -----------
`token` | `string` | required | - | The token string generated by `jwt.sign()`.
`secret` | `string` | required | - | The string which was used to sign the payload.
`algorithm` | `string` | optional | `HS256` | The algorithm used to sign the payload, possible values: `HS256` or `HS512`
`token` #### `return`
returns `boolean`
The token string generated by `jwt.sign()`. <hr>
`secret`
A string which is used to sign the payload.
`algorithm` (optional, default: `HS256`)
The algorithm used to sign the payload, possible values: `HS256` or `HS512`
### `jwt.decode(token)` ### `jwt.decode(token)`
Returns the payload without verifying the integrity of the token. Returns the payload without verifying the integrity of the token.
Argument | Type | Satus | Default | Description
----------- | -------- | -------- | ------- | -----------
`token` | `string` | required | - | The token string generated by `jwt.sign()`.
`token` #### `return`
returns payload `object`
The token string generated by `jwt.sign()`. <hr>
## Install ## Install