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
1
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 0.0.8 to 0.0.9

44

index.js

@@ -0,1 +1,2 @@

const p = require('path')
const axios = require('axios')

@@ -9,2 +10,3 @@ const FormData = require('form-data')

portalFileFieldname: "file",
portalFilesFieldname: "files[]",
customFilename: "",

@@ -36,2 +38,26 @@ }

function UploadDirectory(path, opts) {
const stat = fs.statSync(path)
if (!stat.isDirectory()) {
throw new Error(`Given path is not a directory: ${path}`)
}
const formData = new FormData();
for (const file of walkDirectory(path)) {
formData.append(opts.portalFilesFieldname, fs.createReadStream(file), { filepath: file });
}
const uuid = generateUUID()
const url = `${trimTrailingSlash(opts.portalUrl)}${trimTrailingSlash(opts.portalUploadPath)}/${uuid}?filename=${opts.customFilename || path}`
return new Promise((resolve, reject) => {
axios.post(url, formData, { headers: formData.getHeaders() })
.then(resp => {
resolve(`sia://${resp.data.skylink}`)
}).catch(error => {
reject(error)
})
})
}
function DownloadFile(path, skylink, opts) {

@@ -55,2 +81,19 @@ const url = `${trimTrailingSlash(opts.portalUrl)}/${trimSiaPrefix(skylink)}`

function walkDirectory(path, out) {
let files = []
if (!fs.existsSync(path)) {
return files;
}
for (const subpath of fs.readdirSync(path)) {
const fullpath = p.join(path, subpath)
if (fs.statSync(fullpath).isDirectory()) {
files = files.concat(walkDirectory(fullpath, out))
continue
}
files.push(fullpath)
}
return files
}
function generateUUID() {

@@ -77,3 +120,4 @@ let uuid = ''

UploadFile: UploadFile,
UploadDirectory: UploadDirectory,
DownloadFile: DownloadFile,
}

2

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

@@ -5,0 +5,0 @@ "main": "index.js",

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