@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.
@@ -57215,7 +57215,10 @@ var PolygonIdSdk = (function (exports) {
57215
57215
  valueProof.value = 0n;
57216
57216
  valueProof.mtp = new Kt$1();
57217
57217
  }
57218
- const treeState = this.claim.nonRevProof.treeState;
57218
+ let treeState = this.claim.nonRevProof.treeState;
57219
+ if (this.proofType === exports.ProofType.BJJSignature && this.skipClaimRevocationCheck) {
57220
+ treeState = this.claim.signatureProof?.issuerAuthNonRevProof.treeState;
57221
+ }
57219
57222
  if (!treeState) {
57220
57223
  throw new Error(exports.CircuitError.EmptyTreeState);
57221
57224
  }
@@ -57271,27 +57274,32 @@ var PolygonIdSdk = (function (exports) {
57271
57274
  s.isRevocationChecked = 0;
57272
57275
  }
57273
57276
  if (this.proofType === exports.ProofType.BJJSignature) {
57277
+ const sigProof = this.claim.signatureProof;
57274
57278
  s.proofType = '1';
57275
- s.issuerClaimSignatureR8x = this.claim.signatureProof?.signature.R8[0].toString();
57276
- s.issuerClaimSignatureR8y = this.claim.signatureProof?.signature.R8[1].toString();
57277
- s.issuerClaimSignatureS = this.claim.signatureProof?.signature.S.toString();
57278
- s.issuerAuthClaim = this.claim.signatureProof?.issuerAuthClaim?.marshalJson();
57279
- s.issuerAuthClaimMtp = prepareSiblingsStr(this.claim.signatureProof?.issuerAuthIncProof.proof, this.getMTLevel());
57279
+ s.issuerClaimSignatureR8x = sigProof.signature.R8[0].toString();
57280
+ s.issuerClaimSignatureR8y = sigProof.signature.R8[1].toString();
57281
+ s.issuerClaimSignatureS = sigProof.signature.S.toString();
57282
+ s.issuerAuthClaim = sigProof.issuerAuthClaim?.marshalJson();
57283
+ s.issuerAuthClaimMtp = prepareSiblingsStr(sigProof.issuerAuthIncProof.proof, this.getMTLevel());
57280
57284
  const issuerAuthTreeState = this.claim.nonRevProof.treeState;
57281
57285
  if (!issuerAuthTreeState) {
57282
57286
  throw new Error(exports.CircuitError.EmptyTreeState);
57283
57287
  }
57284
- s.issuerAuthClaimsTreeRoot = issuerAuthTreeState.claimsRoot.bigInt().toString();
57285
- s.issuerAuthRevTreeRoot = issuerAuthTreeState.revocationRoot.bigInt().toString();
57286
- s.issuerAuthRootsTreeRoot = issuerAuthTreeState.rootOfRoots.bigInt().toString();
57287
- s.issuerAuthClaimNonRevMtp = prepareSiblingsStr(this.claim.signatureProof?.issuerAuthNonRevProof.proof, this.getMTLevel());
57288
- const nodeAuxIssuerAuthNonRev = getNodeAuxValue(this.claim.signatureProof?.issuerAuthNonRevProof.proof);
57288
+ s.issuerAuthClaimsTreeRoot = sigProof.issuerAuthIncProof.treeState?.claimsRoot
57289
+ .bigInt()
57290
+ .toString();
57291
+ s.issuerAuthRevTreeRoot = sigProof.issuerAuthIncProof.treeState?.revocationRoot
57292
+ .bigInt()
57293
+ .toString();
57294
+ s.issuerAuthRootsTreeRoot = sigProof.issuerAuthIncProof.treeState?.rootOfRoots
57295
+ .bigInt()
57296
+ .toString();
57297
+ s.issuerAuthClaimNonRevMtp = prepareSiblingsStr(sigProof.issuerAuthNonRevProof.proof, this.getMTLevel());
57298
+ const nodeAuxIssuerAuthNonRev = getNodeAuxValue(sigProof.issuerAuthNonRevProof.proof);
57289
57299
  s.issuerAuthClaimNonRevMtpAuxHi = nodeAuxIssuerAuthNonRev.key.bigInt().toString();
57290
57300
  s.issuerAuthClaimNonRevMtpAuxHv = nodeAuxIssuerAuthNonRev.value.bigInt().toString();
57291
57301
  s.issuerAuthClaimNonRevMtpNoAux = nodeAuxIssuerAuthNonRev.noAux;
57292
- s.issuerAuthState = this.claim.signatureProof?.issuerAuthIncProof.treeState?.state
57293
- .bigInt()
57294
- .toString();
57302
+ s.issuerAuthState = sigProof.issuerAuthIncProof.treeState?.state.bigInt().toString();
57295
57303
  this.fillMTPProofsWithZero(s);
57296
57304
  }
57297
57305
  else if (this.proofType === exports.ProofType.Iden3SparseMerkleTreeProof) {
@@ -61574,6 +61582,16 @@ var PolygonIdSdk = (function (exports) {
61574
61582
  }
61575
61583
  throw new Error('all auth bjj credentials are revoked');
61576
61584
  }
61585
+ /**
61586
+ * {@inheritDoc ICredentialWallet.getAllAuthBJJCredentials}
61587
+ */
61588
+ async getAllAuthBJJCredentials(did) {
61589
+ return this._storage.credential.findCredentialsByQuery({
61590
+ context: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL,
61591
+ type: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,
61592
+ allowedIssuers: [did.string()]
61593
+ });
61594
+ }
61577
61595
  /**
61578
61596
  * {@inheritDoc ICredentialWallet.getRevocationStatusFromCredential}
61579
61597
  */
@@ -61855,13 +61873,19 @@ var PolygonIdSdk = (function (exports) {
61855
61873
  this._storage = _storage;
61856
61874
  this._credentialWallet = _credentialWallet;
61857
61875
  this._opts = _opts;
61876
+ this._credentialStatusPublisherRegistry = this.getCredentialStatusPublisherRegistry(_opts);
61877
+ }
61878
+ getCredentialStatusPublisherRegistry(_opts) {
61858
61879
  if (!_opts?.credentialStatusPublisherRegistry) {
61859
- this._credentialStatusPublisherRegistry = new CredentialStatusPublisherRegistry();
61860
- this._credentialStatusPublisherRegistry.register(exports.CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, new Iden3SmtRhsCredentialStatusPublisher());
61880
+ const registry = new CredentialStatusPublisherRegistry();
61881
+ const emptyPublisher = { publish: () => Promise.resolve() };
61882
+ registry.register(exports.CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, new Iden3SmtRhsCredentialStatusPublisher());
61883
+ registry.register(exports.CredentialStatusType.SparseMerkleTreeProof, emptyPublisher);
61884
+ registry.register(exports.CredentialStatusType.Iden3commRevocationStatusV1, emptyPublisher);
61885
+ return registry;
61861
61886
  }
61862
61887
  else {
61863
- this._credentialStatusPublisherRegistry = this._opts
61864
- ?.credentialStatusPublisherRegistry;
61888
+ return this._opts?.credentialStatusPublisherRegistry;
61865
61889
  }
61866
61890
  }
61867
61891
  /**
@@ -62099,7 +62123,7 @@ var PolygonIdSdk = (function (exports) {
62099
62123
  catch (e) {
62100
62124
  throw new Error(`Error create w3c credential ${e.message}`);
62101
62125
  }
62102
- const issuerAuthBJJCredential = await this._credentialWallet.getAuthBJJCredential(issuerDID);
62126
+ const { authCredential: issuerAuthBJJCredential } = await this.getActualAuthCredential(issuerDID);
62103
62127
  const coreClaimOpts = {
62104
62128
  revNonce: req.revocationOpts.nonce,
62105
62129
  subjectPosition: req.subjectPosition,
@@ -62108,7 +62132,7 @@ var PolygonIdSdk = (function (exports) {
62108
62132
  version: 0,
62109
62133
  merklizeOpts: { ...opts, documentLoader: loader }
62110
62134
  };
62111
- const coreClaim = await Parser.parseClaim(credential, coreClaimOpts);
62135
+ const coreClaim = await credential.toCoreClaim(coreClaimOpts);
62112
62136
  const { hi, hv } = coreClaim.hiHv();
62113
62137
  const coreClaimHash = $$2.hash([hi, hv]);
62114
62138
  const signature = await this.signChallenge(coreClaimHash, issuerAuthBJJCredential);
@@ -62133,6 +62157,25 @@ var PolygonIdSdk = (function (exports) {
62133
62157
  credential.proof = [sigProof];
62134
62158
  return credential;
62135
62159
  }
62160
+ /** {@inheritDoc IIdentityWallet.getActualAuthCredential} */
62161
+ async getActualAuthCredential(did, treeStateInfo) {
62162
+ const authCredentials = await this._credentialWallet.getAllAuthBJJCredentials(did);
62163
+ for (let i = 0; i < authCredentials.length; i++) {
62164
+ const incProof = await this.generateCredentialMtp(did, authCredentials[i], treeStateInfo);
62165
+ if (!incProof.proof.existence) {
62166
+ continue;
62167
+ }
62168
+ const nonRevProof = await this.generateNonRevocationMtp(did, authCredentials[i], treeStateInfo);
62169
+ if (!nonRevProof.proof.existence) {
62170
+ return {
62171
+ authCredential: authCredentials[i],
62172
+ incProof,
62173
+ nonRevProof
62174
+ };
62175
+ }
62176
+ }
62177
+ throw new Error('no auth credentials found');
62178
+ }
62136
62179
  /** {@inheritDoc IIdentityWallet.revokeCredential} */
62137
62180
  async revokeCredential(issuerDID, credential) {
62138
62181
  const issuerTree = await this.getDIDTreeModel(issuerDID);
@@ -83808,8 +83851,8 @@ var PolygonIdSdk = (function (exports) {
83808
83851
  circuitInputs.proofType = proofType;
83809
83852
  circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
83810
83853
  circuitInputs.verifierID = params.verifierDid ? W$2.idFromDID(params.verifierDid) : undefined;
83811
- circuitInputs.nullifierSessionID = proofReq.params?.nullifierSessionID
83812
- ? BigInt(proofReq.params?.nullifierSessionID?.toString())
83854
+ circuitInputs.nullifierSessionID = proofReq.params?.nullifierSessionId
83855
+ ? BigInt(proofReq.params?.nullifierSessionId?.toString())
83813
83856
  : BigInt(0);
83814
83857
  let isEthIdentity = true;
83815
83858
  try {
@@ -83918,9 +83961,7 @@ var PolygonIdSdk = (function (exports) {
83918
83961
  return circuitClaim;
83919
83962
  }
83920
83963
  async prepareAuthBJJCredential(did, treeStateInfo) {
83921
- const authCredential = await this._credentialWallet.getAuthBJJCredential(did);
83922
- const incProof = await this._identityWallet.generateCredentialMtp(did, authCredential, treeStateInfo);
83923
- const nonRevProof = await this._identityWallet.generateNonRevocationMtp(did, authCredential, treeStateInfo);
83964
+ const { authCredential, incProof, nonRevProof } = await this._identityWallet.getActualAuthCredential(did, treeStateInfo);
83924
83965
  const authCoreClaim = authCredential.getCoreClaimFromProof(exports.ProofType.Iden3SparseMerkleTreeProof);
83925
83966
  if (!authCoreClaim) {
83926
83967
  throw new Error('auth core claim is not defined for auth bjj credential');