1.0.41 • Published 2 years ago

@types/passport-http-bearer v1.0.41

Weekly downloads
24,828
License
MIT
Repository
github
Last release
2 years ago

Installation

npm install --save @types/passport-http-bearer

Summary

This package contains type definitions for passport-http-bearer (https://github.com/jaredhanson/passport-http-bearer).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/passport-http-bearer.

index.d.ts

// Type definitions for passport-http-bearer 1.0.1
// Project: https://github.com/jaredhanson/passport-http-bearer
// Definitions by: Isman Usoh <https://github.com/isman-usoh>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

/// <reference types="passport"/>
/// <reference types="express" />
/// <reference types="koa" />

import passport = require("passport");
import express = require("express");
import koa = require("koa");

interface IStrategyOptions {
    scope?: string | Array<string> | undefined;
    realm?: string | undefined;
    passReqToCallback?: boolean | undefined;
}
interface IVerifyOptions {
    message?: string | undefined;
    scope: string | Array<string>;
}

interface VerifyFunction {
    (token: string, done: (error: any, user?: any, options?: IVerifyOptions | string) => void): void;
}

interface IKoaContextContainer { ctx: koa.Context; }
type KoaPassportExpressRequestMock = Partial<express.Request> & IKoaContextContainer;

interface VerifyFunctionWithRequest {
    (req: express.Request, token: string, done: (error: any, user?: any, options?: IVerifyOptions | string) => void): void;
}
interface VerifyFunctionWithContext {
    (req: KoaPassportExpressRequestMock, token: string, done: (error: any, user?: any, options?: IVerifyOptions | string) => void): void;
}

type VerifyFunctions =
    | VerifyFunction
    | VerifyFunctionWithRequest
    | VerifyFunctionWithContext;

declare class Strategy<T extends VerifyFunctions> implements passport.Strategy {
    constructor(verify: VerifyFunction);
    constructor(options: IStrategyOptions, verify: T);

    name: string;
    authenticate(req: express.Request, options?: Object): void;
}

Additional Details

Credits

These definitions were written by Isman Usoh.