openid-client 4.2.3 → 4.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/lib/helpers/request.js +1 -1
- package/lib/issuer.js +36 -24
- package/package.json +3 -3
- package/types/index.d.ts +216 -81
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [4.4.2](https://github.com/panva/node-openid-client/compare/v4.4.1...v4.4.2) (2021-03-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* resolve discovery URIs one by one to yield consistent results ([6b18218](https://github.com/panva/node-openid-client/commit/6b18218cfa098195ec8442086221a88fa6aef654)), closes [#260](https://github.com/panva/node-openid-client/issues/260) [#267](https://github.com/panva/node-openid-client/issues/267)
|
|
11
|
+
|
|
12
|
+
## [4.4.1](https://github.com/panva/node-openid-client/compare/v4.4.0...v4.4.1) (2021-02-26)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* hide AggregateError message stack ([3011cca](https://github.com/panva/node-openid-client/commit/3011ccabc63e670adcee432b6565d10b55554865)), closes [#336](https://github.com/panva/node-openid-client/issues/336)
|
|
18
|
+
|
|
19
|
+
## [4.4.0](https://github.com/panva/node-openid-client/compare/v4.3.0...v4.4.0) (2021-01-29)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* allow options.https.pfx for mTSL ([075cad7](https://github.com/panva/node-openid-client/commit/075cad73a28d825128e6c92d44e7dba556b6a6f4)), closes [#326](https://github.com/panva/node-openid-client/issues/326)
|
|
25
|
+
|
|
26
|
+
## [4.3.0](https://github.com/panva/node-openid-client/compare/v4.2.3...v4.3.0) (2021-01-22)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* **typescript:** add userinfo response generics ([b176b2f](https://github.com/panva/node-openid-client/commit/b176b2f9161be77082c520ab532c237380abda22))
|
|
32
|
+
|
|
5
33
|
## [4.2.3](https://github.com/panva/node-openid-client/compare/v4.2.2...v4.2.3) (2021-01-18)
|
|
6
34
|
|
|
7
35
|
|
package/lib/helpers/request.js
CHANGED
|
@@ -44,7 +44,7 @@ module.exports = async function request(options, { mTLS = false, DPoP } = {}) {
|
|
|
44
44
|
mTLS
|
|
45
45
|
&& (
|
|
46
46
|
(!opts.key || !opts.cert)
|
|
47
|
-
&& (!opts.https || !opts.https.key
|
|
47
|
+
&& (!opts.https || !((opts.https.key && opts.https.certificate) || opts.https.pfx))
|
|
48
48
|
)
|
|
49
49
|
) {
|
|
50
50
|
throw new TypeError('mutual-TLS certificate and key not set');
|
package/lib/issuer.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const { inspect } = require('util');
|
|
4
4
|
const url = require('url');
|
|
5
5
|
|
|
6
|
+
const AggregateError = require('aggregate-error');
|
|
6
7
|
const jose = require('jose');
|
|
7
|
-
const pAny = require('p-any');
|
|
8
8
|
const LRU = require('lru-cache');
|
|
9
9
|
const objectHash = require('object-hash');
|
|
10
10
|
|
|
@@ -240,34 +240,46 @@ class Issuer {
|
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
const
|
|
244
|
-
if (parsed.pathname
|
|
245
|
-
|
|
243
|
+
const pathnames = [];
|
|
244
|
+
if (parsed.pathname.endsWith('/')) {
|
|
245
|
+
pathnames.push(`${parsed.pathname}${OIDC_DISCOVERY.substring(1)}`);
|
|
246
246
|
} else {
|
|
247
|
-
|
|
247
|
+
pathnames.push(`${parsed.pathname}${OIDC_DISCOVERY}`);
|
|
248
248
|
}
|
|
249
|
-
if (parsed.pathname
|
|
250
|
-
|
|
249
|
+
if (parsed.pathname === '/') {
|
|
250
|
+
pathnames.push(`${OAUTH2_DISCOVERY}`);
|
|
251
251
|
} else {
|
|
252
|
-
|
|
252
|
+
pathnames.push(`${OAUTH2_DISCOVERY}${parsed.pathname}`);
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
255
|
+
const errors = [];
|
|
256
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
257
|
+
for (const pathname of pathnames) {
|
|
258
|
+
try {
|
|
259
|
+
const wellKnownUri = url.format({ ...parsed, pathname });
|
|
260
|
+
// eslint-disable-next-line no-await-in-loop
|
|
261
|
+
const response = await request.call(this, {
|
|
262
|
+
method: 'GET',
|
|
263
|
+
responseType: 'json',
|
|
264
|
+
url: wellKnownUri,
|
|
265
|
+
});
|
|
266
|
+
const body = processResponse(response);
|
|
267
|
+
return new Issuer({
|
|
268
|
+
...ISSUER_DEFAULTS,
|
|
269
|
+
...body,
|
|
270
|
+
[AAD_MULTITENANT]: !!AAD_MULTITENANT_DISCOVERY.find(
|
|
271
|
+
(discoveryURL) => wellKnownUri.startsWith(discoveryURL),
|
|
272
|
+
),
|
|
273
|
+
});
|
|
274
|
+
} catch (err) {
|
|
275
|
+
errors.push(err);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const err = new AggregateError(errors);
|
|
280
|
+
err.message = `Issuer.discover() failed.${err.message.split('\n')
|
|
281
|
+
.filter((line) => !line.startsWith(' at')).join('\n')}`;
|
|
282
|
+
throw err;
|
|
271
283
|
}
|
|
272
284
|
|
|
273
285
|
/* istanbul ignore next */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openid-client",
|
|
3
|
-
"version": "4.2
|
|
3
|
+
"version": "4.4.2",
|
|
4
4
|
"description": "OpenID Connect Relying Party (RP, Client) implementation for Node.js runtime, supports passportjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
+
"aggregate-error": "^3.1.0",
|
|
66
67
|
"got": "^11.8.0",
|
|
67
68
|
"jose": "^2.0.4",
|
|
68
69
|
"lru-cache": "^6.0.0",
|
|
69
70
|
"make-error": "^1.3.6",
|
|
70
71
|
"object-hash": "^2.0.1",
|
|
71
|
-
"oidc-token-hash": "^5.0.1"
|
|
72
|
-
"p-any": "^3.0.0"
|
|
72
|
+
"oidc-token-hash": "^5.0.1"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@commitlint/cli": "^11.0.0",
|
package/types/index.d.ts
CHANGED
|
@@ -4,19 +4,28 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @see https://github.com/panva/node-openid-client/blob/master/docs/README.md
|
|
6
6
|
*/
|
|
7
|
-
import * as http from
|
|
8
|
-
import * as http2 from
|
|
7
|
+
import * as http from "http";
|
|
8
|
+
import * as http2 from "http2";
|
|
9
9
|
|
|
10
|
-
import { Options as GotOptions, CancelableRequest, Response } from
|
|
11
|
-
import { URL } from
|
|
12
|
-
import * as jose from
|
|
13
|
-
import * as crypto from
|
|
10
|
+
import { Options as GotOptions, CancelableRequest, Response } from "got";
|
|
11
|
+
import { URL } from "url";
|
|
12
|
+
import * as jose from "jose";
|
|
13
|
+
import * as crypto from "crypto";
|
|
14
14
|
|
|
15
15
|
export type HttpOptions = GotOptions;
|
|
16
16
|
export type RetryFunction = (retry: number, error: Error) => number;
|
|
17
17
|
export type CustomHttpOptionsProvider = (options: HttpOptions) => HttpOptions;
|
|
18
|
-
export type TokenTypeHint =
|
|
19
|
-
export type DPoPInput =
|
|
18
|
+
export type TokenTypeHint = "access_token" | "refresh_token" | string;
|
|
19
|
+
export type DPoPInput =
|
|
20
|
+
| crypto.KeyObject
|
|
21
|
+
| crypto.PrivateKeyInput
|
|
22
|
+
| jose.JWKRSAKey
|
|
23
|
+
| jose.JWKECKey
|
|
24
|
+
| jose.JWKOKPKey;
|
|
25
|
+
|
|
26
|
+
interface UnknownObject {
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
20
29
|
|
|
21
30
|
/**
|
|
22
31
|
* @see https://github.com/panva/node-openid-client/blob/master/lib/index.js
|
|
@@ -30,11 +39,25 @@ export const custom: {
|
|
|
30
39
|
/**
|
|
31
40
|
* @see https://medium.com/@darutk/diagrams-of-all-the-openid-connect-flows-6968e3990660
|
|
32
41
|
*/
|
|
33
|
-
export type ResponseType =
|
|
42
|
+
export type ResponseType =
|
|
43
|
+
| "code"
|
|
44
|
+
| "id_token"
|
|
45
|
+
| "code id_token"
|
|
46
|
+
| "id_token token"
|
|
47
|
+
| "code token"
|
|
48
|
+
| "code id_token token"
|
|
49
|
+
| "none";
|
|
34
50
|
/**
|
|
35
51
|
* @see https://github.com/panva/node-openid-client/blob/master/docs/README.md#client-authentication-methods
|
|
36
52
|
*/
|
|
37
|
-
export type ClientAuthMethod =
|
|
53
|
+
export type ClientAuthMethod =
|
|
54
|
+
| "client_secret_basic"
|
|
55
|
+
| "client_secret_post"
|
|
56
|
+
| "client_secret_jwt"
|
|
57
|
+
| "private_key_jwt"
|
|
58
|
+
| "tls_client_auth"
|
|
59
|
+
| "self_signed_tls_client_auth"
|
|
60
|
+
| "none";
|
|
38
61
|
|
|
39
62
|
/**
|
|
40
63
|
* @see https://github.com/panva/node-openid-client/blob/master/docs/README.md#new-clientmetadata-jwks
|
|
@@ -84,14 +107,16 @@ export interface ClaimsParameterMember {
|
|
|
84
107
|
export interface AuthorizationParameters {
|
|
85
108
|
acr_values?: string;
|
|
86
109
|
audience?: string;
|
|
87
|
-
claims?:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
110
|
+
claims?:
|
|
111
|
+
| string
|
|
112
|
+
| {
|
|
113
|
+
id_token?: {
|
|
114
|
+
[key: string]: null | ClaimsParameterMember;
|
|
115
|
+
};
|
|
116
|
+
userinfo?: {
|
|
117
|
+
[key: string]: null | ClaimsParameterMember;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
95
120
|
claims_locales?: string;
|
|
96
121
|
client_id?: string;
|
|
97
122
|
code_challenge_method?: string;
|
|
@@ -299,38 +324,45 @@ export interface DeviceAuthorizationExtras {
|
|
|
299
324
|
DPoP?: DPoPInput;
|
|
300
325
|
}
|
|
301
326
|
|
|
302
|
-
export
|
|
303
|
-
|
|
304
|
-
name?: string;
|
|
305
|
-
given_name?: string;
|
|
306
|
-
family_name?: string;
|
|
307
|
-
middle_name?: string;
|
|
308
|
-
nickname?: string;
|
|
309
|
-
preferred_username?: string;
|
|
310
|
-
profile?: string;
|
|
311
|
-
picture?: string;
|
|
312
|
-
website?: string;
|
|
313
|
-
email?: string;
|
|
314
|
-
email_verified?: boolean;
|
|
315
|
-
gender?: string;
|
|
316
|
-
birthdate?: string;
|
|
317
|
-
zoneinfo?: string;
|
|
318
|
-
locale?: string;
|
|
319
|
-
phone_number?: string;
|
|
320
|
-
updated_at?: number;
|
|
321
|
-
address?: {
|
|
327
|
+
export type Address<ExtendedAddress extends {} = UnknownObject> = Override<
|
|
328
|
+
{
|
|
322
329
|
formatted?: string;
|
|
323
330
|
street_address?: string;
|
|
324
331
|
locality?: string;
|
|
325
332
|
region?: string;
|
|
326
333
|
postal_code?: string;
|
|
327
334
|
country?: string;
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
335
|
+
},
|
|
336
|
+
ExtendedAddress
|
|
337
|
+
>;
|
|
338
|
+
|
|
339
|
+
export type UserinfoResponse<
|
|
340
|
+
UserInfo extends {} = UnknownObject,
|
|
341
|
+
ExtendedAddress extends {} = UnknownObject
|
|
342
|
+
> = Override<
|
|
343
|
+
{
|
|
344
|
+
sub: string;
|
|
345
|
+
name?: string;
|
|
346
|
+
given_name?: string;
|
|
347
|
+
family_name?: string;
|
|
348
|
+
middle_name?: string;
|
|
349
|
+
nickname?: string;
|
|
350
|
+
preferred_username?: string;
|
|
351
|
+
profile?: string;
|
|
352
|
+
picture?: string;
|
|
353
|
+
website?: string;
|
|
354
|
+
email?: string;
|
|
355
|
+
email_verified?: boolean;
|
|
356
|
+
gender?: string;
|
|
357
|
+
birthdate?: string;
|
|
358
|
+
zoneinfo?: string;
|
|
359
|
+
locale?: string;
|
|
360
|
+
phone_number?: string;
|
|
361
|
+
updated_at?: number;
|
|
362
|
+
address?: Address<ExtendedAddress>;
|
|
363
|
+
},
|
|
364
|
+
UserInfo
|
|
365
|
+
>;
|
|
334
366
|
|
|
335
367
|
export interface IntrospectionResponse {
|
|
336
368
|
active: boolean;
|
|
@@ -345,7 +377,7 @@ export interface IntrospectionResponse {
|
|
|
345
377
|
scope: string;
|
|
346
378
|
token_type?: string;
|
|
347
379
|
cnf?: {
|
|
348
|
-
|
|
380
|
+
"x5t#S256"?: string;
|
|
349
381
|
|
|
350
382
|
[key: string]: unknown;
|
|
351
383
|
};
|
|
@@ -363,7 +395,11 @@ export interface ClientOptions {
|
|
|
363
395
|
* consuming callbacks, triggering token endpoint grants, revoking and introspecting tokens.
|
|
364
396
|
*/
|
|
365
397
|
export class Client {
|
|
366
|
-
constructor(
|
|
398
|
+
constructor(
|
|
399
|
+
metadata: ClientMetadata,
|
|
400
|
+
jwks?: jose.JSONWebKeySet,
|
|
401
|
+
options?: ClientOptions
|
|
402
|
+
);
|
|
367
403
|
[custom.http_options]: CustomHttpOptionsProvider;
|
|
368
404
|
[custom.clock_tolerance]: number;
|
|
369
405
|
metadata: ClientMetadata;
|
|
@@ -392,7 +428,9 @@ export class Client {
|
|
|
392
428
|
* an object. Note: the request read stream will not be parsed, it is expected that you will have a body parser
|
|
393
429
|
* prior to calling this method. This parser would set the req.body property
|
|
394
430
|
*/
|
|
395
|
-
callbackParams(
|
|
431
|
+
callbackParams(
|
|
432
|
+
input: string | http.IncomingMessage | http2.Http2ServerRequest
|
|
433
|
+
): CallbackParamsType;
|
|
396
434
|
|
|
397
435
|
/**
|
|
398
436
|
* Performs the callback for Authorization Server's authorization response.
|
|
@@ -401,7 +439,12 @@ export class Client {
|
|
|
401
439
|
* @param checks checks to perform on the Authorization Response
|
|
402
440
|
* @param extras add extra parameters to the Token Endpoint Request and/or Client Authentication JWT Assertion
|
|
403
441
|
*/
|
|
404
|
-
callback(
|
|
442
|
+
callback(
|
|
443
|
+
redirectUri: string | undefined,
|
|
444
|
+
parameters: CallbackParamsType,
|
|
445
|
+
checks?: OpenIDCallbackChecks,
|
|
446
|
+
extras?: CallbackExtras
|
|
447
|
+
): Promise<TokenSet>;
|
|
405
448
|
|
|
406
449
|
/**
|
|
407
450
|
* Pure OAuth 2.0 version of callback().
|
|
@@ -410,7 +453,12 @@ export class Client {
|
|
|
410
453
|
* @param checks checks to perform on the Authorization Response
|
|
411
454
|
* @param extras add extra parameters to the Token Endpoint Request and/or Client Authentication JWT Assertion
|
|
412
455
|
*/
|
|
413
|
-
oauthCallback(
|
|
456
|
+
oauthCallback(
|
|
457
|
+
redirectUri: string | undefined,
|
|
458
|
+
parameters: CallbackParamsType,
|
|
459
|
+
checks?: OAuthCallbackChecks,
|
|
460
|
+
extras?: CallbackExtras
|
|
461
|
+
): Promise<TokenSet>;
|
|
414
462
|
|
|
415
463
|
/**
|
|
416
464
|
* Performs refresh_token grant type exchange.
|
|
@@ -418,7 +466,10 @@ export class Client {
|
|
|
418
466
|
* will be used automatically.
|
|
419
467
|
* @param extras Add extra parameters to the Token Endpoint Request and/or Client Authentication JWT Assertion
|
|
420
468
|
*/
|
|
421
|
-
refresh(
|
|
469
|
+
refresh(
|
|
470
|
+
refreshToken: TokenSet | string,
|
|
471
|
+
extras?: RefreshExtras
|
|
472
|
+
): Promise<TokenSet>;
|
|
422
473
|
|
|
423
474
|
/**
|
|
424
475
|
* Fetches the OIDC userinfo response with the provided Access Token. Also handles signed and/or
|
|
@@ -429,7 +480,19 @@ export class Client {
|
|
|
429
480
|
* will be used automatically.
|
|
430
481
|
* @param options Options for the UserInfo request.
|
|
431
482
|
*/
|
|
432
|
-
userinfo
|
|
483
|
+
userinfo<
|
|
484
|
+
TUserInfo extends {} = UnknownObject,
|
|
485
|
+
TAddress extends {} = UnknownObject
|
|
486
|
+
>(
|
|
487
|
+
accessToken: TokenSet | string,
|
|
488
|
+
options?: {
|
|
489
|
+
method?: "GET" | "POST";
|
|
490
|
+
via?: "header" | "body" | "query";
|
|
491
|
+
tokenType?: string;
|
|
492
|
+
params?: object;
|
|
493
|
+
DPoP?: DPoPInput;
|
|
494
|
+
}
|
|
495
|
+
): Promise<UserinfoResponse<TUserInfo, TAddress>>;
|
|
433
496
|
|
|
434
497
|
/**
|
|
435
498
|
* Fetches an arbitrary resource with the provided Access Token in an Authorization header.
|
|
@@ -439,13 +502,17 @@ export class Client {
|
|
|
439
502
|
* will be used automatically.
|
|
440
503
|
* @param options Options for the request.
|
|
441
504
|
*/
|
|
442
|
-
requestResource(
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
505
|
+
requestResource(
|
|
506
|
+
resourceUrl: string | URL,
|
|
507
|
+
accessToken: TokenSet | string,
|
|
508
|
+
options?: {
|
|
509
|
+
headers?: object;
|
|
510
|
+
body?: string | Buffer;
|
|
511
|
+
method?: "GET" | "POST" | "PUT" | "HEAD" | "DELETE" | "OPTIONS" | "TRACE";
|
|
512
|
+
tokenType?: string;
|
|
513
|
+
DPoP?: DPoPInput;
|
|
514
|
+
}
|
|
515
|
+
): CancelableRequest<Response<Buffer>>;
|
|
449
516
|
|
|
450
517
|
/**
|
|
451
518
|
* Performs an arbitrary grant_type exchange at the token_endpoint.
|
|
@@ -455,12 +522,20 @@ export class Client {
|
|
|
455
522
|
/**
|
|
456
523
|
* Introspects a token at the Authorization Server's introspection_endpoint.
|
|
457
524
|
*/
|
|
458
|
-
introspect(
|
|
525
|
+
introspect(
|
|
526
|
+
token: string,
|
|
527
|
+
tokenTypeHint?: TokenTypeHint,
|
|
528
|
+
extras?: IntrospectExtras
|
|
529
|
+
): Promise<IntrospectionResponse>;
|
|
459
530
|
|
|
460
531
|
/**
|
|
461
532
|
* Revokes a token at the Authorization Server's revocation_endpoint.
|
|
462
533
|
*/
|
|
463
|
-
revoke(
|
|
534
|
+
revoke(
|
|
535
|
+
token: string,
|
|
536
|
+
tokenTypeHint?: TokenTypeHint,
|
|
537
|
+
extras?: RevokeExtras
|
|
538
|
+
): Promise<undefined>;
|
|
464
539
|
|
|
465
540
|
/**
|
|
466
541
|
* Creates a signed and optionally encrypted Request Object to send to the AS. Uses the client's
|
|
@@ -473,15 +548,27 @@ export class Client {
|
|
|
473
548
|
* Starts a Device Authorization Request at the issuer's device_authorization_endpoint and returns a handle
|
|
474
549
|
* for subsequent Device Access Token Request polling.
|
|
475
550
|
*/
|
|
476
|
-
deviceAuthorization(
|
|
477
|
-
|
|
478
|
-
|
|
551
|
+
deviceAuthorization(
|
|
552
|
+
parameters?: DeviceAuthorizationParameters,
|
|
553
|
+
extras?: DeviceAuthorizationExtras
|
|
554
|
+
): Promise<DeviceFlowHandle<Client>>;
|
|
555
|
+
static register(
|
|
556
|
+
metadata: object,
|
|
557
|
+
other?: RegisterOther & ClientOptions
|
|
558
|
+
): Promise<Client>;
|
|
559
|
+
static fromUri(
|
|
560
|
+
registrationClientUri: string,
|
|
561
|
+
registrationAccessToken: string,
|
|
562
|
+
jwks?: jose.JSONWebKeySet,
|
|
563
|
+
clientOptions?: ClientOptions
|
|
564
|
+
): Promise<Client>;
|
|
479
565
|
static [custom.http_options]: CustomHttpOptionsProvider;
|
|
480
566
|
|
|
481
567
|
[key: string]: unknown;
|
|
482
568
|
}
|
|
483
569
|
|
|
484
|
-
export class DeviceFlowHandle<TClient extends Client> {
|
|
570
|
+
export class DeviceFlowHandle<TClient extends Client> {
|
|
571
|
+
// tslint:disable-line:no-unnecessary-generics
|
|
485
572
|
poll(): Promise<TokenSet>;
|
|
486
573
|
expired(): boolean;
|
|
487
574
|
expires_at: number;
|
|
@@ -526,7 +613,11 @@ export interface MtlsEndpointAliases {
|
|
|
526
613
|
// https://stackoverflow.com/questions/39622778/what-is-new-in-typescript
|
|
527
614
|
// https://github.com/Microsoft/TypeScript/issues/204
|
|
528
615
|
export interface TypeOfGenericClient<TClient extends Client> {
|
|
529
|
-
new (
|
|
616
|
+
new (
|
|
617
|
+
metadata: ClientMetadata,
|
|
618
|
+
jwks?: jose.JSONWebKeySet,
|
|
619
|
+
options?: ClientOptions
|
|
620
|
+
): TClient;
|
|
530
621
|
[custom.http_options]: CustomHttpOptionsProvider;
|
|
531
622
|
[custom.clock_tolerance]: number;
|
|
532
623
|
}
|
|
@@ -535,7 +626,8 @@ export interface TypeOfGenericClient<TClient extends Client> {
|
|
|
535
626
|
* Encapsulates a discovered or instantiated OpenID Connect Issuer (Issuer), Identity Provider (IdP),
|
|
536
627
|
* Authorization Server (AS) and its metadata.
|
|
537
628
|
*/
|
|
538
|
-
export class Issuer<TClient extends Client> {
|
|
629
|
+
export class Issuer<TClient extends Client> {
|
|
630
|
+
// tslint:disable-line:no-unnecessary-generics
|
|
539
631
|
constructor(metadata: IssuerMetadata);
|
|
540
632
|
|
|
541
633
|
/**
|
|
@@ -665,10 +757,34 @@ export class TokenSet implements TokenSetParameters {
|
|
|
665
757
|
[key: string]: unknown;
|
|
666
758
|
}
|
|
667
759
|
|
|
668
|
-
export type StrategyVerifyCallbackUserInfo<
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
760
|
+
export type StrategyVerifyCallbackUserInfo<
|
|
761
|
+
TUser,
|
|
762
|
+
TUserInfo extends {} = UnknownObject,
|
|
763
|
+
TAddress extends {} = UnknownObject
|
|
764
|
+
> = (
|
|
765
|
+
tokenset: TokenSet,
|
|
766
|
+
userinfo: UserinfoResponse<TUserInfo, TAddress>,
|
|
767
|
+
done: (err: any, user?: TUser) => void
|
|
768
|
+
) => void;
|
|
769
|
+
export type StrategyVerifyCallback<TUser> = (
|
|
770
|
+
tokenset: TokenSet,
|
|
771
|
+
done: (err: any, user?: TUser) => void
|
|
772
|
+
) => void;
|
|
773
|
+
export type StrategyVerifyCallbackReqUserInfo<
|
|
774
|
+
TUser,
|
|
775
|
+
TUserInfo extends {} = UnknownObject,
|
|
776
|
+
TAddress extends {} = UnknownObject
|
|
777
|
+
> = (
|
|
778
|
+
req: http.IncomingMessage,
|
|
779
|
+
tokenset: TokenSet,
|
|
780
|
+
userinfo: UserinfoResponse<TUserInfo, TAddress>,
|
|
781
|
+
done: (err: any, user?: TUser) => void
|
|
782
|
+
) => void;
|
|
783
|
+
export type StrategyVerifyCallbackReq<TUser> = (
|
|
784
|
+
req: http.IncomingMessage,
|
|
785
|
+
tokenset: TokenSet,
|
|
786
|
+
done: (err: any, user?: TUser) => void
|
|
787
|
+
) => void;
|
|
672
788
|
|
|
673
789
|
export interface StrategyOptions<TClient extends Client> {
|
|
674
790
|
client: TClient;
|
|
@@ -683,25 +799,30 @@ export interface StrategyOptions<TClient extends Client> {
|
|
|
683
799
|
extras?: CallbackExtras;
|
|
684
800
|
/**
|
|
685
801
|
* Boolean specifying whether the verify function should get the request object as first argument instead.
|
|
686
|
-
* Default: 'false'
|
|
687
802
|
*/
|
|
688
803
|
passReqToCallback?: boolean;
|
|
689
804
|
/**
|
|
690
805
|
* The PKCE method to use. When 'true' it will resolve based on the issuer metadata, when 'false' no PKCE will be
|
|
691
|
-
* used.
|
|
806
|
+
* used.
|
|
692
807
|
*/
|
|
693
808
|
usePKCE?: boolean | string;
|
|
694
809
|
/**
|
|
695
|
-
* The
|
|
696
|
-
* used. Default: 'false'
|
|
810
|
+
* The property name to store transaction information such as nonce, state, max_age, code_verifier, and response_type.
|
|
697
811
|
*/
|
|
698
812
|
sessionKey?: string;
|
|
699
813
|
}
|
|
700
814
|
|
|
701
815
|
// tslint:disable-next-line:no-unnecessary-class
|
|
702
|
-
export class Strategy<TUser, TClient extends Client> {
|
|
703
|
-
|
|
704
|
-
|
|
816
|
+
export class Strategy<TUser, TClient extends Client> {
|
|
817
|
+
// tslint:disable-line:no-unnecessary-generics
|
|
818
|
+
constructor(
|
|
819
|
+
options: StrategyOptions<TClient>,
|
|
820
|
+
verify:
|
|
821
|
+
| StrategyVerifyCallback<TUser>
|
|
822
|
+
| StrategyVerifyCallbackUserInfo<TUser>
|
|
823
|
+
| StrategyVerifyCallbackReq<TUser>
|
|
824
|
+
| StrategyVerifyCallbackReqUserInfo<TUser>
|
|
825
|
+
);
|
|
705
826
|
|
|
706
827
|
authenticate(req: any, options?: any): void;
|
|
707
828
|
success(user: any, info?: any): void;
|
|
@@ -718,25 +839,25 @@ export class Strategy<TUser, TClient extends Client> { // tslint:disable-line:no
|
|
|
718
839
|
export namespace generators {
|
|
719
840
|
/**
|
|
720
841
|
* Generates random bytes and encodes them in url safe base64.
|
|
721
|
-
* @param bytes Number indicating the number of bytes to generate.
|
|
842
|
+
* @param bytes Number indicating the number of bytes to generate.
|
|
722
843
|
*/
|
|
723
844
|
function random(bytes?: number): string;
|
|
724
845
|
|
|
725
846
|
/**
|
|
726
847
|
* Generates random bytes and encodes them in url safe base64.
|
|
727
|
-
* @param bytes Number indicating the number of bytes to generate.
|
|
848
|
+
* @param bytes Number indicating the number of bytes to generate.
|
|
728
849
|
*/
|
|
729
850
|
function state(bytes?: number): string;
|
|
730
851
|
|
|
731
852
|
/**
|
|
732
853
|
* Generates random bytes and encodes them in url safe base64.
|
|
733
|
-
* @param bytes Number indicating the number of bytes to generate.
|
|
854
|
+
* @param bytes Number indicating the number of bytes to generate.
|
|
734
855
|
*/
|
|
735
856
|
function nonce(bytes?: number): string;
|
|
736
857
|
|
|
737
858
|
/**
|
|
738
859
|
* Generates random bytes and encodes them in url safe base64.
|
|
739
|
-
* @param bytes Number indicating the number of bytes to generate.
|
|
860
|
+
* @param bytes Number indicating the number of bytes to generate.
|
|
740
861
|
*/
|
|
741
862
|
function codeVerifier(bytes?: number): string;
|
|
742
863
|
/**
|
|
@@ -811,3 +932,17 @@ export namespace errors {
|
|
|
811
932
|
auth_time?: number;
|
|
812
933
|
}
|
|
813
934
|
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* This is very useful to allow applications to override property types
|
|
938
|
+
* without making types in this package too weird
|
|
939
|
+
*/
|
|
940
|
+
// https://github.com/Microsoft/TypeScript/issues/25987#issuecomment-441224690
|
|
941
|
+
type KnownKeys<T> = {
|
|
942
|
+
[K in keyof T]: string extends K ? never : number extends K ? never : K;
|
|
943
|
+
} extends { [_ in keyof T]: infer U }
|
|
944
|
+
? {} extends U
|
|
945
|
+
? never
|
|
946
|
+
: U
|
|
947
|
+
: never;
|
|
948
|
+
type Override<T1, T2> = Omit<T1, keyof Omit<T2, keyof KnownKeys<T2>>> & T2;
|