Skip to content

Commit

Permalink
Merge pull request #28 from blockchain-certificates/feat/bump-deps
Browse files Browse the repository at this point in the history
fix(JsonLd): turn off safe mode to prevent failures
  • Loading branch information
lemoustachiste authored Aug 22, 2023
2 parents 362169a + 7415064 commit 481a5ff
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/inspectors/computeLocalHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export default async function computeLocalHash (
const normalizeArgs: any = {
algorithm: 'URDNA2015',
format: 'application/nquads',
documentLoader: customLoader
documentLoader: customLoader,
safe: false
};

let normalizedDocument;
Expand Down
63 changes: 63 additions & 0 deletions tests/fixtures/testnet-v3-custom-context.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions tests/inspectors/computeLocalHash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import sinon from 'sinon';
import jsonld from 'jsonld';
import JsonLdError from 'jsonld/lib/JsonLdError';
import blockcertsV3Fixture, { documentHash } from '../fixtures/testnet-v3-did';
import blockcertsV3CustomContextFixture, { blockcertsV3CustomContextHash } from '../fixtures/testnet-v3-custom-context';
import computeLocalHash from '../../src/inspectors/computeLocalHash';

describe('computeLocalHash test suite', function () {
Expand Down Expand Up @@ -46,4 +47,11 @@ describe('computeLocalHash test suite', function () {
normalizeStub.restore();
});
});

describe('given the document has a custom context', function () {
it('should normalize and hash the document as expected', async function () {
const output = await computeLocalHash(blockcertsV3CustomContextFixture);
expect(output).toBe(blockcertsV3CustomContextHash);
});
});
});

0 comments on commit 481a5ff

Please sign in to comment.