mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
fix(hapi-auth-jwt2): allow validate and verify to return directly (#25306)
This commit is contained in:
parent
2f6852e993
commit
b67b2df1d9
@ -32,7 +32,7 @@ server.register({
|
||||
.then(() => {
|
||||
const opts: hapiAuthJwt2.Options = {
|
||||
key: 'NeverShareYourSecret',
|
||||
async validate(decoded: { id: number }, request) {
|
||||
async validate(decoded: { id: number }) {
|
||||
return {
|
||||
isValid: !!users[decoded.id],
|
||||
};
|
||||
@ -42,5 +42,14 @@ server.register({
|
||||
issuer: 'test',
|
||||
}
|
||||
};
|
||||
const opts2: hapiAuthJwt2.Options = {
|
||||
key: 'NeverShareYourSecret2',
|
||||
validate(decoded: { id: number }) {
|
||||
return {
|
||||
isValid: !!users[decoded.id],
|
||||
};
|
||||
}
|
||||
};
|
||||
server.auth.strategy('jwt', 'jwt', opts);
|
||||
server.auth.strategy('jwt2', 'jwt', opts2);
|
||||
});
|
||||
|
||||
12
types/hapi-auth-jwt2/index.d.ts
vendored
12
types/hapi-auth-jwt2/index.d.ts
vendored
@ -39,6 +39,12 @@ declare namespace hapiAuthJwt2 {
|
||||
};
|
||||
}
|
||||
|
||||
interface ValidationResult {
|
||||
isValid: boolean;
|
||||
credentials?: any;
|
||||
response?: ResponseObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options passed to `hapi.auth.strategy` when this plugin is used
|
||||
*/
|
||||
@ -54,11 +60,7 @@ declare namespace hapiAuthJwt2 {
|
||||
* @param decoded the *decoded* and *verified* JWT received from the client in *request.headers.authorization*
|
||||
* @param request the original *request* received from the client
|
||||
*/
|
||||
validate(decoded: {}, request: Request, tk: ResponseToolkit): Promise<{
|
||||
isValid: boolean;
|
||||
credentials?: any;
|
||||
response?: ResponseObject
|
||||
}>;
|
||||
validate(decoded: {}, request: Request, tk: ResponseToolkit): ValidationResult | Promise<ValidationResult>;
|
||||
|
||||
/**
|
||||
* Settings to define how tokens are verified by the jsonwebtoken library
|
||||
|
||||
Loading…
Reference in New Issue
Block a user