Skip to content
Snippets Groups Projects
Verified Commit 8ade6295 authored by Konstantin Tsabolov's avatar Konstantin Tsabolov
Browse files

fix(did-manager): fix did registration dto

parent 6e174621
No related branches found
No related tags found
1 merge request!40End to end run preparation
...@@ -33,13 +33,20 @@ export class DIDsService { ...@@ -33,13 +33,20 @@ export class DIDsService {
public registerFromSeed( public registerFromSeed(
tenantId: string, tenantId: string,
seed: EventDidsRegisterIndyFromSeedInput['seed'], seed: EventDidsRegisterIndyFromSeedInput['seed'],
services?: EventDidsRegisterIndyFromSeedInput['services'], services?: Array<{ id: string; type: string; serviceEndpoint: string }>,
) { ) {
const mappedServices: EventDidsRegisterIndyFromSeedInput['services'] =
services?.map(({ id, type, serviceEndpoint }) => ({
identifier: id,
type,
url: serviceEndpoint,
}));
return this.natsClient return this.natsClient
.send< .send<
EventDidsRegisterIndyFromSeed, EventDidsRegisterIndyFromSeed,
EventDidsRegisterIndyFromSeedInput EventDidsRegisterIndyFromSeedInput
>(EventDidsRegisterIndyFromSeed.token, { tenantId, seed, services }) >(EventDidsRegisterIndyFromSeed.token, { tenantId, seed, services: mappedServices })
.pipe(map(({ data }) => data)); .pipe(map(({ data }) => data));
} }
......
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsArray, IsOptional } from 'class-validator'; import { Type } from 'class-transformer';
import { IsArray, IsOptional, IsString, ValidateNested } from 'class-validator';
class Service {
@IsString()
@ApiProperty({
description: 'Service identifier',
example: 'did:example:123#linked-domain',
})
public id: string;
@IsString()
@ApiProperty({
description: 'Service Type',
example: 'LinkedDomains',
})
public type: string;
@IsString()
@ApiProperty({
description: 'Service Endpoint',
example: 'https://bar.example.com',
})
public serviceEndpoint: string;
}
export class RegisterFromSeedPayload { export class RegisterFromSeedPayload {
@IsString() @IsString()
...@@ -10,6 +34,8 @@ export class RegisterFromSeedPayload { ...@@ -10,6 +34,8 @@ export class RegisterFromSeedPayload {
public seed: string; public seed: string;
@IsArray() @IsArray()
@ValidateNested()
@Type(() => Service)
@IsOptional() @IsOptional()
@ApiProperty({ @ApiProperty({
description: 'Services to associate with DID', description: 'Services to associate with DID',
...@@ -21,9 +47,5 @@ export class RegisterFromSeedPayload { ...@@ -21,9 +47,5 @@ export class RegisterFromSeedPayload {
}, },
], ],
}) })
public services?: Array<{ public services?: Service[];
identifier: string;
url: string;
type: string;
}>;
} }
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