@connectid-tools/rp-nodejs-sdk 5.0.0 → 5.1.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 +131 -1
- package/cache/http-response-cache.d.ts +83 -0
- package/cache/http-response-cache.js +157 -0
- package/{src/endpoints → endpoints}/participants-endpoint.d.ts +5 -2
- package/{src/endpoints → endpoints}/participants-endpoint.js +20 -3
- package/{src/endpoints → endpoints}/pushed-authorisation-request-endpoint.d.ts +3 -1
- package/{src/endpoints → endpoints}/pushed-authorisation-request-endpoint.js +3 -2
- package/{src/endpoints → endpoints}/retrieve-token-endpoint.d.ts +3 -1
- package/{src/endpoints → endpoints}/retrieve-token-endpoint.js +4 -3
- package/{src/endpoints → endpoints}/userinfo-endpoint.d.ts +3 -1
- package/{src/endpoints → endpoints}/userinfo-endpoint.js +3 -2
- package/{src/model → model}/discovery-service.d.ts +7 -2
- package/{src/model → model}/discovery-service.js +32 -3
- package/package.json +1 -1
- package/{src/relying-party-client-sdk.js → relying-party-client-sdk.js} +14 -5
- package/{src/types.d.ts → types.d.ts} +7 -0
- package/{src/utils → utils}/user-agent.d.ts +1 -1
- package/{src/utils → utils}/user-agent.js +1 -1
- package/src/conformance/config.json +0 -60
- package/src/conformance/conformance.test.d.ts +0 -1
- package/src/conformance/conformance.test.js +0 -101
- package/src/conformance/variant.json +0 -1
- package/src/integration/integration.test.d.ts +0 -1
- package/src/integration/integration.test.js +0 -30
- package/src/tests/cert-utils.test.d.ts +0 -1
- package/src/tests/cert-utils.test.js +0 -13
- package/src/tests/functional-utils.test.d.ts +0 -1
- package/src/tests/functional-utils.test.js +0 -13
- package/src/tests/participant-filters.test.d.ts +0 -1
- package/src/tests/participant-filters.test.js +0 -151
- package/src/tests/pushed-authorisation-request-endpoint.test.d.ts +0 -1
- package/src/tests/pushed-authorisation-request-endpoint.test.js +0 -159
- package/src/tests/relying-party-client-sdk.test.d.ts +0 -1
- package/src/tests/relying-party-client-sdk.test.js +0 -313
- package/src/tests/request-utils.test.d.ts +0 -1
- package/src/tests/request-utils.test.js +0 -16
- package/src/tests/system-information.test.d.ts +0 -1
- package/src/tests/system-information.test.js +0 -16
- package/src/tests/user-agent.test.d.ts +0 -1
- package/src/tests/user-agent.test.js +0 -23
- package/src/tests/validator.test.d.ts +0 -1
- package/src/tests/validator.test.js +0 -38
- /package/{src/config.d.ts → config.d.ts} +0 -0
- /package/{src/config.js → config.js} +0 -0
- /package/{src/conformance → conformance}/api/conformance-api.d.ts +0 -0
- /package/{src/conformance → conformance}/api/conformance-api.js +0 -0
- /package/{src/conformance → conformance}/conformance-config.d.ts +0 -0
- /package/{src/conformance → conformance}/conformance-config.js +0 -0
- /package/{src/crypto → crypto}/crypto-loader.d.ts +0 -0
- /package/{src/crypto → crypto}/crypto-loader.js +0 -0
- /package/{src/crypto → crypto}/jwt-helper.d.ts +0 -0
- /package/{src/crypto → crypto}/jwt-helper.js +0 -0
- /package/{src/crypto → crypto}/pkce-helper.d.ts +0 -0
- /package/{src/crypto → crypto}/pkce-helper.js +0 -0
- /package/{src/fapi → fapi}/fapi-utils.d.ts +0 -0
- /package/{src/fapi → fapi}/fapi-utils.js +0 -0
- /package/{src/filter → filter}/participant-filters.d.ts +0 -0
- /package/{src/filter → filter}/participant-filters.js +0 -0
- /package/{src/http → http}/http-client-extensions.d.ts +0 -0
- /package/{src/http → http}/http-client-extensions.js +0 -0
- /package/{src/http → http}/http-client-factory.d.ts +0 -0
- /package/{src/http → http}/http-client-factory.js +0 -0
- /package/{src/logger.d.ts → logger.d.ts} +0 -0
- /package/{src/logger.js → logger.js} +0 -0
- /package/{src/model → model}/callback-params.d.ts +0 -0
- /package/{src/model → model}/callback-params.js +0 -0
- /package/{src/model → model}/claims.d.ts +0 -0
- /package/{src/model → model}/claims.js +0 -0
- /package/{src/model → model}/consolidated-token-set.d.ts +0 -0
- /package/{src/model → model}/consolidated-token-set.js +0 -0
- /package/{src/model → model}/issuer-metadata.d.ts +0 -0
- /package/{src/model → model}/issuer-metadata.js +0 -0
- /package/{src/model → model}/jwks.d.ts +0 -0
- /package/{src/model → model}/jwks.js +0 -0
- /package/{src/model → model}/token-response.d.ts +0 -0
- /package/{src/model → model}/token-response.js +0 -0
- /package/{src/model → model}/token-set.d.ts +0 -0
- /package/{src/model → model}/token-set.js +0 -0
- /package/{src/relying-party-client-sdk.d.ts → relying-party-client-sdk.d.ts} +0 -0
- /package/{src/test-data → test-data}/large-participants-test-data.d.ts +0 -0
- /package/{src/test-data → test-data}/large-participants-test-data.js +0 -0
- /package/{src/test-data → test-data}/participants-test-data.d.ts +0 -0
- /package/{src/test-data → test-data}/participants-test-data.js +0 -0
- /package/{src/test-data → test-data}/sandbox-participants-test-data.d.ts +0 -0
- /package/{src/test-data → test-data}/sandbox-participants-test-data.js +0 -0
- /package/{src/types.js → types.js} +0 -0
- /package/{src/utils → utils}/cert-utils.d.ts +0 -0
- /package/{src/utils → utils}/cert-utils.js +0 -0
- /package/{src/utils → utils}/functional-utils.d.ts +0 -0
- /package/{src/utils → utils}/functional-utils.js +0 -0
- /package/{src/utils → utils}/request-utils.d.ts +0 -0
- /package/{src/utils → utils}/request-utils.js +0 -0
- /package/{src/utils → utils}/system-information.d.ts +0 -0
- /package/{src/utils → utils}/system-information.js +0 -0
- /package/{src/validator.d.ts → validator.d.ts} +0 -0
- /package/{src/validator.js → validator.js} +0 -0
|
@@ -7,14 +7,24 @@
|
|
|
7
7
|
export class DiscoveryService {
|
|
8
8
|
/**
|
|
9
9
|
* Fetches and parses an OIDC discovery document.
|
|
10
|
+
* Uses cache-aside pattern for performance optimization.
|
|
10
11
|
*
|
|
11
12
|
* @param discoveryUrl - URL to the .well-known/openid-configuration endpoint
|
|
12
13
|
* @param httpAgent - Optional undici Agent for mTLS
|
|
14
|
+
* @param cache - Optional HTTP response cache
|
|
13
15
|
* @returns Parsed issuer metadata
|
|
14
16
|
* @throws Error if the discovery document cannot be fetched or parsed
|
|
15
17
|
*/
|
|
16
|
-
static async fetchDiscoveryDocument(discoveryUrl, httpAgent) {
|
|
18
|
+
static async fetchDiscoveryDocument(discoveryUrl, httpAgent, cache) {
|
|
17
19
|
try {
|
|
20
|
+
// Check cache first
|
|
21
|
+
if (cache) {
|
|
22
|
+
const cachedContent = cache.get(discoveryUrl);
|
|
23
|
+
if (cachedContent) {
|
|
24
|
+
return JSON.parse(cachedContent);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Fetch from network
|
|
18
28
|
const response = await fetch(discoveryUrl, {
|
|
19
29
|
method: 'GET',
|
|
20
30
|
headers: {
|
|
@@ -29,7 +39,12 @@ export class DiscoveryService {
|
|
|
29
39
|
// Validate required fields
|
|
30
40
|
this.validateDiscoveryDocument(metadata);
|
|
31
41
|
// Apply mtls_endpoint_aliases if present
|
|
32
|
-
|
|
42
|
+
const processedMetadata = this.applyMtlsAliases(metadata);
|
|
43
|
+
// Cache successful response
|
|
44
|
+
if (cache && response.status >= 200 && response.status < 300) {
|
|
45
|
+
cache.put(discoveryUrl, JSON.stringify(processedMetadata));
|
|
46
|
+
}
|
|
47
|
+
return processedMetadata;
|
|
33
48
|
}
|
|
34
49
|
catch (error) {
|
|
35
50
|
throw new Error(`Failed to fetch discovery document from ${discoveryUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -37,14 +52,24 @@ export class DiscoveryService {
|
|
|
37
52
|
}
|
|
38
53
|
/**
|
|
39
54
|
* Fetches and parses a JWKS document.
|
|
55
|
+
* Uses cache-aside pattern for performance optimization.
|
|
40
56
|
*
|
|
41
57
|
* @param jwksUri - URL to the JWKS endpoint
|
|
42
58
|
* @param httpAgent - Optional HTTPS agent for mTLS
|
|
59
|
+
* @param cache - Optional HTTP response cache
|
|
43
60
|
* @returns Parsed JWKS
|
|
44
61
|
* @throws Error if the JWKS cannot be fetched or parsed
|
|
45
62
|
*/
|
|
46
|
-
static async fetchJwks(jwksUri, httpAgent) {
|
|
63
|
+
static async fetchJwks(jwksUri, httpAgent, cache) {
|
|
47
64
|
try {
|
|
65
|
+
// Check cache first
|
|
66
|
+
if (cache) {
|
|
67
|
+
const cachedContent = cache.get(jwksUri);
|
|
68
|
+
if (cachedContent) {
|
|
69
|
+
return JSON.parse(cachedContent);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Fetch from network
|
|
48
73
|
const response = await fetch(jwksUri, {
|
|
49
74
|
method: 'GET',
|
|
50
75
|
headers: {
|
|
@@ -60,6 +85,10 @@ export class DiscoveryService {
|
|
|
60
85
|
if (!jwks.keys || !Array.isArray(jwks.keys)) {
|
|
61
86
|
throw new Error('Invalid JWKS: missing or invalid keys array');
|
|
62
87
|
}
|
|
88
|
+
// Cache successful response
|
|
89
|
+
if (cache && response.status >= 200 && response.status < 300) {
|
|
90
|
+
cache.put(jwksUri, JSON.stringify(jwks));
|
|
91
|
+
}
|
|
63
92
|
return jwks;
|
|
64
93
|
}
|
|
65
94
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { illegalPurposeChars, isValidCertificate, validatePurpose } from './vali
|
|
|
5
5
|
import { CryptoLoader } from './crypto/crypto-loader.js';
|
|
6
6
|
import { JwtHelper } from './crypto/jwt-helper.js';
|
|
7
7
|
import { HttpClientFactory } from './http/http-client-factory.js';
|
|
8
|
+
import { HttpResponseCache } from './cache/http-response-cache.js';
|
|
8
9
|
import { ParticipantsEndpoint } from './endpoints/participants-endpoint.js';
|
|
9
10
|
import { PushedAuthorisationRequestEndpoint } from './endpoints/pushed-authorisation-request-endpoint.js';
|
|
10
11
|
import { RetrieveTokenEndpoint } from './endpoints/retrieve-token-endpoint.js';
|
|
@@ -27,7 +28,7 @@ export default class RelyingPartyClientSdk {
|
|
|
27
28
|
throw new Error('Either ca_pem or ca_pem_content must be provided');
|
|
28
29
|
}
|
|
29
30
|
this.logger = getLogger(this.config.data.log_level);
|
|
30
|
-
this.logger.info(`Creating RelyingPartyClientSdk - version
|
|
31
|
+
this.logger.info(`Creating RelyingPartyClientSdk - version 5.1.0`);
|
|
31
32
|
// Validate and set purpose
|
|
32
33
|
if (this.config.data.purpose) {
|
|
33
34
|
const purposeValidation = validatePurpose(this.config.data.purpose);
|
|
@@ -73,11 +74,19 @@ export default class RelyingPartyClientSdk {
|
|
|
73
74
|
caPem: getCertificate(this.config.data.ca_pem, this.config.data.ca_pem_content),
|
|
74
75
|
clientId: this.config.data.client_id,
|
|
75
76
|
});
|
|
77
|
+
// Initialize HTTP response cache
|
|
78
|
+
const cacheConfig = {
|
|
79
|
+
enabled: this.config.data.http_cache?.enabled ?? true,
|
|
80
|
+
ttlMinutes: this.config.data.http_cache?.ttl_minutes ?? 10,
|
|
81
|
+
maxEntries: this.config.data.http_cache?.max_entries ?? 100,
|
|
82
|
+
maxElementSizeBytes: this.config.data.http_cache?.max_element_size_bytes ?? 5242880,
|
|
83
|
+
};
|
|
84
|
+
const httpCache = new HttpResponseCache(cacheConfig, this.logger);
|
|
76
85
|
// Initialize endpoints
|
|
77
|
-
this.participantsEndpoint = new ParticipantsEndpoint(this.config, new ParticipantFilters(), this.httpClient, this.logger, () => this.getCurrentDate());
|
|
78
|
-
this.pushedAuthorisationRequestEndpoint = new PushedAuthorisationRequestEndpoint(this.config, this.httpClient, this.jwtHelper, this.logger, this.participantsEndpoint);
|
|
79
|
-
this.retrieveTokenEndpoint = new RetrieveTokenEndpoint(this.config, this.httpClient, this.jwtHelper, this.logger, this.participantsEndpoint);
|
|
80
|
-
this.userInfoEndpoint = new UserInfoEndpoint(this.httpClient, this.logger, this.config.data.client_id, this.participantsEndpoint);
|
|
86
|
+
this.participantsEndpoint = new ParticipantsEndpoint(this.config, new ParticipantFilters(), this.httpClient, this.logger, () => this.getCurrentDate(), httpCache);
|
|
87
|
+
this.pushedAuthorisationRequestEndpoint = new PushedAuthorisationRequestEndpoint(this.config, this.httpClient, this.jwtHelper, this.logger, this.participantsEndpoint, httpCache);
|
|
88
|
+
this.retrieveTokenEndpoint = new RetrieveTokenEndpoint(this.config, this.httpClient, this.jwtHelper, this.logger, this.participantsEndpoint, httpCache);
|
|
89
|
+
this.userInfoEndpoint = new UserInfoEndpoint(this.httpClient, this.logger, this.config.data.client_id, this.participantsEndpoint, httpCache);
|
|
81
90
|
}
|
|
82
91
|
/**
|
|
83
92
|
* Get the list of participating identity providers within the scheme.
|
|
@@ -2,6 +2,12 @@ import { IdTokenClaims } from './model/claims.js';
|
|
|
2
2
|
export type { IdTokenClaims, AddressClaim, VerifiedClaims } from './model/claims.js';
|
|
3
3
|
export type { CallbackParams } from './model/callback-params.js';
|
|
4
4
|
export type { TokenResponse } from './model/token-response.js';
|
|
5
|
+
export type HttpCacheConfig = {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
ttl_minutes?: number;
|
|
8
|
+
max_entries?: number;
|
|
9
|
+
max_element_size_bytes?: number;
|
|
10
|
+
};
|
|
5
11
|
export type RelyingPartyClientSdkConfig = {
|
|
6
12
|
data: {
|
|
7
13
|
ca_pem?: string;
|
|
@@ -24,6 +30,7 @@ export type RelyingPartyClientSdkConfig = {
|
|
|
24
30
|
enable_auto_compliance_verification: boolean;
|
|
25
31
|
purpose?: string;
|
|
26
32
|
client_id: string;
|
|
33
|
+
http_cache?: HttpCacheConfig;
|
|
27
34
|
};
|
|
28
35
|
};
|
|
29
36
|
export type Participant = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const packageJsonVersion = "5.
|
|
1
|
+
export declare const packageJsonVersion = "5.1.0";
|
|
2
2
|
export declare const buildUserAgent: (clientId: string) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { getSystemInformation } from './system-information.js';
|
|
2
2
|
// important: Update this every time the package version changes
|
|
3
|
-
export const packageJsonVersion = '5.
|
|
3
|
+
export const packageJsonVersion = '5.1.0';
|
|
4
4
|
export const buildUserAgent = (clientId) => `cid-rp-nodejs-sdk/${packageJsonVersion} ${getSystemInformation()} +${clientId}`;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
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uDnlo3xSaPNVRXM\naCB3lrl4MGo3q9du2rOivlD0/aof8D6aLapkOsNgtwJLW4ntnpOgRTxPgI8HHfXr\nsmUmmdz2RiJ8UjYffl8or9XSlBz4nOsLrPPUy+T/eiLZsooEvmqvz+ptlX49e+pl\npfMWZX8UBNZbp4wd3lw89A/BMBsSLCmQ/prJyw5FDEMvxTg9wUhs/+pLFpaCFc6J\nX5lsYKc5Hf4Dll4t8Hb/fhjV\n-----END CERTIFICATE-----",
|
|
5
|
-
"client_id": "https://rp.directory.sandbox.connectid.com.au/openid_relying_party/280518db-9807-4824-b080-324d94b45f6a",
|
|
6
|
-
"jwks": {
|
|
7
|
-
"keys": [
|
|
8
|
-
{
|
|
9
|
-
"kty": "RSA",
|
|
10
|
-
"use": "sig",
|
|
11
|
-
"x5c": [
|
|
12
|
-
"MIIGTzCCBTegAwIBAgIUGFmcYfeY/2xuP2RRwBwNDdijwEYwDQYJKoZIhvcNAQELBQAwdzELMAkGA1UEBhMCQVUxKDAmBgNVBAoTH2VmdHBvcyBEaWdpdGFsIElkZW50aXR5IFB0eSBMdGQxEjAQBgNVBAsTCWNvbm5lY3RpZDEqMCgGA1UEAxMhY29ubmVjdGlkIFNBTkRCT1ggSXNzdWluZyBDQSAtIEcxMB4XDTI1MDYzMDA5NDUwMFoXDTI2MDczMDA5NDUwMFowfzELMAkGA1UEBhMCQVUxEjAQBgNVBAoTCWNvbm5lY3RpZDEtMCsGA1UECxMkYWI4MzcyNDAtOTYxOC00OTUzLTk2NmUtOTBmZDFmYTYzOTk5MS0wKwYDVQQDEyQyODA1MThkYi05ODA3LTQ4MjQtYjA4MC0zMjRkOTRiNDVmNmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3Z5vutMgWpAfMWbMuta8OXmqpWoU6Dm66CImoot2HhdhOk4T4ijZpntUHbU1k3Lz2hXijj9F1DBVwU5H3g7JuKanw+5uPPz1aLZ1rhHtb7NI+QPx56FoC4VPMw81ZtLeHBda3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HMgdGhlcmVpbi4wQwYIKwYBBQUHAgEWN2h0dHA6Ly9yZXBvc2l0b3J5LnBraS5zYW5kYm94LmNvbm5lY3RpZC5jb20uYXUvcG9saWNpZXMwDQYJKoZIhvcNAQELBQADggEBAJCvUcPNxrnYow+Xnb7MsPIHrMY8T16nG+3iQqtdJXJw5QoWJ2PnuoCQltleU9ilvO++5Uh5PswGLoNiCCtj7aQmOW9w1CL4b2FSgL4nuWfjgQzpNMQtb+dqL928R7GiksK++apW759sunDB/VlFUjypADpZHaLfc0VvtX8nq/o/lmwsycONLV1IKnuWZp0VmY5BsGpnlx57DHqVx2OPu0zu4rkxz9Rmdzdg619vpRYApnbepMiN6NyylF+Et0/qDmK7xMSKNm4JNGldSSh+D43/ccKYFVORcsLKPH4DE+VnWEA+z2DF72BSyLZuS4gD0QP3ZG0XAWktHHrn46PyINo="
|
|
13
|
-
],
|
|
14
|
-
"n": "t2eb7rTIFqQHzFmzLrWvDl5qqVqFOg5uugiJqKLdh4XYTpOE-Io2aZ7VB21NZNy89oV4o4_RdQwVcFOR94Oybimp8Pubjz89Wi2da4R7W-zSPkD8eehaAuFTzMPNWbS3hwXWt2oew19KtL35Hkkz6VCyTVauejZEXMmhWVM-Y4HslUZGcM9zgVW6juLRWlEdbRft5vQl2SSwPOuGz_S_f-ME2CRugQ89Uo19qqF1ptXlJwlZaq2QQFMd_3ioGpLJkSRjU4n8ugXG7myGMXy3IcArdFt5WQz5JwVWSru2oVL6tFZW1b8IgPtTZ48PVQz_e-Y5vKq7sCcTI0Lgrxie2w",
|
|
15
|
-
"e": "AQAB",
|
|
16
|
-
"kid": "lHf9shwoF1wEES2sB9TBafbs0AVrLiU-1_ntzCrBo8A",
|
|
17
|
-
"x5u": "https://keystore.directory.sandbox.connectid.com.au/ab837240-9618-4953-966e-90fd1fa63999/280518db-9807-4824-b080-324d94b45f6a/lHf9shwoF1wEES2sB9TBafbs0AVrLiU-1_ntzCrBo8A.pem",
|
|
18
|
-
"x5t#S256": "l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X9LVUZqiQTCIK+bRZy+gnmRXeGIDKG3WaWthBO8qAfRQQ1Zq4b7HVFL7tZxLgwzfJdjqUyAWOzm1e7x89iL+4pRBQFXY7EWNDSQ6TbgaeStF4bvby0V86S8PtHoj3FxGGSpihDWJ5gj6tbfVqVlgtaU3h6m2NU8rrUsvFm3sE1SVxhgOZpMYEDcr6jZgg7CCZ15eKbOKvIoflhbZsRSii1uIhdaRe2SoB2xZ2DTf8C5blGbYQyfWck6MjkDpqSI="
|
|
26
|
-
],
|
|
27
|
-
"n": "ikku68s3okqL55DLEfiR02l0SMUn9UfZdhOUSGfkrEGBKRuf2ZeUJqGB6jG_bUOuvAL1HQjeddCNkaxpCTfRGKSI3D0p2fr-Aswq_Ms4J2jtkJ_bDL0Zdpjsf0hekKf1j1WCvCJK7zFQ6N7OA5oVp6UFtTFuT68ymeHB5lubKLSkjL4f5SbZBZ-jHw-zoIyiptd0y1KiXXCoIxEbd3Y5b_Dx5aG2YTVzidB0V-RUDoAKJYQbJMVYzlq30P3TkXWD5qwIa6GZr_CZpw6SncbkNqZMDQzgqFhd8J0KczVThXf-qlc4LNh0g0wbYjNcidQ6FDCHJESzDiZwECXT_XFc_w",
|
|
28
|
-
"e": "AQAB",
|
|
29
|
-
"kid": "6kWTo-i7nrIJrdl6jxfDyT0Nprw-aRT0mcZvxvXtKVE",
|
|
30
|
-
"x5u": "https://keystore.directory.sandbox.connectid.com.au/ab837240-9618-4953-966e-90fd1fa63999/280518db-9807-4824-b080-324d94b45f6a/6kWTo-i7nrIJrdl6jxfDyT0Nprw-aRT0mcZvxvXtKVE.pem",
|
|
31
|
-
"x5t#S256": "6kWTo-i7nrIJrdl6jxfDyT0Nprw-aRT0mcZvxvXtKVE",
|
|
32
|
-
"x5dn": "CN=280518db-9807-4824-b080-324d94b45f6a,OU=ab837240-9618-4953-966e-90fd1fa63999,O=connectid,C=AU"
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
"redirect_uri": "https://tpp.localhost/cb"
|
|
37
|
-
},
|
|
38
|
-
"consent": {},
|
|
39
|
-
"description": "NodeJS Conformance Test Template",
|
|
40
|
-
"server": {
|
|
41
|
-
"jwks": {
|
|
42
|
-
"keys": [
|
|
43
|
-
{
|
|
44
|
-
"p": "9ROiJdNH4qHPe4K92GpxUpQY2T2EP2KjbdOp16TFaL6DmXdZLaJzaYEpinR4NtSnuEpO2nl441_kma1JP99p6VdtmLUvTRUeCEUJXdFh_bqhc0INfGHRuXNBeLLQFcrRRS5Vhi50IM_NqYmpO1GEshxNYfKCweTCTkEwsJzIZkM",
|
|
45
|
-
"kty": "RSA",
|
|
46
|
-
"q": "nluxAF8DH-LhGz8qB3qzVhBaD7y5JB_pZ3SMaYPCV92yWXRysgNvYx2CyaWOtrIPabfzTBauR1XXEiLccxzQRy2f8bQ7pwJZtQJJtmC4UwCnNnIcdQ1WsjzzHMqd0p45gJQVnXpxmPfThIZeotToW4f4CTHZjJW8fKbd2zDg61U",
|
|
47
|
-
"d": "a6N1dGahEGBMd9KYBbwyuliqebughkoNsUeBRFDg29wReDYDfxsCx9nIqS-xNtkkVQYdG7t8FKL8IVapbuJGFcLKvu_w6kbJ7v2csTN71DETrIH4W1xHlor0QuCShYdKeUG_xZjkBznVv8m_2FwzpRNo4WaVHQGwNoiBU5cIBmeA9XxlaGuabaagU6F0z4ArJzl0DIR6XjLYH8DTxb4KFuMvouBS_o9eDw-t1ubU5ffD28nyOY7UvSTd2_kUw4xyWqfyCvN5oTvFNFaJ8EmgkaycvPDkxqWIWOBRoCEk2gAz0UV14t4iPCV75czuA5dc9HlzAh57Ds3k3frm8jAUoQ",
|
|
48
|
-
"e": "AQAB",
|
|
49
|
-
"use": "sig",
|
|
50
|
-
"kid": "ruWVspGvgNx3V22h4ufR9yr64sjuOaaVwDB_i5rwdOM",
|
|
51
|
-
"qi": "0dm4Eb27B9VAP8SoXfE7aUSp0RimmBN3LKlucdL5h1LGyaCFNeRgYHJHo6BL33TKL-tL8m9y0ztyePtVe_EMGtP0QEws6oti8-SUK0ynQ4cXet8fH5uqJx-ArGgW_KDi3xvTeScy4faK3toyzStPZCG4jFdWyv1f2vbv4qg4rDU",
|
|
52
|
-
"dp": "8fkPmK8yA6bl17nvvbTi7LjCjAN8BqVaXT6mK_9I1jF8d9Lp3u_NafcYT9bNNr3iV0gu8PEMldsBN2Zrsz_gL36d_C-wYzgdbebT56irSryxWb522D8wth0BIK3UXB_jXZ3w3UoSaK8kDWeZCrNjBASDttidl9lIq8Eb1NUH3Ec",
|
|
53
|
-
"alg": "PS256",
|
|
54
|
-
"dq": "TTdAc4HgsCecxABkqgj2cTy_7XSEgkzdLojx_nE0zktXr67MTmjGY3n8T_7eO89PHKmJhMx6ZmZA3KMLA0ZFeK-SkfTkMWc__rcC4l7_AdoLrsyte5XpdDesA5n4or5sI3oRoBwYUBJnnPM4KgXO1vLRywn3nklVAyMKgtqukZE",
|
|
55
|
-
"n": "l5nlgOnp5m-klhQGYjcxytnu-vM6CpPFyhzuLII31Y4JT2sJjpItN4DOWRVs5sWL7aj_otQNYWrBz9JJOUJJ2oGIQDq2UBn9nHDTKqCWCZ8r2Gtq9U7z-mFfHx8f67hY6KFmeuMdVcqCBcNN76ZHtCkvRiziglvtYkMpovWF2cGqeyCuunlTr0clMe2N_iA0wOgLwiYDBtvqLi8DBshRcGzTHHlncW-OLdspu0saOb2igGMEaBAuzY2EsL0E2jZODB5bfPfA3WDuo7Swi2FVqDuaudm3pJofOr02lDidJNQCOBJRJhHVH867vFK12_xtgCDAydWn9qNub19nDwl1Pw"
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import RelyingPartyClientSdk from '../relying-party-client-sdk.js';
|
|
2
|
-
import { conformanceConfig } from './conformance-config.js';
|
|
3
|
-
import config from './config.json';
|
|
4
|
-
import variant from './variant.json';
|
|
5
|
-
import packageJson from '../../package.json';
|
|
6
|
-
import { parse } from 'url';
|
|
7
|
-
import { ConformanceApi } from './api/conformance-api.js';
|
|
8
|
-
import winston from 'winston';
|
|
9
|
-
import { describe, before, it } from 'node:test';
|
|
10
|
-
import assert from 'node:assert';
|
|
11
|
-
const alias = 'conformance-nodejs-' + Date.now();
|
|
12
|
-
const conformanceEnv = process.env.CONFORMANCE_ENV || 'production';
|
|
13
|
-
const conformanceApiToken = process.env.CONFORMANCE_API_TOKEN || '';
|
|
14
|
-
const conformanceNodeVersion = process.env.CONFORMANCE_NODE_VERSION || 'unknown';
|
|
15
|
-
const participantsEnv = conformanceEnv === 'production' ? '' : conformanceEnv;
|
|
16
|
-
conformanceConfig.data.registry_participants_uri = `https://api.sandbox.connectid.com.au/oidf-conformance/participants?alias=a/${alias}&env=${participantsEnv}`;
|
|
17
|
-
const rpClient = new RelyingPartyClientSdk(conformanceConfig);
|
|
18
|
-
const conformanceEnvUrls = new Map([
|
|
19
|
-
['staging', 'https://staging.certification.openid.net/'],
|
|
20
|
-
['production', 'https://www.certification.openid.net/']
|
|
21
|
-
]);
|
|
22
|
-
const conformanceBaseUrl = conformanceEnvUrls.get(conformanceEnv);
|
|
23
|
-
console.log(`Selected environment ${conformanceEnv}, baseUrl: ${conformanceBaseUrl}`);
|
|
24
|
-
const conformanceApi = new ConformanceApi(conformanceApiToken, conformanceBaseUrl);
|
|
25
|
-
describe('Conformance Test', { timeout: 600000 }, () => {
|
|
26
|
-
let planInfo;
|
|
27
|
-
before(async () => {
|
|
28
|
-
const planName = 'fapi2-message-signing-id1-client-test-plan';
|
|
29
|
-
config.description = `NodeJS SDK ${packageJson.version} (NodeJS v${conformanceNodeVersion})`;
|
|
30
|
-
config.alias = alias;
|
|
31
|
-
planInfo = await conformanceApi.createPlan(planName, JSON.stringify(variant), config);
|
|
32
|
-
});
|
|
33
|
-
it('should execute the conformance test', async () => {
|
|
34
|
-
const testModules = planInfo.modules.map((module) => module.testModule);
|
|
35
|
-
for (const testName of testModules) {
|
|
36
|
-
console.log(`Executing test ${testName}`);
|
|
37
|
-
// We are mimicking an application log here.
|
|
38
|
-
const logger = createTestLogger(testName);
|
|
39
|
-
rpClient.logger = logger;
|
|
40
|
-
const testInstance = await conformanceApi.createTestFromPlan(planInfo.id, testName);
|
|
41
|
-
let testInformation = await conformanceApi.getTestInformation(testInstance.id);
|
|
42
|
-
logger.info(`Executing version ${testInformation.version} of ${testName}`);
|
|
43
|
-
console.log(`See ${conformanceBaseUrl}log-detail.html?log=${testInstance.id}`);
|
|
44
|
-
const idps = await rpClient.getParticipants();
|
|
45
|
-
const authorisationServerId = idps[0].AuthorisationServers[0].AuthorisationServerId;
|
|
46
|
-
logger.info(`Sending PAR to ${authorisationServerId}`);
|
|
47
|
-
const essentialClaims = ['given_name', 'middle_name', 'family_name', 'phone_number', 'email', 'address', 'birthdate', 'txn'];
|
|
48
|
-
const parResponse = await rpClient.sendPushedAuthorisationRequest(authorisationServerId, essentialClaims);
|
|
49
|
-
const response = await fetch(parResponse.authUrl, {
|
|
50
|
-
redirect: 'manual',
|
|
51
|
-
});
|
|
52
|
-
if (response.status !== 303) {
|
|
53
|
-
console.error(`Expected 303, got ${response.status}`);
|
|
54
|
-
throw new Error(`Expected 303, got ${response.status}`);
|
|
55
|
-
}
|
|
56
|
-
const location = response.headers.get('location');
|
|
57
|
-
if (!location) {
|
|
58
|
-
throw new Error('No location header');
|
|
59
|
-
}
|
|
60
|
-
const locationObj = parse(location, true);
|
|
61
|
-
logger.info(`Executing ${testName}`);
|
|
62
|
-
try {
|
|
63
|
-
logger.info('Getting tokens');
|
|
64
|
-
await rpClient.retrieveTokens(authorisationServerId, locationObj.query, parResponse.codeVerifier, parResponse.state, parResponse.nonce);
|
|
65
|
-
logger.info('Tokens successfully retrieved');
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
logger.error('An error occured while getting tokens:' + getErrorMessage(e));
|
|
69
|
-
console.log(e);
|
|
70
|
-
}
|
|
71
|
-
while (testInformation.status !== 'FINISHED') {
|
|
72
|
-
await delay(250);
|
|
73
|
-
testInformation = await conformanceApi.getTestInformation(testInstance.id);
|
|
74
|
-
}
|
|
75
|
-
logger.info(`Test finished with result: ${testInformation.result}, status: ${testInformation.status}`);
|
|
76
|
-
console.log('Full test information:', JSON.stringify(testInformation, null, 2));
|
|
77
|
-
assert.ok(['WARNING', 'PASSED'].includes(testInformation.result));
|
|
78
|
-
if (testInformation.result === 'WARNING') {
|
|
79
|
-
console.log(`*** A warning occurred while executing ${testName}, please check the logs!!! ***`);
|
|
80
|
-
}
|
|
81
|
-
// TODO: download the logs and store them in Github
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
function delay(time) {
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
return new Promise((resolve) => setTimeout(resolve, time));
|
|
88
|
-
}
|
|
89
|
-
function getErrorMessage(error) {
|
|
90
|
-
if (error instanceof Error)
|
|
91
|
-
return error.message;
|
|
92
|
-
return String(error);
|
|
93
|
-
}
|
|
94
|
-
function createTestLogger(testName) {
|
|
95
|
-
return winston.createLogger({
|
|
96
|
-
level: 'info',
|
|
97
|
-
format: winston.format.simple(),
|
|
98
|
-
defaultMeta: { service: 'conformance-test' },
|
|
99
|
-
transports: [new winston.transports.File({ filename: `logs/${testName}.log` })],
|
|
100
|
-
});
|
|
101
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "client_auth_type": "private_key_jwt", "fapi_request_method": "signed_non_repudiation", "fapi_client_type": "oidc", "sender_constrain": "mtls", "fapi_profile": "connectid_au", "fapi_response_mode": "plain_response" }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import jsonPackage from '../../package.json';
|
|
2
|
-
import { describe, it } from 'node:test';
|
|
3
|
-
import assert from 'node:assert';
|
|
4
|
-
import { config } from '../config.js';
|
|
5
|
-
import RelyingPartyClientSdk from '../relying-party-client-sdk.js';
|
|
6
|
-
describe('RelyingPartyClientSdk', () => {
|
|
7
|
-
it('should retrieve user agent and match details', async () => {
|
|
8
|
-
const version = jsonPackage.version;
|
|
9
|
-
const newConfig = {
|
|
10
|
-
...config,
|
|
11
|
-
data: {
|
|
12
|
-
...config.data,
|
|
13
|
-
registry_participants_uri: 'https://api.sandbox.connectid.com.au/useragent-responder/participants',
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
const participants = await new RelyingPartyClientSdk(newConfig).getParticipants();
|
|
17
|
-
const regex = /(.*?)\/(.*?)\s(\(.*?\))\s(\+.*)/;
|
|
18
|
-
const organisationName = participants[0].OrganisationName;
|
|
19
|
-
const match = organisationName.match(regex);
|
|
20
|
-
assert.ok(match, `Organisation name '${organisationName}' failed to match pattern '${regex.source}'`);
|
|
21
|
-
const namePart = match[1];
|
|
22
|
-
const versionPart = match[2];
|
|
23
|
-
const platformPart = match[3].trim();
|
|
24
|
-
const clientIdPart = match[4];
|
|
25
|
-
assert.strictEqual(namePart, 'cid-rp-nodejs-sdk');
|
|
26
|
-
assert.strictEqual(versionPart, version);
|
|
27
|
-
assert.match(platformPart, /\(.+; .+; .+\)/);
|
|
28
|
-
assert.strictEqual(clientIdPart, '+https://rp.directory.sandbox.connectid.com.au/openid_relying_party/280518db-9807-4824-b080-324d94b45f6a');
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import { getCertificate } from '../utils/cert-utils.js';
|
|
4
|
-
test('should use content when certificate content and path are passed', () => {
|
|
5
|
-
assert.strictEqual(getCertificate('.gitignore', 'abcdefg'), 'abcdefg');
|
|
6
|
-
});
|
|
7
|
-
test('should use path when content is falsy', () => {
|
|
8
|
-
assert.ok(getCertificate('.gitignore', '').toString().includes('# These are some examples of commonly ignored file patterns.'));
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
assert.ok(getCertificate('.gitignore', 0).toString().includes('# These are some examples of commonly ignored file patterns.'));
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
assert.ok(getCertificate('.gitignore', null).toString().includes('# These are some examples of commonly ignored file patterns.'));
|
|
13
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import { partition } from '../utils/functional-utils.js';
|
|
3
|
-
import assert from 'node:assert';
|
|
4
|
-
test('should partition list', () => {
|
|
5
|
-
const [odd, even] = partition([1, 2, 3, 4, 5], (input) => input % 2 == 1);
|
|
6
|
-
assert.deepEqual(odd, [1, 3, 5]);
|
|
7
|
-
assert.deepEqual(even, [2, 4]);
|
|
8
|
-
});
|
|
9
|
-
test('should partition empty list', () => {
|
|
10
|
-
const [odd, even] = partition([], (input) => input % 2 == 1);
|
|
11
|
-
assert.deepEqual(odd, []);
|
|
12
|
-
assert.deepEqual(even, []);
|
|
13
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import ParticipantFilter from '../filter/participant-filters.js';
|
|
2
|
-
import { participantsTestData } from '../test-data/participants-test-data.js';
|
|
3
|
-
import { describe, it } from 'node:test';
|
|
4
|
-
import assert from 'node:assert';
|
|
5
|
-
const participantsFilter = new ParticipantFilter();
|
|
6
|
-
describe('removeOutOfDateCertifications', () => {
|
|
7
|
-
it('should remove all certifications as they are all after the specified date', () => {
|
|
8
|
-
const filteredParticipants = participantsFilter.removeOutOfDateCertifications(getParticipantsTestData(), new Date('2005-01-01'));
|
|
9
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[0].AuthorisationServerCertifications.length, 0);
|
|
10
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[1].AuthorisationServerCertifications.length, 0);
|
|
11
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers[0].AuthorisationServerCertifications.length, 0);
|
|
12
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers[0].AuthorisationServerCertifications.length, 0);
|
|
13
|
-
});
|
|
14
|
-
it('should keep all certification as they span the specified date', () => {
|
|
15
|
-
const filteredParticipants = participantsFilter.removeOutOfDateCertifications(getParticipantsTestData(), new Date('2024-01-01'));
|
|
16
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[0].AuthorisationServerCertifications.length, 4);
|
|
17
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[1].AuthorisationServerCertifications.length, 4);
|
|
18
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers[0].AuthorisationServerCertifications.length, 4);
|
|
19
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers[0].AuthorisationServerCertifications.length, 1);
|
|
20
|
-
});
|
|
21
|
-
it('should keep all certification that span the specified date', () => {
|
|
22
|
-
const filteredParticipants = participantsFilter.removeOutOfDateCertifications(getParticipantsTestData(), new Date('2024-05-20'));
|
|
23
|
-
const testData = getParticipantsTestData();
|
|
24
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[0].AuthorisationServerCertifications.length, 3);
|
|
25
|
-
assert.ok(!filteredParticipants[0].AuthorisationServers[0].AuthorisationServerCertifications.includes(testData[0].AuthorisationServers[0].AuthorisationServerCertifications[0]));
|
|
26
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[1].AuthorisationServerCertifications.length, 2);
|
|
27
|
-
assert.ok(!filteredParticipants[0].AuthorisationServers[1].AuthorisationServerCertifications.includes(testData[0].AuthorisationServers[1].AuthorisationServerCertifications[0]));
|
|
28
|
-
assert.ok(!filteredParticipants[0].AuthorisationServers[1].AuthorisationServerCertifications.includes(testData[0].AuthorisationServers[1].AuthorisationServerCertifications[1]));
|
|
29
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers[0].AuthorisationServerCertifications.length, 1);
|
|
30
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers[0].AuthorisationServerCertifications.length, 0);
|
|
31
|
-
});
|
|
32
|
-
it('should remove all certifications as they are all before the specified date', () => {
|
|
33
|
-
const filteredParticipants = participantsFilter.removeOutOfDateCertifications(getParticipantsTestData(), new Date('2025-01-01'));
|
|
34
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[0].AuthorisationServerCertifications.length, 0);
|
|
35
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[1].AuthorisationServerCertifications.length, 0);
|
|
36
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers[0].AuthorisationServerCertifications.length, 0);
|
|
37
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers[0].AuthorisationServerCertifications.length, 0);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('removeUnofficialCertifications', () => {
|
|
41
|
-
it('should remove certifications that do not have status "Certified"', () => {
|
|
42
|
-
const filteredParticipants = participantsFilter.removeUnofficialCertifications(getParticipantsTestData());
|
|
43
|
-
const testData = getParticipantsTestData();
|
|
44
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[0].AuthorisationServerCertifications.length, 3);
|
|
45
|
-
assert.ok(!filteredParticipants[0].AuthorisationServers[0].AuthorisationServerCertifications.includes(testData[0].AuthorisationServers[0].AuthorisationServerCertifications[3]));
|
|
46
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers[1].AuthorisationServerCertifications.length, 3);
|
|
47
|
-
assert.ok(!filteredParticipants[0].AuthorisationServers[1].AuthorisationServerCertifications.includes(testData[0].AuthorisationServers[1].AuthorisationServerCertifications[2]));
|
|
48
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers[0].AuthorisationServerCertifications.length, 0);
|
|
49
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers[0].AuthorisationServerCertifications.length, 1);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe('removeInactiveAuthServers', () => {
|
|
53
|
-
it('should remove Auth Servers that do not have the Redirect:FAPI certification', () => {
|
|
54
|
-
const filteredParticipants = participantsFilter.removeInactiveAuthServers(getParticipantsTestData());
|
|
55
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 2);
|
|
56
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 0);
|
|
57
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 0);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('removeParticipantsWithoutAuthServers', () => {
|
|
61
|
-
it('should remove Participants that do not have any auth servers', () => {
|
|
62
|
-
const participants = getParticipantsTestData();
|
|
63
|
-
participants[1].AuthorisationServers = [];
|
|
64
|
-
const filteredParticipants = participantsFilter.removeParticipantsWithoutAuthServers(participants);
|
|
65
|
-
assert.strictEqual(filteredParticipants.length, 2);
|
|
66
|
-
assert.ok(filteredParticipants.includes(participants[0]));
|
|
67
|
-
assert.ok(filteredParticipants.includes(participants[2]));
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe('filterAuthServersForSupportedClaims', () => {
|
|
71
|
-
it('should filter auth servers that do not have the over25 required claims', () => {
|
|
72
|
-
const filteredParticipants = participantsFilter.filterAuthServersForSupportedClaims(getParticipantsTestData(), ['over25']);
|
|
73
|
-
const testData = getParticipantsTestData();
|
|
74
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 1);
|
|
75
|
-
assert.deepStrictEqual(filteredParticipants[0].AuthorisationServers[0], testData[0].AuthorisationServers[0]);
|
|
76
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 0);
|
|
77
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 0);
|
|
78
|
-
});
|
|
79
|
-
it('should filter auth servers that match multiple required claims', () => {
|
|
80
|
-
const filteredParticipants = participantsFilter.filterAuthServersForSupportedClaims(getParticipantsTestData(), ['address', 'over18']);
|
|
81
|
-
const testData = getParticipantsTestData();
|
|
82
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 0);
|
|
83
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 1);
|
|
84
|
-
assert.deepStrictEqual(filteredParticipants[1].AuthorisationServers[0], testData[1].AuthorisationServers[0]);
|
|
85
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 0);
|
|
86
|
-
});
|
|
87
|
-
it('should find auth servers with the name claim when asking for a name component', () => {
|
|
88
|
-
const filteredParticipants = participantsFilter.filterAuthServersForSupportedClaims(getParticipantsTestData(), ['given_name']);
|
|
89
|
-
const testData = getParticipantsTestData();
|
|
90
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 1);
|
|
91
|
-
assert.deepStrictEqual(filteredParticipants[0].AuthorisationServers[0], testData[0].AuthorisationServers[0]);
|
|
92
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 0);
|
|
93
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 0);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
describe('removeFallbackIdentityServiceProvider', () => {
|
|
97
|
-
it('should filter out any manual verification auth servers', () => {
|
|
98
|
-
const filteredParticipants = participantsFilter.removeFallbackIdentityServiceProvider(getParticipantsTestData());
|
|
99
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 2);
|
|
100
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 1);
|
|
101
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 0);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe('filterForFallbackIdentityServiceProviders', () => {
|
|
105
|
-
it('should return any auth servers that have the fallback provider certification', () => {
|
|
106
|
-
const filteredParticipants = participantsFilter.filterForFallbackIdentityServiceProviders(getParticipantsTestData());
|
|
107
|
-
const testData = getParticipantsTestData();
|
|
108
|
-
assert.strictEqual(filteredParticipants.length, 3);
|
|
109
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 0);
|
|
110
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 0);
|
|
111
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 1);
|
|
112
|
-
assert.deepStrictEqual(filteredParticipants[2], testData[2]);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
describe('filterForRequiredCertifications', () => {
|
|
116
|
-
it('should return any auth servers that have the TDIF provider certification', () => {
|
|
117
|
-
const certificationFilters = [{ profileVariant: 'Identity Provider', profileType: 'TDIF Accreditation' }];
|
|
118
|
-
const filteredParticipants = participantsFilter.filterForRequiredCertifications(getParticipantsTestData(), certificationFilters);
|
|
119
|
-
const testData = getParticipantsTestData();
|
|
120
|
-
assert.deepStrictEqual(filteredParticipants[0].AuthorisationServers[0], testData[0].AuthorisationServers[1]);
|
|
121
|
-
assert.deepStrictEqual(filteredParticipants[1].AuthorisationServers[0], testData[1].AuthorisationServers[0]);
|
|
122
|
-
assert.strictEqual(filteredParticipants.length, 3);
|
|
123
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 1);
|
|
124
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 1);
|
|
125
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 0);
|
|
126
|
-
});
|
|
127
|
-
it('should return no auth servers when no auth servers have the requested certification', () => {
|
|
128
|
-
const certificationFilters = [{ profileType: 'Bad Profile', profileVariant: 'Bad Variant' }];
|
|
129
|
-
const filteredParticipants = participantsFilter.filterForRequiredCertifications(getParticipantsTestData(), certificationFilters);
|
|
130
|
-
assert.strictEqual(filteredParticipants.length, 3);
|
|
131
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 0);
|
|
132
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 0);
|
|
133
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 0);
|
|
134
|
-
});
|
|
135
|
-
it('should return only auth servers that have all matching certifications', () => {
|
|
136
|
-
const certificationFilters = [
|
|
137
|
-
{ profileType: 'TDIF Accreditation', profileVariant: 'Identity Provider' },
|
|
138
|
-
{ profileType: 'Channel', profileVariant: 'web' },
|
|
139
|
-
];
|
|
140
|
-
const filteredParticipants = participantsFilter.filterForRequiredCertifications(getParticipantsTestData(), certificationFilters);
|
|
141
|
-
const testData = getParticipantsTestData();
|
|
142
|
-
assert.deepStrictEqual(filteredParticipants[0].AuthorisationServers[0], testData[0].AuthorisationServers[1]);
|
|
143
|
-
assert.strictEqual(filteredParticipants.length, 3);
|
|
144
|
-
assert.strictEqual(filteredParticipants[0].AuthorisationServers.length, 1);
|
|
145
|
-
assert.strictEqual(filteredParticipants[1].AuthorisationServers.length, 0);
|
|
146
|
-
assert.strictEqual(filteredParticipants[2].AuthorisationServers.length, 0);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
function getParticipantsTestData() {
|
|
150
|
-
return JSON.parse(JSON.stringify(participantsTestData));
|
|
151
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|