New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nebulous/skynet

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nebulous/skynet - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

8

CHANGELOG.md
# Changelog
## [2.0.1]
### Changed
- Remove leading slash in directory path before uploading an absolute path.
- Fixed length limits for request bodies.
- Fixed upload errors due to missing headers.
## [2.0.0]

@@ -4,0 +12,0 @@

2

package.json
{
"name": "@nebulous/skynet",
"version": "2.0.0",
"version": "2.0.1",
"description": "Skynet SDK",

@@ -5,0 +5,0 @@ "repository": "https://github.com/NebulousLabs/nodejs-skynet",

# Skynet NodeJS SDK
[![Version](https://img.shields.io/github/package-json/v/NebulousLabs/nodejs-skynet)](https://www.npmjs.com/package/@nebulous/skynet)
[![Build Status](https://img.shields.io/github/workflow/status/NebulousLabs/nodejs-skynet/Pull%20Request)](https://github.com/NebulousLabs/nodejs-skynet/actions)
[![Contributors](https://img.shields.io/github/contributors/NebulousLabs/nodejs-skynet)](https://github.com/NebulousLabs/nodejs-skynet/graphs/contributors)
[![License](https://img.shields.io/github/license/NebulousLabs/nodejs-skynet)](https://github.com/NebulousLabs/nodejs-skynet)
An SDK for integrating Skynet into Node.js applications.

@@ -4,0 +9,0 @@

@@ -32,2 +32,9 @@ const axios = require("axios");

if (!config.headers) {
config.headers = {};
}
if (config.customUserAgent) {
config.headers["User-Agent"] = config.customUserAgent;
}
return axios({

@@ -38,3 +45,3 @@ url: url,

params: config.params,
headers: config.customUserAgent && { "User-Agent": config.customUserAgent },
headers: config.headers,
auth: config.APIKey && { username: "", password: config.APIKey },

@@ -49,2 +56,4 @@ responseType: config.responseType,

},
maxContentLength: Infinity,
maxBodyLength: Infinity,
});

@@ -51,0 +60,0 @@ }

@@ -52,2 +52,19 @@ const axios = require("axios");

});
it("should use custom connection options if defined on the client", () => {
const tmpFile = tmp.fileSync();
const client = new SkynetClient("", { APIKey: "foobar", customUserAgent: "Sia-Agent" });
client.downloadFile(tmpFile.name, skylink, { APIKey: "barfoo", customUserAgent: "Sia-Agent-2" });
expect(axios).toHaveBeenCalledWith(
expect.objectContaining({
url: `${portalUrl}/${skylink}`,
auth: { username: "", password: "barfoo" },
headers: expect.objectContaining({ "User-Agent": "Sia-Agent-2" }),
})
);
tmpFile.removeCallback();
});
});

@@ -58,6 +58,8 @@ "use strict";

let basepath = path;
if (basepath != "/") {
// Ensure the basepath ends in a slash.
if (!basepath.endsWith("/")) {
basepath += "/";
// Normalize the slash on non-Unix filesystems.
basepath = p.normalize(basepath);
}
basepath = p.normalize(basepath);

@@ -73,3 +75,7 @@ for (const file of walkDirectory(path)) {

const params = { filename: opts.customDirname || path };
let filename = opts.customDirname || path;
if (filename.startsWith("/")) {
filename = filename.slice(1);
}
const params = { filename };

@@ -76,0 +82,0 @@ if (opts.dryRun) params.dryrun = true;

const axios = require("axios");
const fs = require("fs");
const tmp = require("tmp");

@@ -27,6 +29,8 @@ const { SkynetClient, defaultPortalUrl, uriSkynetPrefix } = require("../index");

_streams: expect.arrayContaining([
expect.stringContaining(`Content-Disposition: form-data; name="file"; filename="file1.txt"`),
expect.stringContaining(
'Content-Disposition: form-data; name="file"; filename="file1.txt"\r\nContent-Type: text/plain'
),
]),
}),
headers: expect.anything(),
headers: expect.objectContaining({ "content-type": expect.stringContaining("multipart/form-data") }),
params: expect.anything(),

@@ -74,3 +78,3 @@ })

auth: { username: "", password: "foobar" },
headers: { "User-Agent": "Sia-Agent" },
headers: expect.objectContaining({ "User-Agent": "Sia-Agent" }),
params: expect.anything(),

@@ -95,3 +99,3 @@ })

auth: { username: "", password: "barfoo" },
headers: { "User-Agent": "Sia-Agent-2" },
headers: expect.objectContaining({ "User-Agent": "Sia-Agent-2" }),
params: expect.anything(),

@@ -102,2 +106,11 @@ })

it("should upload tmp files", async () => {
const file = tmp.fileSync({ postfix: ".json" });
fs.writeFileSync(file.fd, JSON.stringify("testing"));
const data = await client.uploadFile(file.name);
expect(data).toEqual(sialink);
});
it("should return skylink on success", async () => {

@@ -148,3 +161,3 @@ const data = await client.uploadFile(filename);

portalDirectoryFileFieldname: "filetest",
customDirname: "testpath",
customDirname: "/testpath",
dryRun: true,

@@ -151,0 +164,0 @@ });

@@ -65,3 +65,6 @@ "use strict";

function trimSiaPrefix(str) {
return str.replace(uriSkynetPrefix, "");
if (str.startsWith(uriSkynetPrefix)) {
return str.slice(uriSkynetPrefix.length);
}
return str;
}

@@ -68,0 +71,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc