Skip to content

Commit a8fc351

Browse files
committed
Add "safe mode" documentation.
1 parent b47cc24 commit a8fc351

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
- Support test environment in EARL output.
1010
- Support benchmark output in EARL output.
1111
- Benchmark comparison tool.
12+
- Add "safe mode" to all APIs. Enable by adding `{safe: true}` to API options.
13+
This mode causes processing to fail when data constructs are encountered that
14+
result in lossy behavior or other data warnings. This is intended to be the
15+
common way that digital signing and similar applications use this libraray.
1216

1317
## 6.0.0 - 2022-06-06
1418

@@ -34,6 +38,8 @@
3438

3539
### Removed
3640
- Experimental non-standard `protectedMode` option.
41+
- **BREAKING**: Various console warnings were removed. The newly added "safe
42+
mode" can stop processing where these warnings were.
3743

3844
## 5.2.0 - 2021-04-07
3945

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,24 @@ It is recommended to set a default `user-agent` header for Node.js
346346
applications. The default for the default Node.js document loader is
347347
`jsonld.js`.
348348

349+
### Safe Mode
350+
351+
A common use case is to avoid JSON-LD constructs that will result in lossy
352+
behavior. The JSON-LD specifications have notes about when data is dropped.
353+
This can be especially important when calling [`canonize`][] in order to
354+
digitally sign data. A special "safe mode" is available that will detect these
355+
situations and cause processing to fail.
356+
357+
**Note**: This mode is designed to be the common way that digital signing and
358+
similar applications use this library.
359+
360+
The `safe` options flag set to `true` enables this behavior:
361+
362+
```js
363+
// expand a document in safe mode
364+
const expanded = await jsonld.expand(data, {safe: true});
365+
```
366+
349367
Related Modules
350368
---------------
351369

0 commit comments

Comments
 (0)