@credo-ts/indy-vdr 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/IndyVdrApi.d.mts +2 -2
- package/build/IndyVdrApi.d.mts.map +1 -1
- package/build/IndyVdrApi.d.ts.map +1 -1
- package/build/IndyVdrApi.js +1 -1
- package/build/IndyVdrApi.mjs +1 -1
- package/build/IndyVdrApi.mjs.map +1 -1
- package/build/IndyVdrModule.d.mts.map +1 -1
- package/build/IndyVdrModule.d.ts.map +1 -1
- package/build/IndyVdrModule.mjs.map +1 -1
- package/build/anoncreds/IndyVdrAnonCredsRegistry.d.mts.map +1 -1
- package/build/anoncreds/IndyVdrAnonCredsRegistry.d.ts +1 -1
- package/build/anoncreds/IndyVdrAnonCredsRegistry.d.ts.map +1 -1
- package/build/anoncreds/IndyVdrAnonCredsRegistry.js +1 -1
- package/build/anoncreds/IndyVdrAnonCredsRegistry.mjs +1 -1
- package/build/anoncreds/IndyVdrAnonCredsRegistry.mjs.map +1 -1
- package/build/dids/IndyVdrIndyDidRegistrar.d.mts.map +1 -1
- package/build/dids/IndyVdrIndyDidRegistrar.d.ts.map +1 -1
- package/build/dids/IndyVdrIndyDidRegistrar.js +3 -3
- package/build/dids/IndyVdrIndyDidRegistrar.mjs +3 -3
- package/build/dids/IndyVdrIndyDidRegistrar.mjs.map +1 -1
- package/build/dids/IndyVdrIndyDidResolver.d.mts.map +1 -1
- package/build/dids/IndyVdrIndyDidResolver.d.ts.map +1 -1
- package/build/dids/IndyVdrIndyDidResolver.js +1 -1
- package/build/dids/IndyVdrIndyDidResolver.mjs +1 -1
- package/build/dids/IndyVdrIndyDidResolver.mjs.map +1 -1
- package/build/dids/IndyVdrSovDidResolver.d.mts.map +1 -1
- package/build/dids/IndyVdrSovDidResolver.d.ts.map +1 -1
- package/build/dids/IndyVdrSovDidResolver.js +1 -1
- package/build/dids/IndyVdrSovDidResolver.mjs +1 -1
- package/build/dids/IndyVdrSovDidResolver.mjs.map +1 -1
- package/build/dids/didIndyUtil.mjs.map +1 -1
- package/build/dids/didSovUtil.mjs.map +1 -1
- package/build/error/index.js +1 -1
- package/build/error/index.mjs +1 -1
- package/build/index.d.mts +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +3 -3
- package/build/index.mjs +3 -3
- package/build/pool/IndyVdrPool.d.mts +2 -2
- package/build/pool/IndyVdrPool.d.mts.map +1 -1
- package/build/pool/IndyVdrPool.d.ts.map +1 -1
- package/build/pool/IndyVdrPool.js +1 -1
- package/build/pool/IndyVdrPool.mjs +1 -1
- package/build/pool/IndyVdrPool.mjs.map +1 -1
- package/build/pool/IndyVdrPoolService.d.mts.map +1 -1
- package/build/pool/IndyVdrPoolService.d.ts.map +1 -1
- package/build/pool/IndyVdrPoolService.js +2 -2
- package/build/pool/IndyVdrPoolService.mjs +2 -2
- package/build/pool/IndyVdrPoolService.mjs.map +1 -1
- package/build/utils/promises.mjs.map +1 -1
- package/build/utils/sign.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IndyVdrError } from "../error/IndyVdrError.mjs";
|
|
2
|
-
import { IndyVdrNotFoundError } from "../error/IndyVdrNotFound.mjs";
|
|
3
2
|
import { IndyVdrNotConfiguredError } from "../error/IndyVdrNotConfiguredError.mjs";
|
|
3
|
+
import { IndyVdrNotFoundError } from "../error/IndyVdrNotFound.mjs";
|
|
4
4
|
import "../error/index.mjs";
|
|
5
|
+
import { IndyVdrPool } from "./IndyVdrPool.mjs";
|
|
5
6
|
import { IndyVdrModuleConfig } from "../IndyVdrModuleConfig.mjs";
|
|
6
7
|
import { isSelfCertifiedDid } from "../utils/did.mjs";
|
|
7
8
|
import { allSettled, onlyFulfilled, onlyRejected } from "../utils/promises.mjs";
|
|
8
|
-
import { IndyVdrPool } from "./IndyVdrPool.mjs";
|
|
9
9
|
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.mjs";
|
|
10
10
|
import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateParam.mjs";
|
|
11
11
|
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndyVdrPoolService.mjs","names":["IndyVdrPoolService","logger: Logger","pool"],"sources":["../../src/pool/IndyVdrPoolService.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport type { GetNymResponse } from '@hyperledger/indy-vdr-shared'\n\nimport { didIndyRegex } from '@credo-ts/anoncreds'\nimport { CacheModuleConfig, InjectionSymbols, type Logger, inject, injectable } from '@credo-ts/core'\nimport { GetNymRequest } from '@hyperledger/indy-vdr-shared'\n\nimport { IndyVdrModuleConfig } from '../IndyVdrModuleConfig'\nimport { IndyVdrError, IndyVdrNotConfiguredError, IndyVdrNotFoundError } from '../error'\nimport { isSelfCertifiedDid } from '../utils/did'\nimport { allSettled, onlyFulfilled, onlyRejected } from '../utils/promises'\n\nimport { IndyVdrPool } from './IndyVdrPool'\n\nexport interface CachedDidResponse {\n nymResponse: {\n did: string\n verkey: string\n }\n indyNamespace: string\n}\n@injectable()\nexport class IndyVdrPoolService {\n public pools: IndyVdrPool[] = []\n private logger: Logger\n private indyVdrModuleConfig: IndyVdrModuleConfig\n\n public constructor(@inject(InjectionSymbols.Logger) logger: Logger, indyVdrModuleConfig: IndyVdrModuleConfig) {\n this.logger = logger\n this.indyVdrModuleConfig = indyVdrModuleConfig\n\n this.pools = this.indyVdrModuleConfig.networks.map((poolConfig) => new IndyVdrPool(poolConfig))\n }\n\n /**\n * Get the most appropriate pool for the given did.\n * If the did is a qualified indy did, the pool will be determined based on the namespace.\n * If it is a legacy unqualified indy did, the pool will be determined based on the algorithm as described in this document:\n * https://docs.google.com/document/d/109C_eMsuZnTnYe2OAd02jAts1vC4axwEKIq7_4dnNVA/edit\n *\n * This method will optionally return a nym response when the did has been resolved to determine the ledger\n * either now or in the past. The nymResponse can be used to prevent multiple ledger quries fetching the same\n * did\n */\n public async getPoolForDid(\n agentContext: AgentContext,\n did: string\n ): Promise<{ pool: IndyVdrPool; nymResponse?: CachedDidResponse['nymResponse'] }> {\n // Check if the did starts with did:indy\n const match = did.match(didIndyRegex)\n\n if (match) {\n const [, namespace] = match\n\n const pool = this.getPoolForNamespace(namespace)\n\n if (pool) return { pool }\n\n throw new IndyVdrError(`Pool for indy namespace '${namespace}' not found`)\n }\n return await this.getPoolForLegacyDid(agentContext, did)\n }\n\n private async getPoolForLegacyDid(\n agentContext: AgentContext,\n did: string\n ): Promise<{ pool: IndyVdrPool; nymResponse?: CachedDidResponse['nymResponse'] }> {\n const pools = this.pools\n\n if (pools.length === 0) {\n throw new IndyVdrNotConfiguredError(\n 'No indy ledgers configured. Provide at least one pool configuration in IndyVdrModuleConfigOptions.networks'\n )\n }\n\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n const cacheKey = `IndyVdrPoolService:${did}`\n\n const cachedNymResponse = await cache.get<CachedDidResponse>(agentContext, cacheKey)\n const pool = this.pools.find((pool) => pool.indyNamespace === cachedNymResponse?.indyNamespace)\n\n // If we have the nym response with associated pool in the cache, we'll use that\n if (cachedNymResponse && pool) {\n this.logger.trace(`Found ledger id '${pool.indyNamespace}' for did '${did}' in cache`)\n return { pool, nymResponse: cachedNymResponse.nymResponse }\n }\n\n const { successful, rejected } = await this.getSettledDidResponsesFromPools(did, pools)\n\n if (successful.length === 0) {\n const allNotFound = rejected.every((e) => e.reason instanceof IndyVdrNotFoundError)\n const rejectedOtherThanNotFound = rejected.filter((e) => !(e.reason instanceof IndyVdrNotFoundError))\n\n // All ledgers returned response that the did was not found\n if (allNotFound) {\n throw new IndyVdrNotFoundError(`Did '${did}' not found on any of the ledgers (total ${this.pools.length}).`)\n }\n\n // one or more of the ledgers returned an unknown error\n throw new IndyVdrError(\n `Unknown error retrieving did '${did}' from '${rejectedOtherThanNotFound.length}' of '${pools.length}' ledgers. ${rejectedOtherThanNotFound[0].reason}`,\n { cause: rejectedOtherThanNotFound[0].reason }\n )\n }\n\n // If there are self certified DIDs we always prefer it over non self certified DIDs\n // We take the first self certifying DID as we take the order in the\n // IndyVdrModuleConfigOptions.networks config as the order of preference of ledgers\n let value = successful.find((response) =>\n isSelfCertifiedDid(response.value.did.nymResponse.did, response.value.did.nymResponse.verkey)\n )?.value\n\n if (!value) {\n // Split between production and nonProduction ledgers. If there is at least one\n // successful response from a production ledger, only keep production ledgers\n // otherwise we only keep the non production ledgers.\n const production = successful.filter((s) => s.value.pool.config.isProduction)\n const nonProduction = successful.filter((s) => !s.value.pool.config.isProduction)\n const productionOrNonProduction = production.length >= 1 ? production : nonProduction\n\n // We take the first value as we take the order in the IndyVdrModuleConfigOptions.networks\n // config as the order of preference of ledgers\n value = productionOrNonProduction[0].value\n }\n\n await cache.set(agentContext, cacheKey, {\n nymResponse: {\n did: value.did.nymResponse.did,\n verkey: value.did.nymResponse.verkey,\n },\n indyNamespace: value.did.indyNamespace,\n })\n return { pool: value.pool, nymResponse: value.did.nymResponse }\n }\n\n private async getSettledDidResponsesFromPools(did: string, pools: IndyVdrPool[]) {\n this.logger.trace(`Retrieving did '${did}' from ${pools.length} ledgers`)\n const didResponses = await allSettled(pools.map((pool) => this.getDidFromPool(did, pool)))\n\n const successful = onlyFulfilled(didResponses)\n this.logger.trace(`Retrieved ${successful.length} responses from ledgers for did '${did}'`)\n\n const rejected = onlyRejected(didResponses)\n\n return {\n rejected,\n successful,\n }\n }\n\n /**\n * Refresh the pool connections asynchronously\n */\n public refreshPoolConnections() {\n return Promise.allSettled(this.pools.map((pool) => pool.refreshConnection()))\n }\n\n /**\n * Get all pool transactions\n */\n public getAllPoolTransactions() {\n return Promise.allSettled(\n this.pools.map(async (pool) => {\n return { config: pool.config, transactions: await pool.transactions }\n })\n )\n }\n\n /**\n * Get the most appropriate pool for the given indyNamespace\n */\n public getPoolForNamespace(indyNamespace: string) {\n if (this.pools.length === 0) {\n throw new IndyVdrNotConfiguredError(\n 'No indy ledgers configured. Provide at least one pool configuration in IndyVdrModuleConfigOptions.networks'\n )\n }\n\n const pool = this.pools.find((pool) => pool.indyNamespace === indyNamespace)\n\n if (!pool) {\n throw new IndyVdrError(`No ledgers found for indy namespace '${indyNamespace}'.`)\n }\n\n return pool\n }\n\n private async getDidFromPool(did: string, pool: IndyVdrPool): Promise<PublicDidRequest> {\n try {\n this.logger.trace(`Get public did '${did}' from ledger '${pool.indyNamespace}'`)\n const request = new GetNymRequest({ dest: did })\n\n this.logger.trace(`Submitting get did request for did '${did}' to ledger '${pool.indyNamespace}'`)\n const response = await pool.submitRequest(request)\n\n if (!response.result.data) {\n throw new IndyVdrNotFoundError(`Did ${did} not found on indy pool with namespace ${pool.indyNamespace}`)\n }\n\n const result = JSON.parse(response.result.data)\n\n this.logger.trace(`Retrieved did '${did}' from ledger '${pool.indyNamespace}'`, result)\n\n return {\n did: { nymResponse: { did: result.dest, verkey: result.verkey }, indyNamespace: pool.indyNamespace },\n pool,\n response,\n }\n } catch (error) {\n this.logger.trace(`Error retrieving did '${did}' from ledger '${pool.indyNamespace}'`, {\n error,\n did,\n })\n throw error\n }\n }\n}\n\nexport interface PublicDidRequest {\n did: CachedDidResponse\n pool: IndyVdrPool\n response: GetNymResponse\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBO,+BAAMA,qBAAmB;CAK9B,AAAO,YAAY,AAAiCC,QAAgB,qBAA0C;OAJvG,QAAuB,EAAE;AAK9B,OAAK,SAAS;AACd,OAAK,sBAAsB;AAE3B,OAAK,QAAQ,KAAK,oBAAoB,SAAS,KAAK,eAAe,IAAI,YAAY,WAAW,CAAC;;;;;;;;;;;;CAajG,MAAa,cACX,cACA,KACgF;EAEhF,MAAM,QAAQ,IAAI,MAAM,aAAa;AAErC,MAAI,OAAO;GACT,MAAM,GAAG,aAAa;GAEtB,MAAM,OAAO,KAAK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F,MAAI;AACF,QAAK,OAAO,MAAM,mBAAmB,IAAI,iBAAiB,KAAK,cAAc,GAAG;GAChF,MAAM,UAAU,IAAI,cAAc,EAAE,MAAM,KAAK,CAAC;AAEhD,QAAK,OAAO,MAAM,uCAAuC,IAAI,eAAe,KAAK,cAAc,GAAG;GAClG,MAAM,WAAW,MAAM,KAAK,cAAc,QAAQ;AAElD,OAAI,CAAC,SAAS,OAAO,KACnB,OAAM,IAAI,qBAAqB,OAAO,IAAI,yCAAyC,KAAK,gBAAgB;GAG1G,MAAM,SAAS,KAAK,MAAM,SAAS,OAAO,KAAK;AAE/C,QAAK,OAAO,MAAM,kBAAkB,IAAI,iBAAiB,KAAK,cAAc,IAAI,OAAO;AAEvF,UAAO;IACL,KAAK;KAAE,aAAa;MAAE,KAAK,OAAO;MAAM,QAAQ,OAAO;MAAQ;KAAE,eAAe,KAAK;KAAe;IACpG;IACA;IACD;WACM,OAAO;AACd,QAAK,OAAO,MAAM,yBAAyB,IAAI,iBAAiB,KAAK,cAAc,IAAI;IACrF;IACA;IACD,CAAC;AACF,SAAM;;;;;CAhMX,YAAY;oBAMS,OAAO,iBAAiB,OAAO"}
|
|
1
|
+
{"version":3,"file":"IndyVdrPoolService.mjs","names":["IndyVdrPoolService","logger: Logger","pool"],"sources":["../../src/pool/IndyVdrPoolService.ts"],"sourcesContent":["import { didIndyRegex } from '@credo-ts/anoncreds'\nimport type { AgentContext } from '@credo-ts/core'\nimport { CacheModuleConfig, InjectionSymbols, inject, injectable, type Logger } from '@credo-ts/core'\nimport type { GetNymResponse } from '@hyperledger/indy-vdr-shared'\nimport { GetNymRequest } from '@hyperledger/indy-vdr-shared'\nimport { IndyVdrError, IndyVdrNotConfiguredError, IndyVdrNotFoundError } from '../error'\nimport { IndyVdrModuleConfig } from '../IndyVdrModuleConfig'\nimport { isSelfCertifiedDid } from '../utils/did'\nimport { allSettled, onlyFulfilled, onlyRejected } from '../utils/promises'\n\nimport { IndyVdrPool } from './IndyVdrPool'\n\nexport interface CachedDidResponse {\n nymResponse: {\n did: string\n verkey: string\n }\n indyNamespace: string\n}\n@injectable()\nexport class IndyVdrPoolService {\n public pools: IndyVdrPool[] = []\n private logger: Logger\n private indyVdrModuleConfig: IndyVdrModuleConfig\n\n public constructor(@inject(InjectionSymbols.Logger) logger: Logger, indyVdrModuleConfig: IndyVdrModuleConfig) {\n this.logger = logger\n this.indyVdrModuleConfig = indyVdrModuleConfig\n\n this.pools = this.indyVdrModuleConfig.networks.map((poolConfig) => new IndyVdrPool(poolConfig))\n }\n\n /**\n * Get the most appropriate pool for the given did.\n * If the did is a qualified indy did, the pool will be determined based on the namespace.\n * If it is a legacy unqualified indy did, the pool will be determined based on the algorithm as described in this document:\n * https://docs.google.com/document/d/109C_eMsuZnTnYe2OAd02jAts1vC4axwEKIq7_4dnNVA/edit\n *\n * This method will optionally return a nym response when the did has been resolved to determine the ledger\n * either now or in the past. The nymResponse can be used to prevent multiple ledger quries fetching the same\n * did\n */\n public async getPoolForDid(\n agentContext: AgentContext,\n did: string\n ): Promise<{ pool: IndyVdrPool; nymResponse?: CachedDidResponse['nymResponse'] }> {\n // Check if the did starts with did:indy\n const match = did.match(didIndyRegex)\n\n if (match) {\n const [, namespace] = match\n\n const pool = this.getPoolForNamespace(namespace)\n\n if (pool) return { pool }\n\n throw new IndyVdrError(`Pool for indy namespace '${namespace}' not found`)\n }\n return await this.getPoolForLegacyDid(agentContext, did)\n }\n\n private async getPoolForLegacyDid(\n agentContext: AgentContext,\n did: string\n ): Promise<{ pool: IndyVdrPool; nymResponse?: CachedDidResponse['nymResponse'] }> {\n const pools = this.pools\n\n if (pools.length === 0) {\n throw new IndyVdrNotConfiguredError(\n 'No indy ledgers configured. Provide at least one pool configuration in IndyVdrModuleConfigOptions.networks'\n )\n }\n\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n const cacheKey = `IndyVdrPoolService:${did}`\n\n const cachedNymResponse = await cache.get<CachedDidResponse>(agentContext, cacheKey)\n const pool = this.pools.find((pool) => pool.indyNamespace === cachedNymResponse?.indyNamespace)\n\n // If we have the nym response with associated pool in the cache, we'll use that\n if (cachedNymResponse && pool) {\n this.logger.trace(`Found ledger id '${pool.indyNamespace}' for did '${did}' in cache`)\n return { pool, nymResponse: cachedNymResponse.nymResponse }\n }\n\n const { successful, rejected } = await this.getSettledDidResponsesFromPools(did, pools)\n\n if (successful.length === 0) {\n const allNotFound = rejected.every((e) => e.reason instanceof IndyVdrNotFoundError)\n const rejectedOtherThanNotFound = rejected.filter((e) => !(e.reason instanceof IndyVdrNotFoundError))\n\n // All ledgers returned response that the did was not found\n if (allNotFound) {\n throw new IndyVdrNotFoundError(`Did '${did}' not found on any of the ledgers (total ${this.pools.length}).`)\n }\n\n // one or more of the ledgers returned an unknown error\n throw new IndyVdrError(\n `Unknown error retrieving did '${did}' from '${rejectedOtherThanNotFound.length}' of '${pools.length}' ledgers. ${rejectedOtherThanNotFound[0].reason}`,\n { cause: rejectedOtherThanNotFound[0].reason }\n )\n }\n\n // If there are self certified DIDs we always prefer it over non self certified DIDs\n // We take the first self certifying DID as we take the order in the\n // IndyVdrModuleConfigOptions.networks config as the order of preference of ledgers\n let value = successful.find((response) =>\n isSelfCertifiedDid(response.value.did.nymResponse.did, response.value.did.nymResponse.verkey)\n )?.value\n\n if (!value) {\n // Split between production and nonProduction ledgers. If there is at least one\n // successful response from a production ledger, only keep production ledgers\n // otherwise we only keep the non production ledgers.\n const production = successful.filter((s) => s.value.pool.config.isProduction)\n const nonProduction = successful.filter((s) => !s.value.pool.config.isProduction)\n const productionOrNonProduction = production.length >= 1 ? production : nonProduction\n\n // We take the first value as we take the order in the IndyVdrModuleConfigOptions.networks\n // config as the order of preference of ledgers\n value = productionOrNonProduction[0].value\n }\n\n await cache.set(agentContext, cacheKey, {\n nymResponse: {\n did: value.did.nymResponse.did,\n verkey: value.did.nymResponse.verkey,\n },\n indyNamespace: value.did.indyNamespace,\n })\n return { pool: value.pool, nymResponse: value.did.nymResponse }\n }\n\n private async getSettledDidResponsesFromPools(did: string, pools: IndyVdrPool[]) {\n this.logger.trace(`Retrieving did '${did}' from ${pools.length} ledgers`)\n const didResponses = await allSettled(pools.map((pool) => this.getDidFromPool(did, pool)))\n\n const successful = onlyFulfilled(didResponses)\n this.logger.trace(`Retrieved ${successful.length} responses from ledgers for did '${did}'`)\n\n const rejected = onlyRejected(didResponses)\n\n return {\n rejected,\n successful,\n }\n }\n\n /**\n * Refresh the pool connections asynchronously\n */\n public refreshPoolConnections() {\n return Promise.allSettled(this.pools.map((pool) => pool.refreshConnection()))\n }\n\n /**\n * Get all pool transactions\n */\n public getAllPoolTransactions() {\n return Promise.allSettled(\n this.pools.map(async (pool) => {\n return { config: pool.config, transactions: await pool.transactions }\n })\n )\n }\n\n /**\n * Get the most appropriate pool for the given indyNamespace\n */\n public getPoolForNamespace(indyNamespace: string) {\n if (this.pools.length === 0) {\n throw new IndyVdrNotConfiguredError(\n 'No indy ledgers configured. Provide at least one pool configuration in IndyVdrModuleConfigOptions.networks'\n )\n }\n\n const pool = this.pools.find((pool) => pool.indyNamespace === indyNamespace)\n\n if (!pool) {\n throw new IndyVdrError(`No ledgers found for indy namespace '${indyNamespace}'.`)\n }\n\n return pool\n }\n\n private async getDidFromPool(did: string, pool: IndyVdrPool): Promise<PublicDidRequest> {\n try {\n this.logger.trace(`Get public did '${did}' from ledger '${pool.indyNamespace}'`)\n const request = new GetNymRequest({ dest: did })\n\n this.logger.trace(`Submitting get did request for did '${did}' to ledger '${pool.indyNamespace}'`)\n const response = await pool.submitRequest(request)\n\n if (!response.result.data) {\n throw new IndyVdrNotFoundError(`Did ${did} not found on indy pool with namespace ${pool.indyNamespace}`)\n }\n\n const result = JSON.parse(response.result.data)\n\n this.logger.trace(`Retrieved did '${did}' from ledger '${pool.indyNamespace}'`, result)\n\n return {\n did: { nymResponse: { did: result.dest, verkey: result.verkey }, indyNamespace: pool.indyNamespace },\n pool,\n response,\n }\n } catch (error) {\n this.logger.trace(`Error retrieving did '${did}' from ledger '${pool.indyNamespace}'`, {\n error,\n did,\n })\n throw error\n }\n }\n}\n\nexport interface PublicDidRequest {\n did: CachedDidResponse\n pool: IndyVdrPool\n response: GetNymResponse\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBO,+BAAMA,qBAAmB;CAK9B,AAAO,YAAY,AAAiCC,QAAgB,qBAA0C;OAJvG,QAAuB,EAAE;AAK9B,OAAK,SAAS;AACd,OAAK,sBAAsB;AAE3B,OAAK,QAAQ,KAAK,oBAAoB,SAAS,KAAK,eAAe,IAAI,YAAY,WAAW,CAAC;;;;;;;;;;;;CAajG,MAAa,cACX,cACA,KACgF;EAEhF,MAAM,QAAQ,IAAI,MAAM,aAAa;AAErC,MAAI,OAAO;GACT,MAAM,GAAG,aAAa;GAEtB,MAAM,OAAO,KAAK,oBAAoB,UAAU;AAEhD,OAAI,KAAM,QAAO,EAAE,MAAM;AAEzB,SAAM,IAAI,aAAa,4BAA4B,UAAU,aAAa;;AAE5E,SAAO,MAAM,KAAK,oBAAoB,cAAc,IAAI;;CAG1D,MAAc,oBACZ,cACA,KACgF;EAChF,MAAM,QAAQ,KAAK;AAEnB,MAAI,MAAM,WAAW,EACnB,OAAM,IAAI,0BACR,6GACD;EAGH,MAAM,QAAQ,aAAa,kBAAkB,QAAQ,kBAAkB,CAAC;EACxE,MAAM,WAAW,sBAAsB;EAEvC,MAAM,oBAAoB,MAAM,MAAM,IAAuB,cAAc,SAAS;EACpF,MAAM,OAAO,KAAK,MAAM,MAAM,WAASC,OAAK,kBAAkB,mBAAmB,cAAc;AAG/F,MAAI,qBAAqB,MAAM;AAC7B,QAAK,OAAO,MAAM,oBAAoB,KAAK,cAAc,aAAa,IAAI,YAAY;AACtF,UAAO;IAAE;IAAM,aAAa,kBAAkB;IAAa;;EAG7D,MAAM,EAAE,YAAY,aAAa,MAAM,KAAK,gCAAgC,KAAK,MAAM;AAEvF,MAAI,WAAW,WAAW,GAAG;GAC3B,MAAM,cAAc,SAAS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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promises.mjs","names":[],"sources":["../../src/utils/promises.ts"],"sourcesContent":["// This file polyfills the allSettled method introduced in ESNext\n\nexport type AllSettledFulfilled<T> = {\n status: 'fulfilled'\n value: T\n}\n\nexport type AllSettledRejected = {\n status: 'rejected'\n // biome-ignore lint/suspicious/noExplicitAny:
|
|
1
|
+
{"version":3,"file":"promises.mjs","names":[],"sources":["../../src/utils/promises.ts"],"sourcesContent":["// This file polyfills the allSettled method introduced in ESNext\n\nexport type AllSettledFulfilled<T> = {\n status: 'fulfilled'\n value: T\n}\n\nexport type AllSettledRejected = {\n status: 'rejected'\n // biome-ignore lint/suspicious/noExplicitAny: no explanation\n reason: any\n}\n\nexport function allSettled<T>(promises: Promise<T>[]) {\n return Promise.all(\n promises.map((p) =>\n p\n .then(\n (value) =>\n ({\n status: 'fulfilled',\n value,\n }) as AllSettledFulfilled<T>\n )\n .catch(\n (reason) =>\n ({\n status: 'rejected',\n reason,\n }) as AllSettledRejected\n )\n )\n )\n}\n\nexport function onlyFulfilled<T>(entries: Array<AllSettledFulfilled<T> | AllSettledRejected>) {\n // We filter for only the rejected values, so we can safely cast the type\n return entries.filter((e) => e.status === 'fulfilled') as AllSettledFulfilled<T>[]\n}\n\nexport function onlyRejected<T>(entries: Array<AllSettledFulfilled<T> | AllSettledRejected>) {\n // We filter for only the rejected values, so we can safely cast the type\n return entries.filter((e) => e.status === 'rejected') as AllSettledRejected[]\n}\n"],"mappings":";AAaA,SAAgB,WAAc,UAAwB;AACpD,QAAO,QAAQ,IACb,SAAS,KAAK,MACZ,EACG,MACE,WACE;EACC,QAAQ;EACR;EACD,EACJ,CACA,OACE,YACE;EACC,QAAQ;EACR;EACD,EACJ,CACJ,CACF;;AAGH,SAAgB,cAAiB,SAA6D;AAE5F,QAAO,QAAQ,QAAQ,MAAM,EAAE,WAAW,YAAY;;AAGxD,SAAgB,aAAgB,SAA6D;AAE3F,QAAO,QAAQ,QAAQ,MAAM,EAAE,WAAW,WAAW"}
|
package/build/utils/sign.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign.mjs","names":[],"sources":["../../src/utils/sign.ts"],"sourcesContent":["import { AgentContext, Kms } from '@credo-ts/core'\nimport type { IndyVdrRequest } from '@hyperledger/indy-vdr-shared'\nimport
|
|
1
|
+
{"version":3,"file":"sign.mjs","names":[],"sources":["../../src/utils/sign.ts"],"sourcesContent":["import { AgentContext, Kms, TypedArrayEncoder } from '@credo-ts/core'\nimport type { IndyVdrRequest } from '@hyperledger/indy-vdr-shared'\nimport { verificationPublicJwkForIndyDid } from '../dids/didIndyUtil'\nimport type { IndyVdrPool } from '../pool'\n\nexport async function multiSignRequest<Request extends IndyVdrRequest>(\n agentContext: AgentContext,\n request: Request,\n signingKey: Kms.PublicJwk<Kms.Ed25519PublicJwk>,\n identifier: string\n) {\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n const { signature } = await kms.sign({\n data: TypedArrayEncoder.fromString(request.signatureInput),\n algorithm: 'EdDSA',\n keyId: signingKey.keyId,\n })\n\n request.setMultiSignature({\n signature,\n identifier,\n })\n\n return request\n}\n\nexport async function signRequest<Request extends IndyVdrRequest>(\n agentContext: AgentContext,\n pool: IndyVdrPool,\n request: Request,\n submitterDid: string\n) {\n const signingKey = await verificationPublicJwkForIndyDid(agentContext, submitterDid)\n const signedRequest = await pool.prepareWriteRequest(agentContext, request, signingKey)\n\n return signedRequest\n}\n"],"mappings":";;;;AAKA,eAAsB,iBACpB,cACA,SACA,YACA,YACA;CAEA,MAAM,EAAE,cAAc,MADV,aAAa,kBAAkB,QAAQ,IAAI,iBAAiB,CACxC,KAAK;EACnC,MAAM,kBAAkB,WAAW,QAAQ,eAAe;EAC1D,WAAW;EACX,OAAO,WAAW;EACnB,CAAC;AAEF,SAAQ,kBAAkB;EACxB;EACA;EACD,CAAC;AAEF,QAAO;;AAGT,eAAsB,YACpB,cACA,MACA,SACA,cACA;CACA,MAAM,aAAa,MAAM,gCAAgC,cAAc,aAAa;AAGpF,QAFsB,MAAM,KAAK,oBAAoB,cAAc,SAAS,WAAW"}
|
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
|
],
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
"directory": "packages/indy-vdr"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@credo-ts/anoncreds": "0.6.0-pr-
|
|
27
|
-
"@credo-ts/core": "0.6.0-pr-
|
|
26
|
+
"@credo-ts/anoncreds": "0.6.0-pr-2454-20251015095608",
|
|
27
|
+
"@credo-ts/core": "0.6.0-pr-2454-20251015095608"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@hyperledger/indy-vdr-nodejs": "^0.2.2",
|
|
31
31
|
"@hyperledger/indy-vdr-shared": "^0.2.2",
|
|
32
|
-
"@stablelib/ed25519": "^
|
|
32
|
+
"@stablelib/ed25519": "^2.0.2",
|
|
33
33
|
"@types/ref-array-di": "^1.2.6",
|
|
34
34
|
"@types/ref-struct-di": "^1.1.10",
|
|
35
35
|
"rxjs": "^7.8.2",
|
|
36
|
-
"typescript": "~5.
|
|
36
|
+
"typescript": "~5.9.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@hyperledger/indy-vdr-shared": "^0.2.2"
|