New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .isAccessGranted()
method
#90
Conversation
…pp has the right access to perform the active window fixed typo removed unused console log
There are multiple types of accesses. Do you think it's enough to just expose one method for all of them? |
You are right. There is 3 accesses right ? I can work on this. Should I do 3 different methods for each access or one method that returns data for the 3 accesses ? |
I mean, can you imagine needing any of the specific ones instead of just all? I would prefer to keep it simple and do one method for all, but I'm curious if I'm missing any use-cases. |
Maybe some apps ask for the Accessibility permission during the Installation process but not the screen recording. Or the other way around. I think making the method more general and returning a JSON with all the permission can be useful. I will update my pull request |
Then I think there should also be an |
.isAccessGranted()
method
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
You mean in the object returned by the By the way should I keep this name |
Yes
I think {
all: false,
screen: true,
accessibility: false
} |
I pushed the latest changes. However I noticed that one last access is used for the URL of the browser. For this I saw that an apple script was used Couple possibilities:
Also I do noticed an Error on Mojave: |
Hi @sindresorhus any update on this pull request? |
Seems like it's possible: https://halmueller.wordpress.com/2018/09/04/privacy-consent-in-mojave-part-2-applescript/ |
|
||
/** | ||
Resolves all the statuses of the accesses needed to check the active win | ||
Returns an object of type AccessResult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use proper TS doc comment syntax for return value.
} | ||
} | ||
} | ||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use tab-indentation
} | ||
|
||
// Don't check windows owned by this process | ||
if windowProcessIdentifier == processIdentifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use guard
.
*/ | ||
func isScreenRecordingGrantedNoDialog() -> Bool { | ||
// The screen recording security was introduced in version 10.15 of MAC os | ||
if #available(macOS 10.15, *) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use guard
. Applies to many other places.
* CREDITS: https://gist.github.com/soffes/da6ea98be4f56bc7b8e75079a5224b37 | ||
*/ | ||
func isScreenRecordingGrantedNoDialog() -> Bool { | ||
// The screen recording security was introduced in version 10.15 of MAC os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not how you write macOS.
@@ -71,6 +71,14 @@ Returns an `Object` with the result, or `undefined` if there is no active window | |||
- `url` *(string?)* - URL of the active browser tab if the active window is Safari, Chrome, Edge, or Brave *(macOS only)* | |||
- `memoryUsage` *(number)* - Memory usage by the window owner process | |||
|
|||
### activeWin.isAccessGranted() | |||
|
|||
Check if the package has enough access to get the active window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct. It always has access, just not access to the window title, etc.
|
||
Check if the package has enough access to get the active window. | ||
|
||
Returns `true` if there is enough access, `false` otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated.
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Closing as this isn't moving forward and the PR is just too far from being mergable. Probably better to leave it to someone else. |
I read the article you sent me and did more research. Again this permission is only used to get Browser URL from active browser. If you agree on keeping only this 2 I can work on the remaining comments you left to finalize this PR |
Added new method isAccessGranted that will return true if the app has the right access to perform the active window
This method is useful on MAC to avoid getting the activeWin if the access are not granted.
In my case I use activeWin in an Interval to check the foreground window. Without this method the dialogs to ask for permission are prompted again and again.
I don't know if it was in your road map but I am opening this pull request anyway.