diff --git a/packages/core/src/modules/credentials/__tests__/CredentialRecord.test.ts b/packages/core/src/modules/credentials/__tests__/CredentialRecord.test.ts index 27f7bd1b5e..0b8a43258b 100644 --- a/packages/core/src/modules/credentials/__tests__/CredentialRecord.test.ts +++ b/packages/core/src/modules/credentials/__tests__/CredentialRecord.test.ts @@ -15,20 +15,26 @@ describe('CredentialRecord', () => { value: '25', }), ], - metadata: { - credentialDefinitionId: 'Th7MpTaRZVRYnPiabds81Y:3:CL:17:TAG', - schemaId: 'TL1EaPFCZ8Si5aUrqScBDt:2:test-schema-1599055118161:1.0', - }, }) - const credentialInfo = credentialRecord.getCredentialInfo() - expect(credentialInfo?.claims).toEqual({ - age: '25', - }) - expect(credentialInfo?.metadata).toEqual({ + credentialRecord.metadata.set('indyCredential', { credentialDefinitionId: 'Th7MpTaRZVRYnPiabds81Y:3:CL:17:TAG', schemaId: 'TL1EaPFCZ8Si5aUrqScBDt:2:test-schema-1599055118161:1.0', }) + + const credentialInfo = credentialRecord.getCredentialInfo() + + expect(credentialInfo).toEqual({ + claims: { + age: '25', + }, + metadata: { + indyCredential: { + credentialDefinitionId: 'Th7MpTaRZVRYnPiabds81Y:3:CL:17:TAG', + schemaId: 'TL1EaPFCZ8Si5aUrqScBDt:2:test-schema-1599055118161:1.0', + }, + }, + }) }) }) }) diff --git a/packages/core/src/modules/credentials/__tests__/CredentialService.test.ts b/packages/core/src/modules/credentials/__tests__/CredentialService.test.ts index 60d61e48ab..be38d0d11b 100644 --- a/packages/core/src/modules/credentials/__tests__/CredentialService.test.ts +++ b/packages/core/src/modules/credentials/__tests__/CredentialService.test.ts @@ -2,7 +2,8 @@ import type { ConnectionService } from '../../connections/services/ConnectionSer import type { StoreCredentialOptions } from '../../indy/services/IndyHolderService' import type { CredentialStateChangedEvent } from '../CredentialEvents' import type { CredentialPreviewAttribute } from '../messages' -import type { CredentialRecordMetadata, CustomCredentialTags } from '../repository/CredentialRecord' +import type { IndyCredentialMetadata } from '../models/CredentialInfo' +import type { CustomCredentialTags } from '../repository/CredentialRecord' import type { CredentialOfferTemplate } from '../services' import { getAgentConfig, getMockConnection, mockFunction } from '../../../../tests/helpers' @@ -98,7 +99,7 @@ const mockCredentialRecord = ({ }: { state?: CredentialState requestMessage?: RequestCredentialMessage - metadata?: CredentialRecordMetadata + metadata?: IndyCredentialMetadata & { indyRequest: Record } tags?: CustomCredentialTags threadId?: string connectionId?: string @@ -111,17 +112,34 @@ const mockCredentialRecord = ({ offerAttachments: [offerAttachment], }) - return new CredentialRecord({ + const credentialRecord = new CredentialRecord({ offerMessage, id, credentialAttributes: credentialAttributes || credentialPreview.attributes, requestMessage, - metadata, state: state || CredentialState.OfferSent, threadId: threadId ?? offerMessage.id, connectionId: connectionId ?? '123', tags, }) + + if (metadata?.indyRequest) { + credentialRecord.metadata.set('indyRequest', { ...metadata.indyRequest }) + } + + if (metadata?.schemaId) { + credentialRecord.metadata.add('indyCredential', { + schemaId: metadata.schemaId, + }) + } + + if (metadata?.credentialDefinitionId) { + credentialRecord.metadata.add('indyCredential', { + credentialDefinitionId: metadata.credentialDefinitionId, + }) + } + + return credentialRecord } describe('CredentialService', () => { @@ -320,8 +338,8 @@ describe('CredentialService', () => { // then expect(repositoryUpdateSpy).toHaveBeenCalledTimes(1) const [[updatedCredentialRecord]] = repositoryUpdateSpy.mock.calls - expect(updatedCredentialRecord).toMatchObject({ - metadata: { requestMetadata: { cred_req: 'meta-data' } }, + expect(updatedCredentialRecord.toJSON()).toMatchObject({ + metadata: { indyRequest: { cred_req: 'meta-data' } }, state: CredentialState.RequestSent, }) }) @@ -603,7 +621,7 @@ describe('CredentialService', () => { requestMessage: new RequestCredentialMessage({ requestAttachments: [requestAttachment], }), - metadata: { requestMetadata: { cred_req: 'meta-data' } }, + metadata: { indyRequest: { cred_req: 'meta-data' } }, }) const credentialResponse = new IssueCredentialMessage({ @@ -725,7 +743,7 @@ describe('CredentialService', () => { Promise.resolve( mockCredentialRecord({ state, - metadata: { requestMetadata: { cred_req: 'meta-data' } }, + metadata: { indyRequest: { cred_req: 'meta-data' } }, }) ) ) diff --git a/packages/core/src/modules/credentials/models/CredentialInfo.ts b/packages/core/src/modules/credentials/models/CredentialInfo.ts index 2a19a426b4..98c69f1836 100644 --- a/packages/core/src/modules/credentials/models/CredentialInfo.ts +++ b/packages/core/src/modules/credentials/models/CredentialInfo.ts @@ -1,7 +1,7 @@ import type { Attachment } from '../../../decorators/attachment/Attachment' export interface CredentialInfoOptions { - metadata?: IndyCredentialMetadata + metadata?: IndyCredentialMetadata | null claims: Record attachments?: Attachment[] } diff --git a/packages/core/src/modules/credentials/repository/CredentialRecord.ts b/packages/core/src/modules/credentials/repository/CredentialRecord.ts index e5a44845ee..159a854469 100644 --- a/packages/core/src/modules/credentials/repository/CredentialRecord.ts +++ b/packages/core/src/modules/credentials/repository/CredentialRecord.ts @@ -9,20 +9,14 @@ import { AriesFrameworkError } from '../../../error' import { BaseRecord } from '../../../storage/BaseRecord' import { uuid } from '../../../utils/uuid' import { - ProposeCredentialMessage, + CredentialPreviewAttribute, IssueCredentialMessage, - RequestCredentialMessage, OfferCredentialMessage, - CredentialPreviewAttribute, + ProposeCredentialMessage, + RequestCredentialMessage, } from '../messages' import { CredentialInfo } from '../models/CredentialInfo' -export interface CredentialRecordMetadata { - requestMetadata?: Record - credentialDefinitionId?: string - schemaId?: string -} - export interface CredentialRecordProps { id?: string createdAt?: Date @@ -31,7 +25,6 @@ export interface CredentialRecordProps { threadId: string credentialId?: string - metadata?: CredentialRecordMetadata tags?: CustomCredentialTags proposalMessage?: ProposeCredentialMessage offerMessage?: OfferCredentialMessage @@ -55,7 +48,6 @@ export class CredentialRecord extends BaseRecord({ type: CredentialEventTypes.CredentialStateChanged, @@ -187,6 +195,11 @@ export class CredentialService { state: CredentialState.ProposalReceived, }) + credentialRecord.metadata.set('indyCredential', { + schemaId: proposalMessage.schemaId, + credentialDefinitionId: proposalMessage.credentialDefinitionId, + }) + // Assert this.connectionService.assertConnectionOrServiceDecorator(messageContext) @@ -244,8 +257,10 @@ export class CredentialService { credentialRecord.offerMessage = credentialOfferMessage credentialRecord.credentialAttributes = preview.attributes - credentialRecord.metadata.credentialDefinitionId = credOffer.cred_def_id - credentialRecord.metadata.schemaId = credOffer.schema_id + credentialRecord.metadata.set('indyCredential', { + schemaId: credOffer.schema_id, + credentialDefinitionId: credOffer.cred_def_id, + }) credentialRecord.linkedAttachments = attachments?.filter((attachment) => isLinkedAttachment(attachment)) credentialRecord.autoAcceptCredential = credentialTemplate.autoAcceptCredential ?? credentialRecord.autoAcceptCredential @@ -302,14 +317,15 @@ export class CredentialService { offerMessage: credentialOfferMessage, credentialAttributes: credentialPreview.attributes, linkedAttachments: linkedAttachments?.map((linkedAttachments) => linkedAttachments.attachment), - metadata: { - credentialDefinitionId: credOffer.cred_def_id, - schemaId: credOffer.schema_id, - }, state: CredentialState.OfferSent, autoAcceptCredential: credentialTemplate.autoAcceptCredential, }) + credentialRecord.metadata.set('indyCredential', { + credentialDefinitionId: credOffer.cred_def_id, + schemaId: credOffer.schema_id, + }) + await this.credentialRepository.save(credentialRecord) this.eventEmitter.emit({ type: CredentialEventTypes.CredentialStateChanged, @@ -357,11 +373,13 @@ export class CredentialService { }) credentialRecord.offerMessage = credentialOfferMessage - credentialRecord.linkedAttachments = credentialOfferMessage.attachments?.filter((attachment) => - isLinkedAttachment(attachment) - ) - credentialRecord.metadata.credentialDefinitionId = indyCredentialOffer.cred_def_id - credentialRecord.metadata.schemaId = indyCredentialOffer.schema_id + credentialRecord.linkedAttachments = credentialOfferMessage.attachments?.filter(isLinkedAttachment) + + credentialRecord.metadata.set('indyCredential', { + schemaId: indyCredentialOffer.schema_id, + credentialDefinitionId: indyCredentialOffer.cred_def_id, + }) + await this.updateState(credentialRecord, CredentialState.OfferReceived) } catch { // No credential record exists with thread id @@ -370,13 +388,14 @@ export class CredentialService { threadId: credentialOfferMessage.id, offerMessage: credentialOfferMessage, credentialAttributes: credentialOfferMessage.credentialPreview.attributes, - metadata: { - credentialDefinitionId: indyCredentialOffer.cred_def_id, - schemaId: indyCredentialOffer.schema_id, - }, state: CredentialState.OfferReceived, }) + credentialRecord.metadata.set('indyCredential', { + credentialDefinitionId: indyCredentialOffer.cred_def_id, + schemaId: indyCredentialOffer.schema_id, + }) + // Assert this.connectionService.assertConnectionOrServiceDecorator(messageContext) @@ -440,7 +459,7 @@ export class CredentialService { }) credentialRequest.setThread({ threadId: credentialRecord.threadId }) - credentialRecord.metadata.requestMetadata = credReqMetadata + credentialRecord.metadata.set('indyRequest', credReqMetadata) credentialRecord.requestMessage = credentialRequest credentialRecord.autoAcceptCredential = options?.autoAcceptCredential ?? credentialRecord.autoAcceptCredential @@ -604,7 +623,9 @@ export class CredentialService { previousSentMessage: credentialRecord.requestMessage, }) - if (!credentialRecord.metadata.requestMetadata) { + const credentialRequestMetadata = credentialRecord.metadata.get('indyRequest') + + if (!credentialRequestMetadata) { throw new AriesFrameworkError(`Missing required request metadata for credential with id ${credentialRecord.id}`) } @@ -619,7 +640,7 @@ export class CredentialService { const credentialId = await this.indyHolderService.storeCredential({ credentialId: uuid(), - credentialRequestMetadata: credentialRecord.metadata.requestMetadata, + credentialRequestMetadata, credential: indyCredential, credentialDefinition, }) diff --git a/packages/core/src/storage/BaseRecord.ts b/packages/core/src/storage/BaseRecord.ts index a7de841ace..6532b0c362 100644 --- a/packages/core/src/storage/BaseRecord.ts +++ b/packages/core/src/storage/BaseRecord.ts @@ -1,6 +1,9 @@ import { Exclude, Type } from 'class-transformer' import { JsonTransformer } from '../utils/JsonTransformer' +import { MetadataTransformer } from '../utils/transformers' + +import { Metadata } from './Metadata' export type TagValue = string | boolean | undefined | Array export type TagsBase = { @@ -9,6 +12,7 @@ export type TagsBase = { } export type Tags = CustomTags & DefaultTags + export type RecordTags = ReturnType export abstract class BaseRecord { @@ -26,6 +30,10 @@ export abstract class BaseRecord +} + +/** + * Metadata access class to get, set (create and update) and delete + * metadata on any record. + * + * set will override the previous value if it already exists + * + * note: To add persistence to these records, you have to + * update the record in the correct repository + * + * @example + * + * ```ts + * connectionRecord.metadata.set('foo', { bar: 'baz' }) + * connectionRepository.update(connectionRecord) + * ``` + */ +export class Metadata { + public readonly data: MetadataBase + + public constructor(data: MetadataBase) { + this.data = data + } + + /** + * Gets the value by key in the metadata + * + * @param key the key to retrieve the metadata by + * @returns the value saved in the key value pair + * @returns null when the key could not be found + */ + public get>(key: string): T | null { + return (this.data[key] as T) ?? null + } + + /** + * Will set, or override, a key value pair on the metadata + * + * @param key the key to set the metadata by + * @param value the value to set in the metadata + */ + public set(key: string, value: Record): void { + this.data[key] = value + } + + /** + * Adds a record to a metadata key + * + * @param key the key to add the metadata at + * @param value the value to add in the metadata + */ + public add(key: string, value: Record): void { + this.data[key] = { + ...this.data[key], + ...value, + } + } + + /** + * Retrieves all the metadata for a record + * + * @returns all the metadata that exists on the record + */ + public getAll(): MetadataBase { + return this.data + } + + /** + * Will delete the key value pair in the metadata + * + * @param key the key to delete the data by + */ + public delete(key: string): void { + delete this.data[key] + } +} diff --git a/packages/core/src/storage/__tests__/Metadata.test.ts b/packages/core/src/storage/__tests__/Metadata.test.ts new file mode 100644 index 0000000000..f61317ce37 --- /dev/null +++ b/packages/core/src/storage/__tests__/Metadata.test.ts @@ -0,0 +1,62 @@ +import { TestRecord } from './TestRecord' + +describe('Metadata', () => { + const testRecord = new TestRecord() + + test('set() as create', () => { + testRecord.metadata.set('bar', { aries: { framework: 'javascript' } }) + + expect(testRecord.toJSON()).toMatchObject({ + metadata: { bar: { aries: { framework: 'javascript' } } }, + }) + }) + + test('set() as update ', () => { + expect(testRecord.toJSON()).toMatchObject({ + metadata: { bar: { aries: { framework: 'javascript' } } }, + }) + + testRecord.metadata.set('bar', { baz: 'foo' }) + + expect(testRecord.toJSON()).toMatchObject({ + metadata: { bar: { baz: 'foo' } }, + }) + }) + + test('add() ', () => { + testRecord.metadata.set('sample', { foo: 'bar' }) + testRecord.metadata.add('sample', { baz: 'foo' }) + + expect(testRecord.toJSON()).toMatchObject({ + metadata: { sample: { foo: 'bar', baz: 'foo' } }, + }) + }) + + test('get()', () => { + const record = testRecord.metadata.get<{ baz: 'foo' }>('bar') + + expect(record).toMatchObject({ baz: 'foo' }) + }) + + test('delete()', () => { + testRecord.metadata.delete('bar') + + expect(testRecord.toJSON()).toMatchObject({ + metadata: {}, + }) + }) + + test('getAll()', () => { + testRecord.metadata.set('bar', { baz: 'foo' }) + testRecord.metadata.set('bazz', { blub: 'foo' }) + testRecord.metadata.set('test', { abc: { def: 'hij' } }) + + const record = testRecord.metadata.getAll() + + expect(record).toMatchObject({ + bar: { baz: 'foo' }, + bazz: { blub: 'foo' }, + test: { abc: { def: 'hij' } }, + }) + }) +}) diff --git a/packages/core/src/storage/__tests__/TestRecord.ts b/packages/core/src/storage/__tests__/TestRecord.ts index 25d8a648c8..9872d3d405 100644 --- a/packages/core/src/storage/__tests__/TestRecord.ts +++ b/packages/core/src/storage/__tests__/TestRecord.ts @@ -13,7 +13,7 @@ export interface TestRecordProps { export class TestRecord extends BaseRecord { public foo!: string - public constructor(props: TestRecordProps) { + public constructor(props?: TestRecordProps) { super() if (props) { diff --git a/packages/core/src/utils/__tests__/transformers.test.ts b/packages/core/src/utils/__tests__/transformers.test.ts new file mode 100644 index 0000000000..fcf547f8db --- /dev/null +++ b/packages/core/src/utils/__tests__/transformers.test.ts @@ -0,0 +1,29 @@ +import { plainToClass } from 'class-transformer' + +import { CredentialRecord, CredentialState } from '../../modules/credentials' + +describe('transformers', () => { + it('transforms an old credential record', () => { + // Mocked old credentialRecord + const credentialRecord = new CredentialRecord({ state: CredentialState.Done, threadId: '0' }) + const jsonCredentialRecord = credentialRecord.toJSON() + + const metadata = jsonCredentialRecord.metadata as Record | string> + metadata.requestMetadata = { cred_req: 'x' } + metadata.schemaId = 'abc:def' + metadata.credentialDefinitionId = 'abc:def:CL' + + // Converted old to new credentialRecord + const cr = plainToClass(CredentialRecord, jsonCredentialRecord) + + expect(cr.metadata.data).toEqual({ + indyRequest: { + cred_req: 'x', + }, + indyCredential: { + schemaId: 'abc:def', + credentialDefinitionId: 'abc:def:CL', + }, + }) + }) +}) diff --git a/packages/core/src/utils/transformers.ts b/packages/core/src/utils/transformers.ts index 7f7350b909..bb6b2756d6 100644 --- a/packages/core/src/utils/transformers.ts +++ b/packages/core/src/utils/transformers.ts @@ -4,6 +4,8 @@ import { Transform, TransformationType } from 'class-transformer' import { ValidateBy, buildMessage } from 'class-validator' import { DateTime } from 'luxon' +import { Metadata } from '../storage/Metadata' + import { JsonTransformer } from './JsonTransformer' /** @@ -42,6 +44,38 @@ export function RecordTransformer(Class: { new (...args: any[]): T }) { } }) } + +/* + * Decorator that transforms to and from a metadata instance. + * + * @todo remove the conversion at 0.1.0 release via a migration script + */ +export function MetadataTransformer() { + return Transform(({ value, type }) => { + if (type === TransformationType.CLASS_TO_PLAIN) { + return { ...value.data } + } + + if (type === TransformationType.PLAIN_TO_CLASS) { + const { requestMetadata, schemaId, credentialDefinitionId, ...rest } = value + const metadata = new Metadata(rest) + + if (requestMetadata) metadata.add('indyRequest', { ...value.requestMetadata }) + + if (schemaId) metadata.add('indyCredential', { schemaId: value.schemaId }) + + if (credentialDefinitionId) + metadata.add('indyCredential', { credentialDefinitionId: value.credentialDefinitionId }) + + return metadata + } + + if (type === TransformationType.CLASS_TO_CLASS) { + return value + } + }) +} + /* * Function that parses date from multiple formats * including SQL formats. diff --git a/packages/core/tests/connectionless-credentials.test.ts b/packages/core/tests/connectionless-credentials.test.ts index f829f20233..4ceb4a7e64 100644 --- a/packages/core/tests/connectionless-credentials.test.ts +++ b/packages/core/tests/connectionless-credentials.test.ts @@ -123,7 +123,13 @@ describe('credentials', () => { createdAt: expect.any(Date), offerMessage: expect.any(Object), requestMessage: expect.any(Object), - metadata: { requestMetadata: expect.any(Object) }, + metadata: { + data: { + indyCredential: { + credentialDefinitionId: credDefId, + }, + }, + }, credentialId: expect.any(String), state: CredentialState.Done, threadId: expect.any(String), @@ -135,6 +141,13 @@ describe('credentials', () => { createdAt: expect.any(Date), offerMessage: expect.any(Object), requestMessage: expect.any(Object), + metadata: { + data: { + indyCredential: { + credentialDefinitionId: credDefId, + }, + }, + }, state: CredentialState.Done, threadId: expect.any(String), }) @@ -178,7 +191,13 @@ describe('credentials', () => { createdAt: expect.any(Date), offerMessage: expect.any(Object), requestMessage: expect.any(Object), - metadata: { requestMetadata: expect.any(Object) }, + metadata: { + data: { + indyCredential: { + credentialDefinitionId: credDefId, + }, + }, + }, credentialId: expect.any(String), state: CredentialState.Done, threadId: expect.any(String), diff --git a/packages/core/tests/credentials-auto-accept.test.ts b/packages/core/tests/credentials-auto-accept.test.ts index b91a8db2a5..029419ba7d 100644 --- a/packages/core/tests/credentials-auto-accept.test.ts +++ b/packages/core/tests/credentials-auto-accept.test.ts @@ -73,9 +73,13 @@ describe('auto accept credentials', () => { offerMessage: expect.any(Object), requestMessage: expect.any(Object), metadata: { - requestMetadata: expect.any(Object), - schemaId, - credentialDefinitionId: credDefId, + data: { + indyRequest: expect.any(Object), + indyCredential: { + schemaId, + credentialDefinitionId: credDefId, + }, + }, }, credentialId: expect.any(String), state: CredentialState.Done, @@ -86,8 +90,12 @@ describe('auto accept credentials', () => { id: expect.any(String), createdAt: expect.any(Date), metadata: { - schemaId, - credentialDefinitionId: credDefId, + data: { + indyCredential: { + schemaId, + credentialDefinitionId: credDefId, + }, + }, }, offerMessage: expect.any(Object), requestMessage: expect.any(Object), @@ -121,7 +129,15 @@ describe('auto accept credentials', () => { createdAt: expect.any(Date), offerMessage: expect.any(Object), requestMessage: expect.any(Object), - metadata: { requestMetadata: expect.any(Object) }, + metadata: { + data: { + indyRequest: expect.any(Object), + indyCredential: { + schemaId, + credentialDefinitionId: credDefId, + }, + }, + }, credentialId: expect.any(String), state: CredentialState.Done, }) @@ -190,9 +206,13 @@ describe('auto accept credentials', () => { offerMessage: expect.any(Object), requestMessage: expect.any(Object), metadata: { - requestMetadata: expect.any(Object), - schemaId, - credentialDefinitionId: credDefId, + data: { + indyRequest: expect.any(Object), + indyCredential: { + schemaId, + credentialDefinitionId: credDefId, + }, + }, }, credentialId: expect.any(String), state: CredentialState.Done, @@ -203,8 +223,12 @@ describe('auto accept credentials', () => { id: expect.any(String), createdAt: expect.any(Date), metadata: { - schemaId, - credentialDefinitionId: credDefId, + data: { + indyCredential: { + schemaId, + credentialDefinitionId: credDefId, + }, + }, }, offerMessage: expect.any(Object), requestMessage: expect.any(Object), @@ -278,7 +302,15 @@ describe('auto accept credentials', () => { createdAt: expect.any(Date), offerMessage: expect.any(Object), requestMessage: expect.any(Object), - metadata: { requestMetadata: expect.any(Object) }, + metadata: { + data: { + indyRequest: expect.any(Object), + indyCredential: { + schemaId, + credentialDefinitionId: credDefId, + }, + }, + }, credentialId: expect.any(String), state: CredentialState.Done, }) diff --git a/packages/core/tests/credentials.test.ts b/packages/core/tests/credentials.test.ts index 6b1abf3be1..307e7446ac 100644 --- a/packages/core/tests/credentials.test.ts +++ b/packages/core/tests/credentials.test.ts @@ -18,14 +18,13 @@ describe('credentials', () => { let faberAgent: Agent let aliceAgent: Agent let credDefId: string - let schemaId: string let faberConnection: ConnectionRecord let aliceConnection: ConnectionRecord let faberCredentialRecord: CredentialRecord let aliceCredentialRecord: CredentialRecord beforeAll(async () => { - ;({ faberAgent, aliceAgent, credDefId, schemaId, faberConnection, aliceConnection } = await setupCredentialTests( + ;({ faberAgent, aliceAgent, credDefId, faberConnection, aliceConnection } = await setupCredentialTests( 'Faber Agent Credentials', 'Alice Agent Credential' )) @@ -134,11 +133,6 @@ describe('credentials', () => { connectionId: expect.any(String), offerMessage: expect.any(Object), requestMessage: expect.any(Object), - metadata: { - requestMetadata: expect.any(Object), - schemaId, - credentialDefinitionId: credDefId, - }, credentialId: expect.any(String), state: CredentialState.Done, }) @@ -149,10 +143,6 @@ describe('credentials', () => { createdAt: expect.any(Date), threadId: expect.any(String), connectionId: expect.any(String), - metadata: { - schemaId, - credentialDefinitionId: credDefId, - }, offerMessage: expect.any(Object), requestMessage: expect.any(Object), state: CredentialState.Done, @@ -241,7 +231,7 @@ describe('credentials', () => { createdAt: expect.any(Date), offerMessage: expect.any(Object), requestMessage: expect.any(Object), - metadata: { requestMetadata: expect.any(Object) }, + metadata: expect.any(Object), credentialId: expect.any(String), state: CredentialState.Done, threadId: expect.any(String), @@ -252,6 +242,7 @@ describe('credentials', () => { id: expect.any(String), createdAt: expect.any(Date), offerMessage: expect.any(Object), + metadata: expect.any(Object), requestMessage: expect.any(Object), state: CredentialState.Done, threadId: expect.any(String), @@ -364,13 +355,9 @@ describe('credentials', () => { type: CredentialRecord.name, id: expect.any(String), createdAt: expect.any(Date), + metadata: expect.any(Object), offerMessage: expect.any(Object), requestMessage: expect.any(Object), - metadata: { - requestMetadata: expect.any(Object), - schemaId, - credentialDefinitionId: credDefId, - }, credentialId: expect.any(String), state: CredentialState.Done, }) @@ -379,10 +366,7 @@ describe('credentials', () => { type: CredentialRecord.name, id: expect.any(String), createdAt: expect.any(Date), - metadata: { - schemaId, - credentialDefinitionId: credDefId, - }, + metadata: expect.any(Object), offerMessage: expect.any(Object), requestMessage: expect.any(Object), state: CredentialState.Done, @@ -485,7 +469,6 @@ describe('credentials', () => { id: expect.any(String), createdAt: expect.any(Date), requestMessage: expect.any(Object), - metadata: { requestMetadata: expect.any(Object) }, credentialId: expect.any(String), state: CredentialState.Done, })