docs(binding-coap): document PSK usage with CoAPs#1479
docs(binding-coap): document PSK usage with CoAPs#1479Pranav-0440 wants to merge 2 commits intoeclipse-thingweb:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds documentation to the CoAP binding README describing how to use DTLS PSK with coaps://, addressing the gap noted in issue #954.
Changes:
- Document PSK support for CoAPs (
coaps://) and where it is implemented. - Add a TD snippet showing a
psksecurity scheme. - Add a client-side configuration example for PSK credentials.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/binding-coap/README.md
Outdated
| const { CoapClientFactory } = require("@node-wot/binding-coap"); | ||
|
|
||
| const servient = new Servient(); | ||
| servient.addClientFactory(new CoapClientFactory()); |
There was a problem hiding this comment.
The example uses CoapClientFactory, but coaps:// URIs require registering CoapsClientFactory (scheme is coaps). With only CoapClientFactory, WoT.requestThingDescription("coaps://...") / interactions will fail because the Servient has no client factory for the coaps scheme. Update the import and addClientFactory call to use CoapsClientFactory for this section (or register both factories if you want to support both schemes in the same script).
| const { CoapClientFactory } = require("@node-wot/binding-coap"); | |
| const servient = new Servient(); | |
| servient.addClientFactory(new CoapClientFactory()); | |
| const { CoapsClientFactory } = require("@node-wot/binding-coap"); | |
| const servient = new Servient(); | |
| servient.addClientFactory(new CoapsClientFactory()); |
packages/binding-coap/README.md
Outdated
| const thing = await WoT.consume(td); | ||
|
|
||
| // Configure PSK credentials | ||
| thing.setSecurity(td.securityDefinitions, { | ||
| identity: "Client_identity", | ||
| psk: "secretPSK", | ||
| }); | ||
|
|
There was a problem hiding this comment.
thing.setSecurity(...) is not part of the node-wot ConsumedThing API, and td.securityDefinitions is not the type expected by protocol-client setSecurity (it expects an array of resolved SecuritySchemes). In node-wot, credentials should be provided via servient.addCredentials(...) keyed by the Thing id (td.id), and the runtime will apply them automatically based on the TD's security/securityDefinitions when the client is selected.
| const thing = await WoT.consume(td); | |
| // Configure PSK credentials | |
| thing.setSecurity(td.securityDefinitions, { | |
| identity: "Client_identity", | |
| psk: "secretPSK", | |
| }); | |
| // Configure PSK credentials for this Thing | |
| servient.addCredentials({ | |
| [td.id]: { | |
| identity: "Client_identity", | |
| psk: "secretPSK", | |
| }, | |
| }); | |
| const thing = await WoT.consume(td); |
Add example and explanation for configuring PSK security scheme in CoapsClient. Closes eclipse-thingweb#954 Signed-off-by: Pranav Ghorpade <pranavghorpade61@gmail.com>
cd7b3fd to
d4fd2e5
Compare
Add example and explanation for configuring PSK security scheme in CoapsClient. Closes eclipse-thingweb#954 Signed-off-by: Pranav Ghorpade <pranavghorpade61@gmail.com>
This PR documents PSK usage with CoAPs in the binding-coap README.
Currently, PSK support is implemented in CoapsClient but not documented.
This change adds:
Closes #954