-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
rdf-canonize
directly to use RDFC-1.0
algorithm.
- Loading branch information
Showing
4 changed files
with
24 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
/*! | ||
* Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved. | ||
* Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved. | ||
*/ | ||
import * as rdfCanonize from 'rdf-canonize'; | ||
import jsonld from 'jsonld'; | ||
|
||
export async function canonize(input, options) { | ||
return jsonld.canonize(input, { | ||
algorithm: 'URDNA2015', | ||
// convert to RDF dataset and do canonicalization | ||
options = { | ||
algorithm: 'RDFC-1.0', | ||
format: 'application/n-quads', | ||
base: null, | ||
safe: true, | ||
...options | ||
}); | ||
}; | ||
const opts = {...options, produceGeneralizedRdf: false}; | ||
delete opts.format; | ||
opts.produceGeneralizedRdf = false; | ||
const dataset = await jsonld.toRDF(input, opts); | ||
return rdfCanonize.canonize(dataset, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters