File: nsIClearDataService.idl

package info (click to toggle)
firefox 142.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,591,884 kB
  • sloc: cpp: 7,451,570; javascript: 6,392,463; ansic: 3,712,584; python: 1,388,569; xml: 629,223; asm: 426,919; java: 184,857; sh: 63,439; makefile: 19,150; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,352; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (432 lines) | stat: -rw-r--r-- 15,952 bytes parent folder | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIPrincipal;
interface nsIClearDataCallback;

/**
 * nsIClearDataService
 *
 * Provides methods for cleaning data from a nsIPrincipal and/or from a time
 * range.
 */
[scriptable, uuid(6ef3ef16-a502-4576-9fb4-919f1c40bf61)]
interface nsIClearDataService : nsISupports
{
  /**
   * Delete data owned by local files or other hostless schemes.
   * @param aIsUserRequest true if this request comes from a user interaction.
   *        This information is important because if true, it's probably better
   *        to remove more than less, for privacy reason. If false (e.g.
   *        Clear-Site-Data header), we don't want to delete more than what is
   *        strictly required.
   * @param aFlags List of flags. See below the accepted values.
                   Note that not all flags will make sense (e.g. we can't clear
                   certificates for local files). Nonsensical flags will be
                   ignored.
   * @param aCallback this callback will be executed when the operation is
   *                  completed.
   */
  void deleteDataFromLocalFiles(in boolean aIsUserRequest,
                                in uint32_t aFlags,
                                in nsIClearDataCallback aCallback);

  /**
   * Delete data owned by a host. For instance: mozilla.org. Data from any
   * possible originAttributes will be deleted.
   * @param aHost the host to be used.
   * @param aIsUserRequest true if this request comes from a user interaction.
   *        This information is important because if true, it's probably better
   *        to remove more than less, for privacy reason. If false (e.g.
   *        Clear-Site-Data header), we don't want to delete more than what is
   *        strictly required.
   * @param aFlags List of flags. See below the accepted values.
   * @param aCallback this callback will be executed when the operation is
   *                  completed.
   * @deprecated Use deleteDataFromSite instead.
   */
  void deleteDataFromHost(in AUTF8String aHost,
                          in boolean aIsUserRequest,
                          in uint32_t aFlags,
                          in nsIClearDataCallback aCallback);

  /**
   * Delete data from cookie jars associated with the given schemeless site
   * aSchemelessSite.
   * In addition to regular first-party data this includes data of aSchemelessSite in a
   * third-party context and data from other sites partitioned under aSchemelessSite.
   * You can use Services.eTLD.getSchemelessSite to extract the site portion of a URI.
   * See https://html.spec.whatwg.org/#obtain-a-site for details.
   * If you have an nsIPrincipal object you can simply pass in
   * principal.baseDomain.
   * When handling user requests for clearing data using this method is
   * preferred over deleteDataFromPrincipal, since origins may share information
   * with their site (e.g. cookies) that are not deleted by principal.
   * @param aSchemelessSite the site to be cleared excluding scheme.
   * @param aOriginAttributesPatternString optional pattern to filter OriginAttributes
   *        by. If not passed all entries matching aSchemelessSite are cleared.
   * @param aIsUserRequest true if this request comes from a user interaction.
   *        This information is important because if true, it's probably better
   *        to remove more than less, for privacy reason. If false (e.g.
   *        Clear-Site-Data header), we don't want to delete more than what is
   *        strictly required.
   * @param aFlags List of flags. See below the accepted values.
   * @param aCallback this callback will be executed when the operation is
   *                  completed.
   */
  void deleteDataFromSite(in AUTF8String aSchemelessSite,
                                in jsval aOriginAttributesPattern,
                                in boolean aIsUserRequest,
                                in uint32_t aFlags,
                                in nsIClearDataCallback aCallback);

  /**
   * Variant of deleteDataFromSite that accepts a JSON string for the OriginAttributesPattern.
   * This is helpful for native callers because they don't have to construct a jsval.
   * From JS prefer calling deleteDataFromSite directly.
   */
  void deleteDataFromSiteAndOriginAttributesPatternString(in AUTF8String aSchemelessSite,
                              in AString aOriginAttributesPatternString,
                              in boolean aIsUserRequest,
                              in uint32_t aFlags,
                              in nsIClearDataCallback aCallback);

  /**
   * Delete data owned by a principal.
   * @param aPrincipal the nsIPrincipal to be used.
   * @param aIsUserRequest true if this request comes from a user interaction.
   *        This information is important because if true, it's probably better
   *        to remove more than less, for privacy reason. If false (e.g.
   *        Clear-Site-Data header), we don't want to delete more than what is
   *        strictly required.
   * @param aFlags List of flags. See below the accepted values.
   * @param aCallback ths callback will be executed when the operation is
   *                  completed.
   */
  void deleteDataFromPrincipal(in nsIPrincipal aPrincipal,
                               in boolean aIsUserRequest,
                               in uint32_t aFlags,
                               in nsIClearDataCallback aCallback);

  /**
   * Delete all data in a time range. Limit excluded.
   * @param aFrom microseconds from the epoch
   * @param aTo microseconds from the epoch
   * @param aIsUserRequest true if this request comes from a user interaction.
   *        This information is important because if true, it's probably better
   *        to remove more than less, for privacy reason. If false (e.g.
   *        Clear-Site-Data header), we don't want to delete more than what is
   *        strictly required.
   * @param aFlags List of flags. See below the accepted values.
   * @param aCallback ths callback will be executed when the operation is
   *                  completed.
   */
  void deleteDataInTimeRange(in PRTime aFrom, in PRTime aTo,
                             in boolean aIsUserRequest,
                             in uint32_t aFlags,
                             in nsIClearDataCallback aCallback);

  /**
   * Delete all data from any host, in any time range.
   * @param aFlags List of flags. See below the accepted values.
   * @param aCallback ths callback will be executed when the operation is
   *                  completed.
   */
  void deleteData(in uint32_t aFlags,
                  in nsIClearDataCallback aCallback);

  /**
   * Delete all data from an OriginAttributesPatternDictionary.
   * @param aOriginAttributesPattern the originAttributes dictionary.
   * @param aCallback the optional callback will be executed when the operation
   *                  is completed.
   */
  void deleteDataFromOriginAttributesPattern(in jsval aOriginAttributesPattern,
                                             [optional] in nsIClearDataCallback aCallback);

  /**
   * This is a helper function to clear storageAccessAPI permissions
   * in a way that will not result in users getting logged out by
   * cookie purging. To that end we only clear permissions for principals
   * whose base domain does not have any storage associated with it.
   *
   * The principals to be considered will need to be passed by the API consumer.
   * It is recommended to use PrincipalsCollector.sys.mjs for that.
   *
   * @param aPrincipalsWithStorage principals to be excluded from clearing
   * @param aFrom microseconds from the epoch
   * @param aCallback the optional callback will be executed when the operation
   *                  is completed.
   */
  void deleteUserInteractionForClearingHistory(in Array<nsIPrincipal> aPrincipalsWithStorage,
                                               [optional] in PRTime aFrom,
                                               [optional] in nsIClearDataCallback aCallback);

  /**
   * Some cleaners, namely QuotaCleaner, can opt in and treat things as deleted
   * without actually removing files at shutdown. This function will trigger
   * actual removal of them.
   */
  void cleanupAfterDeletionAtShutdown(in uint32_t aFlags, in nsIClearDataCallback aCallback);

  /**
   * Match a host and OriginAttributes against a schemeless site and
   * OriginAttributesPattern.
   * Also considers partitioned state by inspecting OriginAttributes
   * partitionKey.
   * This is a helper method for external callers that need to do
   * filtering for data clearing.
   */
  boolean hostMatchesSite(in AUTF8String aHost, in jsval aOriginAttributes, in AUTF8String aSchemelessSite, [optional] in jsval aOriginAttributesPattern);


  /**************************************************************************
   * Listed below are the various flags which may be or'd together.
   */

  /**
   * Delete cookies.
   */
  const uint32_t CLEAR_COOKIES = 1 << 0;

  /**
   * Network Cache.
   */
  const uint32_t CLEAR_NETWORK_CACHE = 1 << 1;

  /**
   * Clear bfcache.
   * FIXME: We are out of bits in this bitflag. To mitigate this we will merge
   *        CLEAR_ALL_CACHES into a single bit Bug 1918722. Reuse the
   *        CLEAR_NETWORK_CACHE bit for now with similar effect.
   */
  const uint32_t CLEAR_BFCACHE = 1 << 1;

  /**
   * Image cache.
   */
  const uint32_t CLEAR_IMAGE_CACHE = 1 << 2;

  /**
   * In-memory JS cache.
   */
  const uint32_t CLEAR_JS_CACHE = 1 << 3;

  /**
   * Completed downloads.
   */
  const uint32_t CLEAR_DOWNLOADS = 1 << 4;

  // Free bit here.

  /**
   * Media devices.
   */
  const uint32_t CLEAR_MEDIA_DEVICES = 1 << 6;

  /**
   * LocalStorage, IndexedDB, ServiceWorkers, DOM Cache and so on.
   */
  const uint32_t CLEAR_DOM_QUOTA = 1 << 7;

  /**
   * Predictor network data
   */
  const uint32_t CLEAR_PREDICTOR_NETWORK_DATA = 1 << 8;

  /**
   * DOM Push notifications
   */
  const uint32_t CLEAR_DOM_PUSH_NOTIFICATIONS = 1 << 9;

  /**
   * Places history
   */
  const uint32_t CLEAR_HISTORY = 1 << 10;

  /**
   * Messaging Layer Security state
   */
  const uint32_t CLEAR_MESSAGING_LAYER_SECURITY_STATE = 1 << 11;

  /**
   * Auth tokens
   */
  const uint32_t CLEAR_AUTH_TOKENS = 1 << 12;

  /**
   * Login cache
   */
  const uint32_t CLEAR_AUTH_CACHE = 1 << 13;

  /**
   * Clear Site permissions. Excludes permissions which are used as shutdown data clearing exceptions.
   */
  const uint32_t CLEAR_SITE_PERMISSIONS = 1 << 14;

  /**
   * Site preferences
   */
  const uint32_t CLEAR_CONTENT_PREFERENCES = 1 << 15;

  /**
   * Clear HSTS data
   */
    const uint32_t CLEAR_HSTS = 1 << 16;

  /**
   * Media plugin data
   */
  const uint32_t CLEAR_EME = 1 << 17;

  /**
   * Reporting API reports.
   */
  const uint32_t CLEAR_REPORTS = 1 << 18;

  /**
   * StorageAccessAPI flag, which indicates user interaction.
   */
  const uint32_t CLEAR_STORAGE_ACCESS = 1 << 19;

  /**
   * Clear Cert Exceptions.
   */
  const uint32_t CLEAR_CERT_EXCEPTIONS = 1 << 20;

  /**
   * Clear entries in the content blocking database.
   */
  const uint32_t CLEAR_CONTENT_BLOCKING_RECORDS = 1 << 21;

  /**
   * Clear the in-memory CSS cache.
   */
  const uint32_t CLEAR_CSS_CACHE = 1 << 22;

  /**
   * Clear the CORS preflight cache.
   */
  const uint32_t CLEAR_PREFLIGHT_CACHE = 1 << 23;

  /**
   * Forget descision about clients authentification certificate
   */
  const uint32_t CLEAR_CLIENT_AUTH_REMEMBER_SERVICE = 1 << 24;

  /**
   * Clear state associated with FedCM
   */
  const uint32_t CLEAR_CREDENTIAL_MANAGER_STATE = 1 << 25;

  /**
   * Clear the per-site exception for cookie banner handling.
   */
  const uint32_t CLEAR_COOKIE_BANNER_EXCEPTION = 1 << 26;

  /**
   * Clear the site executed record for cookie banner handling.
   */
  const uint32_t CLEAR_COOKIE_BANNER_EXECUTED_RECORD = 1 << 27;

  /**
   * Clear state associated with the fingerprinting protection.
   */
  const uint32_t CLEAR_FINGERPRINTING_PROTECTION_STATE = 1 << 28;

  /**
   * Clear the bounce tracking protection state.
   */
  const uint32_t CLEAR_BOUNCE_TRACKING_PROTECTION_STATE = 1 << 29;

  /**
   * Clear permissions of type "persistent-storage" and "storage-access"
   */
  const uint32_t CLEAR_STORAGE_PERMISSIONS = 1 << 30;

  /**
   * Clear permissions of type "cookie" used for manual cookie rules and shutdown exceptions
   *
   * TODO: Bug 1767271: move clear-on-shutdown exceptions to its own permission type and switch this cleaner over to clear the new permission type, not the "cookie" permissions.
   */
  const uint32_t CLEAR_SHUTDOWN_EXCEPTIONS = 1 << 31;

  /**
   * Use this value to delete all the data.
   */
  const uint32_t CLEAR_ALL = 0xFFFFFFFF;

  /**************************************************************************
   * The following flags are helpers: they combine some of the previous flags
   * in a more convenient way.
   */

  /**
   * Helper flag for clearing ALL permissions from the permission manager.
   */
  const uint32_t CLEAR_PERMISSIONS = CLEAR_SITE_PERMISSIONS | CLEAR_SHUTDOWN_EXCEPTIONS;

  /**
   * Delete all the possible caches.
   */
  const uint32_t CLEAR_ALL_CACHES = CLEAR_NETWORK_CACHE | CLEAR_IMAGE_CACHE |
    CLEAR_JS_CACHE | CLEAR_CSS_CACHE | CLEAR_PREFLIGHT_CACHE | CLEAR_HSTS | CLEAR_BFCACHE;

  /**
   * Delete all DOM storages
   */
  const uint32_t CLEAR_DOM_STORAGES = CLEAR_DOM_QUOTA | CLEAR_DOM_PUSH_NOTIFICATIONS | CLEAR_REPORTS;

  /**
   * Helper flag for forget about site
   */
  const uint32_t CLEAR_FORGET_ABOUT_SITE =
    CLEAR_HISTORY | CLEAR_ALL_CACHES |
    CLEAR_COOKIES | CLEAR_EME | CLEAR_DOWNLOADS |
    CLEAR_PERMISSIONS | CLEAR_DOM_STORAGES | CLEAR_CONTENT_PREFERENCES |
    CLEAR_PREDICTOR_NETWORK_DATA | CLEAR_DOM_PUSH_NOTIFICATIONS |
    CLEAR_CLIENT_AUTH_REMEMBER_SERVICE | CLEAR_REPORTS | CLEAR_CERT_EXCEPTIONS |
    CLEAR_CREDENTIAL_MANAGER_STATE | CLEAR_COOKIE_BANNER_EXCEPTION |
    CLEAR_COOKIE_BANNER_EXECUTED_RECORD | CLEAR_FINGERPRINTING_PROTECTION_STATE |
    CLEAR_BOUNCE_TRACKING_PROTECTION_STATE | CLEAR_MESSAGING_LAYER_SECURITY_STATE;

  /**
   * Helper flag for clearing cookies and site data.
   * This flag groups state that we consider site data
   * from the user perspective. If you implement UI that
   * offers site data clearing this is almost always what you want.
   * If you need more granular control please use more specific
   * flags like CLEAR_COOKIES and CLEAR_DOM_STORAGES.
   * This flag does not clear caches.
   */
  const uint32_t CLEAR_COOKIES_AND_SITE_DATA =
    CLEAR_COOKIES | CLEAR_COOKIE_BANNER_EXECUTED_RECORD | CLEAR_DOM_STORAGES | CLEAR_HSTS |
    CLEAR_EME | CLEAR_AUTH_TOKENS | CLEAR_AUTH_CACHE | CLEAR_FINGERPRINTING_PROTECTION_STATE |
    CLEAR_BOUNCE_TRACKING_PROTECTION_STATE | CLEAR_STORAGE_PERMISSIONS | CLEAR_MESSAGING_LAYER_SECURITY_STATE;

  /**
  * Helper flag for tracker purging
  */
  const uint32_t CLEAR_STATE_FOR_TRACKER_PURGING =
    CLEAR_ALL_CACHES |  CLEAR_COOKIES_AND_SITE_DATA | CLEAR_CLIENT_AUTH_REMEMBER_SERVICE | CLEAR_MEDIA_DEVICES | CLEAR_STORAGE_ACCESS;

};

/**
 * This is a companion interface for
 * nsIClearDataService::deleteDataFromPrincipal().
 */
[function, scriptable, uuid(e225517b-24c5-498a-b9fb-9993e341a398)]
interface nsIClearDataCallback : nsISupports
{
  /**
   * Called to indicate that the data cleaning is completed.
   * @param aFailedFlags this value contains the flags that failed during the
   *                     cleanup. If nothing failed, aFailedFlags will be 0.
   */
  void onDataDeleted(in uint32_t aFailedFlags);
};