@credo-ts/hedera 0.6.0-pr-2392-20251010173905 → 0.6.0-pr-2454-20251015095608
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.
- package/build/HederaModule.d.mts.map +1 -1
- package/build/HederaModule.d.ts.map +1 -1
- package/build/HederaModule.mjs.map +1 -1
- package/build/ledger/HederaLedgerService.d.mts.map +1 -1
- package/build/ledger/HederaLedgerService.d.ts.map +1 -1
- package/build/ledger/HederaLedgerService.mjs.map +1 -1
- package/build/ledger/signer/KmsSigner.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HederaModule.d.mts","names":[],"sources":["../src/HederaModule.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"HederaModule.d.mts","names":[],"sources":["../src/HederaModule.ts"],"sourcesContent":[],"mappings":";;;;cAKa,YAAA,YAAwB;mBACX;EADb,WAAA,CAAA,MAAa,EAGG,yBAHH;EAAA,QAAA,CAAA,iBAAA,EAOW,iBAPX,CAAA,EAAA,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HederaModule.d.ts","names":[],"sources":["../src/HederaModule.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"HederaModule.d.ts","names":[],"sources":["../src/HederaModule.ts"],"sourcesContent":[],"mappings":";;;;cAKa,YAAA,YAAwB;mBACX;EADb,WAAA,CAAA,MAAa,EAGG,yBAHH;EAAA,QAAA,CAAA,iBAAA,EAOW,iBAPX,CAAA,EAAA,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HederaModule.mjs","names":[],"sources":["../src/HederaModule.ts"],"sourcesContent":["import { DependencyManager, type Module } from '@credo-ts/core'\n\nimport {
|
|
1
|
+
{"version":3,"file":"HederaModule.mjs","names":[],"sources":["../src/HederaModule.ts"],"sourcesContent":["import { AgentConfig, Buffer, DependencyManager, type Module } from '@credo-ts/core'\n\nimport { HederaModuleConfig, type HederaModuleConfigOptions } from './HederaModuleConfig'\nimport { HederaLedgerService } from './ledger'\n\nexport class HederaModule implements Module {\n public readonly config: HederaModuleConfig\n\n public constructor(config: HederaModuleConfigOptions) {\n this.config = new HederaModuleConfig(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/hedera' 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(HederaModuleConfig, this.config)\n dependencyManager.registerSingleton(HederaLedgerService)\n\n // Hedera 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"],"mappings":";;;;;;AAKA,IAAa,eAAb,MAA4C;CAG1C,AAAO,YAAY,QAAmC;AACpD,OAAK,SAAS,IAAI,mBAAmB,OAAO;;CAG9C,AAAO,SAAS,mBAAsC;AAEpD,oBACG,QAAQ,YAAY,CACpB,OAAO,KACN,iLACD;AAGH,oBAAkB,iBAAiB,oBAAoB,KAAK,OAAO;AACnE,oBAAkB,kBAAkB,oBAAoB;AAKxD,SAAO,SAAS,OAAO,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HederaLedgerService.d.mts","names":[],"sources":["../../src/ledger/HederaLedgerService.ts"],"sourcesContent":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"HederaLedgerService.d.mts","names":[],"sources":["../../src/ledger/HederaLedgerService.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAyDiB,sBAAA,SAA+B;;EAA/B,OAAA,CAAA,EAAA;IAAuB,OAAA,CAAA,EAG1B,aAH0B,GAAA,MAAA;;QAO7B,CAAA,EAAA;IAPqC,SAAA,CAAA,EAAA,MAAA;IAAgB,IAAA,CAAA,EAOrD,cA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gF,CAAA;iCAAR,CAAA,YAAA,EAkJnE,YAlJmE,EAAA,8BAAA,EAAA,MAAA,CAAA,EAoJhF,OApJgF,CAoJxE,qCApJwE,CAAA;sCAgEnE,CAAA,YAAA,EA0FA,YA1FA,EAAA,OAAA,EA2FL,2CA3FK,CAAA,EA4Fb,OA5Fa,CA4FL,0CA5FK,CAAA;yBACP,CAAA,YAAA,EAqGO,YArGP,EAAA,oBAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,CAAA,EAwGN,OAxGM,CAwGE,6BAxGF,CAAA;8BACE,CAAA,YAAA,EA6GK,YA7GL,EAAA,OAAA,EA8GA,mCA9GA,CAAA,EA+GR,OA/GQ,CA+GA,kCA/GA,CAAA;UAAR,uBAAA;UA6CqB,YAAA;UAAyC,0BAAA;UAAR,qBAAA;UAKtB,0BAAA;UAAuB,YAAA;UAAgC,qBAAA;UAAR,iBAAA;UAOlE,eAAA;UAEL,kBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HederaLedgerService.d.ts","names":[],"sources":["../../src/ledger/HederaLedgerService.ts"],"sourcesContent":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"HederaLedgerService.d.ts","names":[],"sources":["../../src/ledger/HederaLedgerService.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAyDiB,sBAAA,SAA+B;;EAA/B,OAAA,CAAA,EAAA;IAAuB,OAAA,CAAA,EAG1B,aAH0B,GAAA,MAAA;;QAO7B,CAAA,EAAA;IAPqC,SAAA,CAAA,EAAA,MAAA;IAAgB,IAAA,CAAA,EAOrD,cAPqD,EAAA;EAW/C,CAAA;;AACN,UADM,qBAAA,SAA8B,eACpC,CAAA;SADoC,EACpC,cADoC;;AAI9B,UAAA,sBAAA,SAA+B,gBAAR,CAAA;EAAA,MAAA,CAAA,EAAA;IAE7B,IAAA,CAAA,EAAA,cAAA,EAAA;;;AAIM,UAAA,0BAAA,SAAmC,oBAAR,CAAA;EAAA,MAA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,YAAA,EAqGO,YArGP,EAAA,oBAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,CAAA,EAwGN,OAxGM,CAwGE,6BAxGF,CAAA;8BACE,CAAA,YAAA,EA6GK,YA7GL,EAAA,OAAA,EA8GA,mCA9GA,CAAA,EA+GR,OA/GQ,CA+GA,kCA/GA,CAAA;UAAR,uBAAA;UA6CqB,YAAA;UAAyC,0BAAA;UAAR,qBAAA;UAKtB,0BAAA;UAAuB,YAAA;UAAgC,qBAAA;UAAR,iBAAA;UAOlE,eAAA;UAEL,kBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HederaLedgerService.mjs","names":["HederaLedgerService","config: HederaModuleConfig","result: Record<string, Uint8Array>"],"sources":["../../src/ledger/HederaLedgerService.ts"],"sourcesContent":["import type {\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 {\n type AgentContext,\n type DidCreateOptions,\n type DidDeactivateOptions,\n type DidDocument,\n type DidDocumentKey,\n DidRepository,\n type DidUpdateOptions,\n Kms,\n injectable,\n} from '@credo-ts/core'\nimport { Client } from '@hashgraph/sdk'\nimport { HederaAnoncredsRegistry } from '@hiero-did-sdk/anoncreds'\nimport { LRUMemoryCache } from '@hiero-did-sdk/cache'\nimport { HederaClientService, type HederaNetwork } from '@hiero-did-sdk/client'\nimport {\n type Cache,\n type DIDResolution,\n DID_ROOT_KEY_ID,\n type Service,\n type VerificationMethod,\n parseDID,\n} from '@hiero-did-sdk/core'\nimport {\n type CreateDIDResult,\n DIDUpdateBuilder,\n type DeactivateDIDResult,\n type UpdateDIDResult,\n generateCreateDIDRequest,\n generateDeactivateDIDRequest,\n generateUpdateDIDRequest,\n submitCreateDIDRequest,\n submitDeactivateDIDRequest,\n submitUpdateDIDRequest,\n} from '@hiero-did-sdk/registrar'\nimport { TopicReaderHederaHcs, resolveDID } from '@hiero-did-sdk/resolver'\nimport { HederaModuleConfig } from '../HederaModuleConfig'\nimport { KmsPublisher } from './publisher/KmsPublisher'\nimport { KmsSigner } from './signer/KmsSigner'\nimport { createOrGetKey, getMultibasePublicKey } from './utils'\n\nexport interface HederaDidCreateOptions extends DidCreateOptions {\n method: 'hedera'\n options?: {\n network?: HederaNetwork | string\n }\n secret?: {\n rootKeyId?: string\n keys?: DidDocumentKey[]\n }\n}\n\nexport interface HederaCreateDidResult extends CreateDIDResult {\n rootKey: DidDocumentKey\n}\n\nexport interface HederaDidUpdateOptions extends DidUpdateOptions {\n secret?: {\n keys?: DidDocumentKey[]\n }\n}\n\nexport interface HederaDidDeactivateOptions extends DidDeactivateOptions {\n secret?: {\n keys?: DidDocumentKey[]\n }\n}\n\n@injectable()\nexport class HederaLedgerService {\n private readonly clientService: HederaClientService\n private readonly cache: Cache\n\n public constructor(private readonly config: HederaModuleConfig) {\n this.clientService = new HederaClientService(config.options)\n this.cache = this.config.options.cache ?? new LRUMemoryCache(50)\n }\n\n public async resolveDid(agentContext: AgentContext, did: string): Promise<DIDResolution> {\n const topicReader = this.getHederaHcsTopicReader(agentContext)\n return await resolveDID(did, 'application/ld+json;profile=\"https://w3id.org/did-resolution\"', { topicReader })\n }\n\n public async createDid(agentContext: AgentContext, props: HederaDidCreateOptions): Promise<HederaCreateDidResult> {\n const { options, secret, didDocument } = props\n return this.clientService.withClient({ networkName: options?.network }, async (client: Client) => {\n const topicReader = this.getHederaHcsTopicReader(agentContext)\n\n const controller =\n typeof didDocument?.controller === 'string'\n ? didDocument?.controller\n : Array.isArray(didDocument?.controller)\n ? didDocument?.controller[0]\n : undefined\n\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n const publicJwk = await createOrGetKey(kms, secret?.rootKeyId)\n const rootKey = { kmsKeyId: publicJwk.keyId, didDocumentRelativeKeyId: DID_ROOT_KEY_ID }\n\n const publisher = await this.getPublisher(agentContext, client, publicJwk.keyId)\n\n const { state, signingRequest } = await generateCreateDIDRequest(\n {\n controller,\n multibasePublicKey: getMultibasePublicKey(publicJwk),\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n\n const signatureResult = await kms.sign({\n keyId: publicJwk.keyId,\n data: signingRequest.serializedPayload,\n algorithm: 'EdDSA',\n })\n const createDidDocumentResult = await submitCreateDIDRequest(\n { state, signature: signatureResult.signature, topicReader },\n {\n client,\n publisher,\n }\n )\n\n if (didDocument) {\n const keys = [...(secret?.keys ?? []), ...[rootKey]]\n const updateDidDocumentResult = await this.updateDid(agentContext, {\n did: createDidDocumentResult.did,\n didDocumentOperation: 'setDidDocument',\n didDocument,\n options: { ...options },\n secret: { keys },\n })\n return {\n ...updateDidDocumentResult,\n rootKey,\n }\n }\n\n return {\n ...createDidDocumentResult,\n rootKey,\n }\n })\n }\n\n public async updateDid(agentContext: AgentContext, props: HederaDidUpdateOptions): Promise<UpdateDIDResult> {\n const { did, didDocumentOperation, didDocument, secret } = props\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n if (!didDocumentOperation) {\n throw new Error('DidDocumentOperation is required')\n }\n\n const rootKey = secret?.keys?.find((key) => key.didDocumentRelativeKeyId === DID_ROOT_KEY_ID)\n if (!rootKey?.kmsKeyId) {\n throw new Error('The root key not found in the KMS')\n }\n\n this.validateDidUpdateKeys(didDocument, secret?.keys ?? [])\n\n const { network: networkName } = parseDID(did)\n return this.clientService.withClient({ networkName }, async (client: Client) => {\n const topicReader = this.getHederaHcsTopicReader(agentContext)\n\n const currentDidDocumentResolution = await resolveDID(\n did,\n 'application/ld+json;profile=\"https://w3id.org/did-resolution\"',\n { topicReader }\n )\n if (!currentDidDocumentResolution.didDocument) {\n throw new Error(`DID ${did} not found`)\n }\n\n const didUpdates = this.prepareDidUpdates(\n currentDidDocumentResolution.didDocument,\n didDocument,\n didDocumentOperation\n )\n\n const publisher = await this.getPublisher(agentContext, client, rootKey.kmsKeyId)\n\n const { states, signingRequests } = await generateUpdateDIDRequest(\n {\n did,\n updates: didUpdates.build(),\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n\n const signatures = await this.signRequests(signingRequests, kms, rootKey.kmsKeyId)\n return await submitUpdateDIDRequest(\n {\n states,\n signatures,\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n })\n }\n\n public async deactivateDid(\n agentContext: AgentContext,\n props: HederaDidDeactivateOptions\n ): Promise<DeactivateDIDResult> {\n const { did, secret } = props\n\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n const rootKey = secret?.keys?.find((key) => key.didDocumentRelativeKeyId === DID_ROOT_KEY_ID)\n if (!rootKey?.kmsKeyId) {\n throw new Error('The root key not found in the KMS')\n }\n\n const { network: networkName } = parseDID(props.did)\n return this.clientService.withClient({ networkName }, async (client: Client) => {\n const topicReader = this.getHederaHcsTopicReader(agentContext)\n\n const publisher = await this.getPublisher(agentContext, client, rootKey.kmsKeyId)\n\n const { state, signingRequest } = await generateDeactivateDIDRequest(\n {\n did,\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n const signatureResult = await kms.sign({\n keyId: rootKey.kmsKeyId,\n data: signingRequest.serializedPayload,\n algorithm: 'EdDSA',\n })\n return await submitDeactivateDIDRequest(\n {\n state,\n signature: signatureResult.signature,\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n })\n }\n\n getSchema(agentContext: AgentContext, schemaId: string): Promise<GetSchemaReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n return registry.getSchema(schemaId)\n }\n\n async registerSchema(agentContext: AgentContext, options: RegisterSchemaOptions): Promise<RegisterSchemaReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n const issuerKeySigner = await this.getIssuerKeySigner(agentContext, options.schema.issuerId)\n return registry.registerSchema({ ...options, issuerKeySigner })\n }\n\n getCredentialDefinition(\n agentContext: AgentContext,\n credentialDefinitionId: string\n ): Promise<GetCredentialDefinitionReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n return registry.getCredentialDefinition(credentialDefinitionId)\n }\n\n async registerCredentialDefinition(\n agentContext: AgentContext,\n options: RegisterCredentialDefinitionOptions\n ): Promise<RegisterCredentialDefinitionReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n const issuerKeySigner = await this.getIssuerKeySigner(agentContext, options.credentialDefinition.issuerId)\n return await registry.registerCredentialDefinition({\n ...options,\n issuerKeySigner,\n options: {\n supportRevocation: !!options.options?.supportRevocation,\n },\n })\n }\n\n getRevocationRegistryDefinition(\n agentContext: AgentContext,\n revocationRegistryDefinitionId: string\n ): Promise<GetRevocationRegistryDefinitionReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n return registry.getRevocationRegistryDefinition(revocationRegistryDefinitionId)\n }\n\n async registerRevocationRegistryDefinition(\n agentContext: AgentContext,\n options: RegisterRevocationRegistryDefinitionOptions\n ): Promise<RegisterRevocationRegistryDefinitionReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n const issuerKeySigner = await this.getIssuerKeySigner(agentContext, options.revocationRegistryDefinition.issuerId)\n return await registry.registerRevocationRegistryDefinition({\n ...options,\n issuerKeySigner,\n })\n }\n\n getRevocationStatusList(\n agentContext: AgentContext,\n revocationRegistryId: string,\n timestamp: number\n ): Promise<GetRevocationStatusListReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n return registry.getRevocationStatusList(revocationRegistryId, timestamp)\n }\n\n async registerRevocationStatusList(\n agentContext: AgentContext,\n options: RegisterRevocationStatusListOptions\n ): Promise<RegisterRevocationStatusListReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n const issuerKeySigner = await this.getIssuerKeySigner(agentContext, options.revocationStatusList.issuerId)\n return await registry.registerRevocationStatusList({\n ...options,\n issuerKeySigner,\n })\n }\n\n private getHederaHcsTopicReader(_agentContext: AgentContext): TopicReaderHederaHcs {\n return new TopicReaderHederaHcs({ ...this.config.options, cache: this.cache })\n }\n\n private async getPublisher(agentContext: AgentContext, client: Client, keyId: string): Promise<KmsPublisher> {\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n const publicJwk = await createOrGetKey(kms, keyId)\n return new KmsPublisher(agentContext, client, publicJwk)\n }\n\n private getHederaAnonCredsRegistry(_agentContext: AgentContext): HederaAnoncredsRegistry {\n return new HederaAnoncredsRegistry({ ...this.config.options, cache: this.cache })\n }\n\n private getDidDocumentEntryId(item: { id: string } | string): string {\n const id = typeof item === 'string' ? item : item.id\n return id.includes('#') ? `#${id.split('#').pop()}` : id\n }\n\n private getDidDocumentPropertyDiff(\n originalEntries: Array<string | { id: string }> = [],\n updatedEntries: Array<string | { id: string }> = []\n ) {\n const originalIds = new Set(originalEntries.map((item) => this.getDidDocumentEntryId(item)))\n const updatedIds = new Set(updatedEntries.map((item) => this.getDidDocumentEntryId(item)))\n\n const unchangedEntries = updatedEntries.filter((item) => originalIds.has(this.getDidDocumentEntryId(item)))\n const newEntries = updatedEntries.filter((item) => !originalIds.has(this.getDidDocumentEntryId(item)))\n const removedEntries = originalEntries.filter((item) => !updatedIds.has(this.getDidDocumentEntryId(item)))\n\n return { unchangedEntries, newEntries, removedEntries }\n }\n\n private async signRequests(\n signingRequests: Record<string, { serializedPayload: Uint8Array }>,\n kms: Kms.KeyManagementApi,\n keyId: string\n ): Promise<Record<string, Uint8Array>> {\n const result: Record<string, Uint8Array> = {}\n\n for (const [key, request] of Object.entries(signingRequests)) {\n const { signature } = await kms.sign({\n keyId,\n data: request.serializedPayload,\n algorithm: 'EdDSA',\n })\n result[key] = signature\n }\n\n return result\n }\n\n private validateDidUpdateKeys(didDocument: DidDocument | Partial<DidDocument>, keys: DidDocumentKey[]) {\n const verificationRelationships = [\n 'verificationMethod',\n 'assertionMethod',\n 'authentication',\n 'capabilityDelegation',\n 'capabilityInvocation',\n 'keyAgreement',\n ] as const\n\n for (const relationship of verificationRelationships) {\n const entries = didDocument[relationship]\n if (!entries) continue\n\n for (const entry of entries) {\n const id = this.getDidDocumentEntryId(entry)\n if (!keys.some((key) => key.didDocumentRelativeKeyId === id)) {\n throw new Error(\n `Key ${id} is present in updated DID Document, but missing from DID record keys and DID update arguments`\n )\n }\n }\n }\n }\n\n private prepareDidUpdates(\n originalDocument: DidDocument | Partial<DidDocument>,\n newDocument: DidDocument | Partial<DidDocument>,\n operation: string\n ): DIDUpdateBuilder {\n const builder = new DIDUpdateBuilder()\n const properties = [\n 'service',\n 'verificationMethod',\n 'assertionMethod',\n 'authentication',\n 'capabilityDelegation',\n 'capabilityInvocation',\n 'keyAgreement',\n ] as const\n\n for (const property of properties) {\n const { unchangedEntries, newEntries, removedEntries } = this.getDidDocumentPropertyDiff(\n originalDocument[property],\n newDocument[property]\n )\n\n if (operation === 'setDidDocument') {\n for (const entry of removedEntries) {\n const entryId = this.getDidDocumentEntryId(entry)\n if (entryId === DID_ROOT_KEY_ID) continue\n const builderMethod = this.getUpdateMethod(builder, property, 'remove')\n builderMethod(entryId)\n }\n\n for (const entry of newEntries) {\n if (this.getDidDocumentEntryId(entry) === DID_ROOT_KEY_ID) continue\n const builderMethod = this.getUpdateMethod(builder, property, 'add')\n builderMethod(entry)\n }\n }\n\n if (operation === 'addToDidDocument') {\n for (const entry of newEntries) {\n if (this.getDidDocumentEntryId(entry) === DID_ROOT_KEY_ID) continue\n const builderMethod = this.getUpdateMethod(builder, property, 'add')\n builderMethod(entry)\n }\n }\n\n if (operation === 'removeFromDidDocument') {\n for (const entry of unchangedEntries) {\n const entryId = this.getDidDocumentEntryId(entry)\n if (entryId === DID_ROOT_KEY_ID) continue\n const builderMethod = this.getUpdateMethod(builder, property, 'remove')\n builderMethod(entryId)\n }\n }\n }\n\n return builder\n }\n\n private getUpdateMethod(\n builder: DIDUpdateBuilder,\n property: string,\n action: 'add' | 'remove'\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n ): (item: any) => DIDUpdateBuilder {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n const methodMap: Record<string, Record<'add' | 'remove', (item: any) => DIDUpdateBuilder>> = {\n service: {\n add: (item: Service) => builder.addService(item),\n remove: (id: string) => builder.removeService(id),\n },\n verificationMethod: {\n add: (item: VerificationMethod | string) => builder.addVerificationMethod(item),\n remove: (id: string) => builder.removeVerificationMethod(id),\n },\n assertionMethod: {\n add: (item: VerificationMethod | string) => builder.addAssertionMethod(item),\n remove: (id: string) => builder.removeAssertionMethod(id),\n },\n authentication: {\n add: (item: VerificationMethod | string) => builder.addAuthenticationMethod(item),\n remove: (id: string) => builder.removeAuthenticationMethod(id),\n },\n capabilityDelegation: {\n add: (item: VerificationMethod | string) => builder.addCapabilityDelegationMethod(item),\n remove: (id: string) => builder.removeCapabilityDelegationMethod(id),\n },\n capabilityInvocation: {\n add: (item: VerificationMethod | string) => builder.addCapabilityInvocationMethod(item),\n remove: (id: string) => builder.removeCapabilityInvocationMethod(id),\n },\n keyAgreement: {\n add: (item: VerificationMethod | string) => builder.addKeyAgreementMethod(item),\n remove: (id: string) => builder.removeKeyAgreementMethod(id),\n },\n }\n\n const propertyMethods = methodMap[property]\n if (!propertyMethods) {\n return () => builder\n }\n\n return propertyMethods[action]\n }\n\n private async getIssuerKeySigner(agentContext: AgentContext, issuerId: string): Promise<KmsSigner> {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n const didRecord = await didRepository.findCreatedDid(agentContext, issuerId)\n const rootKey = didRecord?.keys?.find((key) => key.didDocumentRelativeKeyId === DID_ROOT_KEY_ID)\n if (!rootKey?.kmsKeyId) {\n throw new Error('The root key not found in the KMS')\n }\n\n const issuerPublicJwk = await createOrGetKey(kms, rootKey.kmsKeyId)\n\n return new KmsSigner(kms, issuerPublicJwk)\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,QAAQ,iCAAiC,GAAG;IACrE;GACD,sBAAsB;IACpB,MAAM,SAAsC,QAAQ,8BAA8B,KAAK;IACvF,SAAS,OAAe,QAAQ,iCAAiC,GAAG;IACrE;GACD,cAAc;IACZ,MAAM,SAAsC,QAAQ,sBAAsB,KAAK;IAC/E,SAAS,OAAe,QAAQ,yBAAyB,GAAG;IAC7D;GACF,CAEiC;AAClC,MAAI,CAAC,gBACH,cAAa;AAGf,SAAO,gBAAgB;;CAGzB,MAAc,mBAAmB,cAA4B,UAAsC;EACjG,MAAM,gBAAgB,aAAa,kBAAkB,QAAQ,cAAc;EAC3E,MAAM,MAAM,aAAa,kBAAkB,QAAQ,IAAI,iBAAiB;EAGxE,MAAM,WADY,MAAM,cAAc,eAAe,cAAc,SAAS,GACjD,MAAM,MAAM,QAAQ,IAAI,6BAA6B,gBAAgB;AAChG,MAAI,CAAC,SAAS,SACZ,OAAM,IAAI,MAAM,oCAAoC;AAKtD,SAAO,IAAI,UAAU,KAFG,MAAM,eAAe,KAAK,QAAQ,SAAS,CAEzB;;;kCA5c7C,YAAY"}
|
|
1
|
+
{"version":3,"file":"HederaLedgerService.mjs","names":["HederaLedgerService","config: HederaModuleConfig","result: Record<string, Uint8ArrayBuffer>"],"sources":["../../src/ledger/HederaLedgerService.ts"],"sourcesContent":["import type {\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 {\n type AgentContext,\n type AnyUint8Array,\n type DidCreateOptions,\n type DidDeactivateOptions,\n type DidDocument,\n type DidDocumentKey,\n DidRepository,\n type DidUpdateOptions,\n injectable,\n Kms,\n type Uint8ArrayBuffer,\n} from '@credo-ts/core'\nimport { Client } from '@hashgraph/sdk'\nimport { HederaAnoncredsRegistry } from '@hiero-did-sdk/anoncreds'\nimport { LRUMemoryCache } from '@hiero-did-sdk/cache'\nimport { HederaClientService, type HederaNetwork } from '@hiero-did-sdk/client'\nimport {\n type Cache,\n DID_ROOT_KEY_ID,\n type DIDResolution,\n parseDID,\n type Service,\n type VerificationMethod,\n} from '@hiero-did-sdk/core'\nimport {\n type CreateDIDResult,\n type DeactivateDIDResult,\n DIDUpdateBuilder,\n generateCreateDIDRequest,\n generateDeactivateDIDRequest,\n generateUpdateDIDRequest,\n submitCreateDIDRequest,\n submitDeactivateDIDRequest,\n submitUpdateDIDRequest,\n type UpdateDIDResult,\n} from '@hiero-did-sdk/registrar'\nimport { resolveDID, TopicReaderHederaHcs } from '@hiero-did-sdk/resolver'\nimport { HederaModuleConfig } from '../HederaModuleConfig'\nimport { KmsPublisher } from './publisher/KmsPublisher'\nimport { KmsSigner } from './signer/KmsSigner'\nimport { createOrGetKey, getMultibasePublicKey } from './utils'\n\nexport interface HederaDidCreateOptions extends DidCreateOptions {\n method: 'hedera'\n options?: {\n network?: HederaNetwork | string\n }\n secret?: {\n rootKeyId?: string\n keys?: DidDocumentKey[]\n }\n}\n\nexport interface HederaCreateDidResult extends CreateDIDResult {\n rootKey: DidDocumentKey\n}\n\nexport interface HederaDidUpdateOptions extends DidUpdateOptions {\n secret?: {\n keys?: DidDocumentKey[]\n }\n}\n\nexport interface HederaDidDeactivateOptions extends DidDeactivateOptions {\n secret?: {\n keys?: DidDocumentKey[]\n }\n}\n\n@injectable()\nexport class HederaLedgerService {\n private readonly clientService: HederaClientService\n private readonly cache: Cache\n\n public constructor(private readonly config: HederaModuleConfig) {\n this.clientService = new HederaClientService(config.options)\n this.cache = this.config.options.cache ?? new LRUMemoryCache(50)\n }\n\n public async resolveDid(agentContext: AgentContext, did: string): Promise<DIDResolution> {\n const topicReader = this.getHederaHcsTopicReader(agentContext)\n return await resolveDID(did, 'application/ld+json;profile=\"https://w3id.org/did-resolution\"', { topicReader })\n }\n\n public async createDid(agentContext: AgentContext, props: HederaDidCreateOptions): Promise<HederaCreateDidResult> {\n const { options, secret, didDocument } = props\n return this.clientService.withClient({ networkName: options?.network }, async (client: Client) => {\n const topicReader = this.getHederaHcsTopicReader(agentContext)\n\n const controller =\n typeof didDocument?.controller === 'string'\n ? didDocument?.controller\n : Array.isArray(didDocument?.controller)\n ? didDocument?.controller[0]\n : undefined\n\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n const publicJwk = await createOrGetKey(kms, secret?.rootKeyId)\n const rootKey = { kmsKeyId: publicJwk.keyId, didDocumentRelativeKeyId: DID_ROOT_KEY_ID }\n\n const publisher = await this.getPublisher(agentContext, client, publicJwk.keyId)\n\n const { state, signingRequest } = await generateCreateDIDRequest(\n {\n controller,\n multibasePublicKey: getMultibasePublicKey(publicJwk),\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n\n const signatureResult = await kms.sign({\n keyId: publicJwk.keyId,\n data: signingRequest.serializedPayload,\n algorithm: 'EdDSA',\n })\n const createDidDocumentResult = await submitCreateDIDRequest(\n { state, signature: signatureResult.signature, topicReader },\n {\n client,\n publisher,\n }\n )\n\n if (didDocument) {\n const keys = [...(secret?.keys ?? []), ...[rootKey]]\n const updateDidDocumentResult = await this.updateDid(agentContext, {\n did: createDidDocumentResult.did,\n didDocumentOperation: 'setDidDocument',\n didDocument,\n options: { ...options },\n secret: { keys },\n })\n return {\n ...updateDidDocumentResult,\n rootKey,\n }\n }\n\n return {\n ...createDidDocumentResult,\n rootKey,\n }\n })\n }\n\n public async updateDid(agentContext: AgentContext, props: HederaDidUpdateOptions): Promise<UpdateDIDResult> {\n const { did, didDocumentOperation, didDocument, secret } = props\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n if (!didDocumentOperation) {\n throw new Error('DidDocumentOperation is required')\n }\n\n const rootKey = secret?.keys?.find((key) => key.didDocumentRelativeKeyId === DID_ROOT_KEY_ID)\n if (!rootKey?.kmsKeyId) {\n throw new Error('The root key not found in the KMS')\n }\n\n this.validateDidUpdateKeys(didDocument, secret?.keys ?? [])\n\n const { network: networkName } = parseDID(did)\n return this.clientService.withClient({ networkName }, async (client: Client) => {\n const topicReader = this.getHederaHcsTopicReader(agentContext)\n\n const currentDidDocumentResolution = await resolveDID(\n did,\n 'application/ld+json;profile=\"https://w3id.org/did-resolution\"',\n { topicReader }\n )\n if (!currentDidDocumentResolution.didDocument) {\n throw new Error(`DID ${did} not found`)\n }\n\n const didUpdates = this.prepareDidUpdates(\n currentDidDocumentResolution.didDocument,\n didDocument,\n didDocumentOperation\n )\n\n const publisher = await this.getPublisher(agentContext, client, rootKey.kmsKeyId)\n\n const { states, signingRequests } = await generateUpdateDIDRequest(\n {\n did,\n updates: didUpdates.build(),\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n\n const signatures = await this.signRequests(signingRequests, kms, rootKey.kmsKeyId)\n return await submitUpdateDIDRequest(\n {\n states,\n signatures,\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n })\n }\n\n public async deactivateDid(\n agentContext: AgentContext,\n props: HederaDidDeactivateOptions\n ): Promise<DeactivateDIDResult> {\n const { did, secret } = props\n\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n const rootKey = secret?.keys?.find((key) => key.didDocumentRelativeKeyId === DID_ROOT_KEY_ID)\n if (!rootKey?.kmsKeyId) {\n throw new Error('The root key not found in the KMS')\n }\n\n const { network: networkName } = parseDID(props.did)\n return this.clientService.withClient({ networkName }, async (client: Client) => {\n const topicReader = this.getHederaHcsTopicReader(agentContext)\n\n const publisher = await this.getPublisher(agentContext, client, rootKey.kmsKeyId)\n\n const { state, signingRequest } = await generateDeactivateDIDRequest(\n {\n did,\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n const signatureResult = await kms.sign({\n keyId: rootKey.kmsKeyId,\n data: signingRequest.serializedPayload,\n algorithm: 'EdDSA',\n })\n return await submitDeactivateDIDRequest(\n {\n state,\n signature: signatureResult.signature,\n topicReader,\n },\n {\n client,\n publisher,\n }\n )\n })\n }\n\n getSchema(agentContext: AgentContext, schemaId: string): Promise<GetSchemaReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n return registry.getSchema(schemaId)\n }\n\n async registerSchema(agentContext: AgentContext, options: RegisterSchemaOptions): Promise<RegisterSchemaReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n const issuerKeySigner = await this.getIssuerKeySigner(agentContext, options.schema.issuerId)\n return registry.registerSchema({ ...options, issuerKeySigner })\n }\n\n getCredentialDefinition(\n agentContext: AgentContext,\n credentialDefinitionId: string\n ): Promise<GetCredentialDefinitionReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n return registry.getCredentialDefinition(credentialDefinitionId)\n }\n\n async registerCredentialDefinition(\n agentContext: AgentContext,\n options: RegisterCredentialDefinitionOptions\n ): Promise<RegisterCredentialDefinitionReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n const issuerKeySigner = await this.getIssuerKeySigner(agentContext, options.credentialDefinition.issuerId)\n return await registry.registerCredentialDefinition({\n ...options,\n issuerKeySigner,\n options: {\n supportRevocation: !!options.options?.supportRevocation,\n },\n })\n }\n\n getRevocationRegistryDefinition(\n agentContext: AgentContext,\n revocationRegistryDefinitionId: string\n ): Promise<GetRevocationRegistryDefinitionReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n return registry.getRevocationRegistryDefinition(revocationRegistryDefinitionId)\n }\n\n async registerRevocationRegistryDefinition(\n agentContext: AgentContext,\n options: RegisterRevocationRegistryDefinitionOptions\n ): Promise<RegisterRevocationRegistryDefinitionReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n const issuerKeySigner = await this.getIssuerKeySigner(agentContext, options.revocationRegistryDefinition.issuerId)\n return await registry.registerRevocationRegistryDefinition({\n ...options,\n issuerKeySigner,\n })\n }\n\n getRevocationStatusList(\n agentContext: AgentContext,\n revocationRegistryId: string,\n timestamp: number\n ): Promise<GetRevocationStatusListReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n return registry.getRevocationStatusList(revocationRegistryId, timestamp)\n }\n\n async registerRevocationStatusList(\n agentContext: AgentContext,\n options: RegisterRevocationStatusListOptions\n ): Promise<RegisterRevocationStatusListReturn> {\n const registry = this.getHederaAnonCredsRegistry(agentContext)\n const issuerKeySigner = await this.getIssuerKeySigner(agentContext, options.revocationStatusList.issuerId)\n return await registry.registerRevocationStatusList({\n ...options,\n issuerKeySigner,\n })\n }\n\n private getHederaHcsTopicReader(_agentContext: AgentContext): TopicReaderHederaHcs {\n return new TopicReaderHederaHcs({ ...this.config.options, cache: this.cache })\n }\n\n private async getPublisher(agentContext: AgentContext, client: Client, keyId: string): Promise<KmsPublisher> {\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n const publicJwk = await createOrGetKey(kms, keyId)\n return new KmsPublisher(agentContext, client, publicJwk)\n }\n\n private getHederaAnonCredsRegistry(_agentContext: AgentContext): HederaAnoncredsRegistry {\n return new HederaAnoncredsRegistry({ ...this.config.options, cache: this.cache })\n }\n\n private getDidDocumentEntryId(item: { id: string } | string): string {\n const id = typeof item === 'string' ? item : item.id\n return id.includes('#') ? `#${id.split('#').pop()}` : id\n }\n\n private getDidDocumentPropertyDiff(\n originalEntries: Array<string | { id: string }> = [],\n updatedEntries: Array<string | { id: string }> = []\n ) {\n const originalIds = new Set(originalEntries.map((item) => this.getDidDocumentEntryId(item)))\n const updatedIds = new Set(updatedEntries.map((item) => this.getDidDocumentEntryId(item)))\n\n const unchangedEntries = updatedEntries.filter((item) => originalIds.has(this.getDidDocumentEntryId(item)))\n const newEntries = updatedEntries.filter((item) => !originalIds.has(this.getDidDocumentEntryId(item)))\n const removedEntries = originalEntries.filter((item) => !updatedIds.has(this.getDidDocumentEntryId(item)))\n\n return { unchangedEntries, newEntries, removedEntries }\n }\n\n private async signRequests(\n signingRequests: Record<string, { serializedPayload: AnyUint8Array }>,\n kms: Kms.KeyManagementApi,\n keyId: string\n ): Promise<Record<string, Uint8ArrayBuffer>> {\n const result: Record<string, Uint8ArrayBuffer> = {}\n\n for (const [key, request] of Object.entries(signingRequests)) {\n const { signature } = await kms.sign({\n keyId,\n data: request.serializedPayload,\n algorithm: 'EdDSA',\n })\n result[key] = signature\n }\n\n return result\n }\n\n private validateDidUpdateKeys(didDocument: DidDocument | Partial<DidDocument>, keys: DidDocumentKey[]) {\n const verificationRelationships = [\n 'verificationMethod',\n 'assertionMethod',\n 'authentication',\n 'capabilityDelegation',\n 'capabilityInvocation',\n 'keyAgreement',\n ] as const\n\n for (const relationship of verificationRelationships) {\n const entries = didDocument[relationship]\n if (!entries) continue\n\n for (const entry of entries) {\n const id = this.getDidDocumentEntryId(entry)\n if (!keys.some((key) => key.didDocumentRelativeKeyId === id)) {\n throw new Error(\n `Key ${id} is present in updated DID Document, but missing from DID record keys and DID update arguments`\n )\n }\n }\n }\n }\n\n private prepareDidUpdates(\n originalDocument: DidDocument | Partial<DidDocument>,\n newDocument: DidDocument | Partial<DidDocument>,\n operation: string\n ): DIDUpdateBuilder {\n const builder = new DIDUpdateBuilder()\n const properties = [\n 'service',\n 'verificationMethod',\n 'assertionMethod',\n 'authentication',\n 'capabilityDelegation',\n 'capabilityInvocation',\n 'keyAgreement',\n ] as const\n\n for (const property of properties) {\n const { unchangedEntries, newEntries, removedEntries } = this.getDidDocumentPropertyDiff(\n originalDocument[property],\n newDocument[property]\n )\n\n if (operation === 'setDidDocument') {\n for (const entry of removedEntries) {\n const entryId = this.getDidDocumentEntryId(entry)\n if (entryId === DID_ROOT_KEY_ID) continue\n const builderMethod = this.getUpdateMethod(builder, property, 'remove')\n builderMethod(entryId)\n }\n\n for (const entry of newEntries) {\n if (this.getDidDocumentEntryId(entry) === DID_ROOT_KEY_ID) continue\n const builderMethod = this.getUpdateMethod(builder, property, 'add')\n builderMethod(entry)\n }\n }\n\n if (operation === 'addToDidDocument') {\n for (const entry of newEntries) {\n if (this.getDidDocumentEntryId(entry) === DID_ROOT_KEY_ID) continue\n const builderMethod = this.getUpdateMethod(builder, property, 'add')\n builderMethod(entry)\n }\n }\n\n if (operation === 'removeFromDidDocument') {\n for (const entry of unchangedEntries) {\n const entryId = this.getDidDocumentEntryId(entry)\n if (entryId === DID_ROOT_KEY_ID) continue\n const builderMethod = this.getUpdateMethod(builder, property, 'remove')\n builderMethod(entryId)\n }\n }\n }\n\n return builder\n }\n\n private getUpdateMethod(\n builder: DIDUpdateBuilder,\n property: string,\n action: 'add' | 'remove'\n // biome-ignore lint/suspicious/noExplicitAny: no explanation\n ): (item: any) => DIDUpdateBuilder {\n // biome-ignore lint/suspicious/noExplicitAny: no explanation\n const methodMap: Record<string, Record<'add' | 'remove', (item: any) => DIDUpdateBuilder>> = {\n service: {\n add: (item: Service) => builder.addService(item),\n remove: (id: string) => builder.removeService(id),\n },\n verificationMethod: {\n add: (item: VerificationMethod | string) => builder.addVerificationMethod(item),\n remove: (id: string) => builder.removeVerificationMethod(id),\n },\n assertionMethod: {\n add: (item: VerificationMethod | string) => builder.addAssertionMethod(item),\n remove: (id: string) => builder.removeAssertionMethod(id),\n },\n authentication: {\n add: (item: VerificationMethod | string) => builder.addAuthenticationMethod(item),\n remove: (id: string) => builder.removeAuthenticationMethod(id),\n },\n capabilityDelegation: {\n add: (item: VerificationMethod | string) => builder.addCapabilityDelegationMethod(item),\n remove: (id: string) => builder.removeCapabilityDelegationMethod(id),\n },\n capabilityInvocation: {\n add: (item: VerificationMethod | string) => builder.addCapabilityInvocationMethod(item),\n remove: (id: string) => builder.removeCapabilityInvocationMethod(id),\n },\n keyAgreement: {\n add: (item: VerificationMethod | string) => builder.addKeyAgreementMethod(item),\n remove: (id: string) => builder.removeKeyAgreementMethod(id),\n },\n }\n\n const propertyMethods = methodMap[property]\n if (!propertyMethods) {\n return () => builder\n }\n\n return propertyMethods[action]\n }\n\n private async getIssuerKeySigner(agentContext: AgentContext, issuerId: string): Promise<KmsSigner> {\n const didRepository = agentContext.dependencyManager.resolve(DidRepository)\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n const didRecord = await didRepository.findCreatedDid(agentContext, issuerId)\n const rootKey = didRecord?.keys?.find((key) => key.didDocumentRelativeKeyId === DID_ROOT_KEY_ID)\n if (!rootKey?.kmsKeyId) {\n throw new Error('The root key not found in the KMS')\n }\n\n const issuerPublicJwk = await createOrGetKey(kms, rootKey.kmsKeyId)\n\n return new KmsSigner(kms, issuerPublicJwk)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqFO,gCAAMA,sBAAoB;CAI/B,AAAO,YAAY,AAAiBC,QAA4B;EAA5B;AAClC,OAAK,gBAAgB,IAAI,oBAAoB,OAAO,QAAQ;AAC5D,OAAK,QAAQ,KAAK,OAAO,QAAQ,SAAS,IAAI,eAAe,GAAG;;CAGlE,MAAa,WAAW,cAA4B,KAAqC;AAEvF,SAAO,MAAM,WAAW,KAAK,mEAAiE,EAAE,aAD5E,KAAK,wBAAwB,aAAa,EAC+C,CAAC;;CAGhH,MAAa,UAAU,cAA4B,OAA+D;EAChH,MAAM,EAAE,SAAS,QAAQ,gBAAgB;AACzC,SAAO,KAAK,cAAc,WAAW,EAAE,aAAa,SAAS,SAAS,EAAE,OAAO,WAAmB;GAChG,MAAM,cAAc,KAAK,wBAAwB,aAAa;GAE9D,MAAM,aACJ,OAAO,aAAa,eAAe,WAC/B,aAAa,aACb,MAAM,QAAQ,aAAa,WAAW,GACpC,aAAa,WAAW,KACxB;GAER,MAAM,MAAM,aAAa,kBAAkB,QAAQ,IAAI,iBAAiB;GAExE,MAAM,YAAY,MAAM,eAAe,KAAK,QAAQ,UAAU;GAC9D,MAAM,UAAU;IAAE,UAAU,UAAU;IAAO,0BAA0B;IAAiB;GAExF,MAAM,YAAY,MAAM,KAAK,aAAa,cAAc,QAAQ,UAAU,MAAM;GAEhF,MAAM,EAAE,OAAO,mB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,MAAM,SAAsC,QAAQ,sBAAsB,KAAK;IAC/E,SAAS,OAAe,QAAQ,yBAAyB,GAAG;IAC7D;GACD,iBAAiB;IACf,MAAM,SAAsC,QAAQ,mBAAmB,KAAK;IAC5E,SAAS,OAAe,QAAQ,sBAAsB,GAAG;IAC1D;GACD,gBAAgB;IACd,MAAM,SAAsC,QAAQ,wBAAwB,KAAK;IACjF,SAAS,OAAe,QAAQ,2BAA2B,GAAG;IAC/D;GACD,sBAAsB;IACpB,MAAM,SAAsC,QAAQ,8BAA8B,KAAK;IACvF,SAAS,OAAe,QAAQ,iCAAiC,GAAG;IACrE;GACD,sBAAsB;IACpB,MAAM,SAAsC,QAAQ,8BAA8B,KAAK;IACvF,SAAS,OAAe,QAAQ,iCAAiC,GAAG;IACrE;GACD,cAAc;IACZ,MAAM,SAAsC,QAAQ,sBAAsB,KAAK;IAC/E,SAAS,OAAe,QAAQ,yBAAyB,GAAG;IAC7D;GACF,CAEiC;AAClC,MAAI,CAAC,gBACH,cAAa;AAGf,SAAO,gBAAgB;;CAGzB,MAAc,mBAAmB,cAA4B,UAAsC;EACjG,MAAM,gBAAgB,aAAa,kBAAkB,QAAQ,cAAc;EAC3E,MAAM,MAAM,aAAa,kBAAkB,QAAQ,IAAI,iBAAiB;EAGxE,MAAM,WADY,MAAM,cAAc,eAAe,cAAc,SAAS,GACjD,MAAM,MAAM,QAAQ,IAAI,6BAA6B,gBAAgB;AAChG,MAAI,CAAC,SAAS,SACZ,OAAM,IAAI,MAAM,oCAAoC;AAKtD,SAAO,IAAI,UAAU,KAFG,MAAM,eAAe,KAAK,QAAQ,SAAS,CAEzB;;;kCA5c7C,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KmsSigner.mjs","names":["kms: Kms.KeyManagementApi"],"sources":["../../../src/ledger/signer/KmsSigner.ts"],"sourcesContent":["import { Kms } from '@credo-ts/core'\nimport { PublicKey } from '@hashgraph/sdk'\nimport { Signer } from '@hiero-did-sdk/core'\nimport { createOrGetKey, hederaPublicKeyFromPublicJwk } from '../utils'\n\nexport class KmsSigner extends Signer {\n private keyId: string\n private _publicKey: PublicKey\n\n constructor(\n private readonly kms: Kms.KeyManagementApi,\n publicJwk: Kms.PublicJwk<Kms.Ed25519PublicJwk>\n ) {\n super()\n\n this.keyId = publicJwk.keyId\n this._publicKey = hederaPublicKeyFromPublicJwk(publicJwk)\n }\n\n async setKeyId(keyId: string): Promise<void> {\n const publicJwk = await createOrGetKey(this.kms, keyId)\n\n this.keyId = keyId\n this._publicKey = hederaPublicKeyFromPublicJwk(publicJwk)\n }\n\n publicKey(): Promise<string> {\n return Promise.resolve(this._publicKey.toStringDer())\n }\n\n async sign(data:
|
|
1
|
+
{"version":3,"file":"KmsSigner.mjs","names":["kms: Kms.KeyManagementApi"],"sources":["../../../src/ledger/signer/KmsSigner.ts"],"sourcesContent":["import { type AnyUint8Array, Kms, type Uint8ArrayBuffer } from '@credo-ts/core'\nimport { PublicKey } from '@hashgraph/sdk'\nimport { Signer } from '@hiero-did-sdk/core'\nimport { createOrGetKey, hederaPublicKeyFromPublicJwk } from '../utils'\n\nexport class KmsSigner extends Signer {\n private keyId: string\n private _publicKey: PublicKey\n\n constructor(\n private readonly kms: Kms.KeyManagementApi,\n publicJwk: Kms.PublicJwk<Kms.Ed25519PublicJwk>\n ) {\n super()\n\n this.keyId = publicJwk.keyId\n this._publicKey = hederaPublicKeyFromPublicJwk(publicJwk)\n }\n\n async setKeyId(keyId: string): Promise<void> {\n const publicJwk = await createOrGetKey(this.kms, keyId)\n\n this.keyId = keyId\n this._publicKey = hederaPublicKeyFromPublicJwk(publicJwk)\n }\n\n publicKey(): Promise<string> {\n return Promise.resolve(this._publicKey.toStringDer())\n }\n\n async sign(data: AnyUint8Array): Promise<Uint8ArrayBuffer> {\n const { signature } = await this.kms.sign({\n keyId: this.keyId,\n data,\n algorithm: 'EdDSA',\n })\n return signature\n }\n\n async verify(message: AnyUint8Array, signature: AnyUint8Array): Promise<boolean> {\n const { verified } = await this.kms.verify({\n data: message,\n signature,\n key: { keyId: this.keyId },\n algorithm: 'EdDSA',\n })\n return verified\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,YAAb,cAA+B,OAAO;CAIpC,YACE,AAAiBA,KACjB,WACA;AACA,SAAO;EAHU;AAKjB,OAAK,QAAQ,UAAU;AACvB,OAAK,aAAa,6BAA6B,UAAU;;CAG3D,MAAM,SAAS,OAA8B;EAC3C,MAAM,YAAY,MAAM,eAAe,KAAK,KAAK,MAAM;AAEvD,OAAK,QAAQ;AACb,OAAK,aAAa,6BAA6B,UAAU;;CAG3D,YAA6B;AAC3B,SAAO,QAAQ,QAAQ,KAAK,WAAW,aAAa,CAAC;;CAGvD,MAAM,KAAK,MAAgD;EACzD,MAAM,EAAE,cAAc,MAAM,KAAK,IAAI,KAAK;GACxC,OAAO,KAAK;GACZ;GACA,WAAW;GACZ,CAAC;AACF,SAAO;;CAGT,MAAM,OAAO,SAAwB,WAA4C;EAC/E,MAAM,EAAE,aAAa,MAAM,KAAK,IAAI,OAAO;GACzC,MAAM;GACN;GACA,KAAK,EAAE,OAAO,KAAK,OAAO;GAC1B,WAAW;GACZ,CAAC;AACF,SAAO"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"./package.json": "./package.json"
|
|
10
10
|
},
|
|
11
|
-
"version": "0.6.0-pr-
|
|
11
|
+
"version": "0.6.0-pr-2454-20251015095608",
|
|
12
12
|
"files": [
|
|
13
13
|
"build"
|
|
14
14
|
],
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"@hiero-did-sdk/publisher-internal": "^0.1.5",
|
|
33
33
|
"@hiero-did-sdk/registrar": "^0.1.5",
|
|
34
34
|
"@hiero-did-sdk/resolver": "^0.1.5",
|
|
35
|
-
"@credo-ts/anoncreds": "0.6.0-pr-
|
|
36
|
-
"@credo-ts/core": "0.6.0-pr-
|
|
35
|
+
"@credo-ts/anoncreds": "0.6.0-pr-2454-20251015095608",
|
|
36
|
+
"@credo-ts/core": "0.6.0-pr-2454-20251015095608"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@hyperledger/anoncreds-nodejs": "^0.3.1",
|
|
40
|
-
"zstd-napi": "^0.0.
|
|
41
|
-
"@credo-ts/node": "0.6.0-pr-
|
|
40
|
+
"zstd-napi": "^0.0.12",
|
|
41
|
+
"@credo-ts/node": "0.6.0-pr-2454-20251015095608"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsdown --config-loader unconfig"
|