Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nut-tree-fork/libnut-darwin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nut-tree-fork/libnut-darwin - npm Package Compare versions

Comparing version 2.7.1 to 2.7.2

2

package.json
{
"name": "@nut-tree-fork/libnut-darwin",
"version": "2.7.1",
"version": "2.7.2",
"description": "libnut is an N-API module for desktop automation with node",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,77 +7,93 @@ let libnut = require("bindings")("libnut");

try {
const permissions = require("@nut-tree/node-mac-permissions");
const permissions = require("@nut-tree-fork/node-mac-permissions");
const wrapWithWarning = (message, nativeFunction) => (...args) => {
console.warn(message);
return nativeFunction(...args);
const wrapWithWarning =
(message, nativeFunction) =>
(...args) => {
console.warn(message);
return nativeFunction(...args);
};
const askForAccessibility = (nativeFunction, functionName) => {
if (process.platform !== 'darwin' || hasAccessibilityPermission) {
return nativeFunction;
}
const accessibilityStatus = permissions.getAuthStatus("accessibility");
const askForAccessibility = (nativeFunction, functionName) => {
if (process.platform !== "darwin" || hasAccessibilityPermission) {
return nativeFunction;
}
const accessibilityStatus = permissions.getAuthStatus("accessibility");
if (accessibilityStatus === 'authorized') {
hasAccessibilityPermission = true;
return nativeFunction;
} else if (accessibilityStatus === 'not determined' || accessibilityStatus === 'denied') {
permissions.askForAccessibilityAccess();
return wrapWithWarning(`##### WARNING! The application running this script tries to access accessibility features to execute ${functionName}! Please grant requested access and visit https://github.com/nut-tree/nut.js#macos for further information. #####`, nativeFunction);
}
if (accessibilityStatus === "authorized") {
hasAccessibilityPermission = true;
return nativeFunction;
} else if (
accessibilityStatus === "not determined" ||
accessibilityStatus === "denied"
) {
permissions.askForAccessibilityAccess();
return wrapWithWarning(
`##### WARNING! The application running this script tries to access accessibility features to execute ${functionName}! Please grant requested access and visit https://github.com/nut-tree/nut.js#macos for further information. #####`,
nativeFunction
);
}
const askForScreenRecording = (nativeFunction, functionName) => {
if (process.platform !== 'darwin' || hasScreenRecordingPermission) {
return nativeFunction;
}
const screenCaptureStatus = permissions.getAuthStatus("screen");
};
const askForScreenRecording = (nativeFunction, functionName) => {
if (process.platform !== "darwin" || hasScreenRecordingPermission) {
return nativeFunction;
}
const screenCaptureStatus = permissions.getAuthStatus("screen");
if (screenCaptureStatus === 'authorized') {
hasScreenRecordingPermission = true;
return nativeFunction;
} else if (screenCaptureStatus === 'not determined' || screenCaptureStatus === 'denied') {
permissions.askForScreenCaptureAccess();
return wrapWithWarning(`##### WARNING! The application running this script tries to screen recording features to execute ${functionName}! Please grant the requested access and visit https://github.com/nut-tree/nut.js#macos for further information. #####`, nativeFunction);
}
if (screenCaptureStatus === "authorized") {
hasScreenRecordingPermission = true;
return nativeFunction;
} else if (
screenCaptureStatus === "not determined" ||
screenCaptureStatus === "denied"
) {
permissions.askForScreenCaptureAccess();
return wrapWithWarning(
`##### WARNING! The application running this script tries to screen recording features to execute ${functionName}! Please grant the requested access and visit https://github.com/nut-tree/nut.js#macos for further information. #####`,
nativeFunction
);
}
};
const accessibilityAccess = [
"dragMouse",
"moveMouse",
"getMousePos",
"mouseClick",
"mouseToggle",
"scrollMouse",
"keyTap",
"keyToggle",
"typeString",
"getScreenSize",
"highlight",
"captureScreen",
"getWindows",
"getActiveWindow",
"getWindowRect",
"getWindowTitle",
"focusWindow",
"resizeWindow"
];
const screenCaptureAccess = [
"getWindowTitle",
"captureScreen",
];
const accessibilityAccess = [
"dragMouse",
"moveMouse",
"getMousePos",
"mouseClick",
"mouseToggle",
"scrollMouse",
"keyTap",
"keyToggle",
"typeString",
"getScreenSize",
"highlight",
"captureScreen",
"getWindows",
"getActiveWindow",
"getWindowRect",
"getWindowTitle",
"focusWindow",
"resizeWindow",
];
const screenCaptureAccess = ["getWindowTitle", "captureScreen"];
for (const functionName of accessibilityAccess) {
const originalFunction = libnut[functionName];
libnut[functionName] = (...args) => askForAccessibility(originalFunction, functionName)(...args);
}
for (const functionName of screenCaptureAccess) {
const originalFunction = libnut[functionName];
libnut[functionName] = (...args) => askForScreenRecording(originalFunction, functionName)(...args);
}
for (const functionName of accessibilityAccess) {
const originalFunction = libnut[functionName];
libnut[functionName] = (...args) =>
askForAccessibility(originalFunction, functionName)(...args);
}
for (const functionName of screenCaptureAccess) {
const originalFunction = libnut[functionName];
libnut[functionName] = (...args) =>
askForScreenRecording(originalFunction, functionName)(...args);
}
} catch (e) {
console.warn(`Encountered error establishing macOS permission checks:`, e.message);
console.warn(`Returning original module.`);
libnut = require("bindings")("libnut");
console.warn(
`Encountered error establishing macOS permission checks:`,
e.message
);
console.warn(`Returning original module.`);
libnut = require("bindings")("libnut");
} finally {
module.exports = libnut;
module.exports = libnut;
}
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