@0xpolygonid/js-sdk 1.8.1 → 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 +44 -11
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +44 -11
- package/dist/browser/umd/index.js.map +1 -1
- 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/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
|
@@ -61443,6 +61443,16 @@ class CredentialWallet {
|
|
|
61443
61443
|
}
|
|
61444
61444
|
throw new Error('all auth bjj credentials are revoked');
|
|
61445
61445
|
}
|
|
61446
|
+
/**
|
|
61447
|
+
* {@inheritDoc ICredentialWallet.getAllAuthBJJCredentials}
|
|
61448
|
+
*/
|
|
61449
|
+
async getAllAuthBJJCredentials(did) {
|
|
61450
|
+
return this._storage.credential.findCredentialsByQuery({
|
|
61451
|
+
context: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL,
|
|
61452
|
+
type: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,
|
|
61453
|
+
allowedIssuers: [did.string()]
|
|
61454
|
+
});
|
|
61455
|
+
}
|
|
61446
61456
|
/**
|
|
61447
61457
|
* {@inheritDoc ICredentialWallet.getRevocationStatusFromCredential}
|
|
61448
61458
|
*/
|
|
@@ -61724,13 +61734,19 @@ class IdentityWallet {
|
|
|
61724
61734
|
this._storage = _storage;
|
|
61725
61735
|
this._credentialWallet = _credentialWallet;
|
|
61726
61736
|
this._opts = _opts;
|
|
61737
|
+
this._credentialStatusPublisherRegistry = this.getCredentialStatusPublisherRegistry(_opts);
|
|
61738
|
+
}
|
|
61739
|
+
getCredentialStatusPublisherRegistry(_opts) {
|
|
61727
61740
|
if (!_opts?.credentialStatusPublisherRegistry) {
|
|
61728
|
-
|
|
61729
|
-
|
|
61741
|
+
const registry = new CredentialStatusPublisherRegistry();
|
|
61742
|
+
const emptyPublisher = { publish: () => Promise.resolve() };
|
|
61743
|
+
registry.register(CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, new Iden3SmtRhsCredentialStatusPublisher());
|
|
61744
|
+
registry.register(CredentialStatusType.SparseMerkleTreeProof, emptyPublisher);
|
|
61745
|
+
registry.register(CredentialStatusType.Iden3commRevocationStatusV1, emptyPublisher);
|
|
61746
|
+
return registry;
|
|
61730
61747
|
}
|
|
61731
61748
|
else {
|
|
61732
|
-
|
|
61733
|
-
?.credentialStatusPublisherRegistry;
|
|
61749
|
+
return this._opts?.credentialStatusPublisherRegistry;
|
|
61734
61750
|
}
|
|
61735
61751
|
}
|
|
61736
61752
|
/**
|
|
@@ -61968,7 +61984,7 @@ class IdentityWallet {
|
|
|
61968
61984
|
catch (e) {
|
|
61969
61985
|
throw new Error(`Error create w3c credential ${e.message}`);
|
|
61970
61986
|
}
|
|
61971
|
-
const issuerAuthBJJCredential = await this.
|
|
61987
|
+
const { authCredential: issuerAuthBJJCredential } = await this.getActualAuthCredential(issuerDID);
|
|
61972
61988
|
const coreClaimOpts = {
|
|
61973
61989
|
revNonce: req.revocationOpts.nonce,
|
|
61974
61990
|
subjectPosition: req.subjectPosition,
|
|
@@ -61977,7 +61993,7 @@ class IdentityWallet {
|
|
|
61977
61993
|
version: 0,
|
|
61978
61994
|
merklizeOpts: { ...opts, documentLoader: loader }
|
|
61979
61995
|
};
|
|
61980
|
-
const coreClaim = await
|
|
61996
|
+
const coreClaim = await credential.toCoreClaim(coreClaimOpts);
|
|
61981
61997
|
const { hi, hv } = coreClaim.hiHv();
|
|
61982
61998
|
const coreClaimHash = poseidon.hash([hi, hv]);
|
|
61983
61999
|
const signature = await this.signChallenge(coreClaimHash, issuerAuthBJJCredential);
|
|
@@ -62002,6 +62018,25 @@ class IdentityWallet {
|
|
|
62002
62018
|
credential.proof = [sigProof];
|
|
62003
62019
|
return credential;
|
|
62004
62020
|
}
|
|
62021
|
+
/** {@inheritDoc IIdentityWallet.getActualAuthCredential} */
|
|
62022
|
+
async getActualAuthCredential(did, treeStateInfo) {
|
|
62023
|
+
const authCredentials = await this._credentialWallet.getAllAuthBJJCredentials(did);
|
|
62024
|
+
for (let i = 0; i < authCredentials.length; i++) {
|
|
62025
|
+
const incProof = await this.generateCredentialMtp(did, authCredentials[i], treeStateInfo);
|
|
62026
|
+
if (!incProof.proof.existence) {
|
|
62027
|
+
continue;
|
|
62028
|
+
}
|
|
62029
|
+
const nonRevProof = await this.generateNonRevocationMtp(did, authCredentials[i], treeStateInfo);
|
|
62030
|
+
if (!nonRevProof.proof.existence) {
|
|
62031
|
+
return {
|
|
62032
|
+
authCredential: authCredentials[i],
|
|
62033
|
+
incProof,
|
|
62034
|
+
nonRevProof
|
|
62035
|
+
};
|
|
62036
|
+
}
|
|
62037
|
+
}
|
|
62038
|
+
throw new Error('no auth credentials found');
|
|
62039
|
+
}
|
|
62005
62040
|
/** {@inheritDoc IIdentityWallet.revokeCredential} */
|
|
62006
62041
|
async revokeCredential(issuerDID, credential) {
|
|
62007
62042
|
const issuerTree = await this.getDIDTreeModel(issuerDID);
|
|
@@ -62914,8 +62949,8 @@ class InputGenerator {
|
|
|
62914
62949
|
circuitInputs.proofType = proofType;
|
|
62915
62950
|
circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
|
|
62916
62951
|
circuitInputs.verifierID = params.verifierDid ? DID.idFromDID(params.verifierDid) : undefined;
|
|
62917
|
-
circuitInputs.nullifierSessionID = proofReq.params?.
|
|
62918
|
-
? BigInt(proofReq.params?.
|
|
62952
|
+
circuitInputs.nullifierSessionID = proofReq.params?.nullifierSessionId
|
|
62953
|
+
? BigInt(proofReq.params?.nullifierSessionId?.toString())
|
|
62919
62954
|
: BigInt(0);
|
|
62920
62955
|
let isEthIdentity = true;
|
|
62921
62956
|
try {
|
|
@@ -63024,9 +63059,7 @@ class InputGenerator {
|
|
|
63024
63059
|
return circuitClaim;
|
|
63025
63060
|
}
|
|
63026
63061
|
async prepareAuthBJJCredential(did, treeStateInfo) {
|
|
63027
|
-
const authCredential = await this.
|
|
63028
|
-
const incProof = await this._identityWallet.generateCredentialMtp(did, authCredential, treeStateInfo);
|
|
63029
|
-
const nonRevProof = await this._identityWallet.generateNonRevocationMtp(did, authCredential, treeStateInfo);
|
|
63062
|
+
const { authCredential, incProof, nonRevProof } = await this._identityWallet.getActualAuthCredential(did, treeStateInfo);
|
|
63030
63063
|
const authCoreClaim = authCredential.getCoreClaimFromProof(ProofType.Iden3SparseMerkleTreeProof);
|
|
63031
63064
|
if (!authCoreClaim) {
|
|
63032
63065
|
throw new Error('auth core claim is not defined for auth bjj credential');
|