@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
|
@@ -1,682 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IndyVdrAnonCredsRegistry = void 0;
|
|
4
|
-
const anoncreds_1 = require("@credo-ts/anoncreds");
|
|
5
|
-
const core_1 = require("@credo-ts/core");
|
|
6
|
-
const indy_vdr_shared_1 = require("@hyperledger/indy-vdr-shared");
|
|
7
|
-
const didIndyUtil_1 = require("../dids/didIndyUtil");
|
|
8
|
-
const pool_1 = require("../pool");
|
|
9
|
-
const sign_1 = require("../utils/sign");
|
|
10
|
-
const identifiers_1 = require("./utils/identifiers");
|
|
11
|
-
const transform_1 = require("./utils/transform");
|
|
12
|
-
class IndyVdrAnonCredsRegistry {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.methodName = 'indy';
|
|
15
|
-
this.supportedIdentifier = identifiers_1.indyVdrAnonCredsRegistryIdentifierRegex;
|
|
16
|
-
}
|
|
17
|
-
async getSchema(agentContext, schemaId) {
|
|
18
|
-
try {
|
|
19
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
20
|
-
// parse schema id (supports did:indy and legacy)
|
|
21
|
-
const { did, namespaceIdentifier, schemaName, schemaVersion } = (0, anoncreds_1.parseIndySchemaId)(schemaId);
|
|
22
|
-
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
23
|
-
agentContext.config.logger.debug(`Getting schema '${schemaId}' from ledger '${pool.indyNamespace}'`);
|
|
24
|
-
// even though we support did:indy and legacy identifiers we always need to fetch using the legacy identifier
|
|
25
|
-
const legacySchemaId = (0, anoncreds_1.getUnqualifiedSchemaId)(namespaceIdentifier, schemaName, schemaVersion);
|
|
26
|
-
const request = new indy_vdr_shared_1.GetSchemaRequest({ schemaId: legacySchemaId });
|
|
27
|
-
agentContext.config.logger.trace(`Submitting get schema request for schema '${schemaId}' to ledger '${pool.indyNamespace}'`);
|
|
28
|
-
const response = await pool.submitRequest(request);
|
|
29
|
-
agentContext.config.logger.trace(`Got un-parsed schema '${schemaId}' from ledger '${pool.indyNamespace}'`, {
|
|
30
|
-
response,
|
|
31
|
-
});
|
|
32
|
-
if (!('attr_names' in response.result.data)) {
|
|
33
|
-
agentContext.config.logger.error(`Error retrieving schema '${schemaId}'`);
|
|
34
|
-
return {
|
|
35
|
-
schemaId,
|
|
36
|
-
resolutionMetadata: {
|
|
37
|
-
error: 'notFound',
|
|
38
|
-
message: `unable to find schema with id ${schemaId}`,
|
|
39
|
-
},
|
|
40
|
-
schemaMetadata: {},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
schema: {
|
|
45
|
-
attrNames: response.result.data.attr_names,
|
|
46
|
-
name: response.result.data.name,
|
|
47
|
-
version: response.result.data.version,
|
|
48
|
-
issuerId: did,
|
|
49
|
-
},
|
|
50
|
-
schemaId,
|
|
51
|
-
resolutionMetadata: {},
|
|
52
|
-
schemaMetadata: {
|
|
53
|
-
didIndyNamespace: pool.indyNamespace,
|
|
54
|
-
// NOTE: the seqNo is required by the indy-sdk even though not present in AnonCreds v1.
|
|
55
|
-
// For this reason we return it in the metadata.
|
|
56
|
-
indyLedgerSeqNo: response.result.seqNo,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
agentContext.config.logger.error(`Error retrieving schema '${schemaId}'`, {
|
|
62
|
-
error,
|
|
63
|
-
schemaId,
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
schemaId,
|
|
67
|
-
resolutionMetadata: {
|
|
68
|
-
error: 'notFound',
|
|
69
|
-
},
|
|
70
|
-
schemaMetadata: {},
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async registerSchema(agentContext, options) {
|
|
75
|
-
var _a, _b;
|
|
76
|
-
const schema = options.schema;
|
|
77
|
-
const { issuerId, name, version, attrNames } = schema;
|
|
78
|
-
try {
|
|
79
|
-
// This will throw an error if trying to register a schema with a legacy indy identifier. We only support did:indy identifiers
|
|
80
|
-
// for registering, that will allow us to extract the namespace and means all stored records will use did:indy identifiers.
|
|
81
|
-
const { namespaceIdentifier, namespace } = (0, anoncreds_1.parseIndyDid)(issuerId);
|
|
82
|
-
const { endorserDid, endorserMode } = options.options;
|
|
83
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
84
|
-
const pool = indyVdrPoolService.getPoolForNamespace(namespace);
|
|
85
|
-
let writeRequest;
|
|
86
|
-
const didIndySchemaId = (0, identifiers_1.getDidIndySchemaId)(namespace, namespaceIdentifier, schema.name, schema.version);
|
|
87
|
-
const endorsedTransaction = options.options.endorsedTransaction;
|
|
88
|
-
if (endorsedTransaction) {
|
|
89
|
-
agentContext.config.logger.debug(`Preparing endorsed tx '${endorsedTransaction}' for submission on ledger '${namespace}' with did '${issuerId}'`, schema);
|
|
90
|
-
writeRequest = new indy_vdr_shared_1.CustomRequest({ customRequest: endorsedTransaction });
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
agentContext.config.logger.debug(`Create schema tx on ledger '${namespace}' with did '${issuerId}'`, schema);
|
|
94
|
-
const legacySchemaId = (0, anoncreds_1.getUnqualifiedSchemaId)(namespaceIdentifier, name, version);
|
|
95
|
-
const schemaRequest = new indy_vdr_shared_1.SchemaRequest({
|
|
96
|
-
submitterDid: namespaceIdentifier,
|
|
97
|
-
schema: { id: legacySchemaId, name, ver: '1.0', version, attrNames },
|
|
98
|
-
});
|
|
99
|
-
const submitterKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(agentContext, issuerId);
|
|
100
|
-
writeRequest = await pool.prepareWriteRequest(agentContext, schemaRequest, submitterKey, endorserDid !== issuerId ? endorserDid : undefined);
|
|
101
|
-
if (endorserMode === 'external') {
|
|
102
|
-
return {
|
|
103
|
-
jobId: didIndySchemaId,
|
|
104
|
-
schemaState: {
|
|
105
|
-
state: 'action',
|
|
106
|
-
action: 'endorseIndyTransaction',
|
|
107
|
-
schemaId: didIndySchemaId,
|
|
108
|
-
schema: schema,
|
|
109
|
-
schemaRequest: writeRequest.body,
|
|
110
|
-
},
|
|
111
|
-
registrationMetadata: {},
|
|
112
|
-
schemaMetadata: {},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (endorserMode === 'internal' && endorserDid !== issuerId) {
|
|
116
|
-
const endorserKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(agentContext, endorserDid);
|
|
117
|
-
await (0, sign_1.multiSignRequest)(agentContext, writeRequest, endorserKey, (0, anoncreds_1.parseIndyDid)(endorserDid).namespaceIdentifier);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const response = await pool.submitRequest(writeRequest);
|
|
121
|
-
agentContext.config.logger.debug(`Registered schema '${didIndySchemaId}' on ledger '${pool.indyNamespace}'`, {
|
|
122
|
-
response,
|
|
123
|
-
writeRequest,
|
|
124
|
-
});
|
|
125
|
-
return {
|
|
126
|
-
schemaState: {
|
|
127
|
-
state: 'finished',
|
|
128
|
-
schema: schema,
|
|
129
|
-
schemaId: didIndySchemaId,
|
|
130
|
-
},
|
|
131
|
-
registrationMetadata: {},
|
|
132
|
-
schemaMetadata: {
|
|
133
|
-
// NOTE: the seqNo is required by the indy-sdk even though not present in AnonCreds v1.
|
|
134
|
-
// For this reason we return it in the metadata.
|
|
135
|
-
// Cast to SchemaResponse to pass type check
|
|
136
|
-
indyLedgerSeqNo: (_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.txnMetadata) === null || _b === void 0 ? void 0 : _b.seqNo,
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
agentContext.config.logger.error(`Error registering schema for did '${issuerId}'`, {
|
|
142
|
-
error,
|
|
143
|
-
did: issuerId,
|
|
144
|
-
schema: schema,
|
|
145
|
-
});
|
|
146
|
-
return {
|
|
147
|
-
schemaMetadata: {},
|
|
148
|
-
registrationMetadata: {},
|
|
149
|
-
schemaState: {
|
|
150
|
-
state: 'failed',
|
|
151
|
-
schema: schema,
|
|
152
|
-
reason: `unknownError: ${error.message}`,
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async getCredentialDefinition(agentContext, credentialDefinitionId) {
|
|
158
|
-
try {
|
|
159
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
160
|
-
// we support did:indy and legacy identifiers
|
|
161
|
-
const { did, namespaceIdentifier, schemaSeqNo, tag } = (0, anoncreds_1.parseIndyCredentialDefinitionId)(credentialDefinitionId);
|
|
162
|
-
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
163
|
-
agentContext.config.logger.debug(`Getting credential definition '${credentialDefinitionId}' from ledger '${pool.indyNamespace}'`);
|
|
164
|
-
const legacyCredentialDefinitionId = (0, anoncreds_1.getUnqualifiedCredentialDefinitionId)(namespaceIdentifier, schemaSeqNo, tag);
|
|
165
|
-
const request = new indy_vdr_shared_1.GetCredentialDefinitionRequest({
|
|
166
|
-
credentialDefinitionId: legacyCredentialDefinitionId,
|
|
167
|
-
});
|
|
168
|
-
agentContext.config.logger.trace(`Submitting get credential definition request for credential definition '${credentialDefinitionId}' to ledger '${pool.indyNamespace}'`);
|
|
169
|
-
const response = await pool.submitRequest(request);
|
|
170
|
-
// We need to fetch the schema to determine the schemaId (we only have the seqNo)
|
|
171
|
-
const schema = await this.fetchIndySchemaWithSeqNo(agentContext, response.result.ref, namespaceIdentifier);
|
|
172
|
-
if (!schema || !response.result.data) {
|
|
173
|
-
agentContext.config.logger.error(`Error retrieving credential definition '${credentialDefinitionId}'`);
|
|
174
|
-
return {
|
|
175
|
-
credentialDefinitionId,
|
|
176
|
-
credentialDefinitionMetadata: {},
|
|
177
|
-
resolutionMetadata: {
|
|
178
|
-
error: 'notFound',
|
|
179
|
-
message: `unable to resolve credential definition with id ${credentialDefinitionId}`,
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
// Format the schema id based on the type of the credential definition id
|
|
184
|
-
const schemaId = credentialDefinitionId.startsWith('did:indy')
|
|
185
|
-
? (0, identifiers_1.getDidIndySchemaId)(pool.indyNamespace, schema.schema.issuerId, schema.schema.name, schema.schema.version)
|
|
186
|
-
: schema.schema.schemaId;
|
|
187
|
-
return {
|
|
188
|
-
credentialDefinitionId,
|
|
189
|
-
credentialDefinition: {
|
|
190
|
-
issuerId: did,
|
|
191
|
-
schemaId,
|
|
192
|
-
tag: response.result.tag,
|
|
193
|
-
type: 'CL',
|
|
194
|
-
value: response.result.data,
|
|
195
|
-
},
|
|
196
|
-
credentialDefinitionMetadata: {
|
|
197
|
-
didIndyNamespace: pool.indyNamespace,
|
|
198
|
-
},
|
|
199
|
-
resolutionMetadata: {},
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
agentContext.config.logger.error(`Error retrieving credential definition '${credentialDefinitionId}'`, {
|
|
204
|
-
error,
|
|
205
|
-
credentialDefinitionId,
|
|
206
|
-
});
|
|
207
|
-
return {
|
|
208
|
-
credentialDefinitionId,
|
|
209
|
-
credentialDefinitionMetadata: {},
|
|
210
|
-
resolutionMetadata: {
|
|
211
|
-
error: 'notFound',
|
|
212
|
-
message: `unable to resolve credential definition: ${error.message}`,
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
async registerCredentialDefinition(agentContext, options) {
|
|
218
|
-
var _a;
|
|
219
|
-
const credentialDefinition = options.credentialDefinition;
|
|
220
|
-
const { schemaId, issuerId, tag, value } = credentialDefinition;
|
|
221
|
-
try {
|
|
222
|
-
// This will throw an error if trying to register a credential definition with a legacy indy identifier. We only support did:indy
|
|
223
|
-
// identifiers for registering, that will allow us to extract the namespace and means all stored records will use did:indy identifiers.
|
|
224
|
-
const { namespaceIdentifier, namespace } = (0, anoncreds_1.parseIndyDid)(issuerId);
|
|
225
|
-
const { endorserDid, endorserMode } = options.options;
|
|
226
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
227
|
-
const pool = indyVdrPoolService.getPoolForNamespace(namespace);
|
|
228
|
-
agentContext.config.logger.debug(`Registering credential definition on ledger '${namespace}' with did '${issuerId}'`, options.credentialDefinition);
|
|
229
|
-
let writeRequest;
|
|
230
|
-
let didIndyCredentialDefinitionId;
|
|
231
|
-
let schemaSeqNo;
|
|
232
|
-
const endorsedTransaction = options.options.endorsedTransaction;
|
|
233
|
-
if (endorsedTransaction) {
|
|
234
|
-
agentContext.config.logger.debug(`Preparing endorsed tx '${endorsedTransaction}' for submission on ledger '${namespace}' with did '${issuerId}'`, credentialDefinition);
|
|
235
|
-
writeRequest = new indy_vdr_shared_1.CustomRequest({ customRequest: endorsedTransaction });
|
|
236
|
-
const operation = (_a = JSON.parse(endorsedTransaction)) === null || _a === void 0 ? void 0 : _a.operation;
|
|
237
|
-
// extract the seqNo from the endorsed transaction, which is contained in the ref field of the operation
|
|
238
|
-
schemaSeqNo = Number(operation === null || operation === void 0 ? void 0 : operation.ref);
|
|
239
|
-
didIndyCredentialDefinitionId = (0, identifiers_1.getDidIndyCredentialDefinitionId)(namespace, namespaceIdentifier, schemaSeqNo, tag);
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
// TODO: this will bypass caching if done on a higher level.
|
|
243
|
-
const { schemaMetadata, resolutionMetadata } = await this.getSchema(agentContext, schemaId);
|
|
244
|
-
if (!(schemaMetadata === null || schemaMetadata === void 0 ? void 0 : schemaMetadata.indyLedgerSeqNo) || typeof schemaMetadata.indyLedgerSeqNo !== 'number') {
|
|
245
|
-
return {
|
|
246
|
-
registrationMetadata: {},
|
|
247
|
-
credentialDefinitionMetadata: {
|
|
248
|
-
didIndyNamespace: pool.indyNamespace,
|
|
249
|
-
},
|
|
250
|
-
credentialDefinitionState: {
|
|
251
|
-
credentialDefinition: options.credentialDefinition,
|
|
252
|
-
state: 'failed',
|
|
253
|
-
reason: `error resolving schema with id ${schemaId}: ${resolutionMetadata.error} ${resolutionMetadata.message}`,
|
|
254
|
-
},
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
schemaSeqNo = schemaMetadata.indyLedgerSeqNo;
|
|
258
|
-
// FIXME: we need to check if schemaId has same namespace as issuerId and it should not be a legacy identifier
|
|
259
|
-
// FIXME: in the other methods we also need to add checks. E.g. when creating a revocation
|
|
260
|
-
// status list, you can only create a revocation status list for a credential definition registry that is created
|
|
261
|
-
// under the same namespace and by the same issuer id (you can create a cred def for a schema created by another issuer
|
|
262
|
-
// but you can't create a revocation registry based on a cred def created by another issuer. We need to add these checks
|
|
263
|
-
// to all register methods in this file)
|
|
264
|
-
const legacyCredentialDefinitionId = (0, anoncreds_1.getUnqualifiedCredentialDefinitionId)(issuerId, schemaSeqNo, tag);
|
|
265
|
-
didIndyCredentialDefinitionId = (0, identifiers_1.getDidIndyCredentialDefinitionId)(namespace, namespaceIdentifier, schemaSeqNo, tag);
|
|
266
|
-
const credentialDefinitionRequest = new indy_vdr_shared_1.CredentialDefinitionRequest({
|
|
267
|
-
submitterDid: namespaceIdentifier,
|
|
268
|
-
credentialDefinition: {
|
|
269
|
-
ver: '1.0',
|
|
270
|
-
id: legacyCredentialDefinitionId,
|
|
271
|
-
schemaId: schemaSeqNo.toString(),
|
|
272
|
-
type: 'CL',
|
|
273
|
-
tag,
|
|
274
|
-
value,
|
|
275
|
-
},
|
|
276
|
-
});
|
|
277
|
-
const submitterKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(agentContext, issuerId);
|
|
278
|
-
writeRequest = await pool.prepareWriteRequest(agentContext, credentialDefinitionRequest, submitterKey, endorserDid !== issuerId ? endorserDid : undefined);
|
|
279
|
-
if (endorserMode === 'external') {
|
|
280
|
-
return {
|
|
281
|
-
jobId: didIndyCredentialDefinitionId,
|
|
282
|
-
credentialDefinitionState: {
|
|
283
|
-
state: 'action',
|
|
284
|
-
action: 'endorseIndyTransaction',
|
|
285
|
-
credentialDefinition: credentialDefinition,
|
|
286
|
-
credentialDefinitionId: didIndyCredentialDefinitionId,
|
|
287
|
-
credentialDefinitionRequest: writeRequest.body,
|
|
288
|
-
},
|
|
289
|
-
registrationMetadata: {},
|
|
290
|
-
credentialDefinitionMetadata: {},
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
if (endorserMode === 'internal' && endorserDid !== issuerId) {
|
|
294
|
-
const endorserKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(agentContext, endorserDid);
|
|
295
|
-
await (0, sign_1.multiSignRequest)(agentContext, writeRequest, endorserKey, (0, anoncreds_1.parseIndyDid)(endorserDid).namespaceIdentifier);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
const response = await pool.submitRequest(writeRequest);
|
|
299
|
-
agentContext.config.logger.debug(`Registered credential definition '${didIndyCredentialDefinitionId}' on ledger '${pool.indyNamespace}'`, {
|
|
300
|
-
response,
|
|
301
|
-
credentialDefinition: options.credentialDefinition,
|
|
302
|
-
});
|
|
303
|
-
return {
|
|
304
|
-
credentialDefinitionMetadata: {},
|
|
305
|
-
credentialDefinitionState: {
|
|
306
|
-
credentialDefinition: credentialDefinition,
|
|
307
|
-
credentialDefinitionId: didIndyCredentialDefinitionId,
|
|
308
|
-
state: 'finished',
|
|
309
|
-
},
|
|
310
|
-
registrationMetadata: {},
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
catch (error) {
|
|
314
|
-
agentContext.config.logger.error(`Error registering credential definition for schema '${schemaId}'`, {
|
|
315
|
-
error,
|
|
316
|
-
did: issuerId,
|
|
317
|
-
credentialDefinition: options.credentialDefinition,
|
|
318
|
-
});
|
|
319
|
-
return {
|
|
320
|
-
credentialDefinitionMetadata: {},
|
|
321
|
-
registrationMetadata: {},
|
|
322
|
-
credentialDefinitionState: {
|
|
323
|
-
credentialDefinition: options.credentialDefinition,
|
|
324
|
-
state: 'failed',
|
|
325
|
-
reason: `unknownError: ${error.message}`,
|
|
326
|
-
},
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
async getRevocationRegistryDefinition(agentContext, revocationRegistryDefinitionId) {
|
|
331
|
-
try {
|
|
332
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
333
|
-
const { did, namespaceIdentifier, credentialDefinitionTag, revocationRegistryTag, schemaSeqNo } = (0, anoncreds_1.parseIndyRevocationRegistryId)(revocationRegistryDefinitionId);
|
|
334
|
-
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
335
|
-
agentContext.config.logger.debug(`Using ledger '${pool.indyNamespace}' to retrieve revocation registry definition '${revocationRegistryDefinitionId}'`);
|
|
336
|
-
const legacyRevocationRegistryId = (0, anoncreds_1.getUnqualifiedRevocationRegistryDefinitionId)(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag);
|
|
337
|
-
const request = new indy_vdr_shared_1.GetRevocationRegistryDefinitionRequest({
|
|
338
|
-
revocationRegistryId: legacyRevocationRegistryId,
|
|
339
|
-
});
|
|
340
|
-
agentContext.config.logger.trace(`Submitting get revocation registry definition request for revocation registry definition '${revocationRegistryDefinitionId}' to ledger`);
|
|
341
|
-
const response = await pool.submitRequest(request);
|
|
342
|
-
if (!response.result.data) {
|
|
343
|
-
agentContext.config.logger.error(`Error retrieving revocation registry definition '${revocationRegistryDefinitionId}' from ledger`, {
|
|
344
|
-
revocationRegistryDefinitionId,
|
|
345
|
-
});
|
|
346
|
-
return {
|
|
347
|
-
resolutionMetadata: {
|
|
348
|
-
error: 'notFound',
|
|
349
|
-
message: 'unable to resolve revocation registry definition',
|
|
350
|
-
},
|
|
351
|
-
revocationRegistryDefinitionId,
|
|
352
|
-
revocationRegistryDefinitionMetadata: {},
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
agentContext.config.logger.trace(`Got revocation registry definition '${revocationRegistryDefinitionId}' from ledger '${pool.indyNamespace}'`, {
|
|
356
|
-
response,
|
|
357
|
-
});
|
|
358
|
-
const credentialDefinitionId = revocationRegistryDefinitionId.startsWith('did:indy:')
|
|
359
|
-
? (0, identifiers_1.getDidIndyCredentialDefinitionId)(pool.indyNamespace, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag)
|
|
360
|
-
: (0, anoncreds_1.getUnqualifiedCredentialDefinitionId)(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag);
|
|
361
|
-
const revocationRegistryDefinition = {
|
|
362
|
-
issuerId: did,
|
|
363
|
-
revocDefType: response.result.data.revocDefType,
|
|
364
|
-
value: {
|
|
365
|
-
maxCredNum: response.result.data.value.maxCredNum,
|
|
366
|
-
tailsHash: response.result.data.value.tailsHash,
|
|
367
|
-
tailsLocation: response.result.data.value.tailsLocation,
|
|
368
|
-
publicKeys: {
|
|
369
|
-
accumKey: {
|
|
370
|
-
z: response.result.data.value.publicKeys.accumKey.z,
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
|
-
tag: response.result.data.tag,
|
|
375
|
-
credDefId: credentialDefinitionId,
|
|
376
|
-
};
|
|
377
|
-
return {
|
|
378
|
-
revocationRegistryDefinitionId,
|
|
379
|
-
revocationRegistryDefinition,
|
|
380
|
-
revocationRegistryDefinitionMetadata: {
|
|
381
|
-
issuanceType: response.result.data.value.issuanceType,
|
|
382
|
-
didIndyNamespace: pool.indyNamespace,
|
|
383
|
-
},
|
|
384
|
-
resolutionMetadata: {},
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
catch (error) {
|
|
388
|
-
agentContext.config.logger.error(`Error retrieving revocation registry definition '${revocationRegistryDefinitionId}' from ledger`, {
|
|
389
|
-
error,
|
|
390
|
-
revocationRegistryDefinitionId,
|
|
391
|
-
});
|
|
392
|
-
return {
|
|
393
|
-
resolutionMetadata: {
|
|
394
|
-
error: 'notFound',
|
|
395
|
-
message: `unable to resolve revocation registry definition: ${error.message}`,
|
|
396
|
-
},
|
|
397
|
-
revocationRegistryDefinitionId,
|
|
398
|
-
revocationRegistryDefinitionMetadata: {},
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
async registerRevocationRegistryDefinition(agentContext, { options, revocationRegistryDefinition }) {
|
|
403
|
-
try {
|
|
404
|
-
// This will throw an error if trying to register a credential definition with a legacy indy identifier. We only support did:indy
|
|
405
|
-
// identifiers for registering, that will allow us to extract the namespace and means all stored records will use did:indy identifiers.
|
|
406
|
-
const { namespaceIdentifier, namespace } = (0, anoncreds_1.parseIndyDid)(revocationRegistryDefinition.issuerId);
|
|
407
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
408
|
-
const pool = indyVdrPoolService.getPoolForNamespace(namespace);
|
|
409
|
-
agentContext.config.logger.debug(`Registering revocation registry definition on ledger '${namespace}' with did '${revocationRegistryDefinition.issuerId}'`, revocationRegistryDefinition);
|
|
410
|
-
let writeRequest;
|
|
411
|
-
let didIndyRevocationRegistryDefinitionId;
|
|
412
|
-
const { schemaSeqNo, tag: credentialDefinitionTag } = (0, anoncreds_1.parseIndyCredentialDefinitionId)(revocationRegistryDefinition.credDefId);
|
|
413
|
-
const { endorsedTransaction, endorserDid, endorserMode } = options;
|
|
414
|
-
if (endorsedTransaction) {
|
|
415
|
-
agentContext.config.logger.debug(`Preparing endorsed tx '${endorsedTransaction}' for submission on ledger '${namespace}' with did '${revocationRegistryDefinition.issuerId}'`, revocationRegistryDefinition);
|
|
416
|
-
writeRequest = new indy_vdr_shared_1.CustomRequest({ customRequest: endorsedTransaction });
|
|
417
|
-
didIndyRevocationRegistryDefinitionId = (0, identifiers_1.getDidIndyRevocationRegistryDefinitionId)(namespace, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryDefinition.tag);
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
const legacyRevocationRegistryDefinitionId = (0, anoncreds_1.getUnqualifiedRevocationRegistryDefinitionId)(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryDefinition.tag);
|
|
421
|
-
didIndyRevocationRegistryDefinitionId = (0, identifiers_1.getDidIndyRevocationRegistryDefinitionId)(namespace, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryDefinition.tag);
|
|
422
|
-
const legacyCredentialDefinitionId = (0, anoncreds_1.getUnqualifiedCredentialDefinitionId)(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag);
|
|
423
|
-
const revocationRegistryDefinitionRequest = new indy_vdr_shared_1.RevocationRegistryDefinitionRequest({
|
|
424
|
-
submitterDid: namespaceIdentifier,
|
|
425
|
-
revocationRegistryDefinitionV1: {
|
|
426
|
-
id: legacyRevocationRegistryDefinitionId,
|
|
427
|
-
ver: '1.0',
|
|
428
|
-
credDefId: legacyCredentialDefinitionId,
|
|
429
|
-
tag: revocationRegistryDefinition.tag,
|
|
430
|
-
revocDefType: revocationRegistryDefinition.revocDefType,
|
|
431
|
-
value: Object.assign({ issuanceType: 'ISSUANCE_BY_DEFAULT' }, revocationRegistryDefinition.value),
|
|
432
|
-
},
|
|
433
|
-
});
|
|
434
|
-
const submitterKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(agentContext, revocationRegistryDefinition.issuerId);
|
|
435
|
-
writeRequest = await pool.prepareWriteRequest(agentContext, revocationRegistryDefinitionRequest, submitterKey, endorserDid !== revocationRegistryDefinition.issuerId ? endorserDid : undefined);
|
|
436
|
-
if (endorserMode === 'external') {
|
|
437
|
-
return {
|
|
438
|
-
jobId: didIndyRevocationRegistryDefinitionId,
|
|
439
|
-
revocationRegistryDefinitionState: {
|
|
440
|
-
state: 'action',
|
|
441
|
-
action: 'endorseIndyTransaction',
|
|
442
|
-
revocationRegistryDefinition,
|
|
443
|
-
revocationRegistryDefinitionId: didIndyRevocationRegistryDefinitionId,
|
|
444
|
-
revocationRegistryDefinitionRequest: writeRequest.body,
|
|
445
|
-
},
|
|
446
|
-
registrationMetadata: {},
|
|
447
|
-
revocationRegistryDefinitionMetadata: {},
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
if (endorserMode === 'internal' && endorserDid !== revocationRegistryDefinition.issuerId) {
|
|
451
|
-
const endorserKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(agentContext, endorserDid);
|
|
452
|
-
await (0, sign_1.multiSignRequest)(agentContext, writeRequest, endorserKey, (0, anoncreds_1.parseIndyDid)(endorserDid).namespaceIdentifier);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
const response = await pool.submitRequest(writeRequest);
|
|
456
|
-
agentContext.config.logger.debug(`Registered revocation registry definition '${didIndyRevocationRegistryDefinitionId}' on ledger '${pool.indyNamespace}'`, {
|
|
457
|
-
response,
|
|
458
|
-
revocationRegistryDefinition,
|
|
459
|
-
});
|
|
460
|
-
return {
|
|
461
|
-
revocationRegistryDefinitionMetadata: {},
|
|
462
|
-
revocationRegistryDefinitionState: {
|
|
463
|
-
revocationRegistryDefinition,
|
|
464
|
-
revocationRegistryDefinitionId: didIndyRevocationRegistryDefinitionId,
|
|
465
|
-
state: 'finished',
|
|
466
|
-
},
|
|
467
|
-
registrationMetadata: {},
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
catch (error) {
|
|
471
|
-
agentContext.config.logger.error(`Error registering revocation registry definition for credential definition '${revocationRegistryDefinition.credDefId}'`, {
|
|
472
|
-
error,
|
|
473
|
-
did: revocationRegistryDefinition.issuerId,
|
|
474
|
-
revocationRegistryDefinition,
|
|
475
|
-
});
|
|
476
|
-
return {
|
|
477
|
-
revocationRegistryDefinitionMetadata: {},
|
|
478
|
-
registrationMetadata: {},
|
|
479
|
-
revocationRegistryDefinitionState: {
|
|
480
|
-
revocationRegistryDefinition,
|
|
481
|
-
state: 'failed',
|
|
482
|
-
reason: `unknownError: ${error.message}`,
|
|
483
|
-
},
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
async getRevocationStatusList(agentContext, revocationRegistryDefinitionId, timestamp) {
|
|
488
|
-
try {
|
|
489
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
490
|
-
const { did } = (0, anoncreds_1.parseIndyRevocationRegistryId)(revocationRegistryDefinitionId);
|
|
491
|
-
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
492
|
-
const revocationDelta = await this.fetchIndyRevocationDelta(agentContext, revocationRegistryDefinitionId, timestamp);
|
|
493
|
-
if (!revocationDelta) {
|
|
494
|
-
return {
|
|
495
|
-
resolutionMetadata: {
|
|
496
|
-
error: 'notFound',
|
|
497
|
-
message: `Error retrieving revocation registry delta '${revocationRegistryDefinitionId}' from ledger, potentially revocation interval ends before revocation registry creation`,
|
|
498
|
-
},
|
|
499
|
-
revocationStatusListMetadata: {},
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
const { revocationRegistryDefinition, resolutionMetadata, revocationRegistryDefinitionMetadata } = await this.getRevocationRegistryDefinition(agentContext, revocationRegistryDefinitionId);
|
|
503
|
-
if (!revocationRegistryDefinition ||
|
|
504
|
-
!revocationRegistryDefinitionMetadata.issuanceType ||
|
|
505
|
-
typeof revocationRegistryDefinitionMetadata.issuanceType !== 'string') {
|
|
506
|
-
return {
|
|
507
|
-
resolutionMetadata: {
|
|
508
|
-
error: `error resolving revocation registry definition with id ${revocationRegistryDefinitionId}: ${resolutionMetadata.error} ${resolutionMetadata.message}`,
|
|
509
|
-
},
|
|
510
|
-
revocationStatusListMetadata: {
|
|
511
|
-
didIndyNamespace: pool.indyNamespace,
|
|
512
|
-
},
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
const isIssuanceByDefault = revocationRegistryDefinitionMetadata.issuanceType === 'ISSUANCE_BY_DEFAULT';
|
|
516
|
-
return {
|
|
517
|
-
resolutionMetadata: {},
|
|
518
|
-
revocationStatusList: (0, transform_1.anonCredsRevocationStatusListFromIndyVdr)(revocationRegistryDefinitionId, revocationRegistryDefinition, revocationDelta, isIssuanceByDefault),
|
|
519
|
-
revocationStatusListMetadata: {
|
|
520
|
-
didIndyNamespace: pool.indyNamespace,
|
|
521
|
-
},
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
catch (error) {
|
|
525
|
-
agentContext.config.logger.error(`Error retrieving revocation registry delta '${revocationRegistryDefinitionId}' from ledger, potentially revocation interval ends before revocation registry creation?"`, {
|
|
526
|
-
error,
|
|
527
|
-
revocationRegistryId: revocationRegistryDefinitionId,
|
|
528
|
-
});
|
|
529
|
-
return {
|
|
530
|
-
resolutionMetadata: {
|
|
531
|
-
error: 'notFound',
|
|
532
|
-
message: `Error retrieving revocation registry delta '${revocationRegistryDefinitionId}' from ledger, potentially revocation interval ends before revocation registry creation: ${error.message}`,
|
|
533
|
-
},
|
|
534
|
-
revocationStatusListMetadata: {},
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
async registerRevocationStatusList(agentContext, { options, revocationStatusList }) {
|
|
539
|
-
try {
|
|
540
|
-
// This will throw an error if trying to register a revocation status list with a legacy indy identifier. We only support did:indy
|
|
541
|
-
// identifiers for registering, that will allow us to extract the namespace and means all stored records will use did:indy identifiers.
|
|
542
|
-
const { endorsedTransaction, endorserDid, endorserMode } = options;
|
|
543
|
-
const { namespaceIdentifier, namespace } = (0, anoncreds_1.parseIndyDid)(revocationStatusList.issuerId);
|
|
544
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
545
|
-
const pool = indyVdrPoolService.getPoolForNamespace(namespace);
|
|
546
|
-
agentContext.config.logger.debug(`Registering revocation status list on ledger '${namespace}' with did '${revocationStatusList.issuerId}'`, revocationStatusList);
|
|
547
|
-
let writeRequest;
|
|
548
|
-
// Parse the revocation registry id
|
|
549
|
-
const { schemaSeqNo, credentialDefinitionTag, namespaceIdentifier: revocationRegistryNamespaceIdentifier, revocationRegistryTag, namespace: revocationRegistryNamespace, } = (0, anoncreds_1.parseIndyRevocationRegistryId)(revocationStatusList.revRegDefId);
|
|
550
|
-
const legacyRevocationRegistryDefinitionId = (0, anoncreds_1.getUnqualifiedRevocationRegistryDefinitionId)(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag);
|
|
551
|
-
const didIndyRevocationRegistryEntryId = (0, identifiers_1.getDidIndyRevocationRegistryEntryId)(namespace, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag);
|
|
552
|
-
if (revocationRegistryNamespace && revocationRegistryNamespace !== namespace) {
|
|
553
|
-
throw new core_1.CredoError(`Issued id '${revocationStatusList.issuerId}' does not have the same namespace (${namespace}) as the revocation registry definition '${revocationRegistryNamespace}'`);
|
|
554
|
-
}
|
|
555
|
-
if (revocationRegistryNamespaceIdentifier !== namespaceIdentifier) {
|
|
556
|
-
throw new core_1.CredoError(`Cannot register revocation registry definition using a different DID. Revocation registry definition contains '${revocationRegistryNamespaceIdentifier}', but DID used was '${namespaceIdentifier}'`);
|
|
557
|
-
}
|
|
558
|
-
if (endorsedTransaction) {
|
|
559
|
-
agentContext.config.logger.debug(`Preparing endorsed tx '${endorsedTransaction}' for submission on ledger '${namespace}' with did '${revocationStatusList.issuerId}'`, revocationStatusList);
|
|
560
|
-
writeRequest = new indy_vdr_shared_1.CustomRequest({ customRequest: endorsedTransaction });
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
const previousDelta = await this.fetchIndyRevocationDelta(agentContext, legacyRevocationRegistryDefinitionId,
|
|
564
|
-
// Fetch revocation delta for current timestamp
|
|
565
|
-
(0, anoncreds_1.dateToTimestamp)(new Date()));
|
|
566
|
-
const revocationRegistryDefinitionEntryValue = (0, transform_1.indyVdrCreateLatestRevocationDelta)(revocationStatusList.currentAccumulator, revocationStatusList.revocationList, previousDelta !== null && previousDelta !== void 0 ? previousDelta : undefined);
|
|
567
|
-
const revocationRegistryDefinitionRequest = new indy_vdr_shared_1.RevocationRegistryEntryRequest({
|
|
568
|
-
submitterDid: namespaceIdentifier,
|
|
569
|
-
revocationRegistryEntry: {
|
|
570
|
-
ver: '1.0',
|
|
571
|
-
value: revocationRegistryDefinitionEntryValue,
|
|
572
|
-
},
|
|
573
|
-
revocationRegistryDefinitionType: 'CL_ACCUM',
|
|
574
|
-
revocationRegistryDefinitionId: legacyRevocationRegistryDefinitionId,
|
|
575
|
-
});
|
|
576
|
-
const submitterKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(agentContext, revocationStatusList.issuerId);
|
|
577
|
-
writeRequest = await pool.prepareWriteRequest(agentContext, revocationRegistryDefinitionRequest, submitterKey, endorserDid !== revocationStatusList.issuerId ? endorserDid : undefined);
|
|
578
|
-
if (endorserMode === 'external') {
|
|
579
|
-
return {
|
|
580
|
-
jobId: didIndyRevocationRegistryEntryId,
|
|
581
|
-
revocationStatusListState: {
|
|
582
|
-
state: 'action',
|
|
583
|
-
action: 'endorseIndyTransaction',
|
|
584
|
-
revocationStatusList,
|
|
585
|
-
revocationStatusListRequest: writeRequest.body,
|
|
586
|
-
},
|
|
587
|
-
registrationMetadata: {},
|
|
588
|
-
revocationStatusListMetadata: {},
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
if (endorserMode === 'internal' && endorserDid !== revocationStatusList.issuerId) {
|
|
592
|
-
const endorserKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(agentContext, endorserDid);
|
|
593
|
-
await (0, sign_1.multiSignRequest)(agentContext, writeRequest, endorserKey, (0, anoncreds_1.parseIndyDid)(endorserDid).namespaceIdentifier);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
const response = await pool.submitRequest(writeRequest);
|
|
597
|
-
agentContext.config.logger.debug(`Registered revocation status list '${didIndyRevocationRegistryEntryId}' on ledger '${pool.indyNamespace}'`, {
|
|
598
|
-
response,
|
|
599
|
-
revocationStatusList,
|
|
600
|
-
});
|
|
601
|
-
return {
|
|
602
|
-
revocationStatusListMetadata: {},
|
|
603
|
-
revocationStatusListState: {
|
|
604
|
-
revocationStatusList: Object.assign(Object.assign({}, revocationStatusList), { timestamp: response.result.txnMetadata.txnTime }),
|
|
605
|
-
state: 'finished',
|
|
606
|
-
},
|
|
607
|
-
registrationMetadata: {},
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
catch (error) {
|
|
611
|
-
agentContext.config.logger.error(`Error registering revocation status list for revocation registry definition '${revocationStatusList.revRegDefId}}'`, {
|
|
612
|
-
error,
|
|
613
|
-
did: revocationStatusList.issuerId,
|
|
614
|
-
});
|
|
615
|
-
return {
|
|
616
|
-
registrationMetadata: {},
|
|
617
|
-
revocationStatusListMetadata: {},
|
|
618
|
-
revocationStatusListState: {
|
|
619
|
-
revocationStatusList,
|
|
620
|
-
state: 'failed',
|
|
621
|
-
reason: `unknownError: ${error.message}`,
|
|
622
|
-
},
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
async fetchIndySchemaWithSeqNo(agentContext, seqNo, did) {
|
|
627
|
-
var _a, _b, _c;
|
|
628
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
629
|
-
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
630
|
-
agentContext.config.logger.debug(`Getting transaction with seqNo '${seqNo}' from ledger '${pool.indyNamespace}'`);
|
|
631
|
-
// ledgerType 1 is domain ledger
|
|
632
|
-
const request = new indy_vdr_shared_1.GetTransactionRequest({ ledgerType: 1, seqNo });
|
|
633
|
-
agentContext.config.logger.trace(`Submitting get transaction request to ledger '${pool.indyNamespace}'`);
|
|
634
|
-
const response = await pool.submitRequest(request);
|
|
635
|
-
if (((_a = response.result.data) === null || _a === void 0 ? void 0 : _a.txn.type) !== '101') {
|
|
636
|
-
agentContext.config.logger.error(`Could not get schema from ledger for seq no ${seqNo}'`);
|
|
637
|
-
return null;
|
|
638
|
-
}
|
|
639
|
-
const schema = (_b = response.result.data) === null || _b === void 0 ? void 0 : _b.txn.data;
|
|
640
|
-
const schemaDid = (_c = response.result.data) === null || _c === void 0 ? void 0 : _c.txn.metadata.from;
|
|
641
|
-
const schemaId = (0, anoncreds_1.getUnqualifiedSchemaId)(schemaDid, schema.data.name, schema.data.version);
|
|
642
|
-
return {
|
|
643
|
-
schema: {
|
|
644
|
-
schemaId,
|
|
645
|
-
attr_name: schema.data.attr_names,
|
|
646
|
-
name: schema.data.name,
|
|
647
|
-
version: schema.data.version,
|
|
648
|
-
issuerId: schemaDid,
|
|
649
|
-
seqNo,
|
|
650
|
-
},
|
|
651
|
-
indyNamespace: pool.indyNamespace,
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
async fetchIndyRevocationDelta(agentContext, revocationRegistryDefinitionId, toTs) {
|
|
655
|
-
const indyVdrPoolService = agentContext.dependencyManager.resolve(pool_1.IndyVdrPoolService);
|
|
656
|
-
const { did, namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag } = (0, anoncreds_1.parseIndyRevocationRegistryId)(revocationRegistryDefinitionId);
|
|
657
|
-
const { pool } = await indyVdrPoolService.getPoolForDid(agentContext, did);
|
|
658
|
-
agentContext.config.logger.debug(`Using ledger '${pool.indyNamespace}' to retrieve revocation registry deltas with revocation registry definition id '${revocationRegistryDefinitionId}' until ${toTs}`);
|
|
659
|
-
const legacyRevocationRegistryDefinitionId = (0, anoncreds_1.getUnqualifiedRevocationRegistryDefinitionId)(namespaceIdentifier, schemaSeqNo, credentialDefinitionTag, revocationRegistryTag);
|
|
660
|
-
const deltaRequest = new indy_vdr_shared_1.GetRevocationRegistryDeltaRequest({
|
|
661
|
-
toTs,
|
|
662
|
-
submitterDid: namespaceIdentifier,
|
|
663
|
-
revocationRegistryId: legacyRevocationRegistryDefinitionId,
|
|
664
|
-
});
|
|
665
|
-
agentContext.config.logger.trace(`Submitting get transaction request to ledger '${pool.indyNamespace}'`);
|
|
666
|
-
const response = await pool.submitRequest(deltaRequest);
|
|
667
|
-
const { result: { data, type, txnTime }, } = response;
|
|
668
|
-
// Indicating there are no deltas
|
|
669
|
-
if (type !== '117' || data === null || !txnTime) {
|
|
670
|
-
agentContext.config.logger.warn(`Could not get any deltas from ledger for revocation registry definition '${revocationRegistryDefinitionId}' from ledger '${pool.indyNamespace}'`);
|
|
671
|
-
return null;
|
|
672
|
-
}
|
|
673
|
-
return {
|
|
674
|
-
revoked: data.value.revoked,
|
|
675
|
-
issued: data.value.issued,
|
|
676
|
-
accum: data.value.accum_to.value.accum,
|
|
677
|
-
txnTime,
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
exports.IndyVdrAnonCredsRegistry = IndyVdrAnonCredsRegistry;
|
|
682
|
-
//# sourceMappingURL=IndyVdrAnonCredsRegistry.js.map
|