Skip to content

Commit

Permalink
feat(iprod-416): updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
geka-evk committed Feb 27, 2024
1 parent 35bef22 commit e6cb537
Show file tree
Hide file tree
Showing 8 changed files with 993 additions and 770 deletions.
2 changes: 1 addition & 1 deletion .ncurc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Add a TODO comment indicating the reason for each rejected dependency upgrade added to this list, and what should be done to resolve it (i.e. handle it through a story, etc).
## Add a comment indicating the reason for each rejected dependency upgrade added to this list, and what should be done to resolve it (i.e. handle it through a story, etc).
reject: [
"chai", # Chai v.5 now only supports EcmaScript Modules (ESM) - no require('chi')
]
1,640 changes: 885 additions & 755 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"start": "node src/index.js",
"start:dev": "node -r dotenv/config src/index.js",
"start-with-oauth-enabled": "source oauth.env && node src/index.js",
"migrate": "DOTENV_CONFIG_PATH=$(pwd)/.env npx knex --knexfile src/knexfile.js migrate:latest",
"seed": "DOTENV_CONFIG_PATH=$(pwd)/.env npx knex --knexfile src/knexfile.js seed:run",
"migrate": "NODE_OPTIONS='-r dotenv/config' npx knex --knexfile src/knexfile.js migrate:latest",
"seed": "NODE_OPTIONS='-r dotenv/config' npx knex --knexfile src/knexfile.js seed:run",
"migrate-and-seed": "npm -s run migrate && npm -s run seed",
"db:start": "./run-mysql.sh",
"db:stop": "./kill-mysql.sh",
Expand Down Expand Up @@ -67,7 +67,7 @@
"jsonwebtoken": "^9.0.2",
"knex": "^3.1.0",
"moment": "^2.30.1",
"mysql2": "^3.9.1",
"mysql2": "^3.9.2",
"node-forge": "^1.3.1",
"node-vault": "^0.10.2",
"oas3-tools": "^2.2.3",
Expand All @@ -80,11 +80,11 @@
"xml2js": "^0.6.2"
},
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",
"chai": "^4.4.1",
"chai-datetime": "^1.8.0",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-node": "^11.1.0",
Expand All @@ -98,7 +98,8 @@
"sinon": "^17.0.1",
"snazzy": "^9.0.0",
"standard-version": "^9.5.0",
"standardx": "^7.0.0"
"standardx": "^7.0.0",
"supertest": "^6.3.4"
},
"standardx": {
"semistandard": true
Expand Down
48 changes: 48 additions & 0 deletions src/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,54 @@ paths:
- OAuth2:
- pta
x-swagger-router-controller: HubCAController
/hub/jwscerts:
get:
tags:
- JWS-certificates-configuration
summary: get Hub JWS certificate
description: TBD
operationId: getHubJWSCerts
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/JWSCert'
404:
description: Hub JWS certs not set
content: {}
security:
- OAuth2:
- mta
- pta
x-swagger-router-controller: JWSCerts
post:
tags:
- JWS-certificates-configuration
summary: Create/Update Hub JWS certificate
description: TBD
operationId: setHubJWSCerts
requestBody:
description: TBD
content:
application/json:
schema:
$ref: '#/components/schemas/BaseJWSCert'
required: true
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/JWSCert'
security:
- OAuth2:
- mta
- pta
x-swagger-router-controller: JWSCerts
x-codegen-request-body-name: body
/dfsps/jwscerts:
get:
tags:
Expand Down
1 change: 1 addition & 0 deletions src/constants/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ module.exports = {
.asInt(),
},
switchFQDN: env.get('SWITCH_FQDN').default('switch.example.com').asString(),
switchId: env.get('SWITCH_ID').default('switch').asString(),

vault: {
endpoint: env.get('VAULT_ENDPOINT').default('http://127.0.0.1:8233').asString(),
Expand Down
26 changes: 22 additions & 4 deletions src/controllers/JWSCerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* limitations under the License. *
******************************************************************************/

'use strict';

const utils = require('../utils/writer.js');
const JWSCertsService = require('../service/JWSCertsService');

Expand All @@ -30,8 +28,8 @@ exports.createDfspJWSCerts = (req, res, next, body, dfspId) => {
});
};

exports.updateDfspJWSCerts = (req, res, next, body, dfspId) => {
JWSCertsService.updateDfspJWSCerts(req.context, dfspId, body)
exports.setHubJWSCerts = (req, res, next, body) => {
JWSCertsService.setHubJWSCerts(req.context, body)
.then(response => {
utils.writeJson(res, response);
})
Expand All @@ -40,6 +38,16 @@ exports.updateDfspJWSCerts = (req, res, next, body, dfspId) => {
});
};

// exports.updateDfspJWSCerts = (req, res, next, body, dfspId) => {
// JWSCertsService.updateDfspJWSCerts(req.context, dfspId, body)
// .then(response => {
// utils.writeJson(res, response);
// })
// .catch(response => {
// utils.writeJson(res, response, response.status);
// });
// };

exports.getDfspJWSCerts = (req, res, next, dfspId) => {
JWSCertsService.getDfspJWSCerts(req.context, dfspId)
.then(response => {
Expand All @@ -50,6 +58,16 @@ exports.getDfspJWSCerts = (req, res, next, dfspId) => {
});
};

exports.getHubJWSCerts = (req, res, next) => {
JWSCertsService.getHubJWSCerts(req.context)
.then(response => {
utils.writeJson(res, response);
})
.catch(response => {
utils.writeJson(res, response, response.status);
});
};

exports.getAllDfspJWSCerts = (req, res, next) => {
JWSCertsService.getAllDfspJWSCerts(req.context)
.then(response => {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const run = async ({

// Start the server
http.createServer(appConnected).listen(serverPort, function () {
console.log('Connection-Manager API server is listening on port %d (http://localhost:%d)', serverPort, serverPort);
console.log('Connection-Manager API server is listening on port %d...', serverPort);
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort);
});
};
Expand Down
29 changes: 27 additions & 2 deletions src/service/JWSCertsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
'use strict';
const DFSPModel = require('../models/DFSPModel');
const PkiService = require('./PkiService');
const NotFoundError = require('../errors/NotFoundError');
const ValidationError = require('../errors/ValidationError');
const { switchId } = require('../constants/Constants');

exports.createDfspJWSCerts = async (ctx, dfspId, body) => {
if (body === null || typeof body === 'undefined') {
Expand All @@ -40,17 +42,40 @@ exports.createDfspJWSCerts = async (ctx, dfspId, body) => {
return jwsData;
};

exports.updateDfspJWSCerts = async (ctx, dfspId, body) => {
return exports.createDfspJWSCerts(dfspId, body);
exports.setHubJWSCerts = async (ctx, body) => {
const switchData = await DFSPModel.findByDfspId(switchId)
.catch(err => {
console.log('Error on getting hub DFSP', err);
if (err instanceof NotFoundError) return null;
throw err;
});
// (?) think, if it's better to create DFSP for hub on service start
if (!switchData) {
console.log('No DFSP for hub, creating new one...');
await PkiService.createDFSPWithCSR(ctx, {
dfspId: switchId,
name: switchId,
});
}

return exports.createDfspJWSCerts(ctx, switchId, body);
};

// exports.updateDfspJWSCerts = async (ctx, dfspId, body) => {
// return exports.createDfspJWSCerts(dfspId, body);
// };

exports.getDfspJWSCerts = async (ctx, dfspId) => {
await PkiService.validateDfsp(ctx, dfspId);
const { pkiEngine } = ctx;
const dbDfspId = await DFSPModel.findIdByDfspId(dfspId);
return pkiEngine.getDFSPJWSCerts(dbDfspId);
};

exports.getHubJWSCerts = async (ctx) => {
return exports.getDfspJWSCerts(ctx, switchId);
};

exports.deleteDfspJWSCerts = async (ctx, dfspId) => {
await PkiService.validateDfsp(ctx, dfspId);
const { pkiEngine } = ctx;
Expand Down

0 comments on commit e6cb537

Please sign in to comment.