@zukhruf/tcc 0.0.0-stage → 0.8.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +298 -2
- package/dist/authorization-statuses.d.ts +7 -0
- package/dist/authorization-statuses.d.ts.map +1 -0
- package/dist/authorization-statuses.js +28 -0
- package/dist/authorization-statuses.js.map +1 -0
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +45 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/native/jxa-request.d.ts +7 -0
- package/dist/native/jxa-request.d.ts.map +1 -0
- package/dist/native/jxa-request.js +34 -0
- package/dist/native/jxa-request.js.map +1 -0
- package/dist/native/node-ffi.d.ts +2 -0
- package/dist/native/node-ffi.d.ts.map +1 -0
- package/dist/native/node-ffi.js +6 -0
- package/dist/native/node-ffi.js.map +1 -0
- package/dist/native/objective-c-class.d.ts +7 -0
- package/dist/native/objective-c-class.d.ts.map +1 -0
- package/dist/native/objective-c-class.js +56 -0
- package/dist/native/objective-c-class.js.map +1 -0
- package/dist/preflight.d.ts +7 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +13 -0
- package/dist/preflight.js.map +1 -0
- package/dist/prompted-service.d.ts +10 -0
- package/dist/prompted-service.d.ts.map +1 -0
- package/dist/prompted-service.js +31 -0
- package/dist/prompted-service.js.map +1 -0
- package/dist/request.prompt.spec.d.ts +2 -0
- package/dist/request.prompt.spec.d.ts.map +1 -0
- package/dist/request.prompt.spec.js +59 -0
- package/dist/request.prompt.spec.js.map +1 -0
- package/dist/service.d.ts +11 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +25 -0
- package/dist/service.js.map +1 -0
- package/dist/services/accessibility.d.ts +11 -0
- package/dist/services/accessibility.d.ts.map +1 -0
- package/dist/services/accessibility.js +20 -0
- package/dist/services/accessibility.js.map +1 -0
- package/dist/services/automation.d.ts +13 -0
- package/dist/services/automation.d.ts.map +1 -0
- package/dist/services/automation.js +58 -0
- package/dist/services/automation.js.map +1 -0
- package/dist/services/bluetooth.d.ts +12 -0
- package/dist/services/bluetooth.d.ts.map +1 -0
- package/dist/services/bluetooth.js +21 -0
- package/dist/services/bluetooth.js.map +1 -0
- package/dist/services/calendars.d.ts +10 -0
- package/dist/services/calendars.d.ts.map +1 -0
- package/dist/services/calendars.js +15 -0
- package/dist/services/calendars.js.map +1 -0
- package/dist/services/camera.d.ts +10 -0
- package/dist/services/camera.d.ts.map +1 -0
- package/dist/services/camera.js +14 -0
- package/dist/services/camera.js.map +1 -0
- package/dist/services/contacts.d.ts +10 -0
- package/dist/services/contacts.d.ts.map +1 -0
- package/dist/services/contacts.js +15 -0
- package/dist/services/contacts.js.map +1 -0
- package/dist/services/full-disk-access.d.ts +11 -0
- package/dist/services/full-disk-access.d.ts.map +1 -0
- package/dist/services/full-disk-access.js +40 -0
- package/dist/services/full-disk-access.js.map +1 -0
- package/dist/services/input-monitoring.d.ts +12 -0
- package/dist/services/input-monitoring.d.ts.map +1 -0
- package/dist/services/input-monitoring.js +22 -0
- package/dist/services/input-monitoring.js.map +1 -0
- package/dist/services/microphone.d.ts +10 -0
- package/dist/services/microphone.d.ts.map +1 -0
- package/dist/services/microphone.js +14 -0
- package/dist/services/microphone.js.map +1 -0
- package/dist/services/photos-add.d.ts +10 -0
- package/dist/services/photos-add.d.ts.map +1 -0
- package/dist/services/photos-add.js +15 -0
- package/dist/services/photos-add.js.map +1 -0
- package/dist/services/photos.d.ts +10 -0
- package/dist/services/photos.d.ts.map +1 -0
- package/dist/services/photos.js +15 -0
- package/dist/services/photos.js.map +1 -0
- package/dist/services/reminders.d.ts +10 -0
- package/dist/services/reminders.d.ts.map +1 -0
- package/dist/services/reminders.js +15 -0
- package/dist/services/reminders.js.map +1 -0
- package/dist/services/screen-recording.d.ts +11 -0
- package/dist/services/screen-recording.d.ts.map +1 -0
- package/dist/services/screen-recording.js +18 -0
- package/dist/services/screen-recording.js.map +1 -0
- package/dist/services/speech-recognition.d.ts +12 -0
- package/dist/services/speech-recognition.d.ts.map +1 -0
- package/dist/services/speech-recognition.js +16 -0
- package/dist/services/speech-recognition.js.map +1 -0
- package/package.json +45 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ezzabuzaid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,299 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zukhruf/tcc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
macOS keeps personal data and devices behind privacy grants: Full Disk Access, Contacts, Camera, Screen Recording and more. The subsystem that keeps them is TCC (Transparency, Consent, and Control), with its daemon `tccd`, its tool tccutil(1) and its database `TCC.db`. A program that needs one must answer the same questions each time. What is the status of the grant for this process? How does the program ask the user? Which program does macOS charge the access to: the terminal app, or the program itself? What must the user turn on, and where? macOS gives no status and no prompt for Full Disk Access: how does the program find out, and get the user to the right pane? This package answers them once, for each service that the leading tools cover.
|
|
4
|
+
|
|
5
|
+
It uses the words of TCC: a **service** is a kind of grant (`kTCCServiceSystemPolicyAllFiles` is Full Disk Access), and a **client** is the program that macOS charges the access to: an app bundle or an executable ([ADR 0001](./docs/adr/0001-the-package-is-named-after-tcc-and-uses-its-words.md)). Each service is a class with Apple's own status values ([ADR 0002](./docs/adr/0002-each-service-is-a-class-and-its-status-has-apples-values.md)). The package depends on no other package. It uses `node:ffi`, `node:fs` and `node:child_process`, and it works only on macOS.
|
|
6
|
+
|
|
7
|
+
The words in these documents have one meaning each. See the glossary in [CONTEXT.md](./CONTEXT.md).
|
|
8
|
+
|
|
9
|
+
## Use it
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @zukhruf/tcc
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Camera, Client } from '@zukhruf/tcc';
|
|
17
|
+
|
|
18
|
+
const camera = new Camera();
|
|
19
|
+
if (camera.status() === 'notDetermined') await camera.request({ signal });
|
|
20
|
+
if (camera.status() !== 'authorized')
|
|
21
|
+
console.error(camera.remedy(Client.responsibleFor(process.pid)));
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Read the status of a service
|
|
25
|
+
|
|
26
|
+
`status()` returns Apple's own value for the calling process. It never shows a prompt. The first call in a process loads `node:ffi`, and Node writes its `ExperimentalWarning` once.
|
|
27
|
+
|
|
28
|
+
| Class | TCC service | `status()` values | Apple's API |
|
|
29
|
+
| ------------------- | --------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------ |
|
|
30
|
+
| `Contacts` | `kTCCServiceAddressBook` | `notDetermined`, `restricted`, `denied`, `authorized` | `+[CNContactStore authorizationStatusForEntityType:]` |
|
|
31
|
+
| `Calendars` | `kTCCServiceCalendar` | `notDetermined`, `restricted`, `denied`, `fullAccess`, `writeOnly` | `+[EKEventStore authorizationStatusForEntityType:]`, event |
|
|
32
|
+
| `Reminders` | `kTCCServiceReminders` | the same as `Calendars` | the same, reminder |
|
|
33
|
+
| `Camera` | `kTCCServiceCamera` | `notDetermined`, `restricted`, `denied`, `authorized` | `+[AVCaptureDevice authorizationStatusForMediaType:]`, video |
|
|
34
|
+
| `Microphone` | `kTCCServiceMicrophone` | the same as `Camera` | the same, audio |
|
|
35
|
+
| `Photos` | `kTCCServicePhotos` | `notDetermined`, `restricted`, `denied`, `authorized`, `limited` | `+[PHPhotoLibrary authorizationStatusForAccessLevel:]`, read-write |
|
|
36
|
+
| `PhotosAdd` | `kTCCServicePhotosAdd` | the same as `Photos` | the same, add only |
|
|
37
|
+
| `SpeechRecognition` | `kTCCServiceSpeechRecognition` | `notDetermined`, `denied`, `restricted`, `authorized` | `+[SFSpeechRecognizer authorizationStatus]` |
|
|
38
|
+
| `Bluetooth` | `kTCCServiceBluetoothAlways` | `notDetermined`, `restricted`, `denied`, `allowedAlways` | `CBManager.authorization` |
|
|
39
|
+
| `InputMonitoring` | `kTCCServiceListenEvent` | `granted`, `denied`, `unknown` | `IOHIDCheckAccess(kIOHIDRequestTypeListenEvent)` |
|
|
40
|
+
| `Accessibility` | `kTCCServiceAccessibility` | `trusted`, `notTrusted` | `AXIsProcessTrusted()` |
|
|
41
|
+
| `ScreenRecording` | `kTCCServiceScreenCapture` | `granted`, `notGranted` | `CGPreflightScreenCaptureAccess()` |
|
|
42
|
+
| `Automation` | `kTCCServiceAppleEvents` | `permitted`, `notPermitted`, `wouldRequireUserConsent`, `notRunning` | `AEDeterminePermissionToAutomateTarget()`, with no prompt |
|
|
43
|
+
| `FullDiskAccess` | `kTCCServiceSystemPolicyAllFiles` | none: see the preflight below | none |
|
|
44
|
+
|
|
45
|
+
`Automation` is a grant for one target app: `new Automation('com.apple.Finder')`. Its status is `notRunning` while the target app does not run, because macOS asks the target (`AppleEvents.h:346`, [ADR 0002](./docs/adr/0002-each-service-is-a-class-and-its-status-has-apples-values.md)).
|
|
46
|
+
|
|
47
|
+
## Ask the user for a service
|
|
48
|
+
|
|
49
|
+
`request()` asks macOS to show its prompt, and resolves with the status after the user answers. It runs `/usr/bin/osascript`, because macOS shows the prompt only to a program that holds Apple's private entitlement `com.apple.private.tcc.allow-prompting`, and `osascript` holds it ([ADR 0007](./docs/adr/0007-a-request-runs-in-osascript-which-may-show-the-prompt.md)). The grant goes to the client of the calling process, the same one that `status()` reads.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
const status = await new Contacts().request({ signal }); // 'authorized' after Allow
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
macOS shows a prompt only while the status is `notDetermined` (or `writeOnly` for Calendars and Reminders, where the request asks for full access). After a denial it shows nothing, and `request()` resolves with the same status: send the user to the pane. For Accessibility, Input Monitoring and Screen Recording, macOS shows a dialog that sends the user to System Settings, where the user turns the client on; `request()` resolves when the dialog shows, with the status as it is then. `FullDiskAccess` has no `request()`: macOS shows nothing for it. The `signal` stops the wait: the package ends `osascript`, and the promise rejects with the signal's reason.
|
|
56
|
+
|
|
57
|
+
## Check Full Disk Access with a preflight
|
|
58
|
+
|
|
59
|
+
Full Disk Access has no status. Apple gives no API for it, and no path that proves the grant ([ADR 0003](./docs/adr/0003-full-disk-access-has-no-status-so-the-caller-preflights-its-own-paths.md)). A process learns whether it can read a protected path only when it reads that path. Thus `preflight()` opens each path that you give, the paths that your work will read, and sorts them by the result:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { FullDiskAccess } from '@zukhruf/tcc';
|
|
63
|
+
|
|
64
|
+
const result = await new FullDiskAccess().preflight([
|
|
65
|
+
`${home}/Library/Mail`,
|
|
66
|
+
`${home}/Library/Messages/chat.db`,
|
|
67
|
+
]);
|
|
68
|
+
result.readable; // the paths that opened
|
|
69
|
+
result.denied; // the paths that macOS or the file mode keeps from this process (EPERM, EACCES)
|
|
70
|
+
result.missing; // the paths that are not there (ENOENT, ENOTDIR)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Do the preflight in the process that does the real work. A grant belongs to the client of a process, and other software, such as Endpoint Security, can also stop a read that Full Disk Access allows.
|
|
74
|
+
|
|
75
|
+
## Find the client of a process
|
|
76
|
+
|
|
77
|
+
macOS charges the access of a process to its responsible process: the app that started it, or the process itself when launchd started it. `Client.responsibleFor(pid)` asks macOS ([ADR 0004](./docs/adr/0004-the-client-comes-from-macos-through-node-ffi.md)):
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { Client } from '@zukhruf/tcc';
|
|
81
|
+
|
|
82
|
+
const client = Client.responsibleFor(process.pid);
|
|
83
|
+
client.type; // 'bundle' from a terminal app, 'executable' when launchd started the process
|
|
84
|
+
client.path; // '/Applications/cmux.app' or '/Users/me/.nvm/versions/node/v26.13.1/bin/node'
|
|
85
|
+
client.name; // 'cmux', or the path of the executable: what the user finds in System Settings
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
A program that will run later, such as the `node` of a launchd job, has no process yet. Make its client from its path:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
Client.executable('/Users/me/.nvm/versions/node/v26.13.1/bin/node');
|
|
92
|
+
Client.bundle('/Applications/cmux.app');
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Tell the user what to turn on
|
|
96
|
+
|
|
97
|
+
`remedy(client)` gives the sentence that the user acts on ([ADR 0005](./docs/adr/0005-the-remedy-names-the-client-and-the-pane-and-opening-the-pane-is-the-request.md)):
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
new Contacts().remedy(client);
|
|
101
|
+
// 'Turn on cmux in System Settings › Privacy & Security › Contacts.'
|
|
102
|
+
|
|
103
|
+
new Accessibility().remedy(client);
|
|
104
|
+
// on macOS 27: 'Turn on cmux in System Settings › Privacy & Security › Device Control and Data Access.'
|
|
105
|
+
|
|
106
|
+
new FullDiskAccess().remedy(client);
|
|
107
|
+
// 'Turn on cmux in System Settings › Privacy & Security › Full Disk Access, then quit and reopen cmux. macOS does not ask for this access.'
|
|
108
|
+
|
|
109
|
+
new FullDiskAccess().remedy(Client.executable(node));
|
|
110
|
+
// 'Turn on /Users/me/.nvm/versions/node/v26.13.1/bin/node in System Settings › Privacy & Security › Full Disk Access, then start it again. macOS does not ask for this access.'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The pane titles are read from System Settings of the Mac at each call (`SecurityPrivacyExtension.appex`, `Localizable.loctable`, in English), because macOS renames panes: Accessibility on macOS 26 is "Device Control and Data Access" on macOS 27 ([ADR 0005](./docs/adr/0005-the-remedy-names-the-client-and-the-pane-and-opening-the-pane-is-the-request.md)). A grant of Full Disk Access applies to the processes that start after it, so its remedy tells the user to start the client again. A host that has its own command for that, such as a restart of a launchd job, writes its command after the remedy.
|
|
114
|
+
|
|
115
|
+
## Open the pane
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
await new FullDiskAccess().openSettings();
|
|
119
|
+
// /usr/bin/open 'x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles'
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Each service opens its own pane, with the anchor that `TCCServiceList.plist` of System Settings gives it, such as `Privacy_Camera` or `Privacy_ListenEvent`. Open a pane only when the user asked for the step: System Settings comes to the front.
|
|
123
|
+
|
|
124
|
+
## Errors
|
|
125
|
+
|
|
126
|
+
| Error | When |
|
|
127
|
+
| ----------------- | ---------------------------------------------------------------------------------- |
|
|
128
|
+
| The signal reason | `request()` was waiting for the user's answer, and the caller's signal was aborted |
|
|
129
|
+
|
|
130
|
+
A preflight gives a denied path and a missing path as data, because the caller does the same next step for each path of a kind. Any other failure of a read, such as `EIO`, is thrown as Node gives it. A failure to load `node:ffi`, for example in a process that runs with `--permission` and without `--allow-ffi`, is thrown as Node gives it.
|
|
131
|
+
|
|
132
|
+
## What macOS does not do
|
|
133
|
+
|
|
134
|
+
- **It gives no API that tells whether a process has Full Disk Access.** Kevin Elliott of Apple DTS, August 2026: "there isn't currently a 'general' solution to this issue". On macOS 27 the per-user `TCC.db` is in a protected container, so a read of it fails also when the grant is there ([Apple Developer Forums thread 841091](https://developer.apple.com/forums/thread/841091)).
|
|
135
|
+
- **It shows no prompt for Full Disk Access.** The user turns the client on in System Settings.
|
|
136
|
+
- **It shows the prompt of a request only to a program with Apple's private entitlement.** The request of any other executable completes with no prompt and no grant ([ADR 0007](./docs/adr/0007-a-request-runs-in-osascript-which-may-show-the-prompt.md)).
|
|
137
|
+
- **It asks the user once.** After a denial, a request shows nothing. Only the user changes the grant, in System Settings.
|
|
138
|
+
|
|
139
|
+
## What the package does not do
|
|
140
|
+
|
|
141
|
+
- **It does not grant access.** Only the user grants it. The package never writes `TCC.db` and never runs `tccutil reset`.
|
|
142
|
+
- **It does not guess Full Disk Access.** It has no call that reads a path of its own choice to say yes or no ([ADR 0003](./docs/adr/0003-full-disk-access-has-no-status-so-the-caller-preflights-its-own-paths.md)).
|
|
143
|
+
- **It keeps no state.** It exports classes, never an instance, and it has no slot in which a host installs a name ([ADR 0006](./docs/adr/0006-the-package-keeps-no-state.md)).
|
|
144
|
+
- **It does not cover Location.** `locationd`, not TCC, keeps the location grant ([ADR 0002](./docs/adr/0002-each-service-is-a-class-and-its-status-has-apples-values.md)).
|
|
145
|
+
|
|
146
|
+
## Scope
|
|
147
|
+
|
|
148
|
+
| Now (this release) | Later | Never |
|
|
149
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
150
|
+
| The 14 services of the status table, each with `remedy()` and `openSettings()`; the 13 other than Full Disk Access with `status()` and `request()` | Media & Apple Music: its only API that is not deprecated, MusicKit, is Swift only | A call that guesses Full Disk Access from a path the package chooses |
|
|
151
|
+
| `preflight(paths)` of Full Disk Access | Motion, HomeKit and the other services of `TCCServiceList.plist`, when a leading tool covers them | A write to `TCC.db`, or `tccutil reset` |
|
|
152
|
+
| `Client.responsibleFor(pid)`, `Client.bundle(path)`, `Client.executable(path)` | A watch that tells when a grant changes | Location, which `locationd` keeps |
|
|
153
|
+
| | A spawn that makes a child process its own client (responsibility disclaim) | Support for a macOS older than the newest |
|
|
154
|
+
|
|
155
|
+
## Who uses it
|
|
156
|
+
|
|
157
|
+
| Consumer | How | Record |
|
|
158
|
+
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
|
|
159
|
+
| elt `@eltjs/sdk-macos-app-database` | Each `Store` names a service class; `StoreUnavailableError` writes `store.service.remedy(Client.responsibleFor(process.pid))`. Replaces `macOSAccess`, an instance with an `install({ program })` slot, its `Grant` type and its pane names (`src/macos-access.ts`, `src/store.ts:5-18`, `src/unavailable.ts`) | elt #5754 |
|
|
160
|
+
| elt `@eltjs/sdk-apple-eventkit` | `Calendars` and `Reminders` give the remedy of its errors (`src/errors.ts:8,19`), and their `request()` replaces the request through `osascript` of its Swift helper (`src/helper/Access.swift:44-68`) | elt #5754 |
|
|
161
|
+
| context-compiler `apps/cli` | Nothing at its entry point: `responsibleProgram()` and its `macOSAccess.install()` go (`src/main.ts:39-59`). `sync watch start` writes `new FullDiskAccess().remedy(Client.executable(node))` (`src/commands/sync-watch-start.ts:18`) | context-compiler #5755 |
|
|
162
|
+
| context-compiler `@workspace/connector` | Each connector names the services of its stores in place of `guidance()`, `access()` and `fullDiskAccess` (27 classes, `packages/connectors/connector/src/connector.ts`) | context-compiler #5755 |
|
|
163
|
+
|
|
164
|
+
## The same concepts in other systems
|
|
165
|
+
|
|
166
|
+
| Concept | Other systems |
|
|
167
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
168
|
+
| A class for each kind of grant | .NET MAUI `Permissions.ContactsRead`, `Permissions.CalendarRead` (dotnet/maui `src/Essentials/src/Permissions/Permissions.shared.cs:181-364`); react-native-permissions `PERMISSIONS.IOS.CONTACTS` |
|
|
169
|
+
| Status | MAUI `CheckStatusAsync<T>()` with `PermissionStatus`; node-mac-permissions `getAuthStatus(type)`; Flutter permission_handler `Permission.contacts.status`; react-native-permissions `check()`; Electron `systemPreferences.getMediaAccessStatus()` |
|
|
170
|
+
| Request | MAUI `RequestAsync<T>()`; node-mac-permissions `askForContactsAccess()` and the other `askFor*` calls; Flutter `request()`; react-native-permissions `request()`; Electron `askForMediaAccess()` |
|
|
171
|
+
| Open the settings | node-mac-permissions `OpenPrefPane("Privacy_AllFiles")` (`permissions.mm:140`); tauri-plugin-macos-permissions (`full_disk_access.rs:60`); Flutter `openAppSettings()`; react-native-permissions `openSettings()`; MAUI `AppInfo.ShowSettingsUI()`, which opens System Settings and no pane |
|
|
172
|
+
| Full Disk Access | node-mac-permissions opens four files, `TCC.db` among them (`permissions.mm:296-320`); tauri-plugin-macos-permissions reads `Library/Safari` (`full_disk_access.rs:26`); Apple DTS: spot-check the locations your work needs (thread 841091) |
|
|
173
|
+
| Client | `responsibility_get_pid_responsible_for_pid` in libSystem (private); the crate `disclaim` and npm `node-macos-disclaim` spawn a child as its own client; the columns `client` and `client_type` of `TCC.db` |
|
|
174
|
+
| Go and Rust | No maintained package checks TCC (pkg.go.dev and crates.io, 2026-11-26): Go `tmc/macgo/permissions` maps names to entitlements; Rust `axwatch` watches the Accessibility grant |
|
|
175
|
+
|
|
176
|
+
## Why no npm package was used
|
|
177
|
+
|
|
178
|
+
Searched on 2026-11-26: the `@stdlib` scope ("permission", "privacy", "macos"), and npm for "macos permissions", "mac permissions", "tcc", "macos tcc", "full disk access", "macos privacy", "privacy settings macos" and "system preferences macos". The checks: Full Disk Access with no prompt (1), the status of each service (2), the client of the process (3), the pane of each service (4), Node 26 on macOS 27 (5), ES module with types (6), and no native toolchain (7).
|
|
179
|
+
|
|
180
|
+
| Package | Last release | Weekly downloads | Why not |
|
|
181
|
+
| ----------------------------------------- | ------------ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
182
|
+
| node-mac-permissions 2.5.0 | 2025-03-15 | 8,667 | Fails 3 and 7: no client, and an Objective-C++ addon that node-gyp and Xcode build. Fails 6: its named ES module imports do not load. Its Full Disk Access check opens the per-user `TCC.db`, which macOS 27 moved. Its location anchor `Privacy_Location` is stale. |
|
|
183
|
+
| @nut-tree-fork/node-mac-permissions 2.2.1 | 2025-03-15 | 4,846 | A republish of an older node-mac-permissions with a prebuilt binary: fails 3 and 7. |
|
|
184
|
+
| @computer-use/node-mac-permissions 2.2.2 | 2025-01-08 | 6,441 | The same JavaScript as the fork above: fails 3 and 7. |
|
|
185
|
+
| node-macos-disclaim 0.0.1 | 2026-11-06 | 944 | Only the client (3), as a prebuilt binary: fails 1, 2, 4 and 7. |
|
|
186
|
+
| @mgcrea/mcp-apple-core 1.43.0 | 2026-11-20 | 467 | An MCP server kit that maps an Automation denial after the fact: fails 1 to 4. |
|
|
187
|
+
| @stakeswky/openclaw-permctl 0.2.0 | 2026-02-18 | 7 | An agent plugin that matches error text: fails 1 to 3, and ships its TypeScript source as its entry. |
|
|
188
|
+
| mac-screen-capture-permissions 2.1.0 | 2023-09-11 | 1,449 | Screen Recording only, with Electron prebuilds: fails 1 to 3 and 7. |
|
|
189
|
+
| tauri-plugin-macos-permissions-api 2.3.0 | 2025-05-06 | 50,897 | Runs only in a Tauri app (5), and its plugin is Rust (7). |
|
|
190
|
+
|
|
191
|
+
Node has no API for TCC: `process.permission` is the permission model of Node, not of macOS. Node 26 has `node:ffi`, which reaches the frameworks of macOS with no toolchain. The maintainer chose it over a native addon on 2026-11-26.
|
|
192
|
+
|
|
193
|
+
## API
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
export abstract class Service {
|
|
197
|
+
readonly name: string; // the TCC service, e.g. 'kTCCServiceCamera'
|
|
198
|
+
readonly pane: string; // the pane's title, read from System Settings of this Mac, e.g. 'Camera'
|
|
199
|
+
readonly url: URL; // x-apple.systempreferences:com.apple.preference.security?Privacy_Camera
|
|
200
|
+
remedy(client: Client): string;
|
|
201
|
+
openSettings(): Promise<void>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// A service whose status a framework of macOS gives, and whose prompt a request shows.
|
|
205
|
+
export abstract class PromptedService<Status extends string> extends Service {
|
|
206
|
+
status(): Status;
|
|
207
|
+
request(options: { readonly signal: AbortSignal }): Promise<Status>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export class Contacts extends PromptedService<
|
|
211
|
+
'notDetermined' | 'restricted' | 'denied' | 'authorized'
|
|
212
|
+
> {}
|
|
213
|
+
export class Calendars extends PromptedService<
|
|
214
|
+
'notDetermined' | 'restricted' | 'denied' | 'fullAccess' | 'writeOnly'
|
|
215
|
+
> {}
|
|
216
|
+
export class Reminders extends PromptedService<
|
|
217
|
+
'notDetermined' | 'restricted' | 'denied' | 'fullAccess' | 'writeOnly'
|
|
218
|
+
> {}
|
|
219
|
+
export class Camera extends PromptedService<
|
|
220
|
+
'notDetermined' | 'restricted' | 'denied' | 'authorized'
|
|
221
|
+
> {}
|
|
222
|
+
export class Microphone extends PromptedService<
|
|
223
|
+
'notDetermined' | 'restricted' | 'denied' | 'authorized'
|
|
224
|
+
> {}
|
|
225
|
+
export class Photos extends PromptedService<
|
|
226
|
+
'notDetermined' | 'restricted' | 'denied' | 'authorized' | 'limited'
|
|
227
|
+
> {}
|
|
228
|
+
export class PhotosAdd extends PromptedService<
|
|
229
|
+
'notDetermined' | 'restricted' | 'denied' | 'authorized' | 'limited'
|
|
230
|
+
> {}
|
|
231
|
+
export class SpeechRecognition extends PromptedService<
|
|
232
|
+
'notDetermined' | 'denied' | 'restricted' | 'authorized'
|
|
233
|
+
> {}
|
|
234
|
+
export class Bluetooth extends PromptedService<
|
|
235
|
+
'notDetermined' | 'restricted' | 'denied' | 'allowedAlways'
|
|
236
|
+
> {}
|
|
237
|
+
export class InputMonitoring extends PromptedService<
|
|
238
|
+
'granted' | 'denied' | 'unknown'
|
|
239
|
+
> {}
|
|
240
|
+
export class Accessibility extends PromptedService<'trusted' | 'notTrusted'> {}
|
|
241
|
+
export class ScreenRecording extends PromptedService<
|
|
242
|
+
'granted' | 'notGranted'
|
|
243
|
+
> {}
|
|
244
|
+
export class Automation extends PromptedService<
|
|
245
|
+
'permitted' | 'notPermitted' | 'wouldRequireUserConsent' | 'notRunning'
|
|
246
|
+
> {
|
|
247
|
+
constructor(target: string); // the bundle identifier of the target app
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export class FullDiskAccess extends Service {
|
|
251
|
+
preflight(paths: readonly string[]): Promise<Preflight>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export class Preflight {
|
|
255
|
+
readonly readable: readonly string[];
|
|
256
|
+
readonly denied: readonly string[];
|
|
257
|
+
readonly missing: readonly string[];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export class Client {
|
|
261
|
+
static responsibleFor(pid: number): Client;
|
|
262
|
+
static bundle(path: string): Client;
|
|
263
|
+
static executable(path: string): Client;
|
|
264
|
+
readonly type: 'bundle' | 'executable';
|
|
265
|
+
readonly path: string;
|
|
266
|
+
readonly name: string;
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Each call and what it does
|
|
271
|
+
|
|
272
|
+
| Call | What it does |
|
|
273
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
274
|
+
| `status()` of a framework service | Loads `node:ffi`, opens the framework, and sends the class method of the status table through `objc_msgSend`, or calls its C function. It maps Apple's raw value to its name. |
|
|
275
|
+
| `new Automation(target).status()` | Builds an `AEDesc` of type `typeApplicationBundleID` with `AECreateDesc()`, and calls `AEDeterminePermissionToAutomateTarget(desc, 'aevt', 'odoc', false)`: `noErr` is permitted, `-1743` not permitted, `-1744` would require user consent, `-600` not running. |
|
|
276
|
+
| `request({ signal })` | Runs `/usr/bin/osascript -l JavaScript` with a script that sends the framework's request and turns its run loop in 50 ms slices until the status is decided, or that calls the C function of the request; then reads the status again. The signal ends `osascript`. |
|
|
277
|
+
| `new FullDiskAccess().preflight(paths)` | Opens each path read-only with `node:fs` and closes it at once: EPERM and EACCES are denied, ENOENT and ENOTDIR are missing, any other code is thrown. |
|
|
278
|
+
| `Client.responsibleFor(pid)` | Calls `responsibility_get_pid_responsible_for_pid(pid)` and `proc_pidpath()` in libSystem through `node:ffi`. A path inside a `.app` folder gives a bundle; any other path gives an executable. |
|
|
279
|
+
| `service.pane` | Runs `/usr/bin/plutil -extract en.<key> raw` on the `Localizable.loctable` of System Settings' Privacy & Security extension. |
|
|
280
|
+
| \1 |
|
|
281
|
+
| `openSettings()` | Runs `/usr/bin/open` with `service.url`. |
|
|
282
|
+
|
|
283
|
+
## Documentation
|
|
284
|
+
|
|
285
|
+
**Decisions**
|
|
286
|
+
|
|
287
|
+
- [ADR 0001](./docs/adr/0001-the-package-is-named-after-tcc-and-uses-its-words.md): the package is named after TCC and uses its words.
|
|
288
|
+
- [ADR 0002](./docs/adr/0002-each-service-is-a-class-and-its-status-has-apples-values.md): each service is a class, and its status has Apple's values.
|
|
289
|
+
- [ADR 0003](./docs/adr/0003-full-disk-access-has-no-status-so-the-caller-preflights-its-own-paths.md): Full Disk Access has no status, so the caller preflights its own paths.
|
|
290
|
+
- [ADR 0004](./docs/adr/0004-the-client-comes-from-macos-through-node-ffi.md): the client comes from macOS, through node:ffi.
|
|
291
|
+
- [ADR 0005](./docs/adr/0005-the-remedy-names-the-client-and-the-pane-and-opening-the-pane-is-the-request.md): the remedy names the client and the pane, and opening the pane is the request.
|
|
292
|
+
- [ADR 0006](./docs/adr/0006-the-package-keeps-no-state.md): the package keeps no state.
|
|
293
|
+
- [ADR 0007](./docs/adr/0007-a-request-runs-in-osascript-which-may-show-the-prompt.md): a request runs in osascript, which may show the prompt.
|
|
294
|
+
|
|
295
|
+
On each Mac: `man tccutil`, the SDK headers of the frameworks in the status table, and `/System/Library/ExtensionKit/Extensions/SecurityPrivacyExtension.appex/Contents/Resources/TCCServiceList.plist`.
|
|
296
|
+
|
|
297
|
+
## Development
|
|
298
|
+
|
|
299
|
+
The project has the tag `platform:darwin`, so its targets run in the macOS job of CI ([root ADR 0005](../../../docs/adr/0005-a-project-that-needs-macos-runs-its-targets-on-a-macos-runner.md)). The tests call the real frameworks through `node:ffi`, on Node 26. A test of `request()` needs a person at the Mac to answer the prompt, so CI runs `test`: the status, preflight, client, remedy and pane tests. The tests that need a person at the Mac to answer a prompt, or that bring System Settings to the front, are `src/**/*.prompt.spec.ts`, which `npx nx run tcc:test-prompt` runs, as `test-network` runs the network tests of `mteb`.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const authorized: readonly ['notDetermined', 'restricted', 'denied', 'authorized'];
|
|
2
|
+
export type Authorized = (typeof authorized)[number];
|
|
3
|
+
export declare const fullAccess: readonly ['notDetermined', 'restricted', 'denied', 'fullAccess', 'writeOnly'];
|
|
4
|
+
export type FullAccess = (typeof fullAccess)[number];
|
|
5
|
+
export declare const limited: readonly ['notDetermined', 'restricted', 'denied', 'authorized', 'limited'];
|
|
6
|
+
export type Limited = (typeof limited)[number];
|
|
7
|
+
//# sourceMappingURL=authorization-statuses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-statuses.d.ts","sourceRoot":"","sources":["../src/authorization-statuses.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,YACrB,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,YAAY,CACJ,CAAC;AACX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAGrD,eAAO,MAAM,UAAU,YACrB,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,WAAW,CACH,CAAC;AACX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAGrD,eAAO,MAAM,OAAO,YAClB,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,SAAS,CACD,CAAC;AACX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Apple's status values, in the order of their raw values in the SDK headers
|
|
2
|
+
// of macOS 27 (MacOSX27.2.sdk).
|
|
3
|
+
// AVAuthorizationStatus (AVFoundation/AVCaptureDevice.h:2159-2163), and
|
|
4
|
+
// CNAuthorizationStatus (Contacts/CNContactStore.h:35-47) without the
|
|
5
|
+
// iOS-only Limited.
|
|
6
|
+
export const authorized = [
|
|
7
|
+
'notDetermined',
|
|
8
|
+
'restricted',
|
|
9
|
+
'denied',
|
|
10
|
+
'authorized',
|
|
11
|
+
];
|
|
12
|
+
// EKAuthorizationStatus (EventKit/EKTypes.h:27-34).
|
|
13
|
+
export const fullAccess = [
|
|
14
|
+
'notDetermined',
|
|
15
|
+
'restricted',
|
|
16
|
+
'denied',
|
|
17
|
+
'fullAccess',
|
|
18
|
+
'writeOnly',
|
|
19
|
+
];
|
|
20
|
+
// PHAuthorizationStatus (Photos/PHPhotoLibrary.h:21-28).
|
|
21
|
+
export const limited = [
|
|
22
|
+
'notDetermined',
|
|
23
|
+
'restricted',
|
|
24
|
+
'denied',
|
|
25
|
+
'authorized',
|
|
26
|
+
'limited',
|
|
27
|
+
];
|
|
28
|
+
//# sourceMappingURL=authorization-statuses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-statuses.js","sourceRoot":"","sources":["../src/authorization-statuses.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gCAAgC;AAEhC,wEAAwE;AACxE,sEAAsE;AACtE,oBAAoB;AACpB,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,YAAY;CACJ,CAAC;AAGX,oDAAoD;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,WAAW;CACH,CAAC;AAGX,yDAAyD;AACzD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,SAAS;CACD,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Client {
|
|
2
|
+
readonly type: 'bundle' | 'executable';
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
private constructor();
|
|
6
|
+
static responsibleFor(pid: number): Client;
|
|
7
|
+
static bundle(path: string): Client;
|
|
8
|
+
static executable(path: string): Client;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAYA,qBAAa,MAAM;IACjB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,OAAO,eAQN;IAID,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiBzC;IAED,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElC;IAED,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtC;CACF"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
import { nodeFfi } from './native/node-ffi.js';
|
|
3
|
+
// PROC_PIDPATHINFO_MAXSIZE (sys/proc_info.h): four times MAXPATHLEN.
|
|
4
|
+
const pathSize = 4096;
|
|
5
|
+
// The main executable of a bundle; the greedy match takes the innermost
|
|
6
|
+
// bundle, the one whose Contents/MacOS holds the executable.
|
|
7
|
+
const bundled = /^(.*\.app)\/Contents\/MacOS\/[^/]+$/;
|
|
8
|
+
// The program that TCC charges an access to, as the columns client and
|
|
9
|
+
// client_type of TCC.db hold it: an app bundle or an executable.
|
|
10
|
+
export class Client {
|
|
11
|
+
type;
|
|
12
|
+
path;
|
|
13
|
+
// What the user finds in System Settings.
|
|
14
|
+
name;
|
|
15
|
+
constructor(type, path, name) {
|
|
16
|
+
this.type = type;
|
|
17
|
+
this.path = path;
|
|
18
|
+
this.name = name;
|
|
19
|
+
}
|
|
20
|
+
// The client that macOS charges the access of the process pid to: the
|
|
21
|
+
// executable of its responsible process (ADR 0004).
|
|
22
|
+
static responsibleFor(pid) {
|
|
23
|
+
using system = new (nodeFfi().DynamicLibrary)('/usr/lib/libSystem.B.dylib');
|
|
24
|
+
const responsible = system.getFunction('responsibility_get_pid_responsible_for_pid', { arguments: ['int32'], return: 'int32' })(pid);
|
|
25
|
+
const buffer = Buffer.alloc(pathSize);
|
|
26
|
+
const length = system.getFunction('proc_pidpath', {
|
|
27
|
+
arguments: ['int32', 'buffer', 'uint32'],
|
|
28
|
+
return: 'int32',
|
|
29
|
+
})(responsible, buffer, pathSize);
|
|
30
|
+
if (length <= 0)
|
|
31
|
+
throw new RangeError(`No process has the pid ${pid}`);
|
|
32
|
+
const path = buffer.toString('utf8', 0, length);
|
|
33
|
+
const bundle = bundled.exec(path)?.[1];
|
|
34
|
+
return bundle === undefined
|
|
35
|
+
? Client.executable(path)
|
|
36
|
+
: Client.bundle(bundle);
|
|
37
|
+
}
|
|
38
|
+
static bundle(path) {
|
|
39
|
+
return new Client('bundle', path, basename(path, '.app'));
|
|
40
|
+
}
|
|
41
|
+
static executable(path) {
|
|
42
|
+
return new Client('executable', path, path);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,qEAAqE;AACrE,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,wEAAwE;AACxE,6DAA6D;AAC7D,MAAM,OAAO,GAAG,qCAAqC,CAAC;AAEtD,uEAAuE;AACvE,iEAAiE;AACjE,MAAM,OAAO,MAAM;IACR,IAAI,CAA0B;IAC9B,IAAI,CAAS;IACtB,0CAA0C;IACjC,IAAI,CAAS;IAEtB,YACE,IAA6B,EAC7B,IAAY,EACZ,IAAY;QAEZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,sEAAsE;IACtE,oDAAoD;IACpD,MAAM,CAAC,cAAc,CAAC,GAAW;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC,4BAA4B,CAAC,CAAC;QAC5E,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CACpC,4CAA4C,EAC5C,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAC1C,CAAC,GAAG,CAAC,CAAC;QACP,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,cAAc,EAAE;YAChD,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;YACxC,MAAM,EAAE,OAAO;SAChB,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAClC,IAAI,MAAM,IAAI,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;QACvE,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACvC,OAAO,MAAM,KAAK,SAAS;YACzB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;YACzB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,IAAY;QACxB,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,IAAY;QAC5B,OAAO,IAAI,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Client } from './client.ts';
|
|
2
|
+
export { Preflight } from './preflight.ts';
|
|
3
|
+
export { PromptedService } from './prompted-service.ts';
|
|
4
|
+
export { Service } from './service.ts';
|
|
5
|
+
export { Accessibility } from './services/accessibility.ts';
|
|
6
|
+
export { Automation } from './services/automation.ts';
|
|
7
|
+
export { Bluetooth } from './services/bluetooth.ts';
|
|
8
|
+
export { Calendars } from './services/calendars.ts';
|
|
9
|
+
export { Camera } from './services/camera.ts';
|
|
10
|
+
export { Contacts } from './services/contacts.ts';
|
|
11
|
+
export { FullDiskAccess } from './services/full-disk-access.ts';
|
|
12
|
+
export { InputMonitoring } from './services/input-monitoring.ts';
|
|
13
|
+
export { Microphone } from './services/microphone.ts';
|
|
14
|
+
export { Photos } from './services/photos.ts';
|
|
15
|
+
export { PhotosAdd } from './services/photos-add.ts';
|
|
16
|
+
export { Reminders } from './services/reminders.ts';
|
|
17
|
+
export { ScreenRecording } from './services/screen-recording.ts';
|
|
18
|
+
export { SpeechRecognition } from './services/speech-recognition.ts';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Client } from './client.js';
|
|
2
|
+
export { Preflight } from './preflight.js';
|
|
3
|
+
export { PromptedService } from './prompted-service.js';
|
|
4
|
+
export { Service } from './service.js';
|
|
5
|
+
export { Accessibility } from './services/accessibility.js';
|
|
6
|
+
export { Automation } from './services/automation.js';
|
|
7
|
+
export { Bluetooth } from './services/bluetooth.js';
|
|
8
|
+
export { Calendars } from './services/calendars.js';
|
|
9
|
+
export { Camera } from './services/camera.js';
|
|
10
|
+
export { Contacts } from './services/contacts.js';
|
|
11
|
+
export { FullDiskAccess } from './services/full-disk-access.js';
|
|
12
|
+
export { InputMonitoring } from './services/input-monitoring.js';
|
|
13
|
+
export { Microphone } from './services/microphone.js';
|
|
14
|
+
export { Photos } from './services/photos.js';
|
|
15
|
+
export { PhotosAdd } from './services/photos-add.js';
|
|
16
|
+
export { Reminders } from './services/reminders.js';
|
|
17
|
+
export { ScreenRecording } from './services/screen-recording.js';
|
|
18
|
+
export { SpeechRecognition } from './services/speech-recognition.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class JxaRequest {
|
|
2
|
+
readonly source: string;
|
|
3
|
+
private constructor();
|
|
4
|
+
static decided(frameworks: readonly string[], request: string, undecided: string): JxaRequest;
|
|
5
|
+
static direct(frameworks: readonly string[], binding: string, call: string): JxaRequest;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=jxa-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jxa-request.d.ts","sourceRoot":"","sources":["../../src/native/jxa-request.ts"],"names":[],"mappings":"AAGA,qBAAa,UAAU;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,eAEN;IAOD,MAAM,CAAC,OAAO,CACZ,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,UAAU,CAMZ;IAID,MAAM,CAAC,MAAM,CACX,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,UAAU,CAIZ;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// A JXA script that osascript runs to ask macOS for a service. macOS shows the
|
|
2
|
+
// prompt only to a program with the private entitlement
|
|
3
|
+
// com.apple.private.tcc.allow-prompting, which osascript holds (ADR 0007).
|
|
4
|
+
export class JxaRequest {
|
|
5
|
+
source;
|
|
6
|
+
constructor(source) {
|
|
7
|
+
this.source = source;
|
|
8
|
+
}
|
|
9
|
+
// A request of a framework. macOS asks when the request runs, and the run
|
|
10
|
+
// loop turns in 50 ms slices until the status is decided. The completion
|
|
11
|
+
// handler is not waited for: JXA runs it on another thread, where it cannot
|
|
12
|
+
// stop a run loop that JavaScript started, and it does not run at all for
|
|
13
|
+
// some requests (probes of 2026-11-26 on macOS 27.2, ADR 0007).
|
|
14
|
+
static decided(frameworks, request, undecided) {
|
|
15
|
+
return new JxaRequest(`${imports(frameworks)}
|
|
16
|
+
const C = (name) => $.NSClassFromString(name);
|
|
17
|
+
${request}
|
|
18
|
+
while (${undecided})
|
|
19
|
+
$.NSRunLoop.currentRunLoop.runUntilDate($.NSDate.dateWithTimeIntervalSinceNow(0.05));`);
|
|
20
|
+
}
|
|
21
|
+
// A C function that shows the dialog of macOS, or waits for the answer
|
|
22
|
+
// itself, and returns.
|
|
23
|
+
static direct(frameworks, binding, call) {
|
|
24
|
+
return new JxaRequest(`${imports(frameworks)}
|
|
25
|
+
ObjC.bindFunction(${binding});
|
|
26
|
+
${call};`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function imports(frameworks) {
|
|
30
|
+
return ['Foundation', ...frameworks]
|
|
31
|
+
.map((framework) => `ObjC.import(${JSON.stringify(framework)});`)
|
|
32
|
+
.join('\n');
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=jxa-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jxa-request.js","sourceRoot":"","sources":["../../src/native/jxa-request.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wDAAwD;AACxD,2EAA2E;AAC3E,MAAM,OAAO,UAAU;IACZ,MAAM,CAAS;IAExB,YAAoB,MAAc;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,0EAA0E;IAC1E,yEAAyE;IACzE,4EAA4E;IAC5E,0EAA0E;IAC1E,gEAAgE;IAChE,MAAM,CAAC,OAAO,CACZ,UAA6B,EAC7B,OAAe,EACf,SAAiB;QAEjB,OAAO,IAAI,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;;EAE9C,OAAO;SACA,SAAS;wFACsE,CAAC,CAAC;IACxF,CAAC;IAED,uEAAuE;IACvE,uBAAuB;IACvB,MAAM,CAAC,MAAM,CACX,UAA6B,EAC7B,OAAe,EACf,IAAY;QAEZ,OAAO,IAAI,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;oBAC5B,OAAO;EACzB,IAAI,GAAG,CAAC,CAAC;IACT,CAAC;CACF;AAED,SAAS,OAAO,CAAC,UAA6B;IAC5C,OAAO,CAAC,YAAY,EAAE,GAAG,UAAU,CAAC;SACjC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;SAChE,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-ffi.d.ts","sourceRoot":"","sources":["../../src/native/node-ffi.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,IAAI,cAAc,UAAU,CAAC,CAEnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-ffi.js","sourceRoot":"","sources":["../../src/native/node-ffi.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,gFAAgF;AAChF,MAAM,UAAU,OAAO;IACrB,OAAO,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objective-c-class.d.ts","sourceRoot":"","sources":["../../src/native/objective-c-class.ts"],"names":[],"mappings":"AAOA,qBAAa,eAAe;;IAI1B,YAAY,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAG1C;IAGD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBnD;IAID,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYrD;CAmBF"}
|