@0xpolygonid/js-sdk 1.4.1 → 1.4.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.
@@ -58256,6 +58256,45 @@ class OnChainResolver {
58256
58256
  }
58257
58257
  }
58258
58258
 
58259
+ /**
58260
+ * IssuerResolver is a class that allows to interact with the issuer's http endpoint to get revocation status.
58261
+ *
58262
+ * @public
58263
+ * @class IssuerResolver
58264
+ */
58265
+ class IssuerResolver {
58266
+ /**
58267
+ * resolve is a method to resolve a credential status directly from the issuer.
58268
+ *
58269
+ * @public
58270
+ * @param {CredentialStatus} credentialStatus - credential status to resolve
58271
+ * @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
58272
+ * @returns `{Promise<RevocationStatus>}`
58273
+ */
58274
+ async resolve(credentialStatus) {
58275
+ const revStatusResp = await fetch(credentialStatus.id);
58276
+ const revStatus = await revStatusResp.json();
58277
+ return toRevocationStatus(revStatus);
58278
+ }
58279
+ }
58280
+ /**
58281
+ * toRevocationStatus is a result of fetching credential status with type SparseMerkleTreeProof converts to RevocationStatus
58282
+ *
58283
+ * @param {RevocationStatusResponse} { issuer, mtp }
58284
+ * @returns {RevocationStatus} RevocationStatus
58285
+ */
58286
+ const toRevocationStatus = ({ issuer, mtp }) => {
58287
+ const p = Proof.fromJSON({
58288
+ nodeAux: mtp.node_aux,
58289
+ existence: mtp.existence,
58290
+ siblings: mtp.siblings
58291
+ });
58292
+ return {
58293
+ mtp: p,
58294
+ issuer
58295
+ };
58296
+ };
58297
+
58259
58298
  /**
58260
58299
  * ProofNode is a partial Reverse Hash Service result
58261
58300
  * it contains the current node hash and its children
@@ -58349,13 +58388,13 @@ class RHSResolver {
58349
58388
  catch (e) {
58350
58389
  if (credentialStatus?.statusIssuer?.type === CredentialStatusType.SparseMerkleTreeProof) {
58351
58390
  try {
58352
- return await (await fetch(credentialStatus.id)).json();
58391
+ return await new IssuerResolver().resolve(credentialStatus.statusIssuer);
58353
58392
  }
58354
58393
  catch (e) {
58355
- throw new Error(`can't fetch revocation status from backup endpoint`);
58394
+ throw new Error(`can't fetch revocation status from backup endpoint: ${e?.message}`);
58356
58395
  }
58357
58396
  }
58358
- throw new Error(`can't fetch revocation status`);
58397
+ throw new Error(`can't fetch revocation status: ${e?.message}`);
58359
58398
  }
58360
58399
  }
58361
58400
  /**
@@ -58538,45 +58577,6 @@ function isGenesisStateId(id, state, type) {
58538
58577
  return id.toString() === idFromState.bigInt().toString();
58539
58578
  }
58540
58579
 
58541
- /**
58542
- * IssuerResolver is a class that allows to interact with the issuer's http endpoint to get revocation status.
58543
- *
58544
- * @public
58545
- * @class IssuerResolver
58546
- */
58547
- class IssuerResolver {
58548
- /**
58549
- * resolve is a method to resolve a credential status directly from the issuer.
58550
- *
58551
- * @public
58552
- * @param {CredentialStatus} credentialStatus - credential status to resolve
58553
- * @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
58554
- * @returns `{Promise<RevocationStatus>}`
58555
- */
58556
- async resolve(credentialStatus) {
58557
- const revStatusResp = await fetch(credentialStatus.id);
58558
- const revStatus = await revStatusResp.json();
58559
- return toRevocationStatus(revStatus);
58560
- }
58561
- }
58562
- /**
58563
- * toRevocationStatus is a result of fetching credential status with type SparseMerkleTreeProof converts to RevocationStatus
58564
- *
58565
- * @param {RevocationStatusResponse} { issuer, mtp }
58566
- * @returns {RevocationStatus} RevocationStatus
58567
- */
58568
- const toRevocationStatus = ({ issuer, mtp }) => {
58569
- const p = Proof.fromJSON({
58570
- nodeAux: mtp.node_aux,
58571
- existence: mtp.existence,
58572
- siblings: mtp.siblings
58573
- });
58574
- return {
58575
- mtp: p,
58576
- issuer
58577
- };
58578
- };
58579
-
58580
58580
  /**
58581
58581
  * CredentialStatusResolverRegistry is a registry of CredentialStatusResolver
58582
58582
  *