Skip to content

Commit

Permalink
feat: add CreateRevocationRegistryDto
Browse files Browse the repository at this point in the history
  • Loading branch information
lotharking committed Dec 18, 2024
1 parent ef96911 commit 93db6a3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/client/src/services/CredentialTypeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class CredentialTypeService {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(credentialType),
})
return ( await response.json()) as CredentialTypeInfo
return (await response.json()) as CredentialTypeInfo
}

public async getAll(): Promise<CredentialTypeInfo[]> {
Expand All @@ -65,9 +65,10 @@ export class CredentialTypeService {
}

public async createRevocation(credentialDefinitionId: string): Promise<string> {
const response = await fetch(`${this.url}/revoke/${credentialDefinitionId}`, {
const response = await fetch(`${this.url}/revoke`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ credentialDefinitionId }),
})
return response.text()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApiProperty } from '@nestjs/swagger'
import { IsString, IsNotEmpty } from 'class-validator'

export class CreateRevocationRegistryDto {
@ApiProperty({
description: 'credentialDefinitionId',
example: 'did:web',
})
@IsString()
@IsNotEmpty()
credentialDefinitionId!: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ApiBody, ApiTags } from '@nestjs/swagger'

import { AgentService } from '../../services/AgentService'

import { CreateRevocationRegistryDto } from './CreateRevocationRegistryDto'
import { CreateCredentialTypeDto } from './CredentialTypeDto'

@ApiTags('credential-types')
Expand Down Expand Up @@ -430,12 +431,11 @@ export class CredentialTypesController {
* @param credentialDefinitionId
* @returns RevocationTypeInfo
*/
@Post('/revoke/:credentialDefinitionId')
public async createRevocationRegistry(
@Param('credentialDefinitionId') credentialDefinitionId: string,
): Promise<string> {
@Post('/revoke')
public async createRevocationRegistry(@Body() options: CreateRevocationRegistryDto): Promise<string> {
try {
const agent = await this.agentService.getAgent()
const credentialDefinitionId = options.credentialDefinitionId

const cred = await agent.modules.anoncreds.getCredentialDefinition(credentialDefinitionId)

Expand Down

0 comments on commit 93db6a3

Please sign in to comment.