Coder Social home page Coder Social logo

codebytere / node-mac-permissions Goto Github PK

View Code? Open in Web Editor NEW
174.0 4.0 40.0 321 KB

A native node module to manage system permissions on macOS.

License: MIT License

Python 2.74% JavaScript 13.20% Objective-C++ 83.91% Shell 0.15%
macos nodejs node-addon electronjs permissions

node-mac-permissions's Issues

Mocha - Error: Module did not self-register

I have integrated node-mac-permissions and am receiving an error when trying to test my app in a headless docker container run

xvfb-run yarn electron-mocha --no-sandbox --disable-gpu -R mocha-jenkins-reporter --require source-map-support/register out/test-main.js

Error:

✖ ERROR: Module did not self-register: '/home/jenkins/app/node_modules/node-mac-permissions/build/Release/permissions.node'.

I was able to narrow down the issue to the binding.gyp -> sources entry.
There's no source/export provided for the permissions target for windows or Linux, which in the docker case, is causing the module to not "self-register".
Resources used:
https://stackoverflow.com/a/41283828
https://stackoverflow.com/a/55177338

I was able to solve it with this small patch that just creates a stub permissions.cc with empty export for win/linux sources

diff --git a/node_modules/node-mac-permissions/binding.gyp b/node_modules/node-mac-permissions/binding.gyp
index d5ba249..1e4bc00 100644
--- a/node_modules/node-mac-permissions/binding.gyp
+++ b/node_modules/node-mac-permissions/binding.gyp
@@ -1,7 +1,7 @@
 {
   "targets": [{
     "target_name": "permissions",
-    "sources": [ ],
+    "sources": [ "permissions.cc" ],
     "conditions": [
       ['OS=="mac"', {
         "sources": [
diff --git a/node_modules/node-mac-permissions/permissions.cc b/node_modules/node-mac-permissions/permissions.cc
new file mode 100644
index 0000000..5522c40
--- /dev/null
+++ b/node_modules/node-mac-permissions/permissions.cc
@@ -0,0 +1,7 @@
+#include <napi.h>
+
+ Napi::Object Init(Napi::Env env, Napi::Object exports) {
+   return exports;
+ }
+
+NODE_API_MODULE(permissions, Init)
\ No newline at end of file

I'm honestly not familiar with NAPI, and I'm not sure if the empty module export is correct. Alternatively, one could simply stub a function for every entry and just returns "authorized". A for-loop could easily improve it, but the approach, in general, feels messy to me.

#include <napi.h>

// Returns the user's home folder path.
Napi::Value GetAuthStatus(const Napi::CallbackInfo &info) {
  Napi::Env env = info.Env();
  std::string auth_status = "authorized"
  return Napi::Value::From(env, auth_status);
}

Napi::Object Init(Napi::Env env, Napi::Object exports) {
  exports.Set(Napi::String::New(env, "getAuthStatus"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForContactsAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForCalendarAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForRemindersAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForFoldersAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForFullDiskAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForCameraAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForMicrophoneAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForSpeechRecognitionAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForPhotosAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForScreenCaptureAccess"),
              Napi::Function::New(env, GetAuthStatus));
  exports.Set(Napi::String::New(env, "askForAccessibilityAccess"),
              Napi::Function::New(env, GetAuthStatus));
  return exports;
}

NODE_API_MODULE(permissions, Init)

At the end of the day, I'm assuming I'm configuring something wrong considering how well maintained this project is (and thank you for it!)
Is node-mac-permissions supposed to be imported/required conditionally based on process.platform or something in the code?

Unable to build on M1 mac

Pulled our repo onto a M1 MacOS VM and ran npm install. When launching the project, I get this error:

Error: dlopen(/Users/m1/Desktop/Development/app_name/node_modules/node-mac-permissions/build/Release/permissions.node, 0x0001): tried: '/Users/m1/Desktop/Development/app_name/node_modules/node-mac-permissions/build/Release/permissions.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/permissions.node' (no such file), '/usr/lib/permissions.node' (no such file)
at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1800)
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1199:18)
at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1800)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:829:12)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:94:18)
at bindings (/Users/m1/Desktop/Development/app_name/node_modules/bindings/bindings.js:112:48)
at Object. (/Users/m1/Desktop/Development/app_name/node_modules/node-mac-permissions/index.js:1:40)

Tried npm rebuild node-mac-permissions but doesn't change anything.

The permissions.target.mk file has this section

Flags passed to all source files.

CFLAGS_Debug :=
-O0
-gdwarf-2
-mmacosx-version-min=10.13
-arch x86_64
-Wall
-Wendif-labels
-W
-Wno-unused-parameter

Universal Binary Doesn't Work

Hi all,

I've been pulling my hair for the last few days on this issue: when I build my app for Mac ARM and Intel separately, the library works as expected. When I build a universal version of the same app, my app does show up in the Accessibility section of the Privacy & Security, but toggling it on in the preferences does have any effect.

Any idea why that might happen?

Thanks!

Module not found: Error: Can't resolve 'fs'

When I add

import {getAuthStatus} from "node-mac-permissions";
const status = getAuthStatus('screen');

I get

Module not found: Error: Can't resolve 'fs' in '/Users/Shared/Pet/App/app-desktop/node_modules/bindings'
 @ ./node_modules/node-mac-permissions/index.js 1:20-39

Calendar & Reminder Access changes in Sonoma

Apple has changed how to request access to calendars and reminders with macOS 14 (Sonoma). This package uses the now deprecated requestAccessToEntityType:completion: method.

Deprecated
On [macOS 14] and later, this method doesn’t prompt for access and immediately calls the completion block with an error.
If your app only uses EKEventEditViewController to let your user create and save calendar events, don’t request events access. Use requestWriteOnlyAccessToEventsWithCompletion: to create calendar events. Use requestFullAccessToEventsWithCompletion: to read and write calendar events. Use requestFullAccessToRemindersWithCompletion: to read and write reminders.

See: https://developer.apple.com/documentation/eventkit/ekeventstore/1507547-requestaccesstoentitytype?language=objc

To mitigate this in the meantime, one has to define the following Properties in the info.plist:

In the long run, this package should not use the deprecated method but the new ones instead.

Fix IT NOW (Home-Effiency-Cost-Savings-Calculator)

For creation of annual tune-ups for Heating&Cooling/Refrigeration systems and replacement for higher seer ratings and btu's. Customer Log-Ins For Easier Data Base Home Or Buisness Measurements R-Values And Age of Property For Easy Access And Customer Friendly Insights For Annual Service And Fuel/Power Savings

Customer Interaction App Download Located On OUR Buisness Site And Appstore With Our Buisness Credentials

For Further Sales And Tune-ups & Customer And Brand Analytics

Support for cross platform projects

I am developing an application that is prepared to work on Windows, Mac, and Linux with the same code, of course, Mac requests permissions that do not exist in the other operating systems and that is why I am using this library.

However, when I try to run npm install on the project on a Windows or a Linux device, there is an error saying that this library is incompatible:

C:\GitHub\cross>npm install
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Koraniar\AppData\Local\npm-cache\_logs\2023-09-04T21_41_03_261Z-debug-0.log

I know I can force the installation using npm install --force, but there are some side effects I would like to avoid like having version conflicts, bypassing security vulnerabilities, etc.

Is there a way to allow this library to be installed in different operating systems? Like allowing it to be installed and do nothing once it is imported If the platform is not darwin like mac-screen-capture-permissions.

app that was built in macOS 14.5.2(intel silicon) crashes in macOS 11.x

macOS 14.5.2(intel silicon)
[email protected]
[email protected]
[email protected]
[email protected]

when the app is built in [email protected](intel silicon), it works well in all the Mac. But after I upgrade my mac version to 14.5.2, the progress of building also works well, after I install the built app and launch it, the app crashes in the [email protected] but works well higher [email protected]:

Process:               EC [22882]
Path:                  /Applications/EC.app/Contents/MacOS/EC
Identifier:            com.ec.ECForMac
Version:               1.4.7-alpha.0 (1.4.7-alpha.0)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           EC [22882]
User ID:               501

Date/Time:             2024-01-22 16:47:52.350 +0800
OS Version:            macOS 11.5.2 (20G95)
Report Version:        12
Bridge OS Version:     5.5 (18P4759a)
Anonymous UUID:        A527D034-2974-006D-4C44-6FE02F204A36

Sleep/Wake UUID:       7043F401-D60E-4A40-90C1-FBD57AA95164

Time Awake Since Boot: 1200000 seconds
Time Since Wake:       11000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  CrBrowserMain  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       EXC_I386_GPFLT
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [22882]

Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
0   permissions.node              	0x0000000114d70000 0x114d70000 + 0
1   com.github.Electron.framework 	0x00000001066e5214 v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Name>, void (*)(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&), void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyCallbackInfo<v8::Boolean> const&)) + 12116
2   ???                           	0x0000002537f0c038 0 + 159852314680
3   ???                           	0x0000002537e8be23 0 + 159851789859
4   ???                           	0x0000002537e8be23 0 + 159851789859
5   ???                           	0x0000002537e8be23 0 + 159851789859
6   ???                           	0x0000002537ec4212 0 + 159852020242
7   ???                           	0x0000002537e8be23 0 + 159851789859
8   ???                           	0x0000002537f5c956 0 + 159852644694
9   ???                           	0x0000002537e898b2 0 + 159851780274
10  ???                           	0x0000002537fad636 0 + 159852975670
11  ???                           	0x0000002537e8be23 0 + 159851789859
12  ???                           	0x0000002537e8be23 0 + 159851789859
13  ???                           	0x00000025300f6c80 0 + 159720107136
14  ???                           	0x0000002537ec4212 0 + 159852020242
15  ???                           	0x000000253012aad7 0 + 159720319703
16  ???                           	0x0000002537f5c956 0 + 159852644694
17  ???                           	0x0000002537e898b2 0 + 159851780274
18  ???                           	0x000000253012aea9 0 + 159720320681
19  ???                           	0x00000025300f5a65 0 + 159720102501
20  ???                           	0x00000025301390be 0 + 159720378558
21  ???                           	0x000000253018e9e7 0 + 159720729063
22  ???                           	0x0000002537e8a39c 0 + 159851783068
23  ???                           	0x0000002537e8a0c7 0 + 159851782343
24  com.github.Electron.framework 	0x000000010679db78 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) + 664
25  com.github.Electron.framework 	0x00000001066904a7 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 599
26  com.github.Electron.framework 	0x000000010bafaf9d node::CallbackScope::~CallbackScope() + 2877
27  com.github.Electron.framework 	0x000000010bafb280 node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) + 192
28  com.github.Electron.framework 	0x00000001056a23ed v8::CodeEvent::GetScriptName() + 171693
29  com.github.Electron.framework 	0x00000001055f37cd v8::CodeEventHandler::~CodeEventHandler() + 346141
30  com.github.Electron.framework 	0x00000001055e05cd v8::CodeEventHandler::~CodeEventHandler() + 267805
31  com.github.Electron.framework 	0x00000001055e06a6 v8::CodeEventHandler::~CodeEventHandler() + 268022
32  com.github.Electron.framework 	0x0000000105615dca v8::CodeEvent::GetCodeSize() + 4138
33  com.github.Electron.framework 	0x000000010820bd41 node::AsyncResource::get_async_id() const + 6276337
34  com.github.Electron.framework 	0x00000001056160cb v8::CodeEvent::GetCodeSize() + 4907
35  com.github.Electron.framework 	0x0000000108770090 node::AsyncResource::get_async_id() const + 11929664
36  com.github.Electron.framework 	0x00000001087743d7 node::AsyncResource::get_async_id() const + 11946887
37  com.github.Electron.framework 	0x0000000108771ccd node::AsyncResource::get_async_id() const + 11936893
38  com.github.Electron.framework 	0x000000010898f298 node::AsyncResource::get_async_id() const + 14154312
39  com.github.Electron.framework 	0x0000000108452cbd node::AsyncResource::get_async_id() const + 8664173
40  com.github.Electron.framework 	0x000000010847181b node::AsyncResource::get_async_id() const + 8789963
41  com.github.Electron.framework 	0x00000001084af37c node::AsyncResource::get_async_id() const + 9042732
42  com.github.Electron.framework 	0x000000010538890a 0x1051fe000 + 1616138
43  com.github.Electron.framework 	0x00000001084aeadf node::AsyncResource::get_async_id() const + 9040527
44  com.apple.CoreFoundation      	0x00007fff2052594c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
45  com.apple.CoreFoundation      	0x00007fff205258b4 __CFRunLoopDoSource0 + 180
46  com.apple.CoreFoundation      	0x00007fff20525634 __CFRunLoopDoSources0 + 242
47  com.apple.CoreFoundation      	0x00007fff2052405c __CFRunLoopRun + 893
48  com.apple.CoreFoundation      	0x00007fff2052361c CFRunLoopRunSpecific + 563
49  com.apple.HIToolbox           	0x00007fff28769a83 RunCurrentEventLoopInMode + 292
50  com.apple.HIToolbox           	0x00007fff287697e5 ReceiveNextEventCommon + 587
51  com.apple.HIToolbox           	0x00007fff28769583 _BlockUntilNextEventMatchingListInModeWithFilter + 70
52  com.apple.AppKit              	0x00007fff22d2b172 _DPSNextEvent + 864
53  com.apple.AppKit              	0x00007fff22d29945 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1364
54  com.apple.AppKit              	0x00007fff22d1bc69 -[NSApplication run] + 586
55  com.github.Electron.framework 	0x00000001084afc76 node::AsyncResource::get_async_id() const + 9045030
56  com.github.Electron.framework 	0x00000001084ae581 node::AsyncResource::get_async_id() const + 9039153
57  com.github.Electron.framework 	0x00000001084724ca node::AsyncResource::get_async_id() const + 8793210
58  com.github.Electron.framework 	0x000000010843be1f node::AsyncResource::get_async_id() const + 8570319
59  com.github.Electron.framework 	0x00000001076e6182 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 3879890
60  com.github.Electron.framework 	0x00000001076e7a62 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 3886258
61  com.github.Electron.framework 	0x00000001076e3964 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 3869620
62  com.github.Electron.framework 	0x0000000105816f51 v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 15681
63  com.github.Electron.framework 	0x000000010581808e v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 20094
64  com.github.Electron.framework 	0x0000000105817b7f v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 18799
65  com.github.Electron.framework 	0x00000001058169d4 v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 14276
66  com.github.Electron.framework 	0x0000000105816af6 v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 14566
67  com.github.Electron.framework 	0x00000001055562b8 ElectronMain + 152
68  libdyld.dylib                 	0x00007fff20447f3d start + 1

I didn't change any code. Then I find another mac that version is 13.x and build the app, everything is OK. So I think there is a
compatbility problem in the output of permissions.node in [email protected]

Screen capture Access Prompt

When using askForScreenCaptureAccess(), it doesn't open the respective system preference tab, when tried with askForAccessibilityAccess() it works, using iterm2 and on macOS 12.6. Im asking for both one by one. Tried replacing it by asking accessibility again but it also didn’t open

Get notified when perms are changed

Is it possible to get notified when a particular permission is granted by the user, manually from System Preferences or through the prompt?

Fails to build on macOS 10.13 Xcode 10.0

Hi @codebytere,

Ran into an issue building on Travis. We're using the osx_image xcode10 and getting the following errors (below). I'm a bit baffled as I thought @available(macOS 10.14, *) would take care of that (??). We have to keep the backwards compatibility - is there any precompiler flags we're missing?

Thanks

[5/5] Building fresh packages...
error /Users/travis/build/loomhq/desktop/node_modules/node-mac-permissions: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/travis/build/loomhq/desktop/node_modules/node-mac-permissions
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 2.7.17 found at "/usr/local/opt/python@2/bin/python2.7"
gyp http GET https://nodejs.org/download/release/v12.16.1/node-v12.16.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v12.16.1/node-v12.16.1-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v12.16.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v12.16.1/SHASUMS256.txt
gyp info spawn /usr/local/opt/python@2/bin/python2.7
gyp info spawn args [
gyp info spawn args '/Users/travis/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/travis/build/loomhq/desktop/node_modules/node-mac-permissions/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/travis/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/travis/Library/Caches/node-gyp/12.16.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/travis/Library/Caches/node-gyp/12.16.1',
gyp info spawn args '-Dnode_gyp_dir=/Users/travis/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/travis/Library/Caches/node-gyp/12.16.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/travis/build/loomhq/desktop/node_modules/node-mac-permissions',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
LIBTOOL-STATIC Release/nothing.a
CXX(target) Release/obj.target/permissions/permissions.o
../permissions.mm:158:5: error: 'AVAuthorizationStatus' is unavailable: not available on macOS
AVAuthorizationStatus status =
^
/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1456:28: note: 'AVAuthorizationStatus' has been explicitly marked unavailable here
typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
^
../permissions.mm:159:26: error: 'authorizationStatusForMediaType:' is unavailable: not available on macOS
[AVCaptureDevice authorizationStatusForMediaType:media_type];
^
/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1479:1: note: 'authorizationStatusForMediaType:' has been explicitly marked unavailable here

  • (AVAuthorizationStatus)authorizationStatusForMediaType:(AVMediaType)mediaType NS_AVAILABLE_IOS(7_0);
    ^
    ../permissions.mm:161:19: error: 'AVAuthorizationStatusAuthorized' is unavailable: not available on macOS
    if (status == AVAuthorizationStatusAuthorized)
    ^
    /System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1456:28: note: 'AVAuthorizationStatus' has been explicitly marked unavailable here
    typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
    ^
    ../permissions.mm:163:24: error: 'AVAuthorizationStatusDenied' is unavailable: not available on macOS
    else if (status == AVAuthorizationStatusDenied)
    ^
    /System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1456:28: note: 'AVAuthorizationStatus' has been explicitly marked unavailable here
    typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
    ^
    ../permissions.mm:165:24: error: 'AVAuthorizationStatusRestricted' is unavailable: not available on macOS
    else if (status == AVAuthorizationStatusRestricted)
    ^
    /System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1456:28: note: 'AVAuthorizationStatus' has been explicitly marked unavailable here
    typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
    ^
    ../permissions.mm:312:11: error: 'requestAccessForMediaType:completionHandler:' is unavailable: not available on macOS
    requestAccessForMediaType:AVMediaTypeVideo
    ^
    /System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1502:1: note: 'requestAccessForMediaType:completionHandler:' has been explicitly marked unavailable here
  • (void)requestAccessForMediaType:(AVMediaType)mediaType completionHandler:(void (^)(BOOL granted))handler NS_AVAILABLE_IOS(7_0);
    ^
    ../permissions.mm:352:11: error: 'requestAccessForMediaType:completionHandler:' is unavailable: not available on macOS
    requestAccessForMediaType:AVMediaTypeAudio
    ^
    /System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1502:1: note: 'requestAccessForMediaType:completionHandler:' has been explicitly marked unavailable here
  • (void)requestAccessForMediaType:(AVMediaType)mediaType completionHandler:(void (^)(BOOL granted))handler NS_AVAILABLE_IOS(7_0);
    ^
    7 errors generated.
    make: *** [Release/obj.target/permissions/permissions.o] Error 1
    gyp ERR! build error
    gyp ERR! stack Error: make failed with exit code: 2
    gyp ERR! stack at ChildProcess.onExit (/Users/travis/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
    gyp ERR! stack at ChildProcess.emit (events.js:311:20)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    gyp ERR! System Darwin 17.7.0
    gyp ERR! command "/Users/travis/.nvm/versions/node/v12.16.1/bin/node" "/Users/travis/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /Users/travis/build/loomhq/desktop/node_modules/node-mac-permissions
    gyp ERR! node -v v12.16.1
    gyp ERR! node-gyp -v v5.0.5
    gyp ERR! not ok
    info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Folder access automatically denied on signed app

Everything works fine. The permission popup appears in my dev env. But when I build the app with electron-packager and sign my app the permission popup does not appear. The log just returns a denied status.
(entitlements are setup correctly)
Can someone confirm that it works on the latest MacOS with a real signed app?

MacOS Sonoma 14.1
electron 26.4.2

Release of v2.4.0 on NPM

Hello 👋,

thank you for this module, I use it successfully to manage permissions on macOS. Thus, I observed that you have released a new version 2.4.0 recently on GitHub, which is not yet available on NPM. I managed to add the dependency from your GitHub repository instead of NPM, but I would be glad to acquire your module from NPM again. Could you upgrade the version available on NPM?

Cheers,
Raphael

Contacts permissions not popping

Hey, when I call askForContactsAccess() nothing is happening on dev mode for me? I tried adding an Info.plist file to a lot of places, but that's not helping either. Has anyone overcome this issue?

New release?

Thanks for this cool library! I see that the last release was back in 2020, and since then, there have been some very important changes. The one I am interested in is the one that specifies the os in the module spec. Could you please release a new version so that consumers are not pulling from GH?

Proposal to support Automation permissions

The library does a great job with almost all Privacy settings.

But it lacks support for Automation. It would be great to be able to check permission like this:

permissions.getAuthStatus('automation', 'com.apple.SystemEvents')

And ask for automation permission like this:

permissions.askForAutomation('com.apple.SystemEvents')

To check this, some simple automation command from Standard Suite can be tried to run, such as count:

tell app id 'some.your.application' to get count

And if the command returns an error, request permission via a call like this:

open x-apple.systempreferences:com.apple.preference.security?Privacy_Automation

The Speech framework is not compatible with macOS < 10.15

We build with a macOS 10.14 image on Travis, permissions.mm fails to build because Speech/Speech.h is not found.

Need to wrap with compiler directives:
#if AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER

And remove ld flag, -frameworks Speech for anything less than 10.15

getMediaAccessStatus returns not-determined if permission was set through script

I'm setting up CircleCI to run automated tests for my app which uses the microphone. CircleCI runs Mac tests on an image with SIP disabled and injects permissions into the TCC.db. The command is add-permission : source

Using the list-permissions command, I am able to confirm that the app does have the correct permission:

`client service auth_value


com.apple.Terminal kTCCServiceDeveloperTool 0
/usr/sbin/sshd kTCCServiceAppleEvents 2
/usr/sbin/sshd kTCCServiceAppleEvents 2
/usr/libexec/sshd-keygen-wrapper kTCCServiceAppleEvents 2
/usr/libexec/sshd-keygen-wrapper kTCCServiceAppleEvents 2
/usr/libexec/sshd-keygen-wrapper kTCCServiceAccessibility 2
APP.BUNDLE.IDENTIFIER kTCCServiceAll 2 `

When testing for the permission using systemPreferences.getMediaAccessStatus, the result is always not determined.

Cloudtabs.db-based Full Disk Access test is not reliable

I've ran into at least one instance where the ~/Library/Safari/Cloudtabs.db file didn't exist at all (this was Monterey and was on a second account that was created on the machine, logged into an already-existing Apple ID) This account also had Safari syncing ON in iCloud.

Is there a different file the library could look at that would be guaranteed (or at least more likely) to exist?

install problem with node-gyp

Hello,

ive got always this error - i tried so many times, reinstalling node-gyp and so on:

make: *** [Release/nothing.a] Error 1
gyp ERR! build error 
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 20.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/...../node_modules/node-mac-permissions
gyp ERR! node -v v14.15.4
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok 
npm WARN [email protected] requires a peer of tslint@^5.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Have somebody a hint, tipp or solution for it?
Thank you very much!

Best regards,
Stephan

installing Problem with node-gyp and installing issue facing from internal dependency "Binding"

Could you kindly assist me in resolving the internal dependency "Binding" installation issue and the node-gyp installation issue?

Exit code: 1 Command: node-gyp rebuild Arguments: Directory: /Users/p21-0008/Desktop/Dushyant/Demo/Desktop Application/ScreenshotV1.0/node_modules/node-mac-permissions Output: gyp info it worked if it ends with ok gyp info using [email protected] gyp info using [email protected] | darwin | x64 gyp info find Python using Python version 3.11.3 found at "/usr/local/opt/[email protected]/bin/python3.11" gyp info spawn /usr/local/opt/[email protected]/bin/python3.11 gyp info spawn args [ gyp info spawn args '/Users/p21-0008/.nvm/versions/node/v18.12.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/Users/p21-0008/Desktop/Dushyant/Demo/Desktop Application/ScreenshotV1.0/node_modules/node-mac-permissions/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/Users/p21-0008/.nvm/versions/node/v18.12.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/Users/p21-0008/Library/Caches/node-gyp/18.12.0/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/Users/p21-0008/Library/Caches/node-gyp/18.12.0', gyp info spawn args '-Dnode_gyp_dir=/Users/p21-0008/.nvm/versions/node/v18.12.0/lib/node_modules/npm/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/Users/p21-0008/Library/Caches/node-gyp/18.12.0/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/Users/p21-0008/Desktop/Dushyant/Demo/Desktop Application/ScreenshotV1.0/node_modules/node-mac-permissions', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] gyp info spawn make gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o LIBTOOL-STATIC Release/nothing.a warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols) CXX(target) Release/obj.target/permissions/permissions.o clang: error: no such file or directory: 'Application/ScreenshotV1.0/node_modules/node-addon-api' make: *** [Release/obj.target/permissions/permissions.o] Error 1 gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/Users/p21-0008/.nvm/versions/node/v18.12.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23) gyp ERR! stack at ChildProcess.emit (node:events:513:28) gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12) gyp ERR! System Darwin 22.5.0 gyp ERR! command "/Users/p21-0008/.nvm/versions/node/v18.12.0/bin/node" "/Users/p21-0008/.nvm/versions/node/v18.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/p21-0008/Desktop/Dushyant/Demo/Desktop Application/ScreenshotV1.0/node_modules/node-mac-permissions gyp ERR! node -v v18.12.0 gyp ERR! node-gyp -v v9.3.1

OS: Ventura 13.4
node version: 18.12.0
npm version:- 9.6.7

Also installed node-gyp V9.3.1

I also attempted to decrease the version of node-mac-permission, but I consistently encountered this issue.

i have also check node-mac-permission dependency in which i have found one dependancy Binding this will also give same error like this so please help to fix this problem

Gyp issue since last MacOS update

Hello,

Since the update to MacOS 12.3, I have this error when running yarn install.
Any idea?

error /Users/gva/Projects/scribe/desktop-app/node_modules/node-mac-permissions: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/gva/Projects/scribe/desktop-app/node_modules/node-mac-permissions
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info find Python using Python version 3.9.10 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
gyp info spawn args [
gyp info spawn args '/Users/gva/.nodenv/versions/14.18.2/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/gva/Projects/scribe/desktop-app/node_modules/node-mac-permissions/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/gva/.nodenv/versions/14.18.2/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/gva/Library/Caches/node-gyp/14.18.2/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/gva/Library/Caches/node-gyp/14.18.2',
gyp info spawn args '-Dnode_gyp_dir=/Users/gva/.nodenv/versions/14.18.2/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/gva/Library/Caches/node-gyp/14.18.2/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/gva/Projects/scribe/desktop-app/node_modules/node-mac-permissions',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
LIBTOOL-STATIC Release/nothing.a
env: python: No such file or directory
make: *** [Release/nothing.a] Error 127
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/gva/.nodenv/versions/14.18.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/Users/gva/.nodenv/versions/14.18.2/bin/node" "/Users/gva/.nodenv/versions/14.18.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/gva/Projects/scribe/desktop-app/node_modules/node-mac-permissions

System Preferences Open Before User Interacts With Prompt

When calling askForAccessibilityAccess(), the system preferences window is opened shortly after the prompt is displayed but before the user has interacted with the prompt.

node-mac-permissions version: 1.4.1

macOS versions:
Catalina 10.15.4, 10.15.5

   const { askForAccessibilityAccess} = require('node-mac-permissions');
   askForAccessibilityAccess();

Error: incompatible architecture issue while run the application

Electron Version: 19.1.0
Apple M1 chip

while run the application I am facing this issue... how to solve that? is there any solution for this issue?

`Error: dlopen(/Users/mine/Documents/proj/node_modules/node-mac-permissions/build/Release/permissions.node, 0x0001): tried: '/Users/mine/Documents/proj/node_modules/node-mac-permissions/build/Release/permissions.node' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
    at process.func [as dlopen] (noe:electron/js2c/asar_bundle:5:1812)
    at Module._extensions..node (node:internal/modules/cjs/loader:1203:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1812)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at bindings (/Users/animchnlap281/Documents/Vmaker_Mac/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/Users/mine/Documents/proj/node_modules/node-mac-permissions/index.js:1:40)

Add support for keyboard / mouse capture permissions (CGEventTapCreate)

https://asciiwwdc.com/2019/sessions/701

Monitoring all keyboard events, including those for other apps, however, requires user approval.

And here you can see an example of using CGEventTapCreate to invoke a callback for key press and release events.

Now, the first time this code runs, this call, the CGEventTapCreate will fail and return nil.

Meanwhile, a dialog is displayed directing the user to the security and privacy preference pane, where the user can approve your app to monitor keyboard events in the background, if they so desire.

Now, apps may check the authorization status without triggering the approval prompt, using the IOHIDCheckAccess function with the kIOHIDRequestTypeListenEvent parameter.

And apps can request an approval dialog to be displayed without creating an event tab or trying to post an event by using the IOHIDRequestAccess function, again with the same parameter.

So in summary, macOS Catalina now requires user consent for apps to record the contents of your screen or the keys that you type on your keyboard.

undefined filename issue with bindings module when used with webpack-dev-server

When using with webpack and webpack-dev-server, I ran into:

[18:16:53] [webpack-dev-server] http://localhost:8083
App threw an error during load
TypeError: Cannot read property 'indexOf' of undefined
    at Function.getFileName (webpack-internal:///./node_modules/bindings/bindings.js:178:16)

TLDR is when packaging for the dev-server, the bindings module used to find the permissions.node file errors with the above.

Quick workaround; in the webpack config for the main.js file, include:

externals: [
    (() => {
      const IGNORES = [
         'node-mac-permissions',
      ];

      return (context, request, callback) => {
        if (IGNORES.indexOf(request) >= 0) {
          return callback(null, `require('${request}')`);
        }

        return callback();
      };
    })(),
  ]

ref: railsware/bozon#40 (comment)

[BUG] Requesting accessibility permission in Electron program is always denied.

electron: 22.0.3
node-mac-permissions: 2.3.0

Calling permissions.getAuthStatus("accessibility") in development version is fine, but after installing the packaged Electron program for the second time, calling permissions.getAuthStatus("accessibility") will always return denied, even if resetting the permission or reinstalling it does not work 😢.

Add request for location access

I can only check the status of the location permission but I cannot change or ask for the permission. I will appreciate if there is a function for requesting the location.

Doesnt work on MacOS Catalina

So, i just trying to use ask for camera access

askForCameraAccess().then((status) => { console.log(Access to Camera is ${status}); });

but i get nodejs crash, so what should i do?

Снимок экрана 2020-06-14 в 14 30 51

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.