Skip to content

Commit

Permalink
Merge branch 'next' into bug/fix-dockerize
Browse files Browse the repository at this point in the history
  • Loading branch information
huynguyen-hl committed May 28, 2024
2 parents e59e27f + 698f3a2 commit 97e0350
Show file tree
Hide file tree
Showing 66 changed files with 9,341 additions and 5,590 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Test

on:
pull_request:
branches:
- next

jobs:
test_and_build:
runs-on: ubuntu-latest
env:
EXCLUDED_PACKAGE_OA_RENDERERS: '!./packages/vckit-oa-renderers/'
EXCLUDED_PACKAGE_CREDENTIAL_OA: '!./packages/credential-oa/'
EXCLUDED_PACKAGE_EXPLORER: '!./packages/demo-explorer/'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Install pnpm
run: npm i pnpm --global

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '21'

- name: Install dependencies
run: pnpm i --filter ${{ env.EXCLUDED_PACKAGE_OA_RENDERERS }} --filter ${{ env.EXCLUDED_PACKAGE_CREDENTIAL_OA }} --filter ${{ env.EXCLUDED_PACKAGE_EXPLORER }} --no-frozen-lockfile

- name: Build
run: pnpm build:agent

- name: Run tests
run: |
pnpm test:packages --changedSince=origin/next --ci --json --coverage --testLocationInResults --outputFile=report.json
- name: Coverage
uses: artiomtr/jest-coverage-report-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
coverage-file: report.json
base-coverage-file: report.json
threshold: 80
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ website/node_modules
/packages/*/api/*.api.md
/packages/*/coverage/
/packages/*/node_modules/
/packages/*/.tmp_npm/
coverage

.npmrc
Expand Down Expand Up @@ -91,4 +92,5 @@ local-database*.json
/scratch

# logs
/logs
/logs
.tmp_npm
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The vckit is built on top of the [Veramo](https://veramo.io/) agent framework. V

## Prerequisites

- [Node.js](https://nodejs.org/en/) version 18.17.0
- [Node.js](https://nodejs.org/en/) version 20.12.2
- [pnpm](https://pnpm.io/) version 8.14.1

This project has been tested and optimized for Node.js version v18.17.0 and pnpm version 8.14.1. Please note that using a Node.js version later than v18.17.0 may result incorrect functionality and potential bugs. It is strongly recommended to use these specific versions for running and testing the project. Deviating from these versions may result in unforeseen compatibility issues or unexpected behavior.
Expand Down
15 changes: 15 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default {
'!**/types/**',
'!**/build/**',
'!**/node_modules/**',
'!packages/vckit-oa-renderers',
'!packages/demo-explorer',
'!packages/credential-oa',
],
coverageReporters: ['text', 'lcov', 'json'],
coverageProvider: 'v8',
Expand All @@ -21,6 +24,9 @@ export default {
'<rootDir>/node_modules/',
'<rootDir>/packages/credential-ld/',
'<rootDir>/packages/vckit-oa-renderers/',
'<rootDir>/packages/demo-explorer/',
'<rootDir>/packages/credential-oa/',
'<rootDir>/.tmp_npm/',
],
testEnvironment: 'node',
automock: false,
Expand All @@ -36,4 +42,13 @@ export default {
},
],
},
// jest will fail if there is less than 80% branch, line, and function coverage, or if there are more than 10 uncovered statements
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: -10,
},
},
};
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
"name": "vckit",
"version": "1.0.0-beta.5",
"scripts": {
"build": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-json-modules\" pnpm build:js && pnpm build:api && pnpm build:schema",
"build:js": "pnpm -r --stream build",
"build:api": "pnpm --package=@vckit/cli -c dlx \"pnpm -r --stream extract-api\"",
"postinstall": "mkdir .tmp_npm; cd .tmp_npm; mkdir veramo; cd veramo; git init; git remote add -f origin https://github.com/gs-gs/veramo.git; git pull --depth=1 origin vc-v2; pnpm install; pnpm build;",
"build": "pnpm build:agent && pnpm build:explorer",
"build:agent": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-json-modules\" pnpm build:js && pnpm build:api && pnpm build:schema",
"build:js": "pnpm -r --stream --filter !./packages/vckit-oa-renderers/ --filter !./packages/credential-oa/ --filter !./packages/demo-explorer/ build",
"build:api": "pnpm --package=@vckit/cli -c dlx \"pnpm -r --stream --filter !./packages/vckit-oa-renderers/ --filter !./packages/credential-oa/ --filter !./packages/demo-explorer/ extract-api\"",
"build:schema": "pnpm --package=@vckit/cli -c dlx \"pnpm -r --stream generate-plugin-schema\"",
"test": "pnpm test:packages && pnpm test:oa-renderer",
"build:explorer": "pnpm -r --stream --filter=@vckit/demo-explorer build",
"test": "pnpm test:packages",
"test:packages-ci": "pnpm test:packages --coverage=true",
"test:packages": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-import-meta-resolve\" jest",
"test:packages-watch": "pnpm test:packages --watch --verbose",
Expand Down Expand Up @@ -83,6 +86,6 @@
"jsonld": "npm:@digitalcredentials/jsonld@^5.2.1"
},
"engines": {
"node": ">= 18.0.0"
"node": ">= 21.0.0"
}
}
}
117 changes: 117 additions & 0 deletions packages/bitstringStatusList/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Bitstring Status List

This plugin implement the bitstring status list https://w3c.github.io/vc-bitstring-status-list/ for Verifiable Credentials. It follows the Veramo plugin architecture.

## Installation

Add the plugin to your agent:

- Configure the database for bitstring status list and the bitstring status list plugin

```yaml
dbConnectionBitstringStatusList:
$require: typeorm#DataSource
$args:
- type: sqlite
database:
$ref: /constants/databaseFile
synchronize: false
migrationsRun: true
migrations:
$require: '@vckit/bitstringStatusList?t=object#migrations'
logging: false
entities:
$require: '@vckit/bitstringStatusList?t=object#Entities'

bitstringStatusList:
$require: '@vckit/bitstringStatusList#BitstringStatusList'
$args:
- bitstringDomainURL: http://localhost:3332
dbConnection:
$ref: /dbConnectionBitstringStatusList
```
- Add the plugin to your agent
```yaml
agent:
$require: '@veramo/core#Agent'
$args:
- schemaValidation: false
plugins:
...
- $ref: /bitstringStatusList
- $require: '@veramo/credential-status#CredentialStatusPlugin'
$args:
- BitstringStatusListEntry:
$require: '@vckit/bitstringStatusList?t=object#checkStatus'
```
- Add the plugin to the vckit server
```yaml
server:
baseUrl:
$ref: /constants/baseUrl
port:
$ref: /constants/port
use:
...
- - /credentials/status/bitstring-status-list
- $require: '@vckit/bitstringStatusList?t=function#bitstringStatusListRouter'
```
- Add the methods to the vckit server
```yaml
constants:
...
methods:
...
- issueBitstringStatusList
- checkBitstringStatus
- setBitstringStatus
```
## Usage
### Request a bitstring status list
```cURL
curl -X POST "http://localhost:3332/agent/issueBitstringStatusList" \
-H "accept: application/json; charset=utf-8"\
-H "content-type: application/json" \
-d '{"statusPurpose":"revocation","bitstringStatusIssuer":"did:web:example.com"}' \
```

Response:

```json
{
"id": "http://localhost:3332/credentials/status/bitstring-status-list/1#0",
"type": "BitstringStatusListEntry",
"statusPurpose": "revocation",
"statusListIndex": 0,
"statusListCredential": "http://localhost:3332/credentials/status/bitstring-status-list/1"
}
```

### Check a bitstring status list

**Note:** This API is exposed to developers to check the status of a credential. The correct usage is checking the status of a credential through the VC verifying of VCkit that will check the verifiable credential and the status of the credential.

```cURL
curl -X POST "http://localhost:3332/agent/checkBitstringStatus" \
-H "accept: application/json; charset=utf-8"\
-H "content-type: application/json" \
-d '{"verifiableCredential":{"issuanceDate":"2024-04-17T10:25:11.124Z","@context":["https://www.w3.org/2018/credentials/v1","https://www.w3.org/2018/credentials/examples/v1","https://w3id.org/security/suites/jws-2020/v1"],"type":["VerifiableCredential","UniversityDegreeCredential"],"credentialSubject":{"id":"did:example:ebfeb1f712ebc6f1c276e12ec21","name":"Jane Smith","degree":{"type":"BachelorDegree","name":"Bachelor of Science and Arts","degreeSchool":"Example University"}},"@type":"WebRenderingTemplate2022"}],"issuer":{"id":"did:web:example.com"},"credentialStatus":{"id":"http://localhost:3332/credentials/status/bitstring-status-list/1#0","type":"BitstringStatusListEntry","statusPurpose":"revocation","statusListIndex":0,"statusListCredential":"http://localhost:3332/credentials/status/bitstring-status-list/1"},"proof":{"type":"JsonWebSignature2020","created":"2024-04-19T03:30:07Z","verificationMethod":"did:web:example.com#e9bc8c0d327897fc70f6d9dea05d1e103b7eca429deba83fc34c2cfde0e81c8f-key-0","proofPurpose":"assertionMethod","jws":"eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..xY0syWgvQda7xiVlq2sC_pEl-eBFXvKzzHjt_9YE3Ek5bAWzGyXw2S60B2kVAQDT9JqAd7AUwRpNCt5LSa12AQ"}}}' \
```

### Set status for a bitstring status list

```cURL
curl -X POST "http://localhost:3332/agent/setBitstringStatus" \
-H "accept: application/json; charset=utf-8"\
-H "content-type: application/json" \
-d '{"statusListCredential":"http://localhost:3332/credentials/status/bitstring-status-list/1","statusListVCIssuer":"did:web:example.com","statusPurpose":"revocation","index":0,"status":true}' \
```
Loading

0 comments on commit 97e0350

Please sign in to comment.