You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

electron-hostile

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

electron-hostile

Update hosts file with permission check

1.1.1
latest
npm
Version published
Weekly downloads
100
23.46%
Maintainers
1
Weekly downloads
 
Created
Source

kotapeter

electron-hostile

This package is inspired by hostile. In an electron app usually we need to get a confirmation from the user. When you add/delete an entry to/from hosts file user will get a confirmation box (mac: password, win: confirm)

Get all entries

import { getEntries } from 'electron-hostile'

// returns entries without comments
const entries = await getEntries()

// returns all entries with comments
const entries = await getEntries(true)

Add new entry

import { addHostsEntry, addHostsEntries } from 'electron-hostile'

// add single entry
await addHostsEntry('100.100.100.100', 'mysite.local', 'WRAPPER', { name: 'MYAPP', icon: '/static/img.png' })

// add multiple entries
await addHostsEntries([
  { ip: '1.1.1.1', host: 'site1.local', wrapper: 'TEST' },
  { ip: '1.1.1.1', host: 'www.site1.local', wrapper: 'TEST' },
], { name: 'MYAPP', icon: '/static/img.png' })

Remove entry

import { removeHostsEntry, removeHostsEntries } from 'electron-hostile'

// remove single entry
await removeHostsEntry('mysite.local', { name: 'MYAPP', icon: '/static/img.png' })

// add multiple entries
await removeHostsEntries([
  { ip: '1.1.1.1', host: 'site1.local' },
  { ip: '1.1.1.1', host: 'www.site1.local' },
], { name: 'MYAPP', icon: '/static/img.png' })

FAQs

Package last updated on 11 Aug 2021

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