@node-wot/binding-http
Advanced tools
Comparing version 0.8.2 to 0.8.3
@@ -65,3 +65,3 @@ "use strict"; | ||
if (token === undefined || token === null) { | ||
throw new Error(`No Bearer credentionals for Thing`); | ||
throw new Error(`No Bearer credentials for Thing`); | ||
} | ||
@@ -68,0 +68,0 @@ this.token = token; |
@@ -92,3 +92,3 @@ "use strict"; | ||
const body = core_1.ProtocolHelpers.toNodeStream(result.body); | ||
return { type: result.headers.get("content-type"), body }; | ||
return new core_1.Content(result.headers.get("content-type"), body); | ||
}); | ||
@@ -140,3 +140,3 @@ } | ||
const body = core_1.ProtocolHelpers.toNodeStream(result.body); | ||
return { type: result.headers.get("content-type"), body }; | ||
return new core_1.Content(result.headers.get("content-type"), body); | ||
}); | ||
@@ -219,3 +219,3 @@ } | ||
basicCredential.password === undefined) { | ||
throw new Error(`No Basic credentionals for Thing`); | ||
throw new Error(`No Basic credentials for Thing`); | ||
} | ||
@@ -227,3 +227,3 @@ this.proxyRequest.headers.set("proxy-authorization", "Basic " + buffer_1.Buffer.from(basicCredential.username + ":" + basicCredential.password).toString("base64")); | ||
if (credentials === undefined || tokenCredentials.token === undefined) { | ||
throw new Error(`No Bearer credentionals for Thing`); | ||
throw new Error(`No Bearer credentials for Thing`); | ||
} | ||
@@ -230,0 +230,0 @@ this.proxyRequest.headers.set("proxy-authorization", "Bearer " + tokenCredentials.token); |
@@ -173,13 +173,25 @@ "use strict"; | ||
} | ||
updateInteractionNameWithUriVariablePattern(interactionName, uriVariables) { | ||
if (uriVariables && Object.keys(uriVariables).length > 0) { | ||
updateInteractionNameWithUriVariablePattern(interactionName, uriVariables = {}, thingVariables = {}) { | ||
const variables = Object.assign({}, uriVariables, thingVariables); | ||
if (Object.keys(variables).length > 0) { | ||
let pattern = "{?"; | ||
let index = 0; | ||
for (const key in uriVariables) { | ||
if (index !== 0) { | ||
pattern += ","; | ||
if (uriVariables) { | ||
for (const key in uriVariables) { | ||
if (index !== 0) { | ||
pattern += ","; | ||
} | ||
pattern += encodeURIComponent(key); | ||
index++; | ||
} | ||
pattern += encodeURIComponent(key); | ||
index++; | ||
} | ||
if (thingVariables) { | ||
for (const key in thingVariables) { | ||
if (index !== 0) { | ||
pattern += ","; | ||
} | ||
pattern += encodeURIComponent(key); | ||
index++; | ||
} | ||
} | ||
pattern += "}"; | ||
@@ -230,3 +242,3 @@ return encodeURIComponent(interactionName) + pattern; | ||
if (removedThing) { | ||
info(`HttpServer succesfully destroyed '${removedThing.title}'`); | ||
info(`HttpServer successfully destroyed '${removedThing.title}'`); | ||
} | ||
@@ -290,3 +302,3 @@ else { | ||
for (const propertyName in thing.properties) { | ||
const propertyNamePattern = this.updateInteractionNameWithUriVariablePattern(propertyName, thing.properties[propertyName].uriVariables); | ||
const propertyNamePattern = this.updateInteractionNameWithUriVariablePattern(propertyName, thing.properties[propertyName].uriVariables, thing.uriVariables); | ||
const href = base + "/" + this.PROPERTY_DIR + "/" + propertyNamePattern; | ||
@@ -332,3 +344,3 @@ const form = new TD.Form(href, type); | ||
for (const actionName in thing.actions) { | ||
const actionNamePattern = this.updateInteractionNameWithUriVariablePattern(actionName, thing.actions[actionName].uriVariables); | ||
const actionNamePattern = this.updateInteractionNameWithUriVariablePattern(actionName, thing.actions[actionName].uriVariables, thing.uriVariables); | ||
const href = base + "/" + this.ACTION_DIR + "/" + actionNamePattern; | ||
@@ -347,3 +359,3 @@ const form = new TD.Form(href, type); | ||
for (const eventName in thing.events) { | ||
const eventNamePattern = this.updateInteractionNameWithUriVariablePattern(eventName, thing.events[eventName].uriVariables); | ||
const eventNamePattern = this.updateInteractionNameWithUriVariablePattern(eventName, thing.events[eventName].uriVariables, thing.uriVariables); | ||
const href = base + "/" + this.EVENT_DIR + "/" + eventNamePattern; | ||
@@ -557,3 +569,3 @@ const form = new TD.Form(href, type); | ||
const content = propMap.get(key); | ||
const data = yield core_1.ProtocolHelpers.readStreamFully(content.body); | ||
const data = yield content.toBuffer(); | ||
recordResponse[key] = data.toString(); | ||
@@ -626,3 +638,3 @@ } | ||
try { | ||
yield thing.handleWriteProperty(segments[3], { body: req, type: contentType }, options); | ||
yield thing.handleWriteProperty(segments[3], new core_1.Content(contentType, req), options); | ||
res.writeHead(204); | ||
@@ -661,3 +673,3 @@ res.end("Changed"); | ||
try { | ||
const output = yield thing.handleInvokeAction(segments[3], { body: req, type: contentType }, options); | ||
const output = yield thing.handleInvokeAction(segments[3], new core_1.Content(contentType, req), options); | ||
if (output) { | ||
@@ -664,0 +676,0 @@ res.setHeader("Content-Type", output.type); |
@@ -49,3 +49,3 @@ "use strict"; | ||
const body = core_1.ProtocolHelpers.toNodeStream(result.body); | ||
next({ type: result.headers.get("content-type"), body }); | ||
next(new core_1.Content(result.headers.get("content-type"), body)); | ||
polling(false); | ||
@@ -83,3 +83,3 @@ } | ||
debug(`HttpClient received ${JSON.stringify(event)} from ${this.form.href}`); | ||
const output = { type: this.form.contentType, body: stream_1.Readable.from(JSON.stringify(event)) }; | ||
const output = new core_1.Content(this.form.contentType, stream_1.Readable.from(JSON.stringify(event))); | ||
next(output); | ||
@@ -86,0 +86,0 @@ }; |
{ | ||
"name": "@node-wot/binding-http", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "HTTP client & server protocol binding for node-wot", | ||
@@ -55,4 +55,4 @@ "author": "Eclipse Thingweb <thingweb-dev@eclipse.org> (https://thingweb.io/)", | ||
"dependencies": { | ||
"@node-wot/core": "0.8.2", | ||
"@node-wot/td-tools": "0.8.2", | ||
"@node-wot/core": "0.8.3", | ||
"@node-wot/td-tools": "0.8.3", | ||
"@types/eventsource": "^1.1.2", | ||
@@ -67,3 +67,3 @@ "accept-language-parser": "1.5.0", | ||
"slugify": "^1.4.5", | ||
"wot-thing-description-types": "^1.1.0-10-August-2022" | ||
"wot-thing-description-types": "^1.1.0-13-October-2022" | ||
}, | ||
@@ -70,0 +70,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178056
2173
+ Added@node-wot/core@0.8.3(transitive)
+ Added@node-wot/td-tools@0.8.3(transitive)
- Removed@node-wot/core@0.8.2(transitive)
- Removed@node-wot/td-tools@0.8.2(transitive)
Updated@node-wot/core@0.8.3
Updated@node-wot/td-tools@0.8.3