@credo-ts/anoncreds 0.6.0-pr-2539-20251127092008 → 0.6.0
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/AnonCredsApi.d.mts +5 -5
- package/build/AnonCredsApi.d.mts.map +1 -1
- package/build/AnonCredsApi.mjs +17 -97
- package/build/AnonCredsApi.mjs.map +1 -1
- package/build/_virtual/{_@oxc-project_runtime@0.97.0 → _@oxc-project_runtime@0.99.0}/helpers/decorate.mjs +1 -1
- package/build/_virtual/{_@oxc-project_runtime@0.97.0 → _@oxc-project_runtime@0.99.0}/helpers/decorateMetadata.mjs +1 -1
- package/build/_virtual/{_@oxc-project_runtime@0.97.0 → _@oxc-project_runtime@0.99.0}/helpers/decorateParam.mjs +1 -1
- package/build/anoncreds-rs/AnonCredsDataIntegrityService.mjs +1 -1
- package/build/anoncreds-rs/AnonCredsRsHolderService.mjs +1 -1
- package/build/anoncreds-rs/AnonCredsRsIssuerService.mjs +1 -1
- package/build/anoncreds-rs/AnonCredsRsVerifierService.mjs +1 -1
- package/build/formats/DataIntegrityDidCommCredentialFormatService.mjs +1 -1
- package/build/formats/DataIntegrityDidCommCredentialFormatService.mjs.map +1 -1
- package/build/models/AnonCredsCredentialProposal.mjs +2 -2
- package/build/models/AnonCredsProofRequest.mjs +2 -2
- package/build/models/AnonCredsRequestedAttribute.mjs +2 -2
- package/build/models/AnonCredsRequestedPredicate.mjs +2 -2
- package/build/models/AnonCredsRestriction.mjs +2 -2
- package/build/models/AnonCredsRestrictionWrapper.mjs +2 -2
- package/build/models/AnonCredsRevocationInterval.mjs +2 -2
- package/build/protocols/credentials/v1/messages/DidCommCredentialV1AckMessage.mjs +2 -2
- package/build/protocols/credentials/v1/messages/DidCommCredentialV1Preview.mjs +2 -2
- package/build/protocols/credentials/v1/messages/DidCommCredentialV1ProblemReportMessage.mjs +2 -2
- package/build/protocols/credentials/v1/messages/DidCommIssueCredentialV1Message.mjs +2 -2
- package/build/protocols/credentials/v1/messages/DidCommOfferCredentialV1Message.mjs +2 -2
- package/build/protocols/credentials/v1/messages/DidCommProposeCredentialV1Message.mjs +2 -2
- package/build/protocols/credentials/v1/messages/DidCommRequestCredentialV1Message.mjs +2 -2
- package/build/protocols/proofs/v1/messages/DidCommPresentationV1AckMessage.mjs +2 -2
- package/build/protocols/proofs/v1/messages/DidCommPresentationV1Message.mjs +2 -2
- package/build/protocols/proofs/v1/messages/DidCommPresentationV1ProblemReportMessage.mjs +2 -2
- package/build/protocols/proofs/v1/messages/DidCommProposePresentationV1Message.mjs +2 -2
- package/build/protocols/proofs/v1/messages/DidCommRequestPresentationV1Message.mjs +2 -2
- package/build/protocols/proofs/v1/models/DidCommPresentationV1Preview.mjs +2 -2
- package/build/repository/AnonCredsCredentialDefinitionPrivateRepository.mjs +3 -3
- package/build/repository/AnonCredsCredentialDefinitionRepository.mjs +3 -3
- package/build/repository/AnonCredsCredentialRepository.mjs +3 -3
- package/build/repository/AnonCredsKeyCorrectnessProofRepository.mjs +3 -3
- package/build/repository/AnonCredsLinkSecretRepository.mjs +3 -3
- package/build/repository/AnonCredsRevocationRegistryDefinitionPrivateRepository.mjs +3 -3
- package/build/repository/AnonCredsRevocationRegistryDefinitionRepository.mjs +3 -3
- package/build/repository/AnonCredsSchemaRepository.mjs +3 -3
- package/build/services/registry/AnonCredsRegistry.d.mts +14 -2
- package/build/services/registry/AnonCredsRegistry.d.mts.map +1 -1
- package/build/services/registry/AnonCredsRegistryService.d.mts +11 -1
- package/build/services/registry/AnonCredsRegistryService.d.mts.map +1 -1
- package/build/services/registry/AnonCredsRegistryService.mjs +209 -2
- package/build/services/registry/AnonCredsRegistryService.mjs.map +1 -1
- package/build/services/registry/base.d.mts +43 -1
- package/build/services/registry/base.d.mts.map +1 -1
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.
|
|
3
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateMetadata.mjs";
|
|
2
|
+
import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateParam.mjs";
|
|
3
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
4
|
import { AnonCredsRevocationRegistryDefinitionRecord } from "./AnonCredsRevocationRegistryDefinitionRecord.mjs";
|
|
5
5
|
import { EventEmitter, InjectionSymbols, Repository, inject, injectable } from "@credo-ts/core";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.
|
|
3
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateMetadata.mjs";
|
|
2
|
+
import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateParam.mjs";
|
|
3
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
4
|
import { AnonCredsSchemaRecord } from "./AnonCredsSchemaRecord.mjs";
|
|
5
5
|
import { EventEmitter, InjectionSymbols, Repository, inject, injectable } from "@credo-ts/core";
|
|
6
6
|
|
|
@@ -11,12 +11,24 @@ import { AgentContext } from "@credo-ts/core";
|
|
|
11
11
|
*/
|
|
12
12
|
interface AnonCredsRegistry {
|
|
13
13
|
/**
|
|
14
|
-
* A name to identify the registry. This will be stored as part of the
|
|
15
|
-
* for created objects using a specific registry.
|
|
14
|
+
* A name to identify the registry. This will be stored as part of the registered anoncreds objects to allow querying
|
|
15
|
+
* for created objects using a specific registry. Multiple implementations can use the same name, but they should in that
|
|
16
16
|
* case also reference objects on the same networks.
|
|
17
17
|
*/
|
|
18
18
|
methodName: string;
|
|
19
19
|
supportedIdentifier: RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Whether this registry allows caching of resolved objects (as well as caching
|
|
22
|
+
* just created objects).
|
|
23
|
+
*/
|
|
24
|
+
readonly allowsCaching?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the resolver allows using a local created object from
|
|
27
|
+
* a record to resolve the object.
|
|
28
|
+
*
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
readonly allowsLocalRecord?: boolean;
|
|
20
32
|
getSchema(agentContext: AgentContext, schemaId: string): Promise<GetSchemaReturn>;
|
|
21
33
|
registerSchema(agentContext: AgentContext, options: RegisterSchemaOptions): Promise<RegisterSchemaReturn>;
|
|
22
34
|
getCredentialDefinition(agentContext: AgentContext, credentialDefinitionId: string): Promise<GetCredentialDefinitionReturn>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnonCredsRegistry.d.mts","names":[],"sources":["../../../src/services/registry/AnonCredsRegistry.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAqBA;AAQuB,UARN,iBAAA,CAQM;
|
|
1
|
+
{"version":3,"file":"AnonCredsRegistry.d.mts","names":[],"sources":["../../../src/services/registry/AnonCredsRegistry.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAqBA;AAQuB,UARN,iBAAA,CAQM;EAgBG;;;;;EAC4D,UAAA,EAAA,MAAA;EAAR,mBAAA,EAjBvD,MAiBuD;EAG5D;;;;EAKL,SAAA,aAAA,CAAA,EAAA,OAAA;EACA;;;;;;EASA,SAAA,iBAAA,CAAA,EAAA,OAAA;EACA,SAAA,CAAA,YAAA,EApBa,YAoBb,EAAA,QAAA,EAAA,MAAA,CAAA,EApB8C,OAoB9C,CApBsD,eAoBtD,CAAA;EAAR,cAAA,CAAA,YAAA,EAnB0B,YAmB1B,EAAA,OAAA,EAnBiD,qBAmBjD,CAAA,EAnByE,OAmBzE,CAnBiF,oBAmBjF,CAAA;EAGa,uBAAA,CAAA,YAAA,EAnBA,YAmBA,EAAA,sBAAA,EAAA,MAAA,CAAA,EAjBb,OAiBa,CAjBL,6BAiBK,CAAA;EAGL,4BAAA,CAAA,YAAA,EAlBK,YAkBL,EAAA,OAAA,EAjBA,mCAiBA,CAAA,EAhBR,OAgBQ,CAhBA,kCAgBA,CAAA;EAAR,+BAAA,CAAA,YAAA,EAba,YAab,EAAA,8BAAA,EAAA,MAAA,CAAA,EAXA,OAWA,CAXQ,qCAWR,CAAA;EAGa,oCAAA,CAAA,YAAA,EAXA,YAWA,EAAA,OAAA,EAVL,2CAUK,CAAA,EATb,OASa,CATL,0CASK,CAAA;EACL,uBAAA,CAAA,YAAA,EAPK,YAOL,EAAA,oBAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,CAAA,EAJR,OAIQ,CAJA,6BAIA,CAAA;EACA,4BAAA,CAAA,YAAA,EAFK,YAEL,EAAA,OAAA,EADA,mCACA,CAAA,EAAR,OAAQ,CAAA,kCAAA,CAAA"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { AnonCredsResolutionOptions } from "./base.mjs";
|
|
2
|
+
import { GetCredentialDefinitionReturn } from "./CredentialDefinitionOptions.mjs";
|
|
3
|
+
import { GetRevocationRegistryDefinitionReturn } from "./RevocationRegistryDefinitionOptions.mjs";
|
|
4
|
+
import { GetRevocationStatusListReturn } from "./RevocationStatusListOptions.mjs";
|
|
5
|
+
import { GetSchemaReturn } from "./SchemaOptions.mjs";
|
|
1
6
|
import { AnonCredsRegistry } from "./AnonCredsRegistry.mjs";
|
|
2
|
-
import "./index.mjs";
|
|
3
7
|
import { AgentContext } from "@credo-ts/core";
|
|
4
8
|
|
|
5
9
|
//#region src/services/registry/AnonCredsRegistryService.d.ts
|
|
@@ -10,7 +14,13 @@ import { AgentContext } from "@credo-ts/core";
|
|
|
10
14
|
* and returns the correct registry based on a given identifier
|
|
11
15
|
*/
|
|
12
16
|
declare class AnonCredsRegistryService {
|
|
17
|
+
getSchema(agentContext: AgentContext, schemaId: string, options?: AnonCredsResolutionOptions): Promise<GetSchemaReturn>;
|
|
18
|
+
getCredentialDefinition(agentContext: AgentContext, credentialDefinitionId: string, options?: AnonCredsResolutionOptions): Promise<GetCredentialDefinitionReturn>;
|
|
19
|
+
getRevocationRegistryDefinition(agentContext: AgentContext, revocationRegistryDefinitionId: string, options?: AnonCredsResolutionOptions): Promise<GetRevocationRegistryDefinitionReturn>;
|
|
20
|
+
getRevocationStatusList(agentContext: AgentContext, revocationRegistryDefinitionId: string, timestamp: number, options?: Omit<AnonCredsResolutionOptions, 'useLocalRecord'>): Promise<GetRevocationStatusListReturn>;
|
|
13
21
|
getRegistryForIdentifier(agentContext: AgentContext, identifier: string): AnonCredsRegistry;
|
|
22
|
+
private findRegistryForIdentifier;
|
|
23
|
+
private getCacheKey;
|
|
14
24
|
}
|
|
15
25
|
//#endregion
|
|
16
26
|
export { AnonCredsRegistryService };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnonCredsRegistryService.d.mts","names":[],"sources":["../../../src/services/registry/AnonCredsRegistryService.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AnonCredsRegistryService.d.mts","names":[],"sources":["../../../src/services/registry/AnonCredsRegistryService.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAuBA;;;AAMa,cALA,wBAAA,CAKA;EAAR,SAAA,CAAA,YAAA,EAHa,YAGb,EAAA,QAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EADQ,0BACR,CAAA,EAAA,OAAA,CAAQ,eAAR,CAAA;EAwFa,uBAAA,CAAA,YAAA,EAAA,YAAA,EAAA,sBAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAEL,0BAFK,CAAA,EAGb,OAHa,CAGL,6BAHK,CAAA;EAEL,+BAAA,CAAA,YAAA,EA4FK,YA5FL,EAAA,8BAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EA8FA,0BA9FA,CAAA,EA+FR,OA/FQ,CA+FA,qCA/FA,CAAA;EACA,uBAAA,CAAA,YAAA,EA+LK,YA/LL,EAAA,8BAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAmMA,IAnMA,CAmMK,0BAnML,EAAA,gBAAA,CAAA,CAAA,EAoMR,OApMQ,CAoMA,6BApMA,CAAA;EAAR,wBAAA,CAAA,YAAA,EAuQ2C,YAvQ3C,EAAA,UAAA,EAAA,MAAA,CAAA,EAuQ8E,iBAvQ9E;EA2Fa,QAAA,yBAAA;EAEL,QAAA,WAAA"}
|
|
@@ -1,16 +1,223 @@
|
|
|
1
1
|
import { AnonCredsModuleConfig } from "../../AnonCredsModuleConfig.mjs";
|
|
2
2
|
import { AnonCredsError } from "../../error/AnonCredsError.mjs";
|
|
3
3
|
import "../../error/index.mjs";
|
|
4
|
-
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.
|
|
5
|
-
import {
|
|
4
|
+
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
5
|
+
import { AnonCredsCredentialDefinitionRepository } from "../../repository/AnonCredsCredentialDefinitionRepository.mjs";
|
|
6
|
+
import { AnonCredsRevocationRegistryDefinitionRepository } from "../../repository/AnonCredsRevocationRegistryDefinitionRepository.mjs";
|
|
7
|
+
import { AnonCredsSchemaRepository } from "../../repository/AnonCredsSchemaRepository.mjs";
|
|
8
|
+
import "../../repository/index.mjs";
|
|
9
|
+
import { AnonCredsCredentialDefinitionRecordMetadataKeys } from "../../repository/anonCredsCredentialDefinitionRecordMetadataTypes.mjs";
|
|
10
|
+
import { AnonCredsRevocationRegistryDefinitionRecordMetadataKeys } from "../../repository/anonCredsRevocationRegistryDefinitionRecordMetadataTypes.mjs";
|
|
11
|
+
import { CacheModuleConfig, injectable } from "@credo-ts/core";
|
|
6
12
|
|
|
7
13
|
//#region src/services/registry/AnonCredsRegistryService.ts
|
|
8
14
|
let AnonCredsRegistryService = class AnonCredsRegistryService$1 {
|
|
15
|
+
async getSchema(agentContext, schemaId, options = {}) {
|
|
16
|
+
const failedReturnBase = {
|
|
17
|
+
resolutionMetadata: {
|
|
18
|
+
error: "error",
|
|
19
|
+
message: `Unable to resolve schema ${schemaId}`
|
|
20
|
+
},
|
|
21
|
+
schemaId,
|
|
22
|
+
schemaMetadata: {}
|
|
23
|
+
};
|
|
24
|
+
const registry = this.findRegistryForIdentifier(agentContext, schemaId);
|
|
25
|
+
if (!registry) {
|
|
26
|
+
failedReturnBase.resolutionMetadata.error = "unsupportedAnonCredsMethod";
|
|
27
|
+
failedReturnBase.resolutionMetadata.message = `Unable to resolve schema ${schemaId}: No registry found for identifier ${schemaId}`;
|
|
28
|
+
return failedReturnBase;
|
|
29
|
+
}
|
|
30
|
+
const { useCache = true, cacheDurationInSeconds = 300, persistInCache = true, useLocalRecord = true } = options;
|
|
31
|
+
const cacheKey = this.getCacheKey("schema", schemaId);
|
|
32
|
+
if (registry.allowsCaching && useCache) {
|
|
33
|
+
const cachedSchema = await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.get(agentContext, cacheKey);
|
|
34
|
+
if (cachedSchema) return {
|
|
35
|
+
...cachedSchema,
|
|
36
|
+
resolutionMetadata: {
|
|
37
|
+
...cachedSchema.resolutionMetadata,
|
|
38
|
+
servedFromCache: true
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (registry.allowsLocalRecord && useLocalRecord) {
|
|
43
|
+
const schemaRecord = await agentContext.resolve(AnonCredsSchemaRepository).findSingleByQuery(agentContext, { schemaId });
|
|
44
|
+
if (schemaRecord) return {
|
|
45
|
+
schemaId,
|
|
46
|
+
schema: schemaRecord.schema,
|
|
47
|
+
schemaMetadata: {},
|
|
48
|
+
resolutionMetadata: {
|
|
49
|
+
servedFromCache: false,
|
|
50
|
+
servedFromRecord: true
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const result = await registry.getSchema(agentContext, schemaId);
|
|
56
|
+
if (result.schema && registry.allowsCaching && persistInCache) await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.set(agentContext, cacheKey, result, cacheDurationInSeconds);
|
|
57
|
+
return {
|
|
58
|
+
...result,
|
|
59
|
+
resolutionMetadata: { servedFromCache: result.resolutionMetadata.servedFromCache ?? false }
|
|
60
|
+
};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
failedReturnBase.resolutionMetadata.message = `Unable to resolve schema ${schemaId}: ${error.message}`;
|
|
63
|
+
return failedReturnBase;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async getCredentialDefinition(agentContext, credentialDefinitionId, options = {}) {
|
|
67
|
+
const failedReturnBase = {
|
|
68
|
+
resolutionMetadata: {
|
|
69
|
+
error: "error",
|
|
70
|
+
message: `Unable to resolve credential definition ${credentialDefinitionId}`
|
|
71
|
+
},
|
|
72
|
+
credentialDefinitionId,
|
|
73
|
+
credentialDefinitionMetadata: {}
|
|
74
|
+
};
|
|
75
|
+
const registry = this.findRegistryForIdentifier(agentContext, credentialDefinitionId);
|
|
76
|
+
if (!registry) {
|
|
77
|
+
failedReturnBase.resolutionMetadata.error = "unsupportedAnonCredsMethod";
|
|
78
|
+
failedReturnBase.resolutionMetadata.message = `Unable to resolve credential definition ${credentialDefinitionId}: No registry found for identifier ${credentialDefinitionId}`;
|
|
79
|
+
return failedReturnBase;
|
|
80
|
+
}
|
|
81
|
+
const { useCache = true, cacheDurationInSeconds = 300, persistInCache = true, useLocalRecord = true } = options;
|
|
82
|
+
const cacheKey = this.getCacheKey("credentialDefinition", credentialDefinitionId);
|
|
83
|
+
if (registry.allowsCaching && useCache) {
|
|
84
|
+
const cachedCredentialDefinition = await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.get(agentContext, cacheKey);
|
|
85
|
+
if (cachedCredentialDefinition) return {
|
|
86
|
+
...cachedCredentialDefinition,
|
|
87
|
+
resolutionMetadata: {
|
|
88
|
+
...cachedCredentialDefinition.resolutionMetadata,
|
|
89
|
+
servedFromCache: true
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (registry.allowsLocalRecord && useLocalRecord) {
|
|
94
|
+
const credentialDefinitionRecord = await agentContext.resolve(AnonCredsCredentialDefinitionRepository).findSingleByQuery(agentContext, { credentialDefinitionId });
|
|
95
|
+
if (credentialDefinitionRecord) return {
|
|
96
|
+
credentialDefinitionId,
|
|
97
|
+
credentialDefinition: credentialDefinitionRecord.credentialDefinition,
|
|
98
|
+
credentialDefinitionMetadata: credentialDefinitionRecord.metadata.get(AnonCredsCredentialDefinitionRecordMetadataKeys.CredentialDefinitionMetadata) ?? {},
|
|
99
|
+
resolutionMetadata: {
|
|
100
|
+
servedFromCache: false,
|
|
101
|
+
servedFromRecord: true
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const result = await registry.getCredentialDefinition(agentContext, credentialDefinitionId);
|
|
107
|
+
if (result.credentialDefinition && registry.allowsCaching && persistInCache) await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.set(agentContext, cacheKey, result, cacheDurationInSeconds);
|
|
108
|
+
return {
|
|
109
|
+
...result,
|
|
110
|
+
resolutionMetadata: { servedFromCache: result.resolutionMetadata.servedFromCache ?? false }
|
|
111
|
+
};
|
|
112
|
+
} catch (error) {
|
|
113
|
+
failedReturnBase.resolutionMetadata.message = `Unable to resolve credential definition ${credentialDefinitionId}: ${error.message}`;
|
|
114
|
+
return failedReturnBase;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async getRevocationRegistryDefinition(agentContext, revocationRegistryDefinitionId, options = {}) {
|
|
118
|
+
const failedReturnBase = {
|
|
119
|
+
resolutionMetadata: {
|
|
120
|
+
error: "error",
|
|
121
|
+
message: `Unable to resolve revocation registry ${revocationRegistryDefinitionId}`
|
|
122
|
+
},
|
|
123
|
+
revocationRegistryDefinitionId,
|
|
124
|
+
revocationRegistryDefinitionMetadata: {}
|
|
125
|
+
};
|
|
126
|
+
const registry = this.findRegistryForIdentifier(agentContext, revocationRegistryDefinitionId);
|
|
127
|
+
if (!registry) {
|
|
128
|
+
failedReturnBase.resolutionMetadata.error = "unsupportedAnonCredsMethod";
|
|
129
|
+
failedReturnBase.resolutionMetadata.message = `Unable to resolve revocation registry ${revocationRegistryDefinitionId}: No registry found for identifier ${revocationRegistryDefinitionId}`;
|
|
130
|
+
return failedReturnBase;
|
|
131
|
+
}
|
|
132
|
+
const { useCache = true, cacheDurationInSeconds = 300, persistInCache = true, useLocalRecord = true } = options;
|
|
133
|
+
const cacheKey = this.getCacheKey("revocationRegistryDefinition", revocationRegistryDefinitionId);
|
|
134
|
+
if (registry.allowsCaching && useCache) {
|
|
135
|
+
const cachedRevocationRegistryDefinition = await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.get(agentContext, cacheKey);
|
|
136
|
+
if (cachedRevocationRegistryDefinition) return {
|
|
137
|
+
...cachedRevocationRegistryDefinition,
|
|
138
|
+
resolutionMetadata: {
|
|
139
|
+
...cachedRevocationRegistryDefinition.resolutionMetadata,
|
|
140
|
+
servedFromCache: true
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (registry.allowsLocalRecord && useLocalRecord) {
|
|
145
|
+
const anoncredsRevocationRegistryDefinitionRecord = await agentContext.resolve(AnonCredsRevocationRegistryDefinitionRepository).findSingleByQuery(agentContext, { revocationRegistryDefinitionId });
|
|
146
|
+
if (anoncredsRevocationRegistryDefinitionRecord) return {
|
|
147
|
+
revocationRegistryDefinitionId,
|
|
148
|
+
revocationRegistryDefinition: anoncredsRevocationRegistryDefinitionRecord.revocationRegistryDefinition,
|
|
149
|
+
revocationRegistryDefinitionMetadata: anoncredsRevocationRegistryDefinitionRecord.metadata.get(AnonCredsRevocationRegistryDefinitionRecordMetadataKeys.RevocationRegistryDefinitionMetadata) ?? {},
|
|
150
|
+
resolutionMetadata: {
|
|
151
|
+
servedFromCache: false,
|
|
152
|
+
servedFromRecord: true
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const result = await registry.getRevocationRegistryDefinition(agentContext, revocationRegistryDefinitionId);
|
|
158
|
+
if (result.revocationRegistryDefinition && registry.allowsCaching && persistInCache) await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.set(agentContext, cacheKey, result, cacheDurationInSeconds);
|
|
159
|
+
return {
|
|
160
|
+
...result,
|
|
161
|
+
resolutionMetadata: { servedFromCache: result.resolutionMetadata.servedFromCache ?? false }
|
|
162
|
+
};
|
|
163
|
+
} catch (error) {
|
|
164
|
+
failedReturnBase.resolutionMetadata.message = `Unable to resolve revocation registry definition ${revocationRegistryDefinitionId}: ${error.message}`;
|
|
165
|
+
return failedReturnBase;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async getRevocationStatusList(agentContext, revocationRegistryDefinitionId, timestamp, options = {}) {
|
|
169
|
+
const failedReturnBase = {
|
|
170
|
+
resolutionMetadata: {
|
|
171
|
+
error: "error",
|
|
172
|
+
message: `Unable to resolve revocation status list for revocation registry ${revocationRegistryDefinitionId}`
|
|
173
|
+
},
|
|
174
|
+
revocationStatusListMetadata: {}
|
|
175
|
+
};
|
|
176
|
+
const registry = this.findRegistryForIdentifier(agentContext, revocationRegistryDefinitionId);
|
|
177
|
+
if (!registry) {
|
|
178
|
+
failedReturnBase.resolutionMetadata.error = "unsupportedAnonCredsMethod";
|
|
179
|
+
failedReturnBase.resolutionMetadata.message = `Unable to resolve revocation status list for revocation registry ${revocationRegistryDefinitionId}: No registry found for identifier ${revocationRegistryDefinitionId}`;
|
|
180
|
+
return failedReturnBase;
|
|
181
|
+
}
|
|
182
|
+
const { useCache = true, cacheDurationInSeconds = 300, persistInCache = true } = options;
|
|
183
|
+
const cacheKey = this.getCacheKey("revocationStatusList", `${revocationRegistryDefinitionId}:${timestamp}`);
|
|
184
|
+
if (registry.allowsCaching && useCache) {
|
|
185
|
+
const cachedRevocationStatusList = await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.get(agentContext, cacheKey);
|
|
186
|
+
if (cachedRevocationStatusList) return {
|
|
187
|
+
...cachedRevocationStatusList,
|
|
188
|
+
resolutionMetadata: {
|
|
189
|
+
...cachedRevocationStatusList.resolutionMetadata,
|
|
190
|
+
servedFromCache: true
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
const result = await registry.getRevocationStatusList(agentContext, revocationRegistryDefinitionId, timestamp);
|
|
196
|
+
if (result.revocationStatusList && registry.allowsCaching && persistInCache) await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.set(agentContext, cacheKey, result, cacheDurationInSeconds);
|
|
197
|
+
return {
|
|
198
|
+
...result,
|
|
199
|
+
resolutionMetadata: { servedFromCache: result.resolutionMetadata.servedFromCache ?? false }
|
|
200
|
+
};
|
|
201
|
+
} catch (error) {
|
|
202
|
+
failedReturnBase.resolutionMetadata.message = `Unable to resolve revocation status list for revocation registry ${revocationRegistryDefinitionId}: ${error.message}`;
|
|
203
|
+
return failedReturnBase;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
9
206
|
getRegistryForIdentifier(agentContext, identifier) {
|
|
10
207
|
const registry = agentContext.dependencyManager.resolve(AnonCredsModuleConfig).registries.find((registry$1) => registry$1.supportedIdentifier.test(identifier));
|
|
11
208
|
if (!registry) throw new AnonCredsError(`No AnonCredsRegistry registered for identifier '${identifier}'`);
|
|
12
209
|
return registry;
|
|
13
210
|
}
|
|
211
|
+
findRegistryForIdentifier(agentContext, identifier) {
|
|
212
|
+
try {
|
|
213
|
+
return this.getRegistryForIdentifier(agentContext, identifier);
|
|
214
|
+
} catch {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
getCacheKey(resourceType, identifier) {
|
|
219
|
+
return `anoncreds:resolver:${resourceType}:${identifier}`;
|
|
220
|
+
}
|
|
14
221
|
};
|
|
15
222
|
AnonCredsRegistryService = __decorate([injectable()], AnonCredsRegistryService);
|
|
16
223
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnonCredsRegistryService.mjs","names":["AnonCredsRegistryService","registry"],"sources":["../../../src/services/registry/AnonCredsRegistryService.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport { injectable } from '@credo-ts/core'\nimport { AnonCredsModuleConfig } from '../../AnonCredsModuleConfig'\nimport { AnonCredsError } from '../../error'\nimport type { AnonCredsRegistry } from '.'\n\n/**\n * @internal\n * The AnonCreds registry service manages multiple {@link AnonCredsRegistry} instances\n * and returns the correct registry based on a given identifier\n */\n@injectable()\nexport class AnonCredsRegistryService {\n public getRegistryForIdentifier(agentContext: AgentContext, identifier: string): AnonCredsRegistry {\n const registries = agentContext.dependencyManager.resolve(AnonCredsModuleConfig).registries\n\n // TODO: should we check if multiple are registered?\n const registry = registries.find((registry) => registry.supportedIdentifier.test(identifier))\n\n if (!registry) {\n throw new AnonCredsError(`No AnonCredsRegistry registered for identifier '${identifier}'`)\n }\n\n return registry\n }\n}\n"],"mappings":";;;;;;;AAYO,qCAAMA,2BAAyB;CACpC,AAAO,yBAAyB,cAA4B,YAAuC;EAIjG,MAAM,WAHa,aAAa,kBAAkB,QAAQ,sBAAsB,CAAC,WAGrD,MAAM,eAAaC,WAAS,oBAAoB,KAAK,WAAW,CAAC;AAE7F,MAAI,CAAC,SACH,OAAM,IAAI,eAAe,mDAAmD,WAAW,GAAG;AAG5F,SAAO;;;uCAZV,YAAY"}
|
|
1
|
+
{"version":3,"file":"AnonCredsRegistryService.mjs","names":["AnonCredsRegistryService","registry"],"sources":["../../../src/services/registry/AnonCredsRegistryService.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport { CacheModuleConfig, injectable } from '@credo-ts/core'\nimport { AnonCredsModuleConfig } from '../../AnonCredsModuleConfig'\nimport { AnonCredsError } from '../../error'\nimport {\n AnonCredsCredentialDefinitionRepository,\n AnonCredsRevocationRegistryDefinitionRepository,\n AnonCredsSchemaRepository,\n} from '../../repository'\nimport { AnonCredsCredentialDefinitionRecordMetadataKeys } from '../../repository/anonCredsCredentialDefinitionRecordMetadataTypes'\nimport { AnonCredsRevocationRegistryDefinitionRecordMetadataKeys } from '../../repository/anonCredsRevocationRegistryDefinitionRecordMetadataTypes'\nimport type { AnonCredsRegistry } from './AnonCredsRegistry'\nimport type { AnonCredsResolutionOptions, Extensible } from './base'\nimport type { GetCredentialDefinitionReturn } from './CredentialDefinitionOptions'\nimport type { GetRevocationRegistryDefinitionReturn } from './RevocationRegistryDefinitionOptions'\nimport type { GetRevocationStatusListReturn } from './RevocationStatusListOptions'\nimport type { GetSchemaReturn } from './SchemaOptions'\n\n/**\n * @internal\n * The AnonCreds registry service manages multiple {@link AnonCredsRegistry} instances\n * and returns the correct registry based on a given identifier\n */\n@injectable()\nexport class AnonCredsRegistryService {\n public async getSchema(\n agentContext: AgentContext,\n schemaId: string,\n options: AnonCredsResolutionOptions = {}\n ): Promise<GetSchemaReturn> {\n const failedReturnBase = {\n resolutionMetadata: {\n error: 'error',\n message: `Unable to resolve schema ${schemaId}`,\n },\n schemaId,\n schemaMetadata: {},\n }\n\n const registry = this.findRegistryForIdentifier(agentContext, schemaId)\n if (!registry) {\n failedReturnBase.resolutionMetadata.error = 'unsupportedAnonCredsMethod'\n failedReturnBase.resolutionMetadata.message = `Unable to resolve schema ${schemaId}: No registry found for identifier ${schemaId}`\n return failedReturnBase\n }\n\n // extract caching options and set defaults\n const { useCache = true, cacheDurationInSeconds = 300, persistInCache = true, useLocalRecord = true } = options\n const cacheKey = this.getCacheKey('schema', schemaId)\n\n if (registry.allowsCaching && useCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n\n // FIXME: in multi-tenancy it can be that the same cache is used for different agent contexts\n // This may become a problem when resolving schemas, as you can get back a cache hit for a different\n // tenant. We should just recommend disabling caching where the results are tenant specific\n // We could allow providing a custom cache prefix in the resolver options, so that the cache key\n // can be recognized in the cache implementation\n const cachedSchema = await cache.get<GetSchemaReturn>(agentContext, cacheKey)\n\n if (cachedSchema) {\n return {\n ...cachedSchema,\n resolutionMetadata: {\n ...cachedSchema.resolutionMetadata,\n servedFromCache: true,\n },\n }\n }\n }\n\n if (registry.allowsLocalRecord && useLocalRecord) {\n const anonCredsSchemaRepository = agentContext.resolve(AnonCredsSchemaRepository)\n const schemaRecord = await anonCredsSchemaRepository.findSingleByQuery(agentContext, {\n schemaId,\n })\n\n if (schemaRecord) {\n return {\n schemaId,\n schema: schemaRecord.schema,\n schemaMetadata: {},\n resolutionMetadata: {\n servedFromCache: false,\n servedFromRecord: true,\n },\n }\n }\n }\n\n try {\n const result = await registry.getSchema(agentContext, schemaId)\n\n if (result.schema && registry.allowsCaching && persistInCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n await cache.set(\n agentContext,\n cacheKey,\n result,\n // Set cache duration\n cacheDurationInSeconds\n )\n }\n\n return {\n ...result,\n resolutionMetadata: {\n servedFromCache: result.resolutionMetadata.servedFromCache ?? false,\n },\n }\n } catch (error) {\n failedReturnBase.resolutionMetadata.message = `Unable to resolve schema ${schemaId}: ${error.message}`\n return failedReturnBase\n }\n }\n\n public async getCredentialDefinition(\n agentContext: AgentContext,\n credentialDefinitionId: string,\n options: AnonCredsResolutionOptions = {}\n ): Promise<GetCredentialDefinitionReturn> {\n const failedReturnBase = {\n resolutionMetadata: {\n error: 'error',\n message: `Unable to resolve credential definition ${credentialDefinitionId}`,\n },\n credentialDefinitionId,\n credentialDefinitionMetadata: {},\n }\n\n const registry = this.findRegistryForIdentifier(agentContext, credentialDefinitionId)\n if (!registry) {\n failedReturnBase.resolutionMetadata.error = 'unsupportedAnonCredsMethod'\n failedReturnBase.resolutionMetadata.message = `Unable to resolve credential definition ${credentialDefinitionId}: No registry found for identifier ${credentialDefinitionId}`\n return failedReturnBase\n }\n\n // extract caching options and set defaults\n const { useCache = true, cacheDurationInSeconds = 300, persistInCache = true, useLocalRecord = true } = options\n const cacheKey = this.getCacheKey('credentialDefinition', credentialDefinitionId)\n\n if (registry.allowsCaching && useCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n\n // FIXME: in multi-tenancy it can be that the same cache is used for different agent contexts\n // This may become a problem when resolving schemas, as you can get back a cache hit for a different\n // tenant. We should just recommend disabling caching where the results are tenant specific\n // We could allow providing a custom cache prefix in the resolver options, so that the cache key\n // can be recognized in the cache implementation\n const cachedCredentialDefinition = await cache.get<GetCredentialDefinitionReturn>(agentContext, cacheKey)\n\n if (cachedCredentialDefinition) {\n return {\n ...cachedCredentialDefinition,\n resolutionMetadata: {\n ...cachedCredentialDefinition.resolutionMetadata,\n servedFromCache: true,\n },\n }\n }\n }\n\n if (registry.allowsLocalRecord && useLocalRecord) {\n const anonCredsCredentialDefinitionRepository = agentContext.resolve(AnonCredsCredentialDefinitionRepository)\n const credentialDefinitionRecord = await anonCredsCredentialDefinitionRepository.findSingleByQuery(agentContext, {\n credentialDefinitionId,\n })\n\n if (credentialDefinitionRecord) {\n return {\n credentialDefinitionId,\n credentialDefinition: credentialDefinitionRecord.credentialDefinition,\n credentialDefinitionMetadata:\n credentialDefinitionRecord.metadata.get(\n AnonCredsCredentialDefinitionRecordMetadataKeys.CredentialDefinitionMetadata\n ) ?? {},\n resolutionMetadata: {\n servedFromCache: false,\n servedFromRecord: true,\n },\n }\n }\n }\n\n try {\n const result = await registry.getCredentialDefinition(agentContext, credentialDefinitionId)\n\n if (result.credentialDefinition && registry.allowsCaching && persistInCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n await cache.set(\n agentContext,\n cacheKey,\n result,\n // Set cache duration\n cacheDurationInSeconds\n )\n }\n\n return {\n ...result,\n resolutionMetadata: {\n servedFromCache: result.resolutionMetadata.servedFromCache ?? false,\n },\n }\n } catch (error) {\n failedReturnBase.resolutionMetadata.message = `Unable to resolve credential definition ${credentialDefinitionId}: ${error.message}`\n return failedReturnBase\n }\n }\n\n public async getRevocationRegistryDefinition(\n agentContext: AgentContext,\n revocationRegistryDefinitionId: string,\n options: AnonCredsResolutionOptions = {}\n ): Promise<GetRevocationRegistryDefinitionReturn> {\n const failedReturnBase = {\n resolutionMetadata: {\n error: 'error',\n message: `Unable to resolve revocation registry ${revocationRegistryDefinitionId}`,\n },\n revocationRegistryDefinitionId,\n revocationRegistryDefinitionMetadata: {},\n }\n\n const registry = this.findRegistryForIdentifier(agentContext, revocationRegistryDefinitionId)\n if (!registry) {\n failedReturnBase.resolutionMetadata.error = 'unsupportedAnonCredsMethod'\n failedReturnBase.resolutionMetadata.message = `Unable to resolve revocation registry ${revocationRegistryDefinitionId}: No registry found for identifier ${revocationRegistryDefinitionId}`\n return failedReturnBase\n }\n\n // extract caching options and set defaults\n const { useCache = true, cacheDurationInSeconds = 300, persistInCache = true, useLocalRecord = true } = options\n const cacheKey = this.getCacheKey('revocationRegistryDefinition', revocationRegistryDefinitionId)\n\n if (registry.allowsCaching && useCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n\n // FIXME: in multi-tenancy it can be that the same cache is used for different agent contexts\n // This may become a problem when resolving schemas, as you can get back a cache hit for a different\n // tenant. We should just recommend disabling caching where the results are tenant specific\n // We could allow providing a custom cache prefix in the resolver options, so that the cache key\n // can be recognized in the cache implementation\n const cachedRevocationRegistryDefinition = await cache.get<GetRevocationRegistryDefinitionReturn>(\n agentContext,\n cacheKey\n )\n\n if (cachedRevocationRegistryDefinition) {\n return {\n ...cachedRevocationRegistryDefinition,\n resolutionMetadata: {\n ...cachedRevocationRegistryDefinition.resolutionMetadata,\n servedFromCache: true,\n },\n }\n }\n }\n\n if (registry.allowsLocalRecord && useLocalRecord) {\n const anoncredsRevocationRegistryDefinitionRepository = agentContext.resolve(\n AnonCredsRevocationRegistryDefinitionRepository\n )\n const anoncredsRevocationRegistryDefinitionRecord =\n await anoncredsRevocationRegistryDefinitionRepository.findSingleByQuery(agentContext, {\n revocationRegistryDefinitionId,\n })\n\n if (anoncredsRevocationRegistryDefinitionRecord) {\n return {\n revocationRegistryDefinitionId,\n revocationRegistryDefinition: anoncredsRevocationRegistryDefinitionRecord.revocationRegistryDefinition,\n revocationRegistryDefinitionMetadata:\n anoncredsRevocationRegistryDefinitionRecord.metadata.get<Extensible>(\n AnonCredsRevocationRegistryDefinitionRecordMetadataKeys.RevocationRegistryDefinitionMetadata\n ) ?? {},\n resolutionMetadata: {\n servedFromCache: false,\n servedFromRecord: true,\n },\n }\n }\n }\n\n try {\n const result = await registry.getRevocationRegistryDefinition(agentContext, revocationRegistryDefinitionId)\n\n if (result.revocationRegistryDefinition && registry.allowsCaching && persistInCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n await cache.set(\n agentContext,\n cacheKey,\n result,\n // Set cache duration\n cacheDurationInSeconds\n )\n }\n\n return {\n ...result,\n resolutionMetadata: {\n servedFromCache: result.resolutionMetadata.servedFromCache ?? false,\n },\n }\n } catch (error) {\n failedReturnBase.resolutionMetadata.message = `Unable to resolve revocation registry definition ${revocationRegistryDefinitionId}: ${error.message}`\n return failedReturnBase\n }\n }\n\n public async getRevocationStatusList(\n agentContext: AgentContext,\n revocationRegistryDefinitionId: string,\n timestamp: number,\n // No record for status list\n options: Omit<AnonCredsResolutionOptions, 'useLocalRecord'> = {}\n ): Promise<GetRevocationStatusListReturn> {\n const failedReturnBase = {\n resolutionMetadata: {\n error: 'error',\n message: `Unable to resolve revocation status list for revocation registry ${revocationRegistryDefinitionId}`,\n },\n revocationStatusListMetadata: {},\n }\n\n const registry = this.findRegistryForIdentifier(agentContext, revocationRegistryDefinitionId)\n if (!registry) {\n failedReturnBase.resolutionMetadata.error = 'unsupportedAnonCredsMethod'\n failedReturnBase.resolutionMetadata.message = `Unable to resolve revocation status list for revocation registry ${revocationRegistryDefinitionId}: No registry found for identifier ${revocationRegistryDefinitionId}`\n return failedReturnBase\n }\n\n // extract caching options and set defaults\n const { useCache = true, cacheDurationInSeconds = 300, persistInCache = true } = options\n const cacheKey = this.getCacheKey('revocationStatusList', `${revocationRegistryDefinitionId}:${timestamp}`)\n\n if (registry.allowsCaching && useCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n\n // FIXME: in multi-tenancy it can be that the same cache is used for different agent contexts\n // This may become a problem when resolving schemas, as you can get back a cache hit for a different\n // tenant. We should just recommend disabling caching where the results are tenant specific\n // We could allow providing a custom cache prefix in the resolver options, so that the cache key\n // can be recognized in the cache implementation\n const cachedRevocationStatusList = await cache.get<GetRevocationStatusListReturn>(agentContext, cacheKey)\n\n if (cachedRevocationStatusList) {\n return {\n ...cachedRevocationStatusList,\n resolutionMetadata: {\n ...cachedRevocationStatusList.resolutionMetadata,\n servedFromCache: true,\n },\n }\n }\n }\n\n try {\n const result = await registry.getRevocationStatusList(agentContext, revocationRegistryDefinitionId, timestamp)\n\n if (result.revocationStatusList && registry.allowsCaching && persistInCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n await cache.set(\n agentContext,\n cacheKey,\n result,\n // Set cache duration\n cacheDurationInSeconds\n )\n }\n\n return {\n ...result,\n resolutionMetadata: {\n servedFromCache: result.resolutionMetadata.servedFromCache ?? false,\n },\n }\n } catch (error) {\n failedReturnBase.resolutionMetadata.message = `Unable to resolve revocation status list for revocation registry ${revocationRegistryDefinitionId}: ${error.message}`\n return failedReturnBase\n }\n }\n\n public getRegistryForIdentifier(agentContext: AgentContext, identifier: string): AnonCredsRegistry {\n const registries = agentContext.dependencyManager.resolve(AnonCredsModuleConfig).registries\n\n // TODO: should we check if multiple are registered?\n const registry = registries.find((registry) => registry.supportedIdentifier.test(identifier))\n\n if (!registry) {\n throw new AnonCredsError(`No AnonCredsRegistry registered for identifier '${identifier}'`)\n }\n\n return registry\n }\n\n private findRegistryForIdentifier(agentContext: AgentContext, identifier: string) {\n try {\n return this.getRegistryForIdentifier(agentContext, identifier)\n } catch {\n return null\n }\n }\n\n private getCacheKey(\n resourceType: 'schema' | 'credentialDefinition' | 'revocationRegistryDefinition' | 'revocationStatusList',\n identifier: string\n ) {\n return `anoncreds:resolver:${resourceType}:${identifier}`\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAwBO,qCAAMA,2BAAyB;CACpC,MAAa,UACX,cACA,UACA,UAAsC,EAAE,EACd;EAC1B,MAAM,mBAAmB;GACvB,oBAAoB;IAClB,OAAO;IACP,SAAS,4BAA4B;IACtC;GACD;GACA,gBAAgB,EAAE;GACnB;EAED,MAAM,WAAW,KAAK,0BAA0B,cAAc,SAAS;AACvE,MAAI,CAAC,UAAU;AACb,oBAAiB,mBAAmB,QAAQ;AAC5C,oBAAiB,mBAAmB,UAAU,4BAA4B,SAAS,qCAAqC;AACxH,UAAO;;EAIT,MAAM,EAAE,WAAW,MAAM,yBAAyB,KAAK,iBAAiB,MAAM,iBAAiB,SAAS;EACxG,MAAM,WAAW,KAAK,YAAY,UAAU,SAAS;AAErD,MAAI,SAAS,iBAAiB,UAAU;GAQtC,MAAM,eAAe,MAPP,aAAa,kBAAkB,QAAQ,kBAAkB,CAAC,MAOvC,IAAqB,cAAc,SAAS;AAE7E,OAAI,aACF,QAAO;IACL,GAAG;IACH,oBAAoB;KAClB,GAAG,aAAa;KAChB,iBAAiB;KAClB;IACF;;AAIL,MAAI,SAAS,qBAAqB,gBAAgB;GAEhD,MAAM,eAAe,MADa,aAAa,QAAQ,0BAA0B,CAC5B,kBAAkB,cAAc,EACnF,UACD,CAAC;AAEF,OAAI,aACF,QAAO;IACL;IACA,QAAQ,aAAa;IACrB,gBAAgB,EAAE;IAClB,oBAAoB;KAClB,iBAAiB;KACjB,kBAAkB;KACnB;IACF;;AAIL,MAAI;GACF,MAAM,SAAS,MAAM,SAAS,UAAU,cAAc,SAAS;AAE/D,OAAI,OAAO,UAAU,SAAS,iBAAiB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A,UACA,QAEA,uBACD;AAGH,UAAO;IACL,GAAG;IACH,oBAAoB,EAClB,iBAAiB,OAAO,mBAAmB,mBAAmB,OAC/D;IACF;WACM,OAAO;AACd,oBAAiB,mBAAmB,UAAU,oEAAoE,+BAA+B,IAAI,MAAM;AAC3J,UAAO;;;CAIX,AAAO,yBAAyB,cAA4B,YAAuC;EAIjG,MAAM,WAHa,aAAa,kBAAkB,QAAQ,sBAAsB,CAAC,WAGrD,MAAM,eAAaC,WAAS,oBAAoB,KAAK,WAAW,CAAC;AAE7F,MAAI,CAAC,SACH,OAAM,IAAI,eAAe,mDAAmD,WAAW,GAAG;AAG5F,SAAO;;CAGT,AAAQ,0BAA0B,cAA4B,YAAoB;AAChF,MAAI;AACF,UAAO,KAAK,yBAAyB,cAAc,WAAW;UACxD;AACN,UAAO;;;CAIX,AAAQ,YACN,cACA,YACA;AACA,SAAO,sBAAsB,aAAa,GAAG;;;uCAjYhD,YAAY"}
|
|
@@ -17,7 +17,49 @@ interface AnonCredsOperationStateFailed {
|
|
|
17
17
|
interface AnonCredsResolutionMetadata extends Extensible {
|
|
18
18
|
error?: 'invalid' | 'notFound' | 'unsupportedAnonCredsMethod' | string;
|
|
19
19
|
message?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the anoncreds object was served from the cache
|
|
22
|
+
*/
|
|
23
|
+
servedFromCache?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the anoncreds object was served from a local record
|
|
26
|
+
*/
|
|
27
|
+
servedFromRecord?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface AnonCredsResolutionOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Whether to resolve the anoncreds object from the cache.
|
|
32
|
+
*
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
useCache?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to resolve the anoncreds object from a local created anoncreds object in a record.
|
|
38
|
+
* Cache has precedence over local records, as they're often faster. Objects
|
|
39
|
+
* served from will not be added to the cache.
|
|
40
|
+
*
|
|
41
|
+
* The resolver must have enabled `allowsLocalRecord` (default false) to use this
|
|
42
|
+
* feature.
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
useLocalRecord?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to persist the anoncreds object in the cache.
|
|
49
|
+
*
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
persistInCache?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* How many seconds to persist the resolved object.
|
|
55
|
+
*
|
|
56
|
+
* This may be overwritten with a shorter time based on the specific anoncreds object
|
|
57
|
+
* e.g. a status list that decides it should only be cached for up to 1 minute
|
|
58
|
+
*
|
|
59
|
+
* @default 300
|
|
60
|
+
*/
|
|
61
|
+
cacheDurationInSeconds?: number;
|
|
20
62
|
}
|
|
21
63
|
//#endregion
|
|
22
|
-
export { AnonCredsOperationStateAction, AnonCredsOperationStateFailed, AnonCredsOperationStateFinished, AnonCredsOperationStateWait, AnonCredsResolutionMetadata, Extensible };
|
|
64
|
+
export { AnonCredsOperationStateAction, AnonCredsOperationStateFailed, AnonCredsOperationStateFinished, AnonCredsOperationStateWait, AnonCredsResolutionMetadata, AnonCredsResolutionOptions, Extensible };
|
|
23
65
|
//# sourceMappingURL=base.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.mts","names":[],"sources":["../../../src/services/registry/base.ts"],"sourcesContent":[],"mappings":";KAAY,UAAA,GAAa;AAAb,UAEK,2BAAA,CAFc;EAEd,KAAA,EAAA,MAAA;AAIjB;AAKiB,UALA,6BAAA,CAK+B;EAI/B,KAAA,EAAA,QAAA;EAKA,MAAA,EAAA,MAAA
|
|
1
|
+
{"version":3,"file":"base.d.mts","names":[],"sources":["../../../src/services/registry/base.ts"],"sourcesContent":[],"mappings":";KAAY,UAAA,GAAa;AAAb,UAEK,2BAAA,CAFc;EAEd,KAAA,EAAA,MAAA;AAIjB;AAKiB,UALA,6BAAA,CAK+B;EAI/B,KAAA,EAAA,QAAA;EAKA,MAAA,EAAA,MAAA;AAejB;UAxBiB,+BAAA;;;UAIA,6BAAA;;;;UAKA,2BAAA,SAAoC;;;;;;;;;;;;UAepC,0BAAA"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
".": "./build/index.mjs",
|
|
5
5
|
"./package.json": "./package.json"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.6.0
|
|
7
|
+
"version": "0.6.0",
|
|
8
8
|
"files": [
|
|
9
9
|
"build"
|
|
10
10
|
],
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"@astronautlabs/jsonpath": "^1.1.2",
|
|
23
23
|
"@sphereon/pex-models": "^2.3.2",
|
|
24
24
|
"class-transformer": "0.5.1",
|
|
25
|
-
"class-validator": "0.14.1",
|
|
25
|
+
"class-validator": "^0.14.1",
|
|
26
26
|
"reflect-metadata": "0.2.2",
|
|
27
|
-
"@credo-ts/core": "0.6.0
|
|
28
|
-
"@credo-ts/didcomm": "0.6.0
|
|
27
|
+
"@credo-ts/core": "0.6.0",
|
|
28
|
+
"@credo-ts/didcomm": "0.6.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@hyperledger/anoncreds-nodejs": "^0.3.4",
|
|
32
32
|
"@hyperledger/anoncreds-shared": "^0.3.4",
|
|
33
33
|
"rxjs": "^7.8.2",
|
|
34
34
|
"typescript": "~5.9.3",
|
|
35
|
-
"@credo-ts/node": "0.6.0
|
|
35
|
+
"@credo-ts/node": "0.6.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@hyperledger/anoncreds-shared": "^0.3.4"
|