mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
* JWT support * Added Next types * other fixes * removed next.js (again) * sameSite union * More adapter types * keepAlive as a number (from #47289) * Moved JWT interface * Added Adapter type * Added myself as a mantainer 👉👈 * Export more * Fixed some typos * Update client.d.ts * Update client.d.ts * Finally!
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import jose from 'jose';
|
|
import { NextApiRequest } from './_utils';
|
|
|
|
export interface JWTEncodeParams {
|
|
token?: object;
|
|
maxAge?: number;
|
|
secret: string | Buffer;
|
|
signingKey?: string;
|
|
signingOptions?: jose.JWT.SignOptions;
|
|
encryptionKey?: string;
|
|
encryptionOptions?: object;
|
|
encryption?: boolean;
|
|
}
|
|
|
|
export interface JWTDecodeParams {
|
|
maxAge?: number;
|
|
secret: string | Buffer;
|
|
signingKey?: string;
|
|
verificationKey?: string;
|
|
verificationOptions?: jose.JWT.VerifyOptions<false>;
|
|
encryptionKey?: string;
|
|
decryptionKey?: string;
|
|
decryptionOptions?: jose.JWE.DecryptOptions<false>;
|
|
encryption?: boolean;
|
|
}
|
|
|
|
declare function encode(args?: JWTEncodeParams): Promise<string>;
|
|
declare function decode(args?: JWTDecodeParams & { token: string }): Promise<object>;
|
|
|
|
declare function getToken(
|
|
args?: {
|
|
req: NextApiRequest;
|
|
secureCookie?: boolean;
|
|
cookieName?: string;
|
|
raw?: string;
|
|
} & JWTDecodeParams,
|
|
): Promise<object>;
|
|
declare function getToken(args?: {
|
|
req: NextApiRequest;
|
|
secureCookie?: boolean;
|
|
cookieName?: string;
|
|
raw: true;
|
|
}): Promise<string>;
|
|
|
|
export { encode, decode, getToken };
|