Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-standard-components",
"version": "19.11.3",
"version": "19.12.0-snapshot.1",
"description": "A set of standard components for connecting to Mojaloop API enabled Switches",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/WSO2Auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class WSO2Auth extends EventEmitter {
*/
constructor(opts) {
super({ captureExceptions: true });
this._logger = opts.logger.push({ component: this.constructor.name });
this._logger = opts.logger.child({ component: this.constructor.name });
this._refreshSeconds = opts.refreshSeconds || DEFAULT_REFRESH_INTERVAL_SECONDS;
this._refreshRetrySeconds = opts.refreshRetrySeconds || DEFAULT_REFRESH_RETRY_INTERVAL_SECONDS;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/jws/jwsSigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const uriRegex = /(?:^.*)(\/(participants|parties|quotes|bulkQuotes|transfers|bu
*/
class JwsSigner {
constructor(config) {
this.logger = config.logger?.push({ component: this.constructor.name }) || console;
this.logger = config.logger?.child({ component: this.constructor.name }) || console;

if(!config.signingKey) {
throw new Error('Signing key must be supplied as config argument');
Expand Down
9 changes: 4 additions & 5 deletions src/lib/jws/jwsValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const SIGNATURE_ALGORITHMS = ['RS256', 'ES256'];
*/
class JwsValidator {
constructor(config) {
this.logger = config.logger?.push({ component: this.constructor.name }) || console;
this.logger = config.logger?.child({ component: this.constructor.name }) || console;

if(!config.validationKeys) {
throw new Error('Validation keys must be supplied as config argument');
Expand All @@ -61,7 +61,7 @@ class JwsValidator {
const { headers, body, data } = request; // todo: define, what to use: only body OR data ?
const payload = body || data;

this.logger.isDebugEnabled && this.logger.debug(`Validating JWS on request with headers: ${safeStringify(headers)} and body: ${safeStringify(payload)}`);
this.logger.debug('Validating JWS on request with headers and body: ', { headers, body });

if(!payload) {
throw new Error('Cannot validate JWS without a body');
Expand All @@ -88,8 +88,7 @@ class JwsValidator {
const { protectedHeader, signature } = signatureHeader;

const token = `${protectedHeader}.${base64url(safeStringify(payload))}.${signature}`;

this.logger.isDebugEnabled && this.logger.debug(`JWS token to verify: ${token}, using public key: ${pubKey}`);
this.logger.debug(`JWS token to verify: ${token}, using public key: ${pubKey}`);

// validate signature
const result = jwt.verify(token, pubKey, {
Expand All @@ -104,7 +103,7 @@ class JwsValidator {
return true;
}
catch (err) {
this.logger.error(`Error validating JWS: ${err?.message}`, err);
this.logger.error('Error validating JWS: ', err);
throw err;
}
}
Expand Down