diff --git a/README.md b/README.md
index f86a4b3bc..bf8d9935f 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
> A fast and extensible framework to connect any device with your application
[![Default CI Pipeline](https://github.com/eclipse-thingweb/node-wot/actions/workflows/ci.yaml/badge.svg)](https://github.com/eclipse-thingweb/node-wot/actions/workflows/ci.yaml)
-[](https://npm-stat.com/charts.html?package=%40node-wot%2Ftd-tools)
+[](https://npm-stat.com/charts.html?package=%40node-wot%2Fcore)
[![codecov](https://codecov.io/gh/eclipse-thingweb/node-wot/branch/master/graph/badge.svg)](https://codecov.io/gh/eclipse-thingweb/node-wot)
[![Telegram Group](https://img.shields.io/endpoint?color=neon&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fnodewot)](https://t.me/nodewot)
[![Discord](https://img.shields.io/badge/Discord-7289DA?logo=discord&logoColor=white&label=node-wot)](https://discord.gg/JXY2Jzefz3)
@@ -59,7 +59,7 @@ The framework can be used in two ways: as a library or as a CLI tool. In this se
### As a library
-The framework is composed by different packages that users can use as they please. The core package is `@node-wot/core` and it is the only mandatory package to install. The other packages are bindings that allow the framework to communicate with different protocols and optionally we offer a set of tools in the `@node-wot/td-tools` package.
+The framework is composed by different packages that users can use as they please. The core package is `@node-wot/core` and it is the only mandatory package to install. The other packages are bindings that allow the framework to communicate with different protocols.
#### Node.js
diff --git a/package-lock.json b/package-lock.json
index 357ddf67f..a8192a1e7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -924,6 +924,45 @@
"testdeck-watch": "bin/watch"
}
},
+ "node_modules/@thingweb/thing-model": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/@thingweb/thing-model/-/thing-model-1.0.3.tgz",
+ "integrity": "sha512-KAm2ux3A7B2lq0LkQw1Eze4g1w1c1zvhlaCA/TQFtX5LQoMsm6uqMuW6X+PcOzSsyKIekxYQjcgwC4rFZpfDbg==",
+ "dependencies": {
+ "ajv": "^8.11.0",
+ "ajv-formats": "^3.0.1",
+ "debug": "^4.3.4",
+ "json-placeholder-replacer": "^2.0.4",
+ "wot-thing-description-types": "1.1.0-09-November-2023",
+ "wot-thing-model-types": "^1.1.0-09-November-2023",
+ "wot-typescript-definitions": "0.8.0-SNAPSHOT.29"
+ }
+ },
+ "node_modules/@thingweb/thing-model/node_modules/ajv-formats": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz",
+ "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==",
+ "dependencies": {
+ "ajv": "^8.0.0"
+ },
+ "peerDependencies": {
+ "ajv": "^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "ajv": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@thingweb/thing-model/node_modules/json-placeholder-replacer": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/json-placeholder-replacer/-/json-placeholder-replacer-2.0.5.tgz",
+ "integrity": "sha512-pK/MgeylpZ1VAMO7s/tp5H6VVsbCIc9i+3cUILYnLTw2MT7xqKLowBQGQmFTtcz/O1414oK+f9C8jT79IADdag==",
+ "bin": {
+ "jpr": "dist/index.js",
+ "json-placeholder-replacer": "dist/index.js"
+ }
+ },
"node_modules/@tsconfig/node10": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
@@ -13104,7 +13143,6 @@
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"@types/node": "16.18.35",
"coap": "^1.4.0",
"multicast-dns": "^7.2.5",
@@ -13120,9 +13158,6 @@
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
"@node-wot/core": "0.8.15"
- },
- "devDependencies": {
- "@node-wot/td-tools": "0.8.15"
}
},
"packages/binding-http": {
@@ -13131,7 +13166,6 @@
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"@types/eventsource": "1.1.10",
"accept-language-parser": "1.5.0",
"basic-auth": "2.0.1",
@@ -13160,7 +13194,6 @@
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"node-mbus": "^2.2.4",
"wot-typescript-definitions": "0.8.0-SNAPSHOT.29"
}
@@ -13171,7 +13204,6 @@
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"modbus-serial": "^8.0.17",
"rxjs": "5.5.11",
"wot-typescript-definitions": "0.8.0-SNAPSHOT.29"
@@ -13183,7 +13215,6 @@
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"aedes": "^0.46.2",
"mqtt": "^5.3.2",
"rxjs": "5.5.11"
@@ -13195,7 +13226,6 @@
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"@types/node-netconf": "npm:@types/netconf@^2.0.0",
"@types/url-parse": "^1.4.3",
"case-1.5.3": "npm:case@^1.5.3",
@@ -13209,7 +13239,6 @@
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"node-opcua": "2.113.0",
"node-opcua-address-space": "2.113.0",
"node-opcua-basic-types": "2.113.0",
@@ -13246,7 +13275,6 @@
"dependencies": {
"@node-wot/binding-http": "0.8.15",
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"slugify": "^1.4.5",
"ws": "^7.5.10"
}
@@ -13264,7 +13292,6 @@
"@node-wot/binding-http": "0.8.15",
"@node-wot/binding-websockets": "0.8.15",
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"browserify": "^17.0.0",
"readable-stream4": "npm:readable-stream@^4.0.0"
}
@@ -13280,7 +13307,7 @@
"@node-wot/binding-mqtt": "0.8.15",
"@node-wot/binding-websockets": "0.8.15",
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
+ "@thingweb/thing-model": "^1.0.1",
"@types/lodash": "^4.14.199",
"ajv": "^8.11.0",
"commander": "^9.1.0",
@@ -13354,8 +13381,8 @@
"version": "0.8.15",
"license": "EPL-2.0 OR W3C-20150513",
"dependencies": {
- "@node-wot/td-tools": "0.8.15",
"@petamoriken/float16": "^3.1.1",
+ "@thingweb/thing-model": "^1.0.3",
"ajv": "^8.11.0",
"ajv-formats": "^2.1.1",
"cbor": "^8.1.0",
@@ -13383,7 +13410,6 @@
"@node-wot/binding-mqtt": "0.8.15",
"@node-wot/binding-opcua": "0.8.15",
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"rxjs": "5.5.11"
}
},
diff --git a/packages/binding-coap/package.json b/packages/binding-coap/package.json
index 48ba4ee9b..391381ea0 100644
--- a/packages/binding-coap/package.json
+++ b/packages/binding-coap/package.json
@@ -15,7 +15,6 @@
"types": "dist/coap.d.ts",
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"@types/node": "16.18.35",
"coap": "^1.4.0",
"multicast-dns": "^7.2.5",
diff --git a/packages/binding-coap/src/coap-client.ts b/packages/binding-coap/src/coap-client.ts
index 9cddc9033..0fd3f0cf3 100644
--- a/packages/binding-coap/src/coap-client.ts
+++ b/packages/binding-coap/src/coap-client.ts
@@ -22,10 +22,7 @@ import * as net from "net";
import { Subscription } from "rxjs/Subscription";
-// for Security definition
-import * as TD from "@node-wot/td-tools";
-
-import { ProtocolClient, Content, ContentSerdes, createLoggers } from "@node-wot/core";
+import { ProtocolClient, Content, ContentSerdes, SecurityScheme, createLoggers } from "@node-wot/core";
import { BlockSize, blockSizeToOptionValue, CoapForm, CoapMethodName } from "./coap";
import CoapServer from "./coap-server";
import { Readable } from "stream";
@@ -209,7 +206,7 @@ export default class CoapClient implements ProtocolClient {
this.agent.close();
}
- public setSecurity = (metadata: Array
): boolean => true;
+ public setSecurity = (metadata: Array): boolean => true;
private uriToOptions(uri: string): CoapRequestParams {
// eslint-disable-next-line n/no-deprecated-api
diff --git a/packages/binding-coap/src/coap-server.ts b/packages/binding-coap/src/coap-server.ts
index 6340f9265..b94d91a9f 100644
--- a/packages/binding-coap/src/coap-server.ts
+++ b/packages/binding-coap/src/coap-server.ts
@@ -17,7 +17,6 @@
* CoAP Server based on coap by mcollina
*/
-import * as TD from "@node-wot/td-tools";
import Servient, {
ProtocolServer,
ContentSerdes,
@@ -26,6 +25,7 @@ import Servient, {
ProtocolHelpers,
Content,
createLoggers,
+ Form,
} from "@node-wot/core";
import { Socket } from "dgram";
import { Server, createServer, registerFormat, IncomingMessage, OutgoingMessage } from "coap";
@@ -231,7 +231,7 @@ export default class CoapServer implements ProtocolServer {
return opValues;
}
- private addFormToAffordance(form: TD.Form, affordance: AffordanceElement): void {
+ private addFormToAffordance(form: Form, affordance: AffordanceElement): void {
const affordanceForms = affordance.forms;
if (affordanceForms == null) {
affordance.forms = [form];
@@ -317,7 +317,7 @@ export default class CoapServer implements ProtocolServer {
affordanceName?: string,
affordanceUriVariables?: PropertyElement["uriVariables"],
subprotocol?: string
- ): TD.Form {
+ ): Form {
const affordanceNamePattern = Helpers.updateInteractionNameWithUriVariablePattern(
affordanceName ?? "",
affordanceUriVariables,
@@ -330,14 +330,14 @@ export default class CoapServer implements ProtocolServer {
href += `/${encodeURIComponent(affordanceNamePattern)}`;
}
- const form = new TD.Form(href, offeredMediaType);
+ const form = new Form(href, offeredMediaType);
form.op = opValues;
form.subprotocol = subprotocol;
return form;
}
- private logHrefAssignment(form: TD.Form, affordanceType: string, affordanceName: string) {
+ private logHrefAssignment(form: Form, affordanceType: string, affordanceName: string) {
debug(`CoapServer on port ${this.port} assigns '${form.href}' to ${affordanceType} '${affordanceName}'`);
}
@@ -610,7 +610,7 @@ export default class CoapServer implements ProtocolServer {
}
private async handleReadMultipleProperties(
- forms: TD.Form[],
+ forms: Form[],
req: IncomingMessage,
contentType: string,
thing: ExposedThing,
@@ -817,7 +817,7 @@ export default class CoapServer implements ProtocolServer {
}
private createInteractionOptions(
- forms: TD.Form[],
+ forms: Form[],
thing: ExposedThing,
req: IncomingMessage,
contentType: string,
diff --git a/packages/binding-coap/src/coap.ts b/packages/binding-coap/src/coap.ts
index 7c96505db..4273185ae 100644
--- a/packages/binding-coap/src/coap.ts
+++ b/packages/binding-coap/src/coap.ts
@@ -13,7 +13,7 @@
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
********************************************************************************/
-import { Form } from "@node-wot/td-tools";
+import { Form } from "@node-wot/core";
export { default as CoapServer } from "./coap-server";
export { default as CoapClientFactory } from "./coap-client-factory";
diff --git a/packages/binding-coap/src/coaps-client.ts b/packages/binding-coap/src/coaps-client.ts
index 6379f6a9c..0120e831f 100644
--- a/packages/binding-coap/src/coaps-client.ts
+++ b/packages/binding-coap/src/coaps-client.ts
@@ -17,11 +17,9 @@
* CoAPS client based on node-coap-client by AlCalzone
*/
-import * as TD from "@node-wot/td-tools";
-
import { Subscription } from "rxjs/Subscription";
-import { ProtocolClient, Content, createLoggers, ContentSerdes } from "@node-wot/core";
+import { ProtocolClient, Content, createLoggers, ContentSerdes, SecurityScheme } from "@node-wot/core";
import { CoapForm, CoapMethodName, isValidCoapMethod, isSupportedCoapMethod } from "./coap";
import { CoapClient as coaps, CoapResponse, RequestMethod, SecurityParameters } from "node-coap-client";
import { Readable } from "stream";
@@ -164,13 +162,13 @@ export default class CoapsClient implements ProtocolClient {
// FIXME coap does not provide proper API to close Agent
}
- public setSecurity(metadata: Array, credentials?: pskSecurityParameters): boolean {
+ public setSecurity(metadata: Array, credentials?: pskSecurityParameters): boolean {
if (metadata === undefined || !Array.isArray(metadata) || metadata.length === 0) {
warn(`CoapsClient received empty security metadata`);
return false;
}
- const security: TD.SecurityScheme = metadata[0];
+ const security: SecurityScheme = metadata[0];
if (security.scheme === "psk" && credentials != null) {
this.authorization = { psk: {} };
diff --git a/packages/binding-coap/test/coap-server-test.ts b/packages/binding-coap/test/coap-server-test.ts
index ec9b76743..dc91d4da7 100644
--- a/packages/binding-coap/test/coap-server-test.ts
+++ b/packages/binding-coap/test/coap-server-test.ts
@@ -1,4 +1,3 @@
-import Servient, { ExposedThing, Content } from "@node-wot/core";
/********************************************************************************
* Copyright (c) 2018 Contributors to the Eclipse Foundation
*
@@ -18,10 +17,10 @@ import Servient, { ExposedThing, Content } from "@node-wot/core";
* Protocol test suite to test protocol implementations
*/
+import Servient, { ExposedThing, Content, Form } from "@node-wot/core";
import { suite, test } from "@testdeck/mocha";
import { expect, should } from "chai";
import { DataSchemaValue, InteractionInput, InteractionOptions, ThingDescription } from "wot-typescript-definitions";
-import * as TD from "@node-wot/td-tools";
import CoapServer from "../src/coap-server";
import { CoapClient } from "../src/coap";
import { Readable } from "stream";
@@ -69,7 +68,7 @@ class CoapServerTest {
const uri = `coap://localhost:${coapServer.getPort()}/test/`;
const coapClient = new CoapClient(coapServer);
- const resp = await coapClient.readResource(new TD.Form(uri + "properties/test"));
+ const resp = await coapClient.readResource(new Form(uri + "properties/test"));
expect((await resp.toBuffer()).toString()).to.equal('"testValue"');
await coapServer.stop();
@@ -104,10 +103,10 @@ class CoapServerTest {
const coapClient = new CoapClient(coapServer);
await coapClient.writeResource(
- new TD.Form(uri + "properties/test"),
+ new Form(uri + "properties/test"),
new Content("text/plain", Readable.from(Buffer.from("testValue1", "utf-8")))
);
- const resp = await coapClient.readResource(new TD.Form(uri + "properties/test"));
+ const resp = await coapClient.readResource(new Form(uri + "properties/test"));
const data = (await resp.toBuffer()).toString();
expect(data).to.equal('"testValue1"');
@@ -141,7 +140,7 @@ class CoapServerTest {
const coapClient = new CoapClient(coapServer);
const resp = await coapClient.invokeResource(
- new TD.Form(uri + "actions/try"),
+ new Form(uri + "actions/try"),
new Content("text/plain", Readable.from(Buffer.from("testValue1", "utf-8")))
);
expect((await resp.toBuffer()).toString()).to.equal('"TEST"');
@@ -173,7 +172,7 @@ class CoapServerTest {
const uri = `coap://localhost:${coapServer.getPort()}/test/`;
const coapClient = new CoapClient(coapServer);
- const form = new TD.Form(uri + "events/eventTest");
+ const form = new Form(uri + "events/eventTest");
const subscription = await coapClient.subscribeResource(form, (value) => {
/** */
});
@@ -223,7 +222,7 @@ class CoapServerTest {
const uri = `coap://[::1]:${coapServer.getPort()}/test/`;
const coapClient = new CoapClient(coapServer);
- const resp = await coapClient.readResource(new TD.Form(uri + "properties/test"));
+ const resp = await coapClient.readResource(new Form(uri + "properties/test"));
expect((await resp.toBuffer()).toString()).to.equal('"testValue"');
await coapClient.stop();
@@ -276,7 +275,7 @@ class CoapServerTest {
const uri = `coap://localhost:${coapServer.getPort()}/test/`;
const coapClient = new CoapClient(coapServer);
- const resp = await coapClient.readResource(new TD.Form(uri + "properties/test?id=testId&globalVarTest=test1"));
+ const resp = await coapClient.readResource(new Form(uri + "properties/test?id=testId&globalVarTest=test1"));
expect((await resp.toBuffer()).toString()).to.equal('"testValue"');
await coapServer.stop();
@@ -301,7 +300,7 @@ class CoapServerTest {
const uri = `coap://localhost:${coapServer.getPort()}/.well-known/core`;
const coapClient = new CoapClient(coapServer);
- const resp = await coapClient.readResource(new TD.Form(uri));
+ const resp = await coapClient.readResource(new Form(uri));
expect((await resp.toBuffer()).toString()).to.equal(
';rt="wot.thing";ct="50 432",;rt="wot.thing";ct="50 432"'
);
@@ -457,12 +456,12 @@ class CoapServerTest {
const propertyUri = `${baseUri}/properties/test?id=testId`;
- await coapClient.writeResource(new TD.Form(propertyUri), new Content("text/plain", Readable.from("on")));
+ await coapClient.writeResource(new Form(propertyUri), new Content("text/plain", Readable.from("on")));
- const response1 = await coapClient.readResource(new TD.Form(propertyUri));
+ const response1 = await coapClient.readResource(new Form(propertyUri));
expect((await response1.toBuffer()).toString()).to.equal('"on"');
- const response2 = await coapClient.invokeResource(new TD.Form(`${baseUri}/actions/try?step=5`));
+ const response2 = await coapClient.invokeResource(new Form(`${baseUri}/actions/try?step=5`));
expect((await response2.toBuffer()).toString()).to.equal('"TEST"');
await coapClient.stop();
@@ -546,19 +545,19 @@ class CoapServerTest {
const baseUri = `coap://localhost:${port}/testa/properties`;
// check values one by one first
- const responseInteger = await coapClient.readResource(new TD.Form(`${baseUri}/testInteger`));
+ const responseInteger = await coapClient.readResource(new Form(`${baseUri}/testInteger`));
expect(await decodeContent(responseInteger)).to.equal(integer);
- const responseBoolean = await coapClient.readResource(new TD.Form(`${baseUri}/testBoolean`));
+ const responseBoolean = await coapClient.readResource(new Form(`${baseUri}/testBoolean`));
expect(await decodeContent(responseBoolean)).to.equal(boolean);
- const responseString = await coapClient.readResource(new TD.Form(`${baseUri}/testString`));
+ const responseString = await coapClient.readResource(new Form(`${baseUri}/testString`));
expect(await decodeContent(responseString)).to.equal(string);
- const responseObject = await coapClient.readResource(new TD.Form(`${baseUri}/testObject`));
+ const responseObject = await coapClient.readResource(new Form(`${baseUri}/testObject`));
expect(await decodeContent(responseObject)).to.deep.equal(object);
- const responseArray = await coapClient.readResource(new TD.Form(`${baseUri}/testArray`));
+ const responseArray = await coapClient.readResource(new Form(`${baseUri}/testArray`));
expect(await decodeContent(responseArray)).to.deep.equal(array);
// check values of readallproperties
- const responseAll = await coapClient.readResource(new TD.Form(baseUri));
+ const responseAll = await coapClient.readResource(new Form(baseUri));
expect(await decodeContent(responseAll)).to.deep.equal({
image,
testInteger: integer,
diff --git a/packages/binding-file/package.json b/packages/binding-file/package.json
index 885d945f8..672d78215 100644
--- a/packages/binding-file/package.json
+++ b/packages/binding-file/package.json
@@ -13,9 +13,6 @@
],
"main": "dist/file.js",
"types": "dist/file.d.ts",
- "devDependencies": {
- "@node-wot/td-tools": "0.8.15"
- },
"dependencies": {
"@node-wot/core": "0.8.15"
},
diff --git a/packages/binding-file/src/file-client.ts b/packages/binding-file/src/file-client.ts
index 47334139d..d77ab21a1 100644
--- a/packages/binding-file/src/file-client.ts
+++ b/packages/binding-file/src/file-client.ts
@@ -16,8 +16,7 @@
/**
* File protocol binding
*/
-import { Form, SecurityScheme } from "@node-wot/td-tools";
-import { ProtocolClient, Content, createLoggers, ContentSerdes } from "@node-wot/core";
+import { ProtocolClient, Content, createLoggers, ContentSerdes, Form, SecurityScheme } from "@node-wot/core";
import { Subscription } from "rxjs/Subscription";
import { promises as asyncFs } from "fs";
import { fileURLToPath } from "node:url";
diff --git a/packages/binding-file/test/file-client-test.ts b/packages/binding-file/test/file-client-test.ts
index 080797ed5..2b995a1f9 100644
--- a/packages/binding-file/test/file-client-test.ts
+++ b/packages/binding-file/test/file-client-test.ts
@@ -13,10 +13,9 @@
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
********************************************************************************/
-import { Content, ContentSerdes } from "@node-wot/core";
+import { Content, ContentSerdes, Form } from "@node-wot/core";
import FileClient from "../src/file-client";
-import { Form } from "@node-wot/td-tools";
import { expect } from "chai";
import { promises as asyncFs } from "fs";
import { fileURLToPath } from "node:url";
diff --git a/packages/binding-http/package.json b/packages/binding-http/package.json
index 6a6a8a0f0..decd85759 100644
--- a/packages/binding-http/package.json
+++ b/packages/binding-http/package.json
@@ -29,7 +29,6 @@
},
"dependencies": {
"@node-wot/core": "0.8.15",
- "@node-wot/td-tools": "0.8.15",
"@types/eventsource": "1.1.10",
"accept-language-parser": "1.5.0",
"basic-auth": "2.0.1",
diff --git a/packages/binding-http/src/codecs/tuya-codec.ts b/packages/binding-http/src/codecs/tuya-codec.ts
index d6165cd45..ea932c951 100644
--- a/packages/binding-http/src/codecs/tuya-codec.ts
+++ b/packages/binding-http/src/codecs/tuya-codec.ts
@@ -13,8 +13,7 @@
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
********************************************************************************/
-import { ContentCodec } from "@node-wot/core";
-import * as TD from "@node-wot/td-tools";
+import { ContentCodec, DataSchema } from "@node-wot/core";
import { DataSchemaValue } from "wot-typescript-definitions";
interface TuyaOutput {
@@ -30,7 +29,7 @@ export default class HttpTuyaCodec implements ContentCodec {
return "application/json+tuya";
}
- bytesToValue(bytes: Buffer, schema: TD.DataSchema, parameters: { [key: string]: string }): DataSchemaValue {
+ bytesToValue(bytes: Buffer, schema: DataSchema, parameters: { [key: string]: string }): DataSchemaValue {
const parsedBody: TuyaOutput = JSON.parse(bytes.toString());
const success = parsedBody.success ?? false;
@@ -46,7 +45,7 @@ export default class HttpTuyaCodec implements ContentCodec {
throw new Error("Property not found");
}
- valueToBytes(value: unknown, schema: TD.DataSchema, parameters?: { [key: string]: string }): Buffer {
+ valueToBytes(value: unknown, schema: DataSchema, parameters?: { [key: string]: string }): Buffer {
const obj = {
commands: [
{
diff --git a/packages/binding-http/src/credential.ts b/packages/binding-http/src/credential.ts
index 540688b4b..4414a1746 100644
--- a/packages/binding-http/src/credential.ts
+++ b/packages/binding-http/src/credential.ts
@@ -15,7 +15,7 @@
import { Token } from "client-oauth2";
import fetch, { Request } from "node-fetch";
-import { BasicSecurityScheme, APIKeySecurityScheme, BearerSecurityScheme } from "@node-wot/td-tools";
+import { BasicSecurityScheme, APIKeySecurityScheme, BearerSecurityScheme } from "@node-wot/core";
import * as crypto from "crypto";
import * as queryString from "query-string";
import { TuyaCustomBearerSecurityScheme } from "./http";
diff --git a/packages/binding-http/src/http-browser.ts b/packages/binding-http/src/http-browser.ts
index 05c6392bc..77365bf57 100644
--- a/packages/binding-http/src/http-browser.ts
+++ b/packages/binding-http/src/http-browser.ts
@@ -13,7 +13,7 @@
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
********************************************************************************/
-import * as TD from "@node-wot/td-tools";
+import { Form, SecurityScheme } from "@node-wot/core";
import { Headers, Response } from "node-fetch";
@@ -39,7 +39,7 @@ export interface HttpConfig {
allowSelfSigned?: boolean;
serverKey?: string;
serverCert?: string;
- security?: TD.SecurityScheme;
+ security?: SecurityScheme;
}
export class HttpHeader {
@@ -47,7 +47,7 @@ export class HttpHeader {
public "http:fieldValue": unknown;
}
-export class HttpForm extends TD.Form {
+export class HttpForm extends Form {
public "http:methodName"?: string; // "GET", "PUT", "POST", "DELETE"
public "http:headers"?: Array | HttpHeader;
}
diff --git a/packages/binding-http/src/http-client-impl.ts b/packages/binding-http/src/http-client-impl.ts
index 14c7ec9ed..e6e7abbad 100644
--- a/packages/binding-http/src/http-client-impl.ts
+++ b/packages/binding-http/src/http-client-impl.ts
@@ -22,10 +22,18 @@ import * as https from "https";
import { Subscription } from "rxjs/Subscription";
-import * as TD from "@node-wot/td-tools";
-// for Security definition
-
-import { ProtocolClient, Content, ProtocolHelpers, createLoggers, ContentSerdes } from "@node-wot/core";
+import {
+ ProtocolClient,
+ Content,
+ ProtocolHelpers,
+ createLoggers,
+ ContentSerdes,
+ SecurityScheme,
+ BasicSecurityScheme,
+ BearerSecurityScheme,
+ APIKeySecurityScheme,
+ OAuth2SecurityScheme,
+} from "@node-wot/core";
import { HttpForm, HttpHeader, HttpConfig, HTTPMethodName, TuyaCustomBearerSecurityScheme } from "./http";
import fetch, { Request, RequestInit, Response } from "node-fetch";
import { Buffer } from "buffer";
@@ -251,29 +259,29 @@ export default class HttpClient implements ProtocolClient {
this.agent?.destroy?.();
}
- public setSecurity(metadata: Array, credentials?: unknown): boolean {
+ public setSecurity(metadata: Array, credentials?: unknown): boolean {
if (metadata === undefined || !Array.isArray(metadata) || metadata.length === 0) {
warn("HttpClient without security");
return false;
}
// TODO support for multiple security schemes
- const security: TD.SecurityScheme = metadata[0];
+ const security: SecurityScheme = metadata[0];
switch (security.scheme) {
case "basic": {
- const securityBasic: TD.BasicSecurityScheme = security;
+ const securityBasic: BasicSecurityScheme = security;
this.credential = new BasicCredential(credentials as BasicCredentialConfiguration, securityBasic);
break;
}
case "bearer": {
- const securityBearer: TD.BearerSecurityScheme = security;
+ const securityBearer: BearerSecurityScheme = security;
this.credential = new BearerCredential(credentials as BearerCredentialConfiguration, securityBearer);
break;
}
case "apikey": {
- const securityAPIKey: TD.APIKeySecurityScheme = security;
+ const securityAPIKey: APIKeySecurityScheme = security;
this.credential = new BasicKeyCredential(
credentials as BasicKeyCredentialConfiguration,
@@ -282,7 +290,7 @@ export default class HttpClient implements ProtocolClient {
break;
}
case "oauth2": {
- const securityOAuth: TD.OAuth2SecurityScheme = security;
+ const securityOAuth: OAuth2SecurityScheme = security;
if (securityOAuth.flow === "client") {
securityOAuth.flow = "client_credentials";
diff --git a/packages/binding-http/src/http-server.ts b/packages/binding-http/src/http-server.ts
index 414bd4ba6..6b17203a6 100644
--- a/packages/binding-http/src/http-server.ts
+++ b/packages/binding-http/src/http-server.ts
@@ -22,18 +22,18 @@ import * as http from "http";
import * as https from "https";
import bauth from "basic-auth";
-import * as TD from "@node-wot/td-tools";
import Servient, {
ProtocolServer,
ContentSerdes,
Helpers,
ExposedThing,
ProtocolHelpers,
+ Form,
+ OAuth2SecurityScheme,
createLoggers,
} from "@node-wot/core";
import { HttpConfig, HttpForm, OAuth2ServerConfig } from "./http";
import createValidator, { Validator } from "./oauth-token-validation";
-import { OAuth2SecurityScheme } from "@node-wot/td-tools";
import slugify from "slugify";
import { ActionElement, EventElement, PropertyElement } from "wot-thing-description-types";
import { MiddlewareRequestHandler } from "./http-server-middleware";
@@ -315,7 +315,7 @@ export default class HttpServer implements ProtocolServer {
return false;
}
- private addUrlRewriteEndpoints(form: TD.Form, forms: Array): void {
+ private addUrlRewriteEndpoints(form: Form, forms: Array