@@ -524,12 +524,18 @@ jsonld.link = async function(input, ctx, options) {
524
524
* unless the 'inputFormat' option is used. The output is an RDF dataset
525
525
* unless the 'format' option is used.
526
526
*
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
+ *
527
533
* @param input the input to normalize as JSON-LD or as a format specified by
528
534
* the 'inputFormat' option.
529
535
* @param [options] the options to use:
530
536
* [algorithm] the normalization algorithm to use, `URDNA2015` or
531
537
* `URGNA2012` (default: `URDNA2015`).
532
- * [base] the base IRI to use.
538
+ * [base] the base IRI to use (default: `null`) .
533
539
* [expandContext] a context to expand with.
534
540
* [skipExpansion] true to assume the input is expanded and skip
535
541
* expansion, false not to, defaults to false.
@@ -539,7 +545,7 @@ jsonld.link = async function(input, ctx, options) {
539
545
* 'application/n-quads' for N-Quads.
540
546
* [documentLoader(url, options)] the document loader.
541
547
* [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).
543
549
* [contextResolver] internal use only.
544
550
*
545
551
* @return a Promise that resolves to the normalized output.
@@ -551,9 +557,10 @@ jsonld.normalize = jsonld.canonize = async function(input, options) {
551
557
552
558
// set default options
553
559
options = _setDefaults ( options , {
554
- base : _isString ( input ) ? input : '' ,
560
+ base : _isString ( input ) ? input : null ,
555
561
algorithm : 'URDNA2015' ,
556
562
skipExpansion : false ,
563
+ safe : true ,
557
564
contextResolver : new ContextResolver (
558
565
{ sharedCache : _resolvedContextCache } )
559
566
} ) ;
0 commit comments