diff --git a/.env.example b/.env.example index d1e8b65..4781b68 100644 --- a/.env.example +++ b/.env.example @@ -1,14 +1,7 @@ PORT=5000 # express trust proxy config for if you are using a reverse proxy TRUST_PROXY=1 -MEMCACHE_URI=127.0.0.1:11211 -BLOCKSYNC_URI_REST=http://localhost:8080/api/ -CONFIG=./config.json -TEMPLATE_REPO=https://api.github.com/repos/ixofoundation/schema/contents/ DATABASE_URL="" -RPC_URL="" -MNEMONIC="" -ASYM_CYPHER="" -ASYM_KEY="" -WEB3STORAGE_TOKEN="" -FILE_TYPES=[] +WEB3_STORAGE_EMAIL="test@gmail.com" +WEB3_STORAGE_SPACE="ixo" +FILE_TYPES=["image/svg+xml", "image/png", "application/ld+json", "application/json", "application/pdf"] diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..0828ab7 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v18 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index da497fa..77ad2d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 node:16.14.2 +FROM --platform=linux/amd64 node:18.15.0 # Create app directory WORKDIR /app diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 8465087..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,47 +0,0 @@ -node { - def app - def branch - - stage('Clone repository') { - /* Let's make sure we have the repository cloned to our workspace */ - checkout scm - branch = scm.branches[0].name.drop(2) - echo 'Branch Name: ' + branch - } - - stage('Build source') { - /* Let's make sure we have the repository cloned to our workspace */ - sh 'npm install' - sh 'npm run build' - } - - stage('Build image') { - app = docker.build("trustlab/ixo-elysian:" + branch) - } - - stage('Test image') { - /* Ideally, we would run a test framework against our image. - * For this example, we're using a Volkswagen-type approach ;-) */ - - app.inside { - sh 'echo "Tests passed"' - } - } - - stage('Push image') { - /* Finally, we'll push the image with two tags: - * First, the incremental build number from Jenkins - * Second, the 'latest' tag. - * Pushing multiple tags is cheap, as all the layers are reused. */ - docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') { - app.push(branch + "-" + "${env.BUILD_NUMBER}") - app.push(branch) - } - } - - stage('Removing Images') { - sh "docker rmi ${app.id}" - sh "docker rmi registry.hub.docker.com/${app.id}" - sh "docker rmi registry.hub.docker.com/${app.id}-${env.BUILD_NUMBER}" - } -} \ No newline at end of file diff --git a/akash button.svg b/akash button.svg deleted file mode 100644 index 24484b7..0000000 --- a/akash button.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/akash.deploy.yaml b/akash.deploy.yaml deleted file mode 100644 index 5bf4771..0000000 --- a/akash.deploy.yaml +++ /dev/null @@ -1,178 +0,0 @@ -#deployment for blocksync on the akash network -#this file has not been tested -version: "2.0" - -services: #environment variables still need to be filled - app: - image: northroomza/ixo-cellnode:latest #try to not use latest because akash uses heavy caching - env: - - 'url=https://add.the.full.domain.here' - - PORT=5000 - - MONGODB_URI=mongodb://db:27017/elysian - - MEMCACHE_URI=cache:11211 - - RABITMQ_URI=amqp://guest:guest@mq:5672?heartbeat=2 - - BLOCKSYNC_URI_REST= - - CONFIG=/usr/src/app/config.json - - TEMPLATE_REPO=https://api.github.com/repos/ixofoundation/schema/contents/ - - ETHEREUM_API= - - ASYM_CYPHER=aes-256-cbc - - ASYM_KEY=trustlab.tech - - VALIDISSUERS=did:sov:123456789 - - NODEDID= - - BLOCKSYNC_URI_REST=http://EXAMPLE:8080/api/ - depends-on: - - mq - - db - expose: - - port: 5000 - as: 80 - accept: - - "add.domain.hostname.here" - to: - - global : true - - cache: - image: memcached:latest 11211 - expose: - - port: 11211 - as: 11211 - to: - - global : false - mq: - image: rabbitmq:3-management - env: - - vhosts="'/','pds'"" - expose: - - port: 5672 - as: 5672 - to: - - global : false - pol: - image: ixoworld/ixo-pol:1.1.3 - depends-on: - - mq - - db - env: - - RABITMQ_URI=amqp://guest:guest@mq:5672?heartbeat=2 - - BLOCKCHAIN_REST= - cli: - image: trustlab/ixo-cli:master - env: - - MONGODB_URI=mongodb://db:27017/elysian - - MEMCACHE_URI=cache:11211 - - BLOCKCHAIN_URI_REST= - db: - image: mongo:latest - storage: - data: - mount: /db/data - expose: - - port: 5432 - as: 5432 - to: - - global : false - -profiles: - compute: - app: - resources: - cpu: - units: 1.0 - memory: - size: 512Mi - storage: 512Mi - cache: - resources: - cpu: - units: 1.0 - memory: - size: 512Mi - storage: 512Mi - mq: - resources: - cpu: - units: 1.0 - memory: - size: 1G - storage: 512Mi - pol: - resources: - cpu: - units: 1.0 - memory: - size: 512Mi - storage: 512Mi - cli: - resources: - cpu: - units: 1.0 - memory: - size: 512Mi - storage: 512Mi - db: - resources: - cpu: - units: 1.0 - memory: - size: 512Mi - storage: - - 512Mi - - name: data - size: 10Gi - attributes: - persistent: true - class: beta2 - placements: #this sections needs to be configured - westcoast: #example region - attributes: - region: us-west #example region - pricing: - app-profile: - denom: #add token denom - amount: #add token amount - cache-profile: - denom: #add token denom - amount: #add token amount - mq-profile: - denom: #add token denom - amount: #add token amount - pol-profile: - denom: #add token denom - amount: #add token amount - cli-profile: - denom: #add token denom - amount: #add token amount - db-profile: - denom: #add token denom - amount: #add token amount - -deployment: - app: - akash: - profiles: app - count: 1 - cache: - akash: - profiles: cache - count: 1 - mq: - akash: - profiles: mq - count: 1 - pol: - akash: - profiles: pol - count: 1 - cli: - akash: - profiles: cli - count: 1 - db: - akash: - profiles: db - count: 1 - - - ###Please note that storage only persists during the lease. The storage is lost when: - ###The deployment is migrated to a different provider. - ###The deployment’s lease is closed. Even when relaunched onto the same provider, storage will not persist across leases. \ No newline at end of file diff --git a/api.md b/api.md deleted file mode 100644 index 9870649..0000000 --- a/api.md +++ /dev/null @@ -1,1062 +0,0 @@ -# Cell Node API Documentation - -This document lists ixo-cellnode's API endpoints and provides some examples of their usage. Since ixo-apimodule is another ixo component which interacts extensively with cell node and demonstrates its usage in [demo.ts](https://github.com/ixofoundation/ixo-apimodule/blob/master/test/demo.ts), some documentation for ixo-apimodule is also provided here to illustrate their interactions. - -* [ixo-apimodule](#ixo-apimodule) \(NPM module\) -* [ixo-cellnode](#cell-node-api) \(decentralised data store\) - -## ixo-apimodule - -(For the code and further documentation, refer to the repo [here](https://github.com/ixofoundation/ixo-apimodule).) - -This NPM module provides APIs that simplify interactions between the ixo-SDK user interfaces and cell nodes, Blockchain Nodes and blocksync. - -`npm install --save ixo-module` - -To Create a new ixo Object \(Without provider\) - -```text -import ixo from 'ixo-module'; -var ixo = new ixo('ixo_node_url') -``` - -### Entity Functions - -Functions are called using `ixo.project.`. In future, this will be replaced with the more generic `ixo.entity.`. - -#### List Entities - -Returns a list of all entities cached in the Explorer Node \(ixo-blocksync\). Note that each ixo Relayer Portal can configure their instance of ixo-blocksync to only synchronise entities that are associated with the Relayer. Linked entities have the Relayer Node-ID in their blockchain record \(Entity Document\). - -Request: - -```text -ixo.project.listProjects().then((result) => { - console.log('Project List: ' + result) -}) -``` - -Response: [ixo Blocksync: listProjects](https://app.swaggerhub.com/apis/ixo-world/ixo/0.2.1#/projects/listProjects) - -#### Get Project - -Retrieves public project details by DID - -```text -let projectDid = 'did:ixo:TknEju4pjyRQvVehivZ82x'; -ixo.project.getProjectByProjectDid(projectDid).then((result) => { - console.log('Project Details: ' + result) -}) -``` - -Response: [ixo Blocksync: getProject](https://app.swaggerhub.com/apis/ixo-world/ixo/0.2.1#/projects/getByProjectDid) - -#### Create Project - -```text -ixo.project.createProject(projectData, signature, CellnodeUrl).then((result) => { - console.log('Project Details: ' + result) -}) -``` - -Response: [ixo Cell Node: createProject](#create-entity) - -#### Update Project Status - -Updates a project's current status. - -Valid project status updates are: -```text -- Null -> CREATED -- CREATED -> PENDING -- PENDING -> CREATED or FUNDED -- FUNDED -> STARTED -- STARTED -> STOPPED -- STOPPED -> PAIDOUT -``` - -Usage: -```text -ixo.project.updateProjectStatus(projectStatusData, signature, CellnodeUrl).then((result) => { - console.log('Project Update Details: ' + result) -}) -``` - -Response: [ixo Cell Node: updateProjectStatus](#update-project-status-1) - -#### Update Project Doc -Updates a project's `Data` field. - -```text -ixo.project.updateProjectDoc(projectDocData, signature, CellnodeUrl).then((result) => { - console.log('Project Update Details: ' + result) -}) -``` - -Response: [ixo Cell Node: updateProjectDoc](#update-project-doc-1) - -#### Withdraw Funds -Withdraws a project agent's funds from the project. - -```text -ixo.project.withdrawFunds(withdrawFundsData, signature, responseFee).then((result) => { - console.log('Withdraw Funds Details: ' + result) -}) -``` - -Response: [ixo Blocksync: withdraw funds](https://app.swaggerhub.com/apis/ixo-world/ixo/0.2.1#/transactions/sendTransaction) - -#### Upload Public Data - -Function to upload into a cell node any public content relating to an entity. This returns a unique content identifier \(CID\) for the data. This allows the data to be content-addressed and retrieved using the identifier `dataUrl`. The primary use is to upload images and json template files to the cell node. But this can accept any arbitrary project-specific public data. - -The `dataUrl` takes the form of `data:;,` // In future this will be replaced by IPLD standard content addresses - -```text -// Upload an image -let dataUrl = 'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg=='; -ixo.project.createPublic(dataUrl, CellnodeUrl) { - console.log('Document hash: ' + result) -}) -``` - -Response: [ixo Cell Node: createPublic](#upload-an-image) - -#### Retrieve Public Data - -Retrieves previously uploaded data from a Cell-Node using the content address \(hash\) - -```text -ixo.project.fetchPublic(documentHash, CellnodeUrl) { - console.log('Document hash: ' + result) -}) -``` - -Response: [ixo Cell Node: fetchPublic](#fetch-image) - -### Agent Functions - -These calls take the form `ixo.agent.` - -#### List Agents - -Returns a list of all agents associated with an entity, from the cell node. - -Request: - -```text -ixo.agent.listAgentsForProject(data, signature, CellnodeUrl).then((result) => { - console.log('Agent List: ' + result) -}) -``` - -Response: [ixo Cell Node: listAgents](#list-agents-1) - -#### Register an Agent for an Entity - -Associates the Agent DID with the entity. - -Request: - -```text -ixo.agent.createAgent(agentData, signature, CellnodeUrl).then((result) => { - console.log('Create Agent: ' + result) -}) -``` - -Response: [ixo Cell Node: createAgent](#create-agent) - -#### Update Agent Status - -Update an agent's registration status. - -Valid statuses are: - -| Status | Value | -| :--- | :--- | -| Pending | 0 | -| Approved | 1 | -| Revoked | 2 | - -Request: - -```text -ixo.agent.updateAgentStatus(agentData, signature, CellnodeUrl).then((result) => { - console.log('Update Agent Status: ' + result) -}) -``` - -Response: [ixo Cell Node: updateAgentStatus](#update-agent-status-1) - -### Claim Functions - -Calls take the form `ixo.claim.` - -#### List Claims - -Returns a list of all claims for an entity, from a cell node, together with the claim status. - -Request: - -```text -ixo.claim.listClaimsForProject(data, signature, CellnodeUrl).then((result) => { - console.log('Claim List: ' + result) -}) -``` - -Response: [ixo Cell Node: listClaimsForProject](#list-claims-1) - -#### List Claims by Template ID - -Returns a list of filtered claims for an entity, from a cell node, together with the claim status. Claims are filtered by a template ID expected to be included in `data` as `claimTemplateId`. - -Request: - -```text -ixo.claim.listClaimsForProjectByTemplateId(data, signature, CellnodeUrl).then((result) => { - console.log('Claim List: ' + result) -}) -``` - -Response: [ixo Cell Node: listClaimsForProjectByTemplateId](#list-claims-by-template-id-1) - -#### Issue Claim - -Issues a claim for an entity. - -Request: - -```text -ixo.agent.createClaim(claimData, signature, CellnodeUrl).then((result) => { - console.log('Create Claim: ' + result) -}) -``` - -Response: [ixo Cell Node: createClaim](#submit-claim) - -#### Evaluate a Claim - -Sets the evaluation status for a claim. - -Valid statuses are: - -| Status | Value | -| :--- | :--- | -| Pending | 0 | -| Approved | 1 | -| Rejected | 2 | -| Disputed | 3 | - -Request: - -```text -ixo.agent.evaluateClaim(evaluationData, signature, CellnodeUrl).then((result) => { - console.log('Create Evaluation: ' + result) -}) -``` - -Response: [ixo Cell Node: evaluateClaim](#evaluate-claim) - -### User Functions - -#### Register agent DID and DID Document - -Registers a new agent identifier and DID document \(DDO\) to the ixo blockchain. - -Request: - -```text -ixo.user.registerUserDid(didData, signature, responseFee).then((result) => { - console.log('Register DID: ' + result) -}) -``` - -Response: [ixo Blockchain: registerUserDid](https://app.swaggerhub.com/apis/ixo-world/ixo/0.2.1#/transactions/sendTransaction) - -#### Get a DID Document - -Retrieves the DID Doc for a specified agent identifier - -Request: - -```text -Let did = 'did:ixo:2p19P17cr6XavfMJ8htYSS'; -ixo.user.getDidDoc(did).then((result) => { - console.log('DID Doc: ' + result) -}) -``` - -Response: [ixo Blockchain: getDidDoc](https://app.swaggerhub.com/apis/ixo-world/ixo-modules_g_rpc_gateway_docs/1.0.0#/Query/DidDoc) - -### Metrics - -Returns the global statistics for all entities associated with a Relayer node. - -Request: - -```text -ixo.stats.getGlobalStats().then((result) => { - console.log('Statistics: ' + result) -}) -``` - -Response: [ixo Blocksync: listStats](https://app.swaggerhub.com/apis/ixo-world/ixo/0.2.1#/stats/getStats) - -### Health Check Functions - -#### Explorer node health check - -Request: - -```text -ixo.network.pingIxoExplorer().then((result) => { - console.log('Health Check: ' + result) -}) -``` - -Response: [ixo Blocksync: ping](https://app.swaggerhub.com/apis/ixo-world/ixo/0.2.1#/blocksync/ping) - -## Cell Node API - -Note: the legacy name for Cell Node was Project Data Store \(PDS\). - -A cell node is a decentralised data processing and storage node. This has a public API and private API. Public API requests do not require cryptographic signatures. All other requests must be signed and adhere to the capabilities that have been granted to the signer. - -### Public API - -URI: `/api/public` - -Request type: `POST` - -Structure: `{"jsonrpc": "2.0", "method": "", "id": , "params": }` - -| Variable | Description | -| :--- | :--- | -| `` | The URL of the server | -| `` | The entity to send the method | -| `` | The name of the method to call defined in the config file | -| `` | The message ID, used to correlate asynchronous responses | -| `` | The parameters that are passed to the method handler | - -#### Structure of the params object - -These are unsigned requests for publicly available information. A content identifier is generated and sent back to the client, to be used in retrieval of this information. - -Data will be accepted any of the following encodings: "ascii" \| "utf8" \| "utf16le" \| "ucs2" \| "base64" \| "latin1" \| "binary" \| "hex". - -contentType should reference a MIME type. See [https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics\_of\_HTTP/MIME\_types/Complete\_list\_of\_MIME\_types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types) - -```text -{ - "jsonrpc":"2.0", - "method":"createPublic", - "id": 123, - "params": { - "data": "bob public message", - "contentType": "text" - } -} -``` - -`` - -#### Upload an image - -Request: - -```text -{ - "jsonrpc": "2.0", - "method": "createPublic", - "id": 3, - "params": - { - "data": "", - "contentType": "image/png" - } -} -``` - -Response: - -```text -{ - "jsonrpc": "2.0", - "id": 3, - "result": "" -} -``` - -#### Fetch image - -Request: - -```text -{ - "jsonrpc": "2.0", - "method": "fetchPublic", - "id": 3, - "params": {"key": } -} -``` - -Response: - -```text -{ - "jsonrpc": "2.0", - "id": 3, - "result": { - "data": "", - "contentType": "image/png" - } -} -``` - -#### Upload a Json file - -Request: - -```text -{ - "jsonrpc": "2.0", - "method": "createPublic", - "id": 3, - "params": - { - "data": "", - "contentType": "application/json" - } -} -``` - -Response: - -```text -{ - "jsonrpc": "2.0", - "id": 3, - "result": "" -} -``` - -#### Fetch Json file - -Request: - -```text -{ - "jsonrpc": "2.0", - "method": "fetchPublic", - "id": 3, - "params": {"key": } -} -``` - -Response: - -```text -{ - "jsonrpc": "2.0", - "id": 3, - "result": { - "data": "", - "contentType": "application/json" - } -} -``` - -### Private API - -URI: `/api/request` - -Request type: `POST` - -Structure: `{"jsonrpc": "2.0", "method": "", "id": , "params": }` - -| Variable | Description | -| :--- | :--- | -| `` | The URL of the server | -| `` | The entity to send the method | -| `` | The name of the method to call defined in the config file | -| `` | The message ID, used to correlate asynchronous responses | -| `` | The parameters that are passed to the method handler | - -#### Structure of the params object - -Everything in the payload section is signed to generate a valid signature. This should be packaged using `JSON.stringify()` method before signing. - -```text -{ - "jsonrpc":"2.0", - "method":"createAgent", - "id": 123, - "params": { - "payload": { - "template": { - "name": "create_agent" - }, - "data": {"projectDid": "did:ixo:TknEju4pjyRQvVehivZ82x", - "name": "example name", - "surname": "example name", - "email": "test@test.com", - "agentDid": "did:sov:64", - "role": "SA"} - }, - "signature": { - "type": "ed25519-sha-256", - "created": "2018-06-27T16:02:20Z", - "creator": "did:ixo:2p19P17cr6XavfMJ8htYSS", - "signatureValue": "A011D11A2D91A9CB03ECFFB7D9AFC1001DB56B3DABF42BDD0F4D00352A9B8E0E73E85F0B4586DA2934696C0A78602EEB047EA6B3D9096C1A0C3FB144E6A51C09" - } - } -} -``` - -#### Create Entity - -Creates a new entity. - -Request: - -```text -{ - "jsonrpc": "2.0", - "method": "createProject", - "id": 3, - "params": { - "payload": { - "template": { - "name": "