From 501d12d4751070349bf87b5f8db76c6969c5f0ec Mon Sep 17 00:00:00 2001 From: Berend Sliedrecht <berend@animo.id> Date: Mon, 29 Jan 2024 13:08:26 +0100 Subject: [PATCH] fix: resolved merge issues Signed-off-by: Berend Sliedrecht <berend@animo.id> --- .../src/agent/agent.service.ts | 1 + .../anoncredsCredentials.controller.ts | 24 ++++++++ .../credentialDefinitions.controller.spec.ts | 1 + .../__tests__/revocation.controller.spec.ts | 5 ++ .../agent/revocation/revocation.service.ts | 19 +----- .../src/agent/withTenantService.ts | 6 +- .../test/anoncredsCredentials.e2e-spec.ts | 5 +- .../test/anoncredsProofs.e2e-spec.ts | 2 +- .../test/credentialDefinitions.e2e-spec.ts | 5 +- apps/ssi-abstraction/test/dids.e2e-spec.ts | 2 +- apps/ssi-abstraction/test/schemas.e2e-spec.ts | 2 +- pnpm-lock.yaml | 59 +++++-------------- 12 files changed, 59 insertions(+), 72 deletions(-) diff --git a/apps/ssi-abstraction/src/agent/agent.service.ts b/apps/ssi-abstraction/src/agent/agent.service.ts index 6e8980a..a0db4d9 100644 --- a/apps/ssi-abstraction/src/agent/agent.service.ts +++ b/apps/ssi-abstraction/src/agent/agent.service.ts @@ -49,6 +49,7 @@ import { LEDGERS } from '../config/ledger.js'; import { AgentLogger } from './logger.js'; +export type TenantAgent = Agent<Omit<AgentService['modules'], 'tenants'>>; export type AppAgent = Agent<AgentService['modules']>; @Injectable() diff --git a/apps/ssi-abstraction/src/agent/anoncredsCredentials/anoncredsCredentials.controller.ts b/apps/ssi-abstraction/src/agent/anoncredsCredentials/anoncredsCredentials.controller.ts index 29f8a2b..b4a7841 100644 --- a/apps/ssi-abstraction/src/agent/anoncredsCredentials/anoncredsCredentials.controller.ts +++ b/apps/ssi-abstraction/src/agent/anoncredsCredentials/anoncredsCredentials.controller.ts @@ -1,8 +1,12 @@ import { Controller } from '@nestjs/common'; import { MessagePattern } from '@nestjs/microservices'; import { + EventAnonCredsCredentialOfferGetAll, + EventAnonCredsCredentialOfferGetAllInput, EventAnonCredsCredentialOfferGetById, EventAnonCredsCredentialOfferGetByIdInput, + EventAnonCredsCredentialRequestGetAll, + EventAnonCredsCredentialRequestGetAllInput, EventAnonCredsCredentialRequestGetById, EventAnonCredsCredentialRequestGetByIdInput, EventAnonCredsCredentialsDeleteById, @@ -33,6 +37,26 @@ export class AnonCredsCredentialsController { ); } + @MessagePattern(EventAnonCredsCredentialOfferGetAll.token) + public async getAllOffers( + options: EventAnonCredsCredentialOfferGetAllInput, + ): Promise<EventAnonCredsCredentialOfferGetAll> { + return new EventAnonCredsCredentialOfferGetAll( + await this.credentialsService.getAllOffers(options), + options.tenantId, + ); + } + + @MessagePattern(EventAnonCredsCredentialRequestGetAll.token) + public async getAllRequests( + options: EventAnonCredsCredentialRequestGetAllInput, + ): Promise<EventAnonCredsCredentialRequestGetAll> { + return new EventAnonCredsCredentialRequestGetAll( + await this.credentialsService.getAllRequests(options), + options.tenantId, + ); + } + @MessagePattern(EventAnonCredsCredentialsGetById.token) public async getById( options: EventAnonCredsCredentialsGetByIdInput, diff --git a/apps/ssi-abstraction/src/agent/credentialDefinitions/__tests__/credentialDefinitions.controller.spec.ts b/apps/ssi-abstraction/src/agent/credentialDefinitions/__tests__/credentialDefinitions.controller.spec.ts index 42e0674..b122c2b 100644 --- a/apps/ssi-abstraction/src/agent/credentialDefinitions/__tests__/credentialDefinitions.controller.spec.ts +++ b/apps/ssi-abstraction/src/agent/credentialDefinitions/__tests__/credentialDefinitions.controller.spec.ts @@ -75,6 +75,7 @@ describe('CredentialDefinitionsController', () => { .mockResolvedValue(result); const event = await credentialDefinitionsController.register({ + supportsRevocation: false, tenantId: 'some-tenant-id', tag: 'some-tag', issuerDid: 'did:indy:issuer', diff --git a/apps/ssi-abstraction/src/agent/revocation/__tests__/revocation.controller.spec.ts b/apps/ssi-abstraction/src/agent/revocation/__tests__/revocation.controller.spec.ts index 885868e..e5ea1ad 100644 --- a/apps/ssi-abstraction/src/agent/revocation/__tests__/revocation.controller.spec.ts +++ b/apps/ssi-abstraction/src/agent/revocation/__tests__/revocation.controller.spec.ts @@ -43,6 +43,10 @@ describe('RevocationController', () => { const event = await revocationController.registerRevocationRegistryDefinition({ + tag: 'rev_tag', + issuerDid: 'did:me', + credentialDefinitionId: 'some:cred:id', + maximumCredentialNumber: 100, tenantId: 'some-id', }); @@ -61,6 +65,7 @@ describe('RevocationController', () => { const event = await revocationController.registerRevocationStatusList({ tenantId: 'some-id', revocationRegistryDefinitionId: 'some-fake-id', + issuerDid: 'did:me', }); expect(event.data).toStrictEqual(result); diff --git a/apps/ssi-abstraction/src/agent/revocation/revocation.service.ts b/apps/ssi-abstraction/src/agent/revocation/revocation.service.ts index 26506a7..df4dedf 100644 --- a/apps/ssi-abstraction/src/agent/revocation/revocation.service.ts +++ b/apps/ssi-abstraction/src/agent/revocation/revocation.service.ts @@ -62,7 +62,7 @@ export class RevocationService { ); } - const timestamp = new Date().getTime() / 1000; + const timestamp = Math.floor(Date.now() / 1000); const { revocationStatusList } = await t.modules.anoncreds.getRevocationStatusList( metadata.revocationRegistryId, @@ -85,24 +85,9 @@ export class RevocationService { ); } - const newRevokedIndices = revocationStatusList.revocationList - .filter( - (state, idx) => - state === 1 || idx === Number(metadata.credentialRevocationId), - ) - .map((_, idx) => idx); - - const newIssuedIndices = revocationStatusList.revocationList - .filter( - (state, idx) => - state === 0 && idx !== Number(metadata.credentialRevocationId), - ) - .map((_, idx) => idx); - const result = await t.modules.anoncreds.updateRevocationStatusList({ revocationRegistryDefinitionId: metadata.revocationRegistryId, - revokedCredentialIndexes: newRevokedIndices, - issuedCredentialIndexes: newIssuedIndices, + revokedCredentialIndexes: [Number(metadata.credentialRevocationId)], }); if (result.revocationStatusListState.state !== 'finished') { diff --git a/apps/ssi-abstraction/src/agent/withTenantService.ts b/apps/ssi-abstraction/src/agent/withTenantService.ts index eacdb08..15b806a 100644 --- a/apps/ssi-abstraction/src/agent/withTenantService.ts +++ b/apps/ssi-abstraction/src/agent/withTenantService.ts @@ -1,4 +1,4 @@ -import type { AppAgent } from './agent.service.js'; +import type { AppAgent, TenantAgent } from './agent.service.js'; import { Injectable } from '@nestjs/common'; @@ -14,7 +14,7 @@ export class WithTenantService { public invoke<T>( tenantId: string, - cb: (tenant: AppAgent) => Promise<T>, + cb: (tenant: TenantAgent) => Promise<T>, ): Promise<T> { // eslint-disable-next-line no-async-promise-executor return new Promise<T>(async (resolve, reject) => { @@ -22,7 +22,7 @@ export class WithTenantService { { tenantId }, async (tenant) => { try { - const ret = await cb(tenant as unknown as AppAgent); + const ret = await cb(tenant as unknown as TenantAgent); resolve(ret); } catch (e) { reject(e); diff --git a/apps/ssi-abstraction/test/anoncredsCredentials.e2e-spec.ts b/apps/ssi-abstraction/test/anoncredsCredentials.e2e-spec.ts index 4751814..0a9a071 100644 --- a/apps/ssi-abstraction/test/anoncredsCredentials.e2e-spec.ts +++ b/apps/ssi-abstraction/test/anoncredsCredentials.e2e-spec.ts @@ -94,17 +94,18 @@ describe('Credentials', () => { issuerDid, tenantId, name: 'test-schema-name', - version: `1.${new Date().getTime()}`, + version: `1.${Date.now()}`, attributeNames: ['Name', 'Age'], }); const credentialDefinitionService = app.get(CredentialDefinitionsService); const { credentialDefinitionId: cdi } = await credentialDefinitionService.register({ + supportsRevocation: false, tenantId, issuerDid, schemaId, - tag: `default-${new Date().getTime()}`, + tag: `default-${Date.now()}`, }); credentialDefinitionId = cdi; diff --git a/apps/ssi-abstraction/test/anoncredsProofs.e2e-spec.ts b/apps/ssi-abstraction/test/anoncredsProofs.e2e-spec.ts index e1a66bb..fc43d34 100644 --- a/apps/ssi-abstraction/test/anoncredsProofs.e2e-spec.ts +++ b/apps/ssi-abstraction/test/anoncredsProofs.e2e-spec.ts @@ -58,7 +58,7 @@ describe('Proofs', () => { await client.connect(); const tenantsService = app.get(TenantsService); - const { id: tId } = await tenantsService.create(TOKEN); + const { id: tId } = await tenantsService.create({ label: TOKEN }); tenantId = tId; const connectionsService = app.get(ConnectionsService); diff --git a/apps/ssi-abstraction/test/credentialDefinitions.e2e-spec.ts b/apps/ssi-abstraction/test/credentialDefinitions.e2e-spec.ts index 05e68cf..2fd3591 100644 --- a/apps/ssi-abstraction/test/credentialDefinitions.e2e-spec.ts +++ b/apps/ssi-abstraction/test/credentialDefinitions.e2e-spec.ts @@ -73,7 +73,7 @@ describe('CredentialDefinitions', () => { issuerDid, tenantId, name: 'test-schema-name', - version: `1.${new Date().getTime()}`, + version: `1.${Date.now()}`, attributeNames: ['none'], }); schemaId = sid; @@ -112,11 +112,12 @@ describe('CredentialDefinitions', () => { }); it(EventAnonCredsCredentialDefinitionsRegister.token, async () => { - const tag = `tag:${new Date().getTime()}`; + const tag = `tag:${Date.now()}`; const response$ = client.send< EventAnonCredsCredentialDefinitionsRegister, EventAnonCredsCredentialDefinitionsRegisterInput >(EventAnonCredsCredentialDefinitionsRegister.token, { + supportsRevocation: false, tenantId, schemaId, issuerDid, diff --git a/apps/ssi-abstraction/test/dids.e2e-spec.ts b/apps/ssi-abstraction/test/dids.e2e-spec.ts index fc11291..785a8e7 100644 --- a/apps/ssi-abstraction/test/dids.e2e-spec.ts +++ b/apps/ssi-abstraction/test/dids.e2e-spec.ts @@ -89,7 +89,7 @@ describe('Dids', () => { EventDidsDidConfigurationInput >(EventDidsDidConfiguration.token, { domain: 'https://example.org', - expiryTime: new Date().getTime() / 1000 + 3600, + expiryTime: Date.now() / 1000 + 3600, tenantId, }); diff --git a/apps/ssi-abstraction/test/schemas.e2e-spec.ts b/apps/ssi-abstraction/test/schemas.e2e-spec.ts index d2ce541..abab76b 100644 --- a/apps/ssi-abstraction/test/schemas.e2e-spec.ts +++ b/apps/ssi-abstraction/test/schemas.e2e-spec.ts @@ -92,7 +92,7 @@ describe('Schemas', () => { }); it(EventAnonCredsSchemasRegister.token, async () => { - const version = `1.${new Date().getTime()}`; + const version = `1.${Date.now()}`; const attributeNames = ['names', 'age']; const name = 'my-schema'; const response$ = client.send< diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2ec7d81..f08918a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -453,9 +453,14 @@ importers: specifier: 0.5.0-alpha.87 version: 0.5.0-alpha.87(expo@49.0.21)(react-native@0.73.2) '@aries-framework/tenants': +<<<<<<< HEAD specifier: ^0.5.0-alpha.87 version: 0.5.0-alpha.91(expo@49.0.21)(react-native@0.73.2) >>>>>>> b235c33 (chore(ssi): update AFJ to latest alpha release) +======= + specifier: 0.5.0-alpha.87 + version: 0.5.0-alpha.87(expo@49.0.21)(react-native@0.73.2) +>>>>>>> 63efb70 (fix: resolved merge issues) '@elastic/ecs-winston-format': specifier: ^1.5.0 version: 1.5.2 @@ -577,9 +582,14 @@ importers: specifier: 0.5.0-alpha.87 version: 0.5.0-alpha.87(expo@49.0.21)(react-native@0.73.2) '@aries-framework/tenants': +<<<<<<< HEAD specifier: ^0.5.0-alpha.87 version: 0.5.0-alpha.91(expo@49.0.21)(react-native@0.73.2) >>>>>>> b235c33 (chore(ssi): update AFJ to latest alpha release) +======= + specifier: 0.5.0-alpha.87 + version: 0.5.0-alpha.87(expo@49.0.21)(react-native@0.73.2) +>>>>>>> 63efb70 (fix: resolved merge issues) '@elastic/ecs-winston-format': specifier: ^1.5.0 version: 1.5.2 @@ -892,47 +902,6 @@ packages: - web-streams-polyfill dev: false - /@aries-framework/core@0.5.0-alpha.91(expo@49.0.21)(react-native@0.73.2): - resolution: {integrity: sha512-CHb1J2oLfM2FSc323B2oL1Jm2uUfCrYx0JdyP5mR8AJlZQggFtzwNhe1kaEVj/IX8x5em/LC4s8zEEvsWb+NOA==} - dependencies: - '@digitalcredentials/jsonld': 5.2.2(expo@49.0.21)(react-native@0.73.2) - '@digitalcredentials/jsonld-signatures': 9.3.2(expo@49.0.21)(react-native@0.73.2) - '@digitalcredentials/vc': 1.1.2(expo@49.0.21)(react-native@0.73.2) - '@multiformats/base-x': 4.0.1 - '@sphereon/pex': 2.2.2 - '@sphereon/pex-models': 2.1.5 - '@sphereon/ssi-types': 0.17.5 - '@stablelib/ed25519': 1.0.3 - '@stablelib/random': 1.0.2 - '@stablelib/sha256': 1.0.1 - '@types/ws': 8.5.10 - abort-controller: 3.0.0 - big-integer: 1.6.52 - borc: 3.0.0 - buffer: 6.0.3 - class-transformer: 0.5.1 - class-validator: 0.14.0 - did-resolver: 4.1.0 - jsonpath: 1.1.1 - lru_map: 0.4.1 - luxon: 3.4.4 - make-error: 1.3.6 - object-inspect: 1.13.1 - query-string: 7.1.3 - reflect-metadata: 0.1.14 - rxjs: 7.8.1 - tsyringe: 4.8.0 - uuid: 9.0.1 - varint: 6.0.0 - web-did-resolver: 2.0.27 - transitivePeerDependencies: - - domexception - - encoding - - expo - - react-native - - web-streams-polyfill - dev: false - /@aries-framework/indy-vdr@0.5.0-alpha.87(@hyperledger/indy-vdr-shared@0.2.0-dev.6)(expo@49.0.21)(react-native@0.73.2): resolution: {integrity: sha512-rj3hqrq2MggqKp8P06edyTXWINKrtcXpFSFd4jG8Ttr5ObR9vdya0G7EdFT7tKHtGkqD8/qbyDF2D7woZMFEkg==} peerDependencies: @@ -969,10 +938,10 @@ packages: - web-streams-polyfill dev: false - /@aries-framework/tenants@0.5.0-alpha.91(expo@49.0.21)(react-native@0.73.2): - resolution: {integrity: sha512-ezAn+6J8AqL/hXiks6ZXbMznJf8PnXcGbQ1IwFzOqaEeZHDxW4PNa4dMlccg/rcbOTVEZW8SG672gMFYtMkwpw==} + /@aries-framework/tenants@0.5.0-alpha.87(expo@49.0.21)(react-native@0.73.2): + resolution: {integrity: sha512-txx2hZjQ5lpcS+vbfaw9ZTNF+SA1DfYuLmGwjdVMNUmMxlCr8siks4MV1h194dGecC53w44Ab+H6AozvRDktog==} dependencies: - '@aries-framework/core': 0.5.0-alpha.91(expo@49.0.21)(react-native@0.73.2) + '@aries-framework/core': 0.5.0-alpha.87(expo@49.0.21)(react-native@0.73.2) async-mutex: 0.4.0 transitivePeerDependencies: - domexception @@ -4615,7 +4584,7 @@ packages: dependencies: '@nestjs/axios': 3.0.1(@nestjs/common@10.3.0)(axios@1.6.5)(reflect-metadata@0.1.14)(rxjs@7.8.1) '@nestjs/common': 10.3.0(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.1.14)(rxjs@7.8.1) - '@nestjs/core': 10.3.0(@nestjs/common@10.3.0)(@nestjs/microservices@10.3.0)(reflect-metadata@0.1.14)(rxjs@7.8.1) + '@nestjs/core': 10.3.0(@nestjs/common@10.3.0)(@nestjs/microservices@10.3.0)(@nestjs/platform-express@10.3.0)(reflect-metadata@0.1.14)(rxjs@7.8.1) '@nestjs/microservices': 10.3.0(@nestjs/common@10.3.0)(@nestjs/core@10.3.0)(nats@2.19.0)(reflect-metadata@0.1.14)(rxjs@7.8.1) boxen: 5.1.2 check-disk-space: 3.4.0 -- GitLab