Comparing version 1.0.0 to 2.0.0
@@ -0,1 +1,11 @@ | ||
var platformMap = { | ||
'mac': 'darwin', | ||
'win': 'win32', | ||
'android': 'android', | ||
'cros': 'cros', | ||
'linux': 'linux', | ||
'openbsd': 'openbsd', | ||
'notsupported': 'Not Supported' | ||
} | ||
exports.endianness = function () { return 'LE' } | ||
@@ -23,3 +33,9 @@ | ||
exports.cpus = function () { return [] } | ||
exports.cpus = function (cb) { | ||
if (typeof cb !== 'function') { | ||
console.warn('The Synchronious cpu call is not supported on Browserify CPA. Consider the Async call by passing a function') | ||
return 'Not Supported' | ||
} | ||
chrome.system.cpu.getInfo(cb) // eslint-disable-line | ||
} | ||
@@ -39,5 +55,13 @@ exports.type = function () { return 'Chrome Packaged Application' } | ||
exports.arch = function () { return 'javascript' } | ||
exports.arch = function () { return 'Not Supported' } | ||
exports.platform = function () { return 'browser' } | ||
exports.platform = function (cb) { | ||
if (typeof cb !== 'function') { | ||
console.warn('The Synchronious platform call is not supported on Browserify CPA. Consider the Async call by passing a function') | ||
return platformMap['notsupported'] | ||
} | ||
chrome.runtime.getPlatformInfo(function (info) { // eslint-disable-line | ||
cb(platformMap[info.os]) | ||
}) | ||
} | ||
@@ -44,0 +68,0 @@ exports.tmpdir = exports.tmpDir = function () { |
{ | ||
"name": "chrome-os", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Use the Node `os` API in Chrome Apps", | ||
@@ -8,3 +8,3 @@ "main": "main.js", | ||
"scripts": { | ||
"test": "standard && tape test/*.js" | ||
"test": "standard && browserify test/chrome-app/index.js -o test/chrome-app/bundle.js && tape test/*.js" | ||
}, | ||
@@ -23,3 +23,6 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/No9/chrome-os" | ||
"homepage": "https://github.com/No9/chrome-os", | ||
"devDependencies": { | ||
"tape": "^4.0.0" | ||
} | ||
} |
# chrome-os | ||
Use the Node `os` API in Chrome Apps | ||
## Usage | ||
This library can be used directly with your browserify builds with targeting Chrome Packaged Apps. | ||
``` | ||
$ npm install chrome-os --save | ||
$ browserify -r chrome-os:os index.js -o bundle.js | ||
``` | ||
## Test | ||
``` | ||
$ npm test | ||
``` | ||
This will load the folder `test/chrome-app` as an unpacked extension in chrome. | ||
Test currently designed for windows and Mac Canary support for others accepted | ||
## Permissions | ||
The following permissions need to be added to your chrome packaged app for this module. | ||
``` | ||
"permissions": [ | ||
"system.memory", | ||
"system.cpu" | ||
] | ||
``` | ||
## Mapping | ||
The chrome apis do not support sync calls for some of the corresponding features so the calls have been made async. | ||
Currently these are | ||
1. cpus(callback(cpuinfo)) | ||
2. platform(callback(platform)) | ||
The platform string maps to the expected node value. | ||
There is currently a console warning and 'Not Supported' is returned if these functions are called without a callback. | ||
It should be noted that browserify doesn't fully support these either only returning placeholders. | ||
If users are interested in full cross platform support then an async-os implementation could be implemented. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
177580
13
5179
48
1
8
2