@0xpolygonid/js-sdk 1.18.3 → 1.18.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Polygon ID JS SDK
1
+ # Privado ID JS SDK
2
2
 
3
- SDK to work with Polygon ID using JavaScript and TypeScript languages.
3
+ SDK to work with Privado ID using JavaScript and TypeScript languages.
4
4
 
5
5
  ## Usage
6
6
 
@@ -59816,12 +59816,20 @@ class IdentityWallet {
59816
59816
  },
59817
59817
  allowedIssuers: [did.string()]
59818
59818
  });
59819
- if (credentials.length) {
59819
+ // if credential exists with the same credential status type we return this credential
59820
+ if (credentials.length === 1 &&
59821
+ credentials[0].credentialStatus.type === opts.revocationOpts.type) {
59820
59822
  return {
59821
59823
  did,
59822
59824
  credential: credentials[0]
59823
59825
  };
59824
59826
  }
59827
+ // otherwise something is already wrong with storage as it has more than 1 credential in it or credential status type of existing credential is different from what user provides - We should remove everything and create new credential.
59828
+ // in this way credential status of auth credential can be upgraded
59829
+ for (let i = 0; i < credentials.length; i++) {
59830
+ await this._credentialWallet.remove(credentials[i].id);
59831
+ }
59832
+ // otherwise we create a new credential
59825
59833
  const credential = await this.createAuthBJJCredential(did, pubKey, authClaim, currentState, opts.revocationOpts);
59826
59834
  const index = authClaim.hIndex();
59827
59835
  const { proof } = await claimsTree.generateProof(index, ctr);
@@ -59839,10 +59847,13 @@ class IdentityWallet {
59839
59847
  coreClaim: authClaim
59840
59848
  });
59841
59849
  credential.proof = [mtpProof];
59842
- await this.publishRevocationInfoByCredentialStatusType(did, opts.revocationOpts.type, {
59843
- rhsUrl: opts.revocationOpts.id,
59844
- onChain: opts.revocationOpts.onChain
59845
- });
59850
+ // only if user specified that genesis state publishing is not needed we won't do this.
59851
+ if (!opts.revocationOpts.genesisPublishingDisabled) {
59852
+ await this.publishRevocationInfoByCredentialStatusType(did, opts.revocationOpts.type, {
59853
+ rhsUrl: opts.revocationOpts.id,
59854
+ onChain: opts.revocationOpts.onChain
59855
+ });
59856
+ }
59846
59857
  await this._credentialWallet.save(credential);
59847
59858
  return {
59848
59859
  did,
@@ -60205,23 +60216,13 @@ class IdentityWallet {
60205
60216
  throw new Error(`there is no registered publisher to save hash is not registered for ${credentialStatusType} is not registered`);
60206
60217
  }
60207
60218
  let nodes = [];
60208
- if (opts?.treeModel) {
60209
- nodes = await getNodesRepresentation(opts.revokedNonces, {
60210
- revocationTree: opts.treeModel.revocationTree,
60211
- claimsTree: opts.treeModel.claimsTree,
60212
- state: opts.treeModel.state,
60213
- rootsTree: opts.treeModel.rootsTree
60214
- }, opts.treeModel.state);
60215
- }
60216
- else {
60217
- const treeState = await this.getDIDTreeModel(issuerDID);
60218
- nodes = await getNodesRepresentation(opts?.revokedNonces, {
60219
- revocationTree: treeState.revocationTree,
60220
- claimsTree: treeState.claimsTree,
60221
- state: treeState.state,
60222
- rootsTree: treeState.rootsTree
60223
- }, treeState.state);
60224
- }
60219
+ const tree = opts?.treeModel ?? (await this.getDIDTreeModel(issuerDID));
60220
+ nodes = await getNodesRepresentation(opts?.revokedNonces ?? [], {
60221
+ revocationTree: tree.revocationTree,
60222
+ claimsTree: tree.claimsTree,
60223
+ state: tree.state,
60224
+ rootsTree: tree.rootsTree
60225
+ }, tree.state);
60225
60226
  if (!nodes.length) {
60226
60227
  return;
60227
60228
  }