@0xpolygonid/js-sdk 1.8.0 → 1.8.2
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/dist/browser/esm/index.js +66 -25
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +66 -25
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/atomic-query-v3-on-chain.js +22 -14
- package/dist/node/cjs/credentials/credential-wallet.js +10 -0
- package/dist/node/cjs/identity/identity-wallet.js +31 -6
- package/dist/node/cjs/proof/provers/inputs-generator.js +3 -5
- package/dist/node/esm/circuits/atomic-query-v3-on-chain.js +22 -14
- package/dist/node/esm/credentials/credential-wallet.js +10 -0
- package/dist/node/esm/identity/identity-wallet.js +32 -7
- package/dist/node/esm/proof/provers/inputs-generator.js +3 -5
- package/dist/types/credentials/credential-wallet.d.ts +12 -1
- package/dist/types/iden3comm/types/protocol/auth.d.ts +5 -1
- package/dist/types/identity/identity-wallet.d.ts +24 -0
- package/package.json +1 -1
|
@@ -119,7 +119,10 @@ class AtomicQueryV3OnChainInputs extends common_1.BaseConfig {
|
|
|
119
119
|
valueProof.value = 0n;
|
|
120
120
|
valueProof.mtp = new js_merkletree_1.Proof();
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
let treeState = this.claim.nonRevProof.treeState;
|
|
123
|
+
if (this.proofType === verifiable_1.ProofType.BJJSignature && this.skipClaimRevocationCheck) {
|
|
124
|
+
treeState = this.claim.signatureProof?.issuerAuthNonRevProof.treeState;
|
|
125
|
+
}
|
|
123
126
|
if (!treeState) {
|
|
124
127
|
throw new Error(models_1.CircuitError.EmptyTreeState);
|
|
125
128
|
}
|
|
@@ -175,27 +178,32 @@ class AtomicQueryV3OnChainInputs extends common_1.BaseConfig {
|
|
|
175
178
|
s.isRevocationChecked = 0;
|
|
176
179
|
}
|
|
177
180
|
if (this.proofType === verifiable_1.ProofType.BJJSignature) {
|
|
181
|
+
const sigProof = this.claim.signatureProof;
|
|
178
182
|
s.proofType = '1';
|
|
179
|
-
s.issuerClaimSignatureR8x =
|
|
180
|
-
s.issuerClaimSignatureR8y =
|
|
181
|
-
s.issuerClaimSignatureS =
|
|
182
|
-
s.issuerAuthClaim =
|
|
183
|
-
s.issuerAuthClaimMtp = (0, common_1.prepareSiblingsStr)(
|
|
183
|
+
s.issuerClaimSignatureR8x = sigProof.signature.R8[0].toString();
|
|
184
|
+
s.issuerClaimSignatureR8y = sigProof.signature.R8[1].toString();
|
|
185
|
+
s.issuerClaimSignatureS = sigProof.signature.S.toString();
|
|
186
|
+
s.issuerAuthClaim = sigProof.issuerAuthClaim?.marshalJson();
|
|
187
|
+
s.issuerAuthClaimMtp = (0, common_1.prepareSiblingsStr)(sigProof.issuerAuthIncProof.proof, this.getMTLevel());
|
|
184
188
|
const issuerAuthTreeState = this.claim.nonRevProof.treeState;
|
|
185
189
|
if (!issuerAuthTreeState) {
|
|
186
190
|
throw new Error(models_1.CircuitError.EmptyTreeState);
|
|
187
191
|
}
|
|
188
|
-
s.issuerAuthClaimsTreeRoot =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
s.
|
|
192
|
-
|
|
192
|
+
s.issuerAuthClaimsTreeRoot = sigProof.issuerAuthIncProof.treeState?.claimsRoot
|
|
193
|
+
.bigInt()
|
|
194
|
+
.toString();
|
|
195
|
+
s.issuerAuthRevTreeRoot = sigProof.issuerAuthIncProof.treeState?.revocationRoot
|
|
196
|
+
.bigInt()
|
|
197
|
+
.toString();
|
|
198
|
+
s.issuerAuthRootsTreeRoot = sigProof.issuerAuthIncProof.treeState?.rootOfRoots
|
|
199
|
+
.bigInt()
|
|
200
|
+
.toString();
|
|
201
|
+
s.issuerAuthClaimNonRevMtp = (0, common_1.prepareSiblingsStr)(sigProof.issuerAuthNonRevProof.proof, this.getMTLevel());
|
|
202
|
+
const nodeAuxIssuerAuthNonRev = (0, common_1.getNodeAuxValue)(sigProof.issuerAuthNonRevProof.proof);
|
|
193
203
|
s.issuerAuthClaimNonRevMtpAuxHi = nodeAuxIssuerAuthNonRev.key.bigInt().toString();
|
|
194
204
|
s.issuerAuthClaimNonRevMtpAuxHv = nodeAuxIssuerAuthNonRev.value.bigInt().toString();
|
|
195
205
|
s.issuerAuthClaimNonRevMtpNoAux = nodeAuxIssuerAuthNonRev.noAux;
|
|
196
|
-
s.issuerAuthState =
|
|
197
|
-
.bigInt()
|
|
198
|
-
.toString();
|
|
206
|
+
s.issuerAuthState = sigProof.issuerAuthIncProof.treeState?.state.bigInt().toString();
|
|
199
207
|
this.fillMTPProofsWithZero(s);
|
|
200
208
|
}
|
|
201
209
|
else if (this.proofType === verifiable_1.ProofType.Iden3SparseMerkleTreeProof) {
|
|
@@ -115,6 +115,16 @@ class CredentialWallet {
|
|
|
115
115
|
}
|
|
116
116
|
throw new Error('all auth bjj credentials are revoked');
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* {@inheritDoc ICredentialWallet.getAllAuthBJJCredentials}
|
|
120
|
+
*/
|
|
121
|
+
async getAllAuthBJJCredentials(did) {
|
|
122
|
+
return this._storage.credential.findCredentialsByQuery({
|
|
123
|
+
context: verifiable_1.VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL,
|
|
124
|
+
type: verifiable_1.VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,
|
|
125
|
+
allowedIssuers: [did.string()]
|
|
126
|
+
});
|
|
127
|
+
}
|
|
118
128
|
/**
|
|
119
129
|
* {@inheritDoc ICredentialWallet.getRevocationStatusFromCredential}
|
|
120
130
|
*/
|
|
@@ -61,13 +61,19 @@ class IdentityWallet {
|
|
|
61
61
|
this._storage = _storage;
|
|
62
62
|
this._credentialWallet = _credentialWallet;
|
|
63
63
|
this._opts = _opts;
|
|
64
|
+
this._credentialStatusPublisherRegistry = this.getCredentialStatusPublisherRegistry(_opts);
|
|
65
|
+
}
|
|
66
|
+
getCredentialStatusPublisherRegistry(_opts) {
|
|
64
67
|
if (!_opts?.credentialStatusPublisherRegistry) {
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
const registry = new credential_status_publisher_1.CredentialStatusPublisherRegistry();
|
|
69
|
+
const emptyPublisher = { publish: () => Promise.resolve() };
|
|
70
|
+
registry.register(verifiable_1.CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, new credential_status_publisher_1.Iden3SmtRhsCredentialStatusPublisher());
|
|
71
|
+
registry.register(verifiable_1.CredentialStatusType.SparseMerkleTreeProof, emptyPublisher);
|
|
72
|
+
registry.register(verifiable_1.CredentialStatusType.Iden3commRevocationStatusV1, emptyPublisher);
|
|
73
|
+
return registry;
|
|
67
74
|
}
|
|
68
75
|
else {
|
|
69
|
-
|
|
70
|
-
?.credentialStatusPublisherRegistry;
|
|
76
|
+
return this._opts?.credentialStatusPublisherRegistry;
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
@@ -305,7 +311,7 @@ class IdentityWallet {
|
|
|
305
311
|
catch (e) {
|
|
306
312
|
throw new Error(`Error create w3c credential ${e.message}`);
|
|
307
313
|
}
|
|
308
|
-
const issuerAuthBJJCredential = await this.
|
|
314
|
+
const { authCredential: issuerAuthBJJCredential } = await this.getActualAuthCredential(issuerDID);
|
|
309
315
|
const coreClaimOpts = {
|
|
310
316
|
revNonce: req.revocationOpts.nonce,
|
|
311
317
|
subjectPosition: req.subjectPosition,
|
|
@@ -314,7 +320,7 @@ class IdentityWallet {
|
|
|
314
320
|
version: 0,
|
|
315
321
|
merklizeOpts: { ...opts, documentLoader: loader }
|
|
316
322
|
};
|
|
317
|
-
const coreClaim = await
|
|
323
|
+
const coreClaim = await credential.toCoreClaim(coreClaimOpts);
|
|
318
324
|
const { hi, hv } = coreClaim.hiHv();
|
|
319
325
|
const coreClaimHash = js_crypto_1.poseidon.hash([hi, hv]);
|
|
320
326
|
const signature = await this.signChallenge(coreClaimHash, issuerAuthBJJCredential);
|
|
@@ -339,6 +345,25 @@ class IdentityWallet {
|
|
|
339
345
|
credential.proof = [sigProof];
|
|
340
346
|
return credential;
|
|
341
347
|
}
|
|
348
|
+
/** {@inheritDoc IIdentityWallet.getActualAuthCredential} */
|
|
349
|
+
async getActualAuthCredential(did, treeStateInfo) {
|
|
350
|
+
const authCredentials = await this._credentialWallet.getAllAuthBJJCredentials(did);
|
|
351
|
+
for (let i = 0; i < authCredentials.length; i++) {
|
|
352
|
+
const incProof = await this.generateCredentialMtp(did, authCredentials[i], treeStateInfo);
|
|
353
|
+
if (!incProof.proof.existence) {
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
const nonRevProof = await this.generateNonRevocationMtp(did, authCredentials[i], treeStateInfo);
|
|
357
|
+
if (!nonRevProof.proof.existence) {
|
|
358
|
+
return {
|
|
359
|
+
authCredential: authCredentials[i],
|
|
360
|
+
incProof,
|
|
361
|
+
nonRevProof
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
throw new Error('no auth credentials found');
|
|
366
|
+
}
|
|
342
367
|
/** {@inheritDoc IIdentityWallet.revokeCredential} */
|
|
343
368
|
async revokeCredential(issuerDID, credential) {
|
|
344
369
|
const issuerTree = await this.getDIDTreeModel(issuerDID);
|
|
@@ -265,8 +265,8 @@ class InputGenerator {
|
|
|
265
265
|
circuitInputs.proofType = proofType;
|
|
266
266
|
circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
|
|
267
267
|
circuitInputs.verifierID = params.verifierDid ? js_iden3_core_1.DID.idFromDID(params.verifierDid) : undefined;
|
|
268
|
-
circuitInputs.nullifierSessionID = proofReq.params?.
|
|
269
|
-
? BigInt(proofReq.params?.
|
|
268
|
+
circuitInputs.nullifierSessionID = proofReq.params?.nullifierSessionId
|
|
269
|
+
? BigInt(proofReq.params?.nullifierSessionId?.toString())
|
|
270
270
|
: BigInt(0);
|
|
271
271
|
let isEthIdentity = true;
|
|
272
272
|
try {
|
|
@@ -375,9 +375,7 @@ class InputGenerator {
|
|
|
375
375
|
return circuitClaim;
|
|
376
376
|
}
|
|
377
377
|
async prepareAuthBJJCredential(did, treeStateInfo) {
|
|
378
|
-
const authCredential = await this.
|
|
379
|
-
const incProof = await this._identityWallet.generateCredentialMtp(did, authCredential, treeStateInfo);
|
|
380
|
-
const nonRevProof = await this._identityWallet.generateNonRevocationMtp(did, authCredential, treeStateInfo);
|
|
378
|
+
const { authCredential, incProof, nonRevProof } = await this._identityWallet.getActualAuthCredential(did, treeStateInfo);
|
|
381
379
|
const authCoreClaim = authCredential.getCoreClaimFromProof(verifiable_1.ProofType.Iden3SparseMerkleTreeProof);
|
|
382
380
|
if (!authCoreClaim) {
|
|
383
381
|
throw new Error('auth core claim is not defined for auth bjj credential');
|
|
@@ -116,7 +116,10 @@ export class AtomicQueryV3OnChainInputs extends BaseConfig {
|
|
|
116
116
|
valueProof.value = 0n;
|
|
117
117
|
valueProof.mtp = new Proof();
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
let treeState = this.claim.nonRevProof.treeState;
|
|
120
|
+
if (this.proofType === ProofType.BJJSignature && this.skipClaimRevocationCheck) {
|
|
121
|
+
treeState = this.claim.signatureProof?.issuerAuthNonRevProof.treeState;
|
|
122
|
+
}
|
|
120
123
|
if (!treeState) {
|
|
121
124
|
throw new Error(CircuitError.EmptyTreeState);
|
|
122
125
|
}
|
|
@@ -172,27 +175,32 @@ export class AtomicQueryV3OnChainInputs extends BaseConfig {
|
|
|
172
175
|
s.isRevocationChecked = 0;
|
|
173
176
|
}
|
|
174
177
|
if (this.proofType === ProofType.BJJSignature) {
|
|
178
|
+
const sigProof = this.claim.signatureProof;
|
|
175
179
|
s.proofType = '1';
|
|
176
|
-
s.issuerClaimSignatureR8x =
|
|
177
|
-
s.issuerClaimSignatureR8y =
|
|
178
|
-
s.issuerClaimSignatureS =
|
|
179
|
-
s.issuerAuthClaim =
|
|
180
|
-
s.issuerAuthClaimMtp = prepareSiblingsStr(
|
|
180
|
+
s.issuerClaimSignatureR8x = sigProof.signature.R8[0].toString();
|
|
181
|
+
s.issuerClaimSignatureR8y = sigProof.signature.R8[1].toString();
|
|
182
|
+
s.issuerClaimSignatureS = sigProof.signature.S.toString();
|
|
183
|
+
s.issuerAuthClaim = sigProof.issuerAuthClaim?.marshalJson();
|
|
184
|
+
s.issuerAuthClaimMtp = prepareSiblingsStr(sigProof.issuerAuthIncProof.proof, this.getMTLevel());
|
|
181
185
|
const issuerAuthTreeState = this.claim.nonRevProof.treeState;
|
|
182
186
|
if (!issuerAuthTreeState) {
|
|
183
187
|
throw new Error(CircuitError.EmptyTreeState);
|
|
184
188
|
}
|
|
185
|
-
s.issuerAuthClaimsTreeRoot =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
s.
|
|
189
|
-
|
|
189
|
+
s.issuerAuthClaimsTreeRoot = sigProof.issuerAuthIncProof.treeState?.claimsRoot
|
|
190
|
+
.bigInt()
|
|
191
|
+
.toString();
|
|
192
|
+
s.issuerAuthRevTreeRoot = sigProof.issuerAuthIncProof.treeState?.revocationRoot
|
|
193
|
+
.bigInt()
|
|
194
|
+
.toString();
|
|
195
|
+
s.issuerAuthRootsTreeRoot = sigProof.issuerAuthIncProof.treeState?.rootOfRoots
|
|
196
|
+
.bigInt()
|
|
197
|
+
.toString();
|
|
198
|
+
s.issuerAuthClaimNonRevMtp = prepareSiblingsStr(sigProof.issuerAuthNonRevProof.proof, this.getMTLevel());
|
|
199
|
+
const nodeAuxIssuerAuthNonRev = getNodeAuxValue(sigProof.issuerAuthNonRevProof.proof);
|
|
190
200
|
s.issuerAuthClaimNonRevMtpAuxHi = nodeAuxIssuerAuthNonRev.key.bigInt().toString();
|
|
191
201
|
s.issuerAuthClaimNonRevMtpAuxHv = nodeAuxIssuerAuthNonRev.value.bigInt().toString();
|
|
192
202
|
s.issuerAuthClaimNonRevMtpNoAux = nodeAuxIssuerAuthNonRev.noAux;
|
|
193
|
-
s.issuerAuthState =
|
|
194
|
-
.bigInt()
|
|
195
|
-
.toString();
|
|
203
|
+
s.issuerAuthState = sigProof.issuerAuthIncProof.treeState?.state.bigInt().toString();
|
|
196
204
|
this.fillMTPProofsWithZero(s);
|
|
197
205
|
}
|
|
198
206
|
else if (this.proofType === ProofType.Iden3SparseMerkleTreeProof) {
|
|
@@ -89,6 +89,16 @@ export class CredentialWallet {
|
|
|
89
89
|
}
|
|
90
90
|
throw new Error('all auth bjj credentials are revoked');
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* {@inheritDoc ICredentialWallet.getAllAuthBJJCredentials}
|
|
94
|
+
*/
|
|
95
|
+
async getAllAuthBJJCredentials(did) {
|
|
96
|
+
return this._storage.credential.findCredentialsByQuery({
|
|
97
|
+
context: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL,
|
|
98
|
+
type: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,
|
|
99
|
+
allowedIssuers: [did.string()]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
92
102
|
/**
|
|
93
103
|
* {@inheritDoc ICredentialWallet.getRevocationStatusFromCredential}
|
|
94
104
|
*/
|
|
@@ -4,7 +4,7 @@ import { poseidon, PublicKey, sha256, Signature, Hex, getRandomBytes } from '@id
|
|
|
4
4
|
import { hashElems, ZERO_HASH } from '@iden3/js-merkletree';
|
|
5
5
|
import { generateProfileDID, subjectPositionIndex } from './common';
|
|
6
6
|
import * as uuid from 'uuid';
|
|
7
|
-
import {
|
|
7
|
+
import { JsonSchemaValidator, cacheLoader } from '../schema-processor';
|
|
8
8
|
import { MerkleTreeType } from '../storage';
|
|
9
9
|
import { VerifiableConstants, BJJSignatureProof2021, MerklizedRootPosition, SubjectPosition, W3CCredential, Iden3SparseMerkleTreeProof, ProofType, CredentialStatusType } from '../verifiable';
|
|
10
10
|
import { getKMSIdByAuthCredential, getNodesRepresentation, pushHashesToRHS } from '../credentials';
|
|
@@ -35,13 +35,19 @@ export class IdentityWallet {
|
|
|
35
35
|
this._storage = _storage;
|
|
36
36
|
this._credentialWallet = _credentialWallet;
|
|
37
37
|
this._opts = _opts;
|
|
38
|
+
this._credentialStatusPublisherRegistry = this.getCredentialStatusPublisherRegistry(_opts);
|
|
39
|
+
}
|
|
40
|
+
getCredentialStatusPublisherRegistry(_opts) {
|
|
38
41
|
if (!_opts?.credentialStatusPublisherRegistry) {
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
const registry = new CredentialStatusPublisherRegistry();
|
|
43
|
+
const emptyPublisher = { publish: () => Promise.resolve() };
|
|
44
|
+
registry.register(CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, new Iden3SmtRhsCredentialStatusPublisher());
|
|
45
|
+
registry.register(CredentialStatusType.SparseMerkleTreeProof, emptyPublisher);
|
|
46
|
+
registry.register(CredentialStatusType.Iden3commRevocationStatusV1, emptyPublisher);
|
|
47
|
+
return registry;
|
|
41
48
|
}
|
|
42
49
|
else {
|
|
43
|
-
|
|
44
|
-
?.credentialStatusPublisherRegistry;
|
|
50
|
+
return this._opts?.credentialStatusPublisherRegistry;
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
/**
|
|
@@ -279,7 +285,7 @@ export class IdentityWallet {
|
|
|
279
285
|
catch (e) {
|
|
280
286
|
throw new Error(`Error create w3c credential ${e.message}`);
|
|
281
287
|
}
|
|
282
|
-
const issuerAuthBJJCredential = await this.
|
|
288
|
+
const { authCredential: issuerAuthBJJCredential } = await this.getActualAuthCredential(issuerDID);
|
|
283
289
|
const coreClaimOpts = {
|
|
284
290
|
revNonce: req.revocationOpts.nonce,
|
|
285
291
|
subjectPosition: req.subjectPosition,
|
|
@@ -288,7 +294,7 @@ export class IdentityWallet {
|
|
|
288
294
|
version: 0,
|
|
289
295
|
merklizeOpts: { ...opts, documentLoader: loader }
|
|
290
296
|
};
|
|
291
|
-
const coreClaim = await
|
|
297
|
+
const coreClaim = await credential.toCoreClaim(coreClaimOpts);
|
|
292
298
|
const { hi, hv } = coreClaim.hiHv();
|
|
293
299
|
const coreClaimHash = poseidon.hash([hi, hv]);
|
|
294
300
|
const signature = await this.signChallenge(coreClaimHash, issuerAuthBJJCredential);
|
|
@@ -313,6 +319,25 @@ export class IdentityWallet {
|
|
|
313
319
|
credential.proof = [sigProof];
|
|
314
320
|
return credential;
|
|
315
321
|
}
|
|
322
|
+
/** {@inheritDoc IIdentityWallet.getActualAuthCredential} */
|
|
323
|
+
async getActualAuthCredential(did, treeStateInfo) {
|
|
324
|
+
const authCredentials = await this._credentialWallet.getAllAuthBJJCredentials(did);
|
|
325
|
+
for (let i = 0; i < authCredentials.length; i++) {
|
|
326
|
+
const incProof = await this.generateCredentialMtp(did, authCredentials[i], treeStateInfo);
|
|
327
|
+
if (!incProof.proof.existence) {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
const nonRevProof = await this.generateNonRevocationMtp(did, authCredentials[i], treeStateInfo);
|
|
331
|
+
if (!nonRevProof.proof.existence) {
|
|
332
|
+
return {
|
|
333
|
+
authCredential: authCredentials[i],
|
|
334
|
+
incProof,
|
|
335
|
+
nonRevProof
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
throw new Error('no auth credentials found');
|
|
340
|
+
}
|
|
316
341
|
/** {@inheritDoc IIdentityWallet.revokeCredential} */
|
|
317
342
|
async revokeCredential(issuerDID, credential) {
|
|
318
343
|
const issuerTree = await this.getDIDTreeModel(issuerDID);
|
|
@@ -262,8 +262,8 @@ export class InputGenerator {
|
|
|
262
262
|
circuitInputs.proofType = proofType;
|
|
263
263
|
circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
|
|
264
264
|
circuitInputs.verifierID = params.verifierDid ? DID.idFromDID(params.verifierDid) : undefined;
|
|
265
|
-
circuitInputs.nullifierSessionID = proofReq.params?.
|
|
266
|
-
? BigInt(proofReq.params?.
|
|
265
|
+
circuitInputs.nullifierSessionID = proofReq.params?.nullifierSessionId
|
|
266
|
+
? BigInt(proofReq.params?.nullifierSessionId?.toString())
|
|
267
267
|
: BigInt(0);
|
|
268
268
|
let isEthIdentity = true;
|
|
269
269
|
try {
|
|
@@ -372,9 +372,7 @@ export class InputGenerator {
|
|
|
372
372
|
return circuitClaim;
|
|
373
373
|
}
|
|
374
374
|
async prepareAuthBJJCredential(did, treeStateInfo) {
|
|
375
|
-
const authCredential = await this.
|
|
376
|
-
const incProof = await this._identityWallet.generateCredentialMtp(did, authCredential, treeStateInfo);
|
|
377
|
-
const nonRevProof = await this._identityWallet.generateNonRevocationMtp(did, authCredential, treeStateInfo);
|
|
375
|
+
const { authCredential, incProof, nonRevProof } = await this._identityWallet.getActualAuthCredential(did, treeStateInfo);
|
|
378
376
|
const authCoreClaim = authCredential.getCoreClaimFromProof(ProofType.Iden3SparseMerkleTreeProof);
|
|
379
377
|
if (!authCoreClaim) {
|
|
380
378
|
throw new Error('auth core claim is not defined for auth bjj credential');
|
|
@@ -68,12 +68,19 @@ export interface ICredentialWallet {
|
|
|
68
68
|
*/
|
|
69
69
|
filterByCredentialSubject(credentials: W3CCredential[], subject: DID): Promise<W3CCredential[]>;
|
|
70
70
|
/**
|
|
71
|
-
* Finds Auth BJJ credential for given user
|
|
71
|
+
* Finds first non-revoked Auth BJJ credential for given user
|
|
72
72
|
*
|
|
73
73
|
* @param {DID} did - the issuer of Auth BJJ credential
|
|
74
74
|
* @returns `Promise<W3CCredential>` W3CCredential with AuthBJJCredential type
|
|
75
75
|
*/
|
|
76
76
|
getAuthBJJCredential(did: DID): Promise<W3CCredential>;
|
|
77
|
+
/**
|
|
78
|
+
* Finds all Auth BJJ credentials for given user
|
|
79
|
+
*
|
|
80
|
+
* @param {DID} did - the issuer of Auth BJJ credential
|
|
81
|
+
* @returns `Promise<W3CCredential[]>` W3CCredentials with AuthBJJCredential type
|
|
82
|
+
*/
|
|
83
|
+
getAllAuthBJJCredentials(did: DID): Promise<W3CCredential[]>;
|
|
77
84
|
/**
|
|
78
85
|
* Fetches or Builds a revocation status for a given credential
|
|
79
86
|
* Supported types for credentialStatus field: SparseMerkleTreeProof, Iden3ReverseSparseMerkleTreeProof
|
|
@@ -137,6 +144,10 @@ export declare class CredentialWallet implements ICredentialWallet {
|
|
|
137
144
|
* {@inheritDoc ICredentialWallet.getAuthBJJCredential}
|
|
138
145
|
*/
|
|
139
146
|
getAuthBJJCredential(did: DID): Promise<W3CCredential>;
|
|
147
|
+
/**
|
|
148
|
+
* {@inheritDoc ICredentialWallet.getAllAuthBJJCredentials}
|
|
149
|
+
*/
|
|
150
|
+
getAllAuthBJJCredentials(did: DID): Promise<W3CCredential[]>;
|
|
140
151
|
/**
|
|
141
152
|
* {@inheritDoc ICredentialWallet.getRevocationStatusFromCredential}
|
|
142
153
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ZKProof } from '@iden3/js-jwz';
|
|
2
2
|
import { MediaType } from '../../constants';
|
|
3
3
|
import { JSONObject, ProtocolMessage } from '../packer';
|
|
4
|
+
import { DID } from '@iden3/js-iden3-core';
|
|
4
5
|
/** AuthorizationResponseMessage is struct the represents iden3message authorization response */
|
|
5
6
|
export type AuthorizationResponseMessage = {
|
|
6
7
|
id: string;
|
|
@@ -41,7 +42,10 @@ export type ZeroKnowledgeProofRequest = {
|
|
|
41
42
|
circuitId: string;
|
|
42
43
|
optional?: boolean;
|
|
43
44
|
query: JSONObject;
|
|
44
|
-
params?:
|
|
45
|
+
params?: {
|
|
46
|
+
nullifierSessionId?: string | number;
|
|
47
|
+
verifierDid?: DID;
|
|
48
|
+
};
|
|
45
49
|
};
|
|
46
50
|
/** ZeroKnowledgeProofResponse represents structure of zkp response */
|
|
47
51
|
export type ZeroKnowledgeProofResponse = {
|
|
@@ -247,6 +247,23 @@ export interface IIdentityWallet {
|
|
|
247
247
|
* @returns `{Promise<void>}`
|
|
248
248
|
*/
|
|
249
249
|
updateIdentityState(issuerDID: DID, published: boolean, treeState?: TreeState): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
* gets actual auth credential with proofs for provided tree state or latest from the trees.
|
|
253
|
+
*
|
|
254
|
+
* @param {DID} issuerDID - identifier of the issuer
|
|
255
|
+
* @param {TreeState} treeStateInfo - optional, state for retrieval
|
|
256
|
+
* @returns `{Promise<{
|
|
257
|
+
authCredential: W3CCredential;
|
|
258
|
+
incProof: MerkleTreeProofWithTreeState;
|
|
259
|
+
nonRevProof: MerkleTreeProofWithTreeState;
|
|
260
|
+
}>}`
|
|
261
|
+
*/
|
|
262
|
+
getActualAuthCredential(did: DID, treeStateInfo?: TreeState): Promise<{
|
|
263
|
+
authCredential: W3CCredential;
|
|
264
|
+
incProof: MerkleTreeProofWithTreeState;
|
|
265
|
+
nonRevProof: MerkleTreeProofWithTreeState;
|
|
266
|
+
}>;
|
|
250
267
|
}
|
|
251
268
|
/**
|
|
252
269
|
* @public
|
|
@@ -276,6 +293,7 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
276
293
|
constructor(_kms: KMS, _storage: IDataStorage, _credentialWallet: ICredentialWallet, _opts?: {
|
|
277
294
|
credentialStatusPublisherRegistry?: CredentialStatusPublisherRegistry | undefined;
|
|
278
295
|
} | undefined);
|
|
296
|
+
private getCredentialStatusPublisherRegistry;
|
|
279
297
|
/**
|
|
280
298
|
* {@inheritDoc IIdentityWallet.createIdentity}
|
|
281
299
|
*/
|
|
@@ -313,6 +331,12 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
313
331
|
signChallenge(challenge: bigint, credential: W3CCredential): Promise<Signature>;
|
|
314
332
|
/** {@inheritDoc IIdentityWallet.issueCredential} */
|
|
315
333
|
issueCredential(issuerDID: DID, req: CredentialRequest, opts?: Options): Promise<W3CCredential>;
|
|
334
|
+
/** {@inheritDoc IIdentityWallet.getActualAuthCredential} */
|
|
335
|
+
getActualAuthCredential(did: DID, treeStateInfo?: TreeState): Promise<{
|
|
336
|
+
authCredential: W3CCredential;
|
|
337
|
+
incProof: MerkleTreeProofWithTreeState;
|
|
338
|
+
nonRevProof: MerkleTreeProofWithTreeState;
|
|
339
|
+
}>;
|
|
316
340
|
/** {@inheritDoc IIdentityWallet.revokeCredential} */
|
|
317
341
|
revokeCredential(issuerDID: DID, credential: W3CCredential): Promise<number>;
|
|
318
342
|
/** {@inheritDoc IIdentityWallet.addCredentialsToMerkleTree} */
|