@@ -992,6 +992,17 @@ <h2>The <dfn>InteractionOutput</dfn> interface</h2>
992
992
[=Resolve=] |promise| with < a > [[\value]]</ a > .
993
993
</ li >
994
994
</ ol >
995
+ < p >
996
+ While the {{value()}} function provides built-in validation, we recognize that some
997
+ use cases may require returning values without validation. In such cases, developers
998
+ can use alternative patterns, such as directly accessing the underlying data
999
+ using streams or the {{InteractionOutput/arrayBuffer()}} function (see [[[#validation-arraybuffer-example]]] and [[[#stream-example]]]).
1000
+ </ p >
1001
+ < p class ="advisement " id ="non-validating-value-warning " title ="Implications for not using validation ">
1002
+ < strong > Warning:</ strong > Disabling validation may introduce risks, particularly when interacting
1003
+ with remote Things, as mismatches in data formats or schema expectations can lead to
1004
+ unforeseen bugs and vulnerabilities. For more details, see the < a data-cite ="wot-thing-description11#behavior-data "> consumer assertions</ a > .
1005
+ </ p >
995
1006
</ section >
996
1007
997
1008
< section > < h3 > The < dfn > arrayBuffer()</ dfn > function</ h3 >
@@ -2463,10 +2474,25 @@ <h2>ConsumedThing Examples</h2>
2463
2474
// image: ArrayBuffer [0x1 0x2 0x3 0x5 0x15 0x23 ...]
2464
2475
}
2465
2476
</ pre >
2477
+ < aside id ="validation-arraybuffer-example " class ="example " title ="Read data without validation using arraybuffer() ">
2478
+ < p >
2479
+ The {{InteractionOutput/arrayBuffer()}} can be used as a shortcut to skip the validation of the {{value()}} function.
2480
+ See < a href ="#non-validating-value-warning "> relevant warning</ a > for the implications.
2481
+ </ p >
2482
+ < pre >
2483
+ try{
2484
+ // output is an InteractionOutput instance
2485
+ const value = JSON.parse(Buffer.from(await output.arrayBuffer()).toString())
2486
+ // ... custom validation
2487
+ } catch(ex) {
2488
+ // deal with parsing errors.
2489
+ }
2490
+ </ pre >
2491
+ </ aside >
2466
2492
< p >
2467
2493
Finally, the next two examples shows the usage of a {{ReadableStream}} from an {{InteractionOutput}}.
2468
2494
</ p >
2469
- < pre class ="example " title ="Thing Client API example with readable stream (e.g., video stream) ">
2495
+ < pre id =" stream-example " class ="example " title ="Thing Client API example with readable stream (e.g., video stream) ">
2470
2496
/*{
2471
2497
"video": {
2472
2498
"description" : "the video stream of this camera",
0 commit comments