Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from rsksmart/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
ilanolkies authored Aug 20, 2020
2 parents 20b5d2d + 4ef515b commit e9996dd
Show file tree
Hide file tree
Showing 42 changed files with 3,060 additions and 320 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ The project has different modules that run together form the RIF Identity main f

> For development, commands appended with `:dev` run a watch mode
> For production, find Docker guide [here](./docs/Deploy_prod.md)
There are also two apps to test the flow:

- `holder/holder-app` is a react app that allows to fulfill the whole flow but retrieve from IPFS
Expand All @@ -38,6 +40,47 @@ If you started the front end apps you should get this

![run-all-front](./img/run-all-front.png)

## Using docker compose

### Setup

To use docker compose option, first you need to setup tha variable `DOCKER_TAG`. This will be the tag when creating the docker image. If no one is set, by default will take the TAG `latest`. For instance:

```bash
export DOCKER_TAG=latest
```

Setup the following `.env` variables. Look into each service section of this README to know how to complete them:

```text
./data-vault/.env
./issuer/.env
./issuer/app/.env
```
### Execute

First, build the image:

```bash
docker-compose build
```

Execute as daemon

```bash
docker-compose up -d
```

Identity service will start using it's own network
```bash
docker network ls
```
```bash
1d8ec230c51e rif-identity-services_default bridge local
```



## Usage

- Create identity
Expand Down
16 changes: 16 additions & 0 deletions data-vault/Dockerfile.dataVault
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:10

WORKDIR /app

COPY package.json ./
COPY ./patch ./patch

RUN npm i
COPY ./patch/ethrDID-copy.js ./node_modules/ethr-did/lib/index.js

COPY ./src ./src
COPY ./tsconfig.json ./

EXPOSE 5102

CMD [ "npm", "run", "start"]
20 changes: 20 additions & 0 deletions data-vault/Dockerfile.ipfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:10

WORKDIR /app
COPY . ./

RUN npm i

RUN wget https://github.com/ipfs/go-ipfs/releases/download/v0.6.0/go-ipfs_v0.6.0_linux-amd64.tar.gz

RUN tar -xvzf go-ipfs_v0.6.0_linux-amd64.tar.gz

RUN cd go-ipfs && \
bash install.sh
RUN ipfs --version

RUN ipfs init

EXPOSE 8080
EXPOSE 5001
CMD [ "ipfs", "daemon"]
29 changes: 23 additions & 6 deletions data-vault/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ After the _store_ process the holder can verify the file was uploaded accessing
npm i
```

`postinstall` is running a script to append `"rsk:testnet"` to `"did:ethr:"` methods name

To do it manually, remove `postinstall` script before running installing, then find this in `node_modules/ethr-did/lib//index.js`

![fix](./img/fix.png)

2. Install IPFS CLI. Find your option: https://docs.ipfs.io/how-to/command-line-quick-start/.

3. Init IPFS
Expand All @@ -63,10 +69,16 @@ After the _store_ process the holder can verify the file was uploaded accessing
```
PRIVATE_KEY= private key
ADDRESS= matching address
```

Optional parameters

```
AUTH_EXPIRATION_TIME= fixed time for auth tokens to expire in
RPC_URL= rsk testnet rpc url
PORT= to run the data vault
IPFS_PORT= port of a local http IPFS gateway
IPFS_PORT= port of an http IPFS gateway
IPFS_HOST=host of an IPFS gateway - should be used if running with Docker
```

Example
Expand All @@ -78,15 +90,20 @@ After the _store_ process the holder can verify the file was uploaded accessing
RPC_URL=https://did.testnet.rsk.co:4444
PORT=5102
IPFS_PORT=5001
IPFS_HOST=rif-identity-ipfs-testnet
```

6. Fix a bug :/ - go to `node_modules/ethr-did/lib/index.js` and find `"did:ethr:"`. Prepend `"rsk:testnet"`
Defaults

![fix](./img/fix.png)

You can also copy paste the file in `./lib/ethrDID-copy.js`
```
AUTH_EXPIRATION_TIME=300000
RPC_URL=https://did.testnet.rsk.co:4444
PORT=5102
IPFS_PORT=5001
IPFS_HOST=localhost
```

7. In another terminal, start data-vault:
6. In another terminal, start data-vault:

```
npm run start
Expand Down
16 changes: 8 additions & 8 deletions data-vault/package-lock.json

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

11 changes: 6 additions & 5 deletions data-vault/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "data-vault",
"version": "1.0.0",
"name": "@rsksmart/rif-id-data-vault-service",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start:build": "tsc",
"start": "npm run start:build && node build/index.js",
"start:dev": "concurrently \"tsc --watch\" \"nodemon ./build/index.js\"",
"test": "echo \"Error: no test specified\" && exit 1"
"start": "npm run start:build && node build/scripts/index.js",
"start:dev": "concurrently \"tsc --watch\" \"nodemon ./build/scripts/index.js\"",
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "rm ./node_modules/ethr-did/lib/index.js && cp ./patch/ethrDID-copy.js ./node_modules/ethr-did/lib/index.js"
},
"author": "",
"license": "ISC",
Expand Down
142 changes: 0 additions & 142 deletions data-vault/src/index.ts

This file was deleted.

32 changes: 32 additions & 0 deletions data-vault/src/scripts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* env */
import dotenv from 'dotenv'
import Debug from 'debug'
import express from 'express'
import cors from 'cors'
import { setupCentralizedIPFSPinner } from '../services/centralizedIPFSPinner'

/* env */
dotenv.config()
Debug.enable('*')

const debug = Debug('rif-id:data-vault:scripts')

if (!process.env.PRIVATE_KEY) throw new Error('Setup private key')
if (!process.env.ADDRESS) throw new Error('Setup address')

const env = {
privateKey: process.env.PRIVATE_KEY,
address: process.env.ADDRESS,
ipfsPort: process.env.IPFS_PORT || '5001',
ipfsHost: process.env.IPFS_HOST || 'localhost',
authExpirationTime: process.env.AUTH_EXPIRATION_TIME || '300000',
rpcUrl: process.env.RPC_URL || 'https://did.testnet.rsk.co:4444'
}

const port = process.env.PORT || '5102'

/* setup app */
const app = express()
app.use(cors())

setupCentralizedIPFSPinner(app, env).then(() => app.listen(port, () => debug(`Data vault started on port ${port}`)))
Loading

0 comments on commit e9996dd

Please sign in to comment.