Skip to content

Commit

Permalink
fix(credentials): parse and validate preview @type (#861)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Jun 15, 2022
1 parent 58e6603 commit 1cc8f46
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { CredentialPreviewOptions } from '../../../models/CredentialPreviewAttribute'

import { Expose, Type } from 'class-transformer'
import { Equals, IsInstance, ValidateNested } from 'class-validator'
import { Expose, Transform, Type } from 'class-transformer'
import { IsInstance, ValidateNested } from 'class-validator'

import { JsonTransformer } from '../../../../../utils/JsonTransformer'
import { IsValidMessageType, parseMessageType, replaceLegacyDidSovPrefix } from '../../../../../utils/messageType'
import { CredentialPreviewAttribute } from '../../../models/CredentialPreviewAttribute'

/**
Expand All @@ -21,9 +22,12 @@ export class V2CredentialPreview {
}

@Expose({ name: '@type' })
@Equals(V2CredentialPreview.type)
public type = V2CredentialPreview.type
public static type = 'https://didcomm.org/issue-credential/2.0/credential-preview'
@IsValidMessageType(V2CredentialPreview.type)
@Transform(({ value }) => replaceLegacyDidSovPrefix(value), {
toClassOnly: true,
})
public readonly type = V2CredentialPreview.type.messageTypeUri
public static readonly type = parseMessageType('https://didcomm.org/issue-credential/2.0/credential-preview')

@Type(() => CredentialPreviewAttribute)
@ValidateNested({ each: true })
Expand Down

0 comments on commit 1cc8f46

Please sign in to comment.