Skip to content

Commit

Permalink
fix: add supportRevocation (false by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
lotharking committed Dec 18, 2024
1 parent 1f67b82 commit 77ce73c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion examples/chatbot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const server = app.listen(PORT, async () => {
* id: randomUUID(),
* name: "phoneNumber",
* version: '1.0',
* attributes: ['phoneNumber']
* attributes: ['phoneNumber'],
* supportRevocation: true
* }))
*/
const credentialDefinition = (await apiClient.credentialTypes.import(phoneCredDefData))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ import { CreateCredentialTypeDto } from './CredentialTypeDto'
})
export class CredentialTypesController {
private readonly logger = new Logger(CredentialTypesController.name)
private readonly supportRevocation: boolean

constructor(private readonly agentService: AgentService) {
this.supportRevocation = process.env.SUPPORTING_REVOCATION === 'true'
}
constructor(private readonly agentService: AgentService) {}

/**
* Get all created credential types
Expand Down Expand Up @@ -137,7 +134,7 @@ export class CredentialTypesController {

const registrationResult = await agent.modules.anoncreds.registerCredentialDefinition({
credentialDefinition: { issuerId, schemaId, tag: `${options.name}.${options.version}` },
options: { supportRevocation: this.supportRevocation },
options: { supportRevocation: options.supportRevocation },
})

const credentialDefinitionId = registrationResult.credentialDefinitionState.credentialDefinitionId
Expand All @@ -152,7 +149,7 @@ export class CredentialTypesController {
}

let revocationRegistryDefinitionId
if (this.supportRevocation) {
if (options.supportRevocation) {
const revocationResult = await agent.modules.anoncreds.registerRevocationRegistryDefinition({
revocationRegistryDefinition: {
credentialDefinitionId,
Expand Down
12 changes: 11 additions & 1 deletion packages/main/src/controllers/credentials/CredentialTypeDto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger'
import { IsString, IsNotEmpty, IsOptional } from 'class-validator'
import { IsString, IsNotEmpty, IsOptional, IsBoolean } from 'class-validator'

export class CreateCredentialTypeDto {
@ApiProperty({
Expand Down Expand Up @@ -32,4 +32,14 @@ export class CreateCredentialTypeDto {
@IsOptional()
@IsNotEmpty()
schemaId?: string

@ApiProperty({
description: 'Indicates whether to enable credential revocation support. If enabled, it allows revocation of issued credentials.',
example: true,
default: false,
})
@IsBoolean()
@IsOptional()
@IsNotEmpty()
supportRevocation: boolean = false
}
1 change: 1 addition & 0 deletions packages/model/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface CreateCredentialTypeOptions {
attributes: string[]
schemaId?: string
revocationId?: string[]
supportRevocation?: boolean
}

type JsonObject = {
Expand Down

0 comments on commit 77ce73c

Please sign in to comment.