Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ changes.

### Removed

- Remove additional canonicalization of the metadata [Issue 3591](https://github.com/IntersectMBO/govtool/issues/3591)

## [v2.0.20](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.20) 2025-04-16

### Added
Expand Down
25 changes: 1 addition & 24 deletions govtool/metadata-validation/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Injectable, Logger } from '@nestjs/common';
import { catchError, finalize, firstValueFrom } from 'rxjs';
import { HttpService } from '@nestjs/axios';
import * as blake from 'blakejs';
import * as jsonld from 'jsonld';

import { ValidateMetadataDTO } from '@dto';
import { LoggerMessage, MetadataValidationStatus } from '@enums';
Expand Down Expand Up @@ -81,29 +80,7 @@ export class AppService {
const hashedMetadata = blake.blake2bHex(rawData, undefined, 32);

if (hashedMetadata !== hash) {
// Optionally validate on a parsed metadata
const hashedParsedMetadata = blake.blake2bHex(
JSON.stringify(parsedData, null, 2),
undefined,
32,
);
if (hashedParsedMetadata !== hash) {
// Optional support for the canonized data hash
// Validate canonized data hash
const canonizedMetadata = await jsonld.canonize(JSON.parse(rawData), {
safe: false,
});

const hashedCanonizedMetadata = blake.blake2bHex(
canonizedMetadata,
undefined,
32,
);

if (hashedCanonizedMetadata !== hash) {
throw MetadataValidationStatus.INVALID_HASH;
}
}
throw MetadataValidationStatus.INVALID_HASH;
}
} catch (error) {
Logger.error(LoggerMessage.METADATA_VALIDATION_ERROR, error);
Expand Down