Skip to content

Commit

Permalink
Fix bugs in applicant and common (#127)
Browse files Browse the repository at this point in the history
* putting dev code here temporarily

* remove manifests and fix type

* align with new manager interface - #126

* #126 - fix bugs in applicant and common

* #126 - resolve bug in applicant and issuer; updates to common

* fix lint

* update version script

* add version scripts

* Package versions updated: {
  root: '5.0.0',
  applicant: '4.0.0', major
  common: '4.1.0', minor
  issuer: '3.1.0', minor
  server: '3.0.1' patch
}
  • Loading branch information
bnonni authored Aug 29, 2024
1 parent 1d0fffc commit 34a7cf2
Show file tree
Hide file tree
Showing 27 changed files with 861 additions and 1,613 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install -r --frozen-lockfile
run: pnpm install -r --no-lockfile

- name: Run linter for all packages
run: pnpm lint
Expand Down
2 changes: 1 addition & 1 deletion dcx.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"editor.codeActionsOnSave": {
"source.fixAll": "always"
},
"typescript.tsdk": "root/node_modules/typescript/lib",
"typescript.tsdk": "${workspaceFolder:root}/node_modules/.pnpm/[email protected]/node_modules/typescript/lib",
"search.exclude": {
"**/dist/**": true,
"**/coverage/**": true,
Expand Down
54 changes: 16 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,13 @@
"publish:all": "pnpm --filter applicant publish && pnpm --filter common publish && pnpm --filter issuer publish && pnpm --filter server publish",
"test": "pnpm --recursive --stream test",
"test:node": "pnpm --recursive --stream test:node",
"workflow": "pnpm lint && pnpm install --frozen-lockfile && pnpm lint && pnpm build && pnpm build:tests:node",
"workflow": "pnpm lint && pnpm install -r && pnpm lint && pnpm build && pnpm build:tests:node",
"build-test": "pnpm --recursive --stream build && pnpm --recursive --stream build:tests:node && pnpm --recursive --stream test:node",
"version": "tsx scripts/version.ts",
"version:patch": "tsx scripts/version.ts patch",
"version:minor": "tsx scripts/version.ts minor",
"version:major": "tsx scripts/version.ts major",
"applicant": "pnpm --filter applicant",
"applicant:build": "pnpm --filter applicant build",
"applicant:publish": "pnpm --filter applicant publish",
"applicant:test:node": "pnpm --filter applicant test:node",
"applicant:version:patch": "tsx scripts/version.ts patch applicant",
"applicant:version:minor": "tsx scripts/version.ts minor applicant",
"applicant:version:major": "tsx scripts/version.ts major applicant",
"common": "pnpm --filter common",
"common:build": "pnpm --filter common build",
"common:publish": "pnpm --filter common publish",
"common:test:node": "pnpm --filter common test:node",
"common:version:patch": "tsx scripts/version.ts patch common",
"common:version:minor": "tsx scripts/version.ts minor common",
"common:version:major": "tsx scripts/version.ts major common",
"issuer": "pnpm --filter issuer",
"issuer:build": "pnpm --filter issuer build",
"issuer:publish": "pnpm --filter issuer publish",
"issuer:test:node": "pnpm --filter issuer test:node",
"issuer:version:patch": "tsx scripts/version.ts patch issuer",
"issuer:version:minor": "tsx scripts/version.ts minor issuer",
"issuer:version:major": "tsx scripts/version.ts major issuer",
"server": "pnpm --filter server",
"server:build": "pnpm --filter server build",
"server:publish": "pnpm --filter server publish",
"server:test:node": "pnpm --filter server test:node",
"server:version:minor": "tsx scripts/version.ts minor server",
"server:version:major": "tsx scripts/version.ts major server",
"server:version:patch": "tsx scripts/version.ts patch server"
"_server": "pnpm --filter server"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -93,16 +66,21 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.7",
"@npmcli/package-json": "^5.2.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"audit-ci": "^7.1.0",
"eslint-plugin-mocha": "^10.4.3",
"globals": "^15.8.0",
"eslint-plugin-mocha": "^10.5.0",
"globals": "^15.9.0",
"npkill": "^0.12.2"
},
"pnpm": {
"overrides": {
"express@<4.19.2": ">=4.19.2",
"ws@<8.17.1": ">=8.17.1"
}
"resolutions": {
"@tbd54566975/dwn-sdk-js": "^0.4.6",
"@web5/agent": "^0.6.1",
"@web5/user-agent": "^0.5.1",
"@web5/common": "^1.0.2",
"@web5/crypto": "^1.0.4",
"@web5/dids": "^1.1.4"
},
"dependencies": {
"typescript": "^5.5.4"
}
}
}
52 changes: 21 additions & 31 deletions packages/applicant/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcx-protocol/applicant",
"version": "3.0.0",
"version": "4.0.0",
"description": "DCX Applicant protocol and server",
"type": "module",
"main": "./dist/cjs/index.js",
Expand All @@ -16,7 +16,8 @@
"test:e2e": "tsx tests/e2e/*.spec.ts -t",
"test:node": "pnpm build:tests:node && NODE_ENV=test pnpm c8 mocha --require dotenv/config",
"lint": "eslint . --max-warnings 0 -c ../../eslint.config.cjs",
"lint:fix": "eslint . --fix -c ../../eslint.config.cjs"
"lint:fix": "eslint . --fix -c ../../eslint.config.cjs",
"version": "tsx ../../scripts/version.ts applicant"
},
"homepage": "https://github.com/TBD54566975/incubation-dcx#readme",
"bugs": "https://github.com/TBD54566975/incubation-dcx/issues",
Expand Down Expand Up @@ -67,49 +68,38 @@
},
"dependencies": {
"@dcx-protocol/common": "workspace:*",
"@noble/ciphers": "^0.5.3",
"@scure/bip39": "^1.3.0",
"@tbd54566975/dwn-sdk-js": "^0.4.4",
"@web5/agent": "^0.4.1",
"@web5/agent": "^0.6.1",
"@web5/api": "^0.10.0",
"@web5/common": "^1.0.2",
"@web5/credentials": "^1.0.4",
"@web5/crypto": "^1.0.2",
"@web5/dids": "^1.1.2",
"@web5/user-agent": "^0.4.1",
"chalk": "^5.3.0",
"ed25519-keygen": "^0.6.2",
"isomorphic-ws": "^5.0.0",
"ms": "^2.1.3"
"@web5/credentials": "^1.1.1",
"@web5/user-agent": "^0.5.1",
"ed25519-keygen": "^0.6.2"
},
"devDependencies": {
"@playwright/test": "^1.45.3",
"@types/chai": "^4.3.16",
"@playwright/test": "^1.46.1",
"@types/chai": "^4.3.19",
"@types/chai-as-promised": "^7.1.8",
"@types/eslint": "^9.6.0",
"@types/eslint": "^9.6.1",
"@types/mocha": "^10.0.7",
"@types/ms": "^0.7.34",
"@types/node": "^20.14.11",
"@types/readable-stream": "^4.0.15",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@web/test-runner": "^0.18.2",
"@types/node": "^20.16.2",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@web/test-runner": "^0.18.3",
"@web/test-runner-playwright": "^0.11.0",
"abstract-level": "^2.0.0",
"c8": "^10.1.2",
"chai": "^5.1.1",
"chai-as-promised": "^8.0.0",
"dotenv": "^16.4.5",
"esbuild": "^0.23.0",
"esbuild": "^0.23.1",
"eslint": "^8.57.0",
"eslint-plugin-mocha": "^10.4.3",
"globals": "^15.8.0",
"mocha": "^10.6.1",
"eslint-plugin-mocha": "^10.5.0",
"globals": "^15.9.0",
"mocha": "^10.7.3",
"mocha-junit-reporter": "^2.2.1",
"node-stdlib-browser": "^1.2.0",
"playwright": "^1.45.3",
"playwright": "^1.46.1",
"rimraf": "^6.0.1",
"typescript": "^5.5.3",
"typescript-eslint": "^7.17.0"
"typescript": "^5.5.4",
"typescript-eslint": "^7.18.0"
}
}
19 changes: 17 additions & 2 deletions packages/applicant/src/dcx-applicant.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
CreateCredentialApplicationParams,
CredentialApplication,
DcxAgent,
DcxAgentRecovery,
DcxDwnError,
DcxError,
Expand Down Expand Up @@ -366,6 +365,22 @@ export class DcxApplicant implements DcxManager {
return { manifests };
}

/**
* Check if the DcxIssuer is initialized
* @returns boolean
*/
public isInitialized(): boolean {
return this.status.initialized && !!(this.web5 && this.agent);
}

/**
* Check if the DcxIssuer is setup
* @returns boolean
*/
public isSetup(): boolean {
return this.status.setup === true;
}

/**
* Setup Dwn associated with the DcxApplicant
*/
Expand Down Expand Up @@ -420,7 +435,7 @@ export class DcxApplicant implements DcxManager {

// Set the DcxManager properties
this.web5 = web5 as Web5;
this.agent = agent as DcxAgent;
this.agent = agent;
this.did = did;

// Set the server initialized flag
Expand Down
5 changes: 3 additions & 2 deletions packages/applicant/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './dcx-applicant.js';
export * from './dcx-applicant-protocol.js';
export * from './dcx-applicant-config.js';
export * from './dcx-applicant-protocol.js';
export * from './dcx-applicant.js';
4 changes: 2 additions & 2 deletions packages/applicant/tests/dcx-applicant-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('ApplicantConfig', () => {
expect(applicantConfig.providers).to.be.an('array').and.to.have.lengthOf(0);
});

it('should have property "manifests" as an array with length 3', () => {
expect(applicantConfig.manifests).to.be.an('array').and.to.have.lengthOf(3);
it('should have property "manifests" as an array with length 1', () => {
expect(applicantConfig.manifests).to.be.an('array').and.to.have.lengthOf(1);
});

it('should have property "issuers" as an array with length 2', () => {
Expand Down
11 changes: 10 additions & 1 deletion packages/applicant/tests/dcx-applicant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ dotenv.config({ path: '.env.test' });

import { FileSystem } from '@dcx-protocol/common';
import { Protocol, Web5 } from '@web5/api';
import { Web5UserAgent } from '@web5/user-agent';
import { expect } from 'chai';
import { applicantConfig } from '../src/dcx-applicant-config.js';
import { DcxApplicant } from '../src/index.js';
import { Web5UserAgent } from '@web5/user-agent';

process.env.NODE_ENV = 'test';

Expand Down Expand Up @@ -93,8 +93,17 @@ describe('applicant = new DcxApplicant({ config: applicantConfig })', () => {
describe('await applicant.initialize()', () => {
it('should initialize applicant properties "web5" and "agent"', async () => {
await applicant.initialize();
});

it('should have property status.initialized as a boolean equal to true', async () => {
expect(applicant.status.initialized).to.be.true;
});

it('should have property applicant.web5 as an instanceof Web5', async () => {
expect(applicant.web5).to.be.instanceof(Web5);
});

it('should have property applicant.agent as an instance of Web5UserAgent', async () => {
expect(applicant.agent).to.be.instanceof(Web5UserAgent);
});
});
Expand Down
54 changes: 23 additions & 31 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcx-protocol/common",
"version": "4.0.0",
"version": "4.1.0",
"description": "Common library shared by the other @dcx-protocol packages",
"type": "module",
"main": "./dist/cjs/index.js",
Expand All @@ -16,7 +16,8 @@
"clean": "rimraf dist coverage tests/compiled",
"test": "pnpm test:node",
"test:e2e": "tsx tests/e2e/*.spec.ts",
"test:node": "pnpm build:tests:node && NODE_ENV=test pnpm c8 mocha --require dotenv/config"
"test:node": "pnpm build:tests:node && NODE_ENV=test pnpm c8 mocha --require dotenv/config",
"version": "tsx ../../scripts/version.ts common"
},
"homepage": "https://github.com/TBD54566975/incubation-dcx#readme",
"bugs": "https://github.com/TBD54566975/incubation-dcx/issues",
Expand Down Expand Up @@ -68,51 +69,42 @@
"dependencies": {
"@noble/ciphers": "0.4.1",
"@scure/bip39": "^1.3.0",
"@sphereon/pex": "3.3.3",
"@sphereon/pex-models": "^2.2.4",
"@sphereon/ssi-types": "0.22.0",
"@tbd54566975/dwn-sdk-js": "^0.4.4",
"@web5/agent": "^0.4.1",
"@web5/agent": "^0.6.1",
"@web5/api": "^0.10.0",
"@web5/common": "^1.0.2",
"@web5/credentials": "^1.0.4",
"@web5/crypto": "^1.0.2",
"@web5/dids": "^1.1.2",
"@web5/user-agent": "^0.4.1",
"@web5/credentials": "^1.1.1",
"@web5/crypto": "^1.0.4",
"@web5/dids": "^1.1.4",
"@web5/user-agent": "^0.5.1",
"chalk": "^5.3.0",
"ed25519-keygen": "^0.6.2",
"isomorphic-ws": "^5.0.0",
"ms": "^2.1.3",
"readable-web-to-node-stream": "^3.0.2"
"ms": "^2.1.3"
},
"devDependencies": {
"@playwright/test": "^1.45.3",
"@types/chai": "^4.3.16",
"@playwright/test": "^1.46.1",
"@types/chai": "^4.3.19",
"@types/chai-as-promised": "^7.1.8",
"@types/eslint": "^9.6.0",
"@types/eslint": "^9.6.1",
"@types/mocha": "^10.0.7",
"@types/ms": "^0.7.34",
"@types/node": "^20.14.11",
"@types/readable-stream": "^4.0.15",
"@types/ws": "^8.5.11",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@web/test-runner": "^0.18.2",
"@types/node": "^20.16.2",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@web/test-runner": "^0.18.3",
"@web/test-runner-playwright": "^0.11.0",
"abstract-level": "^2.0.0",
"c8": "^10.1.2",
"chai": "^5.1.1",
"chai-as-promised": "^8.0.0",
"dotenv": "^16.4.5",
"esbuild": "^0.23.0",
"esbuild": "^0.23.1",
"eslint": "^8.57.0",
"eslint-plugin-mocha": "^10.4.3",
"globals": "^15.8.0",
"mocha": "^10.6.1",
"eslint-plugin-mocha": "^10.5.0",
"globals": "^15.9.0",
"mocha": "^10.7.3",
"mocha-junit-reporter": "^2.2.1",
"playwright": "^1.45.3",
"playwright": "^1.46.1",
"rimraf": "^6.0.1",
"typescript": "^5.5.3",
"typescript-eslint": "^7.17.0"
"typescript": "^5.5.4",
"typescript-eslint": "^7.18.0"
}
}
Loading

0 comments on commit 34a7cf2

Please sign in to comment.