@connectid-tools/rp-nodejs-sdk 4.2.0 → 5.0.0
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/README.md +284 -237
- package/package.json +7 -5
- package/{config.js → src/config.js} +2 -31
- package/src/conformance/api/conformance-api.d.ts +38 -0
- package/src/conformance/api/conformance-api.js +53 -0
- package/src/conformance/config.json +60 -0
- package/src/conformance/conformance-config.d.ts +2 -0
- package/src/conformance/conformance-config.js +34 -0
- package/src/conformance/conformance.test.js +101 -0
- package/src/conformance/variant.json +1 -0
- package/src/crypto/crypto-loader.d.ts +32 -0
- package/src/crypto/crypto-loader.js +49 -0
- package/src/crypto/jwt-helper.d.ts +61 -0
- package/src/crypto/jwt-helper.js +92 -0
- package/src/crypto/pkce-helper.d.ts +43 -0
- package/src/crypto/pkce-helper.js +75 -0
- package/src/endpoints/participants-endpoint.d.ts +55 -0
- package/src/endpoints/participants-endpoint.js +137 -0
- package/src/endpoints/pushed-authorisation-request-endpoint.d.ts +87 -0
- package/src/endpoints/pushed-authorisation-request-endpoint.js +192 -0
- package/src/endpoints/retrieve-token-endpoint.d.ts +66 -0
- package/src/endpoints/retrieve-token-endpoint.js +159 -0
- package/src/endpoints/userinfo-endpoint.d.ts +24 -0
- package/src/endpoints/userinfo-endpoint.js +50 -0
- package/src/fapi/fapi-utils.d.ts +6 -0
- package/src/fapi/fapi-utils.js +9 -0
- package/src/http/http-client-extensions.d.ts +60 -0
- package/src/http/http-client-extensions.js +106 -0
- package/src/http/http-client-factory.d.ts +27 -0
- package/src/http/http-client-factory.js +45 -0
- package/src/integration/integration.test.d.ts +1 -0
- package/src/integration/integration.test.js +30 -0
- package/src/model/callback-params.d.ts +31 -0
- package/src/model/callback-params.js +1 -0
- package/src/model/claims.d.ts +100 -0
- package/src/model/claims.js +1 -0
- package/src/model/consolidated-token-set.d.ts +74 -0
- package/src/model/consolidated-token-set.js +100 -0
- package/src/model/discovery-service.d.ts +46 -0
- package/src/model/discovery-service.js +112 -0
- package/src/model/issuer-metadata.d.ts +165 -0
- package/src/model/issuer-metadata.js +1 -0
- package/src/model/jwks.d.ts +12 -0
- package/src/model/jwks.js +1 -0
- package/src/model/token-response.d.ts +31 -0
- package/src/model/token-response.js +1 -0
- package/src/model/token-set.d.ts +73 -0
- package/src/model/token-set.js +179 -0
- package/src/relying-party-client-sdk.d.ts +68 -0
- package/src/relying-party-client-sdk.js +150 -0
- package/src/test-data/large-participants-test-data.d.ts +865 -0
- package/src/test-data/large-participants-test-data.js +18907 -0
- package/src/test-data/participants-test-data.d.ts +149 -0
- package/src/test-data/participants-test-data.js +458 -0
- package/src/test-data/sandbox-participants-test-data.d.ts +865 -0
- package/src/test-data/sandbox-participants-test-data.js +3794 -0
- package/src/tests/cert-utils.test.d.ts +1 -0
- package/src/tests/cert-utils.test.js +13 -0
- package/src/tests/functional-utils.test.d.ts +1 -0
- package/src/tests/functional-utils.test.js +13 -0
- package/src/tests/participant-filters.test.d.ts +1 -0
- package/src/tests/participant-filters.test.js +151 -0
- package/src/tests/pushed-authorisation-request-endpoint.test.d.ts +1 -0
- package/src/tests/pushed-authorisation-request-endpoint.test.js +159 -0
- package/src/tests/relying-party-client-sdk.test.d.ts +1 -0
- package/src/tests/relying-party-client-sdk.test.js +313 -0
- package/src/tests/request-utils.test.d.ts +1 -0
- package/src/tests/request-utils.test.js +16 -0
- package/src/tests/system-information.test.d.ts +1 -0
- package/src/tests/system-information.test.js +16 -0
- package/src/tests/user-agent.test.d.ts +1 -0
- package/src/tests/user-agent.test.js +23 -0
- package/src/tests/validator.test.d.ts +1 -0
- package/src/tests/validator.test.js +38 -0
- package/{types.d.ts → src/types.d.ts} +61 -32
- package/src/types.js +1 -0
- package/{utils → src/utils}/request-utils.d.ts +1 -1
- package/src/utils/request-utils.js +8 -0
- package/{utils → src/utils}/user-agent.d.ts +1 -1
- package/src/utils/user-agent.js +4 -0
- package/relying-party-client-sdk.d.ts +0 -37
- package/relying-party-client-sdk.js +0 -364
- package/utils/request-utils.js +0 -8
- package/utils/user-agent.js +0 -6
- /package/{config.d.ts → src/config.d.ts} +0 -0
- /package/{types.js → src/conformance/conformance.test.d.ts} +0 -0
- /package/{filter → src/filter}/participant-filters.d.ts +0 -0
- /package/{filter → src/filter}/participant-filters.js +0 -0
- /package/{logger.d.ts → src/logger.d.ts} +0 -0
- /package/{logger.js → src/logger.js} +0 -0
- /package/{utils → src/utils}/cert-utils.d.ts +0 -0
- /package/{utils → src/utils}/cert-utils.js +0 -0
- /package/{utils → src/utils}/functional-utils.d.ts +0 -0
- /package/{utils → src/utils}/functional-utils.js +0 -0
- /package/{utils → src/utils}/system-information.d.ts +0 -0
- /package/{utils → src/utils}/system-information.js +0 -0
- /package/{validator.d.ts → src/validator.d.ts} +0 -0
- /package/{validator.js → src/validator.js} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { IdTokenClaims } from './claims.js';
|
|
2
|
+
import { TokenSet } from './token-set.js';
|
|
3
|
+
import { ConsolidatedTokenSet as IConsolidatedTokenSet } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Consolidated Token Set
|
|
6
|
+
*
|
|
7
|
+
* Wraps a TokenSet and provides additional convenience methods
|
|
8
|
+
* for accessing token data and claims.
|
|
9
|
+
*
|
|
10
|
+
* Implements the ConsolidatedTokenSet interface from types.ts.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ConsolidatedTokenSet implements IConsolidatedTokenSet {
|
|
13
|
+
private tokenSet;
|
|
14
|
+
readonly xFapiInteractionId: string;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new ConsolidatedTokenSet.
|
|
17
|
+
*
|
|
18
|
+
* @param tokenSet - Validated token set
|
|
19
|
+
* @param xFapiInteractionId - FAPI interaction ID from the response
|
|
20
|
+
*/
|
|
21
|
+
constructor(tokenSet: TokenSet, xFapiInteractionId: string);
|
|
22
|
+
get access_token(): string | undefined;
|
|
23
|
+
get token_type(): string | undefined;
|
|
24
|
+
get expires_in(): number | undefined;
|
|
25
|
+
get refresh_token(): string | undefined;
|
|
26
|
+
get scope(): string | undefined;
|
|
27
|
+
get id_token(): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if the access token has expired.
|
|
30
|
+
*
|
|
31
|
+
* @returns true if the token is expired, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
expired(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the parsed ID token claims.
|
|
36
|
+
*
|
|
37
|
+
* @returns Parsed and validated ID token claims
|
|
38
|
+
*/
|
|
39
|
+
claims(): IdTokenClaims;
|
|
40
|
+
/**
|
|
41
|
+
* Returns consolidated claims with verified_claims merged into top level.
|
|
42
|
+
*
|
|
43
|
+
* This method extracts extended claims from the verified_claims structure
|
|
44
|
+
* and merges them into the top-level claims object for easier access.
|
|
45
|
+
*
|
|
46
|
+
* For example, if the ID token contains:
|
|
47
|
+
* ```json
|
|
48
|
+
* {
|
|
49
|
+
* "sub": "12345",
|
|
50
|
+
* "name": "John Doe",
|
|
51
|
+
* "verified_claims": {
|
|
52
|
+
* "claims": {
|
|
53
|
+
* "over18": true,
|
|
54
|
+
* "over21": false
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* This method will return:
|
|
61
|
+
* ```json
|
|
62
|
+
* {
|
|
63
|
+
* "sub": "12345",
|
|
64
|
+
* "name": "John Doe",
|
|
65
|
+
* "over18": true,
|
|
66
|
+
* "over21": false,
|
|
67
|
+
* "verified_claims": { ... }
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @returns Consolidated claims object
|
|
72
|
+
*/
|
|
73
|
+
consolidatedClaims(): IdTokenClaims;
|
|
74
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consolidated Token Set
|
|
3
|
+
*
|
|
4
|
+
* Wraps a TokenSet and provides additional convenience methods
|
|
5
|
+
* for accessing token data and claims.
|
|
6
|
+
*
|
|
7
|
+
* Implements the ConsolidatedTokenSet interface from types.ts.
|
|
8
|
+
*/
|
|
9
|
+
export class ConsolidatedTokenSet {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new ConsolidatedTokenSet.
|
|
12
|
+
*
|
|
13
|
+
* @param tokenSet - Validated token set
|
|
14
|
+
* @param xFapiInteractionId - FAPI interaction ID from the response
|
|
15
|
+
*/
|
|
16
|
+
constructor(tokenSet, xFapiInteractionId) {
|
|
17
|
+
this.tokenSet = tokenSet;
|
|
18
|
+
this.xFapiInteractionId = xFapiInteractionId;
|
|
19
|
+
}
|
|
20
|
+
// Delegate token properties to underlying TokenSet
|
|
21
|
+
get access_token() {
|
|
22
|
+
return this.tokenSet.access_token;
|
|
23
|
+
}
|
|
24
|
+
get token_type() {
|
|
25
|
+
return this.tokenSet.token_type;
|
|
26
|
+
}
|
|
27
|
+
get expires_in() {
|
|
28
|
+
return this.tokenSet.expires_in;
|
|
29
|
+
}
|
|
30
|
+
get refresh_token() {
|
|
31
|
+
return this.tokenSet.refresh_token;
|
|
32
|
+
}
|
|
33
|
+
get scope() {
|
|
34
|
+
return this.tokenSet.scope;
|
|
35
|
+
}
|
|
36
|
+
get id_token() {
|
|
37
|
+
return this.tokenSet.id_token;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Checks if the access token has expired.
|
|
41
|
+
*
|
|
42
|
+
* @returns true if the token is expired, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
expired() {
|
|
45
|
+
return this.tokenSet.expired();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns the parsed ID token claims.
|
|
49
|
+
*
|
|
50
|
+
* @returns Parsed and validated ID token claims
|
|
51
|
+
*/
|
|
52
|
+
claims() {
|
|
53
|
+
return this.tokenSet.claims();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns consolidated claims with verified_claims merged into top level.
|
|
57
|
+
*
|
|
58
|
+
* This method extracts extended claims from the verified_claims structure
|
|
59
|
+
* and merges them into the top-level claims object for easier access.
|
|
60
|
+
*
|
|
61
|
+
* For example, if the ID token contains:
|
|
62
|
+
* ```json
|
|
63
|
+
* {
|
|
64
|
+
* "sub": "12345",
|
|
65
|
+
* "name": "John Doe",
|
|
66
|
+
* "verified_claims": {
|
|
67
|
+
* "claims": {
|
|
68
|
+
* "over18": true,
|
|
69
|
+
* "over21": false
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* This method will return:
|
|
76
|
+
* ```json
|
|
77
|
+
* {
|
|
78
|
+
* "sub": "12345",
|
|
79
|
+
* "name": "John Doe",
|
|
80
|
+
* "over18": true,
|
|
81
|
+
* "over21": false,
|
|
82
|
+
* "verified_claims": { ... }
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @returns Consolidated claims object
|
|
87
|
+
*/
|
|
88
|
+
consolidatedClaims() {
|
|
89
|
+
const claims = this.claims();
|
|
90
|
+
// If there are no verified_claims, return claims as-is
|
|
91
|
+
if (!claims.verified_claims?.claims) {
|
|
92
|
+
return claims;
|
|
93
|
+
}
|
|
94
|
+
// Merge verified_claims.claims into top level
|
|
95
|
+
return {
|
|
96
|
+
...claims,
|
|
97
|
+
...claims.verified_claims.claims,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Agent } from 'undici';
|
|
2
|
+
import { IssuerMetadata } from './issuer-metadata.js';
|
|
3
|
+
import { JWKSet } from './jwks.js';
|
|
4
|
+
/**
|
|
5
|
+
* Service for fetching OIDC discovery documents and JWKS.
|
|
6
|
+
*
|
|
7
|
+
* Handles fetching and parsing of OpenID Connect discovery documents
|
|
8
|
+
* and JSON Web Key Sets from authorization servers.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DiscoveryService {
|
|
11
|
+
/**
|
|
12
|
+
* Fetches and parses an OIDC discovery document.
|
|
13
|
+
*
|
|
14
|
+
* @param discoveryUrl - URL to the .well-known/openid-configuration endpoint
|
|
15
|
+
* @param httpAgent - Optional undici Agent for mTLS
|
|
16
|
+
* @returns Parsed issuer metadata
|
|
17
|
+
* @throws Error if the discovery document cannot be fetched or parsed
|
|
18
|
+
*/
|
|
19
|
+
static fetchDiscoveryDocument(discoveryUrl: string, httpAgent?: Agent): Promise<IssuerMetadata>;
|
|
20
|
+
/**
|
|
21
|
+
* Fetches and parses a JWKS document.
|
|
22
|
+
*
|
|
23
|
+
* @param jwksUri - URL to the JWKS endpoint
|
|
24
|
+
* @param httpAgent - Optional HTTPS agent for mTLS
|
|
25
|
+
* @returns Parsed JWKS
|
|
26
|
+
* @throws Error if the JWKS cannot be fetched or parsed
|
|
27
|
+
*/
|
|
28
|
+
static fetchJwks(jwksUri: string, httpAgent?: Agent): Promise<JWKSet>;
|
|
29
|
+
/**
|
|
30
|
+
* Validates that required discovery document fields are present.
|
|
31
|
+
*
|
|
32
|
+
* @param metadata - Discovery document to validate
|
|
33
|
+
* @throws Error if required fields are missing
|
|
34
|
+
*/
|
|
35
|
+
private static validateDiscoveryDocument;
|
|
36
|
+
/**
|
|
37
|
+
* Applies mtls_endpoint_aliases to override standard endpoints.
|
|
38
|
+
*
|
|
39
|
+
* If mtls_endpoint_aliases are present, they should be used instead of
|
|
40
|
+
* the standard endpoints for certificate-bound operations.
|
|
41
|
+
*
|
|
42
|
+
* @param metadata - Original discovery metadata
|
|
43
|
+
* @returns Metadata with mTLS aliases applied
|
|
44
|
+
*/
|
|
45
|
+
private static applyMtlsAliases;
|
|
46
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service for fetching OIDC discovery documents and JWKS.
|
|
3
|
+
*
|
|
4
|
+
* Handles fetching and parsing of OpenID Connect discovery documents
|
|
5
|
+
* and JSON Web Key Sets from authorization servers.
|
|
6
|
+
*/
|
|
7
|
+
export class DiscoveryService {
|
|
8
|
+
/**
|
|
9
|
+
* Fetches and parses an OIDC discovery document.
|
|
10
|
+
*
|
|
11
|
+
* @param discoveryUrl - URL to the .well-known/openid-configuration endpoint
|
|
12
|
+
* @param httpAgent - Optional undici Agent for mTLS
|
|
13
|
+
* @returns Parsed issuer metadata
|
|
14
|
+
* @throws Error if the discovery document cannot be fetched or parsed
|
|
15
|
+
*/
|
|
16
|
+
static async fetchDiscoveryDocument(discoveryUrl, httpAgent) {
|
|
17
|
+
try {
|
|
18
|
+
const response = await fetch(discoveryUrl, {
|
|
19
|
+
method: 'GET',
|
|
20
|
+
headers: {
|
|
21
|
+
Accept: 'application/json',
|
|
22
|
+
},
|
|
23
|
+
dispatcher: httpAgent, // undici uses 'dispatcher' instead of 'agent'
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(`Failed to fetch discovery document: ${response.status} ${response.statusText}`);
|
|
27
|
+
}
|
|
28
|
+
const metadata = (await response.json());
|
|
29
|
+
// Validate required fields
|
|
30
|
+
this.validateDiscoveryDocument(metadata);
|
|
31
|
+
// Apply mtls_endpoint_aliases if present
|
|
32
|
+
return this.applyMtlsAliases(metadata);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new Error(`Failed to fetch discovery document from ${discoveryUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Fetches and parses a JWKS document.
|
|
40
|
+
*
|
|
41
|
+
* @param jwksUri - URL to the JWKS endpoint
|
|
42
|
+
* @param httpAgent - Optional HTTPS agent for mTLS
|
|
43
|
+
* @returns Parsed JWKS
|
|
44
|
+
* @throws Error if the JWKS cannot be fetched or parsed
|
|
45
|
+
*/
|
|
46
|
+
static async fetchJwks(jwksUri, httpAgent) {
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch(jwksUri, {
|
|
49
|
+
method: 'GET',
|
|
50
|
+
headers: {
|
|
51
|
+
Accept: 'application/json',
|
|
52
|
+
},
|
|
53
|
+
dispatcher: httpAgent, // undici uses 'dispatcher' instead of 'agent'
|
|
54
|
+
});
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
throw new Error(`Failed to fetch JWKS: ${response.status} ${response.statusText}`);
|
|
57
|
+
}
|
|
58
|
+
const jwks = (await response.json());
|
|
59
|
+
// Validate JWKS structure
|
|
60
|
+
if (!jwks.keys || !Array.isArray(jwks.keys)) {
|
|
61
|
+
throw new Error('Invalid JWKS: missing or invalid keys array');
|
|
62
|
+
}
|
|
63
|
+
return jwks;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
throw new Error(`Failed to fetch JWKS from ${jwksUri}: ${error instanceof Error ? error.message : String(error)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Validates that required discovery document fields are present.
|
|
71
|
+
*
|
|
72
|
+
* @param metadata - Discovery document to validate
|
|
73
|
+
* @throws Error if required fields are missing
|
|
74
|
+
*/
|
|
75
|
+
static validateDiscoveryDocument(metadata) {
|
|
76
|
+
const requiredFields = [
|
|
77
|
+
'issuer',
|
|
78
|
+
'authorization_endpoint',
|
|
79
|
+
'token_endpoint',
|
|
80
|
+
'jwks_uri',
|
|
81
|
+
];
|
|
82
|
+
for (const field of requiredFields) {
|
|
83
|
+
if (!metadata[field]) {
|
|
84
|
+
throw new Error(`Discovery document missing required field: ${field}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Applies mtls_endpoint_aliases to override standard endpoints.
|
|
90
|
+
*
|
|
91
|
+
* If mtls_endpoint_aliases are present, they should be used instead of
|
|
92
|
+
* the standard endpoints for certificate-bound operations.
|
|
93
|
+
*
|
|
94
|
+
* @param metadata - Original discovery metadata
|
|
95
|
+
* @returns Metadata with mTLS aliases applied
|
|
96
|
+
*/
|
|
97
|
+
static applyMtlsAliases(metadata) {
|
|
98
|
+
if (!metadata.mtls_endpoint_aliases) {
|
|
99
|
+
return metadata;
|
|
100
|
+
}
|
|
101
|
+
const aliases = metadata.mtls_endpoint_aliases;
|
|
102
|
+
return {
|
|
103
|
+
...metadata,
|
|
104
|
+
token_endpoint: aliases.token_endpoint || metadata.token_endpoint,
|
|
105
|
+
pushed_authorization_request_endpoint: aliases.pushed_authorization_request_endpoint ||
|
|
106
|
+
metadata.pushed_authorization_request_endpoint,
|
|
107
|
+
userinfo_endpoint: aliases.userinfo_endpoint || metadata.userinfo_endpoint,
|
|
108
|
+
revocation_endpoint: aliases.revocation_endpoint || metadata.revocation_endpoint,
|
|
109
|
+
introspection_endpoint: aliases.introspection_endpoint || metadata.introspection_endpoint,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OIDC Provider Metadata
|
|
3
|
+
*
|
|
4
|
+
* Represents the OpenID Connect Discovery document as defined in
|
|
5
|
+
* OpenID Connect Discovery 1.0.
|
|
6
|
+
*
|
|
7
|
+
* @see https://openid.net/specs/openid-connect-discovery-1_0.html
|
|
8
|
+
*/
|
|
9
|
+
export interface IssuerMetadata {
|
|
10
|
+
/**
|
|
11
|
+
* URL using the https scheme with no query or fragment component
|
|
12
|
+
* that the OP asserts as its Issuer Identifier.
|
|
13
|
+
*/
|
|
14
|
+
issuer: string;
|
|
15
|
+
/**
|
|
16
|
+
* URL of the OP's OAuth 2.0 Authorization Endpoint.
|
|
17
|
+
*/
|
|
18
|
+
authorization_endpoint: string;
|
|
19
|
+
/**
|
|
20
|
+
* URL of the OP's OAuth 2.0 Token Endpoint.
|
|
21
|
+
*/
|
|
22
|
+
token_endpoint: string;
|
|
23
|
+
/**
|
|
24
|
+
* URL of the OP's JSON Web Key Set document.
|
|
25
|
+
*/
|
|
26
|
+
jwks_uri: string;
|
|
27
|
+
/**
|
|
28
|
+
* URL of the OP's UserInfo Endpoint.
|
|
29
|
+
*/
|
|
30
|
+
userinfo_endpoint?: string;
|
|
31
|
+
/**
|
|
32
|
+
* URL of the OP's Pushed Authorization Request Endpoint (RFC 9126).
|
|
33
|
+
*/
|
|
34
|
+
pushed_authorization_request_endpoint?: string;
|
|
35
|
+
/**
|
|
36
|
+
* URL of the OP's Registration Endpoint.
|
|
37
|
+
*/
|
|
38
|
+
registration_endpoint?: string;
|
|
39
|
+
/**
|
|
40
|
+
* URL that the OpenID Provider provides to revoke tokens.
|
|
41
|
+
*/
|
|
42
|
+
revocation_endpoint?: string;
|
|
43
|
+
/**
|
|
44
|
+
* URL of the OP's Token Introspection Endpoint.
|
|
45
|
+
*/
|
|
46
|
+
introspection_endpoint?: string;
|
|
47
|
+
/**
|
|
48
|
+
* URL of the OP's Logout Endpoint.
|
|
49
|
+
*/
|
|
50
|
+
end_session_endpoint?: string;
|
|
51
|
+
/**
|
|
52
|
+
* MTLS endpoint aliases for certificate-bound tokens.
|
|
53
|
+
*/
|
|
54
|
+
mtls_endpoint_aliases?: {
|
|
55
|
+
token_endpoint?: string;
|
|
56
|
+
revocation_endpoint?: string;
|
|
57
|
+
introspection_endpoint?: string;
|
|
58
|
+
userinfo_endpoint?: string;
|
|
59
|
+
pushed_authorization_request_endpoint?: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* List of OAuth 2.0 response_type values that this OP supports.
|
|
63
|
+
*/
|
|
64
|
+
response_types_supported?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* List of OAuth 2.0 response_mode values that this OP supports.
|
|
67
|
+
*/
|
|
68
|
+
response_modes_supported?: string[];
|
|
69
|
+
/**
|
|
70
|
+
* List of OAuth 2.0 grant types supported.
|
|
71
|
+
*/
|
|
72
|
+
grant_types_supported?: string[];
|
|
73
|
+
/**
|
|
74
|
+
* List of the OAuth 2.0 scope values supported.
|
|
75
|
+
*/
|
|
76
|
+
scopes_supported?: string[];
|
|
77
|
+
/**
|
|
78
|
+
* List of the Subject Identifier types supported.
|
|
79
|
+
*/
|
|
80
|
+
subject_types_supported?: string[];
|
|
81
|
+
/**
|
|
82
|
+
* List of the JWS signing algorithms supported for the ID Token.
|
|
83
|
+
*/
|
|
84
|
+
id_token_signing_alg_values_supported?: string[];
|
|
85
|
+
/**
|
|
86
|
+
* List of the JWS signing algorithms supported for Request Objects.
|
|
87
|
+
*/
|
|
88
|
+
request_object_signing_alg_values_supported?: string[];
|
|
89
|
+
/**
|
|
90
|
+
* List of Client Authentication methods supported by the Token Endpoint.
|
|
91
|
+
*/
|
|
92
|
+
token_endpoint_auth_methods_supported?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* List of the JWS signing algorithms supported for Client Authentication.
|
|
95
|
+
*/
|
|
96
|
+
token_endpoint_auth_signing_alg_values_supported?: string[];
|
|
97
|
+
/**
|
|
98
|
+
* List of Claim Names of the Claims that the OP MAY be able to supply values for.
|
|
99
|
+
*/
|
|
100
|
+
claims_supported?: string[];
|
|
101
|
+
/**
|
|
102
|
+
* List of the Claim Types that the OP supports.
|
|
103
|
+
*/
|
|
104
|
+
claim_types_supported?: string[];
|
|
105
|
+
/**
|
|
106
|
+
* Languages and scripts supported for values in Claims.
|
|
107
|
+
*/
|
|
108
|
+
claims_locales_supported?: string[];
|
|
109
|
+
/**
|
|
110
|
+
* Languages and scripts supported for the UI.
|
|
111
|
+
*/
|
|
112
|
+
ui_locales_supported?: string[];
|
|
113
|
+
/**
|
|
114
|
+
* URL of a page containing human-readable information about the OP's requirements.
|
|
115
|
+
*/
|
|
116
|
+
service_documentation?: string;
|
|
117
|
+
/**
|
|
118
|
+
* URL that the OP provides for the Relying Party to read about policies.
|
|
119
|
+
*/
|
|
120
|
+
op_policy_uri?: string;
|
|
121
|
+
/**
|
|
122
|
+
* URL that the OP provides for the Relying Party to read about terms of service.
|
|
123
|
+
*/
|
|
124
|
+
op_tos_uri?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Boolean value specifying whether the OP supports use of the claims parameter.
|
|
127
|
+
*/
|
|
128
|
+
claims_parameter_supported?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Boolean value specifying whether the OP supports use of the request parameter.
|
|
131
|
+
*/
|
|
132
|
+
request_parameter_supported?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Boolean value specifying whether the OP supports use of the request_uri parameter.
|
|
135
|
+
*/
|
|
136
|
+
request_uri_parameter_supported?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Boolean value specifying whether the OP requires request_uri values to be pre-registered.
|
|
139
|
+
*/
|
|
140
|
+
require_request_uri_registration?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* URL of the authorization server's code_challenge_methods_supported.
|
|
143
|
+
*/
|
|
144
|
+
code_challenge_methods_supported?: string[];
|
|
145
|
+
/**
|
|
146
|
+
* Boolean indicating support for TLS client certificate bound access tokens.
|
|
147
|
+
*/
|
|
148
|
+
tls_client_certificate_bound_access_tokens?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Boolean indicating whether PAR is required.
|
|
151
|
+
*/
|
|
152
|
+
require_pushed_authorization_requests?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* ACR values supported.
|
|
155
|
+
*/
|
|
156
|
+
acr_values_supported?: string[];
|
|
157
|
+
/**
|
|
158
|
+
* Boolean indicating whether signed request object is required.
|
|
159
|
+
*/
|
|
160
|
+
require_signed_request_object?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Allows for additional custom metadata fields.
|
|
163
|
+
*/
|
|
164
|
+
[key: string]: unknown;
|
|
165
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.0 Token Response
|
|
3
|
+
*
|
|
4
|
+
* Represents the response from the token endpoint as defined in RFC 6749.
|
|
5
|
+
*/
|
|
6
|
+
export interface TokenResponse {
|
|
7
|
+
/**
|
|
8
|
+
* The access token issued by the authorization server.
|
|
9
|
+
*/
|
|
10
|
+
access_token?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The type of token issued (typically "Bearer").
|
|
13
|
+
*/
|
|
14
|
+
token_type?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The lifetime in seconds of the access token.
|
|
17
|
+
*/
|
|
18
|
+
expires_in?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The refresh token for obtaining new access tokens.
|
|
21
|
+
*/
|
|
22
|
+
refresh_token?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The scope of the access token.
|
|
25
|
+
*/
|
|
26
|
+
scope?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The ID token (OIDC extension to OAuth 2.0).
|
|
29
|
+
*/
|
|
30
|
+
id_token?: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { IdTokenClaims } from './claims.js';
|
|
2
|
+
import { TokenResponse } from './token-response.js';
|
|
3
|
+
import { JWKSet } from './jwks.js';
|
|
4
|
+
/**
|
|
5
|
+
* Token Set
|
|
6
|
+
*
|
|
7
|
+
* Represents an OAuth 2.0 / OIDC token response with validation capabilities.
|
|
8
|
+
* Handles ID token validation and claims extraction.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TokenSet {
|
|
11
|
+
readonly access_token?: string;
|
|
12
|
+
readonly token_type?: string;
|
|
13
|
+
readonly expires_in?: number;
|
|
14
|
+
readonly refresh_token?: string;
|
|
15
|
+
readonly scope?: string;
|
|
16
|
+
readonly id_token?: string;
|
|
17
|
+
private idTokenClaims?;
|
|
18
|
+
private jwtPayload?;
|
|
19
|
+
private tokenIssuedAt;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new TokenSet from a token response.
|
|
22
|
+
*
|
|
23
|
+
* @param tokenResponse - Raw token response from the token endpoint
|
|
24
|
+
*/
|
|
25
|
+
constructor(tokenResponse: TokenResponse);
|
|
26
|
+
/**
|
|
27
|
+
* Validates the ID token.
|
|
28
|
+
*
|
|
29
|
+
* Performs the following validations:
|
|
30
|
+
* - Algorithm validation against allowed algorithms
|
|
31
|
+
* - Signature verification using JWKS
|
|
32
|
+
* - Issuer validation
|
|
33
|
+
* - Audience validation
|
|
34
|
+
* - Nonce validation
|
|
35
|
+
* - Timestamp validation (iat, exp)
|
|
36
|
+
*
|
|
37
|
+
* @param jwks - JSON Web Key Set for signature verification
|
|
38
|
+
* @param expectedIssuer - Expected issuer claim value
|
|
39
|
+
* @param expectedAudience - Expected audience claim value
|
|
40
|
+
* @param expectedNonce - Expected nonce value
|
|
41
|
+
* @param allowedAlgorithms - Optional list of allowed signing algorithms from discovery document
|
|
42
|
+
* @throws Error if validation fails
|
|
43
|
+
*/
|
|
44
|
+
validate(jwks: JWKSet, expectedIssuer: string, expectedAudience: string, expectedNonce: string, allowedAlgorithms?: string[]): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the parsed ID token claims.
|
|
47
|
+
*
|
|
48
|
+
* Must call validate() first.
|
|
49
|
+
*
|
|
50
|
+
* @returns Parsed and validated ID token claims
|
|
51
|
+
* @throws Error if token has not been validated
|
|
52
|
+
*/
|
|
53
|
+
claims(): IdTokenClaims;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if the access token has expired.
|
|
56
|
+
*
|
|
57
|
+
* @returns true if the token is expired, false otherwise
|
|
58
|
+
*/
|
|
59
|
+
expired(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Selects the appropriate key from JWKS for verification.
|
|
62
|
+
*
|
|
63
|
+
* Matches based on:
|
|
64
|
+
* - kid (key ID)
|
|
65
|
+
* - alg (algorithm)
|
|
66
|
+
* - use (key usage - should be 'sig')
|
|
67
|
+
*
|
|
68
|
+
* @param jwks - JSON Web Key Set
|
|
69
|
+
* @returns Imported crypto key for verification
|
|
70
|
+
* @throws Error if no matching key is found
|
|
71
|
+
*/
|
|
72
|
+
private selectKey;
|
|
73
|
+
}
|