1
0

Compare commits

...

4 Commits

Author SHA1 Message Date
d99e361d65 Bump version 2021-05-26 02:19:23 +02:00
79f030a35a Added JSDoc 2021-05-26 02:19:04 +02:00
5fd472c33d Renamed workflow 2021-05-25 22:44:42 +02:00
54ad90f6fd Updated tslint 2021-05-25 22:44:10 +02:00
5 changed files with 36 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
name: Publish NPM Package
name: Publish
on:
release:

View File

@@ -31,7 +31,7 @@ Argument | Type | Satus | Default | Description
`algorithm` | `string` | optional | `HS256` | The algorithm used to sign the payload, possible values: `HS256` or `HS512`
#### `return`
returns token as a `string`
Returns token as a `string`.
<hr>

32
index.d.ts vendored
View File

@@ -1,6 +1,38 @@
/**
* JWT
*
* @class
* @constructor
* @public
*/
declare class JWT {
/**
* Signs a payload and returns the token
*
* @param {object} payload The payload object. To use `nbf` (Not Before) and/or `exp` (Expiration Time) add `nbf` and/or `exp` to the payload.
* @param {string} secret A string which is used to sign the payload.
* @param {'HS256' | 'HS512'} [algorithm=HS256] The algorithm used to sign the payload, possible values: `HS256` or `HS512`
* @returns {Promise<string>} Returns token as a `string`.
*/
sign(payload: object, secret: string, algorithm?: "HS256" | "HS512"): Promise<string>
/**
* Verifies the integrity of the token and returns a boolean value.
*
* @param {string} token The token string generated by `jwt.sign()`.
* @param {string} secret The string which was used to sign the payload.
* @param {'HS256' | 'HS512'} [algorithm=HS256] The algorithm used to sign the payload, possible values: `HS256` or `HS512`
* @returns {Promise<boolean>} Returns `true` if signature, `nbf` (if set) and `exp` (if set) are valid, otherwise returns `false`.
*/
verify(token: string, secret: string, algorithm?: "HS256" | "HS512"): Promise<boolean>
/**
* Returns the payload **without** verifying the integrity of the token. Please use `jwt.verify()` first to keep your application secure!
*
* @param {string} token The token string generated by `jwt.sign()`.
* @returns {object | null} Returns payload `object`.
*/
decode(token: string): object | null
}
declare const _exports: JWT

View File

@@ -1,6 +1,6 @@
{
"name": "@tsndr/cloudflare-worker-jwt",
"version": "1.1.0",
"version": "1.1.1",
"description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker",
"main": "index.js",
"scripts": {

View File

@@ -24,7 +24,7 @@
"no-string-throw": true,
"no-tautology-expression": true,
"no-this-assignment": [true, {"allowed-names": ["^self$"], "allow-destructuring": true}],
"no-trailing-whitespace": true,
"no-trailing-whitespace": [true, "ignore-comments", "ignore-jsdoc"],
"no-unnecessary-callback-wrapper": true,
"no-unnecessary-initializer": true,
"no-unsafe-finally": true,