Skip to content
Snippets Groups Projects
Commit 62e6bdf0 authored by Steffen Schulze's avatar Steffen Schulze
Browse files

Merge branch 'ssi-proof-functionality' into 'main'

feat(ssi): crud proof events

See merge request eclipse/xfsc/ocm/ocm-engine!29
parents ae8024d2 4cf97f96
No related branches found
No related tags found
No related merge requests found
Showing
with 538 additions and 21 deletions
import type { BaseEventInput } from './baseEvents.js'; import type { BaseEventInput } from './baseEvents.js';
import type { AnonCredsCredentialOffer } from '@aries-framework/anoncreds'; import type { AnonCredsCredentialOffer } from '@aries-framework/anoncreds';
import {
CredentialExchangeRecord,
JsonTransformer,
} from '@aries-framework/core';
import { BaseEvent } from './baseEvents.js'; import { BaseEvent } from './baseEvents.js';
export type EventAnonCredsCredentialOfferGetAllInput = BaseEventInput; export type EventAnonCredsCredentialOfferGetAllInput = BaseEventInput;
...@@ -11,7 +16,9 @@ export class EventAnonCredsCredentialOfferGetAll extends BaseEvent< ...@@ -11,7 +16,9 @@ export class EventAnonCredsCredentialOfferGetAll extends BaseEvent<
public static token = 'anoncreds.credentialOffers.getAll'; public static token = 'anoncreds.credentialOffers.getAll';
public get instance() { public get instance() {
return this.data; return this.data.map((d) =>
JsonTransformer.fromJSON(d, CredentialExchangeRecord),
);
} }
public static fromEvent(e: EventAnonCredsCredentialOfferGetAll) { public static fromEvent(e: EventAnonCredsCredentialOfferGetAll) {
...@@ -33,7 +40,9 @@ export class EventAnonCredsCredentialOfferGetById extends BaseEvent<AnonCredsCre ...@@ -33,7 +40,9 @@ export class EventAnonCredsCredentialOfferGetById extends BaseEvent<AnonCredsCre
public static token = 'anoncreds.credentialOffers.getById'; public static token = 'anoncreds.credentialOffers.getById';
public get instance() { public get instance() {
return this.data; return this.data
? JsonTransformer.fromJSON(this.data, CredentialExchangeRecord)
: null;
} }
public static fromEvent(e: EventAnonCredsCredentialOfferGetById) { public static fromEvent(e: EventAnonCredsCredentialOfferGetById) {
......
import type { BaseEventInput } from './baseEvents.js'; import type { BaseEventInput } from './baseEvents.js';
import type { AnonCredsCredentialRequest } from '@aries-framework/anoncreds'; import type { AnonCredsCredentialRequest } from '@aries-framework/anoncreds';
import {
CredentialExchangeRecord,
JsonTransformer,
} from '@aries-framework/core';
import { BaseEvent } from './baseEvents.js'; import { BaseEvent } from './baseEvents.js';
export type EventAnonCredsCredentialRequestGetAllInput = BaseEventInput; export type EventAnonCredsCredentialRequestGetAllInput = BaseEventInput;
...@@ -11,7 +16,9 @@ export class EventAnonCredsCredentialRequestGetAll extends BaseEvent< ...@@ -11,7 +16,9 @@ export class EventAnonCredsCredentialRequestGetAll extends BaseEvent<
public static token = 'anoncreds.credentialRequests.getAll'; public static token = 'anoncreds.credentialRequests.getAll';
public get instance() { public get instance() {
return this.data; return this.data.map((d) =>
JsonTransformer.fromJSON(d, CredentialExchangeRecord),
);
} }
public static fromEvent(e: EventAnonCredsCredentialRequestGetAll) { public static fromEvent(e: EventAnonCredsCredentialRequestGetAll) {
...@@ -33,7 +40,9 @@ export class EventAnonCredsCredentialRequestGetById extends BaseEvent<AnonCredsC ...@@ -33,7 +40,9 @@ export class EventAnonCredsCredentialRequestGetById extends BaseEvent<AnonCredsC
public static token = 'anoncreds.credentialRequests.getById'; public static token = 'anoncreds.credentialRequests.getById';
public get instance() { public get instance() {
return this.data; return this.data
? JsonTransformer.fromJSON(this.data, CredentialExchangeRecord)
: null;
} }
public static fromEvent(e: EventAnonCredsCredentialRequestGetById) { public static fromEvent(e: EventAnonCredsCredentialRequestGetById) {
......
import type { BaseEventInput } from './baseEvents.js';
import type {
AnonCredsPredicateType,
AnonCredsProofRequestRestriction,
} from '@aries-framework/anoncreds';
import { JsonTransformer, ProofExchangeRecord } from '@aries-framework/core';
import { BaseEvent } from './baseEvents.js';
export type EventAnonCredsProofsGetAllInput = BaseEventInput;
export class EventAnonCredsProofsGetAll extends BaseEvent<
Array<ProofExchangeRecord>
> {
public static token = 'anoncreds.proofs.getAll';
public get instance() {
return this.data.map((d) =>
JsonTransformer.fromJSON(d, ProofExchangeRecord),
);
}
public static fromEvent(e: EventAnonCredsProofsGetAll) {
return new EventAnonCredsProofsGetAll(
e.data,
e.tenantId,
e.id,
e.type,
e.timestamp,
);
}
}
export type EventAnonCredsProofsGetByIdInput = BaseEventInput<{
proofRecordId: string;
}>;
export class EventAnonCredsProofsGetById extends BaseEvent<ProofExchangeRecord | null> {
public static token = 'anoncreds.proofs.getById';
public get instance() {
return this.data
? JsonTransformer.fromJSON(this.data, ProofExchangeRecord)
: this.data;
}
public static fromEvent(e: EventAnonCredsProofsGetById) {
return new EventAnonCredsProofsGetById(
e.data,
e.tenantId,
e.id,
e.type,
e.timestamp,
);
}
}
export type EventDidcommAnonCredsProofsRequestInput = BaseEventInput<{
connectionId: string;
name: string;
requestedAttributes: {
[groupName: string]: {
names: Array<string>;
restrictions?: Array<AnonCredsProofRequestRestriction>;
};
};
requestedPredicates: {
[groupName: string]: {
name: string;
predicateType: AnonCredsPredicateType;
predicateValue: number;
restrictions?: Array<AnonCredsProofRequestRestriction>;
};
};
}>;
export class EventDidcommAnonCredsProofsRequest extends BaseEvent<ProofExchangeRecord> {
public static token = 'didcomm.anoncreds.proofs.request';
public get instance() {
return JsonTransformer.fromJSON(this.data, ProofExchangeRecord);
}
public static fromEvent(e: EventDidcommAnonCredsProofsRequest) {
return new EventDidcommAnonCredsProofsRequest(
e.data,
e.tenantId,
e.id,
e.type,
e.timestamp,
);
}
}
export type EventAnonCredsProofsDeleteByIdInput = BaseEventInput<{
proofRecordId: string;
}>;
export class EventAnonCredsProofsDeleteById extends BaseEvent {
public static token = 'anoncreds.proofs.deleteById';
public static fromEvent(e: EventDidcommAnonCredsProofsRequest) {
return new EventDidcommAnonCredsProofsRequest(
e.data,
e.tenantId,
e.id,
e.type,
e.timestamp,
);
}
}
...@@ -12,6 +12,7 @@ export * from './events/credentialDefinitionEvents.js'; ...@@ -12,6 +12,7 @@ export * from './events/credentialDefinitionEvents.js';
export * from './events/credentialEvents.js'; export * from './events/credentialEvents.js';
export * from './events/credentialOfferEvents.js'; export * from './events/credentialOfferEvents.js';
export * from './events/credentialRequestEvents.js'; export * from './events/credentialRequestEvents.js';
export * from './events/proofEvents.js';
export * from './dto/pagination-params.dto.js'; export * from './dto/pagination-params.dto.js';
export * from './dto/multitenancy-params.dto.js'; export * from './dto/multitenancy-params.dto.js';
...@@ -19,3 +20,6 @@ export * from './dto/multitenancy-params.dto.js'; ...@@ -19,3 +20,6 @@ export * from './dto/multitenancy-params.dto.js';
export * from './modules/health/health.module.js'; export * from './modules/health/health.module.js';
export * from './interceptors/response-format.interceptor.js'; export * from './interceptors/response-format.interceptor.js';
export * from './dto/pagination-params.dto.js';
export * from './dto/multitenancy-params.dto.js';
...@@ -6,7 +6,9 @@ import type { OnApplicationShutdown } from '@nestjs/common'; ...@@ -6,7 +6,9 @@ import type { OnApplicationShutdown } from '@nestjs/common';
import { import {
AnonCredsCredentialFormatService, AnonCredsCredentialFormatService,
AnonCredsModule, AnonCredsModule,
AnonCredsProofFormatService,
LegacyIndyCredentialFormatService, LegacyIndyCredentialFormatService,
LegacyIndyProofFormatService,
} from '@aries-framework/anoncreds'; } from '@aries-framework/anoncreds';
import { AnonCredsRsModule } from '@aries-framework/anoncreds-rs'; import { AnonCredsRsModule } from '@aries-framework/anoncreds-rs';
import { AskarModule } from '@aries-framework/askar'; import { AskarModule } from '@aries-framework/askar';
...@@ -23,7 +25,9 @@ import { ...@@ -23,7 +25,9 @@ import {
LogLevel, LogLevel,
PeerDidRegistrar, PeerDidRegistrar,
PeerDidResolver, PeerDidResolver,
ProofsModule,
V2CredentialProtocol, V2CredentialProtocol,
V2ProofProtocol,
WebDidResolver, WebDidResolver,
} from '@aries-framework/core'; } from '@aries-framework/core';
import { import {
...@@ -90,13 +94,14 @@ export class AgentService implements OnApplicationShutdown { ...@@ -90,13 +94,14 @@ export class AgentService implements OnApplicationShutdown {
} }
public get modules() { public get modules() {
const { autoAcceptConnection, autoAcceptCredential } = const { autoAcceptConnection, autoAcceptCredential, autoAcceptProof } =
this.configService.get('agent'); this.configService.get('agent');
return { return {
connections: new ConnectionsModule({ connections: new ConnectionsModule({
autoAcceptConnections: autoAcceptConnection, autoAcceptConnections: autoAcceptConnection,
}), }),
credentials: new CredentialsModule({ credentials: new CredentialsModule({
autoAcceptCredentials: autoAcceptCredential, autoAcceptCredentials: autoAcceptCredential,
credentialProtocols: [ credentialProtocols: [
...@@ -109,6 +114,18 @@ export class AgentService implements OnApplicationShutdown { ...@@ -109,6 +114,18 @@ export class AgentService implements OnApplicationShutdown {
], ],
}), }),
proofs: new ProofsModule({
autoAcceptProofs: autoAcceptProof,
proofProtocols: [
new V2ProofProtocol({
proofFormats: [
new AnonCredsProofFormatService(),
new LegacyIndyProofFormatService(),
],
}),
],
}),
anoncredsRs: new AnonCredsRsModule({ anoncreds }), anoncredsRs: new AnonCredsRsModule({ anoncreds }),
anoncreds: new AnonCredsModule({ anoncreds: new AnonCredsModule({
registries: [new IndyVdrAnonCredsRegistry()], registries: [new IndyVdrAnonCredsRegistry()],
......
import { Controller } from '@nestjs/common'; import { Controller } from '@nestjs/common';
import { MessagePattern } from '@nestjs/microservices'; import { MessagePattern } from '@nestjs/microservices';
import { import {
EventDidcommAnonCredsCredentialsGetAll, EventAnonCredsCredentialsGetAll,
EventDidcommAnonCredsCredentialsGetAllInput, EventAnonCredsCredentialsGetAllInput,
EventDidcommAnonCredsCredentialsGetById, EventAnonCredsCredentialsGetById,
EventDidcommAnonCredsCredentialsGetByIdInput, EventAnonCredsCredentialsGetByIdInput,
EventDidcommAnonCredsCredentialsOffer, EventDidcommAnonCredsCredentialsOffer,
EventDidcommAnonCredsCredentialsOfferInput, EventDidcommAnonCredsCredentialsOfferInput,
EventDidcommAnonCredsCredentialsOfferToSelfInput, EventDidcommAnonCredsCredentialsOfferToSelfInput,
...@@ -17,21 +17,21 @@ import { AnonCredsCredentialsService } from './anoncredsCredentials.service.js'; ...@@ -17,21 +17,21 @@ import { AnonCredsCredentialsService } from './anoncredsCredentials.service.js';
export class AnonCredsCredentialsController { export class AnonCredsCredentialsController {
public constructor(private credentialsService: AnonCredsCredentialsService) {} public constructor(private credentialsService: AnonCredsCredentialsService) {}
@MessagePattern(EventDidcommAnonCredsCredentialsGetAll.token) @MessagePattern(EventAnonCredsCredentialsGetAll.token)
public async getAll( public async getAll(
options: EventDidcommAnonCredsCredentialsGetAllInput, options: EventAnonCredsCredentialsGetAllInput,
): Promise<EventDidcommAnonCredsCredentialsGetAll> { ): Promise<EventAnonCredsCredentialsGetAll> {
return new EventDidcommAnonCredsCredentialsGetAll( return new EventAnonCredsCredentialsGetAll(
await this.credentialsService.getAll(options), await this.credentialsService.getAll(options),
options.tenantId, options.tenantId,
); );
} }
@MessagePattern(EventDidcommAnonCredsCredentialsGetById.token) @MessagePattern(EventAnonCredsCredentialsGetById.token)
public async getById( public async getById(
options: EventDidcommAnonCredsCredentialsGetByIdInput, options: EventAnonCredsCredentialsGetByIdInput,
): Promise<EventDidcommAnonCredsCredentialsGetById> { ): Promise<EventAnonCredsCredentialsGetById> {
return new EventDidcommAnonCredsCredentialsGetById( return new EventAnonCredsCredentialsGetById(
await this.credentialsService.getById(options), await this.credentialsService.getById(options),
options.tenantId, options.tenantId,
); );
......
import type { import type {
EventDidcommAnonCredsCredentialsGetAllInput, EventAnonCredsCredentialsGetAllInput,
EventDidcommAnonCredsCredentialsGetByIdInput, EventAnonCredsCredentialsGetByIdInput,
EventDidcommAnonCredsCredentialsOfferInput, EventDidcommAnonCredsCredentialsOfferInput,
EventDidcommAnonCredsCredentialsOfferToSelfInput, EventDidcommAnonCredsCredentialsOfferToSelfInput,
} from '@ocm/shared'; } from '@ocm/shared';
...@@ -20,7 +20,7 @@ export class AnonCredsCredentialsService { ...@@ -20,7 +20,7 @@ export class AnonCredsCredentialsService {
public async getAll({ public async getAll({
tenantId, tenantId,
}: EventDidcommAnonCredsCredentialsGetAllInput): Promise< }: EventAnonCredsCredentialsGetAllInput): Promise<
Array<CredentialExchangeRecord> Array<CredentialExchangeRecord>
> { > {
return this.withTenantService.invoke(tenantId, (t) => return this.withTenantService.invoke(tenantId, (t) =>
...@@ -31,7 +31,7 @@ export class AnonCredsCredentialsService { ...@@ -31,7 +31,7 @@ export class AnonCredsCredentialsService {
public async getById({ public async getById({
tenantId, tenantId,
credentialRecordId, credentialRecordId,
}: EventDidcommAnonCredsCredentialsGetByIdInput): Promise<CredentialExchangeRecord | null> { }: EventAnonCredsCredentialsGetByIdInput): Promise<CredentialExchangeRecord | null> {
return this.withTenantService.invoke(tenantId, (t) => return this.withTenantService.invoke(tenantId, (t) =>
t.credentials.findById(credentialRecordId), t.credentials.findById(credentialRecordId),
); );
......
import { ProofExchangeRecord, ProofState } from '@aries-framework/core';
import { Test } from '@nestjs/testing';
import { mockConfigModule } from '../../../config/__tests__/mockConfig.js';
import { AgentModule } from '../../agent.module.js';
import { AnonCredsProofsController } from '../anoncredsProofs.controller.js';
import { AnonCredsProofsService } from '../anoncredsProofs.service.js';
describe('AnonCredsProofsController', () => {
let proofsController: AnonCredsProofsController;
let proofsService: AnonCredsProofsService;
beforeEach(async () => {
const moduleRef = await Test.createTestingModule({
imports: [mockConfigModule(), AgentModule],
controllers: [AnonCredsProofsController],
providers: [AnonCredsProofsService],
}).compile();
proofsService = moduleRef.get(AnonCredsProofsService);
proofsController = moduleRef.get(AnonCredsProofsController);
});
it('get all', async () => {
const result: Array<ProofExchangeRecord> = [];
jest.spyOn(proofsService, 'getAll').mockResolvedValue(result);
const event = await proofsController.getAll({
tenantId: 'some-id',
});
expect(event.data).toStrictEqual(result);
});
it('get by id', async () => {
const result: ProofExchangeRecord | null = null;
jest.spyOn(proofsService, 'getById').mockResolvedValue(result);
const event = await proofsController.getById({
tenantId: 'some-id',
proofRecordId: 'some-id',
});
expect(event.data).toStrictEqual(result);
});
it('request', async () => {
const result = new ProofExchangeRecord({
state: ProofState.Done,
threadId: 'some-id',
protocolVersion: 'v2',
});
jest.spyOn(proofsService, 'request').mockResolvedValue(result);
const event = await proofsController.request({
tenantId: 'some-id',
connectionId: 'some-id',
name: 'My New Proof Request',
requestedAttributes: {
identity: {
names: ['name'],
restrictions: [{ issuer_id: 'did:web:government.org' }],
},
},
requestedPredicates: {
'age > 18': {
name: 'age',
restrictions: [{ issuer_id: 'did:web:government.org' }],
predicateType: '>',
predicateValue: 18,
},
},
});
expect(event.data).toStrictEqual(result);
});
});
import { Controller } from '@nestjs/common';
import { MessagePattern } from '@nestjs/microservices';
import {
EventAnonCredsProofsDeleteById,
EventAnonCredsProofsDeleteByIdInput,
EventAnonCredsProofsGetAll,
EventAnonCredsProofsGetAllInput,
EventAnonCredsProofsGetById,
EventAnonCredsProofsGetByIdInput,
EventDidcommAnonCredsProofsRequest,
EventDidcommAnonCredsProofsRequestInput,
} from '@ocm/shared';
import { AnonCredsProofsService } from './anoncredsProofs.service.js';
@Controller('anoncredsProofs')
export class AnonCredsProofsController {
public constructor(private proofsService: AnonCredsProofsService) {}
@MessagePattern(EventAnonCredsProofsGetAll.token)
public async getAll(
options: EventAnonCredsProofsGetAllInput,
): Promise<EventAnonCredsProofsGetAll> {
return new EventAnonCredsProofsGetAll(
await this.proofsService.getAll(options),
options.tenantId,
);
}
@MessagePattern(EventAnonCredsProofsGetById.token)
public async getById(
options: EventAnonCredsProofsGetByIdInput,
): Promise<EventAnonCredsProofsGetById> {
return new EventAnonCredsProofsGetById(
await this.proofsService.getById(options),
options.tenantId,
);
}
@MessagePattern(EventAnonCredsProofsDeleteById.token)
public async deleteById(
options: EventAnonCredsProofsDeleteByIdInput,
): Promise<EventAnonCredsProofsDeleteById> {
return new EventAnonCredsProofsDeleteById(
await this.proofsService.deleteById(options),
options.tenantId,
);
}
@MessagePattern(EventDidcommAnonCredsProofsRequest.token)
public async request(
options: EventDidcommAnonCredsProofsRequestInput,
): Promise<EventDidcommAnonCredsProofsRequest> {
return new EventDidcommAnonCredsProofsRequest(
await this.proofsService.request(options),
options.tenantId,
);
}
}
import { Module } from '@nestjs/common';
import { AgentModule } from '../agent.module.js';
import { AnonCredsProofsController } from './anoncredsProofs.controller.js';
import { AnonCredsProofsService } from './anoncredsProofs.service.js';
@Module({
imports: [AgentModule],
providers: [AnonCredsProofsService],
controllers: [AnonCredsProofsController],
})
export class AnonCredsProofsModule {}
import type {
EventAnonCredsProofsDeleteById,
EventAnonCredsProofsDeleteByIdInput,
EventAnonCredsProofsGetAll,
EventAnonCredsProofsGetAllInput,
EventAnonCredsProofsGetById,
EventAnonCredsProofsGetByIdInput,
EventDidcommAnonCredsProofsRequest,
EventDidcommAnonCredsProofsRequestInput,
} from '@ocm/shared';
import { Injectable } from '@nestjs/common';
import { WithTenantService } from '../withTenantService.js';
@Injectable()
export class AnonCredsProofsService {
public constructor(private withTenantService: WithTenantService) {}
public async getAll({
tenantId,
}: EventAnonCredsProofsGetAllInput): Promise<
EventAnonCredsProofsGetAll['data']
> {
return this.withTenantService.invoke(tenantId, (t) => t.proofs.getAll());
}
public async getById({
tenantId,
proofRecordId,
}: EventAnonCredsProofsGetByIdInput): Promise<
EventAnonCredsProofsGetById['data']
> {
return this.withTenantService.invoke(tenantId, (t) =>
t.proofs.findById(proofRecordId),
);
}
public async deleteById({
tenantId,
proofRecordId,
}: EventAnonCredsProofsDeleteByIdInput): Promise<
EventAnonCredsProofsDeleteById['data']
> {
return this.withTenantService.invoke(tenantId, async (t) => {
await t.proofs.deleteById(proofRecordId);
return {};
});
}
public async request({
tenantId,
connectionId,
name,
requestedAttributes,
requestedPredicates,
}: EventDidcommAnonCredsProofsRequestInput): Promise<
EventDidcommAnonCredsProofsRequest['data']
> {
const transformedPredicates = Object.entries(requestedPredicates).reduce(
(prev, [key, value]) => ({
...prev,
[key]: {
name: value.name,
restrictions: value.restrictions,
p_type: value.predicateType,
p_value: value.predicateValue,
},
}),
{},
);
return this.withTenantService.invoke(tenantId, (t) =>
t.proofs.requestProof({
connectionId,
protocolVersion: 'v2',
proofFormats: {
anoncreds: {
name,
version: '1.0',
requested_attributes: requestedAttributes,
requested_predicates: transformedPredicates,
},
},
}),
);
}
}
import type { INestApplication } from '@nestjs/common';
import type { ClientProxy } from '@nestjs/microservices';
import type {
EventAnonCredsProofsGetAllInput,
EventAnonCredsProofsGetByIdInput,
EventDidcommAnonCredsProofsRequestInput,
} from '@ocm/shared';
import { ProofState } from '@aries-framework/core';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import {
EventAnonCredsProofsGetAll,
EventAnonCredsProofsGetById,
EventDidcommAnonCredsProofsRequest,
} from '@ocm/shared';
import { firstValueFrom } from 'rxjs';
import { AgentModule } from '../src/agent/agent.module.js';
import { AnonCredsProofsModule } from '../src/agent/anoncredsProofs/anoncredsProofs.module.js';
import { ConnectionsModule } from '../src/agent/connections/connections.module.js';
import { ConnectionsService } from '../src/agent/connections/connections.service.js';
import { DidsModule } from '../src/agent/dids/dids.module.js';
import { TenantsModule } from '../src/agent/tenants/tenants.module.js';
import { TenantsService } from '../src/agent/tenants/tenants.service.js';
import { mockConfigModule } from '../src/config/__tests__/mockConfig.js';
describe('Proofs', () => {
const TOKEN = 'PROOFS_CLIENT_SERVICE';
let app: INestApplication;
let client: ClientProxy;
let tenantId: string;
let connectionId: string;
let credentialDefinitionId: string;
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
imports: [
mockConfigModule(3004, true),
AgentModule,
ConnectionsModule,
AnonCredsProofsModule,
TenantsModule,
DidsModule,
ClientsModule.register([{ name: TOKEN, transport: Transport.NATS }]),
],
}).compile();
app = moduleRef.createNestApplication();
app.connectMicroservice({ transport: Transport.NATS });
await app.startAllMicroservices();
await app.init();
client = app.get(TOKEN);
await client.connect();
const tenantsService = app.get(TenantsService);
const { id: tId } = await tenantsService.create(TOKEN);
tenantId = tId;
const connectionsService = app.get(ConnectionsService);
const { id } = await connectionsService.createConnectionWithSelf({
tenantId,
});
connectionId = id;
});
afterAll(async () => {
await app.close();
client.close();
});
it(EventAnonCredsProofsGetAll.token, async () => {
const response$ = client.send<
EventAnonCredsProofsGetAll,
EventAnonCredsProofsGetAllInput
>(EventAnonCredsProofsGetAll.token, { tenantId });
const response = await firstValueFrom(response$);
const eventInstance = EventAnonCredsProofsGetAll.fromEvent(response);
expect(eventInstance.instance).toEqual(expect.arrayContaining([]));
});
it(EventAnonCredsProofsGetById.token, async () => {
const response$ = client.send<
EventAnonCredsProofsGetById,
EventAnonCredsProofsGetByIdInput
>(EventAnonCredsProofsGetById.token, {
tenantId,
proofRecordId: 'some-id',
});
const response = await firstValueFrom(response$);
const eventInstance = EventAnonCredsProofsGetById.fromEvent(response);
expect(eventInstance.instance).toEqual(null);
});
it(EventDidcommAnonCredsProofsRequest.token, async () => {
const response$ = client.send<
EventDidcommAnonCredsProofsRequest,
EventDidcommAnonCredsProofsRequestInput
>(EventDidcommAnonCredsProofsRequest.token, {
tenantId,
name: 'My Test Proof Request',
connectionId,
requestedAttributes: {
Identity: {
names: ['Name'],
restrictions: [{ cred_def_id: credentialDefinitionId }],
},
},
requestedPredicates: {
'Age > 21': {
name: 'Age',
restrictions: [{ cred_def_id: credentialDefinitionId }],
predicateType: '>',
predicateValue: 21,
},
},
});
const response = await firstValueFrom(response$);
const eventInstance =
EventDidcommAnonCredsProofsRequest.fromEvent(response);
expect(eventInstance.instance).toMatchObject({
state: ProofState.RequestSent,
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment