mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 07:40:10 +00:00
Add types for passport-microsoft (#41827)
This adds types for the passport-microsoft package, which is a library
for authenticating with Microsoft's GraphQL API over OAuth2 using
PassportJs.
This commit is contained in:
22
types/passport-microsoft/index.d.ts
vendored
Normal file
22
types/passport-microsoft/index.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Type definitions for passport-microsoft 0.0
|
||||
// Project: https://github.com/seanfisher/passport-microsoft#readme
|
||||
// Definitions by: Eitan Levi <https://github.com/skrud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.5
|
||||
|
||||
import * as oauth2 from 'passport-oauth2';
|
||||
|
||||
// Disable automatic exporting
|
||||
export {};
|
||||
|
||||
// The passport-microsoft library provides defaults for these fields, so they become optional
|
||||
// when calling the constructor. (No need to export this).
|
||||
type OptionalOptionParameters = 'authorizationURL' | 'tokenURL' | 'scopeSeparator' | 'customHeaders';
|
||||
|
||||
export type MicrosoftStrategyOptions = Omit<oauth2.StrategyOptions, OptionalOptionParameters> & Partial<oauth2.StrategyOptions>;
|
||||
export type MicrosoftStrategyOptionsWithRequest = Omit<oauth2.StrategyOptionsWithRequest, OptionalOptionParameters> & Partial<oauth2.StrategyOptionsWithRequest>;
|
||||
|
||||
export class Strategy extends oauth2.Strategy {
|
||||
constructor(options: MicrosoftStrategyOptions, verify: oauth2.VerifyFunction);
|
||||
constructor(options: MicrosoftStrategyOptionsWithRequest, verify: oauth2.VerifyFunctionWithRequest);
|
||||
}
|
||||
26
types/passport-microsoft/passport-microsoft-tests.ts
Normal file
26
types/passport-microsoft/passport-microsoft-tests.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import passport = require('passport');
|
||||
import { Strategy as MicrosoftStrategy } from 'passport-microsoft';
|
||||
|
||||
// Just some test model.
|
||||
const User = {
|
||||
findOrCreate(
|
||||
id: string,
|
||||
provider: string,
|
||||
callback: (err: any, user: any) => void
|
||||
): void {
|
||||
callback(null, { username: "arnold" });
|
||||
}
|
||||
};
|
||||
|
||||
passport.use(new MicrosoftStrategy(
|
||||
{
|
||||
clientID: 'thisIsMyClientId',
|
||||
clientSecret: 'thisIsMyClientSecret'
|
||||
},
|
||||
(accessToken: string, refreshToken: string, profile: passport.Profile, done: (error: any, user?: any) => void) => {
|
||||
User.findOrCreate(profile.id, profile.provider, (err, user) => {
|
||||
if (err) { done(err); return; }
|
||||
done(null, user);
|
||||
});
|
||||
}
|
||||
));
|
||||
23
types/passport-microsoft/tsconfig.json
Normal file
23
types/passport-microsoft/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"passport-microsoft-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/passport-microsoft/tslint.json
Normal file
1
types/passport-microsoft/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user