mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
// Type definitions for hapi-auth-bearer-token 6.1
|
|
// Project: https://github.com/johnbrett/hapi-auth-bearer-token
|
|
// Definitions by: Rodrigo Saboya <https://github.com/saboya>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.8
|
|
|
|
import {
|
|
Request,
|
|
Plugin,
|
|
ResponseToolkit,
|
|
AuthenticationData,
|
|
} from 'hapi';
|
|
|
|
type ValidateReturn = AuthenticationData & { isValid: boolean };
|
|
|
|
declare module 'hapi' {
|
|
interface ServerAuth {
|
|
strategy(name: string, scheme: 'bearer-access-token', options: BearerToken.SchemaOptions): void;
|
|
}
|
|
}
|
|
|
|
declare namespace BearerToken {
|
|
interface SchemaOptions {
|
|
validate: Validate;
|
|
accessTokenName?: string;
|
|
allowQueryToken?: boolean;
|
|
allowCookieToken?: boolean;
|
|
allowMultipleHeaders?: boolean;
|
|
allowChaining?: boolean;
|
|
tokenType?: string;
|
|
unauthorized?: (message: string | null, scheme: string) => any;
|
|
}
|
|
|
|
type Validate = (request: Request, token: string, h: ResponseToolkit) => Promise<ValidateReturn> | ValidateReturn;
|
|
}
|
|
|
|
declare var BearerToken: Plugin<{}>;
|
|
|
|
export = BearerToken;
|