Skip to content

Commit

Permalink
updated api path and updated dto
Browse files Browse the repository at this point in the history
  • Loading branch information
varsha766 committed Sep 19, 2024
1 parent 7461529 commit 2f62188
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
5 changes: 2 additions & 3 deletions src/did/controllers/did.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class DidController {
return this.didService.addVerificationMethod(addVm);
}

@Post('/sign')
@Post('/auth/sign')
@ApiOkResponse({
description: 'DidDocument is signed successfully',
type: SignedDidDocument,
Expand Down Expand Up @@ -254,7 +254,7 @@ export class DidController {
Logger.log('SignDidDocument() method: starts', 'DidController');
return this.didService.SignDidDocument(signDidDocDto, req.user);
}
@Post('/verify')
@Post('/auth/verify')
@ApiOkResponse({
description: 'DidDocument is verified successfully',
type: VerifyDidDocResponseDto,
Expand All @@ -275,7 +275,6 @@ export class DidController {
required: false,
})
@UsePipes(ValidationPipe)
@UsePipes(new AtLeastOneParamPipe(['did', 'didDocument']))
VerifyDidDocument(
@Headers('Authorization') authorization: string,
@Req() req: any,
Expand Down
30 changes: 4 additions & 26 deletions src/did/dto/verify-did.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,15 @@ import { ValidateVerificationMethodId } from 'src/utils/customDecorator/vmId.dec

export class VerifyDidDto {
@ApiProperty({
name: 'didDocument',
description: 'didDocument',
type: DidDoc,
name: 'signedDidDocument',
description: 'signedDidDocument',
type: SignedDidDocument,
})
@IsOptional()
@IsNotEmptyObject()
@Type(() => SignedDidDocument)
@ValidateNested({ each: true })
didDocument: SignedDidDocument;
@ApiProperty({
description: 'Verification Method id for did registration',
example: 'did:hid:testnet:........#key-${idx}',
required: true,
})
@ValidateVerificationMethodId()
@IsString()
@Matches(/^[a-zA-Z0-9\:]*testnet[a-zA-Z0-9\-:#]*$/, {
message: "Did's namespace should be testnet",
}) // this is to validate if did is generated using empty namespace
verificationMethodId: string;

@ApiProperty({
name: 'options',
description: 'optional parameter',
type: DidSignOption,
required: false,
})
@IsOptional()
@Type(() => DidSignOption)
@ValidateNested({ each: true })
options?: DidSignOption;
signedDidDocument: SignedDidDocument;
}

export class Controller {
Expand Down
13 changes: 7 additions & 6 deletions src/did/services/did.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,13 +826,14 @@ export class DidService {
appMenemonic,
namespace,
);
const purpose =
verifyDidDto?.options?.purpose || SupportedPurpose.assertionMethod;
const domain = verifyDidDto?.options?.domain;
const challenge = verifyDidDto?.options?.challenge;
const purpose = verifyDidDto.signedDidDocument.proof
.proofPurpose as SupportedPurpose;
const domain = verifyDidDto?.signedDidDocument.proof?.domain;
const challenge = verifyDidDto?.signedDidDocument.proof?.challenge;
const params = {
didDocument: verifyDidDto.didDocument,
verificationMethodId: verifyDidDto.verificationMethodId,
didDocument: verifyDidDto.signedDidDocument,
verificationMethodId:
verifyDidDto.signedDidDocument.proof.verificationMethod,
domain,
challenge,
purpose,
Expand Down

0 comments on commit 2f62188

Please sign in to comment.