diff --git a/apps/shared/src/events/credentialDefinitionEvents.ts b/apps/shared/src/events/credentialDefinitionEvents.ts index c6081cc9cb0452f148e0c7805e179bfc67074e1d..2526043ef04d5209ba6acb33ac2cc30e32eba0df 100644 --- a/apps/shared/src/events/credentialDefinitionEvents.ts +++ b/apps/shared/src/events/credentialDefinitionEvents.ts @@ -3,13 +3,14 @@ import type { AnonCredsCredentialDefinition } from '@credo-ts/anoncreds'; import { BaseEvent } from './baseEvents.js'; -export type CredentialDefinitionWithId = AnonCredsCredentialDefinition & { - credentialDefinitionId: string; -}; +export type AnonCredsCredentialDefinitionWithId = + AnonCredsCredentialDefinition & { + credentialDefinitionId: string; + }; export type EventAnonCredsCredentialDefinitionsGetAllInput = BaseEventInput; export class EventAnonCredsCredentialDefinitionsGetAll extends BaseEvent< - Array<CredentialDefinitionWithId> + Array<AnonCredsCredentialDefinition> > { public static token = 'anoncreds.credentialDefinitions.getAll'; @@ -31,7 +32,7 @@ export class EventAnonCredsCredentialDefinitionsGetAll extends BaseEvent< export type EventAnonCredsCredentialDefinitionsGetByIdInput = BaseEventInput<{ credentialDefinitionId: string; }>; -export class EventAnonCredsCredentialDefinitionsGetById extends BaseEvent<CredentialDefinitionWithId | null> { +export class EventAnonCredsCredentialDefinitionsGetById extends BaseEvent<AnonCredsCredentialDefinitionWithId | null> { public static token = 'anoncreds.credentialDefinitions.getById'; public get instance() { @@ -55,7 +56,7 @@ export type EventAnonCredsCredentialDefinitionsRegisterInput = BaseEventInput<{ issuerDid: string; }>; -export class EventAnonCredsCredentialDefinitionsRegister extends BaseEvent<CredentialDefinitionWithId> { +export class EventAnonCredsCredentialDefinitionsRegister extends BaseEvent<AnonCredsCredentialDefinitionWithId> { public static token = 'anoncreds.credentialDefinitions.register'; public get instance() { diff --git a/apps/shared/src/events/revocationEvents.ts b/apps/shared/src/events/revocationEvents.ts new file mode 100644 index 0000000000000000000000000000000000000000..4265a34c4166478b62e0d9f7aa022d67ea8282e4 --- /dev/null +++ b/apps/shared/src/events/revocationEvents.ts @@ -0,0 +1,73 @@ +import type { BaseEventInput } from './baseEvents.js'; + +import { BaseEvent } from './baseEvents.js'; + +export type EventAnonCredsRevocationRevokeInput = BaseEventInput<{ + credentialId: string; +}>; +export class EventAnonCredsRevocationRevoke extends BaseEvent { + public static token = 'anoncreds.revocation.revoke'; + + public get instance() { + return null; + } + + public static fromEvent(e: EventAnonCredsRevocationRevoke) { + return new EventAnonCredsRevocationRevoke( + e.data, + e.tenantId, + e.id, + e.type, + e.timestamp, + ); + } +} + +// TODO: input type available in the new AFJ +export type EventAnonCredsRevocationRegisterRevocationRegistryDefinitionInput = + BaseEventInput; +export class EventAnonCredsRevocationRegisterRevocationRegistryDefinition extends BaseEvent<{ + revocationRegistryDefinitionId: string; +}> { + public static token = + 'anoncreds.revocation.registerRevocationRegistryDefinition'; + + public get instance() { + return this.data; + } + + public static fromEvent( + e: EventAnonCredsRevocationRegisterRevocationRegistryDefinition, + ) { + return new EventAnonCredsRevocationRegisterRevocationRegistryDefinition( + e.data, + e.tenantId, + e.id, + e.type, + e.timestamp, + ); + } +} + +// TODO: input type available in the new AFJ +export type EventAnonCredsRevocationRegisterRevocationStatusListInput = + BaseEventInput<{ revocationRegistryDefinitionId: string }>; +export class EventAnonCredsRevocationRegisterRevocationStatusList extends BaseEvent { + public static token = 'anoncreds.revocation.registerRevocationStatusList'; + + public get instance() { + return this.data; + } + + public static fromEvent( + e: EventAnonCredsRevocationRegisterRevocationStatusList, + ) { + return new EventAnonCredsRevocationRegisterRevocationStatusList( + e.data, + e.tenantId, + e.id, + e.type, + e.timestamp, + ); + } +} diff --git a/apps/shared/src/events/schemaEvents.ts b/apps/shared/src/events/schemaEvents.ts index 06d0089914250457f9f51643093389d089f25bb5..f057b7f84a342ddb7bbe86fe492728058f29ff0d 100644 --- a/apps/shared/src/events/schemaEvents.ts +++ b/apps/shared/src/events/schemaEvents.ts @@ -3,6 +3,10 @@ import type { AnonCredsSchema } from '@credo-ts/anoncreds'; import { BaseEvent } from './baseEvents.js'; +export type AnonCredsSchemaWithId = AnonCredsSchema & { + schemaId: string; +}; + export type EventAnonCredsSchemasGetAllInput = BaseEventInput; export class EventAnonCredsSchemasGetAll extends BaseEvent< Array<AnonCredsSchema> @@ -51,7 +55,7 @@ export type EventAnonCredsSchemasRegisterInput = BaseEventInput<{ version: string; attributeNames: Array<string>; }>; -export class EventAnonCredsSchemasRegister extends BaseEvent<AnonCredsSchema> { +export class EventAnonCredsSchemasRegister extends BaseEvent<AnonCredsSchemaWithId> { public static token = 'anoncreds.schemas.register'; public get instance() { diff --git a/apps/shared/src/index.ts b/apps/shared/src/index.ts index 36edf136298f8c16bbcaea2801132030521a0951..541830c07d40fdeaac5a81d2599f6f746ba8ed04 100644 --- a/apps/shared/src/index.ts +++ b/apps/shared/src/index.ts @@ -13,6 +13,7 @@ export * from './events/credentialEvents.js'; export * from './events/credentialOfferEvents.js'; export * from './events/credentialRequestEvents.js'; export * from './events/proofEvents.js'; +export * from './events/revocationEvents.js'; export * from './dto/pagination-params.dto.js'; export * from './dto/multitenancy-params.dto.js'; diff --git a/apps/ssi-abstraction/jest.config.js b/apps/ssi-abstraction/jest.config.js index b8e668f1276a964bf64564fc37c8a688e45a9a41..f305cf2e1105561c3342c6e270daf66b79d905d3 100644 --- a/apps/ssi-abstraction/jest.config.js +++ b/apps/ssi-abstraction/jest.config.js @@ -4,6 +4,7 @@ const swcConfig = JSON.parse(readFileSync('../../.swcrc', 'utf8')); /** @type {import('jest').Config} */ export default { + testPathIgnorePatterns: ['dist'], moduleFileExtensions: ['js', 'ts'], testEnvironment: 'node', transform: { diff --git a/apps/ssi-abstraction/src/agent/agent.service.ts b/apps/ssi-abstraction/src/agent/agent.service.ts index 736032bd0226b163397fbf0a0484f71600374801..6e8980a2f103b534d203ed3faf2145fe1c754d07 100644 --- a/apps/ssi-abstraction/src/agent/agent.service.ts +++ b/apps/ssi-abstraction/src/agent/agent.service.ts @@ -194,6 +194,8 @@ export class AgentService implements OnApplicationShutdown { try { await this.agent.shutdown(); // eslint-disable-next-line no-empty - } catch {} + } catch (e) { + logger.warn(`Agent shutdown issue occurred. Cause: ${e}`); + } } } diff --git a/apps/ssi-abstraction/src/agent/connections/connections.service.ts b/apps/ssi-abstraction/src/agent/connections/connections.service.ts index 4b5f9863d619b6cec16778f25c22623113ee5a96..73ae244bacfe0350b23496fe00e82c0c1c2cc533 100644 --- a/apps/ssi-abstraction/src/agent/connections/connections.service.ts +++ b/apps/ssi-abstraction/src/agent/connections/connections.service.ts @@ -4,10 +4,13 @@ import type { ConnectionStateChangedEvent, } from '@credo-ts/core'; import type { + EventDidcommConnectionsBlock, EventDidcommConnectionsBlockInput, EventDidcommConnectionsCreateInvitationInput, + EventDidcommConnectionsCreateWithSelf, EventDidcommConnectionsCreateWithSelfInput, EventDidcommConnectionsGetAllInput, + EventDidcommConnectionsGetById, EventDidcommConnectionsGetByIdInput, EventDidcommConnectionsReceiveInvitationFromUrlInput, } from '@ocm/shared'; @@ -48,7 +51,9 @@ export class ConnectionsService { public async getById({ tenantId, id, - }: EventDidcommConnectionsGetByIdInput): Promise<ConnectionRecord | null> { + }: EventDidcommConnectionsGetByIdInput): Promise< + EventDidcommConnectionsGetById['data'] + > { return this.withTenantService.invoke(tenantId, (t) => t.connections.findById(id), ); @@ -57,7 +62,9 @@ export class ConnectionsService { public async blockByIdOrDid({ tenantId, idOrDid, - }: EventDidcommConnectionsBlockInput): Promise<ConnectionRecord | null> { + }: EventDidcommConnectionsBlockInput): Promise< + EventDidcommConnectionsBlock['data'] + > { return this.withTenantService.invoke(tenantId, async (t) => { if (isDid(idOrDid)) { const records = await t.connections.findAllByQuery({ @@ -131,7 +138,9 @@ export class ConnectionsService { public async createConnectionWithSelf({ tenantId, - }: EventDidcommConnectionsCreateWithSelfInput): Promise<ConnectionRecord> { + }: EventDidcommConnectionsCreateWithSelfInput): Promise< + EventDidcommConnectionsCreateWithSelf['data'] + > { return this.withTenantService.invoke(tenantId, async (t) => { const outOfBandRecord = await t.oob.createInvitation(); const invitation = outOfBandRecord.outOfBandInvitation; 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 df3e04e8091b853e9527acabe181b8f1654440d7..42e0674ee28643cb67e9b575df5be3dd3b9a6065 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 @@ -57,7 +57,9 @@ describe('CredentialDefinitionsController', () => { describe('register credentialDefinition', () => { it('should register a credentialDefinition on a ledger', async () => { - const result: AnonCredsCredentialDefinition = { + const result: AnonCredsCredentialDefinition & { + credentialDefinitionId: string; + } = { tag: 'some-tag', type: 'CL', issuerId: 'did:indy:issuer', @@ -65,6 +67,7 @@ describe('CredentialDefinitionsController', () => { value: { primary: {}, }, + credentialDefinitionId: 'some-id', }; jest diff --git a/apps/ssi-abstraction/src/agent/credentialDefinitions/credentialDefinitions.service.ts b/apps/ssi-abstraction/src/agent/credentialDefinitions/credentialDefinitions.service.ts index 5478186eab432d17e7fe26772f678556014d09d4..5090e19284e37bc7d0f343e411918d3b1d85bfee 100644 --- a/apps/ssi-abstraction/src/agent/credentialDefinitions/credentialDefinitions.service.ts +++ b/apps/ssi-abstraction/src/agent/credentialDefinitions/credentialDefinitions.service.ts @@ -1,8 +1,10 @@ import type { IndyVdrRegisterCredentialDefinitionOptions } from '@credo-ts/indy-vdr'; import type { - CredentialDefinitionWithId, + EventAnonCredsCredentialDefinitionsGetAll, EventAnonCredsCredentialDefinitionsGetAllInput, + EventAnonCredsCredentialDefinitionsGetById, EventAnonCredsCredentialDefinitionsGetByIdInput, + EventAnonCredsCredentialDefinitionsRegister, EventAnonCredsCredentialDefinitionsRegisterInput, } from '@ocm/shared'; @@ -17,7 +19,7 @@ export class CredentialDefinitionsService { public async getAll({ tenantId, }: EventAnonCredsCredentialDefinitionsGetAllInput): Promise< - Array<CredentialDefinitionWithId> + EventAnonCredsCredentialDefinitionsGetAll['data'] > { return this.withTenantService.invoke(tenantId, async (t) => (await t.modules.anoncreds.getCreatedCredentialDefinitions({})).map( @@ -32,7 +34,9 @@ export class CredentialDefinitionsService { public async getById({ tenantId, credentialDefinitionId, - }: EventAnonCredsCredentialDefinitionsGetByIdInput): Promise<CredentialDefinitionWithId | null> { + }: EventAnonCredsCredentialDefinitionsGetByIdInput): Promise< + EventAnonCredsCredentialDefinitionsGetById['data'] + > { return this.withTenantService.invoke(tenantId, async (t) => { const { credentialDefinition } = await t.modules.anoncreds.getCredentialDefinition( @@ -49,7 +53,9 @@ export class CredentialDefinitionsService { schemaId, issuerDid, tag, - }: EventAnonCredsCredentialDefinitionsRegisterInput): Promise<CredentialDefinitionWithId> { + }: EventAnonCredsCredentialDefinitionsRegisterInput): Promise< + EventAnonCredsCredentialDefinitionsRegister['data'] + > { return this.withTenantService.invoke(tenantId, async (t) => { const { credentialDefinitionState } = await t.modules.anoncreds.registerCredentialDefinition<IndyVdrRegisterCredentialDefinitionOptions>( diff --git a/apps/ssi-abstraction/src/agent/dids/dids.service.ts b/apps/ssi-abstraction/src/agent/dids/dids.service.ts index ddabd17ed58afe6f1e023075f1232a3a8d697732..7a2cb508c24710ba844269174f668c9a943026c0 100644 --- a/apps/ssi-abstraction/src/agent/dids/dids.service.ts +++ b/apps/ssi-abstraction/src/agent/dids/dids.service.ts @@ -4,12 +4,12 @@ import type { IndyVdrDidCreateResult, } from '@credo-ts/indy-vdr'; import type { - EventDidsRegisterIndyFromSeed, EventDidsRegisterIndyFromSeedInput, - EventDidsResolve, DidConfiguration, EventDidsDidConfiguration, EventDidsDidConfigurationInput, + EventDidsRegisterIndyFromSeed, + EventDidsResolve, EventDidsResolveInput, } from '@ocm/shared'; 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 new file mode 100644 index 0000000000000000000000000000000000000000..885868e31ac9bc5319908a96b7f3a018b2cdab5c --- /dev/null +++ b/apps/ssi-abstraction/src/agent/revocation/__tests__/revocation.controller.spec.ts @@ -0,0 +1,69 @@ +import { Test } from '@nestjs/testing'; + +import { mockConfigModule } from '../../../config/__tests__/mockConfig.js'; +import { AgentModule } from '../../agent.module.js'; +import { RevocationController } from '../revocation.controller.js'; +import { RevocationService } from '../revocation.service.js'; + +describe('RevocationController', () => { + let revocationController: RevocationController; + let revocationService: RevocationService; + + beforeEach(async () => { + const moduleRef = await Test.createTestingModule({ + imports: [mockConfigModule(), AgentModule], + controllers: [RevocationController], + providers: [RevocationService], + }).compile(); + + revocationService = moduleRef.get(RevocationService); + revocationController = moduleRef.get(RevocationController); + }); + + describe('revoke', () => { + it('should revoke a credential by id', async () => { + const result = {}; + jest.spyOn(revocationService, 'revoke').mockResolvedValue(result); + + const event = await revocationController.revoke({ + tenantId: 'some-id', + credentialId: 'some-fake-id', + }); + + expect(event.data).toStrictEqual(result); + }); + }); + + describe('register revocation registry definition', () => { + it('should register a revocation registry definition', async () => { + const result = { revocationRegistryDefinitionId: 'some-id' }; + jest + .spyOn(revocationService, 'registerRevocationRegistryDefinition') + .mockResolvedValue(result); + + const event = + await revocationController.registerRevocationRegistryDefinition({ + tenantId: 'some-id', + }); + + expect(event.data).toStrictEqual(result); + }); + }); + + describe('register revocation status list', () => { + it('should register a revocation status list', async () => { + const result = {}; + + jest + .spyOn(revocationService, 'registerRevocationStatusList') + .mockResolvedValue(result); + + const event = await revocationController.registerRevocationStatusList({ + tenantId: 'some-id', + revocationRegistryDefinitionId: 'some-fake-id', + }); + + expect(event.data).toStrictEqual(result); + }); + }); +}); diff --git a/apps/ssi-abstraction/src/agent/revocation/revocation.controller.ts b/apps/ssi-abstraction/src/agent/revocation/revocation.controller.ts new file mode 100644 index 0000000000000000000000000000000000000000..87c1624d88f20d5a81468ca82ca6d6206d012d57 --- /dev/null +++ b/apps/ssi-abstraction/src/agent/revocation/revocation.controller.ts @@ -0,0 +1,53 @@ +import { Controller } from '@nestjs/common'; +import { MessagePattern } from '@nestjs/microservices'; +import { + EventAnonCredsRevocationRegisterRevocationRegistryDefinition, + EventAnonCredsRevocationRegisterRevocationRegistryDefinitionInput, + EventAnonCredsRevocationRegisterRevocationStatusList, + EventAnonCredsRevocationRegisterRevocationStatusListInput, + EventAnonCredsRevocationRevoke, + EventAnonCredsRevocationRevokeInput, +} from '@ocm/shared'; + +import { RevocationService } from './revocation.service.js'; + +@Controller('revocation') +export class RevocationController { + public constructor(private revocationService: RevocationService) {} + + @MessagePattern(EventAnonCredsRevocationRevoke.token) + public async revoke( + options: EventAnonCredsRevocationRevokeInput, + ): Promise<EventAnonCredsRevocationRevoke> { + return new EventAnonCredsRevocationRevoke( + await this.revocationService.revoke(options), + options.tenantId, + ); + } + + @MessagePattern( + EventAnonCredsRevocationRegisterRevocationRegistryDefinition.token, + ) + public async registerRevocationRegistryDefinition( + options: EventAnonCredsRevocationRegisterRevocationRegistryDefinitionInput, + ): Promise<EventAnonCredsRevocationRegisterRevocationRegistryDefinition> { + return new EventAnonCredsRevocationRegisterRevocationRegistryDefinition( + await this.revocationService.registerRevocationRegistryDefinition( + options, + ), + options.tenantId, + ); + } + + @MessagePattern( + EventAnonCredsRevocationRegisterRevocationRegistryDefinition.token, + ) + public async registerRevocationStatusList( + options: EventAnonCredsRevocationRegisterRevocationStatusListInput, + ): Promise<EventAnonCredsRevocationRegisterRevocationStatusList> { + return new EventAnonCredsRevocationRegisterRevocationStatusList( + await this.revocationService.registerRevocationStatusList(options), + options.tenantId, + ); + } +} diff --git a/apps/ssi-abstraction/src/agent/revocation/revocation.module.ts b/apps/ssi-abstraction/src/agent/revocation/revocation.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..d4914196a186a20e873612763c88afcb4f5327be --- /dev/null +++ b/apps/ssi-abstraction/src/agent/revocation/revocation.module.ts @@ -0,0 +1,13 @@ +import { Module } from '@nestjs/common'; + +import { AgentModule } from '../agent.module.js'; + +import { RevocationController } from './revocation.controller.js'; +import { RevocationService } from './revocation.service.js'; + +@Module({ + imports: [AgentModule], + providers: [RevocationService], + controllers: [RevocationController], +}) +export class RevocationModule {} diff --git a/apps/ssi-abstraction/src/agent/revocation/revocation.service.ts b/apps/ssi-abstraction/src/agent/revocation/revocation.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b223769289798cb5b5425efe7991ec1776d20346 --- /dev/null +++ b/apps/ssi-abstraction/src/agent/revocation/revocation.service.ts @@ -0,0 +1,51 @@ +import type { + EventAnonCredsRevocationRegisterRevocationRegistryDefinition, + EventAnonCredsRevocationRegisterRevocationRegistryDefinitionInput, + EventAnonCredsRevocationRegisterRevocationStatusList, + EventAnonCredsRevocationRegisterRevocationStatusListInput, + EventAnonCredsRevocationRevoke, + EventAnonCredsRevocationRevokeInput, +} from '@ocm/shared'; + +import { Injectable } from '@nestjs/common'; + +import { WithTenantService } from '../withTenantService.js'; + +@Injectable() +export class RevocationService { + public constructor(private withTenantService: WithTenantService) {} + + // Get the credential from storage + // Get the revocation registry definition id + // Get the revocation index + // Get the status list + // Update the status list with the revoked index set + public async revoke({ + tenantId, + }: EventAnonCredsRevocationRevokeInput): Promise< + EventAnonCredsRevocationRevoke['data'] + > { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + return this.withTenantService.invoke(tenantId, async (_) => ({})); + } + + public async registerRevocationRegistryDefinition({ + tenantId, + }: EventAnonCredsRevocationRegisterRevocationRegistryDefinitionInput): Promise< + EventAnonCredsRevocationRegisterRevocationRegistryDefinition['data'] + > { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + return this.withTenantService.invoke(tenantId, async (_) => ({ + revocationRegistryDefinitionId: 'TODO', + })); + } + + public async registerRevocationStatusList({ + tenantId, + }: EventAnonCredsRevocationRegisterRevocationStatusListInput): Promise< + EventAnonCredsRevocationRegisterRevocationStatusList['data'] + > { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + return this.withTenantService.invoke(tenantId, async (_) => ({})); + } +} diff --git a/apps/ssi-abstraction/src/agent/schemas/__tests__/schemas.controller.spec.ts b/apps/ssi-abstraction/src/agent/schemas/__tests__/schemas.controller.spec.ts index eada3bc6dee62b541774e0cf4d8c7a7edffc6b04..f9e2855e7abb5f2b2a54a503b1670d0e56a2f7de 100644 --- a/apps/ssi-abstraction/src/agent/schemas/__tests__/schemas.controller.spec.ts +++ b/apps/ssi-abstraction/src/agent/schemas/__tests__/schemas.controller.spec.ts @@ -7,7 +7,7 @@ import { AgentModule } from '../../agent.module.js'; import { SchemasController } from '../schemas.controller.js'; import { SchemasService } from '../schemas.service.js'; -describe('SchemassController', () => { +describe('SchemasController', () => { let schemasController: SchemasController; let schemasService: SchemasService; @@ -51,11 +51,12 @@ describe('SchemassController', () => { describe('register schema', () => { it('should register a schema on a ledger', async () => { - const result: AnonCredsSchema = { + const result: AnonCredsSchema & { schemaId: string } = { name: 'schema-name', version: '1.0', issuerId: 'did:indy:123', attrNames: ['name', 'age'], + schemaId: 'some-id', }; jest.spyOn(schemasService, 'register').mockResolvedValue(result); diff --git a/apps/ssi-abstraction/src/agent/schemas/schemas.service.ts b/apps/ssi-abstraction/src/agent/schemas/schemas.service.ts index 6e031b5386f2f88596c8ff61746b64b27caf76db..135f28c2fa31ba9cde29e62d11a30020bfe316bd 100644 --- a/apps/ssi-abstraction/src/agent/schemas/schemas.service.ts +++ b/apps/ssi-abstraction/src/agent/schemas/schemas.service.ts @@ -1,8 +1,11 @@ import type { AnonCredsSchema } from '@credo-ts/anoncreds'; import type { IndyVdrRegisterSchemaOptions } from '@credo-ts/indy-vdr'; import type { + EventAnonCredsSchemasGetAll, EventAnonCredsSchemasGetAllInput, + EventAnonCredsSchemasGetById, EventAnonCredsSchemasGetByIdInput, + EventAnonCredsSchemasRegister, EventAnonCredsSchemasRegisterInput, } from '@ocm/shared'; @@ -16,7 +19,9 @@ export class SchemasService { public async getAll({ tenantId, - }: EventAnonCredsSchemasGetAllInput): Promise<Array<AnonCredsSchema>> { + }: EventAnonCredsSchemasGetAllInput): Promise< + EventAnonCredsSchemasGetAll['data'] + > { return this.withTenantService.invoke(tenantId, async (t) => (await t.modules.anoncreds.getCreatedSchemas({})).map((r) => r.schema), ); @@ -25,7 +30,9 @@ export class SchemasService { public async getById({ tenantId, schemaId, - }: EventAnonCredsSchemasGetByIdInput): Promise<AnonCredsSchema | null> { + }: EventAnonCredsSchemasGetByIdInput): Promise< + EventAnonCredsSchemasGetById['data'] + > { return this.withTenantService.invoke(tenantId, async (t) => { const { schema } = await t.modules.anoncreds.getSchema(schemaId); return schema ?? null; @@ -39,7 +46,7 @@ export class SchemasService { issuerDid, attributeNames, }: EventAnonCredsSchemasRegisterInput): Promise< - AnonCredsSchema & { schemaId: string } + EventAnonCredsSchemasRegister['data'] > { return this.withTenantService.invoke(tenantId, async (t) => { const { schemaState } = diff --git a/apps/ssi-abstraction/src/agent/tenants/tenants.controller.ts b/apps/ssi-abstraction/src/agent/tenants/tenants.controller.ts index 89dc00118c4fff39cccfb8b09e417e5ca75bb7f3..f7bef9055c039c692b7b36c9bbb154944e0e8cd6 100644 --- a/apps/ssi-abstraction/src/agent/tenants/tenants.controller.ts +++ b/apps/ssi-abstraction/src/agent/tenants/tenants.controller.ts @@ -9,11 +9,11 @@ export class TenantsController { public constructor(private tenantsService: TenantsService) {} @MessagePattern(EventTenantsCreate.token) - public async create({ - label, - }: EventTenantsCreateInput): Promise<EventTenantsCreate> { + public async create( + options: EventTenantsCreateInput, + ): Promise<EventTenantsCreate> { return new EventTenantsCreate( - await this.tenantsService.create(label), + await this.tenantsService.create(options), undefined, ); } diff --git a/apps/ssi-abstraction/src/agent/tenants/tenants.service.ts b/apps/ssi-abstraction/src/agent/tenants/tenants.service.ts index 483a64aeed5a89c952e85b3d0ead4aacd7d1a65e..f5772a384528f9c058db87bce4d2ed9def9e32ad 100644 --- a/apps/ssi-abstraction/src/agent/tenants/tenants.service.ts +++ b/apps/ssi-abstraction/src/agent/tenants/tenants.service.ts @@ -1,4 +1,5 @@ import type { AppAgent } from '../agent.service.js'; +import type { EventTenantsCreate, EventTenantsCreateInput } from '@ocm/shared'; import { Injectable } from '@nestjs/common'; @@ -12,7 +13,11 @@ export class TenantsService { this.agent = agentService.agent; } - public async create(label: string) { - return await this.agent.modules.tenants.createTenant({ config: { label } }); + public async create( + options: EventTenantsCreateInput, + ): Promise<EventTenantsCreate['data']> { + return await this.agent.modules.tenants.createTenant({ + config: { label: options.label }, + }); } } diff --git a/apps/ssi-abstraction/test/anoncredsCredentials.e2e-spec.ts b/apps/ssi-abstraction/test/anoncredsCredentials.e2e-spec.ts index 0bf5e2c27ca8eb7b66c8520d2e812911f12fa259..4751814a8991932682062a725b150a2f7c4126a4 100644 --- a/apps/ssi-abstraction/test/anoncredsCredentials.e2e-spec.ts +++ b/apps/ssi-abstraction/test/anoncredsCredentials.e2e-spec.ts @@ -76,7 +76,7 @@ describe('Credentials', () => { await client.connect(); const tenantsService = app.get(TenantsService); - const { id } = await tenantsService.create(TOKEN); + const { id } = await tenantsService.create({ label: TOKEN }); tenantId = id; const connectionsService = app.get(ConnectionsService); diff --git a/apps/ssi-abstraction/test/connections.e2e-spec.ts b/apps/ssi-abstraction/test/connections.e2e-spec.ts index 711d0bdacc0a611aa1816e7fab95f9573d29abbe..64604e86b673d6a620dfe88382c9794fe788d70f 100644 --- a/apps/ssi-abstraction/test/connections.e2e-spec.ts +++ b/apps/ssi-abstraction/test/connections.e2e-spec.ts @@ -57,7 +57,7 @@ describe('Connections', () => { await client.connect(); const ts = app.get(TenantsService); - const { id } = await ts.create(TOKEN); + const { id } = await ts.create({ label: TOKEN }); tenantId = id; }); diff --git a/apps/ssi-abstraction/test/credentialDefinitions.e2e-spec.ts b/apps/ssi-abstraction/test/credentialDefinitions.e2e-spec.ts index 2f87be6acd96465e540ba843a504c689fa6a10af..05e68cfe1641deaaa491aca54632ef28152e9ff8 100644 --- a/apps/ssi-abstraction/test/credentialDefinitions.e2e-spec.ts +++ b/apps/ssi-abstraction/test/credentialDefinitions.e2e-spec.ts @@ -58,7 +58,7 @@ describe('CredentialDefinitions', () => { await client.connect(); const tenantsService = app.get(TenantsService); - const { id } = await tenantsService.create(TOKEN); + const { id } = await tenantsService.create({ label: TOKEN }); tenantId = id; const didsService = app.get(DidsService); diff --git a/apps/ssi-abstraction/test/dids.e2e-spec.ts b/apps/ssi-abstraction/test/dids.e2e-spec.ts index 17ab54593bef7e624281ed90826729979b33c896..fc11291be795c48e8a8d6c5cc3ded5325ceae736 100644 --- a/apps/ssi-abstraction/test/dids.e2e-spec.ts +++ b/apps/ssi-abstraction/test/dids.e2e-spec.ts @@ -50,7 +50,7 @@ describe('Dids', () => { await client.connect(); const ts = app.get(TenantsService); - const { id } = await ts.create(TOKEN); + const { id } = await ts.create({ label: TOKEN }); tenantId = id; }); diff --git a/apps/ssi-abstraction/test/schemas.e2e-spec.ts b/apps/ssi-abstraction/test/schemas.e2e-spec.ts index 018b1d3b63b436f0fc7c320f18e7259a0ef8a5ca..d2ce54183a38f6b80f2f307dc6657ce9115af383 100644 --- a/apps/ssi-abstraction/test/schemas.e2e-spec.ts +++ b/apps/ssi-abstraction/test/schemas.e2e-spec.ts @@ -53,7 +53,7 @@ describe('Schemas', () => { await client.connect(); const ts = app.get(TenantsService); - const { id } = await ts.create(TOKEN); + const { id } = await ts.create({ label: TOKEN }); tenantId = id; const ds = app.get(DidsService);