Skip to content

Commit

Permalink
feat(consortium-indy): support consortium database indy backend hyper…
Browse files Browse the repository at this point in the history
…ledger#675

WORK IN PROGRESS

Fixes hyperledger#675

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz authored and PranjayPathak committed Dec 17, 2021
1 parent f4ce09e commit 437cf5f
Show file tree
Hide file tree
Showing 30 changed files with 1,919 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/cactus-plugin-consortium-indy/.gitignore
@@ -0,0 +1,2 @@
cactus-openapi-spec-plugin-consortium-indy.json
src/main/typescript/generated/openapi/typescript-axios/.npmignore
19 changes: 19 additions & 0 deletions packages/cactus-plugin-consortium-indy/README.md
@@ -0,0 +1,19 @@
# `@hyperledger/cactus-plugin-consortium-indy`

TODO

Items:

1. Create an Indy all-in-one test ledger, similar to all the other test ledgers that are located under packages/cactus-test-tooling/src/main/typescript which are classes that are pulling up containers which are mostly defined in the Dockerfiles under `tools/docker/*all-in-one`
2. Then select an Indy client library (Javascript/Typescript based, one that has Typescript types is preferred but not mandatory)
3. Create a test case where the pristine Indy ledger gets pulled up,
4. Populate Indy ledger with some test data that defines a dummy consortium
5. Instantiate the consortium plugin within the test case with the connection details of the Indy ledger
6. Instantiate an API client of the consortium plugin (packages/cactus-plugin-consortium-indy/src/main/typescript/generated/openapi/typescript-axios => `DefaultApi` class)
7. Use API client to invoke `getNodeJws()` and `getConsortiumJws()` methods of the plugin via HTTP
8. Assert that the data has been retrieved successfully.
9. Test case passed.
10. Open Pull request.


A good example of a containerized ledger is in this Dockerfile: tools/docker/iroha-all-in-one/Dockerfile
7 changes: 7 additions & 0 deletions packages/cactus-plugin-consortium-indy/openapitools.json
@@ -0,0 +1,7 @@
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "5.1.1"
}
}
92 changes: 92 additions & 0 deletions packages/cactus-plugin-consortium-indy/package.json
@@ -0,0 +1,92 @@
{
"name": "@hyperledger/cactus-plugin-consortium-indy",
"version": "0.8.0",
"description": "A web service plugin that provides management capabilities on a Cactus consortium as a whole for administrative purposes.",
"main": "dist/lib/main/typescript/index.js",
"mainMinified": "dist/cactus-plugin-consortium-indy.node.umd.min.js",
"browser": "dist/cactus-plugin-consortium-indy.web.umd.js",
"browserMinified": "dist/cactus-plugin-consortium-indy.web.umd.min.js",
"module": "dist/lib/main/typescript/index.js",
"types": "dist/lib/main/typescript/index.d.ts",
"files": [
"dist/*"
],
"scripts": {
"generate-sdk": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
"codegen:openapi": "npm run generate-sdk",
"codegen": "run-p 'codegen:*'",
"watch": "npm-watch",
"webpack": "npm-run-all webpack:dev webpack:prod",
"webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web",
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js",
"webpack:dev:node": "webpack --env=dev --target=node --config ../../webpack.config.js",
"webpack:prod": "npm-run-all webpack:prod:node webpack:prod:web",
"webpack:prod:web": "webpack --env=prod --target=web --config ../../webpack.config.js",
"webpack:prod:node": "webpack --env=prod --target=node --config ../../webpack.config.js"
},
"watch": {
"codegen:openapi": {
"patterns": [
"./src/main/json/openapi.json"
]
}
},
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=10",
"npm": ">=6"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hyperledger/cactus.git"
},
"keywords": [
"Hyperledger",
"Cactus",
"Integration",
"Blockchain",
"Distributed Ledger Technology"
],
"author": {
"name": "Hyperledger Cactus Contributors",
"email": "cactus@lists.hyperledger.org",
"url": "https://www.hyperledger.org/use/cactus"
},
"contributors": [
{
"name": "Please add yourself to the list of contributors",
"email": "your.name@example.com",
"url": "https://example.com"
},
{
"name": "Peter Somogyvari",
"email": "peter.somogyvari@accenture.com",
"url": "https://accenture.com"
}
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/hyperledger/cactus/issues"
},
"homepage": "https://github.com/hyperledger/cactus#readme",
"dependencies": {
"@hyperledger/cactus-common": "0.8.0",
"@hyperledger/cactus-core": "0.8.0",
"@hyperledger/cactus-core-api": "0.8.0",
"axios": "0.21.1",
"body-parser": "1.19.0",
"express": "4.17.1",
"jose": "1.28.1",
"json-stable-stringify": "1.0.1",
"prom-client": "13.2.0",
"typescript-optional": "2.0.1",
"uuid": "8.3.2"
},
"devDependencies": {
"@types/express": "4.17.13",
"@types/json-stable-stringify": "1.0.33",
"@types/uuid": "8.3.1"
}
}
173 changes: 173 additions & 0 deletions packages/cactus-plugin-consortium-indy/src/main/json/openapi.json
@@ -0,0 +1,173 @@
{
"openapi": "3.0.3",
"info": {
"title": "Hyperledger Cactus Plugin - Consortium Web Service",
"description": "Manage a Cactus consortium through the APIs. Needs administrative privileges.",
"version": "0.0.1",
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"servers": [
{
"url": "https://www.cactus.stream/{basePath}",
"description": "Public test instance",
"variables": {
"basePath": {
"default": ""
}
}
},
{
"url": "http://localhost:4000/{basePath}",
"description": "Local test instance",
"variables": {
"basePath": {
"default": ""
}
}
}
],
"components": {
"schemas": {
"GetNodeJwsResponse": {
"type": "object",
"required": [
"jws"
],
"properties": {
"jws": {
"description": "The JSON Web Signature of the Cactus node.",
"$ref": "../../../../cactus-core-api/src/main/json/openapi.json#/components/schemas/JWSGeneral",
"nullable": false
}
}
},
"GetConsortiumJwsResponse": {
"type": "object",
"required": [
"jws"
],
"properties": {
"jws": {
"description": "The JSON Web Signature of the Cactus consortium.",
"$ref": "../../../../cactus-core-api/src/main/json/openapi.json#/components/schemas/JWSGeneral",
"nullable": false,
"format": "The general format which is a JSON object, not a string."
}
}
},
"PrometheusExporterMetricsResponse": {
"type": "string",
"nullable": false
},
"GetNodeJwsRequest": {
"type": "object",
"properties": {
}
},
"GetConsortiumJwsRequest": {
"type": "object",
"properties": {
}
}
}
},
"paths": {
"/api/v1/plugins/@hyperledger/cactus-plugin-consortium-indy/consortium/jws": {
"post": {
"x-hyperledger-cactus": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-consortium-indy/consortium/jws"
}
},
"operationId": "getConsortiumJwsV1",
"summary": "Retrieves a consortium JWS",
"description": "The JWS asserting the consortium metadata (pub keys and hosts of nodes)",
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetConsortiumJwsRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetConsortiumJwsResponse"
}
}
}
}
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-consortium-indy/node/jws": {
"post": {
"x-hyperledger-cactus": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-consortium-indy/node/jws"
}
},
"operationId": "getNodeJwsV1",
"summary": "Retrieves the JWT of a Cactus Node",
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetNodeJwsRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetNodeJwsResponse"
}
}
}
}
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-consortium-indy/get-prometheus-exporter-metrics": {
"get": {
"x-hyperledger-cactus": {
"http": {
"verbLowerCase": "get",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-consortium-indy/get-prometheus-exporter-metrics"
}
},
"operationId": "getPrometheusMetricsV1",
"summary": "Get the Prometheus Metrics",
"parameters": [],
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/PrometheusExporterMetricsResponse"
}
}
}
}
}
}
}
}
}

0 comments on commit 437cf5f

Please sign in to comment.