@connectid-tools/rp-nodejs-sdk 4.0.5 → 4.2.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 +8 -2
- package/config.js +2 -2
- package/package.json +7 -6
- package/relying-party-client-sdk.js +18 -9
- package/utils/cert-utils.d.ts +1 -1
- package/utils/system-information.d.ts +1 -0
- package/utils/system-information.js +27 -0
- package/utils/user-agent.d.ts +2 -0
- package/utils/user-agent.js +6 -0
package/README.md
CHANGED
|
@@ -413,10 +413,16 @@ The required function parameters are:
|
|
|
413
413
|
|
|
414
414
|
# Release Notes
|
|
415
415
|
|
|
416
|
-
### 4.0
|
|
416
|
+
### 4.2.0 (Aug 8, 2025)
|
|
417
|
+
- `cba_loyalty` claim.
|
|
418
|
+
|
|
419
|
+
### 4.1.0 (Feb 25, 2025)
|
|
420
|
+
- Implemented user-agent support.
|
|
421
|
+
|
|
422
|
+
### 4.0.5 (Feb 24, 2025)
|
|
417
423
|
- Add README.md and license files to bundle.
|
|
418
424
|
|
|
419
|
-
### 4.0.4 (Feb 21,
|
|
425
|
+
### 4.0.4 (Feb 21, 2025)
|
|
420
426
|
- Remove `declarationMap`.
|
|
421
427
|
|
|
422
428
|
### 4.0.3 (Nov 29, 2024)
|
package/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const config = {
|
|
2
2
|
data: {
|
|
3
3
|
// Set the signing Key Id based on what is contained in the JWKS
|
|
4
|
-
signing_kid: '
|
|
4
|
+
signing_kid: 'lHf9shwoF1wEES2sB9TBafbs0AVrLiU-1_ntzCrBo8A',
|
|
5
5
|
// The location of the signing certificate and key that are used for signing purposes
|
|
6
6
|
signing_key: './certs/signing.key',
|
|
7
7
|
signing_pem: './certs/signing.pem', // TODO not being used atm
|
|
@@ -9,7 +9,7 @@ export const config = {
|
|
|
9
9
|
transport_key: './certs/transport.key',
|
|
10
10
|
transport_pem: './certs/transport.pem',
|
|
11
11
|
// The location of the root certificate for the trust authority
|
|
12
|
-
ca_pem: './certs/
|
|
12
|
+
ca_pem: './certs/ca.pem',
|
|
13
13
|
// This is the URL that this application is actually running on and using for callbacks (noting that multiple may be registered for the client)
|
|
14
14
|
application_redirect_uri: 'https://tpp.localhost/cb',
|
|
15
15
|
// The registry API endpoint that will list all participants with their auth server details
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@connectid-tools/rp-nodejs-sdk",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Digital Identity Relying Party Node SDK",
|
|
5
5
|
"main": "relying-party-client-sdk.js",
|
|
6
6
|
"types": "relying-party-client-sdk.d.ts",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"test": "node --import tsx --test src/tests/*.test.ts",
|
|
12
12
|
"test:watch": "node --watch --test --import tsx src/tests/*.test.ts",
|
|
13
13
|
"test:conformance": "node --import tsx --test src/conformance/conformance.test.ts",
|
|
14
|
+
"test:integration": "npm run build && node --import tsx --test src/integration/*.test.ts",
|
|
14
15
|
"prebuild": "rm -rf lib",
|
|
15
16
|
"build": "tsc",
|
|
16
17
|
"postbuild": "cp package.json README.md license lib && cd lib && node ../node_modules/add-js-extension/dist/bin.js . --once && replace-in-files --string='${process.env.SDK_VERSION}' --replacement=$npm_package_version relying-party-client-sdk.js && cd .."
|
|
@@ -35,13 +36,13 @@
|
|
|
35
36
|
"winston": "^3.17.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^20.
|
|
39
|
+
"@types/node": "^20.19.9",
|
|
39
40
|
"@types/openid-client": "^3.7.0",
|
|
40
41
|
"add-js-extension": "^1.0.4",
|
|
41
|
-
"eslint": "^9.
|
|
42
|
-
"prettier": "^3.
|
|
42
|
+
"eslint": "^9.32.0",
|
|
43
|
+
"prettier": "^3.6.2",
|
|
43
44
|
"replace-in-files-cli": "^2.2.0",
|
|
44
|
-
"tsx": "^4.
|
|
45
|
-
"typescript": "^5.
|
|
45
|
+
"tsx": "^4.20.3",
|
|
46
|
+
"typescript": "^5.9.2"
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -15,8 +15,9 @@ import { getLogger } from './logger.js';
|
|
|
15
15
|
import ParticipantFilters from './filter/participant-filters.js';
|
|
16
16
|
import { illegalPurposeChars, isValidCertificate, validatePurpose } from './validator.js';
|
|
17
17
|
import { generatePushAuthorisationRequestParams } from './utils/request-utils.js';
|
|
18
|
+
import { buildUserAgent } from './utils/user-agent.js';
|
|
18
19
|
// The extended list of claims which can be requested for a user
|
|
19
|
-
const extendedClaimList = ['over16', 'over18', 'over21', 'over25', 'over65', 'beneficiary_account_au', 'beneficiary_account_au_payid', 'beneficiary_account_international'];
|
|
20
|
+
const extendedClaimList = ['over16', 'over18', 'over21', 'over25', 'over65', 'beneficiary_account_au', 'beneficiary_account_au_payid', 'beneficiary_account_international', 'cba_loyalty'];
|
|
20
21
|
export default class RelyingPartyClientSdk {
|
|
21
22
|
constructor(config) {
|
|
22
23
|
this.purpose = 'verifying your identity';
|
|
@@ -42,7 +43,7 @@ export default class RelyingPartyClientSdk {
|
|
|
42
43
|
this.signingKey = getCertificate(this.config.data.signing_key, this.config.data.signing_key_content);
|
|
43
44
|
this.caPem = getCertificate(this.config.data.ca_pem, this.config.data.ca_pem_content);
|
|
44
45
|
this.logger = getLogger(this.config.data.log_level);
|
|
45
|
-
this.logger.info(`Creating RelyingPartyClientSdk - version 4.0
|
|
46
|
+
this.logger.info(`Creating RelyingPartyClientSdk - version 4.2.0`);
|
|
46
47
|
if (this.config.data.purpose) {
|
|
47
48
|
const purposeValidation = validatePurpose(this.config.data.purpose);
|
|
48
49
|
if (purposeValidation === 'INVALID_LENGTH') {
|
|
@@ -74,7 +75,7 @@ export default class RelyingPartyClientSdk {
|
|
|
74
75
|
globalAgent.options.key = this.transportKey;
|
|
75
76
|
globalAgent.options.ca = [this.caPem, ...rootCertificates];
|
|
76
77
|
custom.setHttpOptionsDefaults({ timeout: 10000 });
|
|
77
|
-
// 4.0
|
|
78
|
+
// 4.2.0 is replaced with `postbuild` script in package.json (see replace-in-files)
|
|
78
79
|
this.logger.info(`Using ${this.config.data.transport_key_content ? 'transport_key_content' : 'transport_key'} config prop`);
|
|
79
80
|
this.logger.info(`Using ${this.config.data.transport_pem_content ? 'transport_pem_content' : 'transport_pem'} config prop`);
|
|
80
81
|
this.logger.info(`Using ${this.config.data.ca_pem_content ? 'ca_pem_content' : 'ca_pem'} config prop`);
|
|
@@ -130,7 +131,11 @@ export default class RelyingPartyClientSdk {
|
|
|
130
131
|
return new Date();
|
|
131
132
|
}
|
|
132
133
|
async fetchParticipants(participantsUri) {
|
|
133
|
-
const response = await fetch(participantsUri
|
|
134
|
+
const response = await fetch(participantsUri, {
|
|
135
|
+
headers: {
|
|
136
|
+
'User-Agent': buildUserAgent(this.config.data.client.client_id),
|
|
137
|
+
},
|
|
138
|
+
});
|
|
134
139
|
if (!response.ok) {
|
|
135
140
|
throw new Error(`Failed to retrieve participants from ${participantsUri}: status (${response.status})`);
|
|
136
141
|
}
|
|
@@ -142,8 +147,8 @@ export default class RelyingPartyClientSdk {
|
|
|
142
147
|
this.cachedParticipants = await this.fetchParticipants(participantsUri);
|
|
143
148
|
this.cachedParticipantsExpiry = currentTime + (this.config.data.cache_ttl ?? this.default_cache_ttl) * 1000;
|
|
144
149
|
}
|
|
145
|
-
// ensure the cached value remain untouched down the call stack by returning a deep copy
|
|
146
|
-
return this.cachedParticipants.map(participant => Object.assign({}, participant));
|
|
150
|
+
// ensure the cached value remain untouched down the call stack by returning a deep copy
|
|
151
|
+
return this.cachedParticipants.map((participant) => Object.assign({}, participant));
|
|
147
152
|
}
|
|
148
153
|
// Create and send a pushed authorisation request to the specified authorisation
|
|
149
154
|
// server to allow the initiation of an OIDC flow.
|
|
@@ -320,7 +325,11 @@ export default class RelyingPartyClientSdk {
|
|
|
320
325
|
const keyset = await this.getKeyset();
|
|
321
326
|
const fapiClient = new localIssuer.FAPI1Client(this.config.data.client, keyset);
|
|
322
327
|
this.logger.debug(`Discovered client ${JSON.stringify(fapiClient)}`);
|
|
323
|
-
fapiClient[custom.http_options] = () => ({
|
|
328
|
+
fapiClient[custom.http_options] = () => ({
|
|
329
|
+
key: this.transportKey,
|
|
330
|
+
cert: this.transportPem,
|
|
331
|
+
headers: { 'x-fapi-interaction-id': xFapiInteractionId },
|
|
332
|
+
});
|
|
324
333
|
return { fapiClient, localIssuer };
|
|
325
334
|
}
|
|
326
335
|
async generateRequest(fapiClient, claims, purpose) {
|
|
@@ -341,8 +350,8 @@ export default class RelyingPartyClientSdk {
|
|
|
341
350
|
});
|
|
342
351
|
const clientAssertionPayload = {
|
|
343
352
|
clientAssertionPayload: {
|
|
344
|
-
aud: fapiClient.issuer.issuer
|
|
345
|
-
}
|
|
353
|
+
aud: fapiClient.issuer.issuer,
|
|
354
|
+
},
|
|
346
355
|
};
|
|
347
356
|
this.logger.debug('Generated request object: ' + JSON.stringify(request));
|
|
348
357
|
const { request_uri } = await fapiClient.pushedAuthorizationRequest({ request }, clientAssertionPayload);
|
package/utils/cert-utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getCertificate: (certificatePath?: string, certificateContent?: string) => string |
|
|
1
|
+
export declare const getCertificate: (certificatePath?: string, certificateContent?: string) => string | NonSharedBuffer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getSystemInformation: () => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
export const getSystemInformation = () => {
|
|
3
|
+
const platform = os.platform(); // 'darwin', 'win32', 'linux', etc.
|
|
4
|
+
const arch = os.arch(); // 'x64', 'arm64', etc.
|
|
5
|
+
const release = os.release(); // OS version like '10.15.7' or '10.0.18363'
|
|
6
|
+
// Get Node.js version
|
|
7
|
+
const nodeVersion = process.version; // e.g., 'v16.13.0'
|
|
8
|
+
let userAgent;
|
|
9
|
+
if (platform === 'darwin') {
|
|
10
|
+
// macOS
|
|
11
|
+
const chip = arch === 'arm64' ? 'Apple Silicon' : 'Intel'; // Check if M1 chip (arm64)
|
|
12
|
+
userAgent = `(${platform}; ${chip} Mac OS X ${release}; node${nodeVersion.replace('v', ' ')})`;
|
|
13
|
+
}
|
|
14
|
+
else if (platform === 'win32') {
|
|
15
|
+
// Windows
|
|
16
|
+
userAgent = `(${platform}; ${arch} Windows NT ${release}; node${nodeVersion.replace('v', ' ')})`;
|
|
17
|
+
}
|
|
18
|
+
else if (platform === 'linux') {
|
|
19
|
+
// Linux
|
|
20
|
+
userAgent = `(${platform}; ${arch} ${release}; node${nodeVersion.replace('v', ' ')})`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// For any other platform (e.g., unknown)
|
|
24
|
+
userAgent = `(${platform}; ${arch} ${release}; node${nodeVersion.replace('v', ' ')})`;
|
|
25
|
+
}
|
|
26
|
+
return userAgent;
|
|
27
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { getSystemInformation } from './system-information.js';
|
|
2
|
+
// important: Update this every time the package version changes
|
|
3
|
+
export const packageJsonVersion = '4.2.0';
|
|
4
|
+
export const buildUserAgent = (clientId) => {
|
|
5
|
+
return `cid-rp-nodejs-sdk/${packageJsonVersion} ${getSystemInformation()} +${clientId}`;
|
|
6
|
+
};
|