Skip to content

Commit

Permalink
Merge pull request #12 from gradient/feature/typescript-type-definitions
Browse files Browse the repository at this point in the history
Bundle TypeScript type definitions
  • Loading branch information
joews authored Jul 1, 2017
2 parents aed7fb0 + a5832d6 commit bfad462
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.0.0",
"description": "Passport.js strategy for TLS client certificate authentication",
"main": "src",
"typings": "src/index.d.ts",
"scripts": {
"test": "mocha"
},
Expand All @@ -29,6 +30,7 @@
"passport-strategy": "^1.0.0"
},
"devDependencies": {
"@types/express": "^4.0.36",
"chai": "^3.3.0",
"colors": "^1.1.2",
"connect": "^3.4.1",
Expand Down
49 changes: 49 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {Request} from 'express';

import passport = require('passport');
import {Certificate} from 'tls';


export interface PeerCertificate {
subject: Certificate;
issuerInfo: Certificate;
issuer: Certificate;
raw: any;
valid_from: string;
valid_to: string;
fingerprint: string;
serialNumber: string;
}

export interface StrategyOptions {
passReqToCallback?: false;
}

export interface StrategyOptionsWithRequest {
passReqToCallback: true;
}

export interface VerifyOptions {
message: string;
}

export interface VerifyCallback {
(error: any, user?: any, options?: VerifyOptions): void;
}

export interface VerifyFunctionWithRequest {
(clientCert: PeerCertificate, req: Request, done: VerifyCallback): void;
}

export interface VerifyFunction {
(clientCert: PeerCertificate, done: VerifyCallback): void;
}

declare class Strategy implements Strategy {
constructor(options: StrategyOptionsWithRequest, verify: VerifyFunctionWithRequest);
constructor(options: StrategyOptions, verify: VerifyFunction);
constructor(verify: VerifyFunction);

name: string;
authenticate: (req: Request, options?: Object) => void;
}

0 comments on commit bfad462

Please sign in to comment.