Socket
Socket
Sign inDemoInstall

ipc-network

Package Overview
Dependencies
15
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

.eslintrc.js

6

lib/IpcNetwork.d.ts
/// <reference types="node" />
import { EventEmitter } from "events";
import { UnixDgramSocket } from "unix-dgram-socket";
import { EventEmitter } from "events";
import JobItems from "./JobItems";
import { JobItems } from "./JobItems";
export declare class IpcNetwork extends EventEmitter {

@@ -19,3 +19,3 @@ private rpcCallback?;

protected jobsItems: JobItems;
constructor(processName?: string, rpcCallback?: (jobName: string, from: string) => Buffer | string);
constructor(processName?: string, rpcCallback?: ((jobName: string, from: string) => string | Buffer) | undefined);
startListening(): void;

@@ -22,0 +22,0 @@ stopListening(): void;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var nanoid = require("nanoid/async");
var nanoId = require("nanoid/async");
var events_1 = require("events");
var unix_dgram_socket_1 = require("unix-dgram-socket");
var events_1 = require("events");
var IpcNetworkError_1 = require("./IpcNetworkError");

@@ -35,7 +35,16 @@ var IpcNetwork = (function (_super) {

try {
var jobResult = _this.rpcCallback(jobName, remoteSocketName);
sendResult = _this.unixSocket.send(IpcNetwork.composeMessage(IpcNetwork.TYPE_RPC_RESULT, jobResult, jobId), socketPath);
if (_this.rpcCallback) {
var jobResult = _this.rpcCallback(jobName, remoteSocketName);
var messageReply = IpcNetwork.composeMessage(IpcNetwork.TYPE_RPC_RESULT, jobResult, jobId);
sendResult = _this.unixSocket.send(messageReply, socketPath);
}
else {
var noSupport = 'This process has disabled support for RPC commands.';
var messageReply = IpcNetwork.composeMessage(IpcNetwork.TYPE_RPC_ERROR, noSupport, jobId);
sendResult = _this.unixSocket.send(messageReply, socketPath);
}
}
catch (error) {
sendResult = _this.unixSocket.send(IpcNetwork.composeMessage(IpcNetwork.TYPE_RPC_ERROR, error.message, jobId), socketPath);
var messageReply = IpcNetwork.composeMessage(IpcNetwork.TYPE_RPC_ERROR, error.message, jobId);
sendResult = _this.unixSocket.send(messageReply, socketPath);
}

@@ -52,8 +61,9 @@ if (!sendResult) {

}
var contentStart = 1 + IpcNetwork.JOB_ID_LENGTH;
if (messageType === IpcNetwork.TYPE_RPC_ERROR) {
var errorMessage = message.slice(1 + IpcNetwork.JOB_ID_LENGTH).toString(unix_dgram_socket_1.UnixDgramSocket.payloadEncoding);
var errorMessage = message.slice(contentStart).toString(unix_dgram_socket_1.UnixDgramSocket.payloadEncoding);
_this.jobsItems[jobId].reject(new IpcNetworkError_1.IpcNetworkError(IpcNetwork.ERROR_RPC_EXEC, errorMessage));
}
else {
_this.jobsItems[jobId].resolve(message.slice(1 + IpcNetwork.JOB_ID_LENGTH));
_this.jobsItems[jobId].resolve(message.slice(contentStart));
}

@@ -82,7 +92,7 @@ delete _this.jobsItems[jobId];

return new Promise(function (resolve, reject) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var jobId, socketPath, message, timeoutTimer, result;
var jobId, socketPath, message, timeoutTimer, result, errorMessage;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, nanoid(IpcNetwork.JOB_ID_LENGTH)];
case 0: return [4, nanoId(IpcNetwork.JOB_ID_LENGTH)];
case 1:

@@ -92,3 +102,2 @@ jobId = _a.sent();

message = IpcNetwork.composeMessage(IpcNetwork.TYPE_RPC_JOB, jobName, jobId);
timeoutTimer = null;
if (timeout) {

@@ -104,3 +113,4 @@ timeoutTimer = setTimeout(function () {

delete this.jobsItems[jobId];
reject(new IpcNetworkError_1.IpcNetworkError(IpcNetwork.ERROR_RPC_SEND, "Unable to send job to remote process: " + socketPath));
errorMessage = "Unable to send job to remote process: " + socketPath;
reject(new IpcNetworkError_1.IpcNetworkError(IpcNetwork.ERROR_RPC_SEND, errorMessage));
}

@@ -107,0 +117,0 @@ return [2];

/// <reference types="node" />
export default interface JobItems {
export interface JobItems {
[key: string]: {

@@ -4,0 +4,0 @@ resolve: (value?: any) => void;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;
//# sourceMappingURL=JobItems.js.map
/// <reference types="node" />
export default interface Message {
export interface Message {
message: Buffer;
from: string;
}
{
"name": "ipc-network",
"version": "1.0.0",
"version": "1.0.1",
"description": "Inter-process communication network, allows multiple node process to exchange messages using unix-socket.",

@@ -18,3 +18,11 @@ "keywords": [

],
"main": "lib/index.js",
"homepage": "https://github.com/ulwanski/ipc-network",
"license": "GPL-3.0",
"author": "Marek Ulwański <marek@ulwanski.pl>",
"main": "index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "git@github.com:ulwanski/ipc-network.git"
},
"scripts": {

@@ -24,8 +32,7 @@ "clean": "rm -Rf ./dist ./build ./coverage",

"build": "npm run clean && ./node_modules/typescript/bin/tsc --build --pretty ./tsconfig.json",
"baz": "cp -R *.md .gitignore .npmignore LICENSE ChangeLog package.json ./dist",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"prep": "cp -R *.md .gitignore .npmignore .eslintrc.js LICENSE ChangeLog package.json ./dist",
"foo": "npm publish ./dist --access public",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Marek Ulwański <marek@ulwanski.pl>",
"license": "GPL-3.0",
"dependencies": {

@@ -50,2 +57,3 @@ "nanoid": "^2.0.1",

"nyc": "^13.3.0",
"prettier": "^1.16.4",
"rewire": "^4.0.1",

@@ -56,5 +64,6 @@ "sinon": "^7.2.4",

"tslib": "^1.9.3",
"tslint": "^5.12.1",
"tslint": "^5.14.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.3.3"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc