Skip to content

Commit

Permalink
fix(typescript): add missing Strategy interface properties
Browse files Browse the repository at this point in the history
closes #189
  • Loading branch information
panva committed Sep 13, 2019
1 parent 10dc865 commit c0d59c4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
node-version: 12
- run: npm install
- run: npm run lint
- run: npx dtslint --onlyTestTsNext types

test:
name: Node Tests + Coverage
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"types": "types/index.d.ts",
"scripts": {
"coverage": "nyc mocha",
"lint": "eslint lib test",
"lint": "eslint lib test && npx dtslint --onlyTestTsNext types",
"lint-fix": "eslint lib test --fix",
"test": "mocha"
},
Expand All @@ -53,7 +53,9 @@
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@types/got": "^9.6.7",
"@types/passport": "^1.0.1",
"chai": "^4.2.0",
"dtslint": "^0.9.8",
"eslint": "^6.2.2",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
Expand Down
8 changes: 8 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,14 @@ export interface StrategyOptions<TClient extends Client> {
export class Strategy<TUser, TClient extends Client> {
constructor(options: StrategyOptions<TClient>, verify: StrategyVerifyCallback<TUser> | StrategyVerifyCallbackUserInfo<TUser> |
StrategyVerifyCallbackReq<TUser> | StrategyVerifyCallbackReqUserInfo<TUser>)

authenticate(req: any, options?: any): void;
success(user: any, info?: any): void;
fail(challenge: any, status: number): void;
fail(status: number): void;
redirect(url: string, status?: number): void;
pass(): void;
error(err: Error): void;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions types/openid-client-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { IncomingMessage } from 'http';

// tslint:disable-next-line:no-relative-import-in-test
import { custom, generators, Issuer, Client, Strategy, StrategyVerifyCallback, StrategyOptions, TokenSet, RegisterOther, IssuerMetadata } from './index.d';
import passport from 'passport';

async (req: IncomingMessage) => {
// Custom HTTP options on the `Issuer` _c'tor_ (e.g. used for `Issuer.discover()`):
Expand Down Expand Up @@ -185,4 +186,9 @@ async (req: IncomingMessage) => {
strategyOptions.client.myCustomMethod();

const customStrategy = new CustomStrategy(strategyOptions, verify);

passport.use(
'oidc',
new Strategy({ client, params: { foo: 'bar ' } }, verify)
);
};
1 change: 1 addition & 0 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"esModuleInterop": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
Expand Down

0 comments on commit c0d59c4

Please sign in to comment.