diff --git a/api-docs/package.json b/api-docs/package.json index 274d0ff494..a57eb68682 100644 --- a/api-docs/package.json +++ b/api-docs/package.json @@ -1,6 +1,6 @@ { "name": "api-docs", - "version": "2.2.1", + "version": "2.2.2", "description": "Swagger Documentation", "main": "dist/index.js", "scripts": { diff --git a/api-gateway/package.json b/api-gateway/package.json index 5b8fb6a7ff..ab155d9523 100644 --- a/api-gateway/package.json +++ b/api-gateway/package.json @@ -8,8 +8,8 @@ }, "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.2.1", - "@guardian/interfaces": "^2.2.1", + "@guardian/common": "^2.2.2", + "@guardian/interfaces": "^2.2.2", "dotenv": "^16.0.0", "express": "^4.17.1", "jszip": "^3.7.1", @@ -49,5 +49,5 @@ "start": "node dist/index.js", "test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ui-service.xml" }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/auth-service/package.json b/auth-service/package.json index e8020cbe4d..71a5c172b1 100644 --- a/auth-service/package.json +++ b/auth-service/package.json @@ -7,8 +7,8 @@ }, "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.2.1", - "@guardian/interfaces": "^2.2.1", + "@guardian/common": "^2.2.2", + "@guardian/interfaces": "^2.2.2", "dotenv": "^16.0.0", "jsonwebtoken": "^8.5.1", "module-alias": "^2.2.2", @@ -44,5 +44,5 @@ "start": "node dist/index.js", "test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ui-service.xml" }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/common/package.json b/common/package.json index 9bfd8839c8..63b880d6aa 100644 --- a/common/package.json +++ b/common/package.json @@ -1,7 +1,7 @@ { "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/interfaces": "^2.2.1", + "@guardian/interfaces": "^2.2.2", "nats": "^2.6.1", "reflect-metadata": "^0.1.13", "zlib": "^1.0.5" @@ -27,5 +27,5 @@ "prepare": "npm run build", "test": "echo \"Error: no test specified\" && exit 1" }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/guardian-service/package.json b/guardian-service/package.json index 0dea4b88d8..c7bbb0ee9d 100644 --- a/guardian-service/package.json +++ b/guardian-service/package.json @@ -11,8 +11,8 @@ }, "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.2.1", - "@guardian/interfaces": "^2.2.1", + "@guardian/common": "^2.2.2", + "@guardian/interfaces": "^2.2.2", "@hashgraph/sdk": "^2.15.0", "@transmute/credentials-context": "^0.7.0-unstable.60", "@transmute/did-context": "^0.7.0-unstable.60", @@ -72,5 +72,5 @@ "test:network": "mocha tests/network-tests/**/*.test.js", "test:stability": "mocha tests/stability.test.js" }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/guardian-service/src/policy-engine/blocks/document-validator-block.ts b/guardian-service/src/policy-engine/blocks/document-validator-block.ts index e902cc0170..30054023af 100644 --- a/guardian-service/src/policy-engine/blocks/document-validator-block.ts +++ b/guardian-service/src/policy-engine/blocks/document-validator-block.ts @@ -135,11 +135,13 @@ export class DocumentValidatorBlock { @ActionCallback({ output: [PolicyOutputEventType.RunEvent, PolicyOutputEventType.RefreshEvent] }) + @CatchErrors() async runAction(event: IPolicyEvent) { const ref = PolicyComponentsUtils.GetBlockRef(this); ref.log(`runAction`); - if (!ref.run(event)) { + const valid = await ref.run(event); + if (!valid) { throw new BlockActionError(`Invalid document`, ref.blockType, ref.uuid); } diff --git a/guardian-service/src/policy-engine/blocks/request-vc-document-block.ts b/guardian-service/src/policy-engine/blocks/request-vc-document-block.ts index 243ae5eb09..9e332c6aef 100644 --- a/guardian-service/src/policy-engine/blocks/request-vc-document-block.ts +++ b/guardian-service/src/policy-engine/blocks/request-vc-document-block.ts @@ -147,36 +147,44 @@ export class RequestVcDocumentBlock { } async getRelationships(policyId: string, refId: any): Promise { - if (refId) { - let id: string = null; - let documentRef: any = null; - if (typeof (refId) === 'string') { - documentRef = await getMongoRepository(VcDocumentCollection).findOne({ - where: { - 'policyId': { $eq: policyId }, - 'document.credentialSubject.id': { $eq: id } - } - }); - id = refId; - return documentRef; - } else if (typeof (refId) === 'object') { - if (refId.id) { - documentRef = await getMongoRepository(VcDocumentCollection).findOne(refId.id); - } else { + try { + if (refId) { + let documentRef: any = null; + if (typeof (refId) === 'string') { documentRef = await getMongoRepository(VcDocumentCollection).findOne({ where: { 'policyId': { $eq: policyId }, - 'document.credentialSubject.id': { $eq: id } + 'document.credentialSubject.id': { $eq: refId } } }); + } else if (typeof (refId) === 'object') { + if (refId.id) { + documentRef = await getMongoRepository(VcDocumentCollection).findOne(refId.id); + if (documentRef && documentRef.policyId !== policyId) { + documentRef = null; + } + } else { + const id = PolicyUtils.getSubjectId(documentRef); + documentRef = await getMongoRepository(VcDocumentCollection).findOne({ + where: { + 'policyId': { $eq: policyId }, + 'document.credentialSubject.id': { $eq: id } + } + }); + } + } + if(!documentRef) { + throw new Error('Invalid relationships'); } - id = PolicyUtils.getSubjectId(documentRef); return documentRef; + } else { + return null; } - } else { - return null; + } catch (error) { + const ref = PolicyComponentsUtils.GetBlockRef(this); + ref.error(error.message); + throw new BlockActionError('Invalid relationships', ref.blockType, ref.uuid); } - return null; } @ActionCallback({ diff --git a/guardian-service/src/policy-engine/helpers/utils.ts b/guardian-service/src/policy-engine/helpers/utils.ts index c3c4b6dc5f..55136d0752 100644 --- a/guardian-service/src/policy-engine/helpers/utils.ts +++ b/guardian-service/src/policy-engine/helpers/utils.ts @@ -352,18 +352,18 @@ export class PolicyUtils { } public static checkDocumentSchema(document: any, schema: SchemaCollection): boolean { - const iri = schema.iri; + const iri = schema.iri ? schema.iri.slice(1) : null; const context = schema.contextURL; if (document && document.document) { if (Array.isArray(document.document.credentialSubject)) { return ( - document.document.credentialSubject[0]['@context'].indexOf(context) && - document.document.credentialSubject[0].type == iri + document.document.credentialSubject[0]['@context'].indexOf(context) > -1 && + document.document.credentialSubject[0].type === iri ); } else { return ( - document.document.credentialSubject['@context'].indexOf(context) && - document.document.credentialSubject.type == iri + document.document.credentialSubject['@context'].indexOf(context) > -1 && + document.document.credentialSubject.type === iri ); } } diff --git a/interfaces/package.json b/interfaces/package.json index ce5d0a03c7..3561041577 100644 --- a/interfaces/package.json +++ b/interfaces/package.json @@ -24,5 +24,5 @@ "lint": "tslint --project .", "test": "echo \"Error: no test specified\" && exit 1" }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/ipfs-client/package.json b/ipfs-client/package.json index e3549b82a5..fdbfbd8fdd 100644 --- a/ipfs-client/package.json +++ b/ipfs-client/package.json @@ -4,8 +4,8 @@ }, "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.2.1", - "@guardian/interfaces": "^2.2.1", + "@guardian/common": "^2.2.2", + "@guardian/interfaces": "^2.2.2", "@web-std/fetch": "3.0.0", "axios": "^0.26.1", "axios-retry": "^3.2.4", @@ -46,5 +46,5 @@ "start": "node dist/index.js", "test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ipfs-client.xml" }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/logger-service/package.json b/logger-service/package.json index 5b262396d5..f593d7d0c5 100644 --- a/logger-service/package.json +++ b/logger-service/package.json @@ -2,8 +2,8 @@ "packageManager": "yarn@3.2.1", "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.2.1", - "@guardian/interfaces": "^2.2.1", + "@guardian/common": "^2.2.2", + "@guardian/interfaces": "^2.2.2", "@web-std/fetch": "3.0.0", "cors": "^2.8.5", "dotenv": "^16.0.0", @@ -36,5 +36,5 @@ "lint": "tslint --project .", "start": "node dist/index.js" }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/mrv-sender/package.json b/mrv-sender/package.json index d6635e23c3..411fbb9574 100644 --- a/mrv-sender/package.json +++ b/mrv-sender/package.json @@ -1,7 +1,7 @@ { "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.2.1", + "@guardian/common": "^2.2.2", "@transmute/credentials-context": "0.7.0-unstable.40", "@transmute/did-context": "0.7.0-unstable.40", "@transmute/ed25519-signature-2018": "0.7.0-unstable.40", @@ -29,5 +29,5 @@ "dev:docker": "nodemon .", "start": "node dist/index.js" }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/package.json b/package.json index 680ac84079..6422e27c63 100644 --- a/package.json +++ b/package.json @@ -13,5 +13,5 @@ "logger-service", "mrv-sender" ], - "version": "2.2.1" + "version": "2.2.2" } diff --git a/yarn.lock b/yarn.lock index eb850d2328..07a7c2b9e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -169,11 +169,11 @@ __metadata: languageName: node linkType: hard -"@guardian/common@^2.2.1, @guardian/common@workspace:common": +"@guardian/common@^2.2.2, @guardian/common@workspace:common": version: 0.0.0-use.local resolution: "@guardian/common@workspace:common" dependencies: - "@guardian/interfaces": ^2.2.1 + "@guardian/interfaces": ^2.2.2 "@types/node": ^17.0.13 mocha-junit-reporter: ^2.0.2 nats: ^2.6.1 @@ -184,7 +184,7 @@ __metadata: languageName: unknown linkType: soft -"@guardian/interfaces@^2.2.1, @guardian/interfaces@workspace:interfaces": +"@guardian/interfaces@^2.2.2, @guardian/interfaces@workspace:interfaces": version: 0.0.0-use.local resolution: "@guardian/interfaces@workspace:interfaces" dependencies: @@ -1597,8 +1597,8 @@ __metadata: version: 0.0.0-use.local resolution: "api-gateway@workspace:api-gateway" dependencies: - "@guardian/common": ^2.2.1 - "@guardian/interfaces": ^2.2.1 + "@guardian/common": ^2.2.2 + "@guardian/interfaces": ^2.2.2 "@types/express": ^4.17.13 "@types/jszip": ^3.4.1 "@types/node": ^17.0.13 @@ -1769,8 +1769,8 @@ __metadata: version: 0.0.0-use.local resolution: "auth-service@workspace:auth-service" dependencies: - "@guardian/common": ^2.2.1 - "@guardian/interfaces": ^2.2.1 + "@guardian/common": ^2.2.2 + "@guardian/interfaces": ^2.2.2 "@types/jsonwebtoken": ^8.5.4 "@types/node": ^17.0.13 chai: ^4.3.4 @@ -3957,8 +3957,8 @@ __metadata: version: 0.0.0-use.local resolution: "guardian-service@workspace:guardian-service" dependencies: - "@guardian/common": ^2.2.1 - "@guardian/interfaces": ^2.2.1 + "@guardian/common": ^2.2.2 + "@guardian/interfaces": ^2.2.2 "@hashgraph/sdk": ^2.15.0 "@transmute/credentials-context": ^0.7.0-unstable.60 "@transmute/did-context": ^0.7.0-unstable.60 @@ -4527,8 +4527,8 @@ __metadata: version: 0.0.0-use.local resolution: "ipfs-client@workspace:ipfs-client" dependencies: - "@guardian/common": ^2.2.1 - "@guardian/interfaces": ^2.2.1 + "@guardian/common": ^2.2.2 + "@guardian/interfaces": ^2.2.2 "@types/fs-extra": ^9.0.12 "@types/js-yaml": ^4.0.3 "@types/node": ^17.0.13 @@ -5611,8 +5611,8 @@ __metadata: version: 0.0.0-use.local resolution: "logger-service@workspace:logger-service" dependencies: - "@guardian/common": ^2.2.1 - "@guardian/interfaces": ^2.2.1 + "@guardian/common": ^2.2.2 + "@guardian/interfaces": ^2.2.2 "@types/fs-extra": ^9.0.12 "@types/node": ^17.0.13 "@web-std/fetch": 3.0.0 @@ -6144,7 +6144,7 @@ __metadata: version: 0.0.0-use.local resolution: "mrv-sender@workspace:mrv-sender" dependencies: - "@guardian/common": ^2.2.1 + "@guardian/common": ^2.2.2 "@transmute/credentials-context": 0.7.0-unstable.40 "@transmute/did-context": 0.7.0-unstable.40 "@transmute/ed25519-signature-2018": 0.7.0-unstable.40