Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d99e361d65 | |||
| 79f030a35a | |||
| 5fd472c33d | |||
| 54ad90f6fd |
@@ -1,4 +1,4 @@
|
|||||||
name: Publish NPM Package
|
name: Publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
@@ -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`
|
`algorithm` | `string` | optional | `HS256` | The algorithm used to sign the payload, possible values: `HS256` or `HS512`
|
||||||
|
|
||||||
#### `return`
|
#### `return`
|
||||||
returns token as a `string`
|
Returns token as a `string`.
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
|||||||
32
index.d.ts
vendored
32
index.d.ts
vendored
@@ -1,6 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* JWT
|
||||||
|
*
|
||||||
|
* @class
|
||||||
|
* @constructor
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
declare class JWT {
|
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>
|
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>
|
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
|
decode(token: string): object | null
|
||||||
}
|
}
|
||||||
declare const _exports: JWT
|
declare const _exports: JWT
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tsndr/cloudflare-worker-jwt",
|
"name": "@tsndr/cloudflare-worker-jwt",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker",
|
"description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"no-string-throw": true,
|
"no-string-throw": true,
|
||||||
"no-tautology-expression": true,
|
"no-tautology-expression": true,
|
||||||
"no-this-assignment": [true, {"allowed-names": ["^self$"], "allow-destructuring": 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-callback-wrapper": true,
|
||||||
"no-unnecessary-initializer": true,
|
"no-unnecessary-initializer": true,
|
||||||
"no-unsafe-finally": true,
|
"no-unsafe-finally": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user