Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libkernel

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libkernel - npm Package Compare versions

Comparing version 0.0.80 to 0.0.111

dist/messagedownload.d.ts

4

dist/download.d.ts

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

declare function download(skylink: string): Promise<Uint8Array>;
export { download };
declare function download(skylink: string): Promise<Uint8Array>
export { download }

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

import { init, newKernelQuery } from "./init.js";
import { init, newKernelQuery } from "./init.js"
// download will take a skylink and return the fileData for that skylink.

@@ -7,28 +7,31 @@ //

function download(skylink) {
return new Promise((resolve, reject) => {
init()
.then(() => {
let [, query] = newKernelQuery({
method: "moduleCall",
data: {
module: "AQCIaQ0P-r6FwPEDq3auCZiuH_jqrHfqRcY7TjZ136Z_Yw",
method: "secureDownload",
data: {
skylink,
},
},
}, null);
query
.then((response) => {
resolve(response.fileData);
})
.catch((err) => {
reject(err);
});
})
.catch((err) => {
reject(err);
});
});
return new Promise((resolve, reject) => {
init()
.then(() => {
let [, query] = newKernelQuery(
{
method: "moduleCall",
data: {
module: "AQCIaQ0P-r6FwPEDq3auCZiuH_jqrHfqRcY7TjZ136Z_Yw",
method: "secureDownload",
data: {
skylink,
},
},
},
null
)
query
.then((response) => {
resolve(response.fileData)
})
.catch((err) => {
reject(err)
})
})
.catch((err) => {
reject(err)
})
})
}
export { download };
export { download }

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

import { addContextToErr, composeErr } from "libskynet";
export { addContextToErr, composeErr };
import { addContextToErr, composeErr } from "libskynet"
export { addContextToErr, composeErr }

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

import { addContextToErr, composeErr } from "libskynet";
export { addContextToErr, composeErr };
import { addContextToErr, composeErr } from "libskynet"
export { addContextToErr, composeErr }

@@ -1,5 +0,5 @@

export { download } from "./download.js";
export { addContextToErr, composeErr } from "./err.js";
export { init } from "./init.js";
export { callModule, connectModule, testMessage } from "./messages.js";
export { upload } from "./upload.js";
export { download } from "./messagedownload.js";
export { testMessage } from "./messagetest.js";
export { upload } from "./messageupload.js";
export { callModule, connectModule, init } from "./queries.js";
export { addContextToErr, composeErr } from "libskynet";

@@ -1,5 +0,5 @@

export { download } from "./download.js";
export { addContextToErr, composeErr } from "./err.js";
export { init } from "./init.js";
export { callModule, connectModule, testMessage } from "./messages.js";
export { upload } from "./upload.js";
export { download } from "./messagedownload.js";
export { testMessage } from "./messagetest.js";
export { upload } from "./messageupload.js";
export { callModule, connectModule, init } from "./queries.js";
export { addContextToErr, composeErr } from "libskynet";

@@ -1,4 +0,4 @@

declare function testMessage(): Promise<string>;
declare function callModule(module: string, method: string, data: any): Promise<any>;
declare function connectModule(module: string, method: string, data: any, receiveUpdate: any): [any, Promise<any>];
export { callModule, connectModule, testMessage };
declare function testMessage(): Promise<string>
declare function callModule(module: string, method: string, data: any): Promise<any>
declare function connectModule(module: string, method: string, data: any, receiveUpdate: any): [any, Promise<any>]
export { callModule, connectModule, testMessage }

@@ -1,5 +0,5 @@

import { addContextToErr, composeErr } from "./err.js";
import { init, newKernelQuery } from "./init.js";
import { logErr } from "./log.js";
const noBridge = "the bridge failed to initialize (do you have the Skynet browser extension?)";
import { addContextToErr, composeErr } from "./err.js"
import { init, newKernelQuery } from "./init.js"
import { logErr } from "./log.js"
const noBridge = "the bridge failed to initialize (do you have the Skynet browser extension?)"
// testMessage will send a test message to the kernel, ensuring that basic

@@ -12,55 +12,58 @@ // kernel communications are working. The promise will resolve to the version

function testMessage() {
// Retrun a promise that will resolve when a response is received from
// the kernel.
return new Promise((resolve, reject) => {
// Every message should start with init. If initialization has
// already happened, this will be a no-op that instantly
// resolves.
init()
.then(() => {
// Send a 'test' message to the kernel, which is a
// method with no parameters.
//
// The first return value of newKernelQuery is ignored
// because it is an update function that we can call if
// we wish to provide new information to the query via
// a 'queryUpdate'. The 'test' method does not support
// any queryUpdates.
//
// The second input of newKernelQuery is passed as
// null, it's usually a handler function to accept
// 'responseUpdate' messages from the kernel related to
// the query. The 'test' method doesn't have any
// 'responseUpdates', so there is no need to create an
// updateHandler.
let [, query] = newKernelQuery({
method: "test",
}, null);
// We use nested promises instead of promise chaining
// because promise chaining didn't provide enough
// control over handling the error. We like wrapping
// our errors to help indicate exactly which part of
// the code has gone wrong, and that nuance gets lost
// with promise chaining.
query
.then((response) => {
if (!("version" in response)) {
resolve("kernel did not report a version");
return;
}
resolve(response.version);
})
.catch((err) => {
reject(addContextToErr(err, "newKernelQuery failed"));
});
})
.catch((err) => {
// For some reason, the bridge is not available.
// Likely, this means that the user has not installed
// the browser extension.
let cErr = composeErr(noBridge, err);
logErr(cErr);
reject(cErr);
});
});
// Retrun a promise that will resolve when a response is received from
// the kernel.
return new Promise((resolve, reject) => {
// Every message should start with init. If initialization has
// already happened, this will be a no-op that instantly
// resolves.
init()
.then(() => {
// Send a 'test' message to the kernel, which is a
// method with no parameters.
//
// The first return value of newKernelQuery is ignored
// because it is an update function that we can call if
// we wish to provide new information to the query via
// a 'queryUpdate'. The 'test' method does not support
// any queryUpdates.
//
// The second input of newKernelQuery is passed as
// null, it's usually a handler function to accept
// 'responseUpdate' messages from the kernel related to
// the query. The 'test' method doesn't have any
// 'responseUpdates', so there is no need to create an
// updateHandler.
let [, query] = newKernelQuery(
{
method: "test",
},
null
)
// We use nested promises instead of promise chaining
// because promise chaining didn't provide enough
// control over handling the error. We like wrapping
// our errors to help indicate exactly which part of
// the code has gone wrong, and that nuance gets lost
// with promise chaining.
query
.then((response) => {
if (!("version" in response)) {
resolve("kernel did not report a version")
return
}
resolve(response.version)
})
.catch((err) => {
reject(addContextToErr(err, "newKernelQuery failed"))
})
})
.catch((err) => {
// For some reason, the bridge is not available.
// Likely, this means that the user has not installed
// the browser extension.
let cErr = composeErr(noBridge, err)
logErr(cErr)
reject(cErr)
})
})
}

@@ -75,27 +78,30 @@ // callModule is a generic function to call a module. It will send a message to

function callModule(module, method, data) {
return new Promise((resolve, reject) => {
init()
.then(() => {
let [, query] = newKernelQuery({
method: "moduleCall",
data: {
module,
method,
data,
},
}, null);
query
.then((response) => {
resolve(response);
})
.catch((err) => {
reject(addContextToErr(err, "moduleCall query to kernel failed"));
});
})
.catch((err) => {
let cErr = composeErr(noBridge, err);
logErr(cErr);
reject(cErr);
});
});
return new Promise((resolve, reject) => {
init()
.then(() => {
let [, query] = newKernelQuery(
{
method: "moduleCall",
data: {
module,
method,
data,
},
},
null
)
query
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(addContextToErr(err, "moduleCall query to kernel failed"))
})
})
.catch((err) => {
let cErr = composeErr(noBridge, err)
logErr(cErr)
reject(cErr)
})
})
}

@@ -131,30 +137,33 @@ // connectModule opens a "connection" to a module. When using 'callModule', all

function connectModule(module, method, data, receiveUpdate) {
// Create the kernel query.
let [sendUpdate, query] = newKernelQuery({
method: "moduleCall",
data: {
module,
method,
data,
},
}, receiveUpdate);
let p = new Promise((resolve, reject) => {
init()
.then(() => {
query
.then((response) => {
resolve(response);
})
.catch((err) => {
reject(addContextToErr(err, "moduleCall query to kernel failed"));
});
})
.catch((err) => {
let cErr = composeErr(noBridge, err);
logErr(cErr);
reject(cErr);
});
});
return [sendUpdate, p];
// Create the kernel query.
let [sendUpdate, query] = newKernelQuery(
{
method: "moduleCall",
data: {
module,
method,
data,
},
},
receiveUpdate
)
let p = new Promise((resolve, reject) => {
init()
.then(() => {
query
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(addContextToErr(err, "moduleCall query to kernel failed"))
})
})
.catch((err) => {
let cErr = composeErr(noBridge, err)
logErr(cErr)
reject(cErr)
})
})
return [sendUpdate, p]
}
export { callModule, connectModule, testMessage };
export { callModule, connectModule, testMessage }

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

declare function upload(filename: string, fileData: Uint8Array): Promise<string>;
export { upload };
declare function upload(filename: string, fileData: Uint8Array): Promise<string>
export { upload }

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

import { init, newKernelQuery } from "./init.js";
import { init, newKernelQuery } from "./init.js"
// upload will take a filename and some file data and perform a secure upload

@@ -10,29 +10,32 @@ // to Skynet. Secure in this case means that all data is verified before being

function upload(filename, fileData) {
return new Promise((resolve, reject) => {
init()
.then(() => {
let [, query] = newKernelQuery({
method: "moduleCall",
data: {
module: "AQAT_a0MzOInZoJzt1CwBM2U8oQ3GIfP5yKKJu8Un-SfNg",
method: "secureUpload",
data: {
filename,
fileData,
},
},
}, null);
query
.then((response) => {
resolve(response.skylink);
})
.catch((err) => {
reject(err);
});
})
.catch((x) => {
reject(x);
});
});
return new Promise((resolve, reject) => {
init()
.then(() => {
let [, query] = newKernelQuery(
{
method: "moduleCall",
data: {
module: "AQAT_a0MzOInZoJzt1CwBM2U8oQ3GIfP5yKKJu8Un-SfNg",
method: "secureUpload",
data: {
filename,
fileData,
},
},
},
null
)
query
.then((response) => {
resolve(response.skylink)
})
.catch((err) => {
reject(err)
})
})
.catch((x) => {
reject(x)
})
})
}
export { upload };
export { upload }
{
"name": "libkernel",
"version": "0.0.80",
"version": "0.0.111",
"description": "helper library to interact with skynet and the skynet kernel",

@@ -26,4 +26,4 @@ "main": "dist/index.js",

"dependencies": {
"libskynet": "^0.0.1"
"libskynet": "^0.0.7"
}
}
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