New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@el3um4s/ipc-for-electron-system-info

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@el3um4s/ipc-for-electron-system-info

Allow the renderer to get information about the version of Electron, Chrome and NodeJS used

  • 2.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

IPC for Electron: System Info

Allow the renderer to get information about the version of Electron, Chrome and NodeJS

NPM link: @el3um4s/ipc-for-electron-system-info

Use @el3um4s/ipc-for-electron and @el3um4s/renderer-for-electron-system-info to allow communication between Electron and a web page

Install and use the package

To use the package in a project:

npm i @el3um4s/ipc-for-electron @el3um4s/ipc-for-electron-system-info @el3um4s/renderer-for-electron-system-info

Then the preload.ts file:

import { generateContextBridge } from "@el3um4s/ipc-for-electron";
import systemInfo from "@el3um4s/ipc-for-electron-system-info";

const listAPI = [systemInfo];

generateContextBridge(listAPI);

In the renderer file:

import systemInfo from "@el3um4s/renderer-for-electron-system-info";
let isWindows = false;

systemInfo.requestIsWindows({
  callback: (data) => {
    isWindows = data.isWindows;
  },
});

let app: string = "-";
let chrome: string = "-";
let node: string = "-";
let electron: string = "-";

systemInfo.requestSystemInfo({
  callback: (data) => {
    chrome = data.chrome;
    node = data.node;
    electron = data.electron;
    app = data.app;
  },
});

In the renderer you can use:

let isWindows = false;

globalThis.api.systemInfo.send("requestIsWindows", null);
globalThis.api.systemInfo.receive("getIsWindows", (data) => {
  isWindows = data.isWindows;
});

let chrome: string = "-";
let node: string = "-";
let electron: string = "-";
let app: string = "-";

globalThis.api.systemInfo.send("requestSystemInfo", null);
globalThis.api.systemInfo.receive("getSystemInfo", (data) => {
  chrome = data.chrome;
  node = data.node;
  electron = data.electron;
  app = data.app;
});

API: Electron Side

  • requestSystemInfo - Request the version of Electron, Chrome and NodeJS. The response is sent to the getSystemInfo channel
  • requestIsWindows - Request if the OS is Windows. The response is sent to the getIsWindows channel

API: Renderer Side - Request

requestSystemInfo = async (options: { callback?: (arg0: SystemInfo) => void; apiKey?: string; }): Promise<SystemInfo>

example:

import systemInfo from "@el3um4s/renderer-for-electron-system-info";

let app: string = "-";
let chrome: string = "-";
let node: string = "-";
let electron: string = "-";

systemInfo.requestSystemInfo({
  apiKey: "ipc",
  callback: (data) => {
    console.log("DATA OK", data);
    chrome = data.chrome;
    node = data.node;
    electron = data.electron;
    app = data.app;
  },
});

requestIsWindows = async (options: { callback?: (arg0: IsWindows) => void; apiKey?: string; }): Promise<IsWindows>

example:

import systemInfo from "@el3um4s/renderer-for-electron-system-info";

let isWindows = false;

systemInfo.requestIsWindows({
  apiKey: "ipc",
  callback: (data) => {
    console.log("DATA OK", data);
    isWindows = data.isWindows;
  },
});

API: Renderer Side - Response

on.getSystemInfo = async (options: { callback?: (arg0: SystemInfo) => void; apiKey?: string; }): Promise<SystemInfo>

example:

import systemInfo from "@el3um4s/renderer-for-electron-system-info";

let app: string = "-";
let chrome: string = "-";
let node: string = "-";
let electron: string = "-";
systemInfo.requestSystemInfo();

systemInfo.on.getSystemInfo({
  apiKey: "ipc",
  callback: (data) => {
    console.log("DATA OK", data);
    chrome = data.chrome;
    node = data.node;
    electron = data.electron;
    app = data.app;
  },
});

on.getIsWindows = async (options: { callback?: (arg0: IsWindows) => void; apiKey?: string; }): Promise<IsWindows>

example:

import systemInfo from "@el3um4s/renderer-for-electron-system-info";

let isWindows = false;

systemInfo.requestIsWindows();

systemInfo.on.getIsWindows({
  apiKey: "ipc",
  callback: (data) => {
    console.log("DATA OK", data);
    isWindows = data.isWindows;
  },
});

Types

SystemInfo

interface SystemInfo {
  chrome: string;
  node: string;
  electron: string;
  app: string;
}

IsWindows

interface IsWindows {
  isWindows: boolean;
}

DefaultApiKey

type DefaultApiKey = "ipc";

Keywords

FAQs

Package last updated on 10 Sep 2022

Did you know?

Socket

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.

Install

Related posts

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