diff --git a/apps/did-manager/src/dids/dids.service.ts b/apps/did-manager/src/dids/dids.service.ts index 80936bd8d6900c01a7272ea74c57d6bbf4c5e398..ebc44520d7027ea11f8ae87b3f9b53bc3762522c 100644 --- a/apps/did-manager/src/dids/dids.service.ts +++ b/apps/did-manager/src/dids/dids.service.ts @@ -35,18 +35,24 @@ export class DIDsService { seed: EventDidsRegisterIndyFromSeedInput['seed'], services?: Array<{ id: string; type: string; serviceEndpoint: string }>, ) { - const mappedServices: EventDidsRegisterIndyFromSeedInput['services'] = - services?.map(({ id, type, serviceEndpoint }) => ({ - identifier: id, - type, - url: serviceEndpoint, - })); + const data: EventDidsRegisterIndyFromSeedInput = { tenantId, seed }; + + if (services && services.length > 0) { + const mappedServices: EventDidsRegisterIndyFromSeedInput['services'] = + services?.map(({ id, type, serviceEndpoint }) => ({ + identifier: id, + type, + url: serviceEndpoint, + })); + + data.services = mappedServices; + } return this.natsClient .send< EventDidsRegisterIndyFromSeed, EventDidsRegisterIndyFromSeedInput - >(EventDidsRegisterIndyFromSeed.token, { tenantId, seed, services: mappedServices }) + >(EventDidsRegisterIndyFromSeed.token, data) .pipe(map(({ data }) => data)); } diff --git a/apps/did-manager/src/dids/dto/register-from-seed.dto.ts b/apps/did-manager/src/dids/dto/register-from-seed.dto.ts index 9d5effeb54dca741a46d4b7349fb60bf0c44b47c..eb90b1efafb0caae2ba77d835763ae7e2565eafc 100644 --- a/apps/did-manager/src/dids/dto/register-from-seed.dto.ts +++ b/apps/did-manager/src/dids/dto/register-from-seed.dto.ts @@ -1,6 +1,12 @@ import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; -import { IsArray, IsOptional, IsString, ValidateNested } from 'class-validator'; +import { + IsArray, + IsNotEmpty, + IsOptional, + IsString, + ValidateNested, +} from 'class-validator'; class Service { @IsString() @@ -34,6 +40,7 @@ export class RegisterFromSeedPayload { public seed: string; @IsArray() + @IsNotEmpty() @ValidateNested() @Type(() => Service) @IsOptional()