Skip to content

Commit a7cee68

Browse files
author
SomaticIT
committed
Add jsonwebtoken node module definitions
1 parent 50dd84e commit a7cee68

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

jsonwebtoken/jsonwebtoken.d.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Type definitions for jsonwebtoken 0.4.0
2+
// Project: https://github.com/auth0/node-jsonwebtoken
3+
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
declare module "jsonwebtoken" {
7+
8+
interface SignOptions {
9+
/**
10+
* Signature algorithm. Could be one of these values :
11+
* - HS256: HMAC using SHA-256 hash algorithm
12+
* - HS384: HMAC using SHA-384 hash algorithm
13+
* - HS512: HMAC using SHA-512 hash algorithm
14+
* - RS256: RSASSA using SHA-256 hash algorithm
15+
* - RS384: RSASSA using SHA-384 hash algorithm
16+
* - RS512: RSASSA using SHA-512 hash algorithm
17+
* - ES256: ECDSA using P-256 curve and SHA-256 hash algorithm
18+
* - ES384: ECDSA using P-384 curve and SHA-384 hash algorithm
19+
* - ES512: ECDSA using P-521 curve and SHA-512 hash algorithm
20+
* - none: No digital signature or MAC value included
21+
*/
22+
algorithm?: string;
23+
/** @member {number} - Lifetime for the token in minutes */
24+
expiresInMinutes?: number;
25+
audience?: string;
26+
subject?: string;
27+
issuer?: string;
28+
}
29+
30+
interface VerifyOptions {
31+
audience?: string;
32+
issuer?: string;
33+
}
34+
35+
/**
36+
* Sign the given payload into a JSON Web Token string
37+
* @param {string|object|buffer} payload - Payload to sign, could be an literal, buffer or string
38+
* @param {string|buffer} secretOrPrivateKey - Either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA.
39+
* @param {SignOptions} options - Options for the signature
40+
* @returns The JSON Web Token string
41+
*/
42+
function sign(payload: any, secretOrPrivateKey: any, options?: SignOptions): string;
43+
44+
/**
45+
* Verify given token using a secret or a public key to get a decoded token
46+
* @param {string} token - JWT string to verify
47+
* @param {string|buffer} secretOrPublicKey - Either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA.
48+
* @param {Function} callback - Callback to get the decoded token on
49+
*/
50+
function verify(token: string, secretOrPublicKey: any, callback: (err: Error, decoded: {}) => void): void;
51+
/**
52+
* Verify given token using a secret or a public key to get a decoded token
53+
* @param {string} token - JWT string to verify
54+
* @param {string|buffer} secretOrPublicKey - Either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA.
55+
* @param {VerifyOptions} options - Options for the verification
56+
* @param {Function} callback - Callback to get the decoded token on
57+
*/
58+
function verify(token: string, secretOrPublicKey: any, options: VerifyOptions, callback: (err: Error, decoded: {}) => void): void;
59+
60+
/**
61+
* Returns the decoded payload without verifying if the signature is valid.
62+
* @param {string} token - JWT string to decode
63+
* @returns The decoded Token
64+
*/
65+
function decode(token: string): {};
66+
}

0 commit comments

Comments
 (0)