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

@synonymdev/slashtags-rpc

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@synonymdev/slashtags-rpc - npm Package Compare versions

Comparing version 0.1.0-alpha.9 to 0.1.1

4

cjs/src/engine.js

@@ -19,2 +19,6 @@ 'use strict';

};
this.handleRaw = async (data, noiseSocket) => noiseSocket.write(await this.handle({
...JSON.parse(typeof data === 'string' ? data : b4a__default["default"].toString(data)),
noiseSocket
}));
this.handle = async function (request) {

@@ -21,0 +25,0 @@ const parsed = jsonrpc__default["default"].parseObject(request);

32

cjs/src/rpc.js

@@ -15,12 +15,5 @@ 'use strict';

const RPC = async opts => {
const engine$1 = new engine.Engine();
const engine$1 = await new engine.Engine();
const node = await dht.DHT(opts);
const server = node.createServer(noiseSocket => noiseSocket.on('data', async data => {
data = JSON.parse(data);
const response = await engine$1.handle({
...data,
noiseSocket
});
noiseSocket.write(response);
}));
const server = node.createServer(noiseSocket => noiseSocket.on('data', data => engine$1.handleRaw(data, noiseSocket)));
const _listen = async () => {

@@ -55,13 +48,18 @@ try {

});
return {
noiseSocket,
resetTimeout
};
return new Promise((resolve, reject) => {
noiseSocket.on('open', () => resolve({
noiseSocket,
resetTimeout
}));
noiseSocket.on('error', error => {
reject(error);
});
});
};
const _request = async (destination, method, params) => {
let openScoket = _openSockets.get(b4a__default["default"].toString(destination, 'hex'));
if (!openScoket || openScoket.noiseSocket.destroyed) {
openScoket = await setupNoiseSocket(destination);
let openSocket = _openSockets.get(b4a__default["default"].toString(destination, 'hex'));
if (!openSocket || openSocket.noiseSocket.destroyed) {
openSocket = await setupNoiseSocket(destination);
}
return engine$1.call(method, params, openScoket.noiseSocket);
return engine$1.call(method, params, openSocket.noiseSocket);
};

@@ -68,0 +66,0 @@ return {

@@ -9,2 +9,6 @@ import jsonrpc from 'jsonrpc-lite';

};
this.handleRaw = async (data, noiseSocket) => noiseSocket.write(await this.handle({
...JSON.parse(typeof data === 'string' ? data : b4a.toString(data)),
noiseSocket
}));
this.handle = async function (request) {

@@ -11,0 +15,0 @@ const parsed = jsonrpc.parseObject(request);

@@ -6,12 +6,5 @@ import { DHT } from './dht.js';

export const RPC = async opts => {
const engine = new Engine();
const engine = await new Engine();
const node = await DHT(opts);
const server = node.createServer(noiseSocket => noiseSocket.on('data', async data => {
data = JSON.parse(data);
const response = await engine.handle({
...data,
noiseSocket
});
noiseSocket.write(response);
}));
const server = node.createServer(noiseSocket => noiseSocket.on('data', data => engine.handleRaw(data, noiseSocket)));
const _listen = async () => {

@@ -46,13 +39,18 @@ try {

});
return {
noiseSocket,
resetTimeout
};
return new Promise((resolve, reject) => {
noiseSocket.on('open', () => resolve({
noiseSocket,
resetTimeout
}));
noiseSocket.on('error', error => {
reject(error);
});
});
};
const _request = async (destination, method, params) => {
let openScoket = _openSockets.get(b4a.toString(destination, 'hex'));
if (!openScoket || openScoket.noiseSocket.destroyed) {
openScoket = await setupNoiseSocket(destination);
let openSocket = _openSockets.get(b4a.toString(destination, 'hex'));
if (!openSocket || openSocket.noiseSocket.destroyed) {
openSocket = await setupNoiseSocket(destination);
}
return engine.call(method, params, openScoket.noiseSocket);
return engine.call(method, params, openSocket.noiseSocket);
};

@@ -59,0 +57,0 @@ return {

{
"name": "@synonymdev/slashtags-rpc",
"version": "0.1.0-alpha.9",
"version": "0.1.1",
"description": "JsonRPC on top of Hyperswarm's secret-stream",

@@ -41,3 +41,3 @@ "keywords": [

},
"gitHead": "37a1d584531d482353982e252c04ba8b04c28806",
"gitHead": "5d346f38557a4c158871aa39193d3a05375aa038",
"browser": {

@@ -44,0 +44,0 @@ ".": "./cjs/src/index.js"

@@ -16,2 +16,7 @@ /**

/**
* @param {string | Uint8Array} data
* @param {NoiseSocket} noiseSocket
*/
handleRaw: (data: string | Uint8Array, noiseSocket: NoiseSocket) => Promise<boolean>;
/**
* @param {Request} request

@@ -18,0 +23,0 @@ * @returns

@@ -29,3 +29,3 @@ /// <reference types="node" />

};
export declare type EngineMethod = (req: EngineRequest) => Promise<JSONElement>;
export declare type EngineMethod = (req: EngineRequest) => Promise<JSONElement> | JSONElement;
export interface SlashtagsRPC {

@@ -32,0 +32,0 @@ addMethods(methods: Record<string, EngineMethod>): void;

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