Skip to content

docs(binding-coap): document PSK usage with CoAPs#1479

Open
Pranav-0440 wants to merge 2 commits intoeclipse-thingweb:masterfrom
Pranav-0440:docs/coap-psk
Open

docs(binding-coap): document PSK usage with CoAPs#1479
Pranav-0440 wants to merge 2 commits intoeclipse-thingweb:masterfrom
Pranav-0440:docs/coap-psk

Conversation

@Pranav-0440
Copy link

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:

  • Thing Description example with psk scheme
  • Client configuration example
  • Explanation of required identity and psk fields

Closes #954

Copilot AI review requested due to automatic review settings February 12, 2026 17:50
@Pranav-0440 Pranav-0440 requested a review from JKRhb as a code owner February 12, 2026 17:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 psk security scheme.
  • Add a client-side configuration example for PSK credentials.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 127 to 130
const { CoapClientFactory } = require("@node-wot/binding-coap");

const servient = new Servient();
servient.addClientFactory(new CoapClientFactory());
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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());

Copilot uses AI. Check for mistakes.
Comment on lines 134 to 141
const thing = await WoT.consume(td);

// Configure PSK credentials
thing.setSecurity(td.securityDefinitions, {
identity: "Client_identity",
psk: "secretPSK",
});

Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Add example and explanation for configuring PSK security scheme in CoapsClient.

Closes eclipse-thingweb#954

Signed-off-by: Pranav Ghorpade <pranavghorpade61@gmail.com>
Add example and explanation for configuring PSK security scheme in CoapsClient.

Closes eclipse-thingweb#954

Signed-off-by: Pranav Ghorpade <pranavghorpade61@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documenting PSK usage with CoAPs

1 participant