thingweb / node-wot

Web of Things implementation on Node.js
27 stars 13 forks source link

Conflict with writable "false" and thing.writeProperty(...) from handler #90

Closed danielpeintner closed 6 years ago

danielpeintner commented 6 years ago

Let's assume the "writable" property from a counter value is set to false. Hence, it should not be allowed to set a value directly withthing.writeProperty(...) .

The assumption is that counter value changes are performed through action handlers. For example

thing.setActionHandler(
    "increment",
    (parameters) => {
        return thing.readProperty("counter ").then(function(count){
            let value = count + 1;
            thing.writeProperty("counter", value);
        });
    }
);

I wonder "how" the node-wot runtime in such a case can detect whether thing.writeProperty(...) has been called through an action handler (which is allowed) compared to "directly" calling thing.writeProperty(...) (which should be forbidden)?

Note: currently in node-wot we do not check whether a property value is writable or not when performing a thing.writeProperty(...)

mkovatsc commented 6 years ago

See https://github.com/thingweb/node-wot/issues/80 Check is done in the PropertyResourceListener, as only writes from the outside should be rejected. Closing.