Socket
Socket
Sign inDemoInstall

default-browser-id

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

default-browser-id - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

32

index.js
'use strict';
var os = require('os');
var bplist = require('bplist-parser');
var untildify = require('untildify');
var bundleId = 'com.apple.Safari';
var osxVersion = Number(os.release().split('.')[0]);
var file = untildify(osxVersion >= 14 ? '~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist' : '~/Library/Preferences/com.apple.LaunchServices.plist');
const os = require('os');
const bplist = require('bplist-parser');
const untildify = require('untildify');
const pify = require('pify');
const osxVersion = Number(os.release().split('.')[0]);
const file = untildify(osxVersion >= 14 ? '~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist' : '~/Library/Preferences/com.apple.LaunchServices.plist');
module.exports = function (cb) {
module.exports = () => {
if (process.platform !== 'darwin') {
throw new Error('Only OS X systems are supported');
return Promise.reject(new Error('Only OS X is supported'));
}
bplist.parseFile(file, function (err, data) {
if (err) {
return cb(err);
}
let bundleId = 'com.apple.Safari';
var handlers = data && data[0].LSHandlers;
return pify(bplist.parseFile)(file).then(data => {
const handlers = data && data[0].LSHandlers;
if (!handlers || handlers.length === 0) {
return cb(null, bundleId);
return bundleId;
}
for (var i = 0; i < handlers.length; i++) {
var el = handlers[i];
for (const el of handlers) {
if (el.LSHandlerURLScheme === 'http' && el.LSHandlerRoleAll) {

@@ -34,4 +30,4 @@ bundleId = el.LSHandlerRoleAll;

cb(null, bundleId);
return bundleId;
});
};
{
"name": "default-browser-id",
"version": "1.0.4",
"version": "2.0.0",
"description": "Get the bundle identifier of the default browser (OS X). Example: com.apple.Safari",

@@ -12,16 +12,12 @@ "license": "MIT",

},
"bin": "cli.js",
"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "mocha"
"test": "xo && ava"
},
"files": [
"index.js",
"cli.js"
"index.js"
],
"keywords": [
"cli-app",
"cli",
"osx",

@@ -40,8 +36,12 @@ "browser",

"bplist-parser": "^0.1.0",
"meow": "^3.1.0",
"pify": "^2.3.0",
"untildify": "^2.0.0"
},
"devDependencies": {
"mocha": "*"
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
}
# default-browser-id [![Build Status](https://travis-ci.org/sindresorhus/default-browser-id.svg?branch=master)](https://travis-ci.org/sindresorhus/default-browser-id)
> Get the [bundle identifier](https://developer.apple.com/library/Mac/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/plist/info/CFBundleIdentifier) of the default browser (OS X)
> Get the [bundle identifier](https://developer.apple.com/library/Mac/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/plist/info/CFBundleIdentifier) of the default browser (OS X)<br>
> Example: `com.apple.Safari`
## Usage
## Install

@@ -13,6 +13,9 @@ ```

## Usage
```js
var defaultBrowserId = require('default-browser-id');
const defaultBrowserId = require('default-browser-id');
defaultBrowserId(function (err, browserId) {
defaultBrowserId().then(browserId => {
console.log(browserId);

@@ -24,19 +27,4 @@ //=> 'com.apple.Safari'

## CLI
```
$ npm install --global default-browser-id
```
```
$ default-browser-id --help
Example
$ default-browser-id
com.apple.Safari
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
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