Skip to content

Commit a55d96d

Browse files
Add initial_permissions proposal
1 parent 892ba8c commit a55d96d

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Proposal: `initial_permissions` and `initial_host_permissions`
2+
3+
**Summary**
4+
5+
`initial_permissions` and `initial_host_permissions` will allow extension
6+
authors to declare the permissions browsers may prompt extension users
7+
at initial installation time.
8+
9+
**Document Metadata**
10+
11+
**Author:** Carlos Jeurissen
12+
13+
**Sponsoring Browser:** TBD
14+
15+
**Created:** 2025-10-05
16+
17+
**Related Issues:** https://github.com/w3c/webextensions/issues/711, https://github.com/w3c/webextensions/issues/116, https://github.com/w3c/webextensions/issues/700, https://github.com/w3c/webextensions/issues/227
18+
19+
## Motivation
20+
21+
### Objective
22+
23+
`initial_permissions` and `initial_host_permissions` will allow extension
24+
authors to declare the permissions browsers may prompt extension users
25+
at initial installation time.
26+
27+
Existing options like `permissions` and `host_permissions` cause issues
28+
when introducing new permissions to users on update-time.
29+
30+
#### Use Cases
31+
32+
1) Make it easier for extension authors to introduce new permissions. This will
33+
also reduce the amount of extension authors attempting to future-proof their
34+
extension with permissions they do not need yet.
35+
36+
2) Be more semantic. The purpose of `permissions` is ambiguous, which
37+
`initial_permissions` intends to solve.
38+
39+
3) Suppress automatically hoisting of `host_permissions` when declaring
40+
`content_scripts` in the manifest. This reduces the need for registering
41+
content scripts dynamically with all potential bugs associated.
42+
43+
### Known Consumers
44+
45+
1) Any extension author wanting to be more cautious and intentional with their
46+
permission declarations.
47+
48+
2) Extension authors introducing new (host) permissions in updates.
49+
50+
3) Extension developers which want to offer certain content scripts by default
51+
but not request all host permissions on initial installation.
52+
53+
## Specification
54+
55+
### Schema
56+
57+
```ts
58+
interface Manifest {
59+
initial_permissions: string[];
60+
initial_host_permissions: string[];
61+
}
62+
```
63+
64+
### Behavior
65+
66+
`initial_permissions` will take over the permission prompt on initial
67+
installation of the existing `permissions` field. In supported browsers,
68+
permissions in `permissions` should be treated as `optional_permissions`
69+
unless they are specified in `initial_permissions`.
70+
71+
Same goes for `initial_host_permissions` and `optional_host_permissions`.
72+
73+
If `initial_host_permissions` is specified in the manifest as empty or non-empty
74+
array of permissions, any `host_permissions` triggered by the `matches`
75+
properties should be treated as `optional_host_permissions` instead of
76+
`host_permissions`.
77+
78+
If new permissions will be added in an update to `initial_permissions`, these
79+
new permissions will be treated as `optional_permissions` for existing users.
80+
81+
### New Permissions
82+
83+
None
84+
85+
## Security and Privacy
86+
87+
### Exposed Sensitive Data
88+
89+
None
90+
91+
### Abuse Mitigations
92+
93+
Reduced abuse risk as extension users may get confused with current
94+
permission update behaviors in existing browsers.
95+
96+
### Additional Security Considerations
97+
98+
None
99+
100+
## Alternatives
101+
102+
### Existing Workarounds
103+
104+
1) Using `optional_permissions` for all new permissions. However this makes the
105+
onboarding experience confusing and not as smooth as it could be.
106+
107+
2) Using `chrome.scripting.registerContentScripts()`. This is dynamic instead of
108+
declarative with the risk of registration and background scripting lifetime bugs.
109+
110+
### Open Web API
111+
112+
This is a concept specific to browser extensions.
113+
114+
## Implementation Notes
115+
116+
An empty permissions declaration of `initial_host_permissions` would be valid
117+
as it would suppress the hoisting of `content_scripts` permissions.
118+
119+
## Future Work
120+
121+
1) Always disable the automatic hoisting of `content_scripts`. This may need a
122+
manifest update.
123+
124+
2) Either remove the non descriptive `permissions` and `host_permissions` OR
125+
remove `optional_permissions` and `optional_host_permissions` and always treat
126+
the permissions declared in `permissions` and `host_permissions` as optional.

0 commit comments

Comments
 (0)