Skip to content

Commit

Permalink
feat: seed test identifier (#217)
Browse files Browse the repository at this point in the history
## What type of PR is this? (check all applicable)

- [x] πŸ• Feature
- [ ] πŸ› Bug Fix
- [ ] πŸ“ Documentation Update
- [ ] 🎨 Style
- [ ] πŸ§‘β€πŸ’» Code Refactor
- [ ] πŸ”₯ Performance Improvements
- [ ] βœ… Test
- [ ] πŸ€– Build
- [ ] πŸ” CI
- [ ] πŸ“¦ Chore (Release)
- [ ] ⏩ Revert

## Description

This feature automates the process of seeding a predefined DID document
for use in development environments.

## Added to documentation?

- [x] πŸ“œ README.md
- [ ] πŸ““ [vc-kit doc site](https://uncefact.github.io/vckit/)
- [ ] πŸ“• storybook
- [ ] πŸ™… no documentation needed

---------

Co-authored-by: Nam Hoang <hoangxuannam160493@gmail.com>
  • Loading branch information
hoa-ngo-gs and namhoang1604 authored Oct 11, 2024
1 parent 2adb515 commit bd3ee1c
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ COPY --from=build /app/packages/vc-api/package.json packages/vc-api/package.json
COPY --from=build /app/packages/vc-api/src/vc-api-schemas/vc-api.yaml packages/vc-api/src/vc-api-schemas/vc-api.yaml
COPY --from=build /app/packages/vc-api/src/vc-api-schemas/vc-api-v2.yaml packages/vc-api/src/vc-api-schemas/vc-api-v2.yaml

# Add the DID Web Identifier
COPY development/did-web-identifier.json .

# Add an entrypoint script to the image
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ pnpm vckit config

The `pnpm vckit config` command will create a `agent.yml` file in the root of the project. This file contains the configuration for the Veramo agent. You can edit this file to configure the agent to your needs. The default configuration is sufficient to get started.

## Seed Identifier

This feature automates the process of seeding a predefined DID document for use in development environments.

The DID document is located at `documentation/static/test-and-development/did.json`.
This document is built and served using Docusaurus.

A seed-identifier script is available to seed the identifier into the vckit instance.
This script runs the `vckit did import` command and uses a predefined identifier file located at `/development/did-web-identifier.json`.

The predefined did:web used for seeding is: `did:web:uncefact.github.io:project-vckit:test-and-development`

```bash
# Seed identifier
pnpm seed-identifier
```

The Docker Compose entrypoint includes a shell command to run the seed-identifier script automatically.

## Start the server on local

```bash
Expand Down
1 change: 1 addition & 0 deletions development/did-web-identifier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"did":"did:web:uncefact.github.io:project-vckit:test-and-development","alias":"uncefact.github.io:project-vckit:test-and-development","provider":"did:web","controllerKeyId":"7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6","keys":[{"kid":"7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6","kms":"local","type":"Ed25519","publicKeyHex":"7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6","privateKeyHex":"5f217ba8a29fb4e4cc4b461212bc28af7b31ffa075d146d34120d5061e631aa9","meta":{"algorithms":["EdDSA","Ed25519"]}}]}
72 changes: 72 additions & 0 deletions documentation/static/test-and-development/did.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/suites/ed25519-2020/v1",
"https://w3id.org/security/suites/jws-2020/v1"
],
"id": "did:web:uncefact.github.io:project-vckit:test-and-development",
"verificationMethod": [
{
"id": "did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6",
"type": "Ed25519VerificationKey2020",
"controller": "did:web:uncefact.github.io:project-vckit:test-and-development",
"publicKeyMultibase": "z6MknjB7dKeKciUSdJAiUUxZYoZ5kkJHZWtaPDX3uXvCZagV"
},
{
"id": "did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey2020-key-0",
"type": "JsonWebKey2020",
"controller": "did:web:uncefact.github.io:project-vckit:test-and-development",
"publicKeyJwk": {
"kty": "OKP",
"crv": "Ed25519",
"x": "evE2qO-hGk3y6QELlyvbkqABNyS1Dl76RUB6Ld6hhOY"
}
},
{
"id": "did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey2020-key-1",
"type": "JsonWebKey2020",
"controller": "did:web:uncefact.github.io:project-vckit:test-and-development",
"publicKeyJwk": {
"kty": "OKP",
"crv": "X25519",
"x": "-O3nPjITiIlmPK8hQPI92s4gZio4M3esuk2HAyG3QzY"
}
},
{
"id": "did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey-key-0",
"type": "JsonWebKey",
"controller": "did:web:uncefact.github.io:project-vckit:test-and-development",
"publicKeyJwk": {
"kty": "OKP",
"crv": "Ed25519",
"x": "evE2qO-hGk3y6QELlyvbkqABNyS1Dl76RUB6Ld6hhOY"
}
},
{
"id": "did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey-key-1",
"type": "JsonWebKey",
"controller": "did:web:uncefact.github.io:project-vckit:test-and-development",
"publicKeyJwk": {
"kty": "OKP",
"crv": "X25519",
"x": "-O3nPjITiIlmPK8hQPI92s4gZio4M3esuk2HAyG3QzY"
}
}
],
"authentication": [
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6",
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey2020-key-0",
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey2020-key-1",
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey-key-0",
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey-key-1"
],
"assertionMethod": [
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6",
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey2020-key-0",
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey2020-key-1",
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey-key-0",
"did:web:uncefact.github.io:project-vckit:test-and-development#7af136a8efa11a4df2e9010b972bdb92a0013724b50e5efa45407a2ddea184e6-JsonWebKey-key-1"
],
"keyAgreement": [],
"service": []
}
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ envsubst '${DATABASE_TYPE},${DATABASE_NAME},${DATABASE_HOST},${DATABASE_PORT},${

echo "Agent.yml updated."

# Seed test identifier
echo "Seeding test identifier..."
cat did-web-identifier.json| node packages/cli/build/cli.js did import
echo "Test identifier seeded."

# Execute the Docker CMD
exec "$@"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"migrate:db": "pnpm -r --stream typeorm migration:run",
"rollback:db": "pnpm -r --stream typeorm migration:revert",
"watch": "pnpm -r exec --if-present 'pnpm run watch'",
"seed-identifier": "cat development/did-web-identifier.json | pnpm vckit did import",
"vckit": "cross-env NODE_NO_WARNINGS=1 ./packages/cli/bin/vckit.js",
"prettier": "prettier --write \"{packages,docs,__tests__,!build}/**/*.{ts,js,json,md,yml}\"",
"publish:latest": "lerna publish --conventional-commits --include-merged-tags --create-release github --yes --dist-tag beta --registry \"https://registry.npmjs.org/:_authToken=${NPM_TOKEN}\"",
Expand Down

0 comments on commit bd3ee1c

Please sign in to comment.