-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdump-possible-permissions.js
62 lines (49 loc) · 1.7 KB
/
dump-possible-permissions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
dump-possible-permissions.js
Get all the permissions mentioned in WFActions.plist and save them to permissions.json.
All preexisting values in permissions.json are preserved, so permissions.json can be filled in manually.
Supports macOS, iOS (direct filesystem access), and iSH on iOS.
*/
const bplist = require('bplist-parser')
const { writeFileSync } = require('fs')
const permissionsJSONPath = './permissions.json'
let perms = []
function pushOrNot(perm) {
if (!perms.includes(perm)) {
perms.push(perm)
}
}
(async () => {
const actionsDict = await bplist.parseFile(require('./get-wfactions-path.js'))[0]
for (const actionID in actionsDict) {
const resources = actionDict[actionID].RequiredResources;
if (resources) {
for (const resource of resources) {
if (typeof resource == "string") {
pushOrNot(resource);
} else {
if (resource.WFAccountClass) {
pushOrNot(resource.WFAccountClass)
} else {
pushOrNot(resource.WFResourceClass)
}
}
}
}
}
for (const perm of ["Apple TV Remote", "FaceTime", "Phone", "Run JavaScript", "Settings"]) {
perms.push(perm)
}
perms.sort();
const permsJSON = require(permissionsJSONPath)
for (const p of perms) {
if (permsJSON[p] === undefined) {
permsJSON[p] = {
icon: "",
description: ""
}
console.log(`Permission '${p}' has no description`)
}
}
writeFileSync(permissionsJSONPath, JSON.stringify(permsJSON, null, 4))
})()