Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a draft for docker usage #4

Merged
merged 3 commits into from
Jun 16, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config
Dockerfile
example.env
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:16-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

CMD [ "node", "index.js"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
1. Update the self description in `self-description.json`.
2. Create a new `.env` file with `PRIVATE_KEY`, `CERTIFICATE`, `VERIFICATION_METHOD` and `X5U_URL` as properties.
3. Install dependencies `npm i` and execute the script `node index.js` (node@16 or higher required).
- Alternatively, the script can be run with docker
1. Build the container with `docker build -t self-description-signer .`
2. Run the script with `docker run -it --mount src="$(pwd)/config",target=/usr/src/app/config,type=bind self-description-signer`
4. The given self description will be locally signed and a new file containing self description + proof called `timestamp_self-signed_gx-type.json` will be created.
5. In addition, a did.json will be created based on the provided `CERTIFICATE` and `VERIFICATION_METHOD`
6. Upload this did.json to your domain (e.g. `https://your_domain.com/.well-known/did.json`).
7. Re-run the script and finally, the compliance service is used to sign the locally signed self description. It signs it if the final result is against the compliance service. The result is stored in a new file called `timestamp_complete_gx-type.json`


## How it Works
1. The given Self Description is canonized with [URDNA2015](https://json-ld.github.io/rdf-dataset-canonicalization/spec/)
2. Next the canonized output is hashed with [SHA256](https://json-ld.github.io/rdf-dataset-canonicalization/spec/#dfn-hash-algorithm).
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
require('dotenv').config()
const conf = './config/'

require('dotenv').config({path:conf + '.env'})

const axios = require('axios')
const crypto = require('crypto')
const fs = require('fs').promises
const jose = require('jose')

const { selfDescription } = require('./self-description.json')
const { selfDescription } = require(conf+'/self-description.json')
const currentTime = new Date().getTime()
const BASE_URL = "https://compliance.lab.gaia-x.eu"

Expand Down Expand Up @@ -64,7 +66,7 @@ async function createSignedSdFile(selfDescription, proof) {
const status = proof ? "self-signed" : "complete"
const type = proof ? selfDescription['@type'].split(':')[0] : selfDescription.selfDescriptionCredential.selfDescription['@type'].split(':')[0]
const data = JSON.stringify(content, null, 2)
const filename = `${currentTime}_${status}_${type}.json`
const filename = conf+`${currentTime}_${status}_${type}.json`

await fs.writeFile(filename, data)

Expand Down Expand Up @@ -92,7 +94,7 @@ async function createDIDFile() {
}

const data = JSON.stringify(did, null, 2)
const filename = `${currentTime}_did.json`
const filename = conf + `${currentTime}_did.json`

await fs.writeFile(filename, data)

Expand Down