Skip to content

Commit 54a2c71

Browse files
committed
feat: add support for Firefox data collection permissions
1 parent 78f8434 commit 54a2c71

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

packages/wxt/src/core/utils/manifest.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ export async function generateManifest(
118118
? undefined
119119
: versionName;
120120

121+
// Warn if building for Firefox without data_collection_permissions
122+
if (
123+
wxt.config.browser === 'firefox' &&
124+
!userManifest.browser_specific_settings?.gecko?.data_collection_permissions
125+
) {
126+
wxt.logger.warn(
127+
'Firefox requires explicit data collection permissions. Consider adding `data_collection_permissions` to your manifest config.\n' +
128+
'For more details, see: https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/#specifying-data-types\n',
129+
);
130+
}
131+
121132
addEntrypoints(manifest, entrypoints, buildOutput);
122133

123134
if (wxt.config.command === 'serve') addDevModeCsp(manifest);

packages/wxt/src/types.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,38 @@ export type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
844844
: T[key];
845845
} & { [key in TOmitted]: T[key] };
846846

847+
/**
848+
* Firefox data collection permission types for personal data.
849+
* See: https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/#specifying-data-types
850+
*/
851+
export type FirefoxDataCollectionType =
852+
| 'locationInfo'
853+
| 'browsingActivity'
854+
| 'websiteContent'
855+
| 'websiteActivity'
856+
| 'searchTerms'
857+
| 'bookmarksInfo'
858+
| 'healthInfo'
859+
| 'contactInfo'
860+
| 'socialInfo';
861+
862+
/**
863+
* Firefox data collection permissions configuration.
864+
* See: https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/#specifying-data-types
865+
*/
866+
export interface FirefoxDataCollectionPermissions {
867+
/**
868+
* Required data collection permissions. Users must opt in to use the extension.
869+
* Can include personal data types or "none" to explicitly indicate no data collection.
870+
*/
871+
required?: Array<FirefoxDataCollectionType | 'none'>;
872+
/**
873+
* Optional data collection permissions. Users can opt in after installation.
874+
* Can include personal data types or "technicalAndInteraction" (which can only be optional).
875+
*/
876+
optional?: Array<FirefoxDataCollectionType | 'technicalAndInteraction'>;
877+
}
878+
847879
/**
848880
* Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
849881
* here, they are configured inline.
@@ -879,6 +911,11 @@ export type UserManifest = {
879911
strict_min_version?: string;
880912
strict_max_version?: string;
881913
update_url?: string;
914+
/**
915+
* Firefox data collection permissions configuration.
916+
* See: https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/#specifying-data-types
917+
*/
918+
data_collection_permissions?: FirefoxDataCollectionPermissions;
882919
};
883920
gecko_android?: {
884921
strict_min_version?: string;

0 commit comments

Comments
 (0)