Skip to content

Commit

Permalink
refactor: revocation list (#147)
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
- [ ] 📝 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]. 
-->
This PR refactor the revocation list 2020 package to make that suitable
with the database providers to lock the change on the revocation list
and data.

## 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?

- [ ] 📜 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 18, 2023
1 parent 1a741ef commit 5a3e6a6
Show file tree
Hide file tree
Showing 13 changed files with 462 additions and 154 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"test:packages-watch": "pnpm test:packages --watch --verbose",
"test:oa-renderer": "cd packages/vckit-oa-renderers && pnpm test",
"test:oa-renderer-ci": "pnpm test:oa-renderer -- --coverage=true",
"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'",
"vckit": "cross-env NODE_NO_WARNINGS=1 ./packages/cli/bin/vckit.js",
"prettier": "prettier --write \"{packages,docs,__tests__,!build}/**/*.{ts,js,json,md,yml}\"",
Expand Down
3 changes: 3 additions & 0 deletions packages/encrypted-storage/.env.postgres.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/vckit"
DATABASE_TYPE="postgres"
DATABASE_DATABASE="vckit"
2 changes: 2 additions & 0 deletions packages/encrypted-storage/.env.sqlite.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DATABASE_DATABASE="../../../database.sqlite"
DATABASE_TYPE="sqlite"
6 changes: 4 additions & 2 deletions packages/encrypted-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"scripts": {
"build": "tsc",
"extract-api": "node ../cli/bin/vckit.js dev extract-api"
"extract-api": "node ../cli/bin/vckit.js dev extract-api",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d ./build/data-source.js"
},
"license": "Apache-2.0",
"keywords": [],
Expand Down Expand Up @@ -41,6 +42,7 @@
"@veramo/utils": "5.2.0",
"express-interceptor": "^1.2.0",
"typeorm": "^0.3.10",
"uuid": "^9.0.0"
"uuid": "^9.0.0",
"dotenv": "^16.0.0"
}
}
15 changes: 15 additions & 0 deletions packages/encrypted-storage/src/data-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DataSource, DataSourceOptions } from 'typeorm';
import { migrations, Entities } from './index.js';
import 'dotenv/config';

const dataSource = {
type: process.env.DATABASE_TYPE as string,
database: process.env.DATABASE_DATABASE as string,
url: process.env.DATABASE_URL as string,
entities: Entities,
synchronize: false,
logging: false,
migrations: migrations,
};

export default new DataSource(dataSource as DataSourceOptions);
3 changes: 3 additions & 0 deletions packages/revocation-list-2020/.env.postgres.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/vckit"
DATABASE_TYPE="postgres"
DATABASE_DATABASE="vckit"
2 changes: 2 additions & 0 deletions packages/revocation-list-2020/.env.sqlite.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DATABASE_DATABASE="../../../database.sqlite"
DATABASE_TYPE="sqlite"
4 changes: 3 additions & 1 deletion packages/revocation-list-2020/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"scripts": {
"build": "tsc",
"extract-api": "node ../cli/bin/vckit.js dev extract-api"
"extract-api": "node ../cli/bin/vckit.js dev extract-api",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d ./build/data-source.js"
},
"license": "Apache-2.0",
"keywords": [],
Expand Down Expand Up @@ -47,6 +48,7 @@
"@veramo/data-store": "5.2.0",
"@veramo/utils": "5.2.0",
"credential-status": "^2.0.5",
"dotenv": "^16.0.0",
"express-interceptor": "^1.2.0",
"jsonld-signatures": "^11.2.1",
"typeorm": "^0.3.10",
Expand Down
15 changes: 15 additions & 0 deletions packages/revocation-list-2020/src/data-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DataSource, DataSourceOptions } from 'typeorm';
import { migrations, Entities } from './index.js';
import 'dotenv/config';

const dataSource = {
type: process.env.DATABASE_TYPE as string,
database: process.env.DATABASE_DATABASE as string,
url: process.env.DATABASE_URL as string,
entities: Entities,
synchronize: false,
logging: false,
migrations: migrations,
};

export default new DataSource(dataSource as DataSourceOptions);
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
BaseEntity,
BeforeInsert,
BeforeUpdate,
Column,
Entity,
PrimaryColumn,
PrimaryGeneratedColumn,
} from 'typeorm';
import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('revocation-data')
export class RevocationData extends BaseEntity {
Expand Down
Loading

0 comments on commit 5a3e6a6

Please sign in to comment.