@credo-ts/indy-vdr 0.6.1-pr-2091-20241119140918 → 0.6.2-alpha-20251210145840
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 +42 -0
- package/build/IndyVdrApi.d.mts.map +1 -0
- package/build/IndyVdrApi.mjs +72 -0
- package/build/IndyVdrApi.mjs.map +1 -0
- package/build/IndyVdrModule.d.mts +20 -0
- package/build/IndyVdrModule.d.mts.map +1 -0
- package/build/IndyVdrModule.mjs +30 -0
- package/build/IndyVdrModule.mjs.map +1 -0
- package/build/IndyVdrModuleConfig.d.mts +72 -0
- package/build/IndyVdrModuleConfig.d.mts.map +1 -0
- package/build/IndyVdrModuleConfig.mjs +18 -0
- package/build/IndyVdrModuleConfig.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs +10 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateMetadata.mjs +7 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateParam.mjs +9 -0
- package/build/anoncreds/IndyVdrAnonCredsRegistry.d.mts +125 -0
- package/build/anoncreds/IndyVdrAnonCredsRegistry.d.mts.map +1 -0
- package/build/anoncreds/IndyVdrAnonCredsRegistry.mjs +586 -0
- package/build/anoncreds/IndyVdrAnonCredsRegistry.mjs.map +1 -0
- package/build/anoncreds/index.d.mts +1 -0
- package/build/anoncreds/index.mjs +1 -0
- package/build/anoncreds/utils/identifiers.mjs +29 -0
- package/build/anoncreds/utils/identifiers.mjs.map +1 -0
- package/build/anoncreds/utils/transform.mjs +63 -0
- package/build/anoncreds/utils/transform.mjs.map +1 -0
- package/build/dids/IndyVdrIndyDidRegistrar.d.mts +92 -0
- package/build/dids/IndyVdrIndyDidRegistrar.d.mts.map +1 -0
- package/build/dids/IndyVdrIndyDidRegistrar.mjs +290 -0
- package/build/dids/IndyVdrIndyDidRegistrar.mjs.map +1 -0
- package/build/dids/IndyVdrIndyDidResolver.d.mts +12 -0
- package/build/dids/IndyVdrIndyDidResolver.d.mts.map +1 -0
- package/build/dids/IndyVdrIndyDidResolver.mjs +36 -0
- package/build/dids/IndyVdrIndyDidResolver.mjs.map +1 -0
- package/build/dids/IndyVdrSovDidResolver.d.mts +13 -0
- package/build/dids/IndyVdrSovDidResolver.d.mts.map +1 -0
- package/build/dids/IndyVdrSovDidResolver.mjs +70 -0
- package/build/dids/IndyVdrSovDidResolver.mjs.map +1 -0
- package/build/dids/didIndyUtil.mjs +147 -0
- package/build/dids/didIndyUtil.mjs.map +1 -0
- package/build/dids/didSovUtil.mjs +118 -0
- package/build/dids/didSovUtil.mjs.map +1 -0
- package/build/dids/index.d.mts +3 -0
- package/build/dids/index.mjs +3 -0
- package/build/error/IndyVdrError.mjs +12 -0
- package/build/error/IndyVdrError.mjs.map +1 -0
- package/build/error/IndyVdrNotConfiguredError.mjs +12 -0
- package/build/error/IndyVdrNotConfiguredError.mjs.map +1 -0
- package/build/error/IndyVdrNotFound.mjs +12 -0
- package/build/error/IndyVdrNotFound.mjs.map +1 -0
- package/build/error/index.mjs +3 -0
- package/build/index.d.mts +12 -0
- package/build/index.mjs +12 -0
- package/build/pool/IndyVdrPool.d.mts +61 -0
- package/build/pool/IndyVdrPool.d.mts.map +1 -0
- package/build/pool/IndyVdrPool.mjs +104 -0
- package/build/pool/IndyVdrPool.mjs.map +1 -0
- package/build/pool/IndyVdrPoolService.d.mts +54 -0
- package/build/pool/IndyVdrPoolService.d.mts.map +1 -0
- package/build/pool/IndyVdrPoolService.mjs +157 -0
- package/build/pool/IndyVdrPoolService.mjs.map +1 -0
- package/build/pool/index.d.mts +2 -0
- package/build/pool/index.mjs +2 -0
- package/build/utils/did.mjs +48 -0
- package/build/utils/did.mjs.map +1 -0
- package/build/utils/promises.mjs +20 -0
- package/build/utils/promises.mjs.map +1 -0
- package/build/utils/sign.mjs +24 -0
- package/build/utils/sign.mjs.map +1 -0
- package/package.json +19 -19
- package/build/IndyVdrApi.d.ts +0 -34
- package/build/IndyVdrApi.js +0 -82
- package/build/IndyVdrApi.js.map +0 -1
- package/build/IndyVdrModule.d.ts +0 -14
- package/build/IndyVdrModule.js +0 -31
- package/build/IndyVdrModule.js.map +0 -1
- package/build/IndyVdrModuleConfig.d.ts +0 -66
- package/build/IndyVdrModuleConfig.js +0 -18
- package/build/IndyVdrModuleConfig.js.map +0 -1
- package/build/anoncreds/IndyVdrAnonCredsRegistry.d.ts +0 -113
- package/build/anoncreds/IndyVdrAnonCredsRegistry.js +0 -682
- package/build/anoncreds/IndyVdrAnonCredsRegistry.js.map +0 -1
- package/build/anoncreds/index.d.ts +0 -1
- package/build/anoncreds/index.js +0 -18
- package/build/anoncreds/index.js.map +0 -1
- package/build/anoncreds/utils/identifiers.d.ts +0 -5
- package/build/anoncreds/utils/identifiers.js +0 -40
- package/build/anoncreds/utils/identifiers.js.map +0 -1
- package/build/anoncreds/utils/transform.d.ts +0 -32
- package/build/anoncreds/utils/transform.js +0 -91
- package/build/anoncreds/utils/transform.js.map +0 -1
- package/build/dids/IndyVdrIndyDidRegistrar.d.ts +0 -85
- package/build/dids/IndyVdrIndyDidRegistrar.js +0 -338
- package/build/dids/IndyVdrIndyDidRegistrar.js.map +0 -1
- package/build/dids/IndyVdrIndyDidResolver.d.ts +0 -7
- package/build/dids/IndyVdrIndyDidResolver.js +0 -39
- package/build/dids/IndyVdrIndyDidResolver.js.map +0 -1
- package/build/dids/IndyVdrSovDidResolver.d.ts +0 -8
- package/build/dids/IndyVdrSovDidResolver.js +0 -79
- package/build/dids/IndyVdrSovDidResolver.js.map +0 -1
- package/build/dids/didIndyUtil.d.ts +0 -47
- package/build/dids/didIndyUtil.js +0 -241
- package/build/dids/didIndyUtil.js.map +0 -1
- package/build/dids/didSovUtil.d.ts +0 -26
- package/build/dids/didSovUtil.js +0 -180
- package/build/dids/didSovUtil.js.map +0 -1
- package/build/dids/index.d.ts +0 -3
- package/build/dids/index.js +0 -10
- package/build/dids/index.js.map +0 -1
- package/build/error/IndyVdrError.d.ts +0 -6
- package/build/error/IndyVdrError.js +0 -11
- package/build/error/IndyVdrError.js.map +0 -1
- package/build/error/IndyVdrNotConfiguredError.d.ts +0 -6
- package/build/error/IndyVdrNotConfiguredError.js +0 -11
- package/build/error/IndyVdrNotConfiguredError.js.map +0 -1
- package/build/error/IndyVdrNotFound.d.ts +0 -6
- package/build/error/IndyVdrNotFound.js +0 -11
- package/build/error/IndyVdrNotFound.js.map +0 -1
- package/build/error/index.d.ts +0 -3
- package/build/error/index.js +0 -20
- package/build/error/index.js.map +0 -1
- package/build/index.d.ts +0 -5
- package/build/index.js +0 -27
- package/build/index.js.map +0 -1
- package/build/pool/IndyVdrPool.d.ts +0 -54
- package/build/pool/IndyVdrPool.js +0 -131
- package/build/pool/IndyVdrPool.js.map +0 -1
- package/build/pool/IndyVdrPoolService.d.ts +0 -55
- package/build/pool/IndyVdrPoolService.js +0 -175
- package/build/pool/IndyVdrPoolService.js.map +0 -1
- package/build/pool/index.d.ts +0 -2
- package/build/pool/index.js +0 -19
- package/build/pool/index.js.map +0 -1
- package/build/utils/did.d.ts +0 -32
- package/build/utils/did.js +0 -57
- package/build/utils/did.js.map +0 -1
- package/build/utils/promises.d.ts +0 -11
- package/build/utils/promises.js +0 -26
- package/build/utils/promises.js.map +0 -1
- package/build/utils/sign.d.ts +0 -5
- package/build/utils/sign.js +0 -23
- package/build/utils/sign.js.map +0 -1
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
import { verificationPublicJwkForIndyDid } from "../dids/didIndyUtil.mjs";
|
|
2
|
+
import { IndyVdrPoolService } from "../pool/IndyVdrPoolService.mjs";
|
|
3
|
+
import "../pool/index.mjs";
|
|
4
|
+
import { multiSignRequest } from "../utils/sign.mjs";
|
|
5
|
+
import { getDidIndyCredentialDefinitionId, getDidIndyRevocationRegistryDefinitionId, getDidIndyRevocationRegistryEntryId, getDidIndySchemaId, indyVdrAnonCredsRegistryIdentifierRegex } from "./utils/identifiers.mjs";
|
|
6
|
+
import { anonCredsRevocationStatusListFromIndyVdr, indyVdrCreateLatestRevocationDelta } from "./utils/transform.mjs";
|
|
7
|
+
import { AnonCredsRegistryService, dateToTimestamp, getUnqualifiedCredentialDefinitionId, getUnqualifiedRevocationRegistryDefinitionId, getUnqualifiedSchemaId, parseIndyCredentialDefinitionId, parseIndyDid, parseIndyRevocationRegistryId, parseIndySchemaId } from "@credo-ts/anoncreds";
|
|
8
|
+
import { CredoError } from "@credo-ts/core";
|
|
9
|
+
import { CredentialDefinitionRequest, CustomRequest, GetCredentialDefinitionRequest, GetRevocationRegistryDefinitionRequest, GetRevocationRegistryDeltaRequest, GetSchemaRequest, GetTransactionRequest, RevocationRegistryDefinitionRequest, RevocationRegistryEntryRequest, SchemaRequest } from "@hyperledger/indy-vdr-shared";
|
|
10
|
+
|
|
11
|
+
//#region src/anoncreds/IndyVdrAnonCredsRegistry.ts
|
|
12
|
+
var IndyVdrAnonCredsRegistry = class {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.methodName = "indy";
|
|
15
|
+
this.supportedIdentifier = indyVdrAnonCredsRegistryIdentifierRegex;
|
|
16
|
+
this.allowsCaching = true;
|
|
17
|
+
this.allowsLocalRecord = true;
|
|
18
|
+
}
|
|
19
|
+
async getSchema(agentContext, schemaId) {
|
|
20
|
+
try {
|
|
21
|
+
const indyVdrPoolService = agentContext.dependencyManager.resolve(IndyVdrPoolService);
|
|
22
|
+
const { did, namespaceIdentifier, schemaName, schemaVersion } = parseIndySchemaId(schemaId);
|
|
23
|
+
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
24
|
+
agentContext.config.logger.debug(`Getting schema '${schemaId}' from ledger '${pool.indyNamespace}'`);
|
|
25
|
+
const request = new GetSchemaRequest({ schemaId: getUnqualifiedSchemaId(namespaceIdentifier, schemaName, schemaVersion) });
|
|
26
|
+
agentContext.config.logger.trace(`Submitting get schema request for schema '${schemaId}' to ledger '${pool.indyNamespace}'`);
|
|
27
|
+
const response = await pool.submitRequest(request);
|
|
28
|
+
agentContext.config.logger.trace(`Got un-parsed schema '${schemaId}' from ledger '${pool.indyNamespace}'`, { response });
|
|
29
|
+
if (!("attr_names" in response.result.data)) {
|
|
30
|
+
agentContext.config.logger.error(`Error retrieving schema '${schemaId}'`);
|
|
31
|
+
return {
|
|
32
|
+
schemaId,
|
|
33
|
+
resolutionMetadata: {
|
|
34
|
+
error: "notFound",
|
|
35
|
+
message: `unable to find schema with id ${schemaId}`
|
|
36
|
+
},
|
|
37
|
+
schemaMetadata: {}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
schema: {
|
|
42
|
+
attrNames: response.result.data.attr_names,
|
|
43
|
+
name: response.result.data.name,
|
|
44
|
+
version: response.result.data.version,
|
|
45
|
+
issuerId: did
|
|
46
|
+
},
|
|
47
|
+
schemaId,
|
|
48
|
+
resolutionMetadata: {},
|
|
49
|
+
schemaMetadata: {
|
|
50
|
+
didIndyNamespace: pool.indyNamespace,
|
|
51
|
+
indyLedgerSeqNo: response.result.seqNo
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
} catch (error) {
|
|
55
|
+
agentContext.config.logger.error(`Error retrieving schema '${schemaId}'`, {
|
|
56
|
+
error,
|
|
57
|
+
schemaId
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
schemaId,
|
|
61
|
+
resolutionMetadata: { error: "notFound" },
|
|
62
|
+
schemaMetadata: {}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async registerSchema(agentContext, options) {
|
|
67
|
+
const schema = options.schema;
|
|
68
|
+
const { issuerId, name, version, attrNames } = schema;
|
|
69
|
+
try {
|
|
70
|
+
const { namespaceIdentifier, namespace } = parseIndyDid(issuerId);
|
|
71
|
+
const { endorserDid, endorserMode } = options.options;
|
|
72
|
+
const pool = agentContext.dependencyManager.resolve(IndyVdrPoolService).getPoolForNamespace(namespace);
|
|
73
|
+
let writeRequest;
|
|
74
|
+
const didIndySchemaId = getDidIndySchemaId(namespace, namespaceIdentifier, schema.name, schema.version);
|
|
75
|
+
const endorsedTransaction = options.options.endorsedTransaction;
|
|
76
|
+
if (endorsedTransaction) {
|
|
77
|
+
agentContext.config.logger.debug(`Preparing endorsed tx '${endorsedTransaction}' for submission on ledger '${namespace}' with did '${issuerId}'`, schema);
|
|
78
|
+
writeRequest = new CustomRequest({ customRequest: endorsedTransaction });
|
|
79
|
+
} else {
|
|
80
|
+
agentContext.config.logger.debug(`Create schema tx on ledger '${namespace}' with did '${issuerId}'`, schema);
|
|
81
|
+
const schemaRequest = new SchemaRequest({
|
|
82
|
+
submitterDid: namespaceIdentifier,
|
|
83
|
+
schema: {
|
|
84
|
+
id: getUnqualifiedSchemaId(namespaceIdentifier, name, version),
|
|
85
|
+
name,
|
|
86
|
+
ver: "1.0",
|
|
87
|
+
version,
|
|
88
|
+
attrNames
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const submitterKey = await verificationPublicJwkForIndyDid(agentContext, issuerId);
|
|
92
|
+
writeRequest = await pool.prepareWriteRequest(agentContext, schemaRequest, submitterKey, endorserDid !== issuerId ? endorserDid : void 0);
|
|
93
|
+
if (endorserMode === "external") return {
|
|
94
|
+
jobId: didIndySchemaId,
|
|
95
|
+
schemaState: {
|
|
96
|
+
state: "action",
|
|
97
|
+
action: "endorseIndyTransaction",
|
|
98
|
+
schemaId: didIndySchemaId,
|
|
99
|
+
schema,
|
|
100
|
+
schemaRequest: writeRequest.body
|
|
101
|
+
},
|
|
102
|
+
registrationMetadata: {},
|
|
103
|
+
schemaMetadata: {}
|
|
104
|
+
};
|
|
105
|
+
if (endorserMode === "internal" && endorserDid !== issuerId) {
|
|
106
|
+
const endorserKey = await verificationPublicJwkForIndyDid(agentContext, endorserDid);
|
|
107
|
+
await multiSignRequest(agentContext, writeRequest, endorserKey, parseIndyDid(endorserDid).namespaceIdentifier);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const response = await pool.submitRequest(writeRequest);
|
|
111
|
+
agentContext.config.logger.debug(`Registered schema '${didIndySchemaId}' on ledger '${pool.indyNamespace}'`, {
|
|
112
|
+
response,
|
|
113
|
+
writeRequest
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
schemaState: {
|
|
117
|
+
state: "finished",
|
|
118
|
+
schema,
|
|
119
|
+
schemaId: didIndySchemaId
|
|
120
|
+
},
|
|
121
|
+
registrationMetadata: {},
|
|
122
|
+
schemaMetadata: { indyLedgerSeqNo: response?.result?.txnMetadata?.seqNo }
|
|
123
|
+
};
|
|
124
|
+
} catch (error) {
|
|
125
|
+
agentContext.config.logger.error(`Error registering schema for did '${issuerId}'`, {
|
|
126
|
+
error,
|
|
127
|
+
did: issuerId,
|
|
128
|
+
schema
|
|
129
|
+
});
|
|
130
|
+
return {
|
|
131
|
+
schemaMetadata: {},
|
|
132
|
+
registrationMetadata: {},
|
|
133
|
+
schemaState: {
|
|
134
|
+
state: "failed",
|
|
135
|
+
schema,
|
|
136
|
+
reason: `unknownError: ${error.message}`
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async getCredentialDefinition(agentContext, credentialDefinitionId) {
|
|
142
|
+
try {
|
|
143
|
+
const indyVdrPoolService = agentContext.dependencyManager.resolve(IndyVdrPoolService);
|
|
144
|
+
const { did, namespaceIdentifier, schemaSeqNo, tag } = parseIndyCredentialDefinitionId(credentialDefinitionId);
|
|
145
|
+
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
146
|
+
agentContext.config.logger.debug(`Getting credential definition '${credentialDefinitionId}' from ledger '${pool.indyNamespace}'`);
|
|
147
|
+
const request = new GetCredentialDefinitionRequest({ credentialDefinitionId: getUnqualifiedCredentialDefinitionId(namespaceIdentifier, schemaSeqNo, tag) });
|
|
148
|
+
agentContext.config.logger.trace(`Submitting get credential definition request for credential definition '${credentialDefinitionId}' to ledger '${pool.indyNamespace}'`);
|
|
149
|
+
const response = await pool.submitRequest(request);
|
|
150
|
+
const schema = await this.fetchIndySchemaWithSeqNo(agentContext, response.result.ref, namespaceIdentifier);
|
|
151
|
+
if (!schema || !response.result.data) {
|
|
152
|
+
agentContext.config.logger.error(`Error retrieving credential definition '${credentialDefinitionId}'`);
|
|
153
|
+
return {
|
|
154
|
+
credentialDefinitionId,
|
|
155
|
+
credentialDefinitionMetadata: {},
|
|
156
|
+
resolutionMetadata: {
|
|
157
|
+
error: "notFound",
|
|
158
|
+
message: `unable to resolve credential definition with id ${credentialDefinitionId}`
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
credentialDefinitionId,
|
|
164
|
+
credentialDefinition: {
|
|
165
|
+
issuerId: did,
|
|
166
|
+
schemaId: credentialDefinitionId.startsWith("did:indy") ? getDidIndySchemaId(pool.indyNamespace, schema.schema.issuerId, schema.schema.name, schema.schema.version) : schema.schema.schemaId,
|
|
167
|
+
tag: response.result.tag,
|
|
168
|
+
type: "CL",
|
|
169
|
+
value: response.result.data
|
|
170
|
+
},
|
|
171
|
+
credentialDefinitionMetadata: { didIndyNamespace: pool.indyNamespace },
|
|
172
|
+
resolutionMetadata: {}
|
|
173
|
+
};
|
|
174
|
+
} catch (error) {
|
|
175
|
+
agentContext.config.logger.error(`Error retrieving credential definition '${credentialDefinitionId}'`, {
|
|
176
|
+
error,
|
|
177
|
+
credentialDefinitionId
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
credentialDefinitionId,
|
|
181
|
+
credentialDefinitionMetadata: {},
|
|
182
|
+
resolutionMetadata: {
|
|
183
|
+
error: "notFound",
|
|
184
|
+
message: `unable to resolve credential definition: ${error.message}`
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async registerCredentialDefinition(agentContext, options) {
|
|
190
|
+
const credentialDefinition = options.credentialDefinition;
|
|
191
|
+
const { schemaId, issuerId, tag, value } = credentialDefinition;
|
|
192
|
+
try {
|
|
193
|
+
const { namespaceIdentifier, namespace } = parseIndyDid(issuerId);
|
|
194
|
+
const { endorserDid, endorserMode } = options.options;
|
|
195
|
+
const pool = agentContext.dependencyManager.resolve(IndyVdrPoolService).getPoolForNamespace(namespace);
|
|
196
|
+
agentContext.config.logger.debug(`Registering credential definition on ledger '${namespace}' with did '${issuerId}'`, options.credentialDefinition);
|
|
197
|
+
let writeRequest;
|
|
198
|
+
let didIndyCredentialDefinitionId;
|
|
199
|
+
let schemaSeqNo;
|
|
200
|
+
const endorsedTransaction = options.options.endorsedTransaction;
|
|
201
|
+
if (endorsedTransaction) {
|
|
202
|
+
agentContext.config.logger.debug(`Preparing endorsed tx '${endorsedTransaction}' for submission on ledger '${namespace}' with did '${issuerId}'`, credentialDefinition);
|
|
203
|
+
writeRequest = new CustomRequest({ customRequest: endorsedTransaction });
|
|
204
|
+
const operation = JSON.parse(endorsedTransaction)?.operation;
|
|
205
|
+
schemaSeqNo = Number(operation?.ref);
|
|
206
|
+
didIndyCredentialDefinitionId = getDidIndyCredentialDefinitionId(namespace, namespaceIdentifier, schemaSeqNo, tag);
|
|
207
|
+
} else {
|
|
208
|
+
const { schemaMetadata, resolutionMetadata } = await agentContext.resolve(AnonCredsRegistryService).getSchema(agentContext, schemaId, { useLocalRecord: false });
|
|
209
|
+
if (!schemaMetadata?.indyLedgerSeqNo || typeof schemaMetadata.indyLedgerSeqNo !== "number") return {
|
|
210
|
+
registrationMetadata: {},
|
|
211
|
+
credentialDefinitionMetadata: { didIndyNamespace: pool.indyNamespace },
|
|
212
|
+
credentialDefinitionState: {
|
|
213
|
+
credentialDefinition: options.credentialDefinition,
|
|
214
|
+
state: "failed",
|
|
215
|
+
reason: `error resolving schema with id ${schemaId}: ${resolutionMetadata.error} ${resolutionMetadata.message}`
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
schemaSeqNo = schemaMetadata.indyLedgerSeqNo;
|
|
219
|
+
const legacyCredentialDefinitionId = getUnqualifiedCredentialDefinitionId(issuerId, schemaSeqNo, tag);
|
|
220
|
+
didIndyCredentialDefinitionId = getDidIndyCredentialDefinitionId(namespace, namespaceIdentifier, schemaSeqNo, tag);
|
|
221
|
+
const credentialDefinitionRequest = new CredentialDefinitionRequest({
|
|
222
|
+
submitterDid: namespaceIdentifier,
|
|
223
|
+
credentialDefinition: {
|
|
224
|
+
ver: "1.0",
|
|
225
|
+
id: legacyCredentialDefinitionId,
|
|
226
|
+
schemaId: schemaSeqNo.toString(),
|
|
227
|
+
type: "CL",
|
|
228
|
+
tag,
|
|
229
|
+
value
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const submitterKey = await verificationPublicJwkForIndyDid(agentContext, issuerId);
|
|
233
|
+
writeRequest = await pool.prepareWriteRequest(agentContext, credentialDefinitionRequest, submitterKey, endorserDid !== issuerId ? endorserDid : void 0);
|
|
234
|
+
if (endorserMode === "external") return {
|
|
235
|
+
jobId: didIndyCredentialDefinitionId,
|
|
236
|
+
credentialDefinitionState: {
|
|
237
|
+
state: "action",
|
|
238
|
+
action: "endorseIndyTransaction",
|
|
239
|
+
credentialDefinition,
|
|
240
|
+
credentialDefinitionId: didIndyCredentialDefinitionId,
|
|
241
|
+
credentialDefinitionRequest: writeRequest.body
|
|
242
|
+
},
|
|
243
|
+
registrationMetadata: {},
|
|
244
|
+
credentialDefinitionMetadata: {}
|
|
245
|
+
};
|
|
246
|
+
if (endorserMode === "internal" && endorserDid !== issuerId) {
|
|
247
|
+
const endorserKey = await verificationPublicJwkForIndyDid(agentContext, endorserDid);
|
|
248
|
+
await multiSignRequest(agentContext, writeRequest, endorserKey, parseIndyDid(endorserDid).namespaceIdentifier);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const response = await pool.submitRequest(writeRequest);
|
|
252
|
+
agentContext.config.logger.debug(`Registered credential definition '${didIndyCredentialDefinitionId}' on ledger '${pool.indyNamespace}'`, {
|
|
253
|
+
response,
|
|
254
|
+
credentialDefinition: options.credentialDefinition
|
|
255
|
+
});
|
|
256
|
+
return {
|
|
257
|
+
credentialDefinitionMetadata: {},
|
|
258
|
+
credentialDefinitionState: {
|
|
259
|
+
credentialDefinition,
|
|
260
|
+
credentialDefinitionId: didIndyCredentialDefinitionId,
|
|
261
|
+
state: "finished"
|
|
262
|
+
},
|
|
263
|
+
registrationMetadata: {}
|
|
264
|
+
};
|
|
265
|
+
} catch (error) {
|
|
266
|
+
agentContext.config.logger.error(`Error registering credential definition for schema '${schemaId}'`, {
|
|
267
|
+
error,
|
|
268
|
+
did: issuerId,
|
|
269
|
+
credentialDefinition: options.credentialDefinition
|
|
270
|
+
});
|
|
271
|
+
return {
|
|
272
|
+
credentialDefinitionMetadata: {},
|
|
273
|
+
registrationMetadata: {},
|
|
274
|
+
credentialDefinitionState: {
|
|
275
|
+
credentialDefinition: options.credentialDefinition,
|
|
276
|
+
state: "failed",
|
|
277
|
+
reason: `unknownError: ${error.message}`
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async getRevocationRegistryDefinition(agentContext, revocationRegistryDefinitionId) {
|
|
283
|
+
try {
|
|
284
|
+
const indyVdrPoolService = agentContext.dependencyManager.resolve(IndyVdrPoolService);
|
|
285
|
+
const { did, namespaceIdentifier, credentialDefinitionTag, revocationRegistryTag, schemaSeqNo } = parseIndyRevocationRegistryId(revocationRegistryDefinitionId);
|
|
286
|
+
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
287
|
+
agentContext.config.logger.debug(`Using ledger '${pool.indyNamespace}' to retrieve revocation registry definition '${revocationRegistryDefinitionId}'`);
|
|
288
|
+
const request = new GetRevocationRegistryDefinitionRequest({ revocationRegistryId: getUnqualifiedRevocationRegistryDefinitionId(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag) });
|
|
289
|
+
agentContext.config.logger.trace(`Submitting get revocation registry definition request for revocation registry definition '${revocationRegistryDefinitionId}' to ledger`);
|
|
290
|
+
const response = await pool.submitRequest(request);
|
|
291
|
+
if (!response.result.data) {
|
|
292
|
+
agentContext.config.logger.error(`Error retrieving revocation registry definition '${revocationRegistryDefinitionId}' from ledger`, { revocationRegistryDefinitionId });
|
|
293
|
+
return {
|
|
294
|
+
resolutionMetadata: {
|
|
295
|
+
error: "notFound",
|
|
296
|
+
message: "unable to resolve revocation registry definition"
|
|
297
|
+
},
|
|
298
|
+
revocationRegistryDefinitionId,
|
|
299
|
+
revocationRegistryDefinitionMetadata: {}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
agentContext.config.logger.trace(`Got revocation registry definition '${revocationRegistryDefinitionId}' from ledger '${pool.indyNamespace}'`, { response });
|
|
303
|
+
const credentialDefinitionId = revocationRegistryDefinitionId.startsWith("did:indy:") ? getDidIndyCredentialDefinitionId(pool.indyNamespace, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag) : getUnqualifiedCredentialDefinitionId(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag);
|
|
304
|
+
return {
|
|
305
|
+
revocationRegistryDefinitionId,
|
|
306
|
+
revocationRegistryDefinition: {
|
|
307
|
+
issuerId: did,
|
|
308
|
+
revocDefType: response.result.data.revocDefType,
|
|
309
|
+
value: {
|
|
310
|
+
maxCredNum: response.result.data.value.maxCredNum,
|
|
311
|
+
tailsHash: response.result.data.value.tailsHash,
|
|
312
|
+
tailsLocation: response.result.data.value.tailsLocation,
|
|
313
|
+
publicKeys: { accumKey: { z: response.result.data.value.publicKeys.accumKey.z } }
|
|
314
|
+
},
|
|
315
|
+
tag: response.result.data.tag,
|
|
316
|
+
credDefId: credentialDefinitionId
|
|
317
|
+
},
|
|
318
|
+
revocationRegistryDefinitionMetadata: {
|
|
319
|
+
issuanceType: response.result.data.value.issuanceType,
|
|
320
|
+
didIndyNamespace: pool.indyNamespace
|
|
321
|
+
},
|
|
322
|
+
resolutionMetadata: {}
|
|
323
|
+
};
|
|
324
|
+
} catch (error) {
|
|
325
|
+
agentContext.config.logger.error(`Error retrieving revocation registry definition '${revocationRegistryDefinitionId}' from ledger`, {
|
|
326
|
+
error,
|
|
327
|
+
revocationRegistryDefinitionId
|
|
328
|
+
});
|
|
329
|
+
return {
|
|
330
|
+
resolutionMetadata: {
|
|
331
|
+
error: "notFound",
|
|
332
|
+
message: `unable to resolve revocation registry definition: ${error.message}`
|
|
333
|
+
},
|
|
334
|
+
revocationRegistryDefinitionId,
|
|
335
|
+
revocationRegistryDefinitionMetadata: {}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async registerRevocationRegistryDefinition(agentContext, { options, revocationRegistryDefinition }) {
|
|
340
|
+
try {
|
|
341
|
+
const { namespaceIdentifier, namespace } = parseIndyDid(revocationRegistryDefinition.issuerId);
|
|
342
|
+
const pool = agentContext.dependencyManager.resolve(IndyVdrPoolService).getPoolForNamespace(namespace);
|
|
343
|
+
agentContext.config.logger.debug(`Registering revocation registry definition on ledger '${namespace}' with did '${revocationRegistryDefinition.issuerId}'`, revocationRegistryDefinition);
|
|
344
|
+
let writeRequest;
|
|
345
|
+
let didIndyRevocationRegistryDefinitionId;
|
|
346
|
+
const { schemaSeqNo, tag: credentialDefinitionTag } = parseIndyCredentialDefinitionId(revocationRegistryDefinition.credDefId);
|
|
347
|
+
const { endorsedTransaction, endorserDid, endorserMode } = options;
|
|
348
|
+
if (endorsedTransaction) {
|
|
349
|
+
agentContext.config.logger.debug(`Preparing endorsed tx '${endorsedTransaction}' for submission on ledger '${namespace}' with did '${revocationRegistryDefinition.issuerId}'`, revocationRegistryDefinition);
|
|
350
|
+
writeRequest = new CustomRequest({ customRequest: endorsedTransaction });
|
|
351
|
+
didIndyRevocationRegistryDefinitionId = getDidIndyRevocationRegistryDefinitionId(namespace, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryDefinition.tag);
|
|
352
|
+
} else {
|
|
353
|
+
const legacyRevocationRegistryDefinitionId = getUnqualifiedRevocationRegistryDefinitionId(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryDefinition.tag);
|
|
354
|
+
didIndyRevocationRegistryDefinitionId = getDidIndyRevocationRegistryDefinitionId(namespace, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryDefinition.tag);
|
|
355
|
+
const revocationRegistryDefinitionRequest = new RevocationRegistryDefinitionRequest({
|
|
356
|
+
submitterDid: namespaceIdentifier,
|
|
357
|
+
revocationRegistryDefinitionV1: {
|
|
358
|
+
id: legacyRevocationRegistryDefinitionId,
|
|
359
|
+
ver: "1.0",
|
|
360
|
+
credDefId: getUnqualifiedCredentialDefinitionId(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag),
|
|
361
|
+
tag: revocationRegistryDefinition.tag,
|
|
362
|
+
revocDefType: revocationRegistryDefinition.revocDefType,
|
|
363
|
+
value: {
|
|
364
|
+
issuanceType: "ISSUANCE_BY_DEFAULT",
|
|
365
|
+
...revocationRegistryDefinition.value
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
const submitterKey = await verificationPublicJwkForIndyDid(agentContext, revocationRegistryDefinition.issuerId);
|
|
370
|
+
writeRequest = await pool.prepareWriteRequest(agentContext, revocationRegistryDefinitionRequest, submitterKey, endorserDid !== revocationRegistryDefinition.issuerId ? endorserDid : void 0);
|
|
371
|
+
if (endorserMode === "external") return {
|
|
372
|
+
jobId: didIndyRevocationRegistryDefinitionId,
|
|
373
|
+
revocationRegistryDefinitionState: {
|
|
374
|
+
state: "action",
|
|
375
|
+
action: "endorseIndyTransaction",
|
|
376
|
+
revocationRegistryDefinition,
|
|
377
|
+
revocationRegistryDefinitionId: didIndyRevocationRegistryDefinitionId,
|
|
378
|
+
revocationRegistryDefinitionRequest: writeRequest.body
|
|
379
|
+
},
|
|
380
|
+
registrationMetadata: {},
|
|
381
|
+
revocationRegistryDefinitionMetadata: {}
|
|
382
|
+
};
|
|
383
|
+
if (endorserMode === "internal" && endorserDid !== revocationRegistryDefinition.issuerId) {
|
|
384
|
+
const endorserKey = await verificationPublicJwkForIndyDid(agentContext, endorserDid);
|
|
385
|
+
await multiSignRequest(agentContext, writeRequest, endorserKey, parseIndyDid(endorserDid).namespaceIdentifier);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const response = await pool.submitRequest(writeRequest);
|
|
389
|
+
agentContext.config.logger.debug(`Registered revocation registry definition '${didIndyRevocationRegistryDefinitionId}' on ledger '${pool.indyNamespace}'`, {
|
|
390
|
+
response,
|
|
391
|
+
revocationRegistryDefinition
|
|
392
|
+
});
|
|
393
|
+
return {
|
|
394
|
+
revocationRegistryDefinitionMetadata: {},
|
|
395
|
+
revocationRegistryDefinitionState: {
|
|
396
|
+
revocationRegistryDefinition,
|
|
397
|
+
revocationRegistryDefinitionId: didIndyRevocationRegistryDefinitionId,
|
|
398
|
+
state: "finished"
|
|
399
|
+
},
|
|
400
|
+
registrationMetadata: {}
|
|
401
|
+
};
|
|
402
|
+
} catch (error) {
|
|
403
|
+
agentContext.config.logger.error(`Error registering revocation registry definition for credential definition '${revocationRegistryDefinition.credDefId}'`, {
|
|
404
|
+
error,
|
|
405
|
+
did: revocationRegistryDefinition.issuerId,
|
|
406
|
+
revocationRegistryDefinition
|
|
407
|
+
});
|
|
408
|
+
return {
|
|
409
|
+
revocationRegistryDefinitionMetadata: {},
|
|
410
|
+
registrationMetadata: {},
|
|
411
|
+
revocationRegistryDefinitionState: {
|
|
412
|
+
revocationRegistryDefinition,
|
|
413
|
+
state: "failed",
|
|
414
|
+
reason: `unknownError: ${error.message}`
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
async getRevocationStatusList(agentContext, revocationRegistryDefinitionId, timestamp) {
|
|
420
|
+
try {
|
|
421
|
+
const indyVdrPoolService = agentContext.dependencyManager.resolve(IndyVdrPoolService);
|
|
422
|
+
const { did } = parseIndyRevocationRegistryId(revocationRegistryDefinitionId);
|
|
423
|
+
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
424
|
+
const revocationDelta = await this.fetchIndyRevocationDelta(agentContext, revocationRegistryDefinitionId, timestamp);
|
|
425
|
+
if (!revocationDelta) return {
|
|
426
|
+
resolutionMetadata: {
|
|
427
|
+
error: "notFound",
|
|
428
|
+
message: `Error retrieving revocation registry delta '${revocationRegistryDefinitionId}' from ledger, potentially revocation interval ends before revocation registry creation`
|
|
429
|
+
},
|
|
430
|
+
revocationStatusListMetadata: {}
|
|
431
|
+
};
|
|
432
|
+
const { revocationRegistryDefinition, resolutionMetadata, revocationRegistryDefinitionMetadata } = await agentContext.resolve(AnonCredsRegistryService).getRevocationRegistryDefinition(agentContext, revocationRegistryDefinitionId);
|
|
433
|
+
if (!revocationRegistryDefinition || !revocationRegistryDefinitionMetadata.issuanceType || typeof revocationRegistryDefinitionMetadata.issuanceType !== "string") return {
|
|
434
|
+
resolutionMetadata: { error: `error resolving revocation registry definition with id ${revocationRegistryDefinitionId}: ${resolutionMetadata.error} ${resolutionMetadata.message}` },
|
|
435
|
+
revocationStatusListMetadata: { didIndyNamespace: pool.indyNamespace }
|
|
436
|
+
};
|
|
437
|
+
return {
|
|
438
|
+
resolutionMetadata: {},
|
|
439
|
+
revocationStatusList: anonCredsRevocationStatusListFromIndyVdr(revocationRegistryDefinitionId, revocationRegistryDefinition, revocationDelta, revocationRegistryDefinitionMetadata.issuanceType === "ISSUANCE_BY_DEFAULT"),
|
|
440
|
+
revocationStatusListMetadata: { didIndyNamespace: pool.indyNamespace }
|
|
441
|
+
};
|
|
442
|
+
} catch (error) {
|
|
443
|
+
agentContext.config.logger.error(`Error retrieving revocation registry delta '${revocationRegistryDefinitionId}' from ledger, potentially revocation interval ends before revocation registry creation?"`, {
|
|
444
|
+
error,
|
|
445
|
+
revocationRegistryId: revocationRegistryDefinitionId
|
|
446
|
+
});
|
|
447
|
+
return {
|
|
448
|
+
resolutionMetadata: {
|
|
449
|
+
error: "notFound",
|
|
450
|
+
message: `Error retrieving revocation registry delta '${revocationRegistryDefinitionId}' from ledger, potentially revocation interval ends before revocation registry creation: ${error.message}`
|
|
451
|
+
},
|
|
452
|
+
revocationStatusListMetadata: {}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
async registerRevocationStatusList(agentContext, { options, revocationStatusList }) {
|
|
457
|
+
try {
|
|
458
|
+
const { endorsedTransaction, endorserDid, endorserMode } = options;
|
|
459
|
+
const { namespaceIdentifier, namespace } = parseIndyDid(revocationStatusList.issuerId);
|
|
460
|
+
const pool = agentContext.dependencyManager.resolve(IndyVdrPoolService).getPoolForNamespace(namespace);
|
|
461
|
+
agentContext.config.logger.debug(`Registering revocation status list on ledger '${namespace}' with did '${revocationStatusList.issuerId}'`, revocationStatusList);
|
|
462
|
+
let writeRequest;
|
|
463
|
+
const { schemaSeqNo, credentialDefinitionTag, namespaceIdentifier: revocationRegistryNamespaceIdentifier, revocationRegistryTag, namespace: revocationRegistryNamespace } = parseIndyRevocationRegistryId(revocationStatusList.revRegDefId);
|
|
464
|
+
const legacyRevocationRegistryDefinitionId = getUnqualifiedRevocationRegistryDefinitionId(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag);
|
|
465
|
+
const didIndyRevocationRegistryEntryId = getDidIndyRevocationRegistryEntryId(namespace, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag);
|
|
466
|
+
if (revocationRegistryNamespace && revocationRegistryNamespace !== namespace) throw new CredoError(`Issued id '${revocationStatusList.issuerId}' does not have the same namespace (${namespace}) as the revocation registry definition '${revocationRegistryNamespace}'`);
|
|
467
|
+
if (revocationRegistryNamespaceIdentifier !== namespaceIdentifier) throw new CredoError(`Cannot register revocation registry definition using a different DID. Revocation registry definition contains '${revocationRegistryNamespaceIdentifier}', but DID used was '${namespaceIdentifier}'`);
|
|
468
|
+
if (endorsedTransaction) {
|
|
469
|
+
agentContext.config.logger.debug(`Preparing endorsed tx '${endorsedTransaction}' for submission on ledger '${namespace}' with did '${revocationStatusList.issuerId}'`, revocationStatusList);
|
|
470
|
+
writeRequest = new CustomRequest({ customRequest: endorsedTransaction });
|
|
471
|
+
} else {
|
|
472
|
+
const previousDelta = await this.fetchIndyRevocationDelta(agentContext, legacyRevocationRegistryDefinitionId, dateToTimestamp(/* @__PURE__ */ new Date()));
|
|
473
|
+
const revocationRegistryDefinitionRequest = new RevocationRegistryEntryRequest({
|
|
474
|
+
submitterDid: namespaceIdentifier,
|
|
475
|
+
revocationRegistryEntry: {
|
|
476
|
+
ver: "1.0",
|
|
477
|
+
value: indyVdrCreateLatestRevocationDelta(revocationStatusList.currentAccumulator, revocationStatusList.revocationList, previousDelta ?? void 0)
|
|
478
|
+
},
|
|
479
|
+
revocationRegistryDefinitionType: "CL_ACCUM",
|
|
480
|
+
revocationRegistryDefinitionId: legacyRevocationRegistryDefinitionId
|
|
481
|
+
});
|
|
482
|
+
const submitterKey = await verificationPublicJwkForIndyDid(agentContext, revocationStatusList.issuerId);
|
|
483
|
+
writeRequest = await pool.prepareWriteRequest(agentContext, revocationRegistryDefinitionRequest, submitterKey, endorserDid !== revocationStatusList.issuerId ? endorserDid : void 0);
|
|
484
|
+
if (endorserMode === "external") return {
|
|
485
|
+
jobId: didIndyRevocationRegistryEntryId,
|
|
486
|
+
revocationStatusListState: {
|
|
487
|
+
state: "action",
|
|
488
|
+
action: "endorseIndyTransaction",
|
|
489
|
+
revocationStatusList,
|
|
490
|
+
revocationStatusListRequest: writeRequest.body
|
|
491
|
+
},
|
|
492
|
+
registrationMetadata: {},
|
|
493
|
+
revocationStatusListMetadata: {}
|
|
494
|
+
};
|
|
495
|
+
if (endorserMode === "internal" && endorserDid !== revocationStatusList.issuerId) {
|
|
496
|
+
const endorserKey = await verificationPublicJwkForIndyDid(agentContext, endorserDid);
|
|
497
|
+
await multiSignRequest(agentContext, writeRequest, endorserKey, parseIndyDid(endorserDid).namespaceIdentifier);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
const response = await pool.submitRequest(writeRequest);
|
|
501
|
+
agentContext.config.logger.debug(`Registered revocation status list '${didIndyRevocationRegistryEntryId}' on ledger '${pool.indyNamespace}'`, {
|
|
502
|
+
response,
|
|
503
|
+
revocationStatusList
|
|
504
|
+
});
|
|
505
|
+
return {
|
|
506
|
+
revocationStatusListMetadata: {},
|
|
507
|
+
revocationStatusListState: {
|
|
508
|
+
revocationStatusList: {
|
|
509
|
+
...revocationStatusList,
|
|
510
|
+
timestamp: response.result.txnMetadata.txnTime
|
|
511
|
+
},
|
|
512
|
+
state: "finished"
|
|
513
|
+
},
|
|
514
|
+
registrationMetadata: {}
|
|
515
|
+
};
|
|
516
|
+
} catch (error) {
|
|
517
|
+
agentContext.config.logger.error(`Error registering revocation status list for revocation registry definition '${revocationStatusList.revRegDefId}}'`, {
|
|
518
|
+
error,
|
|
519
|
+
did: revocationStatusList.issuerId
|
|
520
|
+
});
|
|
521
|
+
return {
|
|
522
|
+
registrationMetadata: {},
|
|
523
|
+
revocationStatusListMetadata: {},
|
|
524
|
+
revocationStatusListState: {
|
|
525
|
+
revocationStatusList,
|
|
526
|
+
state: "failed",
|
|
527
|
+
reason: `unknownError: ${error.message}`
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
async fetchIndySchemaWithSeqNo(agentContext, seqNo, did) {
|
|
533
|
+
const { pool } = await agentContext.dependencyManager.resolve(IndyVdrPoolService).getPoolForDid(agentContext, did);
|
|
534
|
+
agentContext.config.logger.debug(`Getting transaction with seqNo '${seqNo}' from ledger '${pool.indyNamespace}'`);
|
|
535
|
+
const request = new GetTransactionRequest({
|
|
536
|
+
ledgerType: 1,
|
|
537
|
+
seqNo
|
|
538
|
+
});
|
|
539
|
+
agentContext.config.logger.trace(`Submitting get transaction request to ledger '${pool.indyNamespace}'`);
|
|
540
|
+
const response = await pool.submitRequest(request);
|
|
541
|
+
if (response.result.data?.txn.type !== "101") {
|
|
542
|
+
agentContext.config.logger.error(`Could not get schema from ledger for seq no ${seqNo}'`);
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
const schema = response.result.data?.txn.data;
|
|
546
|
+
const schemaDid = response.result.data?.txn.metadata.from;
|
|
547
|
+
return {
|
|
548
|
+
schema: {
|
|
549
|
+
schemaId: getUnqualifiedSchemaId(schemaDid, schema.data.name, schema.data.version),
|
|
550
|
+
attr_name: schema.data.attr_names,
|
|
551
|
+
name: schema.data.name,
|
|
552
|
+
version: schema.data.version,
|
|
553
|
+
issuerId: schemaDid,
|
|
554
|
+
seqNo
|
|
555
|
+
},
|
|
556
|
+
indyNamespace: pool.indyNamespace
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
async fetchIndyRevocationDelta(agentContext, revocationRegistryDefinitionId, toTs) {
|
|
560
|
+
const indyVdrPoolService = agentContext.dependencyManager.resolve(IndyVdrPoolService);
|
|
561
|
+
const { did, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag } = parseIndyRevocationRegistryId(revocationRegistryDefinitionId);
|
|
562
|
+
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
563
|
+
agentContext.config.logger.debug(`Using ledger '${pool.indyNamespace}' to retrieve revocation registry deltas with revocation registry definition id '${revocationRegistryDefinitionId}' until ${toTs}`);
|
|
564
|
+
const deltaRequest = new GetRevocationRegistryDeltaRequest({
|
|
565
|
+
toTs,
|
|
566
|
+
submitterDid: namespaceIdentifier,
|
|
567
|
+
revocationRegistryId: getUnqualifiedRevocationRegistryDefinitionId(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag)
|
|
568
|
+
});
|
|
569
|
+
agentContext.config.logger.trace(`Submitting get transaction request to ledger '${pool.indyNamespace}'`);
|
|
570
|
+
const { result: { data, type, txnTime } } = await pool.submitRequest(deltaRequest);
|
|
571
|
+
if (type !== "117" || data === null || !txnTime) {
|
|
572
|
+
agentContext.config.logger.warn(`Could not get any deltas from ledger for revocation registry definition '${revocationRegistryDefinitionId}' from ledger '${pool.indyNamespace}'`);
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
575
|
+
return {
|
|
576
|
+
revoked: data.value.revoked,
|
|
577
|
+
issued: data.value.issued,
|
|
578
|
+
accum: data.value.accum_to.value.accum,
|
|
579
|
+
txnTime
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
//#endregion
|
|
585
|
+
export { IndyVdrAnonCredsRegistry };
|
|
586
|
+
//# sourceMappingURL=IndyVdrAnonCredsRegistry.mjs.map
|