You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@node-wot/binding-file

Package Overview
Dependencies
Maintainers
0
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node-wot/binding-file - npm Package Compare versions

Comparing version

to
0.9.0

0

dist/file-client-factory.d.ts

@@ -0,0 +0,0 @@ import { ProtocolClientFactory, ProtocolClient } from "@node-wot/core";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { ProtocolClient, Content, Form, SecurityScheme } from "@node-wot/core";

79

dist/file-client.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -23,54 +14,36 @@ const core_1 = require("@node-wot/core");

}
readFromFile(uri, contentType) {
return __awaiter(this, void 0, void 0, function* () {
const filePath = (0, node_url_1.fileURLToPath)(uri);
debug(`Reading file of Content-Type ${contentType} from path ${filePath}.`);
const fileHandle = yield fs_1.promises.open(filePath);
const body = fileHandle.createReadStream();
return new core_1.Content(contentType, body);
});
async readFromFile(uri, contentType) {
const filePath = (0, node_url_1.fileURLToPath)(uri);
debug(`Reading file of Content-Type ${contentType} from path ${filePath}.`);
const fileHandle = await fs_1.promises.open(filePath);
const body = fileHandle.createReadStream();
return new core_1.Content(contentType, body);
}
readResource(form) {
return __awaiter(this, void 0, void 0, function* () {
const formContentType = form.contentType;
if (formContentType == null) {
debug(`Found no Content-Type for Form, defaulting to ${core_1.ContentSerdes.DEFAULT}`);
}
const contentType = formContentType !== null && formContentType !== void 0 ? formContentType : core_1.ContentSerdes.DEFAULT;
return this.readFromFile(form.href, contentType);
});
async readResource(form) {
const formContentType = form.contentType;
if (formContentType == null) {
debug(`Found no Content-Type for Form, defaulting to ${core_1.ContentSerdes.DEFAULT}`);
}
const contentType = formContentType ?? core_1.ContentSerdes.DEFAULT;
return this.readFromFile(form.href, contentType);
}
writeResource(form, content) {
return __awaiter(this, void 0, void 0, function* () {
const filePath = (0, node_url_1.fileURLToPath)(form.href);
yield fs_1.promises.writeFile(filePath, content.body);
});
async writeResource(form, content) {
const filePath = (0, node_url_1.fileURLToPath)(form.href);
await fs_1.promises.writeFile(filePath, content.body);
}
invokeResource(form, content) {
return __awaiter(this, void 0, void 0, function* () {
throw new Error("FileClient does not implement invoke");
});
async invokeResource(form, content) {
throw new Error("FileClient does not implement invoke");
}
unlinkResource(form) {
return __awaiter(this, void 0, void 0, function* () {
throw new Error("FileClient does not implement unlink");
});
async unlinkResource(form) {
throw new Error("FileClient does not implement unlink");
}
requestThingDescription(uri) {
return __awaiter(this, void 0, void 0, function* () {
return this.readFromFile(uri, "application/td+json");
});
async requestThingDescription(uri) {
return this.readFromFile(uri, "application/td+json");
}
subscribeResource(form, next, error, complete) {
return __awaiter(this, void 0, void 0, function* () {
throw new Error("FileClient does not implement subscribe");
});
async subscribeResource(form, next, error, complete) {
throw new Error("FileClient does not implement subscribe");
}
start() {
return __awaiter(this, void 0, void 0, function* () {
});
async start() {
}
stop() {
return __awaiter(this, void 0, void 0, function* () {
});
async stop() {
}

@@ -77,0 +50,0 @@ }

@@ -0,0 +0,0 @@ export { default as FileClient } from "./file-client";

@@ -0,0 +0,0 @@ "use strict";

{
"name": "@node-wot/binding-file",
"version": "0.8.16",
"version": "0.9.0",
"description": "File client protocol binding for node-wot",

@@ -17,3 +17,4 @@ "author": "Eclipse Thingweb <thingweb-dev@eclipse.org> (https://thingweb.io/)",

"dependencies": {
"@node-wot/core": "0.8.16"
"@node-wot/core": "0.9.0",
"rxjs": "5.5.11"
},

@@ -20,0 +21,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet