Skip to content

Commit bd46c63

Browse files
authored
🤖 Merge PR DefinitelyTyped#74314 Add types for passport-google-oidc by @nathanhleung
Co-authored-by: nathanhleung <nathanhleung@users.noreply.github.com>
1 parent fffee71 commit bd46c63

File tree

5 files changed

+206
-0
lines changed

5 files changed

+206
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import OpenIDConnectStrategy = require("passport-openidconnect");
2+
3+
declare namespace GoogleOidcStrategy {
4+
type StrategyOptions =
5+
& Omit<
6+
OpenIDConnectStrategy.StrategyOptions,
7+
"issuer" | "authorizationURL" | "tokenURL" | "userInfoURL"
8+
>
9+
& {
10+
// In the example from the repo, these are the only required properties
11+
// https://github.com/jaredhanson/passport-google-openidconnect/blob/master/lib/strategy.js
12+
clientID: string;
13+
clientSecret: string;
14+
callbackURL: string;
15+
16+
issuer?: string | undefined;
17+
authorizationURL?: string | undefined;
18+
tokenURL?: string | undefined;
19+
};
20+
}
21+
22+
declare class GoogleOidcStrategy extends OpenIDConnectStrategy {
23+
constructor(
24+
options: GoogleOidcStrategy.StrategyOptions,
25+
verify: OpenIDConnectStrategy.VerifyFunction,
26+
);
27+
}
28+
29+
export = GoogleOidcStrategy;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"private": true,
3+
"name": "@types/passport-google-oidc",
4+
"version": "0.1.9999",
5+
"projects": [
6+
"https://github.com/jaredhanson/passport-google-openidconnect#readme"
7+
],
8+
"dependencies": {
9+
"@types/passport-openidconnect": "*"
10+
},
11+
"devDependencies": {
12+
"@types/express": "*",
13+
"@types/passport-google-oidc": "workspace:."
14+
},
15+
"owners": [
16+
{
17+
"name": "Nathan H. Leung",
18+
"githubUsername": "nathanhleung"
19+
}
20+
]
21+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import { Request } from "express";
2+
import GoogleOidcStrategy from "passport-google-oidc";
3+
import { Profile, VerifyCallback } from "passport-openidconnect";
4+
5+
const opts: GoogleOidcStrategy.StrategyOptions = {
6+
clientID: "dummy",
7+
clientSecret: "secret",
8+
callbackURL: "https://example.com/callback",
9+
};
10+
11+
function testVerifyFunc3(i: string, p: Profile, cb: VerifyCallback) {
12+
cb(new Error("Not implemented"));
13+
}
14+
15+
function testVerifyFunc4(i: string, p: Profile, ctx: object, cb: VerifyCallback) {
16+
cb(new Error("Not Implemented"));
17+
}
18+
function testVerifyFunc5(i: string, p: Profile, ctx: object, _idToken: string | object, cb: VerifyCallback) {
19+
cb(new Error("Not implemented"));
20+
}
21+
22+
function testVerifyFunc7(
23+
i: string,
24+
p: Profile,
25+
ctx: object,
26+
_idToken: string | object,
27+
_accessToken: string | object,
28+
_refreshToken: string | object,
29+
cb: VerifyCallback,
30+
) {
31+
cb(new Error("Not implemented"));
32+
}
33+
34+
function testVerifyFunc8(
35+
i: string,
36+
p: Profile,
37+
ctx: object,
38+
_idToken: string | object,
39+
_accessToken: string | object,
40+
_refreshToken: string | object,
41+
_params: any,
42+
cb: VerifyCallback,
43+
) {
44+
cb(new Error("Not implemented"));
45+
}
46+
47+
function testVerifyFunc9(
48+
i: string,
49+
uiProfile: object,
50+
idProfile: object,
51+
ctx: object,
52+
_idToken: string | object,
53+
_accessToken: string | object,
54+
_refreshToken: string | object,
55+
_params: any,
56+
cb: VerifyCallback,
57+
) {
58+
cb(new Error("Not implemented"));
59+
}
60+
61+
function testVerifyFuncReq4(r: Request, i: string, p: Profile, cb: VerifyCallback) {
62+
cb(new Error("Not implemented"));
63+
}
64+
65+
function testVerifyFuncReq5(r: Request, i: string, p: Profile, ctx: object, cb: VerifyCallback) {
66+
cb(new Error("Not Implemented"));
67+
}
68+
function testVerifyFuncReq6(
69+
r: Request,
70+
i: string,
71+
p: Profile,
72+
ctx: object,
73+
_idToken: string | object,
74+
cb: VerifyCallback,
75+
) {
76+
cb(new Error("Not implemented"));
77+
}
78+
79+
function testVerifyFuncReq8(
80+
r: Request,
81+
i: string,
82+
p: Profile,
83+
ctx: object,
84+
_idToken: string | object,
85+
_accessToken: string | object,
86+
_refreshToken: string | object,
87+
cb: VerifyCallback,
88+
) {
89+
cb(new Error("Not implemented"));
90+
}
91+
92+
function testVerifyFuncReq9(
93+
r: Request,
94+
i: string,
95+
p: Profile,
96+
ctx: object,
97+
_idToken: string | object,
98+
_accessToken: string | object,
99+
_refreshToken: string | object,
100+
_params: any,
101+
cb: VerifyCallback,
102+
) {
103+
cb(new Error("Not implemented"));
104+
}
105+
106+
function testVerifyFuncReq10(
107+
r: Request,
108+
i: string,
109+
uiProfile: object,
110+
idProfile: object,
111+
ctx: object,
112+
_idToken: string | object,
113+
_accessToken: string | object,
114+
_refreshToken: string | object,
115+
_params: any,
116+
cb: VerifyCallback,
117+
) {
118+
cb(new Error("Not implemented"));
119+
}
120+
121+
let strat: GoogleOidcStrategy = new GoogleOidcStrategy(opts, testVerifyFunc3);
122+
strat = new GoogleOidcStrategy(opts, testVerifyFunc4);
123+
strat = new GoogleOidcStrategy(opts, testVerifyFunc5);
124+
strat = new GoogleOidcStrategy(opts, testVerifyFunc7);
125+
strat = new GoogleOidcStrategy(opts, testVerifyFunc8);
126+
strat = new GoogleOidcStrategy(opts, testVerifyFunc9);
127+
strat = new GoogleOidcStrategy(opts, testVerifyFuncReq4);
128+
strat = new GoogleOidcStrategy(opts, testVerifyFuncReq5);
129+
strat = new GoogleOidcStrategy(opts, testVerifyFuncReq6);
130+
strat = new GoogleOidcStrategy(opts, testVerifyFuncReq8);
131+
strat = new GoogleOidcStrategy(opts, testVerifyFuncReq9);
132+
strat = new GoogleOidcStrategy(opts, testVerifyFuncReq10);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"module": "node16",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"types": [],
12+
"noEmit": true,
13+
"forceConsistentCasingInFileNames": true
14+
},
15+
"files": [
16+
"index.d.ts",
17+
"passport-google-oidc-tests.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)