Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

@node-wot/binding-file

Package Overview
Dependencies
1
Maintainers
4
Versions
27
Issues
File Explorer

Advanced tools

@node-wot/binding-file

File client protocol binding for node-wot

    0.8.1latest

Version published
Maintainers
4
Yearly downloads
12,461
increased by365.48%

Weekly downloads

Changelog

Source

v0.8.1

Summary of updates

  • binding-firestore re-introduced
  • added tuya to binding-http
  • other improvements / bug-fixes

What's Changed (Automatically generated release notes)

  • fix: use proper handleUnobserveProperty call instead of event by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/734
  • Use new statistics links by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/732
  • refactor: remove obsolete / deprecated code by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/731
  • chore: increase version to 0.8.1 and fix dependency issues with TMs, CoAP, OPC-UA by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/727
  • fix template and change to async-await paradigm by @FadySalama in https://github.com/eclipse/thingweb.node-wot/pull/740
  • chore(binding-opcua): update packages by @erossignon in https://github.com/eclipse/thingweb.node-wot/pull/739
  • chore(deps): bump coap to 1.0.8 by @JKRhb in https://github.com/eclipse/thingweb.node-wot/pull/744
  • Fix CoapClientFactory constructor, clean up examples by @JKRhb in https://github.com/eclipse/thingweb.node-wot/pull/742
  • chore(binding-http): add HTTP examples from README as files by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/746
  • added tuya binding with security and codec management by @SeppiaBrilla in https://github.com/eclipse/thingweb.node-wot/pull/735
  • feat: cli to accept servient config through file/.env/cli-arguments by @fillobotto in https://github.com/eclipse/thingweb.node-wot/pull/733
  • adapted binding-firestore to 0.8 (Issue-482) by @hidetak in https://github.com/eclipse/thingweb.node-wot/pull/737
  • fix: value() might also return undefined if no value is expected by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/748
  • Exposed template update 0.8.x by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/752
  • issue-755 Measures for binding-firebase test failure by @hidetak in https://github.com/eclipse/thingweb.node-wot/pull/757
  • Cleanup td definititions (v2) by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/750
  • chore: regenerate package-lock.json for next release by @danielpeintner in https://github.com/eclipse/thingweb.node-wot/pull/759

New Contributors

  • @SeppiaBrilla made their first contribution in https://github.com/eclipse/thingweb.node-wot/pull/735
  • @fillobotto made their first contribution in https://github.com/eclipse/thingweb.node-wot/pull/733

Full Changelog: https://github.com/eclipse/thingweb.node-wot/compare/v0.8.0...v0.8.1

Readme

Source

File Binding of node-wot

Protocol specifier

The protocol prefix handled by this binding is file://.

Getting Started

In the following examples, how to use the File binding of node-wot is shown.

Prerequisites

  • npm install @node-wot/core
  • npm install @node-wot/binding-file
  • local test file test.txt with content

Example 1

The example tries to load an internal TestThing TD and reads the fileContent property, which exposes the content of the file test.txt.

node example1.js

// example.js1 Servient = require("@node-wot/core").Servient; FileClientFactory = require("@node-wot/binding-file").FileClientFactory; // create Servient and add File binding let servient = new Servient(); servient.addClientFactory(new FileClientFactory(null)); td = { id: "urn:dev:wot:org:w3:testthing:file", title: "TestThing", "@type": "Thing", security: ["nosec_sc"], properties: { fileContent: { type: "string", readOnly: true, observable: false, forms: [ { href: "file://test.txt", contentType: "text/plain", op: ["readproperty"], }, ], }, }, securityDefinitions: { nosec_sc: { scheme: "nosec", }, }, }; // try to read property that exposes the content of file test.txt try { servient.start().then(async (WoT) => { const thing = await WoT.consume(td); // read property "fileContent" and print the content const read1 = await thing.readProperty("fileContent"); console.log("Content of File:\n", await read1.value()); }); } catch (err) { console.error("Script error:", err); }

Example 2

The example tries to load a locally stored TestThing TD and reads the fileContent property, which exposes the content of the file test.txt.

Prerequisites

  • local TD file TD.jsonld with content as in Example 1

node example2.js

// example2.js Servient = require("@node-wot/core").Servient; FileClientFactory = require("@node-wot/binding-file").FileClientFactory; Helpers = require("@node-wot/core").Helpers; // create Servient and add File binding let servient = new Servient(); servient.addClientFactory(new FileClientFactory(null)); let wotHelper = new Helpers(servient); wotHelper .fetch("file://TD.jsonld") .then(async (td) => { // using await for serial execution (note 'async' in then() of fetch()) try { const WoT = await servient.start(); const thing = await WoT.consume(td); // read property "fileContent" and print the content const read1 = await thing.readProperty("fileContent"); console.log("Content of File:\n" + (await read1.value())); } catch (err) { console.error("Script error:", err); } }) .catch((err) => { console.error("Fetch error:", err); });

More Details

See https://github.com/eclipse/thingweb.node-wot/

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc