Skip to content

Commit

Permalink
fix bug with backup status issuer for Iden3SparseMerkleTreeProof (#154)
Browse files Browse the repository at this point in the history
* fix bug with  backup status issuer for Iden3SparseMerkleTreeProof

* make a call through resolver
  • Loading branch information
vmidyllic authored Nov 30, 2023
1 parent d38bec2 commit fc346fd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 6 additions & 3 deletions src/credentials/status/reverse-sparse-merkle-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}`);
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/rhs/rhs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('rhs', () => {
await credWallet.save(issuerAuthCredential);

const credBasicStatus: CredentialStatus = {
id: 'issuerurl',
id: 'http://issuerurl.com',
revocationNonce: 0,
type: CredentialStatusType.SparseMerkleTreeProof
};
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('rhs', () => {
});

const credBasicStatus: CredentialStatus = {
id: 'issuerurl',
id: 'http://issuerurl.coml',
revocationNonce: 0,
type: CredentialStatusType.SparseMerkleTreeProof
};
Expand Down Expand Up @@ -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
};
Expand Down

0 comments on commit fc346fd

Please sign in to comment.