From fc346fd6bdd9ad38a76257e0e846660a5b33d717 Mon Sep 17 00:00:00 2001 From: vmidyllic <74898029+vmidyllic@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:41:31 +0200 Subject: [PATCH] fix bug with backup status issuer for Iden3SparseMerkleTreeProof (#154) * fix bug with backup status issuer for Iden3SparseMerkleTreeProof * make a call through resolver --- package-lock.json | 4 ++-- package.json | 2 +- src/credentials/status/reverse-sparse-merkle-tree.ts | 9 ++++++--- tests/rhs/rhs.test.ts | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2fe1bdfb..140304cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.4.1", + "version": "1.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@0xpolygonid/js-sdk", - "version": "1.4.1", + "version": "1.4.2", "license": "AGPL-3.0", "dependencies": { "ajv": "8.12.0", diff --git a/package.json b/package.json index ef7185bd..7c21fd05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.4.1", + "version": "1.4.2", "description": "SDK to work with Polygon ID", "main": "dist/node/cjs/index.js", "module": "dist/node/esm/index.js", diff --git a/src/credentials/status/reverse-sparse-merkle-tree.ts b/src/credentials/status/reverse-sparse-merkle-tree.ts index d544b25a..83313e9c 100644 --- a/src/credentials/status/reverse-sparse-merkle-tree.ts +++ b/src/credentials/status/reverse-sparse-merkle-tree.ts @@ -6,6 +6,7 @@ import { CredentialStatusResolver, CredentialStatusResolveOptions } from './reso import { CredentialStatus, RevocationStatus, State } from '../../verifiable'; import { VerifiableConstants, CredentialStatusType } from '../../verifiable/constants'; import { isGenesisState } from './utils'; +import { IssuerResolver } from './sparse-merkle-tree'; /** * ProofNode is a partial Reverse Hash Service result @@ -122,12 +123,14 @@ export class RHSResolver implements CredentialStatusResolver { } catch (e: unknown) { if (credentialStatus?.statusIssuer?.type === CredentialStatusType.SparseMerkleTreeProof) { try { - return await (await fetch(credentialStatus.id)).json(); + return await new IssuerResolver().resolve(credentialStatus.statusIssuer); } catch (e) { - throw new Error(`can't fetch revocation status from backup endpoint`); + throw new Error( + `can't fetch revocation status from backup endpoint: ${(e as Error)?.message}` + ); } } - throw new Error(`can't fetch revocation status`); + throw new Error(`can't fetch revocation status: ${(e as Error)?.message}`); } } diff --git a/tests/rhs/rhs.test.ts b/tests/rhs/rhs.test.ts index ed30989d..277041d6 100644 --- a/tests/rhs/rhs.test.ts +++ b/tests/rhs/rhs.test.ts @@ -194,7 +194,7 @@ describe('rhs', () => { await credWallet.save(issuerAuthCredential); const credBasicStatus: CredentialStatus = { - id: 'issuerurl', + id: 'http://issuerurl.com', revocationNonce: 0, type: CredentialStatusType.SparseMerkleTreeProof }; @@ -249,7 +249,7 @@ describe('rhs', () => { }); const credBasicStatus: CredentialStatus = { - id: 'issuerurl', + id: 'http://issuerurl.coml', revocationNonce: 0, type: CredentialStatusType.SparseMerkleTreeProof }; @@ -326,7 +326,7 @@ describe('rhs', () => { expect(credential).not.to.be.undefined; const credBasicStatus: CredentialStatus = { - id: 'issuerurl', + id: 'http://issuerurl.coml', revocationNonce: 0, type: CredentialStatusType.SparseMerkleTreeProof };