Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
A Javascript module made to simplify communication with Sia Skynet portals from the browser.
Using npm
npm install skynet-js
Using yarn
yarn add skynet-js
yarn
yarn test
to run the testsClient implements all the standalone functions as methods with bound portalUrl
so you don't need to repeat it every time.
portalUrl
(string) - Optional portal url. If not specified, will try to use the current portal that the sky app is running inside of.
import { SkynetClient } from "skynet-js";
const client = new SkynetClient("https://siasky.net");
Calling SkynetClient
without parameters will use the URL of the current portal that is running the skapp (sky app).
Use the client to upload file
contents.
file
(File) - The file to upload.
options.APIKey
(string) - Optional API key password for authentication.
options.onUploadProgress
(function) - Optional callback to track progress.
Returns a promise that resolves with a { skylink }
or throws error
on failure.
import { SkynetClient } from "skynet-js";
const onUploadProgress = (progress, { loaded, total }) => {
console.info(`Progress ${Math.round(progress * 100)}%`);
};
async function uploadExample() {
try {
const client = new SkynetClient();
const { skylink } = await client.upload(file, { onUploadProgress });
} catch (error) {
console.log(error);
}
}
With authentication:
import { SkynetClient } from "skynet-js";
async function authenticationExample() {
try {
const client = new SkynetClient("https://my-portal.net");
const { skylink } = await client.upload(file, { APIKey: "foobar" });
} catch (error) {
console.log(error);
}
}
Use the client to upload directory
contents as a filename
.
directory
(Object) - Directory map { "file1.jpeg": <File>, "subdirectory/file2.jpeg": <File> }
filename
(string) - Output file name (directory name).
options.onUploadProgress
(function) - Optional callback to track progress.
Returns a promise that resolves with a { skylink }
or throws error
on failure.
import { getRelativeFilePath, getRootDirectory, SkynetClient } from "skynet-js";
// Assume we have a list of files from an input form.
async function uploadDirectoryExample() {
try {
// Get the directory name from the list of files.
// Can also be named manually, i.e. if you build the files yourself
// instead of getting them from an input form.
const filename = getRootDirectory(files[0]);
// Use reduce to build the map of files indexed by filepaths
// (relative from the directory).
const directory = files.reduce((accumulator, file) => {
const path = getRelativeFilePath(file);
return { ...accumulator, [path]: file };
}, {});
const client = new SkynetClient();
const { skylink } = await client.uploadDirectory(directory, filename);
} catch (error) {
console.log(error);
}
}
import { SkynetClient } from "skynet-js";
// Assume we have a skylink e.g. from a previous upload.
try {
const client = new SkynetClient();
client.download(skylink);
} catch (error) {
console.log(error);
}
Use the client to download skylink
contents.
skylink
(string) - 46 character skylink.
Returns nothing.
import { SkynetClient } from "skynet-js";
Use the client to open skylink
in a new browser tab. Browsers support opening natively only limited file extensions like .html or .jpg and will fallback to downloading the file.
skylink
(string) - 46 character skylink.
Returns nothing.
import { SkynetClient } from "skynet-js";
Use the client to generate direct skylink
url.
skylink
(string) - 46 character skylink.
options.download
(boolean) - Option to include download directive in the url that will force a download when used. Defaults to false
.
import { parseSkylink } from "skynet-js";
Use the parseSkylink
to extract skylink from a string.
Currently supported string types are:
"XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg"
sia:
prefixed string, for example "sia:XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg"
sia://
prefixed string, for example "sia://XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg"
"https://siasky.net/XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg"
skylink
(string) - String containing 46 character skylink.
Returns extracted skylink string or throws error.
[0.1.0] - 2020-07-29
SkynetClient
class that must be initialized to call methods such as
upload
and download
.getRelativeFilePath
and defaultPortalUrl
.SkynetClient
. Previous code
that was calling upload(...)
instead of client.upload(...)
will no longer
work.FAQs
Sia Skynet Javascript Client
The npm package skynet-js receives a total of 66 weekly downloads. As such, skynet-js popularity was classified as not popular.
We found that skynet-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.