mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
passport-client-cert: Provides its own types (#22369)
This commit is contained in:
@@ -792,6 +792,12 @@
|
||||
"sourceRepoURL": "https://github.com/blakeembrey/pascal-case",
|
||||
"asOfVersion": "1.1.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "passport-client-cert",
|
||||
"typingsPackageName": "passport-client-cert",
|
||||
"sourceRepoURL": "https://github.com/ripjar/passport-client-cert",
|
||||
"asOfVersion": "2.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "path-case",
|
||||
"typingsPackageName": "path-case",
|
||||
|
||||
35
types/passport-client-cert/index.d.ts
vendored
35
types/passport-client-cert/index.d.ts
vendored
@@ -1,35 +0,0 @@
|
||||
// Type definitions for passport-client-cert 2.0
|
||||
// Project: https://github.com/ripjar/passport-client-cert
|
||||
// Definitions by: Sean Warner <https://github.com/warnersean>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Strategy as PassportStrategy } from 'passport-strategy';
|
||||
import { Request } from 'express';
|
||||
|
||||
export class Strategy extends PassportStrategy {
|
||||
constructor(verify: PkiCallback);
|
||||
constructor(opt: StrategyOptions, verify: PkiCallback | PkiCallbackWithRequest);
|
||||
}
|
||||
|
||||
export interface StrategyOptions {
|
||||
passReqToCallback?: boolean;
|
||||
}
|
||||
|
||||
export type PkiCallback = (payload: ClientCert, done: PkiVerifiedCallback) => void;
|
||||
|
||||
export type PkiCallbackWithRequest = (req: Request, payload: ClientCert, done: PkiVerifiedCallback) => void;
|
||||
|
||||
export interface ClientCert {
|
||||
exponent: string;
|
||||
fingerprint: string;
|
||||
issuer: any;
|
||||
modulus: string;
|
||||
raw: Uint8Array;
|
||||
serialNumber: string;
|
||||
subject: any;
|
||||
valid_from: string;
|
||||
valid_to: string;
|
||||
}
|
||||
|
||||
export type PkiVerifiedCallback = (error: any, user?: any, info?: any) => void;
|
||||
@@ -1,14 +0,0 @@
|
||||
import * as passport from "passport";
|
||||
import { ClientCert, PkiVerifiedCallback, Strategy as ClientCertStrategy } from "passport-client-cert";
|
||||
|
||||
passport.use(new ClientCertStrategy((clientCert: ClientCert, done: PkiVerifiedCallback) => {
|
||||
const cn = clientCert.subject.cn;
|
||||
let user = null;
|
||||
|
||||
// The CN will typically be checked against a database
|
||||
if (cn === 'test-cn') {
|
||||
user = { name: 'Test User' };
|
||||
}
|
||||
|
||||
done(null, user);
|
||||
}));
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"passport-client-cert-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user