@@ -524,12 +524,18 @@ jsonld.link = async function(input, ctx, options) {
524524 * unless the 'inputFormat' option is used. The output is an RDF dataset
525525 * unless the 'format' option is used.
526526 *
527+ * Note: Canonicalization sets `safe` to `true` and `base` to `null` by
528+ * default in order to produce safe outputs and "fail closed" by default. This
529+ * is different from the other API transformations in this version which
530+ * allow unsafe defaults (for cryptographic usage) in order to comply with the
531+ * JSON-LD 1.1 specification.
532+ *
527533 * @param input the input to normalize as JSON-LD or as a format specified by
528534 * the 'inputFormat' option.
529535 * @param [options] the options to use:
530536 * [algorithm] the normalization algorithm to use, `URDNA2015` or
531537 * `URGNA2012` (default: `URDNA2015`).
532- * [base] the base IRI to use.
538+ * [base] the base IRI to use (default: `null`) .
533539 * [expandContext] a context to expand with.
534540 * [skipExpansion] true to assume the input is expanded and skip
535541 * expansion, false not to, defaults to false.
@@ -539,7 +545,7 @@ jsonld.link = async function(input, ctx, options) {
539545 * 'application/n-quads' for N-Quads.
540546 * [documentLoader(url, options)] the document loader.
541547 * [useNative] true to use a native canonize algorithm
542- * [safe] true to use safe mode. (default: false)
548+ * [safe] true to use safe mode. (default: true).
543549 * [contextResolver] internal use only.
544550 *
545551 * @return a Promise that resolves to the normalized output.
@@ -551,9 +557,10 @@ jsonld.normalize = jsonld.canonize = async function(input, options) {
551557
552558 // set default options
553559 options = _setDefaults ( options , {
554- base : _isString ( input ) ? input : '' ,
560+ base : _isString ( input ) ? input : null ,
555561 algorithm : 'URDNA2015' ,
556562 skipExpansion : false ,
563+ safe : true ,
557564 contextResolver : new ContextResolver (
558565 { sharedCache : _resolvedContextCache } )
559566 } ) ;
0 commit comments