@@ -19,7 +19,11 @@ import type { AgentContext } from '@credo-ts/core'
19
19
import { CredoError , Hasher , JsonTransformer , TypedArrayEncoder , utils } from '@credo-ts/core'
20
20
21
21
import { CheqdDidResolver , CheqdDidRegistrar } from '../../dids'
22
- import { cheqdSdkAnonCredsRegistryIdentifierRegex , parseCheqdDid } from '../utils/identifiers'
22
+ import {
23
+ cheqdAnonCredsResourceTypes ,
24
+ cheqdSdkAnonCredsRegistryIdentifierRegex ,
25
+ parseCheqdDid ,
26
+ } from '../utils/identifiers'
23
27
import {
24
28
CheqdCredentialDefinition ,
25
29
CheqdRevocationRegistryDefinition ,
@@ -87,7 +91,7 @@ export class CheqdAnonCredsRegistry implements AnonCredsRegistry {
87
91
const schemaResource = {
88
92
id : utils . uuid ( ) ,
89
93
name : `${ schema . name } -Schema` ,
90
- resourceType : 'anonCredsSchema' ,
94
+ resourceType : cheqdAnonCredsResourceTypes . schema ,
91
95
data : {
92
96
name : schema . name ,
93
97
version : schema . version ,
@@ -145,7 +149,7 @@ export class CheqdAnonCredsRegistry implements AnonCredsRegistry {
145
149
const credDefResource = {
146
150
id : utils . uuid ( ) ,
147
151
name : TypedArrayEncoder . toHex ( credDefNameHashBuffer ) ,
148
- resourceType : 'anonCredsCredDef' ,
152
+ resourceType : cheqdAnonCredsResourceTypes . credentialDefinition ,
149
153
data : {
150
154
type : credentialDefinition . type ,
151
155
tag : credentialDefinition . tag ,
@@ -250,9 +254,9 @@ export class CheqdAnonCredsRegistry implements AnonCredsRegistry {
250
254
251
255
const searchDid = parsedDid . path
252
256
? revocationRegistryDefinitionId
253
- : `${ revocationRegistryDefinitionId } ${
254
- revocationRegistryDefinitionId . includes ( '?' ) ? '&' : '?'
255
- } resourceType=anonCredsRevocRegDef `
257
+ : `${ revocationRegistryDefinitionId } ${ revocationRegistryDefinitionId . includes ( '?' ) ? '&' : '?' } resourceType= ${
258
+ cheqdAnonCredsResourceTypes . revocationRegistryDefinition
259
+ } `
256
260
257
261
const response = await cheqdDidResolver . resolveResource ( agentContext , searchDid )
258
262
const revocationRegistryDefinition = JsonTransformer . fromJSON (
@@ -306,10 +310,13 @@ export class CheqdAnonCredsRegistry implements AnonCredsRegistry {
306
310
307
311
const cheqdDidRegistrar = agentContext . dependencyManager . resolve ( CheqdDidRegistrar )
308
312
313
+ const revocDefName = `${ credentialDefinitionName } -${ revocationRegistryDefinition . tag } `
314
+ const revocDefNameHashedBuffer = Hasher . hash ( revocDefName , 'sha-256' )
315
+
309
316
const revocationRegistryDefinitionResource = {
310
317
id : utils . uuid ( ) ,
311
- name : credentialDefinitionName as string ,
312
- resourceType : 'anonCredsRevocRegDef' ,
318
+ name : TypedArrayEncoder . toHex ( revocDefNameHashedBuffer ) ,
319
+ resourceType : cheqdAnonCredsResourceTypes . revocationRegistryDefinition ,
313
320
data : {
314
321
credDefId : revocationRegistryDefinition . credDefId ,
315
322
revocDefType : revocationRegistryDefinition . revocDefType ,
@@ -385,7 +392,7 @@ export class CheqdAnonCredsRegistry implements AnonCredsRegistry {
385
392
386
393
const response = await cheqdDidResolver . resolveResource (
387
394
agentContext ,
388
- `${ parsedDid . did } ?resourceType=anonCredsStatusList &resourceVersionTime=${ timestamp } &resourceName=${ revocationRegistryDefinitionName } `
395
+ `${ parsedDid . did } ?resourceType=${ cheqdAnonCredsResourceTypes . revocationStatusList } &resourceVersionTime=${ timestamp } &resourceName=${ revocationRegistryDefinitionName } `
389
396
)
390
397
391
398
const revocationStatusList = JsonTransformer . fromJSON ( response . resource , CheqdRevocationStatusList )
@@ -444,7 +451,7 @@ export class CheqdAnonCredsRegistry implements AnonCredsRegistry {
444
451
const revocationStatusListResource = {
445
452
id : utils . uuid ( ) ,
446
453
name : revocationRegistryDefinitionName as string ,
447
- resourceType : 'anonCredsStatusList' ,
454
+ resourceType : cheqdAnonCredsResourceTypes . revocationStatusList ,
448
455
data : {
449
456
currentAccumulator : revocationStatusList . currentAccumulator ,
450
457
revRegDefId : revocationStatusList . revRegDefId ,
0 commit comments