DefinitelyTyped/types/next-auth/jwt.d.ts
JuanM04 8ea3802414
🤖 Merge PR #47310 [next-auth] Important fixes and Adapter Types by @JuanM04
* 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!
2020-09-17 08:01:41 -07:00

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 };