|
| 1 | +import * as jwt from "jsonwebtoken"; |
| 2 | +export declare type PubkeyData = { |
| 3 | + cert: string; |
| 4 | + alg: string; |
| 5 | +} | undefined | null; |
| 6 | +export declare type PrivkeyData = { |
| 7 | + key: string; |
| 8 | + passphrase: string; |
| 9 | + alg: string; |
| 10 | +} | undefined | null; |
| 11 | +export declare type PubkeyResolver = (keyId: string) => PubkeyData | Promise<PubkeyData>; |
| 12 | +export declare type PrivkeyResolver = (keyId: string) => PrivkeyData | Promise<PrivkeyData>; |
| 13 | +export declare class JwtHandler { |
| 14 | + private debug; |
| 15 | + private pubkeyResolver; |
| 16 | + private privkeyResolver; |
| 17 | + private jwtVerifyAsync; |
| 18 | + private jwtSignAsync; |
| 19 | + constructor(debugNamePrefix: string, pubkeyResolver: PubkeyResolver | null, privkeyResolver: PrivkeyResolver | null); |
| 20 | + /** |
| 21 | + * Extract key ID from the given JWT |
| 22 | + * |
| 23 | + * @param {type} jwtRaw The JWT in raw form, i.e. Base64 coded parts separated with dots |
| 24 | + * @return {Promise<string, MissingKeyIdError>} Promise to the key id |
| 25 | + */ |
| 26 | + extractKeyId(jwtRaw: string): string; |
| 27 | + /** |
| 28 | + * Validates the given JWT |
| 29 | + * |
| 30 | + * @param {string} jwtRaw The JWT in raw form, i.e. Base64 coded parts separated with dots |
| 31 | + * @param {Object} options Validation options (jsonwebtoken module options) |
| 32 | + * @return {Promise<Object, JsonWebTokenError>} Promise to the JWT body |
| 33 | + */ |
| 34 | + verify(jwtRaw: string, options?: jwt.VerifyOptions): Promise<string | object>; |
| 35 | + /** |
| 36 | + * Creates a new JWT with the given body and signs it with the given key |
| 37 | + * |
| 38 | + * @param {string} tokenBody The body of the JWT token |
| 39 | + * @param {string} keyId The ID of the signing key |
| 40 | + * @return {Promise<Object, JsonWebTokenError>} Promise to the JWT body |
| 41 | + */ |
| 42 | + create(tokenBody: object, keyId: string): Promise<string>; |
| 43 | +} |
0 commit comments