summaryrefslogtreecommitdiffstats
path: root/extensions/common/api/declarative_web_request.json
blob: f504070bb230c0e46297d3d71fb3c2315eaa9a85 (plain)
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

[
  {
    "namespace": "declarativeWebRequest",
    "description": "<em><strong>Note:</strong> this API is currently on hold, without concrete plans to move to stable.</em> Use the <code>chrome.declarativeWebRequest</code> API to intercept, block, or modify requests in-flight. It is significantly faster than the <a href='webRequest'><code>chrome.webRequest</code> API</a> because you can register rules that are evaluated in the browser rather than the JavaScript engine with reduces roundtrip latencies and allows higher efficiency.",
    "types": [
      {
        "id": "HeaderFilter",
        "type": "object",
        "description": "Filters request headers for various criteria. Multiple criteria are evaluated as a conjunction.",
        "properties": {
          "namePrefix": {
            "description" : "Matches if the header name starts with the specified string.",
            "type": "string",
            "optional": true
          },
          "nameSuffix": {
            "type": "string",
            "optional": true,
            "description" : "Matches if the header name ends with the specified string."
          },
          "nameContains": {
            "choices": [
             {"type": "array", "items": {"type": "string"}},
             {"type": "string"}
            ],
            "optional": true,
            "description" : "Matches if the header name contains all of the specified strings."
          },
          "nameEquals": {
            "type": "string",
            "optional": true,
            "description" : "Matches if the header name is equal to the specified string."
          },
          "valuePrefix": {
            "type": "string",
            "optional": true,
            "description" : "Matches if the header value starts with the specified string."
          },
          "valueSuffix": {
            "type": "string",
            "optional": true,
            "description" : "Matches if the header value ends with the specified string."
          },
          "valueContains": {
            "choices": [
             {"type": "array", "items": {"type": "string"}},
             {"type": "string"}
            ],
            "optional": true,
            "description" : "Matches if the header value contains all of the specified strings."
          },
          "valueEquals": {
            "type": "string",
            "optional": true,
            "description" : "Matches if the header value is equal to the specified string."
          }
        }
      },
      {
        "id": "RequestMatcher",
        "type": "object",
        "description": "Matches network events by various criteria.",
        "properties": {
          "url": {
            "$ref": "events.UrlFilter",
            "description": "Matches if the conditions of the UrlFilter are fulfilled for the URL of the request.",
            "optional": true
          },
          "firstPartyForCookiesUrl": {
            "$ref": "events.UrlFilter",
            "description": "Matches if the conditions of the UrlFilter are fulfilled for the 'first party' URL of the request. The 'first party' URL of a request, when present, can be different from the request's target URL, and describes what is considered 'first party' for the sake of third-party checks for cookies.",
            "optional": true
          },
          "resourceType": {
            "type": "array",
            "optional": true,
            "description": "Matches if the request type of a request is contained in the list. Requests that cannot match any of the types will be filtered out.",
            "items": { "type": "string", "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "other"] }
          },
          "contentType": {
            "type": "array",
            "optional": true,
            "description": "Matches if the MIME media type of a response (from the HTTP Content-Type header) is contained in the list.",
            "items": { "type": "string" }
          },
          "excludeContentType": {
            "type": "array",
            "optional": true,
            "description": "Matches if the MIME media type of a response (from the HTTP Content-Type header) is <em>not</em> contained in the list.",
            "items": { "type": "string" }
          },
          "requestHeaders": {
            "type": "array",
            "optional": true,
            "description": "Matches if some of the request headers is matched by one of the HeaderFilters.",
            "items": { "$ref": "HeaderFilter" }
          },
          "excludeRequestHeaders": {
            "type": "array",
            "optional": true,
            "description": "Matches if none of the request headers is matched by any of the HeaderFilters.",
            "items": { "$ref": "HeaderFilter" }
          },
          "responseHeaders": {
            "type": "array",
            "optional": true,
            "description": "Matches if some of the response headers is matched by one of the HeaderFilters.",
            "items": { "$ref": "HeaderFilter" }
          },
          "excludeResponseHeaders": {
            "type": "array",
            "optional": true,
            "description": "Matches if none of the response headers is matched by any of the HeaderFilters.",
            "items": { "$ref": "HeaderFilter" }
          },
          "thirdPartyForCookies": {
            "type": "boolean",
            "optional": true,
            "description": "If set to true, matches requests that are subject to third-party cookie policies. If set to false, matches all other requests."
          },
          "stages": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["onBeforeRequest", "onBeforeSendHeaders", "onHeadersReceived", "onAuthRequired"]
            },
            "optional": true,
            "description": "Contains a list of strings describing stages. Allowed values are 'onBeforeRequest', 'onBeforeSendHeaders', 'onHeadersReceived', 'onAuthRequired'. If this attribute is present, then it limits the applicable stages to those listed. Note that the whole condition is only applicable in stages compatible with all attributes."
          },
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RequestMatcher"],
            "nodoc": true
          }
        }
      },
      {
        "id": "CancelRequest",
        "description": "Declarative event action that cancels a network request.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.CancelRequest"],
            "nodoc": true
          }
        }
      },
      {
        "id": "RedirectRequest",
        "description": "Declarative event action that redirects a network request.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RedirectRequest"],
            "nodoc": true
          },
          "redirectUrl": { "type": "string", "description": "Destination to where the request is redirected."}
        }
      },
      {
        "id": "declarativeWebRequest.RedirectToTransparentImage",
        "description": "Declarative event action that redirects a network request to a transparent image.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RedirectToTransparentImage"],
            "nodoc": true
          }
        }
      },
      {
        "id": "declarativeWebRequest.RedirectToEmptyDocument",
        "description": "Declarative event action that redirects a network request to an empty document.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RedirectToEmptyDocument"],
            "nodoc": true
          }
        }
      },
      {
        "id": "declarativeWebRequest.RedirectByRegEx",
        "description": "Redirects a request by applying a regular expression on the URL. The regular expressions use the <a href=\"https://github.com/google/re2/blob/master/doc/syntax.txt\">RE2 syntax</a>.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RedirectByRegEx"],
            "nodoc": true
          },
          "from": {
            "type": "string",
            "description": "A match pattern that may contain capture groups. Capture groups are referenced in the Perl syntax ($1, $2, ...) instead of the RE2 syntax (\\1, \\2, ...) in order to be closer to JavaScript Regular Expressions."
          },
          "to": {
            "type": "string",
            "description": "Destination pattern."
          }
        }
      },
      {
        "id": "declarativeWebRequest.SetRequestHeader",
        "description": "Sets the request header of the specified name to the specified value. If a header with the specified name did not exist before, a new one is created. Header name comparison is always case-insensitive. Each request header name occurs only once in each request.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.SetRequestHeader"],
            "nodoc": true
          },
          "name": {
            "type": "string",
            "description": "HTTP request header name."
          },
          "value": {
            "type": "string",
            "description": "HTTP request header value."
          }
        }
      },
      {
        "id": "declarativeWebRequest.RemoveRequestHeader",
        "description": "Removes the request header of the specified name. Do not use SetRequestHeader and RemoveRequestHeader with the same header name on the same request. Each request header name occurs only once in each request.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RemoveRequestHeader"],
            "nodoc": true
          },
          "name": {
            "type": "string",
            "description": "HTTP request header name (case-insensitive)."
          }
        }
      },
      {
        "id": "declarativeWebRequest.AddResponseHeader",
        "description": "Adds the response header to the response of this web request. As multiple response headers may share the same name, you need to first remove and then add a new response header in order to replace one.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.AddResponseHeader"],
            "nodoc": true
          },
          "name": {
            "type": "string",
            "description": "HTTP response header name."
          },
          "value": {
            "type": "string",
            "description": "HTTP response header value."
          }
        }
      },
      {
        "id": "declarativeWebRequest.RemoveResponseHeader",
        "description": "Removes all response headers of the specified names and values.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RemoveResponseHeader"],
            "nodoc": true
          },
          "name": {
            "type": "string",
            "description": "HTTP request header name (case-insensitive)."
          },
          "value": {
            "type": "string",
            "description": "HTTP request header value (case-insensitive).",
            "optional": true
          }
        }
      },
      {
        "id": "declarativeWebRequest.IgnoreRules",
        "description": "Masks all rules that match the specified criteria.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.IgnoreRules"],
            "nodoc": true
          },
          "lowerPriorityThan": {
            "type": "integer",
            "description": "If set, rules with a lower priority than the specified value are ignored. This boundary is not persisted, it affects only rules and their actions of the same network request stage.",
            "optional": true
          },
          "hasTag": {
            "type": "string",
            "description": "If set, rules with the specified tag are ignored. This ignoring is not persisted, it affects only rules and their actions of the same network request stage. Note that rules are executed in descending order of their priorities. This action affects rules of lower priority than the current rule. Rules with the same priority may or may not be ignored.",
            "optional": true
          }
        }
      },
      {
        "id": "declarativeWebRequest.SendMessageToExtension",
        "description": "Triggers the $(ref:declarativeWebRequest.onMessage) event.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.SendMessageToExtension"],
            "nodoc": true
          },
          "message": {
            "type": "string",
            "description": "The value that will be passed in the <code>message</code> attribute of the dictionary that is passed to the event handler."
          }
        }
      },
      {
        "id": "declarativeWebRequest.RequestCookie",
        "description": "A filter or specification of a cookie in HTTP Requests.",
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of a cookie.",
            "optional": true
          },
          "value": {
            "type": "string",
            "description": "Value of a cookie, may be padded in double-quotes.",
            "optional": true
          }
        }
      },
      {
        "id": "declarativeWebRequest.ResponseCookie",
        "description": "A specification of a cookie in HTTP Responses.",
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of a cookie.",
            "optional": true
          },
          "value": {
            "type": "string",
            "description": "Value of a cookie, may be padded in double-quotes.",
            "optional": true
          },
          "expires": {
            "type": "string",
            "description": "Value of the Expires cookie attribute.",
            "optional": true
          },
          "maxAge": {
            "type": "number",
            "description": "Value of the Max-Age cookie attribute",
            "optional": true
          },
          "domain": {
            "type": "string",
            "description": "Value of the Domain cookie attribute.",
            "optional": true
          },
          "path": {
            "type": "string",
            "description": "Value of the Path cookie attribute.",
            "optional": true
          },
          "secure": {
            "type": "string",
            "description": "Existence of the Secure cookie attribute.",
            "optional": true
          },
          "httpOnly": {
            "type": "string",
            "description": "Existence of the HttpOnly cookie attribute.",
            "optional": true
          }
        }
      },
      {
        "id": "declarativeWebRequest.FilterResponseCookie",
        "description": "A filter of a cookie in HTTP Responses.",
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of a cookie.",
            "optional": true
          },
          "value": {
            "type": "string",
            "description": "Value of a cookie, may be padded in double-quotes.",
            "optional": true
          },
          "expires": {
            "type": "string",
            "description": "Value of the Expires cookie attribute.",
            "optional": true
          },
          "maxAge": {
            "type": "number",
            "description": "Value of the Max-Age cookie attribute",
            "optional": true
          },
          "domain": {
            "type": "string",
            "description": "Value of the Domain cookie attribute.",
            "optional": true
          },
          "path": {
            "type": "string",
            "description": "Value of the Path cookie attribute.",
            "optional": true
          },
          "secure": {
            "type": "string",
            "description": "Existence of the Secure cookie attribute.",
            "optional": true
          },
          "httpOnly": {
            "type": "string",
            "description": "Existence of the HttpOnly cookie attribute.",
            "optional": true
          },
          "ageUpperBound": {
            "type": "integer",
            "description": "Inclusive upper bound on the cookie lifetime (specified in seconds after current time). Only cookies whose expiration date-time is in the interval [now, now + ageUpperBound] fulfill this criterion. Session cookies and cookies whose expiration date-time is in the past do not meet the criterion of this filter. The cookie lifetime is calculated from either 'max-age' or 'expires' cookie attributes. If both are specified, 'max-age' is used to calculate the cookie lifetime.",
            "minimum": 0,
            "optional": true
          },
          "ageLowerBound": {
            "type": "integer",
            "description": "Inclusive lower bound on the cookie lifetime (specified in seconds after current time). Only cookies whose expiration date-time is set to 'now + ageLowerBound' or later fulfill this criterion. Session cookies do not meet the criterion of this filter. The cookie lifetime is calculated from either 'max-age' or 'expires' cookie attributes. If both are specified, 'max-age' is used to calculate the cookie lifetime.",
            "minimum": 0,
            "optional": true
          },
          "sessionCookie": {
            "type": "boolean",
            "description": "Filters session cookies. Session cookies have no lifetime specified in any of 'max-age' or 'expires' attributes.",
            "optional": true
          }
        }
      },
      {
        "id": "declarativeWebRequest.AddRequestCookie",
        "description": "Adds a cookie to the request or overrides a cookie, in case another cookie of the same name exists already. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.AddRequestCookie"],
            "nodoc": true
          },
          "cookie": {
            "$ref": "declarativeWebRequest.RequestCookie",
            "description": "Cookie to be added to the request. No field may be undefined."
          }
        }
      },
      {
        "id": "declarativeWebRequest.AddResponseCookie",
        "description": "Adds a cookie to the response or overrides a cookie, in case another cookie of the same name exists already. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.AddResponseCookie"],
            "nodoc": true
          },
          "cookie": {
            "$ref": "declarativeWebRequest.ResponseCookie",
            "description": "Cookie to be added to the response. The name and value need to be specified."
          }
        }
      },
      {
        "id": "declarativeWebRequest.EditRequestCookie",
        "description": "Edits one or more cookies of request. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.EditRequestCookie"],
            "nodoc": true
          },
          "filter": {
            "$ref": "declarativeWebRequest.RequestCookie",
            "description": "Filter for cookies that will be modified. All empty entries are ignored."
          },
          "modification": {
            "$ref": "declarativeWebRequest.RequestCookie",
            "description": "Attributes that shall be overridden in cookies that machted the filter. Attributes that are set to an empty string are removed."
          }
        }
      },
      {
        "id": "declarativeWebRequest.EditResponseCookie",
        "description": "Edits one or more cookies of response. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.EditResponseCookie"],
            "nodoc": true
          },
          "filter": {
            "$ref": "declarativeWebRequest.FilterResponseCookie",
            "description": "Filter for cookies that will be modified. All empty entries are ignored."
          },
          "modification": {
            "$ref": "declarativeWebRequest.ResponseCookie",
            "description": "Attributes that shall be overridden in cookies that machted the filter. Attributes that are set to an empty string are removed."
          }
        }
      },
      {
        "id": "declarativeWebRequest.RemoveRequestCookie",
        "description": "Removes one or more cookies of request. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RemoveRequestCookie"],
            "nodoc": true
          },
          "filter": {
            "$ref": "declarativeWebRequest.RequestCookie",
            "description": "Filter for cookies that will be removed. All empty entries are ignored."
          }
        }
      },
      {
        "id": "declarativeWebRequest.RemoveResponseCookie",
        "description": "Removes one or more cookies of response. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
        "type": "object",
        "properties": {
          "instanceType": {
            "type": "string", "enum": ["declarativeWebRequest.RemoveResponseCookie"],
            "nodoc": true
          },
          "filter": {
            "$ref": "declarativeWebRequest.FilterResponseCookie",
            "description": "Filter for cookies that will be removed. All empty entries are ignored."
          }
        }
      }
    ],
    "functions": [
    ],
    "events": [
      {
        "name": "onRequest",
        "options": {
          "supportsListeners": false,
          "supportsRules": true,
          "conditions": ["declarativeWebRequest.RequestMatcher"],
          "actions": [
            "declarativeWebRequest.AddRequestCookie",
            "declarativeWebRequest.AddResponseCookie",
            "declarativeWebRequest.AddResponseHeader",
            "declarativeWebRequest.CancelRequest",
            "declarativeWebRequest.EditRequestCookie",
            "declarativeWebRequest.EditResponseCookie",
            "declarativeWebRequest.RedirectRequest",
            "declarativeWebRequest.RedirectToTransparentImage",
            "declarativeWebRequest.RedirectToEmptyDocument",
            "declarativeWebRequest.RedirectByRegEx",
            "declarativeWebRequest.RemoveRequestCookie",
            "declarativeWebRequest.RemoveResponseCookie",
            "declarativeWebRequest.RemoveRequestHeader",
            "declarativeWebRequest.RemoveResponseHeader",
            "declarativeWebRequest.SetRequestHeader",
            "declarativeWebRequest.SendMessageToExtension",
            "declarativeWebRequest.IgnoreRules"
          ]
        }
      },
      {
        "name": "onMessage",
        "type": "function",
        "description": "Fired when a message is sent via $(ref:declarativeWebRequest.SendMessageToExtension) from an action of the declarative web request API.",
        "parameters": [
          {
            "type": "object",
            "name": "details",
            "properties": {
              "message": {"type": "string", "description": "The message sent by the calling script."},
              "stage": {"type": "string",
                        "enum": ["onBeforeRequest", "onBeforeSendHeaders", "onHeadersReceived", "onAuthRequired"],
                        "description": "The stage of the network request during which the event was triggered."},
              "requestId": {"type": "string", "description": "The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request."},
              "url": {"type": "string"},
              "method": {"type": "string", "description": "Standard HTTP method."},
              "frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
              "parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
              "tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
              "type": {"type": "string", "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", "other"], "description": "How the requested resource will be used."},
              "timeStamp": {"type": "number", "description": "The time when this signal is triggered, in milliseconds since the epoch."}
            }
          }
        ]
      }
    ]
  }
]