Skip to content

Commit

Permalink
refactor: vc api structure (#142)
Browse files Browse the repository at this point in the history
<!--
  For Work In Progress Pull Requests, please use the Draft PR feature,
see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for
further details.
  
  For a timely review/response, please avoid force-pushing additional
  commits if your PR already received reviews or comments.
  
Before submitting a Pull Request, please ensure you've done the
following:
- 📖 Read the [Contributing
Guide](https://github.com/uncefact/project-vckit/blob/main/CONTRIBUTING.md).
- 📖 Read the [Code of
Conduct](https://github.com/uncefact/project-vckit/blob/main/CODE_OF_CONDUCT.md).
  - 👷‍♀️ Create small PRs. In most cases, this will be possible.
  - ✅ Provide tests for your changes.
- 📝 Use descriptive commit messages following [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/).
- 📗 Update any related documentation and include any relevant
screenshots.
-->

## What type of PR is this? (check all applicable)

- [ ] 🍕 Feature
- [ ] 🐛 Bug Fix
- [x] 📝 Documentation Update
- [ ] 🎨 Style
- [x] 🧑‍💻 Code Refactor
- [ ] 🔥 Performance Improvements
- [ ] ✅ Test
- [ ] 🤖 Build
- [ ] 🔁 CI
- [ ] 📦 Chore (Release)
- [ ] ⏩ Revert

## Description

<!-- 
Please do not leave this blank 
This PR [adds/removes/fixes/replaces] the [feature/bug/etc]. 
-->

## Related Tickets & Documents
<!-- 
Please use this format link issue numbers: Fixes #123

https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

## Mobile & Desktop Screenshots/Recordings

<!-- Visual changes require screenshots -->


## Added tests?

- [ ] 👍 yes
- [ ] 🙅 no, because they aren't needed
- [ ] 🙋 no, because I need help

## Added to documentation?

- [x] 📜 README.md
- [ ] 📓 [vc-kit doc site](https://uncefact.github.io/vckit/)
- [ ] 📕 storybook
- [ ] 🙅 no documentation needed

## [optional] Are there any post-deployment tasks we need to perform?


<!-- note: PRs with deleted sections will be marked invalid -->

---------

Signed-off-by: Nam Hoang <[email protected]>
  • Loading branch information
namhoang1604 committed Aug 11, 2023
1 parent 71d85c0 commit 63f93f0
Show file tree
Hide file tree
Showing 25 changed files with 296 additions and 521 deletions.
14 changes: 5 additions & 9 deletions packages/cli/default/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,12 @@ server:

# DID Documents
- - $require: '@vckit/remote-server?t=function#WebDidDocRouter'

- - $require: '@vckit/vc-api?t=function#HolderRouter'
- - $require: '@vckit/vc-api?t=function#IssuerRouter'
$args:
- createCredential: createVerifiableCredential
updateCredentialStatus: updateVerifiableCredentialStatus
- - $require: '@vckit/vc-api?t=function#VerifierRouter'
$args:
- verifyCredential: verifyCredential
verifyPresentation: verifyPresentation
- keyMapping:
Ed25519: JsonWebKey2020 # Ed25519VerificationKey2020 | JsonWebKey2020

# VC API
- - $require: '@vckit/vc-api?t=function#VCRouter'
# VC API docs path
- - /vc-api.json
- $require: '@vckit/vc-api?t=function#VCApiSchemaRouter'
Expand Down Expand Up @@ -366,6 +361,7 @@ credentialIssuerLD:
$args:
- suites:
- $require: '@veramo/credential-ld#VeramoEd25519Signature2018'
# - $require: '@veramo/credential-ld#VeramoEd25519Signature2020'
- $require: '@veramo/credential-ld#VeramoJsonWebSignature2020'
- $require: '@veramo/credential-ld#VeramoEcdsaSecp256k1RecoverySignature2020'
contextMaps:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@veramo/did-resolver": "5.1.2",
"@veramo/key-manager": "5.1.2",
"@veramo/kms-local": "5.1.2",
"@veramo/remote-client": "5.2.1-next.5",
"@veramo/remote-client": "5.1.2",
"@veramo/message-handler": "5.1.2",
"@veramo/selective-disclosure": "5.1.2",
"@veramo/url-handler": "5.1.2",
Expand Down
59 changes: 17 additions & 42 deletions packages/credential-oa/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Credential OpenAttestation Plugin

- This plugin is used for issuing and verifying verifiable credential that adhere to OpenAttestation framework
- `uncefact/project-vckit` ’s goals is to support issuing and verifying verifiable credential in both W3C and OpenAtttestation framework right now , so this plugin is packed inside `uncefact/project-vckit` core but it can be plugged into any platform/library that using Veramo architecture.

## Usage

- Add this declaration to `agent.yml` config file
- Add the plugin to your `agent.yml` file

```
```yaml

///... other declarations
# Agent
Expand All @@ -17,44 +16,20 @@ agent:
- schemaValidation: false
plugins:
/// ... other declarations
**- $require: '@vckit/credential-oa#CredentialPlugin'**
- $require: '@vckit/credential-oa#CredentialOA'
```
- And export the functions of the plugin to be used in the application
```yaml
- createVerifiableCredentialOA
- verifyCredentialOA
```
- Use the CLI to quickly issue a credential
```bash
pnpm vckit credentialOA create
```

- **Signing**
- To streamline the signing process across signing process between w3c, OpenAttestation and other frameworks in mind , the plugin use private key that managed by Veramo’s keyManager to sign and associate with did document.
> **NOTE**: OpenAttestation document currently support 2 types of DID which is **did ethereum** and **did web**
- **Using uncefact/project-vckit CLI to create an OpenAttestation verifiable credential**
- **Prerequisites:** create a new did document if you haven’t create one \*\*\*\*
- `pnpm run vckit did create`
- Select **did:ether** or **did:web**
- If you select **did:web,** it’s your responsibility to put the verification information to standard endpoint so that verifier can resolve and verify your document
- **Note**: Every did document created has a key associated with it , to add a new key , run `pnpm run vckit did add-key`
```jsx
? Select identifier provider (Use arrow keys)
❯ did:ethr
```
### **Create OpenAttestation VC**
- Run: `pnpm run vckit credential create`
- Select `OpenAttestationMerkleProofSignature2018`
```jsx
? Credential proofFormat
jwt
lds
EthereumEip712Signature2021
❯ OpenAttestationMerkleProofSignature2018
```
- Select a did document you create earlier to identify issuer and sign document
```jsx
Issuer DID
❯ did:ethr:0x034bb92d2fffb6ff7ad8fbbefc01a919818017ef3f32c3e1443f44a45ab94f16bb
```
- Select identity proof type
- **Note**: `DNS-DID` and `DNS-TXT` require you to put the Issuer DID information to the domain specified in Identity Proof Type. Refer to [this](https://www.openattestation.com/docs/integrator-section/verifiable-document/ethereum/dns-proof) for more information. For the `DID` , verification process will skip checking for the issuer information
```jsx
? Identity Proof Type (Use arrow keys)
❯ DNS-DID
DNS-TXT
DID
```
### Verify **OpenAttestation VC**
- Simple run `pnpm run vckit verify -f vc-file.json` with the result from the create vc to verify the vc
> **Note**: The credential OA plugin only supports issuing by DID ethr. You can use the `@veramo/did-manager` plugin that should be configured in the `agent.yml` file to create a DID ethr.
1 change: 0 additions & 1 deletion packages/credential-oa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@govtechsg/oa-verify": "^8.0.0",
"@govtechsg/open-attestation": "^6.6.0",
"@vckit/core-types": "^1.0.0-beta.5",
"@veramo/message-handler": "5.1.2",
"@veramo/utils": "5.2.0"
},
"devDependencies": {
Expand Down
44 changes: 22 additions & 22 deletions packages/demo-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"scripts": {
"dev": "craco start",
"build": "pnpm run build:explorer && pnpm run build:verifier",
"build": "pnpm run build:explorer",
"build:explorer": "craco build",
"build:verifier": "REACT_APP_MODE=verifier craco build",
"test": "craco test --watchAll=false",
Expand Down Expand Up @@ -71,7 +71,7 @@
"@vckit/example-documents": "workspace:^1.0.0-beta.4",
"@vckit/react-components": "workspace:^1.0.0-beta.5",
"@vckit/renderer": "workspace:^1.0.0-beta.5",
"@veramo/remote-client": "5.2.1-next.5",
"@veramo/remote-client": "5.1.2",
"ajv": "^8.12.0",
"commander": "^10.0.1",
"express": "^4.18.2",
Expand Down Expand Up @@ -131,26 +131,26 @@
"@types/uuid": "^9.0.1",
"@veramo-community/react-components": "^1.4.0",
"@veramo-community/veramo-react": "^1.0.82",
"@veramo/core": "5.2.1-next.5",
"@veramo/core-types": "5.2.1-next.5",
"@veramo/credential-eip712": "5.2.1-next.5",
"@veramo/credential-w3c": "5.2.1-next.5",
"@veramo/data-store": "5.2.1-next.5",
"@veramo/data-store-json": "5.2.1-next.5",
"@veramo/did-comm": "5.2.1-next.5",
"@veramo/did-discovery": "5.2.1-next.5",
"@veramo/did-jwt": "5.2.1-next.5",
"@veramo/did-manager": "5.2.1-next.5",
"@veramo/did-provider-ethr": "5.2.1-next.5",
"@veramo/did-provider-peer": "5.2.1-next.5",
"@veramo/did-resolver": "5.2.1-next.5",
"@veramo/key-manager": "5.2.1-next.5",
"@veramo/kms-local": "5.2.1-next.5",
"@veramo/kms-web3": "5.2.1-next.5",
"@veramo/message-handler": "5.2.1-next.5",
"@veramo/remote-client": "5.2.1-next.5",
"@veramo/selective-disclosure": "5.2.1-next.5",
"@veramo/utils": "5.2.1-next.5",
"@veramo/core": "5.2.0",
"@veramo/core-types": "5.1.2",
"@veramo/credential-eip712": "5.2.0",
"@veramo/credential-w3c": "5.2.0",
"@veramo/data-store": "5.2.0",
"@veramo/data-store-json": "5.2.0",
"@veramo/did-comm": "5.2.0",
"@veramo/did-discovery": "5.1.2",
"@veramo/did-jwt": "5.2.0",
"@veramo/did-manager": "5.1.2",
"@veramo/did-provider-ethr": "5.1.2",
"@veramo/did-provider-peer": "5.2.0",
"@veramo/did-resolver": "5.2.0",
"@veramo/key-manager": "5.1.2",
"@veramo/kms-local": "5.1.2",
"@veramo/kms-web3": "5.1.2",
"@veramo/message-handler": "5.1.2",
"@veramo/remote-client": "5.2.0",
"@veramo/selective-disclosure": "5.2.0",
"@veramo/utils": "5.2.0",
"@web3-react/core": "^8.2.0",
"@web3-react/metamask": "^8.2.1",
"@web3-react/types": "^8.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@vckit/core-types": "^1.0.0-beta.5",
"@veramo/core": "5.2.0",
"@veramo/remote-client": "5.2.1-next.5",
"@veramo/remote-client": "5.1.2",
"@veramo/credential-w3c": "5.2.0",
"@veramo/data-store": "5.2.0",
"@veramo/data-store-json": "5.2.0",
Expand Down
12 changes: 10 additions & 2 deletions packages/encrypted-storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The encrypted storage plugin provides a secure storage for the agent. It is used

To use the encrypted storage plugin, you need to add the following configuration to the agent.yml.

Fist, add the `dbConnectionEncrypted` to define the database connection for the encrypted storage.
- First, add the `dbConnectionEncrypted` to define the database connection for the encrypted storage.

```yaml
dbConnectionEncrypted:
Expand All @@ -17,7 +17,7 @@ dbConnectionEncrypted:
- type: sqlite
database:
$ref: /constants/databaseFile
synchronize: true
synchronize: false
migrationsRun: true
migrations:
$require: '@vckit/encrypted-storage?t=object#migrations'
Expand Down Expand Up @@ -50,6 +50,14 @@ agent:
- $ref: /encryptedStorage
```

Then, you need to expose the functions of the plugin.

```yaml
- encryptAndStoreData
- fetchEncryptedData
- fetchEncryptedDataByCredentialHash
```

After that, you need to configure the middleware to use the encrypted storage plugin to store the verifiable credentials when issue the verifiable credentials. You can configure the middleware in the `apiRoutes` section of the agent.yml.

```yaml
Expand Down
2 changes: 1 addition & 1 deletion packages/remote-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@transmute/ed25519-key-pair": "0.7.0-unstable.81",
"@vckit/core-types": "^1.0.0-beta.5",
"@veramo/remote-client": "5.2.1-next.5",
"@veramo/remote-client": "5.1.2",
"@veramo/utils": "5.2.0",
"debug": "^4.3.3",
"did-resolver": "^4.0.1",
Expand Down
Loading

0 comments on commit 63f93f0

Please sign in to comment.