mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Added passport-client-cert type definition (#16710)
* Added passport-client-cert type definition * Added passport-client-cert type definition * Minor fixes for PR corrected ts version call changed index accessor for subject and issuer to any. Any makes more sense than anything else, due to potential variation in response.
This commit is contained in:
committed by
Mohamed Hegazy
parent
86da68051e
commit
8926f7fbff
35
types/passport-client-cert/index.d.ts
vendored
Normal file
35
types/passport-client-cert/index.d.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Type definitions for passport-jwt 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.1
|
||||
|
||||
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;
|
||||
14
types/passport-client-cert/passport-client-cert-tests.ts
Normal file
14
types/passport-client-cert/passport-client-cert-tests.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as passport from "passport";
|
||||
import {ClientCert, PkiVerifiedCallback, Strategy as ClientCertStrategy} from "passport-client-cert";
|
||||
|
||||
passport.use(new ClientCertStrategy( (clientCert: ClientCert, done: PkiVerifiedCallback) => {
|
||||
let 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);
|
||||
}));
|
||||
22
types/passport-client-cert/tsconfig.json
Normal file
22
types/passport-client-cert/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"passport-client-cert-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/passport-client-cert/tslint.json
Normal file
1
types/passport-client-cert/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user