@credo-ts/cheqd 0.6.0-pr-2392-20251010173905 → 0.6.0-pr-2457-20251016083534

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/build/CheqdModule.d.mts +1 -1
  2. package/build/CheqdModule.d.mts.map +1 -1
  3. package/build/CheqdModule.d.ts +1 -1
  4. package/build/CheqdModule.d.ts.map +1 -1
  5. package/build/CheqdModule.mjs.map +1 -1
  6. package/build/anoncreds/services/CheqdAnonCredsRegistry.d.mts.map +1 -1
  7. package/build/anoncreds/services/CheqdAnonCredsRegistry.d.ts +1 -1
  8. package/build/anoncreds/services/CheqdAnonCredsRegistry.d.ts.map +1 -1
  9. package/build/anoncreds/services/CheqdAnonCredsRegistry.mjs.map +1 -1
  10. package/build/dids/CheqdDidRegistrar.d.mts +1 -1
  11. package/build/dids/CheqdDidRegistrar.d.mts.map +1 -1
  12. package/build/dids/CheqdDidRegistrar.d.ts +1 -1
  13. package/build/dids/CheqdDidRegistrar.d.ts.map +1 -1
  14. package/build/dids/CheqdDidRegistrar.js +2 -2
  15. package/build/dids/CheqdDidRegistrar.mjs +1 -1
  16. package/build/dids/CheqdDidRegistrar.mjs.map +1 -1
  17. package/build/dids/CheqdDidResolver.d.mts.map +1 -1
  18. package/build/dids/CheqdDidResolver.d.ts.map +1 -1
  19. package/build/dids/CheqdDidResolver.mjs.map +1 -1
  20. package/build/dids/didCheqdUtil.js +3 -3
  21. package/build/dids/didCheqdUtil.mjs +2 -2
  22. package/build/dids/didCheqdUtil.mjs.map +1 -1
  23. package/build/index.d.mts +2 -2
  24. package/build/index.d.ts +2 -2
  25. package/build/ledger/CheqdLedgerService.d.mts +1 -1
  26. package/build/ledger/CheqdLedgerService.d.mts.map +1 -1
  27. package/build/ledger/CheqdLedgerService.d.ts +2 -2
  28. package/build/ledger/CheqdLedgerService.d.ts.map +1 -1
  29. package/build/ledger/CheqdLedgerService.js +2 -2
  30. package/build/ledger/CheqdLedgerService.mjs +1 -1
  31. package/build/ledger/CheqdLedgerService.mjs.map +1 -1
  32. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
- import { CheqdModuleConfig, CheqdModuleConfigOptions } from "./CheqdModuleConfig.mjs";
2
1
  import { CheqdApi } from "./CheqdApi.mjs";
2
+ import { CheqdModuleConfig, CheqdModuleConfigOptions } from "./CheqdModuleConfig.mjs";
3
3
  import { AgentContext, DependencyManager, Module } from "@credo-ts/core";
4
4
 
5
5
  //#region src/CheqdModule.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdModule.d.mts","names":[],"sources":["../src/CheqdModule.ts"],"sourcesContent":[],"mappings":";;;;;cASa,WAAA,YAAuB;EAAvB,SAAA,MAAY,EACC,iBADD;EAAA,SAAA,GAAA,EAAA,OAEJ,QAFI;aACC,CAAA,MAAA,EAGG,wBAHH;UACL,CAAA,iBAAA,EAMgB,iBANhB,CAAA,EAAA,IAAA;YAEQ,CAAA,YAAA,EAuBW,YAvBX,CAAA,EAuB0B,OAvB1B,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"CheqdModule.d.mts","names":[],"sources":["../src/CheqdModule.ts"],"sourcesContent":[],"mappings":";;;;;cAOa,WAAA,YAAuB;EAAvB,SAAA,MAAY,EACC,iBADD;EAAA,SAAA,GAAA,EAAA,OAEJ,QAFI;aACC,CAAA,MAAA,EAGG,wBAHH;UACL,CAAA,iBAAA,EAMgB,iBANhB,CAAA,EAAA,IAAA;YAEQ,CAAA,YAAA,EAuBW,YAvBX,CAAA,EAuB0B,OAvB1B,CAAA,IAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import { CheqdModuleConfig, CheqdModuleConfigOptions } from "./CheqdModuleConfig.js";
2
1
  import { CheqdApi } from "./CheqdApi.js";
2
+ import { CheqdModuleConfig, CheqdModuleConfigOptions } from "./CheqdModuleConfig.js";
3
3
  import { AgentContext, DependencyManager, Module } from "@credo-ts/core";
4
4
 
5
5
  //#region src/CheqdModule.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdModule.d.ts","names":[],"sources":["../src/CheqdModule.ts"],"sourcesContent":[],"mappings":";;;;;cASa,WAAA,YAAuB;EAAvB,SAAA,MAAY,EACC,iBADD;EAAA,SAAA,GAAA,EAAA,OAEJ,QAFI;aACC,CAAA,MAAA,EAGG,wBAHH;UACL,CAAA,iBAAA,EAMgB,iBANhB,CAAA,EAAA,IAAA;YAEQ,CAAA,YAAA,EAuBW,YAvBX,CAAA,EAuB0B,OAvB1B,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"CheqdModule.d.ts","names":[],"sources":["../src/CheqdModule.ts"],"sourcesContent":[],"mappings":";;;;;cAOa,WAAA,YAAuB;EAAvB,SAAA,MAAY,EACC,iBADD;EAAA,SAAA,GAAA,EAAA,OAEJ,QAFI;aACC,CAAA,MAAA,EAGG,wBAHH;UACL,CAAA,iBAAA,EAMgB,iBANhB,CAAA,EAAA,IAAA;YAEQ,CAAA,YAAA,EAuBW,YAvBX,CAAA,EAuB0B,OAvB1B,CAAA,IAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdModule.mjs","names":[],"sources":["../src/CheqdModule.ts"],"sourcesContent":["import type { AgentContext, DependencyManager, Module } from '@credo-ts/core'\nimport type { CheqdModuleConfigOptions } from './CheqdModuleConfig'\n\nimport { AgentConfig, Buffer } from '@credo-ts/core'\n\nimport { CheqdApi } from './CheqdApi'\nimport { CheqdModuleConfig } from './CheqdModuleConfig'\nimport { CheqdLedgerService } from './ledger'\n\nexport class CheqdModule implements Module {\n public readonly config: CheqdModuleConfig\n public readonly api = CheqdApi\n\n public constructor(config: CheqdModuleConfigOptions) {\n this.config = new CheqdModuleConfig(config)\n }\n\n public register(dependencyManager: DependencyManager) {\n // Warn about experimental module\n dependencyManager\n .resolve(AgentConfig)\n .logger.warn(\n \"The '@credo-ts/cheqd' module is experimental and could have unexpected breaking changes. When using this module, make sure to use strict versions for all @credo-ts packages.\"\n )\n\n // Register config\n dependencyManager.registerInstance(CheqdModuleConfig, this.config)\n\n dependencyManager.registerSingleton(CheqdLedgerService)\n\n // Cheqd module needs Buffer to be available globally\n // If it is not available yet, we overwrite it with the\n // Buffer implementation from Credo\n global.Buffer = global.Buffer || Buffer\n }\n\n public async initialize(agentContext: AgentContext): Promise<void> {\n // not required\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n // We don't await it, as it impact startup time\n void cheqdLedgerService.connect()\n }\n}\n"],"mappings":";;;;;;;AASA,IAAa,cAAb,MAA2C;CAIzC,AAAO,YAAY,QAAkC;OAFrC,MAAM;AAGpB,OAAK,SAAS,IAAI,kBAAkB,OAAO;;CAG7C,AAAO,SAAS,mBAAsC;AAEpD,oBACG,QAAQ,YAAY,CACpB,OAAO,KACN,gLACD;AAGH,oBAAkB,iBAAiB,mBAAmB,KAAK,OAAO;AAElE,oBAAkB,kBAAkB,mBAAmB;AAKvD,SAAO,SAAS,OAAO,UAAU;;CAGnC,MAAa,WAAW,cAA2C;AAIjE,EAF2B,aAAa,kBAAkB,QAAQ,mBAAmB,CAE7D,SAAS"}
1
+ {"version":3,"file":"CheqdModule.mjs","names":[],"sources":["../src/CheqdModule.ts"],"sourcesContent":["import type { AgentContext, DependencyManager, Module } from '@credo-ts/core'\nimport { AgentConfig, Buffer } from '@credo-ts/core'\nimport { CheqdApi } from './CheqdApi'\nimport type { CheqdModuleConfigOptions } from './CheqdModuleConfig'\nimport { CheqdModuleConfig } from './CheqdModuleConfig'\nimport { CheqdLedgerService } from './ledger'\n\nexport class CheqdModule implements Module {\n public readonly config: CheqdModuleConfig\n public readonly api = CheqdApi\n\n public constructor(config: CheqdModuleConfigOptions) {\n this.config = new CheqdModuleConfig(config)\n }\n\n public register(dependencyManager: DependencyManager) {\n // Warn about experimental module\n dependencyManager\n .resolve(AgentConfig)\n .logger.warn(\n \"The '@credo-ts/cheqd' module is experimental and could have unexpected breaking changes. When using this module, make sure to use strict versions for all @credo-ts packages.\"\n )\n\n // Register config\n dependencyManager.registerInstance(CheqdModuleConfig, this.config)\n\n dependencyManager.registerSingleton(CheqdLedgerService)\n\n // Cheqd module needs Buffer to be available globally\n // If it is not available yet, we overwrite it with the\n // Buffer implementation from Credo\n global.Buffer = global.Buffer || Buffer\n }\n\n public async initialize(agentContext: AgentContext): Promise<void> {\n // not required\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n // We don't await it, as it impact startup time\n void cheqdLedgerService.connect()\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,cAAb,MAA2C;CAIzC,AAAO,YAAY,QAAkC;OAFrC,MAAM;AAGpB,OAAK,SAAS,IAAI,kBAAkB,OAAO;;CAG7C,AAAO,SAAS,mBAAsC;AAEpD,oBACG,QAAQ,YAAY,CACpB,OAAO,KACN,gLACD;AAGH,oBAAkB,iBAAiB,mBAAmB,KAAK,OAAO;AAElE,oBAAkB,kBAAkB,mBAAmB;AAKvD,SAAO,SAAS,OAAO,UAAU;;CAGnC,MAAa,WAAW,cAA2C;AAIjE,EAF2B,aAAa,kBAAkB,QAAQ,mBAAmB,CAE7D,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdAnonCredsRegistry.d.mts","names":[],"sources":["../../../src/anoncreds/services/CheqdAnonCredsRegistry.ts"],"sourcesContent":[],"mappings":";;;;cAiCa,sBAAA,YAAkC;;EAAlC;;;;;WAU2D,mBAAA,EAFnC,MAEmC;WAwCtD,CAAA,YAAA,EAxCqB,YAwCrB,EAAA,QAAA,EAAA,MAAA,CAAA,EAxCsD,OAwCtD,CAxC8D,eAwC9D,CAAA;gBACL,CAAA,YAAA,EADK,YACL,EAAA,OAAA,EAAA,qBAAA,CAAA,EACR,OADQ,CACA,oBADA,CAAA;8BACA,CAAA,YAAA,EAmDK,YAnDL,EAAA,OAAA,EAoDA,mCApDA,CAAA,EAqDR,OArDQ,CAqDA,kCArDA,CAAA;yBAAR,CAAA,YAAA,EAoHa,YApHb,EAAA,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;sCACL,CAAA,YAAA,EA8JK,YA9JL,EAAA;IAAA,4BAAA;IAAA;EAAA,CAAA,EA+JkC,2CA/JlC,CAAA,EAgKR,OAhKQ,CAgKA,0CAhKA,CAAA;yBACA,CAAA,YAAA,EAsOK,YAtOL,EAAA,oBAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,CAAA,EAyOR,OAzOQ,CAyOA,6BAzOA,CAAA;8BAAR,CAAA,YAAA,EAqSa,YArSb,EAAA;IAAA,oBAAA;IAAA;EAAA,CAAA,EAsSkC,mCAtSlC,CAAA,EAuSA,OAvSA,CAuSQ,kCAvSR,CAAA"}
@@ -1,5 +1,5 @@
1
- import { AgentContext } from "@credo-ts/core";
2
1
  import { AnonCredsRegistry, GetCredentialDefinitionReturn, GetRevocationRegistryDefinitionReturn, GetRevocationStatusListReturn, GetSchemaReturn, RegisterCredentialDefinitionOptions, RegisterCredentialDefinitionReturn, RegisterRevocationRegistryDefinitionOptions, RegisterRevocationRegistryDefinitionReturn, RegisterRevocationStatusListOptions, RegisterRevocationStatusListReturn, RegisterSchemaOptions, RegisterSchemaReturn } from "@credo-ts/anoncreds";
2
+ import { AgentContext } from "@credo-ts/core";
3
3
 
4
4
  //#region src/anoncreds/services/CheqdAnonCredsRegistry.d.ts
5
5
  declare class CheqdAnonCredsRegistry implements AnonCredsRegistry {
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdAnonCredsRegistry.d.ts","names":[],"sources":["../../../src/anoncreds/services/CheqdAnonCredsRegistry.ts"],"sourcesContent":[],"mappings":";;;;cAiCa,sBAAA,YAAkC;;EAAlC;;;;;WAU2D,mBAAA,EAFnC,MAEmC;WAwCtD,CAAA,YAAA,EAxCqB,YAwCrB,EAAA,QAAA,EAAA,MAAA,CAAA,EAxCsD,OAwCtD,CAxC8D,eAwC9D,CAAA;gBACL,CAAA,YAAA,EADK,YACL,EAAA,OAAA,EAAA,qBAAA,CAAA,EACR,OADQ,CACA,oBADA,CAAA;8BACA,CAAA,YAA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HQ,6BAtHR,CAAA;iCAmDa,CAAA,YAAA,EA0GA,YA1GA,EAAA,8BAAA,EAAA,MAAA,CAAA,EA4Gb,OA5Ga,CA4GL,qCA5GK,CAAA;sCACL,CAAA,YAAA,EA8JK,YA9JL,EAAA;IAAA,4BAAA;IAAA;EAAA,CAAA,EA+JkC,2CA/JlC,CAAA,EAgKR,OAhKQ,CAgKA,0CAhKA,CAAA;yBACA,CAAA,YAAA,EAsOK,YAtOL,EAAA,oBAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,CAAA,EAyOR,OAzOQ,CAyOA,6BAzOA,CAAA;8BAAR,CAAA,YAAA,EAqSa,YArSb,EAAA;IAAA,oBAAA;IAAA;EAAA,CAAA,EAsSkC,mCAtSlC,CAAA,EAuSA,OAvSA,CAuSQ,kCAvSR,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdAnonCredsRegistry.mjs","names":[],"sources":["../../../src/anoncreds/services/CheqdAnonCredsRegistry.ts"],"sourcesContent":["import type {\n AnonCredsRegistry,\n GetCredentialDefinitionReturn,\n GetRevocationRegistryDefinitionReturn,\n GetRevocationStatusListReturn,\n GetSchemaReturn,\n RegisterCredentialDefinitionOptions,\n RegisterCredentialDefinitionReturn,\n RegisterRevocationRegistryDefinitionOptions,\n RegisterRevocationRegistryDefinitionReturn,\n RegisterRevocationStatusListOptions,\n RegisterRevocationStatusListReturn,\n RegisterSchemaOptions,\n RegisterSchemaReturn,\n} from '@credo-ts/anoncreds'\nimport type { AgentContext } from '@credo-ts/core'\nimport type { CheqdCreateResourceOptions } from '../../dids'\n\nimport { CredoError, Hasher, JsonTransformer, TypedArrayEncoder, utils } from '@credo-ts/core'\n\nimport { CheqdDidRegistrar, CheqdDidResolver } from '../../dids'\nimport {\n cheqdAnonCredsResourceTypes,\n cheqdSdkAnonCredsRegistryIdentifierRegex,\n parseCheqdDid,\n} from '../utils/identifiers'\nimport {\n CheqdCredentialDefinition,\n CheqdRevocationRegistryDefinition,\n CheqdRevocationStatusList,\n CheqdSchema,\n} from '../utils/transform'\n\nexport class CheqdAnonCredsRegistry implements AnonCredsRegistry {\n public methodName = 'cheqd'\n\n /**\n * This class supports resolving and registering objects with cheqd identifiers.\n * It needs to include support for the schema, credential definition, revocation registry as well\n * as the issuer id (which is needed when registering objects).\n */\n public readonly supportedIdentifier = cheqdSdkAnonCredsRegistryIdentifierRegex\n\n public async getSchema(agentContext: AgentContext, schemaId: string): Promise<GetSchemaReturn> {\n try {\n const cheqdDidResolver = agentContext.dependencyManager.resolve(CheqdDidResolver)\n const parsedDid = parseCheqdDid(schemaId)\n if (!parsedDid) throw new CredoError(`Invalid schemaId: ${schemaId}`)\n\n agentContext.config.logger.trace(`Submitting get schema request for schema '${schemaId}' to ledger`)\n\n const response = await cheqdDidResolver.resolveResource(agentContext, schemaId)\n const schema = JsonTransformer.fromJSON(response.resource, CheqdSchema)\n\n return {\n schema: {\n attrNames: schema.attrNames,\n name: schema.name,\n version: schema.version,\n issuerId: parsedDid.did,\n },\n schemaId,\n resolutionMetadata: {},\n schemaMetadata: {},\n }\n } catch (error) {\n agentContext.config.logger.error(`Error retrieving schema '${schemaId}'`, {\n error,\n schemaId,\n })\n\n return {\n schemaId,\n resolutionMetadata: {\n error: 'notFound',\n message: `unable to resolve schema: ${error.message}`,\n },\n schemaMetadata: {},\n }\n }\n }\n\n public async registerSchema(\n agentContext: AgentContext,\n options: RegisterSchemaOptions\n ): Promise<RegisterSchemaReturn> {\n try {\n const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)\n\n const schema = options.schema\n const schemaResource = {\n id: utils.uuid(),\n name: `${schema.name}-Schema`,\n resourceType: cheqdAnonCredsResourceTypes.schema,\n data: {\n name: schema.name,\n version: schema.version,\n attrNames: schema.attrNames,\n },\n version: schema.version,\n } satisfies CheqdCreateResourceOptions\n\n const response = await cheqdDidRegistrar.createResource(agentContext, schema.issuerId, schemaResource)\n if (response.resourceState.state !== 'finished') {\n throw new CredoError(response.resourceState.reason ?? 'Unknown error')\n }\n\n return {\n schemaState: {\n state: 'finished',\n schema,\n schemaId: `${schema.issuerId}/resources/${schemaResource.id}`,\n },\n registrationMetadata: {},\n schemaMetadata: {},\n }\n } catch (error) {\n agentContext.config.logger.debug(`Error registering schema for did '${options.schema.issuerId}'`, {\n error,\n did: options.schema.issuerId,\n schema: options,\n })\n\n return {\n schemaMetadata: {},\n registrationMetadata: {},\n schemaState: {\n state: 'failed',\n schema: options.schema,\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async registerCredentialDefinition(\n agentContext: AgentContext,\n options: RegisterCredentialDefinitionOptions\n ): Promise<RegisterCredentialDefinitionReturn> {\n try {\n const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)\n const { credentialDefinition } = options\n const schema = await this.getSchema(agentContext, credentialDefinition.schemaId)\n if (!schema.schema) throw new CredoError(`Schema not found for schemaId: ${credentialDefinition.schemaId}`)\n\n const credDefName = `${schema.schema.name}-${credentialDefinition.tag}`\n const credDefNameHashBuffer = Hasher.hash(credDefName, 'sha-256')\n\n const credDefResource = {\n id: utils.uuid(),\n name: TypedArrayEncoder.toHex(credDefNameHashBuffer),\n resourceType: cheqdAnonCredsResourceTypes.credentialDefinition,\n data: {\n type: credentialDefinition.type,\n tag: credentialDefinition.tag,\n value: credentialDefinition.value,\n schemaId: credentialDefinition.schemaId,\n },\n version: utils.uuid(),\n } satisfies CheqdCreateResourceOptions\n\n const response = await cheqdDidRegistrar.createResource(\n agentContext,\n credentialDefinition.issuerId,\n credDefResource\n )\n if (response.resourceState.state !== 'finished')\n throw new CredoError(response.resourceState.reason ?? 'Unknown error')\n\n return {\n credentialDefinitionState: {\n state: 'finished',\n credentialDefinition,\n credentialDefinitionId: `${credentialDefinition.issuerId}/resources/${credDefResource.id}`,\n },\n registrationMetadata: {},\n credentialDefinitionMetadata: {},\n }\n } catch (error) {\n agentContext.config.logger.error(\n `Error registering credential definition for did '${options.credentialDefinition.issuerId}'`,\n {\n error,\n did: options.credentialDefinition.issuerId,\n schema: options,\n }\n )\n\n return {\n credentialDefinitionMetadata: {},\n registrationMetadata: {},\n credentialDefinitionState: {\n state: 'failed',\n credentialDefinition: options.credentialDefinition,\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async getCredentialDefinition(\n agentContext: AgentContext,\n credentialDefinitionId: string\n ): Promise<GetCredentialDefinitionReturn> {\n try {\n const cheqdDidResolver = agentContext.dependencyManager.resolve(CheqdDidResolver)\n const parsedDid = parseCheqdDid(credentialDefinitionId)\n if (!parsedDid) throw new CredoError(`Invalid credentialDefinitionId: ${credentialDefinitionId}`)\n\n agentContext.config.logger.trace(\n `Submitting get credential definition request for '${credentialDefinitionId}' to ledger`\n )\n\n const response = await cheqdDidResolver.resolveResource(agentContext, credentialDefinitionId)\n const credentialDefinition = JsonTransformer.fromJSON(response.resource, CheqdCredentialDefinition)\n return {\n credentialDefinition: {\n ...credentialDefinition,\n issuerId: parsedDid.did,\n },\n credentialDefinitionId,\n resolutionMetadata: {},\n credentialDefinitionMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(`Error retrieving credential definition '${credentialDefinitionId}'`, {\n error,\n credentialDefinitionId,\n })\n\n return {\n credentialDefinitionId,\n resolutionMetadata: {\n error: 'notFound',\n message: `unable to resolve credential definition: ${error.message}`,\n },\n credentialDefinitionMetadata: {},\n }\n }\n }\n\n public async getRevocationRegistryDefinition(\n agentContext: AgentContext,\n revocationRegistryDefinitionId: string\n ): Promise<GetRevocationRegistryDefinitionReturn> {\n try {\n const cheqdDidResolver = agentContext.dependencyManager.resolve(CheqdDidResolver)\n const parsedDid = parseCheqdDid(revocationRegistryDefinitionId)\n if (!parsedDid) throw new CredoError(`Invalid revocationRegistryDefinitionId: ${revocationRegistryDefinitionId}`)\n\n agentContext.config.logger.trace(\n `Submitting get revocation registry definition request for '${revocationRegistryDefinitionId}' to ledger`\n )\n\n const searchDid = parsedDid.path\n ? revocationRegistryDefinitionId\n : `${revocationRegistryDefinitionId}${revocationRegistryDefinitionId.includes('?') ? '&' : '?'}resourceType=${\n cheqdAnonCredsResourceTypes.revocationRegistryDefinition\n }`\n\n const response = await cheqdDidResolver.resolveResource(agentContext, searchDid)\n const revocationRegistryDefinition = JsonTransformer.fromJSON(\n response.resource,\n CheqdRevocationRegistryDefinition\n )\n return {\n revocationRegistryDefinition: {\n ...revocationRegistryDefinition,\n issuerId: parsedDid.did,\n },\n revocationRegistryDefinitionId,\n resolutionMetadata: {},\n revocationRegistryDefinitionMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(\n `Error retrieving revocation registry definition '${revocationRegistryDefinitionId}'`,\n {\n error,\n revocationRegistryDefinitionId,\n }\n )\n\n return {\n revocationRegistryDefinitionId,\n resolutionMetadata: {\n error: 'notFound',\n message: `unable to resolve revocation registry definition: ${error.message}`,\n },\n revocationRegistryDefinitionMetadata: {},\n }\n }\n }\n\n public async registerRevocationRegistryDefinition(\n agentContext: AgentContext,\n { revocationRegistryDefinition, options }: RegisterRevocationRegistryDefinitionOptions\n ): Promise<RegisterRevocationRegistryDefinitionReturn> {\n try {\n const credentialDefinition = await this.getCredentialDefinition(\n agentContext,\n revocationRegistryDefinition.credDefId\n )\n if (!credentialDefinition.credentialDefinition)\n throw new CredoError(`Credential definition not found for id: ${revocationRegistryDefinition.credDefId}`)\n\n const credentialDefinitionName = credentialDefinition.credentialDefinitionMetadata.name\n if (!credentialDefinitionName)\n throw new CredoError(`Credential definition name not found for id: ${revocationRegistryDefinition.credDefId}`)\n\n const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)\n\n const revocDefName = `${credentialDefinitionName}-${revocationRegistryDefinition.tag}`\n const revocDefNameHashedBuffer = Hasher.hash(revocDefName, 'sha-256')\n\n const revocationRegistryDefinitionResource = {\n id: utils.uuid(),\n name: TypedArrayEncoder.toHex(revocDefNameHashedBuffer),\n resourceType: cheqdAnonCredsResourceTypes.revocationRegistryDefinition,\n data: {\n credDefId: revocationRegistryDefinition.credDefId,\n revocDefType: revocationRegistryDefinition.revocDefType,\n tag: revocationRegistryDefinition.tag,\n value: revocationRegistryDefinition.value,\n },\n version: utils.uuid(),\n } satisfies CheqdCreateResourceOptions\n\n const response = await cheqdDidRegistrar.createResource(\n agentContext,\n revocationRegistryDefinition.issuerId,\n revocationRegistryDefinitionResource\n )\n if (response.resourceState.state !== 'finished')\n throw new CredoError(response.resourceState.reason ?? 'Unknown error')\n\n return {\n revocationRegistryDefinitionState: {\n state: 'finished',\n revocationRegistryDefinition,\n revocationRegistryDefinitionId: `${revocationRegistryDefinition.issuerId}/resources/${revocationRegistryDefinitionResource.id}`,\n },\n registrationMetadata: {},\n revocationRegistryDefinitionMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(\n `Error registering revocation registry definition for did '${revocationRegistryDefinition.issuerId}'`,\n {\n error,\n did: revocationRegistryDefinition.issuerId,\n options,\n }\n )\n\n return {\n revocationRegistryDefinitionMetadata: {},\n registrationMetadata: {},\n revocationRegistryDefinitionState: {\n state: 'failed',\n revocationRegistryDefinition,\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async getRevocationStatusList(\n agentContext: AgentContext,\n revocationRegistryId: string,\n timestamp: number\n ): Promise<GetRevocationStatusListReturn> {\n try {\n const cheqdDidResolver = agentContext.dependencyManager.resolve(CheqdDidResolver)\n const parsedDid = parseCheqdDid(revocationRegistryId)\n if (!parsedDid) throw new CredoError(`Invalid revocationRegistryId: ${revocationRegistryId}`)\n\n agentContext.config.logger.trace(\n `Submitting get revocation status request for '${revocationRegistryId}' to ledger`\n )\n\n const revocationRegistryDefinition = await this.getRevocationRegistryDefinition(\n agentContext,\n revocationRegistryId\n )\n if (!revocationRegistryDefinition.revocationRegistryDefinition)\n throw new CredoError(`Revocation registry definition not found for id: ${revocationRegistryId}`)\n\n const revocationRegistryDefinitionName = revocationRegistryDefinition.revocationRegistryDefinitionMetadata.name\n if (!revocationRegistryDefinitionName)\n throw new CredoError(`Revocation registry definition name not found for id: ${revocationRegistryId}`)\n\n const response = await cheqdDidResolver.resolveResource(\n agentContext,\n `${parsedDid.did}?resourceType=${cheqdAnonCredsResourceTypes.revocationStatusList}&resourceVersionTime=${timestamp}&resourceName=${revocationRegistryDefinitionName}`\n )\n\n const revocationStatusList = JsonTransformer.fromJSON(response.resource, CheqdRevocationStatusList)\n\n const statusListTimestamp = response.resourceMetadata?.created\n ? Math.floor(response.resourceMetadata.created.getTime() / 1000)\n : undefined\n if (statusListTimestamp === undefined)\n throw new CredoError(`Unable to extract revocation status list timestamp from resource ${revocationRegistryId}`)\n\n return {\n revocationStatusList: {\n ...revocationStatusList,\n issuerId: parsedDid.did,\n timestamp: statusListTimestamp,\n },\n resolutionMetadata: {},\n revocationStatusListMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(`Error retrieving revocation registry status list '${revocationRegistryId}'`, {\n error,\n revocationRegistryId,\n })\n\n return {\n resolutionMetadata: {\n error: 'notFound',\n message: `unable to resolve revocation registry status list: ${error.message}`,\n },\n revocationStatusListMetadata: {},\n }\n }\n }\n\n public async registerRevocationStatusList(\n agentContext: AgentContext,\n { revocationStatusList, options }: RegisterRevocationStatusListOptions\n ): Promise<RegisterRevocationStatusListReturn> {\n try {\n const revocationRegistryDefinition = await this.getRevocationRegistryDefinition(\n agentContext,\n revocationStatusList.revRegDefId\n )\n if (!revocationRegistryDefinition.revocationRegistryDefinition) {\n throw new CredoError(`Revocation registry definition not found for id: ${revocationStatusList.revRegDefId}`)\n }\n\n const revocationRegistryDefinitionName = revocationRegistryDefinition.revocationRegistryDefinitionMetadata.name\n if (!revocationRegistryDefinitionName)\n throw new CredoError(\n `Revocation registry definition name not found for id: ${revocationStatusList.revRegDefId}`\n )\n\n const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)\n const revocationStatusListResource = {\n id: utils.uuid(),\n name: revocationRegistryDefinitionName as string,\n resourceType: cheqdAnonCredsResourceTypes.revocationStatusList,\n data: {\n currentAccumulator: revocationStatusList.currentAccumulator,\n revRegDefId: revocationStatusList.revRegDefId,\n revocationList: revocationStatusList.revocationList,\n },\n version: utils.uuid(),\n } satisfies CheqdCreateResourceOptions\n\n const response = await cheqdDidRegistrar.createResource(\n agentContext,\n revocationStatusList.issuerId,\n revocationStatusListResource\n )\n if (response.resourceState.state !== 'finished')\n throw new CredoError(response.resourceState.reason ?? 'Unknown error')\n\n // It's not possible to get the timestamp from the response, so we set it to the current time\n const nowTimestamp = Math.floor(Date.now() / 1000)\n\n return {\n revocationStatusListState: {\n state: 'finished',\n revocationStatusList: {\n ...revocationStatusList,\n timestamp: nowTimestamp,\n },\n },\n registrationMetadata: {},\n revocationStatusListMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(\n `Error registering revocation status list for did '${revocationStatusList.issuerId}'`,\n {\n error,\n did: revocationStatusList.issuerId,\n options,\n }\n )\n\n return {\n revocationStatusListMetadata: {},\n registrationMetadata: {},\n revocationStatusListState: {\n state: 'failed',\n revocationStatusList,\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n}\n"],"mappings":";;;;;;;;AAiCA,IAAa,yBAAb,MAAiE;;OACxD,aAAa;OAOJ,sBAAsB;;CAEtC,MAAa,UAAU,cAA4B,UAA4C;AAC7F,MAAI;GACF,MAAM,mBAAmB,aAAa,kBAAkB,QAAQ,iBAAiB;GACjF,MAAM,YAAY,cAAc,SAAS;AACzC,OAAI,CAAC,UAAW,OAAM,IAAI,WAAW,qBAAqB,WAAW;AAErE,gBAAa,OAAO,OAAO,MAAM,6CAA6C,SAAS,aAAa;GAEpG,MAAM,WAAW,MAAM,iBAAiB,gBAAgB,cAAc,SAAS;GAC/E,MAAM,SAAS,gBAAg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YACtB;AACD,OAAI,CAAC,6BAA6B,6BAChC,OAAM,IAAI,WAAW,oDAAoD,qBAAqB,cAAc;GAG9G,MAAM,mCAAmC,6BAA6B,qCAAqC;AAC3G,OAAI,CAAC,iCACH,OAAM,IAAI,WACR,yDAAyD,qBAAqB,cAC/E;GAEH,MAAM,oBAAoB,aAAa,kBAAkB,QAAQ,kBAAkB;GACnF,MAAM,+BAA+B;IACnC,IAAI,MAAM,MAAM;IAChB,MAAM;IACN,cAAc,4BAA4B;IAC1C,MAAM;KACJ,oBAAoB,qBAAqB;KACzC,aAAa,qBAAqB;KAClC,gBAAgB,qBAAqB;KACtC;IACD,SAAS,MAAM,MAAM;IACtB;GAED,MAAM,WAAW,MAAM,kBAAkB,eACvC,cACA,qBAAqB,UACrB,6BACD;AACD,OAAI,SAAS,cAAc,UAAU,WACnC,OAAM,IAAI,WAAW,SAAS,cAAc,UAAU,gBAAgB;GAGxE,MAAM,eAAe,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;AAElD,UAAO;IACL,2BAA2B;KACzB,OAAO;KACP,sBAAsB;MACpB,GAAG;MACH,WAAW;MACZ;KACF;IACD,sBAAsB,EAAE;IACxB,8BAA+B,SAAS,oBAAoB,EAAE;IAC/D;WACM,OAAO;AACd,gBAAa,OAAO,OAAO,MACzB,qDAAqD,qBAAqB,SAAS,IACnF;IACE;IACA,KAAK,qBAAqB;IAC1B;IACD,CACF;AAED,UAAO;IACL,8BAA8B,EAAE;IAChC,sBAAsB,EAAE;IACxB,2BAA2B;KACzB,OAAO;KACP;KACA,QAAQ,iBAAiB,MAAM;KAChC;IACF"}
1
+ {"version":3,"file":"CheqdAnonCredsRegistry.mjs","names":[],"sources":["../../../src/anoncreds/services/CheqdAnonCredsRegistry.ts"],"sourcesContent":["import type {\n AnonCredsRegistry,\n GetCredentialDefinitionReturn,\n GetRevocationRegistryDefinitionReturn,\n GetRevocationStatusListReturn,\n GetSchemaReturn,\n RegisterCredentialDefinitionOptions,\n RegisterCredentialDefinitionReturn,\n RegisterRevocationRegistryDefinitionOptions,\n RegisterRevocationRegistryDefinitionReturn,\n RegisterRevocationStatusListOptions,\n RegisterRevocationStatusListReturn,\n RegisterSchemaOptions,\n RegisterSchemaReturn,\n} from '@credo-ts/anoncreds'\nimport type { AgentContext } from '@credo-ts/core'\nimport { CredoError, Hasher, JsonTransformer, TypedArrayEncoder, utils } from '@credo-ts/core'\nimport type { CheqdCreateResourceOptions } from '../../dids'\n\nimport { CheqdDidRegistrar, CheqdDidResolver } from '../../dids'\nimport {\n cheqdAnonCredsResourceTypes,\n cheqdSdkAnonCredsRegistryIdentifierRegex,\n parseCheqdDid,\n} from '../utils/identifiers'\nimport {\n CheqdCredentialDefinition,\n CheqdRevocationRegistryDefinition,\n CheqdRevocationStatusList,\n CheqdSchema,\n} from '../utils/transform'\n\nexport class CheqdAnonCredsRegistry implements AnonCredsRegistry {\n public methodName = 'cheqd'\n\n /**\n * This class supports resolving and registering objects with cheqd identifiers.\n * It needs to include support for the schema, credential definition, revocation registry as well\n * as the issuer id (which is needed when registering objects).\n */\n public readonly supportedIdentifier = cheqdSdkAnonCredsRegistryIdentifierRegex\n\n public async getSchema(agentContext: AgentContext, schemaId: string): Promise<GetSchemaReturn> {\n try {\n const cheqdDidResolver = agentContext.dependencyManager.resolve(CheqdDidResolver)\n const parsedDid = parseCheqdDid(schemaId)\n if (!parsedDid) throw new CredoError(`Invalid schemaId: ${schemaId}`)\n\n agentContext.config.logger.trace(`Submitting get schema request for schema '${schemaId}' to ledger`)\n\n const response = await cheqdDidResolver.resolveResource(agentContext, schemaId)\n const schema = JsonTransformer.fromJSON(response.resource, CheqdSchema)\n\n return {\n schema: {\n attrNames: schema.attrNames,\n name: schema.name,\n version: schema.version,\n issuerId: parsedDid.did,\n },\n schemaId,\n resolutionMetadata: {},\n schemaMetadata: {},\n }\n } catch (error) {\n agentContext.config.logger.error(`Error retrieving schema '${schemaId}'`, {\n error,\n schemaId,\n })\n\n return {\n schemaId,\n resolutionMetadata: {\n error: 'notFound',\n message: `unable to resolve schema: ${error.message}`,\n },\n schemaMetadata: {},\n }\n }\n }\n\n public async registerSchema(\n agentContext: AgentContext,\n options: RegisterSchemaOptions\n ): Promise<RegisterSchemaReturn> {\n try {\n const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)\n\n const schema = options.schema\n const schemaResource = {\n id: utils.uuid(),\n name: `${schema.name}-Schema`,\n resourceType: cheqdAnonCredsResourceTypes.schema,\n data: {\n name: schema.name,\n version: schema.version,\n attrNames: schema.attrNames,\n },\n version: schema.version,\n } satisfies CheqdCreateResourceOptions\n\n const response = await cheqdDidRegistrar.createResource(agentContext, schema.issuerId, schemaResource)\n if (response.resourceState.state !== 'finished') {\n throw new CredoError(response.resourceState.reason ?? 'Unknown error')\n }\n\n return {\n schemaState: {\n state: 'finished',\n schema,\n schemaId: `${schema.issuerId}/resources/${schemaResource.id}`,\n },\n registrationMetadata: {},\n schemaMetadata: {},\n }\n } catch (error) {\n agentContext.config.logger.debug(`Error registering schema for did '${options.schema.issuerId}'`, {\n error,\n did: options.schema.issuerId,\n schema: options,\n })\n\n return {\n schemaMetadata: {},\n registrationMetadata: {},\n schemaState: {\n state: 'failed',\n schema: options.schema,\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async registerCredentialDefinition(\n agentContext: AgentContext,\n options: RegisterCredentialDefinitionOptions\n ): Promise<RegisterCredentialDefinitionReturn> {\n try {\n const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)\n const { credentialDefinition } = options\n const schema = await this.getSchema(agentContext, credentialDefinition.schemaId)\n if (!schema.schema) throw new CredoError(`Schema not found for schemaId: ${credentialDefinition.schemaId}`)\n\n const credDefName = `${schema.schema.name}-${credentialDefinition.tag}`\n const credDefNameHashBuffer = Hasher.hash(credDefName, 'sha-256')\n\n const credDefResource = {\n id: utils.uuid(),\n name: TypedArrayEncoder.toHex(credDefNameHashBuffer),\n resourceType: cheqdAnonCredsResourceTypes.credentialDefinition,\n data: {\n type: credentialDefinition.type,\n tag: credentialDefinition.tag,\n value: credentialDefinition.value,\n schemaId: credentialDefinition.schemaId,\n },\n version: utils.uuid(),\n } satisfies CheqdCreateResourceOptions\n\n const response = await cheqdDidRegistrar.createResource(\n agentContext,\n credentialDefinition.issuerId,\n credDefResource\n )\n if (response.resourceState.state !== 'finished')\n throw new CredoError(response.resourceState.reason ?? 'Unknown error')\n\n return {\n credentialDefinitionState: {\n state: 'finished',\n credentialDefinition,\n credentialDefinitionId: `${credentialDefinition.issuerId}/resources/${credDefResource.id}`,\n },\n registrationMetadata: {},\n credentialDefinitionMetadata: {},\n }\n } catch (error) {\n agentContext.config.logger.error(\n `Error registering credential definition for did '${options.credentialDefinition.issuerId}'`,\n {\n error,\n did: options.credentialDefinition.issuerId,\n schema: options,\n }\n )\n\n return {\n credentialDefinitionMetadata: {},\n registrationMetadata: {},\n credentialDefinitionState: {\n state: 'failed',\n credentialDefinition: options.credentialDefinition,\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async getCredentialDefinition(\n agentContext: AgentContext,\n credentialDefinitionId: string\n ): Promise<GetCredentialDefinitionReturn> {\n try {\n const cheqdDidResolver = agentContext.dependencyManager.resolve(CheqdDidResolver)\n const parsedDid = parseCheqdDid(credentialDefinitionId)\n if (!parsedDid) throw new CredoError(`Invalid credentialDefinitionId: ${credentialDefinitionId}`)\n\n agentContext.config.logger.trace(\n `Submitting get credential definition request for '${credentialDefinitionId}' to ledger`\n )\n\n const response = await cheqdDidResolver.resolveResource(agentContext, credentialDefinitionId)\n const credentialDefinition = JsonTransformer.fromJSON(response.resource, CheqdCredentialDefinition)\n return {\n credentialDefinition: {\n ...credentialDefinition,\n issuerId: parsedDid.did,\n },\n credentialDefinitionId,\n resolutionMetadata: {},\n credentialDefinitionMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(`Error retrieving credential definition '${credentialDefinitionId}'`, {\n error,\n credentialDefinitionId,\n })\n\n return {\n credentialDefinitionId,\n resolutionMetadata: {\n error: 'notFound',\n message: `unable to resolve credential definition: ${error.message}`,\n },\n credentialDefinitionMetadata: {},\n }\n }\n }\n\n public async getRevocationRegistryDefinition(\n agentContext: AgentContext,\n revocationRegistryDefinitionId: string\n ): Promise<GetRevocationRegistryDefinitionReturn> {\n try {\n const cheqdDidResolver = agentContext.dependencyManager.resolve(CheqdDidResolver)\n const parsedDid = parseCheqdDid(revocationRegistryDefinitionId)\n if (!parsedDid) throw new CredoError(`Invalid revocationRegistryDefinitionId: ${revocationRegistryDefinitionId}`)\n\n agentContext.config.logger.trace(\n `Submitting get revocation registry definition request for '${revocationRegistryDefinitionId}' to ledger`\n )\n\n const searchDid = parsedDid.path\n ? revocationRegistryDefinitionId\n : `${revocationRegistryDefinitionId}${revocationRegistryDefinitionId.includes('?') ? '&' : '?'}resourceType=${\n cheqdAnonCredsResourceTypes.revocationRegistryDefinition\n }`\n\n const response = await cheqdDidResolver.resolveResource(agentContext, searchDid)\n const revocationRegistryDefinition = JsonTransformer.fromJSON(\n response.resource,\n CheqdRevocationRegistryDefinition\n )\n return {\n revocationRegistryDefinition: {\n ...revocationRegistryDefinition,\n issuerId: parsedDid.did,\n },\n revocationRegistryDefinitionId,\n resolutionMetadata: {},\n revocationRegistryDefinitionMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(\n `Error retrieving revocation registry definition '${revocationRegistryDefinitionId}'`,\n {\n error,\n revocationRegistryDefinitionId,\n }\n )\n\n return {\n revocationRegistryDefinitionId,\n resolutionMetadata: {\n error: 'notFound',\n message: `unable to resolve revocation registry definition: ${error.message}`,\n },\n revocationRegistryDefinitionMetadata: {},\n }\n }\n }\n\n public async registerRevocationRegistryDefinition(\n agentContext: AgentContext,\n { revocationRegistryDefinition, options }: RegisterRevocationRegistryDefinitionOptions\n ): Promise<RegisterRevocationRegistryDefinitionReturn> {\n try {\n const credentialDefinition = await this.getCredentialDefinition(\n agentContext,\n revocationRegistryDefinition.credDefId\n )\n if (!credentialDefinition.credentialDefinition)\n throw new CredoError(`Credential definition not found for id: ${revocationRegistryDefinition.credDefId}`)\n\n const credentialDefinitionName = credentialDefinition.credentialDefinitionMetadata.name\n if (!credentialDefinitionName)\n throw new CredoError(`Credential definition name not found for id: ${revocationRegistryDefinition.credDefId}`)\n\n const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)\n\n const revocDefName = `${credentialDefinitionName}-${revocationRegistryDefinition.tag}`\n const revocDefNameHashedBuffer = Hasher.hash(revocDefName, 'sha-256')\n\n const revocationRegistryDefinitionResource = {\n id: utils.uuid(),\n name: TypedArrayEncoder.toHex(revocDefNameHashedBuffer),\n resourceType: cheqdAnonCredsResourceTypes.revocationRegistryDefinition,\n data: {\n credDefId: revocationRegistryDefinition.credDefId,\n revocDefType: revocationRegistryDefinition.revocDefType,\n tag: revocationRegistryDefinition.tag,\n value: revocationRegistryDefinition.value,\n },\n version: utils.uuid(),\n } satisfies CheqdCreateResourceOptions\n\n const response = await cheqdDidRegistrar.createResource(\n agentContext,\n revocationRegistryDefinition.issuerId,\n revocationRegistryDefinitionResource\n )\n if (response.resourceState.state !== 'finished')\n throw new CredoError(response.resourceState.reason ?? 'Unknown error')\n\n return {\n revocationRegistryDefinitionState: {\n state: 'finished',\n revocationRegistryDefinition,\n revocationRegistryDefinitionId: `${revocationRegistryDefinition.issuerId}/resources/${revocationRegistryDefinitionResource.id}`,\n },\n registrationMetadata: {},\n revocationRegistryDefinitionMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(\n `Error registering revocation registry definition for did '${revocationRegistryDefinition.issuerId}'`,\n {\n error,\n did: revocationRegistryDefinition.issuerId,\n options,\n }\n )\n\n return {\n revocationRegistryDefinitionMetadata: {},\n registrationMetadata: {},\n revocationRegistryDefinitionState: {\n state: 'failed',\n revocationRegistryDefinition,\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async getRevocationStatusList(\n agentContext: AgentContext,\n revocationRegistryId: string,\n timestamp: number\n ): Promise<GetRevocationStatusListReturn> {\n try {\n const cheqdDidResolver = agentContext.dependencyManager.resolve(CheqdDidResolver)\n const parsedDid = parseCheqdDid(revocationRegistryId)\n if (!parsedDid) throw new CredoError(`Invalid revocationRegistryId: ${revocationRegistryId}`)\n\n agentContext.config.logger.trace(\n `Submitting get revocation status request for '${revocationRegistryId}' to ledger`\n )\n\n const revocationRegistryDefinition = await this.getRevocationRegistryDefinition(\n agentContext,\n revocationRegistryId\n )\n if (!revocationRegistryDefinition.revocationRegistryDefinition)\n throw new CredoError(`Revocation registry definition not found for id: ${revocationRegistryId}`)\n\n const revocationRegistryDefinitionName = revocationRegistryDefinition.revocationRegistryDefinitionMetadata.name\n if (!revocationRegistryDefinitionName)\n throw new CredoError(`Revocation registry definition name not found for id: ${revocationRegistryId}`)\n\n const response = await cheqdDidResolver.resolveResource(\n agentContext,\n `${parsedDid.did}?resourceType=${cheqdAnonCredsResourceTypes.revocationStatusList}&resourceVersionTime=${timestamp}&resourceName=${revocationRegistryDefinitionName}`\n )\n\n const revocationStatusList = JsonTransformer.fromJSON(response.resource, CheqdRevocationStatusList)\n\n const statusListTimestamp = response.resourceMetadata?.created\n ? Math.floor(response.resourceMetadata.created.getTime() / 1000)\n : undefined\n if (statusListTimestamp === undefined)\n throw new CredoError(`Unable to extract revocation status list timestamp from resource ${revocationRegistryId}`)\n\n return {\n revocationStatusList: {\n ...revocationStatusList,\n issuerId: parsedDid.did,\n timestamp: statusListTimestamp,\n },\n resolutionMetadata: {},\n revocationStatusListMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(`Error retrieving revocation registry status list '${revocationRegistryId}'`, {\n error,\n revocationRegistryId,\n })\n\n return {\n resolutionMetadata: {\n error: 'notFound',\n message: `unable to resolve revocation registry status list: ${error.message}`,\n },\n revocationStatusListMetadata: {},\n }\n }\n }\n\n public async registerRevocationStatusList(\n agentContext: AgentContext,\n { revocationStatusList, options }: RegisterRevocationStatusListOptions\n ): Promise<RegisterRevocationStatusListReturn> {\n try {\n const revocationRegistryDefinition = await this.getRevocationRegistryDefinition(\n agentContext,\n revocationStatusList.revRegDefId\n )\n if (!revocationRegistryDefinition.revocationRegistryDefinition) {\n throw new CredoError(`Revocation registry definition not found for id: ${revocationStatusList.revRegDefId}`)\n }\n\n const revocationRegistryDefinitionName = revocationRegistryDefinition.revocationRegistryDefinitionMetadata.name\n if (!revocationRegistryDefinitionName)\n throw new CredoError(\n `Revocation registry definition name not found for id: ${revocationStatusList.revRegDefId}`\n )\n\n const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)\n const revocationStatusListResource = {\n id: utils.uuid(),\n name: revocationRegistryDefinitionName as string,\n resourceType: cheqdAnonCredsResourceTypes.revocationStatusList,\n data: {\n currentAccumulator: revocationStatusList.currentAccumulator,\n revRegDefId: revocationStatusList.revRegDefId,\n revocationList: revocationStatusList.revocationList,\n },\n version: utils.uuid(),\n } satisfies CheqdCreateResourceOptions\n\n const response = await cheqdDidRegistrar.createResource(\n agentContext,\n revocationStatusList.issuerId,\n revocationStatusListResource\n )\n if (response.resourceState.state !== 'finished')\n throw new CredoError(response.resourceState.reason ?? 'Unknown error')\n\n // It's not possible to get the timestamp from the response, so we set it to the current time\n const nowTimestamp = Math.floor(Date.now() / 1000)\n\n return {\n revocationStatusListState: {\n state: 'finished',\n revocationStatusList: {\n ...revocationStatusList,\n timestamp: nowTimestamp,\n },\n },\n registrationMetadata: {},\n revocationStatusListMetadata: (response.resourceMetadata ?? {}) as Record<string, unknown>,\n }\n } catch (error) {\n agentContext.config.logger.error(\n `Error registering revocation status list for did '${revocationStatusList.issuerId}'`,\n {\n error,\n did: revocationStatusList.issuerId,\n options,\n }\n )\n\n return {\n revocationStatusListMetadata: {},\n registrationMetadata: {},\n revocationStatusListState: {\n state: 'failed',\n revocationStatusList,\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n}\n"],"mappings":";;;;;;;;AAgCA,IAAa,yBAAb,MAAiE;;OACxD,aAAa;OAOJ,sBAAsB;;CAEtC,MAAa,UAAU,cAA4B,UAA4C;AAC7F,MAAI;GACF,MAAM,mBAAmB,aAAa,kBAAkB,QAAQ,iBAAiB;GACjF,MAAM,YAAY,cAAc,SAAS;AACzC,OAAI,CAAC,UAAW,OAAM,IAAI,WAAW,qBAAqB,WAAW;AAErE,gBAAa,OAAO,OAAO,MAAM,6CAA6C,SAAS,aAAa;GAEpG,MAAM,WAAW,MAAM,iBAAiB,gBAAgB,cAAc,SAAS;GAC/E,MAAM,SAAS,gBAAgB,SAAS,SAAS,UAAU,YAAY;AAEvE,UAAO;IACL,QAAQ;KACN,WAAW,OAAO;KAClB,MAAM,OAAO;KACb,SAAS,OAAO;KAChB,UAAU,UAAU;KACrB;IACD;IACA,oBAAoB,EAAE;IACtB,gBAAgB,EAAE;IACnB;WACM,OAAO;AACd,gBAAa,OAAO,OAAO,MAAM,4BAA4B,SAAS,IAAI;IACxE;IACA;IACD,CAAC;AAEF,UAAO;IACL;IACA,oBAAoB;KAClB,OAAO;KACP,SAAS,6BAA6B,MAAM;KAC7C;IACD,gBAAgB,EAAE;IACnB;;;CAIL,MAAa,eACX,cACA,SAC+B;AAC/B,MAAI;GACF,MAAM,oBAAoB,aAAa,kBAAkB,QAAQ,kBAAkB;GAEnF,MAAM,SAAS,QAAQ;GACvB,MAAM,iBAAiB;IACrB,IAAI,MAAM,MAAM;IAChB,MAAM,GAAG,OAAO,KAAK;IACrB,cAAc,4BAA4B;IAC1C,MAAM;KACJ,MAAM,OAAO;KACb,SAAS,OAAO;KAChB,WAAW,OAAO;KACnB;IACD,SAAS,OAAO;IACjB;GAED,MAAM,WAAW,MAAM,kBAAkB,eAAe,cAAc,OAAO,UAAU,eAAe;AACtG,OAAI,SAAS,cAAc,UAAU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AC/D;WACM,OAAO;AACd,gBAAa,OAAO,OAAO,MACzB,qDAAqD,qBAAqB,SAAS,IACnF;IACE;IACA,KAAK,qBAAqB;IAC1B;IACD,CACF;AAED,UAAO;IACL,8BAA8B,EAAE;IAChC,sBAAsB,EAAE;IACxB,2BAA2B;KACzB,OAAO;KACP;KACA,QAAQ,iBAAiB,MAAM;KAChC;IACF"}
@@ -1,5 +1,5 @@
1
- import { CheqdNetwork, DidStdFee, MethodSpecificIdAlgo } from "@cheqd/sdk";
2
1
  import { AgentContext, DidCreateOptions, DidCreateResult, DidDeactivateResult, DidDocument, DidDocumentKey, DidRegistrar, DidUpdateOptions, DidUpdateResult, Kms, XOR } from "@credo-ts/core";
2
+ import { CheqdNetwork, DidStdFee, MethodSpecificIdAlgo } from "@cheqd/sdk";
3
3
  import { MsgCreateResourcePayload } from "@cheqd/ts-proto/cheqd/resource/v2";
4
4
 
5
5
  //#region src/dids/CheqdDidRegistrar.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdDidRegistrar.d.mts","names":[],"sources":["../../src/dids/CheqdDidRegistrar.ts"],"sourcesContent":[],"mappings":";;;;;AA8Ca,cAAA,iBAAA,YAA6B,YAAX,CAAA;EAAA,SAAA,gBAAA,EAAA,MAAA,EAAA;UA2CK,cAAA;UAAuB,kBAAA;QAAgC,CAAA,YAAA,EAAvD,YAAuD,EAAA,OAAA,EAAhC,qBAAgC,CAAA,EAAR,OAAQ,CAAA,eAAA,CAAA;QAAR,CAAA,YAAA,EA6L/C,YA7L+C,EAAA,OAAA,EA6LxB,qBA7LwB,CAAA,EA6LA,OA7LA,CA6LQ,eA7LR,CAAA;YA6L/C,CAAA,YAAA,EAyNlB,YAzNkB,EAAA,OAAA,EA0NvB,yBA1NuB,CAAA,EA2N/B,OA3N+B,CA2NvB,mBA3NuB,CAAA;gBAAuB,CAAA,YAAA,EAiSf,YAjSe,EAAA,GAAA,EAAA,MAAA,EAAA,QAAA,EAiSsB,0BAjStB,CAAA,EAi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qd/sdk";
2
1
  import { AgentContext, DidCreateOptions, DidCreateResult, DidDeactivateResult, DidDocument, DidDocumentKey, DidRegistrar, DidUpdateOptions, DidUpdateResult, Kms, XOR } from "@credo-ts/core";
3
2
  import { MsgCreateResourcePayload } from "@cheqd/ts-proto/cheqd/resource/v2";
3
+ import { CheqdNetwork, DidStdFee, MethodSpecificIdAlgo } from "@cheqd/sdk";
4
4
 
5
5
  //#region src/dids/CheqdDidRegistrar.d.ts
6
6
  declare class CheqdDidRegistrar implements DidRegistrar {
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdDidRegistrar.d.ts","names":[],"sources":["../../src/dids/CheqdDidRegistrar.ts"],"sourcesContent":[],"mappings":";;;;;AA8Ca,cAAA,iBAAA,YAA6B,YAAX,CAAA;EAAA,SAAA,gBAAA,EAAA,MAAA,EAAA;UA2CK,cAAA;UAAuB,kBAAA;QAAgC,CAAA,YAAA,EAAvD,YAAuD,EAAA,OAAA,EAAhC,qBAAgC,CAAA,EAAR,OAAQ,CAAA,eAAA,CAAA;QAAR,CAAA,YAAA,EA6L/C,YA7L+C,EAAA,OAAA,EA6LxB,qBA7LwB,CAAA,EA6LA,OA7LA,CA6LQ,eA7LR,CAAA;YA6L/C,CAAA,YAAA,EAyNlB,YAzNkB,EAAA,OAAA,EA0NvB,yBA1NuB,CAAA,EA2N/B,OA3N+B,CA2NvB,mBA3NuB,CAAA;gBAAuB,CAAA,YAAA,EAiSf,YAjSe,EAAA,GAAA,EAAA,MAAA,EAAA,QAAA,EAiSsB,0BAjStB,CAAA,EAiSgD,OAjShD,CAAA;IAAgC,gBAAA,EAAA,CAAA,CAAA;IAAR,4BAAA,EAAA,CAAA,CAAA;IAyNjE,aAAA,EAAA;MACL,KAAA,EAAA,MAAA;MACA,MAAA,EAAA,MAAA;MAAR,UAAA,CAAA,EAAA,SAAA;MAsEuC,QAAA,CAAA,EAAA,SAAA;IAAqC,CAAA;;IAA0B,gBAAA,EAAA,CAAA,CAAA;IAzgBjE,4B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AjB,CAAA,EAAA,KAAA;aAX2D,CAAA,EAAA,KAAA;EAAgB,MAAA,CAAA,EAAA,KAAA;EAchE,OAAA,EAAA;IAAqC,OAAA,EAAA,GAPtC,YAOsC,EAAA;IAGvC,GAAA,CAAA,EATL,SASK;IAML,SAAA,CAAA,EAAA,MAAA;IACA,oBAAA,CAAA,EAAA,GAdoB,oBAcpB,EAAA;MAbJ,GAGwD,CAAA;IAAgB,SAAA,EAHvD,6BAGuD;EAelE,CAAA,EAAA;IAAqB,KAAA,EAAA,MAAA;;;AAAiF,UAfjG,oCAAA,SAA6C,gBAeoD,CAAA;EAEjG,MAAA,EAAA,OAAA;EAAsB,GAAA,CAAA,EAAA,SAAA;aAExB,EAhBA,WAgBA;SAQJ,EAAA;IAED;;;;IAZqD,IAAA,EARrD,cAQqD,EAAA;IAiB9C,GAAA,CAAA,EAxBP,SAwBO;IAA0B,SAAA,CAAA,EAAA,MAAA;;;AAAwB,KAnBvD,qBAAA,GAAwB,oCAmB+B,GAnBQ,uCAmBR;AASlD,UA1BA,qBAAA,SAA8B,gBA0BH,CAAA;EAAA,GAAA,EAAA,MAAA;aAAa,EAxB1C,WAwB0C;QACxC,CAAA,EAAA,KAAA;SACA,CAAA,EAAA;IACL;;;;WAnBD;UAED;;MAEJ;gBAAkB;;;;;UAGP,yBAAA,SAAkC;;;;UAIzC;;;;UAKO,0BAAA,SAAmC,KAAK;iBACxC;iBACA;YACL;gBACI"}
@@ -3,10 +3,10 @@ const require_identifiers = require('../anoncreds/utils/identifiers.js');
3
3
  const require_didCheqdUtil = require('./didCheqdUtil.js');
4
4
  const require_CheqdLedgerService = require('../ledger/CheqdLedgerService.js');
5
5
  require('../ledger/index.js');
6
- let __cheqd_sdk = require("@cheqd/sdk");
7
- __cheqd_sdk = require_rolldown_runtime.__toESM(__cheqd_sdk);
8
6
  let __credo_ts_core = require("@credo-ts/core");
9
7
  __credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);
8
+ let __cheqd_sdk = require("@cheqd/sdk");
9
+ __cheqd_sdk = require_rolldown_runtime.__toESM(__cheqd_sdk);
10
10
  let __cheqd_ts_proto_cheqd_resource_v2 = require("@cheqd/ts-proto/cheqd/resource/v2");
11
11
  __cheqd_ts_proto_cheqd_resource_v2 = require_rolldown_runtime.__toESM(__cheqd_ts_proto_cheqd_resource_v2);
12
12
 
@@ -2,8 +2,8 @@ import { ED25519_SUITE_CONTEXT_URL_2018, ED25519_SUITE_CONTEXT_URL_2020, parseCh
2
2
  import { createMsgCreateDidDocPayloadToSign, createMsgDeactivateDidDocPayloadToSign, generateDidDoc, validateSpecCompliantPayload } from "./didCheqdUtil.mjs";
3
3
  import { CheqdLedgerService } from "../ledger/CheqdLedgerService.mjs";
4
4
  import "../ledger/index.mjs";
5
- import { CheqdNetwork, MethodSpecificIdAlgo, VerificationMethods, createDidVerificationMethod } from "@cheqd/sdk";
6
5
  import { AgentContext, DID_V1_CONTEXT_URL, DidDocument, DidDocumentRole, DidRecord, DidRepository, JsonTransformer, Kms, SECURITY_JWS_CONTEXT_URL, TypedArrayEncoder, VerificationMethod, getKmsKeyIdForVerifiacationMethod, getPublicJwkFromVerificationMethod, utils } from "@credo-ts/core";
6
+ import { CheqdNetwork, MethodSpecificIdAlgo, VerificationMethods, createDidVerificationMethod } from "@cheqd/sdk";
7
7
  import { MsgCreateResourcePayload } from "@cheqd/ts-proto/cheqd/resource/v2";
8
8
 
9
9
  //#region src/dids/CheqdDidRegistrar.ts
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdDidRegistrar.mjs","names":["didDocument: DidDocument","keys: DidDocumentKey[]","publicJwk: Kms.KmsJwkPublicOkp & { crv: 'Ed25519' }","authentication","didRecord: DidRecord | null","createdKey: DidDocumentKey","data: Uint8Array"],"sources":["../../src/dids/CheqdDidRegistrar.ts"],"sourcesContent":["import { CheqdNetwork, type DIDDocument, type DidStdFee, VerificationMethods } from '@cheqd/sdk'\nimport type { SignInfo } from '@cheqd/ts-proto/cheqd/did/v2'\nimport {\n AgentContext,\n DID_V1_CONTEXT_URL,\n type DidCreateOptions,\n type DidCreateResult,\n type DidDeactivateResult,\n type DidDocumentKey,\n type DidRegistrar,\n type DidUpdateOptions,\n type DidUpdateResult,\n Kms,\n SECURITY_JWS_CONTEXT_URL,\n type XOR,\n getKmsKeyIdForVerifiacationMethod,\n getPublicJwkFromVerificationMethod,\n} from '@credo-ts/core'\n\nimport { MethodSpecificIdAlgo, createDidVerificationMethod } from '@cheqd/sdk'\nimport { MsgCreateResourcePayload } from '@cheqd/ts-proto/cheqd/resource/v2'\nimport {\n DidDocument,\n DidDocumentRole,\n DidRecord,\n DidRepository,\n JsonTransformer,\n TypedArrayEncoder,\n VerificationMethod,\n utils,\n} from '@credo-ts/core'\n\nimport {\n ED25519_SUITE_CONTEXT_URL_2018,\n ED25519_SUITE_CONTEXT_URL_2020,\n parseCheqdDid,\n} from '../anoncreds/utils/identifiers'\nimport { CheqdLedgerService } from '../ledger'\n\nimport {\n createMsgCreateDidDocPayloadToSign,\n createMsgDeactivateDidDocPayloadToSign,\n generateDidDoc,\n validateSpecCompliantPayload,\n} from './didCheqdUtil'\n\nexport class CheqdDidRegistrar implements DidRegistrar {\n public readonly supportedMethods = ['cheqd']\n private contextMapping = {\n Ed25519VerificationKey2018: ED25519_SUITE_CONTEXT_URL_2018,\n Ed25519VerificationKey2020: ED25519_SUITE_CONTEXT_URL_2020,\n JsonWebKey2020: SECURITY_JWS_CONTEXT_URL,\n }\n\n private collectAllContexts(didDocument: DidDocument): Set<string> {\n const contextSet = new Set<string>(\n typeof didDocument.context === 'string'\n ? [didDocument.context]\n : Array.isArray(didDocument.context)\n ? didDocument.context\n : []\n )\n // List of verification relationships to check for embedded verification methods\n // Note: these are the relationships defined in the DID Core spec\n const relationships = [\n 'authentication',\n 'assertionMethod',\n 'capabilityInvocation',\n 'capabilityDelegation',\n 'keyAgreement',\n 'verificationMethod',\n ] as const\n // Collect verification methods from relationships\n for (const rel of relationships) {\n const entries = didDocument[rel]\n if (entries) {\n for (const entry of entries) {\n if (typeof entry !== 'string' && entry.type) {\n const contextUrl = this.contextMapping[entry.type as keyof typeof this.contextMapping]\n if (contextUrl) {\n contextSet.add(contextUrl)\n }\n }\n }\n }\n }\n return contextSet\n }\n\n public async create(agentContext: AgentContext, options: CheqdDidCreateOptions): Promise<DidCreateResult> {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n\n let didDocument: DidDocument\n const versionId = options.options?.versionId ?? utils.uuid()\n\n let keys: DidDocumentKey[] = []\n\n try {\n if (options.didDocument) {\n const isSpecCompliantPayload = validateSpecCompliantPayload(options.didDocument)\n if (!isSpecCompliantPayload.valid) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `Invalid did document provided. ${isSpecCompliantPayload.error}`,\n },\n }\n }\n\n didDocument = options.didDocument\n const authenticationIds = didDocument.authentication?.map((v) => (typeof v === 'string' ? v : v.id)) ?? []\n const didDocumentRelativeKeyIds = options.options.keys.map((key) => key.didDocumentRelativeKeyId)\n keys = options.options.keys\n\n // Ensure all keys are present in the did document\n for (const didDocumentKeyId of didDocumentRelativeKeyIds) {\n didDocument.dereferenceKey(didDocumentKeyId)\n }\n\n if (!authenticationIds.every((id) => didDocumentRelativeKeyIds.includes(id.replace(didDocument.id, '')))) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `For all 'authentication' verification methods in the did document a 'key' entry in the options MUST be provided that link the did document key id with the kms key id`,\n },\n }\n }\n\n const cheqdDid = parseCheqdDid(options.didDocument.id)\n\n if (!cheqdDid) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `Unable to parse cheqd did ${options.didDocument.id}`,\n },\n }\n }\n } else if (options.options.createKey || options.options.keyId) {\n const methodSpecificIdAlgo = options.options.methodSpecificIdAlgo\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n let publicJwk: Kms.KmsJwkPublicOkp & { crv: 'Ed25519' }\n if (options.options.createKey) {\n const createKeyResult = await kms.createKey(options.options.createKey)\n publicJwk = createKeyResult.publicJwk\n keys.push({\n kmsKeyId: createKeyResult.keyId,\n didDocumentRelativeKeyId: '#key-1',\n })\n } else {\n const _publicJwk = await kms.getPublicKey({\n keyId: options.options.keyId,\n })\n keys.push({\n kmsKeyId: options.options.keyId,\n didDocumentRelativeKeyId: '#key-1',\n })\n if (!_publicJwk) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `notFound: key with key id '${options.options.keyId}' not found`,\n },\n }\n }\n\n if (_publicJwk.kty !== 'OKP' || _publicJwk.crv !== 'Ed25519') {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `key with key id '${options.options.keyId}' uses unsupported ${Kms.getJwkHumanDescription(\n _publicJwk\n )} for did:cheqd`,\n },\n }\n }\n\n publicJwk = {\n ..._publicJwk,\n crv: _publicJwk.crv,\n }\n }\n\n // TODO: make this configureable\n const verificationMethod = VerificationMethods.JWK\n const jwk = Kms.PublicJwk.fromPublicJwk(publicJwk)\n\n didDocument = generateDidDoc({\n verificationMethod,\n verificationMethodId: 'key-1',\n methodSpecificIdAlgo: (methodSpecificIdAlgo as MethodSpecificIdAlgo) || MethodSpecificIdAlgo.Uuid,\n network: options.options.network as CheqdNetwork,\n publicKey: TypedArrayEncoder.toHex(jwk.publicKey.publicKey),\n })\n } else {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Provide a didDocument or provide createKey or keyId in options',\n },\n }\n }\n\n // Collect all contexts from the didDic into a set\n const contextSet = this.collectAllContexts(didDocument)\n // Add Cheqd default context to the did document\n didDocument.context = Array.from(contextSet.add(DID_V1_CONTEXT_URL))\n\n const didDocumentJson = didDocument.toJSON() as DIDDocument\n const payloadToSign = await createMsgCreateDidDocPayloadToSign(didDocumentJson, versionId)\n\n const authentication = didDocument.authentication?.map((authentication) =>\n typeof authentication === 'string' ? didDocument.dereferenceVerificationMethod(authentication) : authentication\n )\n if (!authentication || authentication.length === 0) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: \"No keys to sign with in 'authentication' of DID document\",\n },\n }\n }\n\n const signInputs = await this.signPayload(agentContext, payloadToSign, authentication, keys)\n\n const response = await cheqdLedgerService.create(didDocumentJson, signInputs, versionId)\n if (response.code !== 0) {\n throw new Error(`${response.rawLog}`)\n }\n\n // Save the did so we know we created it and can issue with it\n const didRecord = new DidRecord({\n did: didDocument.id,\n role: DidDocumentRole.Created,\n didDocument,\n keys,\n })\n await didRepository.save(agentContext, didRecord)\n\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'finished',\n did: didDocument.id,\n didDocument,\n secret: options.secret,\n },\n }\n } catch (error) {\n agentContext.config.logger.error('Error registering DID', error)\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async update(agentContext: AgentContext, options: CheqdDidUpdateOptions): Promise<DidUpdateResult> {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n\n const versionId = options.options?.versionId || utils.uuid()\n let didDocument: DidDocument\n let didRecord: DidRecord | null\n\n try {\n if (options.didDocument) {\n const isSpecCompliantPayload = validateSpecCompliantPayload(options.didDocument)\n if (!isSpecCompliantPayload.valid) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `Invalid did document provided. ${isSpecCompliantPayload.error}`,\n },\n }\n }\n\n didDocument = options.didDocument\n const resolvedDocument = await cheqdLedgerService.resolve(didDocument.id)\n didRecord = await didRepository.findCreatedDid(agentContext, didDocument.id)\n if (!resolvedDocument.didDocument || resolvedDocument.didDocumentMetadata.deactivated || !didRecord) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Did not found',\n },\n }\n }\n\n const keys = didRecord.keys ?? []\n if (options.options?.createKey || options.options?.keyId) {\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n let createdKey: DidDocumentKey\n\n let publicJwk: Kms.KmsJwkPublicOkp & { crv: 'Ed25519' }\n if (options.options.createKey) {\n const createKeyResult = await kms.createKey(options.options.createKey)\n publicJwk = createKeyResult.publicJwk\n\n createdKey = {\n didDocumentRelativeKeyId: `#${utils.uuid()}-1`,\n kmsKeyId: createKeyResult.keyId,\n }\n } else if (options.options.keyId) {\n const _publicJwk = await kms.getPublicKey({\n keyId: options.options.keyId,\n })\n createdKey = {\n didDocumentRelativeKeyId: `#${utils.uuid()}-1`,\n kmsKeyId: options.options.keyId,\n }\n if (!_publicJwk) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `notFound: key with key id '${options.options.keyId}' not found`,\n },\n }\n }\n\n if (_publicJwk.kty !== 'OKP' || _publicJwk.crv !== 'Ed25519') {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `key with key id '${options.options.keyId}' uses unsupported ${Kms.getJwkHumanDescription(\n _publicJwk\n )} for did:cheqd`,\n },\n }\n }\n\n publicJwk = {\n ..._publicJwk,\n crv: _publicJwk.crv,\n }\n } else {\n // This will never happen, but to make TS happy\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Expect options.createKey or options.keyId',\n },\n }\n }\n\n // TODO: make this configureable\n const verificationMethod = VerificationMethods.JWK\n const jwk = Kms.PublicJwk.fromPublicJwk(publicJwk)\n\n keys.push(createdKey)\n didDocument.verificationMethod?.concat(\n JsonTransformer.fromJSON(\n createDidVerificationMethod(\n [verificationMethod],\n [\n {\n methodSpecificId: didDocument.id.split(':')[3],\n didUrl: didDocument.id,\n keyId: `${didDocument.id}${createdKey.didDocumentRelativeKeyId}` as `${string}#${string}-${number}`,\n publicKey: TypedArrayEncoder.toHex(jwk.publicKey.publicKey),\n },\n ]\n ),\n VerificationMethod\n )\n )\n }\n } else {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Provide a valid didDocument',\n },\n }\n }\n\n // Filter out all keys that are not present in the did document anymore\n didRecord.keys = didRecord.keys?.filter(({ didDocumentRelativeKeyId }) => {\n try {\n didDocument.dereferenceKey(didDocumentRelativeKeyId)\n return true\n } catch (_error) {\n return false\n }\n })\n\n // TODO: we don't know which keys are managed by Credo. Should we\n // create a keys array for all keys within the did document set to the legacy key id\n // TODO: we need some sort of migration plan, otherwise we will have to support\n // legacy key ids forever\n // const authenticationIds = didDocument.authentication?.map(a => typeof a === 'string' ? a : a.id) ?? []\n // const didDocumentKeyIds = didRecord.keys?.map(({didDocumentRelativeKeyId}) => didDocumentRelativeKeyId)\n // if (!authenticationIds.every((id) => didDocumentKeyIds?.includes(id))) {\n // return {\n // didDocumentMetadata: {},\n // didRegistrationMetadata: {},\n // didState: {\n // state: \"failed\",\n // reason: `For all 'authentication' verification methods in the did document a 'key' entry in the options MUST be provided that link the did document key id with the kms key id`,\n // },\n // };\n // }\n\n const payloadToSign = await createMsgCreateDidDocPayloadToSign(didDocument.toJSON() as DIDDocument, versionId)\n\n const authentication = didDocument.authentication?.map((authentication) =>\n typeof authentication === 'string' ? didDocument.dereferenceVerificationMethod(authentication) : authentication\n )\n if (!authentication || authentication.length === 0) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: \"No keys to sign with in 'authentication' of DID document\",\n },\n }\n }\n const signInputs = await this.signPayload(\n agentContext,\n payloadToSign,\n // TOOD: we should also sign with the authentication entries that are removed (so we should diff)\n authentication,\n didRecord.keys\n )\n\n const response = await cheqdLedgerService.update(didDocument.toJSON() as DIDDocument, signInputs, versionId)\n if (response.code !== 0) {\n throw new Error(`${response.rawLog}`)\n }\n // Collect all contexts, override existing context if provided\n const contextSet = this.collectAllContexts(options.didDocument || didDocument)\n // Add Cheqd default context to the did document\n didDocument.context = Array.from(contextSet.add(DID_V1_CONTEXT_URL))\n // Save the did so we know we created it and can issue with it\n didRecord.didDocument = didDocument\n await didRepository.update(agentContext, didRecord)\n\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'finished',\n did: didDocument.id,\n didDocument,\n secret: options.secret,\n },\n }\n } catch (error) {\n agentContext.config.logger.error('Error updating DID', error)\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async deactivate(\n agentContext: AgentContext,\n options: CheqdDidDeactivateOptions\n ): Promise<DidDeactivateResult> {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n\n const did = options.did\n const versionId = options.options?.versionId || utils.uuid()\n\n try {\n const { didDocument, didDocumentMetadata } = await cheqdLedgerService.resolve(did)\n\n const didRecord = await didRepository.findCreatedDid(agentContext, did)\n if (!didDocument || didDocumentMetadata.deactivated || !didRecord) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Did not found',\n },\n }\n }\n const payloadToSign = createMsgDeactivateDidDocPayloadToSign(didDocument, versionId)\n const didDocumentInstance = DidDocument.fromJSON(didDocument)\n\n const authentication = didDocumentInstance.authentication?.map((authentication) =>\n typeof authentication === 'string'\n ? didDocumentInstance.dereferenceVerificationMethod(authentication)\n : authentication\n )\n if (!authentication || authentication.length === 0) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: \"No keys to sign with in 'authentication' of DID document\",\n },\n }\n }\n const signInputs = await this.signPayload(agentContext, payloadToSign, authentication, didRecord.keys)\n const response = await cheqdLedgerService.deactivate(didDocument, signInputs, versionId)\n if (response.code !== 0) {\n throw new Error(`${response.rawLog}`)\n }\n\n await didRepository.update(agentContext, didRecord)\n\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'finished',\n did: didDocument.id,\n didDocument: JsonTransformer.fromJSON(didRecord.didDocument, DidDocument),\n secret: options.secret,\n },\n }\n } catch (error) {\n agentContext.config.logger.error('Error deactivating DID', error)\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async createResource(agentContext: AgentContext, did: string, resource: CheqdCreateResourceOptions) {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n const { didDocument, didDocumentMetadata } = await cheqdLedgerService.resolve(did)\n const didRecord = await didRepository.findCreatedDid(agentContext, did)\n if (!didDocument || didDocumentMetadata.deactivated || !didRecord) {\n return {\n resourceMetadata: {},\n resourceRegistrationMetadata: {},\n resourceState: {\n state: 'failed',\n reason: `DID: ${did} not found`,\n },\n }\n }\n\n try {\n let data: Uint8Array\n if (typeof resource.data === 'string') {\n data = TypedArrayEncoder.fromBase64(resource.data)\n } else if (typeof resource.data === 'object') {\n data = TypedArrayEncoder.fromString(JSON.stringify(resource.data))\n } else {\n data = resource.data\n }\n\n const resourcePayload = MsgCreateResourcePayload.fromPartial({\n collectionId: did.split(':')[3],\n id: resource.id,\n resourceType: resource.resourceType,\n name: resource.name,\n version: resource.version,\n alsoKnownAs: resource.alsoKnownAs,\n data,\n })\n const payloadToSign = MsgCreateResourcePayload.encode(resourcePayload).finish()\n\n const didDocumentInstance = JsonTransformer.fromJSON(didDocument, DidDocument)\n const signInputs = await this.signPayload(\n agentContext,\n payloadToSign,\n didDocumentInstance.verificationMethod,\n didRecord.keys\n )\n const response = await cheqdLedgerService.createResource(did, resourcePayload, signInputs)\n if (response.code !== 0) {\n throw new Error(`${response.rawLog}`)\n }\n\n return {\n resourceMetadata: {},\n resourceRegistrationMetadata: {},\n resourceState: {\n state: 'finished',\n resourceId: resourcePayload.id,\n resource: resourcePayload,\n },\n }\n } catch (error) {\n return {\n resourceMetadata: {},\n resourceRegistrationMetadata: {},\n resourceState: {\n state: 'failed',\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n private async signPayload(\n agentContext: AgentContext,\n payload: Uint8Array,\n verificationMethod: VerificationMethod[] = [],\n keys?: DidDocumentKey[]\n ) {\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n return await Promise.all(\n verificationMethod.map(async (method) => {\n const publicJwk = getPublicJwkFromVerificationMethod(method)\n const kmsKeyId = getKmsKeyIdForVerifiacationMethod(method, keys) ?? publicJwk.legacyKeyId\n\n const { signature } = await kms.sign({\n data: payload as Uint8Array<ArrayBuffer>,\n algorithm: publicJwk.signatureAlgorithm,\n keyId: kmsKeyId,\n })\n\n // EC signatures need to be sent as DER encoded for Cheqd\n const jwk = publicJwk.toJson()\n if (jwk.kty === 'EC') {\n return {\n verificationMethodId: method.id,\n signature: Kms.rawEcSignatureToDer(signature, jwk.crv),\n }\n }\n\n return {\n verificationMethodId: method.id,\n signature,\n } satisfies SignInfo\n })\n )\n }\n}\n\ntype KmsCreateKeyOptionsOkpEd25519 = Kms.KmsCreateKeyOptions<Kms.KmsCreateKeyTypeOkp & { crv: 'Ed25519' }>\n\nexport interface CheqdDidCreateWithoutDidDocumentOptions extends DidCreateOptions {\n method: 'cheqd'\n did?: never\n didDocument?: never\n secret?: never\n\n options: {\n network: `${CheqdNetwork}`\n fee?: DidStdFee\n versionId?: string\n methodSpecificIdAlgo?: `${MethodSpecificIdAlgo}`\n } & XOR<{ createKey: KmsCreateKeyOptionsOkpEd25519 }, { keyId: string }>\n}\n\nexport interface CheqdDidCreateFromDidDocumentOptions extends DidCreateOptions {\n method: 'cheqd'\n did?: undefined\n didDocument: DidDocument\n options: {\n /**\n * The linking between the did document keys and the kms keys. For cheqd dids ALL authentication entries MUST sign the request\n * and thus it is required to a mapping for all keys.\n */\n keys: DidDocumentKey[]\n fee?: DidStdFee\n versionId?: string\n }\n}\n\nexport type CheqdDidCreateOptions = CheqdDidCreateFromDidDocumentOptions | CheqdDidCreateWithoutDidDocumentOptions\n\nexport interface CheqdDidUpdateOptions extends DidUpdateOptions {\n did: string\n didDocument: DidDocument\n secret?: never\n\n options?: {\n /**\n * The linking between the did document keys and the kms keys. The existing keys will be filtered based on the keys not present\n * in the did document anymore, and this new list will be merged into it.\n */\n keys?: DidDocumentKey[]\n\n fee?: DidStdFee\n versionId?: string\n } & XOR<{ createKey?: KmsCreateKeyOptionsOkpEd25519 }, { keyId?: string }>\n}\n\nexport interface CheqdDidDeactivateOptions extends DidCreateOptions {\n method: 'cheqd'\n did: string\n options: {\n fee?: DidStdFee\n versionId?: string\n }\n}\n\nexport interface CheqdCreateResourceOptions extends Pick<MsgCreateResourcePayload, 'id' | 'name' | 'resourceType'> {\n data: string | Uint8Array | object\n collectionId?: MsgCreateResourcePayload['collectionId']\n version?: MsgCreateResourcePayload['version']\n alsoKnownAs?: MsgCreateResourcePayload['alsoKnownAs']\n}\n"],"mappings":";;;;;;;;;AA8CA,IAAa,oBAAb,MAAuD;;OACrC,mBAAmB,CAAC,QAAQ;OACpC,iBAAiB;GACvB,4BAA4B;GAC5B,4BAA4B;GAC5B,gBAAgB;GACjB;;CAED,AAAQ,mBAAmB,aAAuC;EAChE,MAAM,aAAa,IAAI,IACrB,OAAO,YAAY,YAAY,WAC3B,CAAC,YAAY,QAAQ,GACrB,MAAM,QAAQ,YAAY,QAAQ,GAChC,YAAY,UACZ,EAAE,CACT;AAYD,OAAK,MAAM,OATW;GACpB;GACA;GACA;GACA;GACA;GACA;GACD,EAEgC;GAC/B,MAAM,UAAU,YAAY;AA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Q;AAC9B,OAAI,IAAI,QAAQ,KACd,QAAO;IACL,sBAAsB,OAAO;IAC7B,WAAW,IAAI,oBAAoB,WAAW,IAAI,IAAI;IACvD;AAGH,UAAO;IACL,sBAAsB,OAAO;IAC7B;IACD;IACD,CACH"}
1
+ {"version":3,"file":"CheqdDidRegistrar.mjs","names":["didDocument: DidDocument","keys: DidDocumentKey[]","publicJwk: Kms.KmsJwkPublicOkp & { crv: 'Ed25519' }","authentication","didRecord: DidRecord | null","createdKey: DidDocumentKey","data: Uint8ArrayBuffer"],"sources":["../../src/dids/CheqdDidRegistrar.ts"],"sourcesContent":["import {\n CheqdNetwork,\n createDidVerificationMethod,\n type DIDDocument,\n type DidStdFee,\n MethodSpecificIdAlgo,\n VerificationMethods,\n} from '@cheqd/sdk'\nimport type { SignInfo } from '@cheqd/ts-proto/cheqd/did/v2'\nimport { MsgCreateResourcePayload } from '@cheqd/ts-proto/cheqd/resource/v2'\nimport {\n AgentContext,\n type AnyUint8Array,\n DID_V1_CONTEXT_URL,\n type DidCreateOptions,\n type DidCreateResult,\n type DidDeactivateResult,\n DidDocument,\n type DidDocumentKey,\n DidDocumentRole,\n DidRecord,\n type DidRegistrar,\n DidRepository,\n type DidUpdateOptions,\n type DidUpdateResult,\n getKmsKeyIdForVerifiacationMethod,\n getPublicJwkFromVerificationMethod,\n JsonTransformer,\n Kms,\n SECURITY_JWS_CONTEXT_URL,\n TypedArrayEncoder,\n type Uint8ArrayBuffer,\n utils,\n VerificationMethod,\n type XOR,\n} from '@credo-ts/core'\n\nimport {\n ED25519_SUITE_CONTEXT_URL_2018,\n ED25519_SUITE_CONTEXT_URL_2020,\n parseCheqdDid,\n} from '../anoncreds/utils/identifiers'\nimport { CheqdLedgerService } from '../ledger'\n\nimport {\n createMsgCreateDidDocPayloadToSign,\n createMsgDeactivateDidDocPayloadToSign,\n generateDidDoc,\n validateSpecCompliantPayload,\n} from './didCheqdUtil'\n\nexport class CheqdDidRegistrar implements DidRegistrar {\n public readonly supportedMethods = ['cheqd']\n private contextMapping = {\n Ed25519VerificationKey2018: ED25519_SUITE_CONTEXT_URL_2018,\n Ed25519VerificationKey2020: ED25519_SUITE_CONTEXT_URL_2020,\n JsonWebKey2020: SECURITY_JWS_CONTEXT_URL,\n }\n\n private collectAllContexts(didDocument: DidDocument): Set<string> {\n const contextSet = new Set<string>(\n typeof didDocument.context === 'string'\n ? [didDocument.context]\n : Array.isArray(didDocument.context)\n ? didDocument.context\n : []\n )\n // List of verification relationships to check for embedded verification methods\n // Note: these are the relationships defined in the DID Core spec\n const relationships = [\n 'authentication',\n 'assertionMethod',\n 'capabilityInvocation',\n 'capabilityDelegation',\n 'keyAgreement',\n 'verificationMethod',\n ] as const\n // Collect verification methods from relationships\n for (const rel of relationships) {\n const entries = didDocument[rel]\n if (entries) {\n for (const entry of entries) {\n if (typeof entry !== 'string' && entry.type) {\n const contextUrl = this.contextMapping[entry.type as keyof typeof this.contextMapping]\n if (contextUrl) {\n contextSet.add(contextUrl)\n }\n }\n }\n }\n }\n return contextSet\n }\n\n public async create(agentContext: AgentContext, options: CheqdDidCreateOptions): Promise<DidCreateResult> {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n\n let didDocument: DidDocument\n const versionId = options.options?.versionId ?? utils.uuid()\n\n let keys: DidDocumentKey[] = []\n\n try {\n if (options.didDocument) {\n const isSpecCompliantPayload = validateSpecCompliantPayload(options.didDocument)\n if (!isSpecCompliantPayload.valid) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `Invalid did document provided. ${isSpecCompliantPayload.error}`,\n },\n }\n }\n\n didDocument = options.didDocument\n const authenticationIds = didDocument.authentication?.map((v) => (typeof v === 'string' ? v : v.id)) ?? []\n const didDocumentRelativeKeyIds = options.options.keys.map((key) => key.didDocumentRelativeKeyId)\n keys = options.options.keys\n\n // Ensure all keys are present in the did document\n for (const didDocumentKeyId of didDocumentRelativeKeyIds) {\n didDocument.dereferenceKey(didDocumentKeyId)\n }\n\n if (!authenticationIds.every((id) => didDocumentRelativeKeyIds.includes(id.replace(didDocument.id, '')))) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `For all 'authentication' verification methods in the did document a 'key' entry in the options MUST be provided that link the did document key id with the kms key id`,\n },\n }\n }\n\n const cheqdDid = parseCheqdDid(options.didDocument.id)\n\n if (!cheqdDid) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `Unable to parse cheqd did ${options.didDocument.id}`,\n },\n }\n }\n } else if (options.options.createKey || options.options.keyId) {\n const methodSpecificIdAlgo = options.options.methodSpecificIdAlgo\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n let publicJwk: Kms.KmsJwkPublicOkp & { crv: 'Ed25519' }\n if (options.options.createKey) {\n const createKeyResult = await kms.createKey(options.options.createKey)\n publicJwk = createKeyResult.publicJwk\n keys.push({\n kmsKeyId: createKeyResult.keyId,\n didDocumentRelativeKeyId: '#key-1',\n })\n } else {\n const _publicJwk = await kms.getPublicKey({\n keyId: options.options.keyId,\n })\n keys.push({\n kmsKeyId: options.options.keyId,\n didDocumentRelativeKeyId: '#key-1',\n })\n if (!_publicJwk) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `notFound: key with key id '${options.options.keyId}' not found`,\n },\n }\n }\n\n if (_publicJwk.kty !== 'OKP' || _publicJwk.crv !== 'Ed25519') {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `key with key id '${options.options.keyId}' uses unsupported ${Kms.getJwkHumanDescription(\n _publicJwk\n )} for did:cheqd`,\n },\n }\n }\n\n publicJwk = {\n ..._publicJwk,\n crv: _publicJwk.crv,\n }\n }\n\n // TODO: make this configureable\n const verificationMethod = VerificationMethods.JWK\n const jwk = Kms.PublicJwk.fromPublicJwk(publicJwk)\n\n didDocument = generateDidDoc({\n verificationMethod,\n verificationMethodId: 'key-1',\n methodSpecificIdAlgo: (methodSpecificIdAlgo as MethodSpecificIdAlgo) || MethodSpecificIdAlgo.Uuid,\n network: options.options.network as CheqdNetwork,\n publicKey: TypedArrayEncoder.toHex(jwk.publicKey.publicKey),\n })\n } else {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Provide a didDocument or provide createKey or keyId in options',\n },\n }\n }\n\n // Collect all contexts from the didDic into a set\n const contextSet = this.collectAllContexts(didDocument)\n // Add Cheqd default context to the did document\n didDocument.context = Array.from(contextSet.add(DID_V1_CONTEXT_URL))\n\n const didDocumentJson = didDocument.toJSON() as DIDDocument\n const payloadToSign = await createMsgCreateDidDocPayloadToSign(didDocumentJson, versionId)\n\n const authentication = didDocument.authentication?.map((authentication) =>\n typeof authentication === 'string' ? didDocument.dereferenceVerificationMethod(authentication) : authentication\n )\n if (!authentication || authentication.length === 0) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: \"No keys to sign with in 'authentication' of DID document\",\n },\n }\n }\n\n const signInputs = await this.signPayload(agentContext, payloadToSign, authentication, keys)\n\n const response = await cheqdLedgerService.create(didDocumentJson, signInputs, versionId)\n if (response.code !== 0) {\n throw new Error(`${response.rawLog}`)\n }\n\n // Save the did so we know we created it and can issue with it\n const didRecord = new DidRecord({\n did: didDocument.id,\n role: DidDocumentRole.Created,\n didDocument,\n keys,\n })\n await didRepository.save(agentContext, didRecord)\n\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'finished',\n did: didDocument.id,\n didDocument,\n secret: options.secret,\n },\n }\n } catch (error) {\n agentContext.config.logger.error('Error registering DID', error)\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async update(agentContext: AgentContext, options: CheqdDidUpdateOptions): Promise<DidUpdateResult> {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n\n const versionId = options.options?.versionId || utils.uuid()\n let didDocument: DidDocument\n let didRecord: DidRecord | null\n\n try {\n if (options.didDocument) {\n const isSpecCompliantPayload = validateSpecCompliantPayload(options.didDocument)\n if (!isSpecCompliantPayload.valid) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `Invalid did document provided. ${isSpecCompliantPayload.error}`,\n },\n }\n }\n\n didDocument = options.didDocument\n const resolvedDocument = await cheqdLedgerService.resolve(didDocument.id)\n didRecord = await didRepository.findCreatedDid(agentContext, didDocument.id)\n if (!resolvedDocument.didDocument || resolvedDocument.didDocumentMetadata.deactivated || !didRecord) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Did not found',\n },\n }\n }\n\n const keys = didRecord.keys ?? []\n if (options.options?.createKey || options.options?.keyId) {\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n let createdKey: DidDocumentKey\n\n let publicJwk: Kms.KmsJwkPublicOkp & { crv: 'Ed25519' }\n if (options.options.createKey) {\n const createKeyResult = await kms.createKey(options.options.createKey)\n publicJwk = createKeyResult.publicJwk\n\n createdKey = {\n didDocumentRelativeKeyId: `#${utils.uuid()}-1`,\n kmsKeyId: createKeyResult.keyId,\n }\n } else if (options.options.keyId) {\n const _publicJwk = await kms.getPublicKey({\n keyId: options.options.keyId,\n })\n createdKey = {\n didDocumentRelativeKeyId: `#${utils.uuid()}-1`,\n kmsKeyId: options.options.keyId,\n }\n if (!_publicJwk) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `notFound: key with key id '${options.options.keyId}' not found`,\n },\n }\n }\n\n if (_publicJwk.kty !== 'OKP' || _publicJwk.crv !== 'Ed25519') {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `key with key id '${options.options.keyId}' uses unsupported ${Kms.getJwkHumanDescription(\n _publicJwk\n )} for did:cheqd`,\n },\n }\n }\n\n publicJwk = {\n ..._publicJwk,\n crv: _publicJwk.crv,\n }\n } else {\n // This will never happen, but to make TS happy\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Expect options.createKey or options.keyId',\n },\n }\n }\n\n // TODO: make this configureable\n const verificationMethod = VerificationMethods.JWK\n const jwk = Kms.PublicJwk.fromPublicJwk(publicJwk)\n\n keys.push(createdKey)\n didDocument.verificationMethod?.concat(\n JsonTransformer.fromJSON(\n createDidVerificationMethod(\n [verificationMethod],\n [\n {\n methodSpecificId: didDocument.id.split(':')[3],\n didUrl: didDocument.id,\n keyId: `${didDocument.id}${createdKey.didDocumentRelativeKeyId}` as `${string}#${string}-${number}`,\n publicKey: TypedArrayEncoder.toHex(jwk.publicKey.publicKey),\n },\n ]\n ),\n VerificationMethod\n )\n )\n }\n } else {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Provide a valid didDocument',\n },\n }\n }\n\n // Filter out all keys that are not present in the did document anymore\n didRecord.keys = didRecord.keys?.filter(({ didDocumentRelativeKeyId }) => {\n try {\n didDocument.dereferenceKey(didDocumentRelativeKeyId)\n return true\n } catch (_error) {\n return false\n }\n })\n\n // TODO: we don't know which keys are managed by Credo. Should we\n // create a keys array for all keys within the did document set to the legacy key id\n // TODO: we need some sort of migration plan, otherwise we will have to support\n // legacy key ids forever\n // const authenticationIds = didDocument.authentication?.map(a => typeof a === 'string' ? a : a.id) ?? []\n // const didDocumentKeyIds = didRecord.keys?.map(({didDocumentRelativeKeyId}) => didDocumentRelativeKeyId)\n // if (!authenticationIds.every((id) => didDocumentKeyIds?.includes(id))) {\n // return {\n // didDocumentMetadata: {},\n // didRegistrationMetadata: {},\n // didState: {\n // state: \"failed\",\n // reason: `For all 'authentication' verification methods in the did document a 'key' entry in the options MUST be provided that link the did document key id with the kms key id`,\n // },\n // };\n // }\n\n const payloadToSign = await createMsgCreateDidDocPayloadToSign(didDocument.toJSON() as DIDDocument, versionId)\n\n const authentication = didDocument.authentication?.map((authentication) =>\n typeof authentication === 'string' ? didDocument.dereferenceVerificationMethod(authentication) : authentication\n )\n if (!authentication || authentication.length === 0) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: \"No keys to sign with in 'authentication' of DID document\",\n },\n }\n }\n const signInputs = await this.signPayload(\n agentContext,\n payloadToSign,\n // TOOD: we should also sign with the authentication entries that are removed (so we should diff)\n authentication,\n didRecord.keys\n )\n\n const response = await cheqdLedgerService.update(didDocument.toJSON() as DIDDocument, signInputs, versionId)\n if (response.code !== 0) {\n throw new Error(`${response.rawLog}`)\n }\n // Collect all contexts, override existing context if provided\n const contextSet = this.collectAllContexts(options.didDocument || didDocument)\n // Add Cheqd default context to the did document\n didDocument.context = Array.from(contextSet.add(DID_V1_CONTEXT_URL))\n // Save the did so we know we created it and can issue with it\n didRecord.didDocument = didDocument\n await didRepository.update(agentContext, didRecord)\n\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'finished',\n did: didDocument.id,\n didDocument,\n secret: options.secret,\n },\n }\n } catch (error) {\n agentContext.config.logger.error('Error updating DID', error)\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async deactivate(\n agentContext: AgentContext,\n options: CheqdDidDeactivateOptions\n ): Promise<DidDeactivateResult> {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n\n const did = options.did\n const versionId = options.options?.versionId || utils.uuid()\n\n try {\n const { didDocument, didDocumentMetadata } = await cheqdLedgerService.resolve(did)\n\n const didRecord = await didRepository.findCreatedDid(agentContext, did)\n if (!didDocument || didDocumentMetadata.deactivated || !didRecord) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: 'Did not found',\n },\n }\n }\n const payloadToSign = createMsgDeactivateDidDocPayloadToSign(didDocument, versionId)\n const didDocumentInstance = DidDocument.fromJSON(didDocument)\n\n const authentication = didDocumentInstance.authentication?.map((authentication) =>\n typeof authentication === 'string'\n ? didDocumentInstance.dereferenceVerificationMethod(authentication)\n : authentication\n )\n if (!authentication || authentication.length === 0) {\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: \"No keys to sign with in 'authentication' of DID document\",\n },\n }\n }\n const signInputs = await this.signPayload(agentContext, payloadToSign, authentication, didRecord.keys)\n const response = await cheqdLedgerService.deactivate(didDocument, signInputs, versionId)\n if (response.code !== 0) {\n throw new Error(`${response.rawLog}`)\n }\n\n await didRepository.update(agentContext, didRecord)\n\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'finished',\n did: didDocument.id,\n didDocument: JsonTransformer.fromJSON(didRecord.didDocument, DidDocument),\n secret: options.secret,\n },\n }\n } catch (error) {\n agentContext.config.logger.error('Error deactivating DID', error)\n return {\n didDocumentMetadata: {},\n didRegistrationMetadata: {},\n didState: {\n state: 'failed',\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n public async createResource(agentContext: AgentContext, did: string, resource: CheqdCreateResourceOptions) {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n const { didDocument, didDocumentMetadata } = await cheqdLedgerService.resolve(did)\n const didRecord = await didRepository.findCreatedDid(agentContext, did)\n if (!didDocument || didDocumentMetadata.deactivated || !didRecord) {\n return {\n resourceMetadata: {},\n resourceRegistrationMetadata: {},\n resourceState: {\n state: 'failed',\n reason: `DID: ${did} not found`,\n },\n }\n }\n\n try {\n let data: Uint8ArrayBuffer\n if (typeof resource.data === 'string') {\n data = TypedArrayEncoder.fromBase64(resource.data)\n } else if (typeof resource.data === 'object') {\n data = TypedArrayEncoder.fromString(JSON.stringify(resource.data))\n } else {\n data = resource.data\n }\n\n const resourcePayload = MsgCreateResourcePayload.fromPartial({\n collectionId: did.split(':')[3],\n id: resource.id,\n resourceType: resource.resourceType,\n name: resource.name,\n version: resource.version,\n alsoKnownAs: resource.alsoKnownAs,\n data,\n })\n const payloadToSign = MsgCreateResourcePayload.encode(resourcePayload).finish()\n\n const didDocumentInstance = JsonTransformer.fromJSON(didDocument, DidDocument)\n const signInputs = await this.signPayload(\n agentContext,\n payloadToSign,\n didDocumentInstance.verificationMethod,\n didRecord.keys\n )\n const response = await cheqdLedgerService.createResource(did, resourcePayload, signInputs)\n if (response.code !== 0) {\n throw new Error(`${response.rawLog}`)\n }\n\n return {\n resourceMetadata: {},\n resourceRegistrationMetadata: {},\n resourceState: {\n state: 'finished',\n resourceId: resourcePayload.id,\n resource: resourcePayload,\n },\n }\n } catch (error) {\n return {\n resourceMetadata: {},\n resourceRegistrationMetadata: {},\n resourceState: {\n state: 'failed',\n reason: `unknownError: ${error.message}`,\n },\n }\n }\n }\n\n private async signPayload(\n agentContext: AgentContext,\n payload: AnyUint8Array,\n verificationMethod: VerificationMethod[] = [],\n keys?: DidDocumentKey[]\n ) {\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n return await Promise.all(\n verificationMethod.map(async (method) => {\n const publicJwk = getPublicJwkFromVerificationMethod(method)\n const kmsKeyId = getKmsKeyIdForVerifiacationMethod(method, keys) ?? publicJwk.legacyKeyId\n\n const { signature } = await kms.sign({\n data: payload,\n algorithm: publicJwk.signatureAlgorithm,\n keyId: kmsKeyId,\n })\n\n // EC signatures need to be sent as DER encoded for Cheqd\n const jwk = publicJwk.toJson()\n if (jwk.kty === 'EC') {\n return {\n verificationMethodId: method.id,\n signature: Kms.rawEcSignatureToDer(signature, jwk.crv),\n }\n }\n\n return {\n verificationMethodId: method.id,\n signature,\n } satisfies SignInfo\n })\n )\n }\n}\n\ntype KmsCreateKeyOptionsOkpEd25519 = Kms.KmsCreateKeyOptions<Kms.KmsCreateKeyTypeOkp & { crv: 'Ed25519' }>\n\nexport interface CheqdDidCreateWithoutDidDocumentOptions extends DidCreateOptions {\n method: 'cheqd'\n did?: never\n didDocument?: never\n secret?: never\n\n options: {\n network: `${CheqdNetwork}`\n fee?: DidStdFee\n versionId?: string\n methodSpecificIdAlgo?: `${MethodSpecificIdAlgo}`\n } & XOR<{ createKey: KmsCreateKeyOptionsOkpEd25519 }, { keyId: string }>\n}\n\nexport interface CheqdDidCreateFromDidDocumentOptions extends DidCreateOptions {\n method: 'cheqd'\n did?: undefined\n didDocument: DidDocument\n options: {\n /**\n * The linking between the did document keys and the kms keys. For cheqd dids ALL authentication entries MUST sign the request\n * and thus it is required to a mapping for all keys.\n */\n keys: DidDocumentKey[]\n fee?: DidStdFee\n versionId?: string\n }\n}\n\nexport type CheqdDidCreateOptions = CheqdDidCreateFromDidDocumentOptions | CheqdDidCreateWithoutDidDocumentOptions\n\nexport interface CheqdDidUpdateOptions extends DidUpdateOptions {\n did: string\n didDocument: DidDocument\n secret?: never\n\n options?: {\n /**\n * The linking between the did document keys and the kms keys. The existing keys will be filtered based on the keys not present\n * in the did document anymore, and this new list will be merged into it.\n */\n keys?: DidDocumentKey[]\n\n fee?: DidStdFee\n versionId?: string\n } & XOR<{ createKey?: KmsCreateKeyOptionsOkpEd25519 }, { keyId?: string }>\n}\n\nexport interface CheqdDidDeactivateOptions extends DidCreateOptions {\n method: 'cheqd'\n did: string\n options: {\n fee?: DidStdFee\n versionId?: string\n }\n}\n\nexport interface CheqdCreateResourceOptions extends Pick<MsgCreateResourcePayload, 'id' | 'name' | 'resourceType'> {\n data: string | Uint8Array | object\n collectionId?: MsgCreateResourcePayload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O;IACL,kBAAkB,EAAE;IACpB,8BAA8B,EAAE;IAChC,eAAe;KACb,OAAO;KACP,QAAQ,iBAAiB,MAAM;KAChC;IACF;;;CAIL,MAAc,YACZ,cACA,SACA,qBAA2C,EAAE,EAC7C,MACA;EACA,MAAM,MAAM,aAAa,kBAAkB,QAAQ,IAAI,iBAAiB;AACxE,SAAO,MAAM,QAAQ,IACnB,mBAAmB,IAAI,OAAO,WAAW;GACvC,MAAM,YAAY,mCAAmC,OAAO;GAC5D,MAAM,WAAW,kCAAkC,QAAQ,KAAK,IAAI,UAAU;GAE9E,MAAM,EAAE,cAAc,MAAM,IAAI,KAAK;IACnC,MAAM;IACN,WAAW,UAAU;IACrB,OAAO;IACR,CAAC;GAGF,MAAM,MAAM,UAAU,QAAQ;AAC9B,OAAI,IAAI,QAAQ,KACd,QAAO;IACL,sBAAsB,OAAO;IAC7B,WAAW,IAAI,oBAAoB,WAAW,IAAI,IAAI;IACvD;AAGH,UAAO;IACL,sBAAsB,OAAO;IAC7B;IACD;IACD,CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdDidResolver.d.mts","names":[],"sources":["../../src/dids/CheqdDidResolver.ts"],"sourcesContent":[],"mappings":";;;;cAmBa,gBAAA,YAA4B;;EAA5B,SAAA,aAAiB,GAAA,IAAA;EAAA,SAAA,oBAAA,GAAA,IAAA;SAKO,CAAA,YAAA,EAAA,YAAA,EAAA,GAAA,EAAA,MAAA,EAAA,MAAA,EAAmC,SAAnC,CAAA,EAA+C,OAA/C,CAAuD,mBAAvD,CAAA;iBAAmC,CAAA,YAAA,EA4C3B,YA5C2B,EAAA,GAAA,EAAA,MAAA,CAAA,EA4CF,OA5CE,CAAA;IAAoB,KAAA,EAAA,MAAA;IAAR,OAAA,EAAA,MAAA;IA4CvC,QAAA,CAAA,EAAA,SAAA;;IAAyB,0BAAA,CAAA,EAAA,SAAA;MAjD7B;IAAW,QAAA,EAAA,GAAA"}
1
+ {"version":3,"file":"CheqdDidResolver.d.mts","names":[],"sources":["../../src/dids/CheqdDidResolver.ts"],"sourcesContent":[],"mappings":";;;;cAkBa,gBAAA,YAA4B;;EAA5B,SAAA,aAAiB,GAAA,IAAA;EAAA,SAAA,oBAAA,GAAA,IAAA;SAKO,CAAA,YAAA,EAAA,YAAA,EAAA,GAAA,EAAA,MAAA,EAAA,MAAA,EAAmC,SAAnC,CAAA,EAA+C,OAA/C,CAAuD,mBAAvD,CAAA;iBAAmC,CAAA,YAAA,EA4C3B,YA5C2B,EAAA,GAAA,EAAA,MAAA,CAAA,EA4CF,OA5CE,CAAA;IAAoB,KAAA,EAAA,MAAA;IAAR,OAAA,EAAA,MAAA;IA4CvC,QAAA,CAAA,EAAA,SAAA;;IAAyB,0BAAA,CAAA,EAAA,SAAA;MAjD7B;IAAW,QAAA,EAAA,GAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdDidResolver.d.ts","names":[],"sources":["../../src/dids/CheqdDidResolver.ts"],"sourcesContent":[],"mappings":";;;;cAmBa,gBAAA,YAA4B;;EAA5B,SAAA,aAAiB,GAAA,IAAA;EAAA,SAAA,oBAAA,GAAA,IAAA;SAKO,CAAA,YAAA,EAAA,YAAA,EAAA,GAAA,EAAA,MAAA,EAAA,MAAA,EAAmC,SAAnC,CAAA,EAA+C,OAA/C,CAAuD,mBAAvD,CAAA;iBAAmC,CAAA,YAAA,EA4C3B,YA5C2B,EAAA,GAAA,EAAA,MAAA,CAAA,EA4CF,OA5CE,CAAA;IAAoB,KAAA,EAAA,MAAA;IAAR,OAAA,EAAA,MAAA;IA4CvC,QAAA,CAAA,EAAA,SAAA;;IAAyB,0BAAA,CAAA,EAAA,SAAA;MAjD7B;IAAW,QAAA,EAAA,GAAA"}
1
+ {"version":3,"file":"CheqdDidResolver.d.ts","names":[],"sources":["../../src/dids/CheqdDidResolver.ts"],"sourcesContent":[],"mappings":";;;;cAkBa,gBAAA,YAA4B;;EAA5B,SAAA,aAAiB,GAAA,IAAA;EAAA,SAAA,oBAAA,GAAA,IAAA;SAKO,CAAA,YAAA,EAAA,YAAA,EAAA,GAAA,EAAA,MAAA,EAAA,MAAA,EAAmC,SAAnC,CAAA,EAA+C,OAA/C,CAAuD,mBAAvD,CAAA;iBAAmC,CAAA,YAAA,EA4C3B,YA5C2B,EAAA,GAAA,EAAA,MAAA,CAAA,EA4CF,OA5CE,CAAA;IAAoB,KAAA,EAAA,MAAA;IAAR,OAAA,EAAA,MAAA;IA4CvC,QAAA,CAAA,EAAA,SAAA;;IAAyB,0BAAA,CAAA,EAAA,SAAA;MAjD7B;IAAW,QAAA,EAAA,GAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdDidResolver.mjs","names":["resourceId: string","resource: Metadata | undefined","resource"],"sources":["../../src/dids/CheqdDidResolver.ts"],"sourcesContent":["import type { Metadata } from '@cheqd/ts-proto/cheqd/resource/v2'\nimport type { AgentContext, DidResolutionResult, DidResolver, ParsedDid } from '@credo-ts/core'\nimport type { ParsedCheqdDid } from '../anoncreds/utils/identifiers'\n\nimport { CredoError, DidDocument, JsonTransformer, utils } from '@credo-ts/core'\n\nimport {\n cheqdDidMetadataRegex,\n cheqdDidRegex,\n cheqdDidVersionRegex,\n cheqdDidVersionsRegex,\n cheqdResourceMetadataRegex,\n cheqdResourceRegex,\n parseCheqdDid,\n} from '../anoncreds/utils/identifiers'\nimport { CheqdLedgerService } from '../ledger'\n\nimport { filterResourcesByNameAndType, getClosestResourceVersion, renderResourceData } from './didCheqdUtil'\n\nexport class CheqdDidResolver implements DidResolver {\n public readonly supportedMethods = ['cheqd']\n public readonly allowsCaching = true\n public readonly allowsLocalDidRecord = true\n\n public async resolve(agentContext: AgentContext, did: string, parsed: ParsedDid): Promise<DidResolutionResult> {\n const didDocumentMetadata = {}\n\n try {\n const parsedDid = parseCheqdDid(parsed.didUrl)\n if (!parsedDid) {\n throw new Error('Invalid DID')\n }\n\n switch (did) {\n case did.match(cheqdDidRegex)?.input:\n return await this.resolveDidDoc(agentContext, parsedDid.did)\n case did.match(cheqdDidVersionRegex)?.input: {\n const version = did.split('/')[2]\n return await this.resolveDidDoc(agentContext, parsedDid.did, version)\n }\n case did.match(cheqdDidVersionsRegex)?.input:\n return await this.resolveAllDidDocVersions(agentContext, parsedDid)\n case did.match(cheqdDidMetadataRegex)?.input:\n return await this.dereferenceCollectionResources(agentContext, parsedDid)\n case did.match(cheqdResourceMetadataRegex)?.input:\n return await this.dereferenceResourceMetadata(agentContext, parsedDid)\n default:\n return {\n didDocument: null,\n didDocumentMetadata,\n didResolutionMetadata: {\n error: 'Invalid request',\n message: `Unsupported did Url: '${did}'`,\n },\n }\n }\n } catch (error) {\n return {\n didDocument: null,\n didDocumentMetadata,\n didResolutionMetadata: {\n error: 'notFound',\n message: `resolver_error: Unable to resolve did '${did}': ${error}`,\n },\n }\n }\n }\n\n public async resolveResource(agentContext: AgentContext, did: string) {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n try {\n const parsedDid = parseCheqdDid(did)\n if (!parsedDid) {\n throw new Error('Invalid DID')\n }\n\n const { params, id } = parsedDid\n let resourceId: string\n if (did.match(cheqdResourceRegex)?.input) {\n resourceId = did.split('/')[2]\n } else if (params?.resourceName && params.resourceType) {\n let resources = (await cheqdLedgerService.resolveCollectionResources(parsedDid.did, id)).resources\n resources = filterResourcesByNameAndType(resources, params.resourceName, params.resourceType)\n if (!resources.length) {\n throw new Error('No resources found')\n }\n\n let resource: Metadata | undefined\n if (params.version) {\n resource = resources.find((resource) => resource.version === params.version)\n } else {\n const date = params.resourceVersionTime ? new Date(Number(params.resourceVersionTime) * 1000) : new Date()\n // find the resourceId closest to the created time\n resource = getClosestResourceVersion(resources, date)\n }\n\n if (!resource) {\n throw new Error('No resources found')\n }\n\n resourceId = resource.id\n } else {\n return {\n error: 'notFound',\n message: `resolver_error: Invalid did url '${did}'`,\n }\n }\n if (!utils.isValidUuid(resourceId)) {\n throw new Error('Invalid resource Id')\n }\n\n const { resource, metadata } = await cheqdLedgerService.resolveResource(parsedDid.did, id, resourceId)\n if (!resource || !metadata) {\n throw new Error('resolver_error: Unable to resolve resource, Please try again')\n }\n\n const result = await renderResourceData(resource.data, metadata.mediaType)\n return {\n resource: result,\n resourceMetadata: metadata,\n resourceResolutionMetadata: {},\n }\n } catch (error) {\n return {\n error: 'notFound',\n message: `resolver_error: Unable to resolve resource '${did}': ${error}`,\n }\n }\n }\n\n private async resolveAllDidDocVersions(agentContext: AgentContext, parsedDid: ParsedCheqdDid) {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n const { did } = parsedDid\n\n const { didDocumentVersionsMetadata } = await cheqdLedgerService.resolveMetadata(did)\n return {\n didDocument: new DidDocument({ id: did }),\n didDocumentMetadata: didDocumentVersionsMetadata,\n didResolutionMetadata: {},\n }\n }\n\n private async dereferenceCollectionResources(agentContext: AgentContext, parsedDid: ParsedCheqdDid) {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n const { did, id } = parsedDid\n\n const metadata = await cheqdLedgerService.resolveCollectionResources(did, id)\n return {\n didDocument: new DidDocument({ id: did }),\n didDocumentMetadata: {\n linkedResourceMetadata: metadata,\n },\n didResolutionMetadata: {},\n }\n }\n\n private async dereferenceResourceMetadata(agentContext: AgentContext, parsedDid: ParsedCheqdDid) {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n const { did, id } = parsedDid\n\n if (!parsedDid.path) {\n throw new CredoError(`Missing path in did ${parsedDid.did}`)\n }\n\n const [, , resourceId] = parsedDid.path.split('/')\n\n if (!resourceId) {\n throw new CredoError(`Missing resource id in didUrl ${parsedDid.didUrl}`)\n }\n\n const metadata = await cheqdLedgerService.resolveResourceMetadata(did, id, resourceId)\n return {\n didDocument: new DidDocument({ id: did }),\n didDocumentMetadata: {\n linkedResourceMetadata: metadata,\n },\n didResolutionMetadata: {},\n }\n }\n\n private async resolveDidDoc(agentContext: AgentContext, did: string, version?: string): Promise<DidResolutionResult> {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n\n const { didDocument, didDocumentMetadata } = await cheqdLedgerService.resolve(did, version)\n const { resources } = await cheqdLedgerService.resolveCollectionResources(did, did.split(':')[3])\n didDocumentMetadata.linkedResourceMetadata = resources\n\n return {\n didDocument: JsonTransformer.fromJSON(didDocument, DidDocument),\n didDocumentMetadata,\n didResolutionMetadata: {},\n }\n }\n}\n"],"mappings":";;;;;;;AAmBA,IAAa,mBAAb,MAAqD;;OACnC,mBAAmB,CAAC,QAAQ;OAC5B,gBAAgB;OAChB,uBAAuB;;CAEvC,MAAa,QAAQ,cAA4B,KAAa,QAAiD;EAC7G,MAAM,sBAAsB,EAAE;AAE9B,MAAI;GACF,MAAM,YAAY,cAAc,OAAO,OAAO;AAC9C,OAAI,CAAC,UACH,OAAM,IAAI,MAAM,cAAc;AAGhC,WAAQ,KAAR;IACE,KAAK,IAAI,MAAM,cAAc,EAAE,MAC7B,QAAO,MAAM,KAAK,cAAc,cAAc,UAAU,IAAI;IAC9D,KAAK,IAAI,MAAM,qBAAqB,EAAE,OAAO;KAC3C,MAAM,UAAU,IAAI,MAAM,IAAI,CAAC;AAC/B,YAAO,MAAM,KAAK,cAAc,cAAc,UAAU,KAAK,QAAQ;;IAEvE,KAAK,IAAI,MAAM,sBAAsB,EAAE,MACrC,QAAO,MAAM,KAAK,yBAAyB,cAAc,UAAU;IACrE,KAAK,IAAI,MAAM,sBAAsB,EAAE,MACrC,QAAO,MAAM,KAAK,+BAA+B,cAAc,UAAU;IAC3E,KAAK,IAAI,MAAM,2BAA2B,EAAE,MAC1C,QAAO,MAAM,KAAK,4BAA4B,cAAc,UAAU;IACxE,QACE,QAAO;KACL,aAAa;KACb;KACA,uBAAuB;MACrB,OAAO;MACP,SAAS,yBAAyB,IAAI;MACvC;KACF;;WAEE,OAAO;AACd,UAAO;IACL,aAAa;IACb;IACA,uBAAuB;KACrB,OAAO;KACP,SAAS,0CAA0C,IAAI,KAAK;KAC7D;IAC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c,MAAM,mBAAmB,2BAA2B,KAAK,IAAI,MAAM,IAAI,CAAC,GAAG;AACjG,sBAAoB,yBAAyB;AAE7C,SAAO;GACL,aAAa,gBAAgB,SAAS,aAAa,YAAY;GAC/D;GACA,uBAAuB,EAAE;GAC1B"}
1
+ {"version":3,"file":"CheqdDidResolver.mjs","names":["resourceId: string","resource: Metadata | undefined","resource"],"sources":["../../src/dids/CheqdDidResolver.ts"],"sourcesContent":["import type { Metadata } from '@cheqd/ts-proto/cheqd/resource/v2'\nimport type { AgentContext, DidResolutionResult, DidResolver, ParsedDid } from '@credo-ts/core'\nimport { CredoError, DidDocument, JsonTransformer, utils } from '@credo-ts/core'\nimport type { ParsedCheqdDid } from '../anoncreds/utils/identifiers'\n\nimport {\n cheqdDidMetadataRegex,\n cheqdDidRegex,\n cheqdDidVersionRegex,\n cheqdDidVersionsRegex,\n cheqdResourceMetadataRegex,\n cheqdResourceRegex,\n parseCheqdDid,\n} from '../anoncreds/utils/identifiers'\nimport { CheqdLedgerService } from '../ledger'\n\nimport { filterResourcesByNameAndType, getClosestResourceVersion, renderResourceData } from './didCheqdUtil'\n\nexport class CheqdDidResolver implements DidResolver {\n public readonly supportedMethods = ['cheqd']\n public readonly allowsCaching = true\n public readonly allowsLocalDidRecord = true\n\n public async resolve(agentContext: AgentContext, did: string, parsed: ParsedDid): Promise<DidResolutionResult> {\n const didDocumentMetadata = {}\n\n try {\n const parsedDid = parseCheqdDid(parsed.didUrl)\n if (!parsedDid) {\n throw new Error('Invalid DID')\n }\n\n switch (did) {\n case did.match(cheqdDidRegex)?.input:\n return await this.resolveDidDoc(agentContext, parsedDid.did)\n case did.match(cheqdDidVersionRegex)?.input: {\n const version = did.split('/')[2]\n return await this.resolveDidDoc(agentContext, parsedDid.did, version)\n }\n case did.match(cheqdDidVersionsRegex)?.input:\n return await this.resolveAllDidDocVersions(agentContext, parsedDid)\n case did.match(cheqdDidMetadataRegex)?.input:\n return await this.dereferenceCollectionResources(agentContext, parsedDid)\n case did.match(cheqdResourceMetadataRegex)?.input:\n return await this.dereferenceResourceMetadata(agentContext, parsedDid)\n default:\n return {\n didDocument: null,\n didDocumentMetadata,\n didResolutionMetadata: {\n error: 'Invalid request',\n message: `Unsupported did Url: '${did}'`,\n },\n }\n }\n } catch (error) {\n return {\n didDocument: null,\n didDocumentMetadata,\n didResolutionMetadata: {\n error: 'notFound',\n message: `resolver_error: Unable to resolve did '${did}': ${error}`,\n },\n }\n }\n }\n\n public async resolveResource(agentContext: AgentContext, did: string) {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n try {\n const parsedDid = parseCheqdDid(did)\n if (!parsedDid) {\n throw new Error('Invalid DID')\n }\n\n const { params, id } = parsedDid\n let resourceId: string\n if (did.match(cheqdResourceRegex)?.input) {\n resourceId = did.split('/')[2]\n } else if (params?.resourceName && params.resourceType) {\n let resources = (await cheqdLedgerService.resolveCollectionResources(parsedDid.did, id)).resources\n resources = filterResourcesByNameAndType(resources, params.resourceName, params.resourceType)\n if (!resources.length) {\n throw new Error('No resources found')\n }\n\n let resource: Metadata | undefined\n if (params.version) {\n resource = resources.find((resource) => resource.version === params.version)\n } else {\n const date = params.resourceVersionTime ? new Date(Number(params.resourceVersionTime) * 1000) : new Date()\n // find the resourceId closest to the created time\n resource = getClosestResourceVersion(resources, date)\n }\n\n if (!resource) {\n throw new Error('No resources found')\n }\n\n resourceId = resource.id\n } else {\n return {\n error: 'notFound',\n message: `resolver_error: Invalid did url '${did}'`,\n }\n }\n if (!utils.isValidUuid(resourceId)) {\n throw new Error('Invalid resource Id')\n }\n\n const { resource, metadata } = await cheqdLedgerService.resolveResource(parsedDid.did, id, resourceId)\n if (!resource || !metadata) {\n throw new Error('resolver_error: Unable to resolve resource, Please try again')\n }\n\n const result = await renderResourceData(resource.data, metadata.mediaType)\n return {\n resource: result,\n resourceMetadata: metadata,\n resourceResolutionMetadata: {},\n }\n } catch (error) {\n return {\n error: 'notFound',\n message: `resolver_error: Unable to resolve resource '${did}': ${error}`,\n }\n }\n }\n\n private async resolveAllDidDocVersions(agentContext: AgentContext, parsedDid: ParsedCheqdDid) {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n const { did } = parsedDid\n\n const { didDocumentVersionsMetadata } = await cheqdLedgerService.resolveMetadata(did)\n return {\n didDocument: new DidDocument({ id: did }),\n didDocumentMetadata: didDocumentVersionsMetadata,\n didResolutionMetadata: {},\n }\n }\n\n private async dereferenceCollectionResources(agentContext: AgentContext, parsedDid: ParsedCheqdDid) {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n const { did, id } = parsedDid\n\n const metadata = await cheqdLedgerService.resolveCollectionResources(did, id)\n return {\n didDocument: new DidDocument({ id: did }),\n didDocumentMetadata: {\n linkedResourceMetadata: metadata,\n },\n didResolutionMetadata: {},\n }\n }\n\n private async dereferenceResourceMetadata(agentContext: AgentContext, parsedDid: ParsedCheqdDid) {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n const { did, id } = parsedDid\n\n if (!parsedDid.path) {\n throw new CredoError(`Missing path in did ${parsedDid.did}`)\n }\n\n const [, , resourceId] = parsedDid.path.split('/')\n\n if (!resourceId) {\n throw new CredoError(`Missing resource id in didUrl ${parsedDid.didUrl}`)\n }\n\n const metadata = await cheqdLedgerService.resolveResourceMetadata(did, id, resourceId)\n return {\n didDocument: new DidDocument({ id: did }),\n didDocumentMetadata: {\n linkedResourceMetadata: metadata,\n },\n didResolutionMetadata: {},\n }\n }\n\n private async resolveDidDoc(agentContext: AgentContext, did: string, version?: string): Promise<DidResolutionResult> {\n const cheqdLedgerService = agentContext.dependencyManager.resolve(CheqdLedgerService)\n\n const { didDocument, didDocumentMetadata } = await cheqdLedgerService.resolve(did, version)\n const { resources } = await cheqdLedgerService.resolveCollectionResources(did, did.split(':')[3])\n didDocumentMetadata.linkedResourceMetadata = resources\n\n return {\n didDocument: JsonTransformer.fromJSON(didDocument, DidDocument),\n did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ual/rolldown_runtime.js');
2
- let __cheqd_sdk = require("@cheqd/sdk");
3
- __cheqd_sdk = require_rolldown_runtime.__toESM(__cheqd_sdk);
4
2
  let __credo_ts_core = require("@credo-ts/core");
5
3
  __credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);
4
+ let __cheqd_sdk = require("@cheqd/sdk");
5
+ __cheqd_sdk = require_rolldown_runtime.__toESM(__cheqd_sdk);
6
6
  let __cheqd_ts_proto_cheqd_did_v2 = require("@cheqd/ts-proto/cheqd/did/v2");
7
7
  __cheqd_ts_proto_cheqd_did_v2 = require_rolldown_runtime.__toESM(__cheqd_ts_proto_cheqd_did_v2);
8
8
  let __cosmjs_crypto = require("@cosmjs/crypto");
@@ -85,7 +85,7 @@ function generateDidDoc(options) {
85
85
  }
86
86
  function getClosestResourceVersion(resources, date) {
87
87
  let minDiff = Number.POSITIVE_INFINITY;
88
- let closest = void 0;
88
+ let closest;
89
89
  for (const resource of resources) {
90
90
  if (!resource.created) throw new __credo_ts_core.CredoError("Missing required property 'created' on resource");
91
91
  if (resource.created.getTime() < date.getTime()) {
@@ -1,5 +1,5 @@
1
- import { DIDModule, VerificationMethods, createDidPayload, createDidVerificationMethod, createVerificationKeys } from "@cheqd/sdk";
2
1
  import { CredoError, DidDocument, JsonEncoder, JsonTransformer, TypedArrayEncoder } from "@credo-ts/core";
2
+ import { DIDModule, VerificationMethods, createDidPayload, createDidVerificationMethod, createVerificationKeys } from "@cheqd/sdk";
3
3
  import { MsgCreateDidDocPayload, MsgDeactivateDidDocPayload } from "@cheqd/ts-proto/cheqd/did/v2";
4
4
  import { EnglishMnemonic } from "@cosmjs/crypto";
5
5
  import { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from "@cosmjs/proto-signing";
@@ -79,7 +79,7 @@ function generateDidDoc(options) {
79
79
  }
80
80
  function getClosestResourceVersion(resources, date) {
81
81
  let minDiff = Number.POSITIVE_INFINITY;
82
- let closest = void 0;
82
+ let closest;
83
83
  for (const resource of resources) {
84
84
  if (!resource.created) throw new CredoError("Missing required property 'created' on resource");
85
85
  if (resource.created.getTime() < date.getTime()) {
@@ -1 +1 @@
1
- {"version":3,"file":"didCheqdUtil.mjs","names":["closest: Metadata | undefined","EnglishMnemonic","_"],"sources":["../../src/dids/didCheqdUtil.ts"],"sourcesContent":["import type { CheqdNetwork, DIDDocument, MethodSpecificIdAlgo, TVerificationKey } from '@cheqd/sdk'\nimport type { Metadata } from '@cheqd/ts-proto/cheqd/resource/v2'\n\nimport {\n DIDModule,\n VerificationMethods,\n createDidPayload,\n createDidVerificationMethod,\n createVerificationKeys,\n} from '@cheqd/sdk'\nimport { MsgCreateDidDocPayload, MsgDeactivateDidDocPayload } from '@cheqd/ts-proto/cheqd/did/v2'\nimport { EnglishMnemonic as _ } from '@cosmjs/crypto'\nimport { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing'\nimport { CredoError, DidDocument, JsonEncoder, JsonTransformer, TypedArrayEncoder } from '@credo-ts/core'\n\nexport function validateSpecCompliantPayload(didDocument: DidDocument): SpecValidationResult {\n // id is required, validated on both compile and runtime\n if (!didDocument.id && !didDocument.id.startsWith('did:cheqd:')) return { valid: false, error: 'id is required' }\n\n // verificationMethod is required\n if (!didDocument.verificationMethod) return { valid: false, error: 'verificationMethod is required' }\n\n // verificationMethod must be an array\n if (!Array.isArray(didDocument.verificationMethod))\n return { valid: false, error: 'verificationMethod must be an array' }\n\n // verificationMethod must be not be empty\n if (!didDocument.verificationMethod.length) return { valid: false, error: 'verificationMethod must be not be empty' }\n\n // verificationMethod types must be supported\n const isValidVerificationMethod = didDocument.verificationMethod.every((vm) => {\n switch (vm.type) {\n case VerificationMethods.Ed255192020:\n return vm.publicKeyMultibase != null\n case VerificationMethods.JWK:\n return vm.publicKeyJwk != null\n case VerificationMethods.Ed255192018:\n return vm.publicKeyBase58 != null\n default:\n return false\n }\n })\n\n if (!isValidVerificationMethod) return { valid: false, error: 'verificationMethod publicKey is Invalid' }\n\n const isValidService = didDocument.service\n ? didDocument?.service?.every((s) => {\n return s?.serviceEndpoint && s?.id && s?.type\n })\n : true\n\n if (!isValidService) return { valid: false, error: 'Service is Invalid' }\n return { valid: true } as SpecValidationResult\n}\n\n// Create helpers in sdk like MsgCreateDidDocPayload.fromDIDDocument to replace the below\nexport async function createMsgCreateDidDocPayloadToSign(didPayload: DIDDocument, versionId: string) {\n didPayload.service = didPayload.service?.map((e) => {\n return {\n ...e,\n serviceEndpoint: Array.isArray(e.serviceEndpoint) ? e.serviceEndpoint : [e.serviceEndpoint],\n }\n })\n const { protobufVerificationMethod, protobufService } = await DIDModule.validateSpecCompliantPayload(didPayload)\n return MsgCreateDidDocPayload.encode(\n MsgCreateDidDocPayload.fromPartial({\n context: <string[]>didPayload?.['@context'],\n id: didPayload.id,\n controller: <string[]>didPayload.controller,\n verificationMethod: protobufVerificationMethod,\n authentication: <string[]>didPayload.authentication,\n assertionMethod: <string[]>didPayload.assertionMethod,\n capabilityInvocation: <string[]>didPayload.capabilityInvocation,\n capabilityDelegation: <string[]>didPayload.capabilityDelegation,\n keyAgreement: <string[]>didPayload.keyAgreement,\n service: protobufService,\n alsoKnownAs: <string[]>didPayload.alsoKnownAs,\n versionId,\n })\n ).finish()\n}\n\nexport function createMsgDeactivateDidDocPayloadToSign(didPayload: DIDDocument, versionId?: string) {\n return MsgDeactivateDidDocPayload.encode(\n MsgDeactivateDidDocPayload.fromPartial({\n id: didPayload.id,\n versionId,\n })\n ).finish()\n}\n\nexport type SpecValidationResult = {\n valid: boolean\n error?: string\n}\n\nexport function generateDidDoc(options: IDidDocOptions) {\n const { verificationMethod, methodSpecificIdAlgo, verificationMethodId, network, publicKey } = options\n const verificationKeys = createVerificationKeys(publicKey, methodSpecificIdAlgo, verificationMethodId, network)\n if (!verificationKeys) {\n throw new Error('Invalid DID options')\n }\n const verificationMethods = createDidVerificationMethod([verificationMethod], [verificationKeys])\n const didPayload = createDidPayload(verificationMethods, [verificationKeys])\n return JsonTransformer.fromJSON(didPayload, DidDocument)\n}\n\nexport interface IDidDocOptions {\n verificationMethod: VerificationMethods\n verificationMethodId: TVerificationKey<string, number>\n methodSpecificIdAlgo: MethodSpecificIdAlgo\n network: CheqdNetwork\n publicKey: string\n}\n\nexport function getClosestResourceVersion(resources: Metadata[], date: Date) {\n let minDiff = Number.POSITIVE_INFINITY\n let closest: Metadata | undefined = undefined\n\n // TODO: if the cheqd/sdk returns sorted resources, change this to binary search\n for (const resource of resources) {\n if (!resource.created) throw new CredoError(\"Missing required property 'created' on resource\")\n\n if (resource.created.getTime() < date.getTime()) {\n const diff = date.getTime() - resource.created.getTime()\n\n if (diff < minDiff) {\n closest = resource\n minDiff = diff\n }\n }\n }\n\n return closest\n}\n\nexport function filterResourcesByNameAndType(resources: Metadata[], name: string, type: string) {\n return resources.filter((resource) => resource.name === name && resource.resourceType === type)\n}\n\nexport async function renderResourceData(data: Uint8Array, mimeType: string) {\n if (mimeType === 'application/json') {\n return await JsonEncoder.fromBuffer(data)\n }\n if (mimeType === 'text/plain') {\n return TypedArrayEncoder.toUtf8String(data)\n }\n return TypedArrayEncoder.toBase64URL(data)\n}\n\nexport class EnglishMnemonic extends _ {\n public static readonly _mnemonicMatcher = /^[a-z]+( [a-z]+)*$/\n}\n\nexport function getCosmosPayerWallet(cosmosPayerSeed?: string) {\n if (!cosmosPayerSeed || cosmosPayerSeed === '') {\n return DirectSecp256k1HdWallet.generate()\n }\n return EnglishMnemonic._mnemonicMatcher.test(cosmosPayerSeed)\n ? DirectSecp256k1HdWallet.fromMnemonic(cosmosPayerSeed, { prefix: 'cheqd' })\n : DirectSecp256k1Wallet.fromKey(TypedArrayEncoder.fromString(cosmosPayerSeed.replace(/^0x/, '')), 'cheqd')\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,6BAA6B,aAAgD;AAE3F,KAAI,CAAC,YAAY,MAAM,CAAC,YAAY,GAAG,WAAW,aAAa,CAAE,QAAO;EAAE,OAAO;EAAO,OAAO;EAAkB;AAG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,oBAAoB,GAC1C,QAAO,wBAAwB,UAAU;AAE3C,QAAOD,kBAAgB,iBAAiB,KAAK,gBAAgB,GACzD,wBAAwB,aAAa,iBAAiB,EAAE,QAAQ,SAAS,CAAC,GAC1E,sBAAsB,QAAQ,kBAAkB,WAAW,gBAAgB,QAAQ,OAAO,GAAG,CAAC,EAAE,QAAQ"}
1
+ {"version":3,"file":"didCheqdUtil.mjs","names":["closest: Metadata | undefined","EnglishMnemonic","_"],"sources":["../../src/dids/didCheqdUtil.ts"],"sourcesContent":["import type { CheqdNetwork, DIDDocument, MethodSpecificIdAlgo, TVerificationKey } from '@cheqd/sdk'\nimport {\n createDidPayload,\n createDidVerificationMethod,\n createVerificationKeys,\n DIDModule,\n VerificationMethods,\n} from '@cheqd/sdk'\nimport { MsgCreateDidDocPayload, MsgDeactivateDidDocPayload } from '@cheqd/ts-proto/cheqd/did/v2'\nimport type { Metadata } from '@cheqd/ts-proto/cheqd/resource/v2'\nimport { EnglishMnemonic as _ } from '@cosmjs/crypto'\nimport { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing'\nimport {\n type AnyUint8Array,\n CredoError,\n DidDocument,\n JsonEncoder,\n JsonTransformer,\n TypedArrayEncoder,\n} from '@credo-ts/core'\n\nexport function validateSpecCompliantPayload(didDocument: DidDocument): SpecValidationResult {\n // id is required, validated on both compile and runtime\n if (!didDocument.id && !didDocument.id.startsWith('did:cheqd:')) return { valid: false, error: 'id is required' }\n\n // verificationMethod is required\n if (!didDocument.verificationMethod) return { valid: false, error: 'verificationMethod is required' }\n\n // verificationMethod must be an array\n if (!Array.isArray(didDocument.verificationMethod))\n return { valid: false, error: 'verificationMethod must be an array' }\n\n // verificationMethod must be not be empty\n if (!didDocument.verificationMethod.length) return { valid: false, error: 'verificationMethod must be not be empty' }\n\n // verificationMethod types must be supported\n const isValidVerificationMethod = didDocument.verificationMethod.every((vm) => {\n switch (vm.type) {\n case VerificationMethods.Ed255192020:\n return vm.publicKeyMultibase != null\n case VerificationMethods.JWK:\n return vm.publicKeyJwk != null\n case VerificationMethods.Ed255192018:\n return vm.publicKeyBase58 != null\n default:\n return false\n }\n })\n\n if (!isValidVerificationMethod) return { valid: false, error: 'verificationMethod publicKey is Invalid' }\n\n const isValidService = didDocument.service\n ? didDocument?.service?.every((s) => {\n return s?.serviceEndpoint && s?.id && s?.type\n })\n : true\n\n if (!isValidService) return { valid: false, error: 'Service is Invalid' }\n return { valid: true } as SpecValidationResult\n}\n\n// Create helpers in sdk like MsgCreateDidDocPayload.fromDIDDocument to replace the below\nexport async function createMsgCreateDidDocPayloadToSign(didPayload: DIDDocument, versionId: string) {\n didPayload.service = didPayload.service?.map((e) => {\n return {\n ...e,\n serviceEndpoint: Array.isArray(e.serviceEndpoint) ? e.serviceEndpoint : [e.serviceEndpoint],\n }\n })\n const { protobufVerificationMethod, protobufService } = await DIDModule.validateSpecCompliantPayload(didPayload)\n return MsgCreateDidDocPayload.encode(\n MsgCreateDidDocPayload.fromPartial({\n context: <string[]>didPayload?.['@context'],\n id: didPayload.id,\n controller: <string[]>didPayload.controller,\n verificationMethod: protobufVerificationMethod,\n authentication: <string[]>didPayload.authentication,\n assertionMethod: <string[]>didPayload.assertionMethod,\n capabilityInvocation: <string[]>didPayload.capabilityInvocation,\n capabilityDelegation: <string[]>didPayload.capabilityDelegation,\n keyAgreement: <string[]>didPayload.keyAgreement,\n service: protobufService,\n alsoKnownAs: <string[]>didPayload.alsoKnownAs,\n versionId,\n })\n ).finish()\n}\n\nexport function createMsgDeactivateDidDocPayloadToSign(didPayload: DIDDocument, versionId?: string) {\n return MsgDeactivateDidDocPayload.encode(\n MsgDeactivateDidDocPayload.fromPartial({\n id: didPayload.id,\n versionId,\n })\n ).finish()\n}\n\nexport type SpecValidationResult = {\n valid: boolean\n error?: string\n}\n\nexport function generateDidDoc(options: IDidDocOptions) {\n const { verificationMethod, methodSpecificIdAlgo, verificationMethodId, network, publicKey } = options\n const verificationKeys = createVerificationKeys(publicKey, methodSpecificIdAlgo, verificationMethodId, network)\n if (!verificationKeys) {\n throw new Error('Invalid DID options')\n }\n const verificationMethods = createDidVerificationMethod([verificationMethod], [verificationKeys])\n const didPayload = createDidPayload(verificationMethods, [verificationKeys])\n return JsonTransformer.fromJSON(didPayload, DidDocument)\n}\n\nexport interface IDidDocOptions {\n verificationMethod: VerificationMethods\n verificationMethodId: TVerificationKey<string, number>\n methodSpecificIdAlgo: MethodSpecificIdAlgo\n network: CheqdNetwork\n publicKey: string\n}\n\nexport function getClosestResourceVersion(resources: Metadata[], date: Date) {\n let minDiff = Number.POSITIVE_INFINITY\n let closest: Metadata | undefined\n\n // TODO: if the cheqd/sdk returns sorted resources, change this to binary search\n for (const resource of resources) {\n if (!resource.created) throw new CredoError(\"Missing required property 'created' on resource\")\n\n if (resource.created.getTime() < date.getTime()) {\n const diff = date.getTime() - resource.created.getTime()\n\n if (diff < minDiff) {\n closest = resource\n minDiff = diff\n }\n }\n }\n\n return closest\n}\n\nexport function filterResourcesByNameAndType(resources: Metadata[], name: string, type: string) {\n return resources.filter((resource) => resource.name === name && resource.resourceType === type)\n}\n\nexport async function renderResourceData(data: AnyUint8Array, mimeType: string) {\n if (mimeType === 'application/json') {\n return await JsonEncoder.fromBuffer(data)\n }\n if (mimeType === 'text/plain') {\n return TypedArrayEncoder.toUtf8String(data)\n }\n return TypedArrayEncoder.toBase64URL(data)\n}\n\nexport class EnglishMnemonic extends _ {\n public static readonly _mnemonicMatcher = /^[a-z]+( [a-z]+)*$/\n}\n\nexport function getCosmosPayerWallet(cosmosPayerSeed?: string) {\n if (!cosmosPayerSeed || cosmosPayerSeed === '') {\n return DirectSecp256k1HdWallet.generate()\n }\n return EnglishMnemonic._mnemonicMatcher.test(cosmosPayerSeed)\n ? DirectSecp256k1HdWallet.fromMnemonic(cosmosPayerSeed, { prefix: 'cheqd' })\n : DirectSecp256k1Wallet.fromKey(TypedArrayEncoder.fromString(cosmosPayerSeed.replace(/^0x/, '')), 'cheqd')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Aa,KAAK;AAE7C,QAAO,kBAAkB,YAAY,KAAK;;AAG5C,IAAaC,oBAAb,cAAqCC,gBAAE;kBACd,mBAAmB;AAG5C,SAAgB,qBAAqB,iBAA0B;AAC7D,KAAI,CAAC,mBAAmB,oBAAoB,GAC1C,QAAO,wBAAwB,UAAU;AAE3C,QAAOD,kBAAgB,iBAAiB,KAAK,gBAAgB,GACzD,wBAAwB,aAAa,iBAAiB,EAAE,QAAQ,SAAS,CAAC,GAC1E,sBAAsB,QAAQ,kBAAkB,WAAW,gBAAgB,QAAQ,OAAO,GAAG,CAAC,EAAE,QAAQ"}
package/build/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
+ import { CheqdAnonCredsRegistry } from "./anoncreds/services/CheqdAnonCredsRegistry.mjs";
1
2
  import { CheqdDidCreateOptions, CheqdDidDeactivateOptions, CheqdDidRegistrar, CheqdDidUpdateOptions } from "./dids/CheqdDidRegistrar.mjs";
2
3
  import { CheqdDidResolver } from "./dids/CheqdDidResolver.mjs";
3
- import { CheqdAnonCredsRegistry } from "./anoncreds/services/CheqdAnonCredsRegistry.mjs";
4
4
  import { CheqdModuleConfig, CheqdModuleConfigOptions } from "./CheqdModuleConfig.mjs";
5
- import { CheqdLedgerService } from "./ledger/CheqdLedgerService.mjs";
6
5
  import { CheqdModule } from "./CheqdModule.mjs";
6
+ import { CheqdLedgerService } from "./ledger/CheqdLedgerService.mjs";
7
7
  export { CheqdAnonCredsRegistry, type CheqdDidCreateOptions, type CheqdDidDeactivateOptions, CheqdDidRegistrar, CheqdDidResolver, type CheqdDidUpdateOptions, CheqdLedgerService, CheqdModule, CheqdModuleConfig, type CheqdModuleConfigOptions };
package/build/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import { CheqdAnonCredsRegistry } from "./anoncreds/services/CheqdAnonCredsRegistry.js";
1
2
  import { CheqdDidCreateOptions, CheqdDidDeactivateOptions, CheqdDidRegistrar, CheqdDidUpdateOptions } from "./dids/CheqdDidRegistrar.js";
2
3
  import { CheqdDidResolver } from "./dids/CheqdDidResolver.js";
3
- import { CheqdAnonCredsRegistry } from "./anoncreds/services/CheqdAnonCredsRegistry.js";
4
4
  import { CheqdModuleConfig, CheqdModuleConfigOptions } from "./CheqdModuleConfig.js";
5
- import { CheqdLedgerService } from "./ledger/CheqdLedgerService.js";
6
5
  import { CheqdModule } from "./CheqdModule.js";
6
+ import { CheqdLedgerService } from "./ledger/CheqdLedgerService.js";
7
7
  export { CheqdAnonCredsRegistry, type CheqdDidCreateOptions, type CheqdDidDeactivateOptions, CheqdDidRegistrar, CheqdDidResolver, type CheqdDidUpdateOptions, CheqdLedgerService, CheqdModule, CheqdModuleConfig, type CheqdModuleConfigOptions };
@@ -1,7 +1,7 @@
1
1
  import { CheqdModuleConfig } from "../CheqdModuleConfig.mjs";
2
+ import { DidDocumentMetadata, Logger } from "@credo-ts/core";
2
3
  import * as _cheqd_sdk0 from "@cheqd/sdk";
3
4
  import { DIDDocument, DidStdFee } from "@cheqd/sdk";
4
- import { DidDocumentMetadata, Logger } from "@credo-ts/core";
5
5
  import { Metadata, MsgCreateResourcePayload, QueryCollectionResourcesResponse, ResourceWithMetadata } from "@cheqd/ts-proto/cheqd/resource/v2";
6
6
  import { QueryAllDidDocVersionsMetadataResponse, SignInfo } from "@cheqd/ts-proto/cheqd/did/v2";
7
7
  import { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from "@cosmjs/proto-signing";
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdLedgerService.d.mts","names":[],"sources":["../../src/ledger/CheqdLedgerService.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA8HU,cA9FG,kBAAA,CA8FH;UACG,QAAA;UAAR,MAAA;aAMW,CAAA,oBAAA,EAjG2B,iBAiG3B,EAAA,MAAA,EAjGuF,MAiGvF;SACA,CAAA,CAAA,EAtFM,OAsFN,CAAA,IAAA,CAAA;YAEN,CAAA,CAAA,EA9Ee,OA8Ef,CAAA,IAAA,CAAA;UACG,MAAA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ARL,CAQa,wBARb,CAAA,EAAA,UAAA,EASA,QATA,EAAA,EAAA,GAAA,CAAA,EAUN,SAVM,CAAA,EAWX,OAXW,CAWH,iBAXG,CAAA;iBAF6B,CAAA,GAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,CAAA,EAkB0C,OAlB1C,CAkBkD,oBAlBlD,CAAA;4BAUhB,CAAA,GAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,CAAA,EAgBxB,OAhBwB,CAgBhB,gCAhBgB,CAAA;yBAAR,CAAA,GAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,CAAA,EAqB0E,OArB1E,CAqBkF,QArBlF,CAAA"}
@@ -1,8 +1,8 @@
1
1
  import { CheqdModuleConfig } from "../CheqdModuleConfig.js";
2
- import * as _cheqd_sdk0 from "@cheqd/sdk";
3
- import { DIDDocument, DidStdFee } from "@cheqd/sdk";
4
2
  import { DidDocumentMetadata, Logger } from "@credo-ts/core";
5
3
  import { Metadata, MsgCreateResourcePayload, QueryCollectionResourcesResponse, ResourceWithMetadata } from "@cheqd/ts-proto/cheqd/resource/v2";
4
+ import * as _cheqd_sdk0 from "@cheqd/sdk";
5
+ import { DIDDocument, DidStdFee } from "@cheqd/sdk";
6
6
  import { QueryAllDidDocVersionsMetadataResponse, SignInfo } from "@cheqd/ts-proto/cheqd/did/v2";
7
7
  import { DeliverTxResponse } from "@cosmjs/stargate";
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdLedgerService.d.ts","names":[],"sources":["../../src/ledger/CheqdLedgerService.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AA+Ha,cA/FA,kBAAA,CA+FA;UAAR,QAAA;UAMW,MAAA;aACA,CAAA,oBAAA,EAlG2B,iBAkG3B,EAAA,MAAA,EAlGuF,MAkGvF;SAEN,CAAA,CAAA,EAxFY,OAwFZ,CAAA,IAAA,CAAA;YACG,CAAA,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gBADY,CAAA,GAAA,EAAA,MAAA,EAAA,eAAA,EAUxB,OAVwB,CAUhB,wBAVgB,CAAA,EAAA,UAAA,EAW7B,QAX6B,EAAA,EAAA,GAAA,CAAA,EAYnC,SAZmC,CAAA,EAaxC,OAbwC,CAahC,iBAbgC,CAAA;iBAUhB,CAAA,GAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,CAAA,EAQ0D,OAR1D,CAQkE,oBARlE,CAAA;4BAAR,CAAA,GAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,CAAA,EAgBhB,OAhBgB,CAgBR,gCAhBQ,CAAA;yBACL,CAAA,GAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,CAAA,EAoB+E,OApB/E,CAoBuF,QApBvF,CAAA"}
@@ -5,10 +5,10 @@ const require_didCheqdUtil = require('../dids/didCheqdUtil.js');
5
5
  const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.js');
6
6
  const require_decorateParam = require('../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateParam.js');
7
7
  const require_decorate = require('../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js');
8
- let __cheqd_sdk = require("@cheqd/sdk");
9
- __cheqd_sdk = require_rolldown_runtime.__toESM(__cheqd_sdk);
10
8
  let __credo_ts_core = require("@credo-ts/core");
11
9
  __credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);
10
+ let __cheqd_sdk = require("@cheqd/sdk");
11
+ __cheqd_sdk = require_rolldown_runtime.__toESM(__cheqd_sdk);
12
12
 
13
13
  //#region src/ledger/CheqdLedgerService.ts
14
14
  var _ref;
@@ -4,8 +4,8 @@ import { getCosmosPayerWallet } from "../dids/didCheqdUtil.mjs";
4
4
  import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.mjs";
5
5
  import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateParam.mjs";
6
6
  import { __decorate } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.mjs";
7
- import { CheqdNetwork, DIDModule, FeemarketModule, ResourceModule, createCheqdSDK } from "@cheqd/sdk";
8
7
  import { CredoError, InjectionSymbols, inject, injectable } from "@credo-ts/core";
8
+ import { CheqdNetwork, DIDModule, FeemarketModule, ResourceModule, createCheqdSDK } from "@cheqd/sdk";
9
9
 
10
10
  //#region src/ledger/CheqdLedgerService.ts
11
11
  var _ref;
@@ -1 +1 @@
1
- {"version":3,"file":"CheqdLedgerService.mjs","names":["CheqdLedgerService","logger: Logger","network"],"sources":["../../src/ledger/CheqdLedgerService.ts"],"sourcesContent":["import type { AbstractCheqdSDKModule, CheqdSDK, DIDDocument, DidStdFee } from '@cheqd/sdk'\nimport type { QueryAllDidDocVersionsMetadataResponse, SignInfo } from '@cheqd/ts-proto/cheqd/did/v2'\nimport type {\n Metadata,\n MsgCreateResourcePayload,\n QueryCollectionResourcesResponse,\n ResourceWithMetadata,\n} from '@cheqd/ts-proto/cheqd/resource/v2'\nimport type { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing'\nimport type { DidDocumentMetadata } from '@credo-ts/core'\n\nimport { CheqdNetwork, DIDModule, FeemarketModule, ResourceModule, createCheqdSDK } from '@cheqd/sdk'\nimport { CredoError, InjectionSymbols, type Logger, inject, injectable } from '@credo-ts/core'\n\nimport type { DeliverTxResponse } from '@cosmjs/stargate'\nimport { CheqdModuleConfig } from '../CheqdModuleConfig'\nimport { parseCheqdDid } from '../anoncreds/utils/identifiers'\nimport { getCosmosPayerWallet } from '../dids/didCheqdUtil'\n\nexport interface ICheqdLedgerConfig {\n network: string\n rpcUrl: string\n readonly cosmosPayerWallet: Promise<DirectSecp256k1HdWallet | DirectSecp256k1Wallet>\n sdk?: Promise<CheqdSDK>\n}\n\nexport enum DefaultRPCUrl {\n Mainnet = 'https://rpc.cheqd.net',\n Testnet = 'https://rpc.cheqd.network',\n}\n\n@injectable()\nexport class CheqdLedgerService {\n private networks: ICheqdLedgerConfig[]\n private logger: Logger\n\n public constructor(cheqdSdkModuleConfig: CheqdModuleConfig, @inject(InjectionSymbols.Logger) logger: Logger) {\n this.logger = logger\n this.networks = cheqdSdkModuleConfig.networks.map((config) => {\n const { network, rpcUrl, cosmosPayerSeed } = config\n return {\n network,\n rpcUrl: rpcUrl ? rpcUrl : network === CheqdNetwork.Mainnet ? DefaultRPCUrl.Mainnet : DefaultRPCUrl.Testnet,\n cosmosPayerWallet: getCosmosPayerWallet(cosmosPayerSeed),\n }\n })\n }\n\n public async connect() {\n for (const network of this.networks) {\n if (!network.sdk) {\n await this.initializeSdkForNetwork(network)\n } else {\n this.logger.debug(`Not connecting to network ${network} as SDK already initialized`)\n }\n }\n }\n\n public async disconnect() {\n for (const network of this.networks) {\n const _a = await network.sdk\n if (!network.sdk) {\n await this.initializeSdkForNetwork(network)\n } else {\n this.logger.debug(`Not connecting to network ${network} as SDK already initialized`)\n }\n }\n }\n\n private async getSdk(did: string) {\n const parsedDid = parseCheqdDid(did)\n if (!parsedDid) {\n throw new Error('Invalid DID')\n }\n if (this.networks.length === 0) {\n throw new Error('No cheqd networks configured')\n }\n\n const network = this.networks.find((network) => network.network === parsedDid.network)\n if (!network) {\n throw new Error(`Network ${network} not found in cheqd networks configuration`)\n }\n\n if (!network.sdk) {\n const sdk = await this.initializeSdkForNetwork(network)\n if (!sdk) throw new Error(`Cheqd SDK not initialized for network ${parsedDid.network}`)\n return sdk\n }\n\n try {\n const sdk = await network.sdk\n return sdk\n } catch (error) {\n throw new Error(`Error initializing cheqd sdk for network ${parsedDid.network}: ${error.message}`)\n }\n }\n\n private async initializeSdkForNetwork(network: ICheqdLedgerConfig) {\n try {\n // Initialize cheqd sdk with promise\n network.sdk = createCheqdSDK({\n modules: [\n FeemarketModule as unknown as AbstractCheqdSDKModule,\n DIDModule as unknown as AbstractCheqdSDKModule,\n ResourceModule as unknown as AbstractCheqdSDKModule,\n ],\n rpcUrl: network.rpcUrl,\n wallet: await network.cosmosPayerWallet.catch((error) => {\n throw new CredoError(`Error initializing cosmos payer wallet: ${error.message}`, { cause: error })\n }),\n })\n\n return await network.sdk\n } catch (error) {\n this.logger.error(\n `Skipping connection for network ${network.network} in cheqd sdk due to error in initialization: ${error.message}`\n )\n network.sdk = undefined\n return undefined\n }\n }\n\n public async create(\n didPayload: DIDDocument,\n signInputs: SignInfo[],\n versionId?: string | undefined,\n fee?: DidStdFee\n ): Promise<DeliverTxResponse> {\n const sdk = await this.getSdk(didPayload.id)\n return sdk.createDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)\n }\n\n public async update(\n didPayload: DIDDocument,\n signInputs: SignInfo[],\n versionId?: string | undefined,\n fee?: DidStdFee\n ): Promise<DeliverTxResponse> {\n const sdk = await this.getSdk(didPayload.id)\n return sdk.updateDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)\n }\n\n public async deactivate(\n didPayload: DIDDocument,\n signInputs: SignInfo[],\n versionId?: string | undefined,\n fee?: DidStdFee\n ): Promise<DeliverTxResponse> {\n const sdk = await this.getSdk(didPayload.id)\n return sdk.deactivateDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)\n }\n\n public async resolve(did: string, version?: string) {\n const sdk = await this.getSdk(did)\n return version ? sdk.queryDidDocVersion(did, version) : sdk.queryDidDoc(did)\n }\n\n public async resolveMetadata(did: string): Promise<{\n didDocumentVersionsMetadata: DidDocumentMetadata[]\n pagination: QueryAllDidDocVersionsMetadataResponse['pagination']\n }> {\n const sdk = await this.getSdk(did)\n return sdk.queryAllDidDocVersionsMetadata(did)\n }\n\n public async createResource(\n did: string,\n resourcePayload: Partial<MsgCreateResourcePayload>,\n signInputs: SignInfo[],\n fee?: DidStdFee\n ): Promise<DeliverTxResponse> {\n const sdk = await this.getSdk(did)\n return sdk.createLinkedResourceTx(signInputs, resourcePayload, '', fee, undefined)\n }\n\n public async resolveResource(did: string, collectionId: string, resourceId: string): Promise<ResourceWithMetadata> {\n const sdk = await this.getSdk(did)\n return sdk.queryLinkedResource(collectionId, resourceId)\n }\n\n public async resolveCollectionResources(\n did: string,\n collectionId: string\n ): Promise<QueryCollectionResourcesResponse> {\n const sdk = await this.getSdk(did)\n return sdk.queryLinkedResources(collectionId)\n }\n\n public async resolveResourceMetadata(did: string, collectionId: string, resourceId: string): Promise<Metadata> {\n const sdk = await this.getSdk(did)\n return sdk.queryLinkedResourceMetadata(collectionId, resourceId)\n }\n}\n"],"mappings":";;;;;;;;;;;AA0BA,IAAY,0DAAL;AACL;AACA;;;AAIK,+BAAMA,qBAAmB;CAI9B,AAAO,YAAY,sBAAyC,AAAiCC,QAAgB;AAC3G,OAAK,SAAS;AACd,OAAK,WAAW,qBAAqB,SAAS,KAAK,WAAW;GAC5D,MAAM,EAAE,SAAS,QAAQ,oBAAoB;AAC7C,UAAO;IACL;IACA,QAAQ,SAAS,SAAS,YAAY,aAAa,UAAU,cAAc,UAAU,cAAc;IACnG,mBAAmB,qBAAqB,gBAAgB;IACzD;IACD;;CAGJ,MAAa,UAAU;AACrB,OAAK,MAAM,WAAW,KAAK,SACzB,KAAI,CAAC,QAAQ,IACX,OAAM,KAAK,wBAAwB,QAAQ;MAE3C,MAAK,OAAO,MAAM,6BAA6B,QAAQ,6BAA6B;;CAK1F,MAAa,aAAa;AACxB,OAAK,MAAM,WAAW,KAAK,UAAU;AACxB,SAAM,QAAQ;AACzB,OAAI,CAAC,QAAQ,IACX,OAAM,KAAK,wBAAwB,QAAQ;OAE3C,MAAK,OAAO,MAAM,6BAA6B,QAAQ,6BAA6B;;;CAK1F,MAAc,OAAO,KAAa;EAChC,MAAM,YAAY,cAAc,IAAI;AACpC,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,cAAc;AAEhC,MAAI,KAAK,SAAS,WAAW,EAC3B,OAAM,IAAI,MAAM,+BAA+B;EAGjD,MAAM,UAAU,KAAK,SAAS,MAAM,cAAYC,UAA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B,KAAK,QAAQ,GAAG,IAAI,YAAY,IAAI;;CAG9E,MAAa,gBAAgB,KAG1B;AAED,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,+BAA+B,IAAI;;CAGhD,MAAa,eACX,KACA,iBACA,YACA,KAC4B;AAE5B,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,uBAAuB,YAAY,iBAAiB,IAAI,KAAK,OAAU;;CAGpF,MAAa,gBAAgB,KAAa,cAAsB,YAAmD;AAEjH,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,oBAAoB,cAAc,WAAW;;CAG1D,MAAa,2BACX,KACA,cAC2C;AAE3C,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,qBAAqB,aAAa;;CAG/C,MAAa,wBAAwB,KAAa,cAAsB,YAAuC;AAE7G,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,4BAA4B,cAAc,WAAW;;;;CA/JnE,YAAY;oBAKkD,OAAO,iBAAiB,OAAO"}
1
+ {"version":3,"file":"CheqdLedgerService.mjs","names":["CheqdLedgerService","logger: Logger","network"],"sources":["../../src/ledger/CheqdLedgerService.ts"],"sourcesContent":["import type { AbstractCheqdSDKModule, CheqdSDK, DIDDocument, DidStdFee } from '@cheqd/sdk'\nimport { CheqdNetwork, createCheqdSDK, DIDModule, FeemarketModule, ResourceModule } from '@cheqd/sdk'\nimport type { QueryAllDidDocVersionsMetadataResponse, SignInfo } from '@cheqd/ts-proto/cheqd/did/v2'\nimport type {\n Metadata,\n MsgCreateResourcePayload,\n QueryCollectionResourcesResponse,\n ResourceWithMetadata,\n} from '@cheqd/ts-proto/cheqd/resource/v2'\nimport type { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing'\nimport type { DeliverTxResponse } from '@cosmjs/stargate'\nimport type { DidDocumentMetadata } from '@credo-ts/core'\nimport { CredoError, InjectionSymbols, inject, injectable, type Logger } from '@credo-ts/core'\nimport { parseCheqdDid } from '../anoncreds/utils/identifiers'\nimport { CheqdModuleConfig } from '../CheqdModuleConfig'\nimport { getCosmosPayerWallet } from '../dids/didCheqdUtil'\n\nexport interface ICheqdLedgerConfig {\n network: string\n rpcUrl: string\n readonly cosmosPayerWallet: Promise<DirectSecp256k1HdWallet | DirectSecp256k1Wallet>\n sdk?: Promise<CheqdSDK>\n}\n\nexport enum DefaultRPCUrl {\n Mainnet = 'https://rpc.cheqd.net',\n Testnet = 'https://rpc.cheqd.network',\n}\n\n@injectable()\nexport class CheqdLedgerService {\n private networks: ICheqdLedgerConfig[]\n private logger: Logger\n\n public constructor(cheqdSdkModuleConfig: CheqdModuleConfig, @inject(InjectionSymbols.Logger) logger: Logger) {\n this.logger = logger\n this.networks = cheqdSdkModuleConfig.networks.map((config) => {\n const { network, rpcUrl, cosmosPayerSeed } = config\n return {\n network,\n rpcUrl: rpcUrl ? rpcUrl : network === CheqdNetwork.Mainnet ? DefaultRPCUrl.Mainnet : DefaultRPCUrl.Testnet,\n cosmosPayerWallet: getCosmosPayerWallet(cosmosPayerSeed),\n }\n })\n }\n\n public async connect() {\n for (const network of this.networks) {\n if (!network.sdk) {\n await this.initializeSdkForNetwork(network)\n } else {\n this.logger.debug(`Not connecting to network ${network} as SDK already initialized`)\n }\n }\n }\n\n public async disconnect() {\n for (const network of this.networks) {\n const _a = await network.sdk\n if (!network.sdk) {\n await this.initializeSdkForNetwork(network)\n } else {\n this.logger.debug(`Not connecting to network ${network} as SDK already initialized`)\n }\n }\n }\n\n private async getSdk(did: string) {\n const parsedDid = parseCheqdDid(did)\n if (!parsedDid) {\n throw new Error('Invalid DID')\n }\n if (this.networks.length === 0) {\n throw new Error('No cheqd networks configured')\n }\n\n const network = this.networks.find((network) => network.network === parsedDid.network)\n if (!network) {\n throw new Error(`Network ${network} not found in cheqd networks configuration`)\n }\n\n if (!network.sdk) {\n const sdk = await this.initializeSdkForNetwork(network)\n if (!sdk) throw new Error(`Cheqd SDK not initialized for network ${parsedDid.network}`)\n return sdk\n }\n\n try {\n const sdk = await network.sdk\n return sdk\n } catch (error) {\n throw new Error(`Error initializing cheqd sdk for network ${parsedDid.network}: ${error.message}`)\n }\n }\n\n private async initializeSdkForNetwork(network: ICheqdLedgerConfig) {\n try {\n // Initialize cheqd sdk with promise\n network.sdk = createCheqdSDK({\n modules: [\n FeemarketModule as unknown as AbstractCheqdSDKModule,\n DIDModule as unknown as AbstractCheqdSDKModule,\n ResourceModule as unknown as AbstractCheqdSDKModule,\n ],\n rpcUrl: network.rpcUrl,\n wallet: await network.cosmosPayerWallet.catch((error) => {\n throw new CredoError(`Error initializing cosmos payer wallet: ${error.message}`, { cause: error })\n }),\n })\n\n return await network.sdk\n } catch (error) {\n this.logger.error(\n `Skipping connection for network ${network.network} in cheqd sdk due to error in initialization: ${error.message}`\n )\n network.sdk = undefined\n return undefined\n }\n }\n\n public async create(\n didPayload: DIDDocument,\n signInputs: SignInfo[],\n versionId?: string | undefined,\n fee?: DidStdFee\n ): Promise<DeliverTxResponse> {\n const sdk = await this.getSdk(didPayload.id)\n return sdk.createDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)\n }\n\n public async update(\n didPayload: DIDDocument,\n signInputs: SignInfo[],\n versionId?: string | undefined,\n fee?: DidStdFee\n ): Promise<DeliverTxResponse> {\n const sdk = await this.getSdk(didPayload.id)\n return sdk.updateDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)\n }\n\n public async deactivate(\n didPayload: DIDDocument,\n signInputs: SignInfo[],\n versionId?: string | undefined,\n fee?: DidStdFee\n ): Promise<DeliverTxResponse> {\n const sdk = await this.getSdk(didPayload.id)\n return sdk.deactivateDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)\n }\n\n public async resolve(did: string, version?: string) {\n const sdk = await this.getSdk(did)\n return version ? sdk.queryDidDocVersion(did, version) : sdk.queryDidDoc(did)\n }\n\n public async resolveMetadata(did: string): Promise<{\n didDocumentVersionsMetadata: DidDocumentMetadata[]\n pagination: QueryAllDidDocVersionsMetadataResponse['pagination']\n }> {\n const sdk = await this.getSdk(did)\n return sdk.queryAllDidDocVersionsMetadata(did)\n }\n\n public async createResource(\n did: string,\n resourcePayload: Partial<MsgCreateResourcePayload>,\n signInputs: SignInfo[],\n fee?: DidStdFee\n ): Promise<DeliverTxResponse> {\n const sdk = await this.getSdk(did)\n return sdk.createLinkedResourceTx(signInputs, resourcePayload, '', fee, undefined)\n }\n\n public async resolveResource(did: string, collectionId: string, resourceId: string): Promise<ResourceWithMetadata> {\n const sdk = await this.getSdk(did)\n return sdk.queryLinkedResource(collectionId, resourceId)\n }\n\n public async resolveCollectionResources(\n did: string,\n collectionId: string\n ): Promise<QueryCollectionResourcesResponse> {\n const sdk = await this.getSdk(did)\n return sdk.queryLinkedResources(collectionId)\n }\n\n public async resolveResourceMetadata(did: string, collectionId: string, resourceId: string): Promise<Metadata> {\n const sdk = await this.getSdk(did)\n return sdk.queryLinkedResourceMetadata(collectionId, resourceId)\n }\n}\n"],"mappings":";;;;;;;;;;;AAwBA,IAAY,0DAAL;AACL;AACA;;;AAIK,+BAAMA,qBAAmB;CAI9B,AAAO,YAAY,sBAAyC,AAAiCC,QAAgB;AAC3G,OAAK,SAAS;AACd,OAAK,WAAW,qBAAqB,SAAS,KAAK,WAAW;GAC5D,MAAM,EAAE,SAAS,QAAQ,oBAAoB;AAC7C,UAAO;IACL;IACA,QAAQ,SAAS,SAAS,YAAY,aAAa,UAAU,cAAc,UAAU,cAAc;IACnG,mBAAmB,qBAAqB,gBAAgB;IACzD;IACD;;CAGJ,MAAa,UAAU;AACrB,OAAK,MAAM,WAAW,KAAK,SACzB,KAAI,CAAC,QAAQ,IACX,OAAM,KAAK,wBAAwB,QAAQ;MAE3C,MAAK,OAAO,MAAM,6BAA6B,QAAQ,6BAA6B;;CAK1F,MAAa,aAAa;AACxB,OAAK,MAAM,WAAW,KAAK,UAAU;AACxB,SAAM,QAAQ;AACzB,OAAI,CAAC,QAAQ,IACX,OAAM,KAAK,wBAAwB,QAAQ;OAE3C,MAAK,OAAO,MAAM,6B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CAGlF,MAAa,WACX,YACA,YACA,WACA,KAC4B;AAE5B,UADY,MAAM,KAAK,OAAO,WAAW,GAAG,EACjC,mBAAmB,YAAY,YAAY,IAAI,KAAK,QAAW,UAAU;;CAGtF,MAAa,QAAQ,KAAa,SAAkB;EAClD,MAAM,MAAM,MAAM,KAAK,OAAO,IAAI;AAClC,SAAO,UAAU,IAAI,mBAAmB,KAAK,QAAQ,GAAG,IAAI,YAAY,IAAI;;CAG9E,MAAa,gBAAgB,KAG1B;AAED,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,+BAA+B,IAAI;;CAGhD,MAAa,eACX,KACA,iBACA,YACA,KAC4B;AAE5B,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,uBAAuB,YAAY,iBAAiB,IAAI,KAAK,OAAU;;CAGpF,MAAa,gBAAgB,KAAa,cAAsB,YAAmD;AAEjH,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,oBAAoB,cAAc,WAAW;;CAG1D,MAAa,2BACX,KACA,cAC2C;AAE3C,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,qBAAqB,aAAa;;CAG/C,MAAa,wBAAwB,KAAa,cAAsB,YAAuC;AAE7G,UADY,MAAM,KAAK,OAAO,IAAI,EACvB,4BAA4B,cAAc,WAAW;;;;CA/JnE,YAAY;oBAKkD,OAAO,iBAAiB,OAAO"}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "./package.json": "./package.json"
10
10
  },
11
- "version": "0.6.0-pr-2392-20251010173905",
11
+ "version": "0.6.0-pr-2457-20251016083534",
12
12
  "files": [
13
13
  "build"
14
14
  ],
@@ -28,16 +28,16 @@
28
28
  "@cosmjs/crypto": "^0.33.1",
29
29
  "@cosmjs/proto-signing": "^0.33.1",
30
30
  "@cosmjs/stargate": "^0.33.1",
31
- "@stablelib/ed25519": "^1.0.3",
31
+ "@stablelib/ed25519": "^2.0.2",
32
32
  "class-transformer": "0.5.1",
33
33
  "class-validator": "0.14.1",
34
34
  "rxjs": "^7.8.2",
35
35
  "tsyringe": "^4.10.0",
36
- "@credo-ts/anoncreds": "0.6.0-pr-2392-20251010173905",
37
- "@credo-ts/core": "0.6.0-pr-2392-20251010173905"
36
+ "@credo-ts/anoncreds": "0.6.0-pr-2457-20251016083534",
37
+ "@credo-ts/core": "0.6.0-pr-2457-20251016083534"
38
38
  },
39
39
  "devDependencies": {
40
- "typescript": "~5.8.3"
40
+ "typescript": "~5.9.3"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsdown --config-loader unconfig"