mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
[passport-google-oauth20] Extend Strategy constructor overloads (#46492)
* Extend constructor overloads Allow for verify callbacks that include `params` returned by `getOAuthAccessToken`. * Remove unused import * Fix import pattern * Revert import pattern
This commit is contained in:
parent
8258289db3
commit
6836850295
22
types/passport-google-oauth20/index.d.ts
vendored
22
types/passport-google-oauth20/index.d.ts
vendored
@ -10,7 +10,6 @@
|
||||
import * as passport from "passport";
|
||||
import * as express from "express";
|
||||
import * as oauth2 from "passport-oauth2";
|
||||
import { OutgoingHttpHeaders } from "http";
|
||||
|
||||
export type OAuth2StrategyOptionsWithoutRequiredURLs = Pick<
|
||||
oauth2._StrategyOptionsBase,
|
||||
@ -54,6 +53,16 @@ export class Strategy extends oauth2.Strategy {
|
||||
done: VerifyCallback
|
||||
) => void
|
||||
);
|
||||
constructor(
|
||||
options: StrategyOptions,
|
||||
verify: (
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
params: any,
|
||||
profile: Profile,
|
||||
done: VerifyCallback
|
||||
) => void
|
||||
);
|
||||
constructor(
|
||||
options: StrategyOptionsWithRequest,
|
||||
verify: (
|
||||
@ -64,6 +73,17 @@ export class Strategy extends oauth2.Strategy {
|
||||
done: VerifyCallback
|
||||
) => void
|
||||
);
|
||||
constructor(
|
||||
options: StrategyOptionsWithRequest,
|
||||
verify: (
|
||||
req: express.Request,
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
params: any,
|
||||
profile: Profile,
|
||||
done: VerifyCallback
|
||||
) => void
|
||||
);
|
||||
}
|
||||
|
||||
// additional Google-specific options
|
||||
|
||||
@ -78,3 +78,55 @@ passport.use(
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
passport.use(
|
||||
new google.Strategy(
|
||||
{
|
||||
callbackURL,
|
||||
clientID,
|
||||
clientSecret,
|
||||
passReqToCallback: true
|
||||
},
|
||||
(
|
||||
request: express.Request,
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
params: any,
|
||||
profile: google.Profile,
|
||||
done: (error: any, user?: any) => void
|
||||
) => {
|
||||
User.findOrCreate(profile.id, profile.provider, (err, user) => {
|
||||
if (err) {
|
||||
done(err);
|
||||
return;
|
||||
}
|
||||
done(null, user);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
passport.use(
|
||||
new google.Strategy(
|
||||
{
|
||||
callbackURL,
|
||||
clientID,
|
||||
clientSecret,
|
||||
},
|
||||
(
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
params: any,
|
||||
profile: google.Profile,
|
||||
done: (error: any, user?: any) => void
|
||||
) => {
|
||||
User.findOrCreate(profile.id, profile.provider, (err, user) => {
|
||||
if (err) {
|
||||
done(err);
|
||||
return;
|
||||
}
|
||||
done(null, user);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user