[next] Permit (#1899)

* feat: replaced custom auth extraction logic with permit

* fix: fixed tests
This commit is contained in:
Wyatt Johnson
2018-09-21 22:06:46 +00:00
committed by GitHub
parent 18e6638162
commit 85af8d1bbf
5 changed files with 53 additions and 68 deletions
+31
View File
@@ -0,0 +1,31 @@
// TODO: (wyattjoh) following https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29061 to merge then replace this with @types/permit.
declare module "permit" {
import { IncomingMessage, ServerResponse } from "http";
export interface PermitOptions {
scheme?: string;
proxy?: string;
realm?: string;
}
export interface BearerOptions extends PermitOptions {
basic?: string;
header?: string;
query?: string;
}
export class Permit {
constructor(options: PermitOptions);
check(req: IncomingMessage): void;
fail(res: ServerResponse): void;
}
export class Bearer extends Permit {
constructor(options: BearerOptions);
check(req: IncomingMessage): string;
}
export class Basic extends Permit {
check(req: IncomingMessage): [string, string];
}
}