diff --git a/apps/api-gateway/src/issuance/dtos/issuance.dto.ts b/apps/api-gateway/src/issuance/dtos/issuance.dto.ts index a295ee8b0..4b0a7c4fc 100644 --- a/apps/api-gateway/src/issuance/dtos/issuance.dto.ts +++ b/apps/api-gateway/src/issuance/dtos/issuance.dto.ts @@ -16,6 +16,26 @@ class Issuer { @Type(() => String) id: string | { id?: string }; } + +class PrettyVc { + @ApiPropertyOptional() + @IsOptional() + @Transform(({ value }) => trim(value)) + @IsString({ message: 'Certificate must be in string format.' }) + certificate: string; + + @ApiPropertyOptional({example: 'a4'}) + @IsOptional() + @Transform(({ value }) => trim(value)) + @IsString({ message: 'Size must be in string format.' }) + size: string; + + @ApiPropertyOptional({example: 'landscape'}) + @IsOptional() + @Transform(({ value }) => trim(value)) + @IsString({ message: 'orientation must be in string format.' }) + orientation: string; +} export class Credential { @ApiProperty() @IsNotEmpty({ message: 'context is required' }) @@ -32,8 +52,7 @@ export class Credential { @Type(() => String) @IsOptional() id?:string; - - + @ApiProperty() @ValidateNested({ each: true }) @Type(() => Issuer) @@ -45,6 +64,11 @@ export class Credential { @Type(() => String) issuanceDate:string; + @ApiPropertyOptional() + @IsOptional() + @Type(() => PrettyVc) + prettyVc?: PrettyVc; + @ApiProperty() @IsString({ message: 'expiration date should be string' }) @IsNotEmpty({ message: 'expiration date is required' }) @@ -52,10 +76,10 @@ export class Credential { @IsOptional() expirationDate?:string; - @ApiProperty() - @IsNotEmpty({ message: ' credential subject required' }) - credentialSubject: SingleOrArray; - [key: string]: unknown + @ApiProperty() + @IsNotEmpty({ message: ' credential subject required' }) + credentialSubject: SingleOrArray; + [key: string]: unknown } @@ -573,8 +597,7 @@ export class ClientDetails { userId?: string; - @ApiPropertyOptional({ example: 'https://example.com/logo.png' }) - @Transform(({ value }) => trim(value)) + @ApiProperty({ required: false, example: 'issue-data.csv' }) @IsOptional() @IsUrl( { diff --git a/apps/issuance/interfaces/issuance.interfaces.ts b/apps/issuance/interfaces/issuance.interfaces.ts index 5699f5b29..66c734cc5 100644 --- a/apps/issuance/interfaces/issuance.interfaces.ts +++ b/apps/issuance/interfaces/issuance.interfaces.ts @@ -141,15 +141,6 @@ export interface ICredential{ '@context':[]; type: string[]; prettyVc?: IPrettyVc; - issuer?: { - id: string; - }; - issuanceDate?: string; - credentialSubject?: ICredentialSubject; -} - -interface ICredentialSubject { - [key: string]: string; } export interface IOptions{ @@ -343,7 +334,6 @@ export interface IQueuePayload{ certificate?: string; size?: string; orientation?: string; - isReuseConnection?: boolean; } interface FileDetails { diff --git a/apps/issuance/src/issuance.service.ts b/apps/issuance/src/issuance.service.ts index a6c0d975a..462e0e3f5 100644 --- a/apps/issuance/src/issuance.service.ts +++ b/apps/issuance/src/issuance.service.ts @@ -1566,8 +1566,8 @@ return newCacheKey; schemaLedgerId, credentialData: jobDetails.credential_data, orgDid, - orgId, - isReuseConnection: true + orgId + }; prettyVc = { @@ -1578,7 +1578,6 @@ return newCacheKey; oobIssuancepayload = await createOobJsonldIssuancePayload(JsonldCredentialDetails, prettyVc); } - const oobCredentials = await this.outOfBandCredentialOffer( oobIssuancepayload, jobDetails?.platformName, jobDetails?.organizationLogoUrl, prettyVc); if (oobCredentials) { diff --git a/libs/common/src/cast.helper.ts b/libs/common/src/cast.helper.ts index f11532b05..4fe6a902f 100644 --- a/libs/common/src/cast.helper.ts +++ b/libs/common/src/cast.helper.ts @@ -1,4 +1,4 @@ -import { DidMethod, JSONSchemaType, ledgerLessDIDType, ProofType, schemaRequestType, TemplateIdentifier } from '@credebl/enum/enum'; +import { JSONSchemaType, ledgerLessDIDType, schemaRequestType, TemplateIdentifier } from '@credebl/enum/enum'; import { ISchemaFields } from './interfaces/schema.interface'; import { BadRequestException, PipeTransform } from '@nestjs/common'; import { plainToClass } from 'class-transformer'; @@ -12,7 +12,7 @@ import { registerDecorator } from 'class-validator'; import { ResponseMessages } from './response-messages'; -import { ICredentialData, IJsonldCredential, IPrettyVc } from './interfaces/issuance.interface'; +import { IJsonldCredential, IPrettyVc } from './interfaces/issuance.interface'; interface ToNumberOptions { default?: number; @@ -181,11 +181,9 @@ export const validateEmail = (email: string): boolean => { // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type export const createOobJsonldIssuancePayload = (JsonldCredentialDetails: IJsonldCredential, prettyVc: IPrettyVc) => { - const {credentialData, orgDid, orgId, schemaLedgerId, schemaName, isReuseConnection} = JsonldCredentialDetails; + const {credentialData, orgDid, orgId, schemaLedgerId, schemaName} = JsonldCredentialDetails; const credentialSubject = { }; - const proofType = (orgDid?.includes(DidMethod.POLYGON)) ? ProofType.POLYGON_PROOFTYPE : ProofType.NO_LEDGER_PROOFTYPE; - for (const key in credentialData) { if (credentialData.hasOwnProperty(key) && TemplateIdentifier.EMAIL_COLUMN !== key) { credentialSubject[key] = credentialData[key]; diff --git a/libs/prisma-service/prisma/schema.prisma b/libs/prisma-service/prisma/schema.prisma index 360144797..8eec4a21c 100644 --- a/libs/prisma-service/prisma/schema.prisma +++ b/libs/prisma-service/prisma/schema.prisma @@ -485,7 +485,7 @@ model file_upload { organisation organisation? @relation(fields: [orgId], references: [id]) orgId String? @db.Uuid credential_type String? - templateId String? @db.VarChar + templateId String? @db.VarChar } model file_data {