@wxt-dev/browser 0.0.324 → 0.0.326

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/gen/index.d.ts +674 -194
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wxt-dev/browser",
3
3
  "description": "Provides a cross-browser API for using extension APIs and types based on @types/chrome",
4
- "version": "0.0.324",
4
+ "version": "0.0.326",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
7
7
  "types": "src/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "src"
20
20
  ],
21
21
  "devDependencies": {
22
- "@types/chrome": "0.0.324",
22
+ "@types/chrome": "0.0.326",
23
23
  "fs-extra": "^11.3.0",
24
24
  "nano-spawn": "^0.2.0",
25
25
  "tsx": "4.19.4",
@@ -6,6 +6,7 @@
6
6
 
7
7
  // Helpers
8
8
  type SetRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
9
+ type SetPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
9
10
 
10
11
  ////////////////////
11
12
  // Global object
@@ -1385,6 +1386,246 @@ export namespace Browser {
1385
1386
  export function removeIndexedDB(options: RemovalOptions, callback: () => void): void;
1386
1387
  }
1387
1388
 
1389
+ ////////////////////
1390
+ // Certificate Provider
1391
+ ////////////////////
1392
+ /**
1393
+ * Use this API to expose certificates to the platform which can use these certificates for TLS authentications.
1394
+ *
1395
+ * Manifest: "certificateProvider"
1396
+ * @platform ChromeOS only
1397
+ * @since Chrome 46
1398
+ */
1399
+ export namespace certificateProvider {
1400
+ /** Types of supported cryptographic signature algorithms. */
1401
+ export enum Algorithm {
1402
+ /**
1403
+ * Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the MD5-SHA-1 hashing. The extension must not prepend a DigestInfo prefix but only add PKCS#1 padding.
1404
+ * @deprecated This algorithm is deprecated and will never be requested by Chrome as of version 109.
1405
+ */
1406
+ RSASSA_PKCS1_V1_5_MD5_SHA1 = "RSASSA_PKCS1_v1_5_MD5_SHA1",
1407
+ /** Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the SHA-1 hash function. */
1408
+ RSASSA_PKCS1_V1_5_SHA1 = "RSASSA_PKCS1_v1_5_SHA1",
1409
+ /** Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the SHA-256 hashing function. */
1410
+ RSASSA_PKCS1_V1_5_SHA256 = "RSASSA_PKCS1_v1_5_SHA256",
1411
+ /** Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the SHA-384 hashing function. */
1412
+ RSASSA_PKCS1_V1_5_SHA384 = "RSASSA_PKCS1_v1_5_SHA384",
1413
+ /** Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the SHA-512 hashing function. */
1414
+ RSASSA_PKCS1_V1_5_SHA512 = "RSASSA_PKCS1_v1_5_SHA512",
1415
+ /** Specifies the RSASSA PSS signature algorithm with the SHA-256 hashing function, MGF1 mask generation function and the salt of the same size as the hash. */
1416
+ RSASSA_PSS_SHA256 = "RSASSA_PSS_SHA256",
1417
+ /** Specifies the RSASSA PSS signature algorithm with the SHA-384 hashing function, MGF1 mask generation function and the salt of the same size as the hash. */
1418
+ RSASSA_PSS_SHA384 = "RSASSA_PSS_SHA384",
1419
+ /** Specifies the RSASSA PSS signature algorithm with the SHA-512 hashing function, MGF1 mask generation function and the salt of the same size as the hash. */
1420
+ RSASSA_PSS_SHA512 = "RSASSA_PSS_SHA512",
1421
+ }
1422
+
1423
+ export interface CertificateInfo {
1424
+ /** Must be the DER encoding of a X.509 certificate. Currently, only certificates of RSA keys are supported. */
1425
+ certificate: ArrayBuffer;
1426
+ /** Must be set to all hashes supported for this certificate. This extension will only be asked for signatures of digests calculated with one of these hash algorithms. This should be in order of decreasing hash preference. */
1427
+ supportedHashes: `${Hash}`[];
1428
+ }
1429
+
1430
+ /** @since Chrome 86 */
1431
+ export interface CertificatesUpdateRequest {
1432
+ /** Request identifier to be passed to {@link setCertificates}. */
1433
+ certificatesRequestId: number;
1434
+ }
1435
+
1436
+ /** @since Chrome 86 */
1437
+ export interface ClientCertificateInfo {
1438
+ /**
1439
+ * The array must contain the DER encoding of the X.509 client certificate as its first element.
1440
+ *
1441
+ * This must include exactly one certificate.
1442
+ */
1443
+ certificateChain: ArrayBuffer[];
1444
+ /** All algorithms supported for this certificate. The extension will only be asked for signatures using one of these algorithms. */
1445
+ supportedAlgorithms: `${Algorithm}`[];
1446
+ }
1447
+
1448
+ /**
1449
+ * Types of errors that the extension can report.
1450
+ * @since Chrome 86
1451
+ */
1452
+ export enum Error {
1453
+ GENERAL_ERROR = "GENERAL_ERROR",
1454
+ }
1455
+
1456
+ /** @deprecated Replaced by {@link Algorithm}.*/
1457
+ export enum Hash {
1458
+ /** Specifies the MD5 and SHA1 hashing algorithms. */
1459
+ MD5_SHA1 = "MD5_SHA1",
1460
+ /** Specifies the SHA1 hashing algorithm. */
1461
+ SHA1 = "SHA1",
1462
+ /** Specifies the SHA256 hashing algorithm. */
1463
+ SHA256 = "SHA256",
1464
+ /** Specifies the SHA384 hashing algorithm. */
1465
+ SHA384 = "SHA384",
1466
+ /** Specifies the SHA512 hashing algorithm. */
1467
+ SHA512 = "SHA512",
1468
+ }
1469
+
1470
+ /**
1471
+ * The types of errors that can be presented to the user through the requestPin function.
1472
+ * @since Chrome 57
1473
+ */
1474
+ export enum PinRequestErrorType {
1475
+ /** Specifies the PIN is invalid. */
1476
+ INVALID_PIN = "INVALID_PIN",
1477
+ /** Specifies the PUK is invalid. */
1478
+ INVALID_PUK = "INVALID_PUK",
1479
+ /** Specifies the maximum attempt number has been exceeded. */
1480
+ MAX_ATTEMPTS_EXCEEDED = "MAX_ATTEMPTS_EXCEEDED",
1481
+ /** Specifies that the error cannot be represented by the above types. */
1482
+ UNKNOWN_ERROR = "UNKNOWN_ERROR",
1483
+ }
1484
+
1485
+ /**
1486
+ * The type of code being requested by the extension with requestPin function.
1487
+ * @since Chrome 57
1488
+ */
1489
+ export enum PinRequestType {
1490
+ /** Specifies the requested code is a PIN. */
1491
+ PIN = "PIN",
1492
+ /** Specifies the requested code is a PUK. */
1493
+ PUK = "PUK",
1494
+ }
1495
+
1496
+ /** @since Chrome 57 */
1497
+ export interface PinResponseDetails {
1498
+ /** The code provided by the user. Empty if user closed the dialog or some other error occurred. */
1499
+ userInput?: string | undefined;
1500
+ }
1501
+
1502
+ /** @since Chrome 86 */
1503
+ export interface ReportSignatureDetails {
1504
+ /** Error that occurred while generating the signature, if any. */
1505
+ error?: `${Error}` | undefined;
1506
+ /** Request identifier that was received via the {@link onSignatureRequested} event. */
1507
+ signRequestId: number;
1508
+ /** The signature, if successfully generated. */
1509
+ signature?: ArrayBuffer | undefined;
1510
+ }
1511
+
1512
+ /** @since Chrome 57 */
1513
+ export interface RequestPinDetails {
1514
+ /** The number of attempts left. This is provided so that any UI can present this information to the user. Chrome is not expected to enforce this, instead stopPinRequest should be called by the extension with errorType = MAX_ATTEMPTS_EXCEEDED when the number of pin requests is exceeded. */
1515
+ attemptsLeft?: number | undefined;
1516
+ /** The error template displayed to the user. This should be set if the previous request failed, to notify the user of the failure reason. */
1517
+ errorType?: `${PinRequestErrorType}` | undefined;
1518
+ /** The type of code requested. Default is PIN. */
1519
+ requestType?: `${PinRequestType}` | undefined;
1520
+ /** The ID given by Chrome in SignRequest. */
1521
+ signRequestId: number;
1522
+ }
1523
+
1524
+ /** @since Chrome 86 */
1525
+ export interface SetCertificatesDetails {
1526
+ /** When called in response to {@link onCertificatesUpdateRequested}, should contain the received `certificatesRequestId` value. Otherwise, should be unset. */
1527
+ certificatesRequestId?: number | undefined;
1528
+ /** List of currently available client certificates. */
1529
+ clientCertificates: ClientCertificateInfo[];
1530
+ /** Error that occurred while extracting the certificates, if any. This error will be surfaced to the user when appropriate. */
1531
+ error?: `${Error}` | undefined;
1532
+ }
1533
+
1534
+ /** @since Chrome 86 */
1535
+ export interface SignatureRequest {
1536
+ /** Signature algorithm to be used. */
1537
+ algorithm: `${Algorithm}`;
1538
+ /** The DER encoding of a X.509 certificate. The extension must sign `input` using the associated private key. */
1539
+ certificate: ArrayBuffer;
1540
+ /** Data to be signed. Note that the data is not hashed. */
1541
+ input: ArrayBuffer;
1542
+ /** Request identifier to be passed to {@link reportSignature}. */
1543
+ signRequestId: number;
1544
+ }
1545
+
1546
+ export interface SignRequest {
1547
+ /** The DER encoding of a X.509 certificate. The extension must sign `digest` using the associated private key. */
1548
+ certificate: ArrayBuffer;
1549
+ /** The digest that must be signed. */
1550
+ digest: ArrayBuffer;
1551
+ /** Refers to the hash algorithm that was used to create `digest`. */
1552
+ hash: `${Hash}`;
1553
+ /**
1554
+ * The unique ID to be used by the extension should it need to call a method that requires it, e.g. requestPin.
1555
+ * @since Chrome 57
1556
+ */
1557
+ signRequestId: number;
1558
+ }
1559
+
1560
+ /** @since Chrome 57 */
1561
+ export interface StopPinRequestDetails {
1562
+ /** The error template. If present it is displayed to user. Intended to contain the reason for stopping the flow if it was caused by an error, e.g. MAX\_ATTEMPTS\_EXCEEDED. */
1563
+ errorType?: `${PinRequestErrorType}` | undefined;
1564
+ /** The ID given by Chrome in SignRequest. */
1565
+ signRequestId: number;
1566
+ }
1567
+
1568
+ /**
1569
+ * Should be called as a response to {@link onSignatureRequested}.
1570
+ *
1571
+ * The extension must eventually call this function for every {@link onSignatureRequested} event; the API implementation will stop waiting for this call after some time and respond with a timeout error when this function is called.
1572
+ *
1573
+ * Can return its result via Promise since Chrome 96.
1574
+ * @since Chrome 86
1575
+ */
1576
+ export function reportSignature(details: ReportSignatureDetails): Promise<void>;
1577
+ export function reportSignature(details: ReportSignatureDetails, callback: () => void): void;
1578
+
1579
+ /**
1580
+ * Requests the PIN from the user. Only one ongoing request at a time is allowed. The requests issued while another flow is ongoing are rejected. It's the extension's responsibility to try again later if another flow is in progress.
1581
+ *
1582
+ * Can return its result via Promise since Chrome 96.
1583
+ * @param details Contains the details about the requested dialog.
1584
+ * @since Chrome 57
1585
+ */
1586
+ export function requestPin(details: RequestPinDetails): Promise<PinResponseDetails | undefined>;
1587
+ export function requestPin(
1588
+ details: RequestPinDetails,
1589
+ callback: (details?: PinResponseDetails | undefined) => void,
1590
+ ): void;
1591
+
1592
+ /**
1593
+ * Sets a list of certificates to use in the browser.
1594
+ *
1595
+ * The extension should call this function after initialization and on every change in the set of currently available certificates. The extension should also call this function in response to {@link onCertificatesUpdateRequested} every time this event is received.
1596
+ *
1597
+ * Can return its result via Promise since Chrome 96.
1598
+ * @param details The certificates to set. Invalid certificates will be ignored.
1599
+ * @since Chrome 86
1600
+ */
1601
+ export function setCertificates(details: SetCertificatesDetails): Promise<void>;
1602
+ export function setCertificates(details: SetCertificatesDetails, callback: () => void): void;
1603
+
1604
+ /**
1605
+ * Stops the pin request started by the {@link requestPin} function.
1606
+ *
1607
+ * Can return its result via Promise since Chrome 96.
1608
+ * @param details Contains the details about the reason for stopping the request flow.
1609
+ * @since Chrome 57
1610
+ */
1611
+ export function stopPinRequest(details: StopPinRequestDetails): Promise<void>;
1612
+ export function stopPinRequest(details: StopPinRequestDetails, callback: () => void): void;
1613
+
1614
+ /**
1615
+ * This event fires if the certificates set via {@link setCertificates} are insufficient or the browser requests updated information. The extension must call {@link setCertificates} with the updated list of certificates and the received `certificatesRequestId`.
1616
+ * @since Chrome 86
1617
+ */
1618
+ export const onCertificatesUpdateRequested: events.Event<(request: CertificatesUpdateRequest) => void>;
1619
+
1620
+ /**
1621
+ * This event fires every time the browser needs to sign a message using a certificate provided by this extension via {@link setCertificates}.
1622
+ *
1623
+ * The extension must sign the input data from `request` using the appropriate algorithm and private key and return it by calling {@link reportSignature} with the received `signRequestId`.
1624
+ * @since Chrome 86
1625
+ */
1626
+ export const onSignatureRequested: events.Event<(request: SignatureRequest) => void>;
1627
+ }
1628
+
1388
1629
  ////////////////////
1389
1630
  // Commands
1390
1631
  ////////////////////
@@ -12882,6 +13123,123 @@ export namespace Browser {
12882
13123
  export function setWallpaper(details: WallpaperDetails, callback: (thumbnail?: ArrayBuffer) => void): void;
12883
13124
  }
12884
13125
 
13126
+ ////////////////////
13127
+ // Web Authentication Proxy
13128
+ ////////////////////
13129
+ /**
13130
+ * The `Browser.webAuthenticationProxy` API lets remote desktop software running on a remote host intercept Web Authentication API (WebAuthn) requests in order to handle them on a local client.
13131
+ *
13132
+ * Permissions: "webAuthenticationProxy"
13133
+ * @since Chrome 115, MV3
13134
+ */
13135
+ export namespace webAuthenticationProxy {
13136
+ export interface CreateRequest {
13137
+ /** The `PublicKeyCredentialCreationOptions` passed to `navigator.credentials.create()`, serialized as a JSON string. The serialization format is compatible with [`PublicKeyCredential.parseCreationOptionsFromJSON()`](https://w3c.github.io/webauthn/#sctn-parseCreationOptionsFromJSON). */
13138
+ requestDetailsJson: string;
13139
+ /** An opaque identifier for the request. */
13140
+ requestId: number;
13141
+ }
13142
+
13143
+ export interface CreateResponseDetails {
13144
+ /** The `DOMException` yielded by the remote request, if any. */
13145
+ error?: DOMExceptionDetails | undefined;
13146
+ /** The `requestId` of the `CreateRequest`. */
13147
+ requestId: number;
13148
+ /** The `PublicKeyCredential`, yielded by the remote request, if any, serialized as a JSON string by calling [`PublicKeyCredential.toJSON()`](https://w3c.github.io/webauthn/#dom-publickeycredential-tojson). */
13149
+ responseJson?: string | undefined;
13150
+ }
13151
+
13152
+ export interface DOMExceptionDetails {
13153
+ name: string;
13154
+ message: string;
13155
+ }
13156
+
13157
+ export interface GetRequest {
13158
+ /** The `PublicKeyCredentialRequestOptions` passed to `navigator.credentials.get()`, serialized as a JSON string. The serialization format is compatible with [`PublicKeyCredential.parseRequestOptionsFromJSON()`](https://w3c.github.io/webauthn/#sctn-parseRequestOptionsFromJSON). */
13159
+ requestDetailsJson: string;
13160
+ /** An opaque identifier for the request. */
13161
+ requestId: number;
13162
+ }
13163
+
13164
+ export interface GetResponseDetails {
13165
+ /** The `DOMException` yielded by the remote request, if any. */
13166
+ error?: DOMExceptionDetails | undefined;
13167
+ /** The `requestId` of the `CreateRequest`. */
13168
+ requestId: number;
13169
+ /** The `PublicKeyCredential`, yielded by the remote request, if any, serialized as a JSON string by calling [`PublicKeyCredential.toJSON()`](https://w3c.github.io/webauthn/#dom-publickeycredential-tojson). */
13170
+ responseJson?: string | undefined;
13171
+ }
13172
+
13173
+ export interface IsUvpaaRequest {
13174
+ /** An opaque identifier for the request. */
13175
+ requestId: number;
13176
+ }
13177
+
13178
+ export interface IsUvpaaResponseDetails {
13179
+ isUvpaa: boolean;
13180
+ requestId: number;
13181
+ }
13182
+
13183
+ /**
13184
+ * Makes this extension the active Web Authentication API request proxy.
13185
+ *
13186
+ * Remote desktop extensions typically call this method after detecting attachment of a remote session to this host. Once this method returns without error, regular processing of WebAuthn requests is suspended, and events from this extension API are raised.
13187
+ *
13188
+ * This method fails with an error if a different extension is already attached.
13189
+ *
13190
+ * The attached extension must call `detach()` once the remote desktop session has ended in order to resume regular WebAuthn request processing. Extensions automatically become detached if they are unloaded.
13191
+ *
13192
+ * Refer to the `onRemoteSessionStateChange` event for signaling a change of remote session attachment from a native application to to the (possibly suspended) extension.
13193
+ */
13194
+ export function attach(): Promise<string | undefined>;
13195
+ export function attach(callback: (error?: string | undefined) => void): void;
13196
+
13197
+ /** Reports the result of a `navigator.credentials.create()` call. The extension must call this for every `onCreateRequest` event it has received, unless the request was canceled (in which case, an `onRequestCanceled` event is fired). */
13198
+ export function completeCreateRequest(details: CreateResponseDetails): Promise<void>;
13199
+ export function completeCreateRequest(details: CreateResponseDetails, callback: () => void): void;
13200
+
13201
+ /** Reports the result of a `navigator.credentials.get()` call. The extension must call this for every `onGetRequest` event it has received, unless the request was canceled (in which case, an `onRequestCanceled` event is fired). */
13202
+ export function completeGetRequest(details: GetResponseDetails): Promise<void>;
13203
+ export function completeGetRequest(details: GetResponseDetails, callback: () => void): void;
13204
+
13205
+ /** Reports the result of a `PublicKeyCredential.isUserVerifyingPlatformAuthenticator()` call. The extension must call this for every `onIsUvpaaRequest` event it has received. */
13206
+ export function completeIsUvpaaRequest(details: IsUvpaaResponseDetails): Promise<void>;
13207
+ export function completeIsUvpaaRequest(details: IsUvpaaResponseDetails, callback: () => void): void;
13208
+
13209
+ /**
13210
+ * Removes this extension from being the active Web Authentication API request proxy.
13211
+ *
13212
+ * This method is typically called when the extension detects that a remote desktop session was terminated. Once this method returns, the extension ceases to be the active Web Authentication API request proxy.
13213
+ *
13214
+ * Refer to the `onRemoteSessionStateChange` event for signaling a change of remote session attachment from a native application to to the (possibly suspended) extension.
13215
+ */
13216
+ export function detach(): Promise<string | undefined>;
13217
+ export function detach(callback: (error?: string | undefined) => void): void;
13218
+
13219
+ /** Fires when a WebAuthn `navigator.credentials.create()` call occurs. The extension must supply a response by calling `completeCreateRequest()` with the `requestId` from `requestInfo`. */
13220
+ export const onCreateRequest: events.Event<(requestInfo: CreateRequest) => void>;
13221
+
13222
+ /** Fires when a WebAuthn `navigator.credentials.get()` call occurs. The extension must supply a response by calling `completeGetRequest()` with the `requestId` from `requestInfo` */
13223
+ export const onGetRequest: events.Event<(requestInfo: GetRequest) => void>;
13224
+
13225
+ /** Fires when a `PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()` call occurs. The extension must supply a response by calling `completeIsUvpaaRequest()` with the `requestId` from `requestInfo` */
13226
+ export const onIsUvpaaRequest: events.Event<(requestInfo: IsUvpaaRequest) => void>;
13227
+
13228
+ /**
13229
+ * A native application associated with this extension can cause this event to be fired by writing to a file with a name equal to the extension's ID in a directory named `WebAuthenticationProxyRemoteSessionStateChange` inside the [default user data directory](https://chromium.googlesource.com/chromium/src/+/main/docs/user_data_dir.md#default-location)
13230
+ *
13231
+ * The contents of the file should be empty. I.e., it is not necessary to change the contents of the file in order to trigger this event.
13232
+ *
13233
+ * The native host application may use this event mechanism to signal a possible remote session state change (i.e. from detached to attached, or vice versa) while the extension service worker is possibly suspended. In the handler for this event, the extension can call the `attach()` or `detach()` API methods accordingly.
13234
+ *
13235
+ * The event listener must be registered synchronously at load time.
13236
+ */
13237
+ export const onRemoteSessionStateChange: events.Event<() => void>;
13238
+
13239
+ /** Fires when a `onCreateRequest` or `onGetRequest` event is canceled (because the WebAuthn request was aborted by the caller, or because it timed out). When receiving this event, the extension should cancel processing of the corresponding request on the client side. Extensions cannot complete a request once it has been canceled. */
13240
+ export const onRequestCanceled: events.Event<(requestId: number) => void>;
13241
+ }
13242
+
12885
13243
  ////////////////////
12886
13244
  // Web Navigation
12887
13245
  ////////////////////
@@ -13109,24 +13467,8 @@ export namespace Browser {
13109
13467
  interface WebRequestEvent<T extends (...args: any) => void, U extends string[]>
13110
13468
  extends Omit<Browser.events.Event<T>, "addListener">
13111
13469
  {
13112
- addListener(callback: T, filter: RequestFilter, extraInfoSpec?: U): void;
13113
- }
13114
-
13115
- /** How the requested resource will be used. */
13116
- export type ResourceType =
13117
- | "main_frame"
13118
- | "sub_frame"
13119
- | "stylesheet"
13120
- | "script"
13121
- | "image"
13122
- | "font"
13123
- | "object"
13124
- | "xmlhttprequest"
13125
- | "ping"
13126
- | "csp_report"
13127
- | "media"
13128
- | "websocket"
13129
- | "other";
13470
+ addListener(callback: T, filter: RequestFilter, extraInfoSpec?: U | undefined): void;
13471
+ }
13130
13472
 
13131
13473
  export interface AuthCredentials {
13132
13474
  username: string;
@@ -13135,228 +13477,324 @@ export namespace Browser {
13135
13477
 
13136
13478
  /** An HTTP Header, represented as an object containing a key and either a value or a binaryValue. */
13137
13479
  export interface HttpHeader {
13480
+ /** Name of the HTTP header. */
13138
13481
  name: string;
13482
+ /** Value of the HTTP header if it can be represented by UTF-8. */
13139
13483
  value?: string | undefined;
13484
+ /** Value of the HTTP header if it cannot be represented by UTF-8, stored as individual byte values (0..255). */
13140
13485
  binaryValue?: ArrayBuffer | undefined;
13141
13486
  }
13142
13487
 
13143
13488
  /** Returns value for event handlers that have the 'blocking' extraInfoSpec applied. Allows the event handler to modify network requests. */
13144
13489
  export interface BlockingResponse {
13145
- /** Optional. If true, the request is cancelled. Used in onBeforeRequest, this prevents the request from being sent. */
13490
+ /** If true, the request is cancelled. This prevents the request from being sent. This can be used as a response to the onBeforeRequest, onBeforeSendHeaders, onHeadersReceived and onAuthRequired events. */
13146
13491
  cancel?: boolean | undefined;
13147
- /**
13148
- * Optional.
13149
- * Only used as a response to the onBeforeRequest and onHeadersReceived events. If set, the original request is prevented from being sent/completed and is instead redirected to the given URL. Redirections to non-HTTP schemes such as data: are allowed. Redirects initiated by a redirect action use the original request method for the redirect, with one exception: If the redirect is initiated at the onHeadersReceived stage, then the redirect will be issued using the GET method.
13150
- */
13492
+ /** Only used as a response to the onBeforeRequest and onHeadersReceived events. If set, the original request is prevented from being sent/completed and is instead redirected to the given URL. Redirections to non-HTTP schemes such as `data:` are allowed. Redirects initiated by a redirect action use the original request method for the redirect, with one exception: If the redirect is initiated at the onHeadersReceived stage, then the redirect will be issued using the GET method. Redirects from URLs with `ws://` and `wss://` schemes are **ignored**. */
13151
13493
  redirectUrl?: string | undefined;
13152
- /**
13153
- * Optional.
13154
- * Only used as a response to the onHeadersReceived event. If set, the server is assumed to have responded with these response headers instead. Only return responseHeaders if you really want to modify the headers in order to limit the number of conflicts (only one extension may modify responseHeaders for each request).
13155
- */
13494
+ /** Only used as a response to the onHeadersReceived event. If set, the server is assumed to have responded with these response headers instead. Only return `responseHeaders` if you really want to modify the headers in order to limit the number of conflicts (only one extension may modify `responseHeaders` for each request). */
13156
13495
  responseHeaders?: HttpHeader[] | undefined;
13157
- /** Optional. Only used as a response to the onAuthRequired event. If set, the request is made using the supplied credentials. */
13496
+ /** Only used as a response to the onAuthRequired event. If set, the request is made using the supplied credentials. */
13158
13497
  authCredentials?: AuthCredentials | undefined;
13159
- /**
13160
- * Optional.
13161
- * Only used as a response to the onBeforeSendHeaders event. If set, the request is made with these request headers instead.
13162
- */
13498
+ /** Only used as a response to the onBeforeSendHeaders event. If set, the request is made with these request headers instead. */
13163
13499
  requestHeaders?: HttpHeader[] | undefined;
13164
13500
  }
13165
13501
 
13502
+ /**
13503
+ * Contains data passed within form data. For urlencoded form it is stored as string if data is utf-8 string and as ArrayBuffer otherwise. For form-data it is ArrayBuffer. If form-data represents uploading file, it is string with filename, if the filename is provided.
13504
+ * @since Chrome 66
13505
+ */
13506
+ export type FormDataItem = string | ArrayBuffer;
13507
+
13508
+ /** @since Chrome 70 */
13509
+ export enum IgnoredActionType {
13510
+ AUTH_CREDENTIALS = "auth_credentials",
13511
+ REDIRECT = "redirect",
13512
+ REQUEST_HEADERS = "request_headers",
13513
+ RESPONSE_HEADERS = "response_headers",
13514
+ }
13515
+
13516
+ /** @since Chrome 44 */
13517
+ export enum OnAuthRequiredOptions {
13518
+ /** Specifies that the response headers should be included in the event. */
13519
+ RESPONSE_HEADERS = "responseHeaders",
13520
+ /** Specifies the request is blocked until the callback function returns. */
13521
+ BLOCKING = "blocking",
13522
+ /** Specifies that the callback function is handled asynchronously. */
13523
+ ASYNC_BLOCKING = "asyncBlocking",
13524
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13525
+ EXTRA_HEADERS = "extraHeaders",
13526
+ }
13527
+
13528
+ /** @since Chrome 44 */
13529
+ export enum OnBeforeRedirectOptions {
13530
+ /** Specifies that the response headers should be included in the event. */
13531
+ RESPONSE_HEADERS = "responseHeaders",
13532
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13533
+ EXTRA_HEADERS = "extraHeaders",
13534
+ }
13535
+
13536
+ /** @since Chrome 44 */
13537
+ export enum OnBeforeRequestOptions {
13538
+ /** Specifies the request is blocked until the callback function returns. */
13539
+ BLOCKING = "blocking",
13540
+ /** Specifies that the request body should be included in the event. */
13541
+ REQUEST_BODY = "requestBody",
13542
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13543
+ EXTRA_HEADERS = "extraHeaders",
13544
+ }
13545
+
13546
+ /** @since Chrome 44 */
13547
+ export enum OnBeforeSendHeadersOptions {
13548
+ /** Specifies that the request header should be included in the event. */
13549
+ REQUEST_HEADERS = "requestHeaders",
13550
+ /** Specifies the request is blocked until the callback function returns. */
13551
+ BLOCKING = "blocking",
13552
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13553
+ EXTRA_HEADERS = "extraHeaders",
13554
+ }
13555
+
13556
+ /** @since Chrome 44 */
13557
+ export enum OnCompletedOptions {
13558
+ /** Specifies that the response headers should be included in the event. */
13559
+ RESPONSE_HEADERS = "responseHeaders",
13560
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13561
+ EXTRA_HEADERS = "extraHeaders",
13562
+ }
13563
+
13564
+ /** @since Chrome 44 */
13565
+ export enum OnErrorOccurredOptions {
13566
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13567
+ EXTRA_HEADERS = "extraHeaders",
13568
+ }
13569
+
13570
+ /** @since Chrome 44 */
13571
+ export enum OnHeadersReceivedOptions {
13572
+ /** Specifies the request is blocked until the callback function returns. */
13573
+ BLOCKING = "blocking",
13574
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13575
+ EXTRA_HEADERS = "extraHeaders",
13576
+ /** Specifies that the response headers should be included in the event. */
13577
+ RESPONSE_HEADERS = "responseHeaders",
13578
+ }
13579
+
13580
+ /** @since Chrome 44 */
13581
+ export enum OnResponseStartedOptions {
13582
+ /** Specifies that the response headers should be included in the event. */
13583
+ RESPONSE_HEADERS = "responseHeaders",
13584
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13585
+ EXTRA_HEADERS = "extraHeaders",
13586
+ }
13587
+
13588
+ /** @since Chrome 44 */
13589
+ export enum OnSendHeadersOptions {
13590
+ /** Specifies that the request header should be included in the event. */
13591
+ REQUEST_HEADERS = "requestHeaders",
13592
+ /** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
13593
+ EXTRA_HEADERS = "extraHeaders",
13594
+ }
13595
+
13166
13596
  /** An object describing filters to apply to webRequest events. */
13167
13597
  export interface RequestFilter {
13168
- /** Optional. */
13169
13598
  tabId?: number | undefined;
13170
- /**
13171
- * A list of request types. Requests that cannot match any of the types will be filtered out.
13172
- */
13173
- types?: ResourceType[] | undefined;
13599
+ /** A list of request types. Requests that cannot match any of the types will be filtered out. */
13600
+ types?: `${ResourceType}`[] | undefined;
13174
13601
  /** A list of URLs or URL patterns. Requests that cannot match any of the URLs will be filtered out. */
13175
13602
  urls: string[];
13176
-
13177
- /** Optional. */
13178
13603
  windowId?: number | undefined;
13179
13604
  }
13180
13605
 
13181
- /**
13182
- * Contains data uploaded in a URL request.
13183
- * @since Chrome 23
13184
- */
13606
+ /** @since Chrome 44 */
13607
+ export enum ResourceType {
13608
+ /** Specifies the resource as the main frame. */
13609
+ MAIN_FRAME = "main_frame",
13610
+ /** Specifies the resource as a sub frame. */
13611
+ SUB_FRAME = "sub_frame",
13612
+ /** Specifies the resource as a stylesheet. */
13613
+ STYLESHEET = "stylesheet",
13614
+ /** Specifies the resource as a script. */
13615
+ SCRIPT = "script",
13616
+ /** Specifies the resource as an image. */
13617
+ IMAGE = "image",
13618
+ /** Specifies the resource as a font. */
13619
+ FONT = "font",
13620
+ /** Specifies the resource as an object. */
13621
+ OBJECT = "object",
13622
+ /** Specifies the resource as an XMLHttpRequest. */
13623
+ XMLHTTPREQUEST = "xmlhttprequest",
13624
+ /** Specifies the resource as a ping. */
13625
+ PING = "ping",
13626
+ /** Specifies the resource as a Content Security Policy (CSP) report. */
13627
+ CSP_REPORT = "csp_report",
13628
+ /** Specifies the resource as a media object. */
13629
+ MEDIA = "media",
13630
+ /** Specifies the resource as a WebSocket. */
13631
+ WEBSOCKET = "websocket",
13632
+ /** Specifies the resource as a WebBundle. */
13633
+ WEBBUNDLE = "webbundle",
13634
+ /** Specifies the resource as a type not included in the listed types. */
13635
+ OTHER = "other",
13636
+ }
13637
+
13638
+ /** Contains data uploaded in a URL request. */
13185
13639
  export interface UploadData {
13186
- /** Optional. An ArrayBuffer with a copy of the data. */
13187
- bytes?: ArrayBuffer | undefined;
13188
- /** Optional. A string with the file's path and name. */
13189
- file?: string | undefined;
13640
+ /** An ArrayBuffer with a copy of the data. */
13641
+ bytes?: ArrayBuffer;
13642
+ /** A string with the file's path and name. */
13643
+ file?: string;
13190
13644
  }
13191
13645
 
13192
- export interface WebRequestBody {
13193
- /** Optional. Errors when obtaining request body data. */
13194
- error?: string | undefined;
13646
+ /** The maximum number of times that `handlerBehaviorChanged` can be called per 10 minute sustained interval. `handlerBehaviorChanged` is an expensive function call that shouldn't be called often. */
13647
+ export const MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: 20;
13648
+
13649
+ /** Common properties for all webRequest events (except {@link onActionIgnored}). */
13650
+ export interface WebRequestDetails {
13195
13651
  /**
13196
- * Optional.
13197
- * If the request method is POST and the body is a sequence of key-value pairs encoded in UTF8, encoded as either multipart/form-data, or application/x-www-form-urlencoded, this dictionary is present and for each key contains the list of all values for that key. If the data is of another media type, or if it is malformed, the dictionary is not present. An example value of this dictionary is {'key': ['value1', 'value2']}.
13652
+ * The UUID of the document making the request.
13653
+ * @since Chrome 106
13198
13654
  */
13199
- formData?: { [key: string]: string[] } | undefined;
13655
+ documentId: string;
13200
13656
  /**
13201
- * Optional.
13202
- * If the request method is PUT or POST, and the body is not already parsed in formData, then the unparsed request body elements are contained in this array.
13657
+ * The lifecycle the document is in.
13658
+ * @since Chrome 106
13203
13659
  */
13204
- raw?: UploadData[] | undefined;
13205
- }
13206
-
13207
- export interface WebAuthChallenger {
13208
- host: string;
13209
- port: number;
13210
- }
13211
-
13212
- export interface ResourceRequest {
13213
- url: string;
13214
- /** 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. */
13215
- requestId: string;
13216
- /** 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 (type is main_frame or sub_frame), frameId indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab. */
13660
+ documentLifecycle: extensionTypes.DocumentLifecycle;
13661
+ /** 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 (`type` is `main_frame` or `sub_frame`), `frameId` indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab. */
13217
13662
  frameId: number;
13218
- /** ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists. */
13219
- parentFrameId: number;
13220
- /** The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab. */
13221
- tabId: number;
13222
13663
  /**
13223
- * How the requested resource will be used.
13664
+ * The type of frame the request occurred in.
13665
+ * @since Chrome 106
13224
13666
  */
13225
- type: ResourceType;
13226
- /** The time when this signal is triggered, in milliseconds since the epoch. */
13227
- timeStamp: number;
13228
- /** The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
13667
+ frameType: extensionTypes.FrameType;
13668
+ /**
13669
+ * The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
13229
13670
  * @since Chrome 63
13230
13671
  */
13231
- initiator?: string | undefined;
13232
- }
13233
-
13234
- export interface WebRequestDetails extends ResourceRequest {
13672
+ initiator?: string;
13235
13673
  /** Standard HTTP method. */
13236
13674
  method: string;
13237
- }
13238
-
13239
- export interface WebRequestHeadersDetails extends WebRequestDetails {
13240
- /** Optional. The HTTP request headers that are going to be sent out with this request. */
13241
- requestHeaders?: HttpHeader[] | undefined;
13242
- documentId: string;
13243
- documentLifecycle: extensionTypes.DocumentLifecycle;
13244
- frameType: extensionTypes.FrameType;
13245
- frameId: number;
13246
- initiator?: string | undefined;
13247
- parentDocumentId?: string | undefined;
13675
+ /**
13676
+ * The UUID of the parent document owning this frame. This is not set if there is no parent.
13677
+ * @since Chrome 106
13678
+ */
13679
+ parentDocumentId?: string;
13680
+ /** ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists. */
13248
13681
  parentFrameId: number;
13682
+ /** 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. */
13249
13683
  requestId: string;
13684
+ /** The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab. */
13250
13685
  tabId: number;
13686
+ /** The time when this signal is triggered, in milliseconds since the epoch. */
13251
13687
  timeStamp: number;
13252
- type: ResourceType;
13688
+ /** How the requested resource will be used. */
13689
+ type: `${ResourceType}`;
13253
13690
  url: string;
13254
13691
  }
13255
13692
 
13256
- export interface WebRequestBodyDetails extends WebRequestDetails {
13257
- /**
13258
- * Contains the HTTP request body data. Only provided if extraInfoSpec contains 'requestBody'.
13259
- * @since Chrome 23
13260
- */
13261
- requestBody: WebRequestBody | null;
13262
- }
13263
-
13264
- export interface WebRequestFullDetails extends WebRequestHeadersDetails, WebRequestBodyDetails {}
13265
-
13266
- export interface WebResponseDetails extends ResourceRequest {
13267
- /** HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line). */
13268
- statusLine: string;
13693
+ export interface OnAuthRequiredDetails extends WebRequestDetails {
13694
+ /** The server requesting authentication. */
13695
+ challenger: {
13696
+ host: string;
13697
+ port: number;
13698
+ };
13699
+ /** True for Proxy-Authenticate, false for WWW-Authenticate. */
13700
+ isProxy: boolean;
13701
+ /** The authentication realm provided by the server, if there is one. */
13702
+ realm?: string;
13703
+ /** The HTTP response headers that were received along with this response. */
13704
+ responseHeaders?: HttpHeader[];
13705
+ /** The authentication scheme, e.g. Basic or Digest. */
13706
+ scheme: string;
13269
13707
  /**
13270
13708
  * Standard HTTP status code returned by the server.
13271
13709
  * @since Chrome 43
13272
13710
  */
13273
13711
  statusCode: number;
13712
+ /** HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.*/
13713
+ statusLine: string;
13274
13714
  }
13275
13715
 
13276
- export interface WebResponseHeadersDetails extends WebResponseDetails {
13277
- /** Optional. The HTTP response headers that have been received with this response. */
13278
- responseHeaders?: HttpHeader[] | undefined;
13279
- method: string /** standard HTTP method i.e. GET, POST, PUT, etc. */;
13280
- }
13281
-
13282
- export interface WebResponseCacheDetails extends WebResponseHeadersDetails {
13283
- /**
13284
- * Optional.
13285
- * The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
13286
- */
13287
- ip?: string | undefined;
13716
+ export interface OnBeforeRedirectDetails extends WebRequestDetails {
13288
13717
  /** Indicates if this response was fetched from disk cache. */
13289
13718
  fromCache: boolean;
13290
- }
13291
-
13292
- export interface WebRedirectionResponseDetails extends WebResponseCacheDetails {
13719
+ /** The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address. */
13720
+ ip?: string;
13293
13721
  /** The new URL. */
13294
13722
  redirectUrl: string;
13723
+ /** The HTTP response headers that were received along with this redirect. */
13724
+ responseHeaders?: HttpHeader[];
13725
+ /** Standard HTTP status code returned by the server. */
13726
+ statusCode: number;
13727
+ /** HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.*/
13728
+ statusLine: string;
13295
13729
  }
13296
13730
 
13297
- export interface WebAuthenticationChallengeDetails extends WebResponseHeadersDetails {
13298
- /** The authentication scheme, e.g. Basic or Digest. */
13299
- scheme: string;
13300
- /** The authentication realm provided by the server, if there is one. */
13301
- realm?: string | undefined;
13302
- /** The server requesting authentication. */
13303
- challenger: WebAuthChallenger;
13304
- /** True for Proxy-Authenticate, false for WWW-Authenticate. */
13305
- isProxy: boolean;
13731
+ export interface OnBeforeRequestDetails
13732
+ extends SetPartial<WebRequestDetails, "documentId" | "documentLifecycle" | "frameType">
13733
+ {
13734
+ /** Contains the HTTP request body data. Only provided if extraInfoSpec contains 'requestBody'. */
13735
+ requestBody: {
13736
+ /** Errors when obtaining request body data. */
13737
+ error?: string;
13738
+ /** If the request method is POST and the body is a sequence of key-value pairs encoded in UTF8, encoded as either multipart/form-data, or application/x-www-form-urlencoded, this dictionary is present and for each key contains the list of all values for that key. If the data is of another media type, or if it is malformed, the dictionary is not present. An example value of this dictionary is {'key': \['value1', 'value2'\]}. */
13739
+ formData?: { [key: string]: FormDataItem[] };
13740
+ /** If the request method is PUT or POST, and the body is not already parsed in formData, then the unparsed request body elements are contained in this array. */
13741
+ raw?: UploadData[];
13742
+ } | undefined;
13306
13743
  }
13307
13744
 
13308
- export interface WebResponseErrorDetails extends WebResponseCacheDetails {
13309
- /** The error description. This string is not guaranteed to remain backwards compatible between releases. You must not parse and act based upon its content. */
13310
- error: string;
13745
+ export interface OnBeforeSendHeadersDetails extends WebRequestDetails {
13746
+ /** The HTTP request headers that are going to be sent out with this request. */
13747
+ requestHeaders?: HttpHeader[];
13311
13748
  }
13312
13749
 
13313
- export type WebRequestBodyEvent = WebRequestEvent<
13314
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
13315
- (details: WebRequestBodyDetails) => BlockingResponse | void,
13316
- string[]
13317
- >;
13318
-
13319
- export type WebRequestHeadersSynchronousEvent = WebRequestEvent<
13320
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
13321
- (details: WebRequestHeadersDetails) => BlockingResponse | void,
13322
- string[]
13323
- >;
13324
-
13325
- export type WebRequestHeadersEvent = WebRequestEvent<
13326
- (details: WebRequestHeadersDetails) => void,
13327
- string[]
13328
- >;
13329
-
13330
- export type _WebResponseHeadersEvent<T extends WebResponseHeadersDetails> = WebRequestEvent<
13331
- (details: T) => void,
13332
- string[]
13333
- >;
13334
-
13335
- export type WebResponseHeadersEvent = WebRequestEvent<
13336
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
13337
- (details: WebResponseHeadersDetails) => BlockingResponse | void,
13338
- string[]
13339
- >;
13340
-
13341
- export type WebResponseCacheEvent = _WebResponseHeadersEvent<WebResponseCacheDetails>;
13750
+ export interface OnCompletedDetails extends WebRequestDetails {
13751
+ /** Indicates if this response was fetched from disk cache. */
13752
+ fromCache: boolean;
13753
+ /** The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address. */
13754
+ ip?: string;
13755
+ /** The HTTP response headers that were received along with this response. */
13756
+ responseHeaders?: HttpHeader[];
13757
+ /** Standard HTTP status code returned by the server. */
13758
+ statusCode: number;
13759
+ /** HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.*/
13760
+ statusLine: string;
13761
+ }
13342
13762
 
13343
- export type WebRedirectionResponseEvent = _WebResponseHeadersEvent<WebRedirectionResponseDetails>;
13763
+ export interface OnErrorOccurredDetails extends WebRequestDetails {
13764
+ /** The error description. This string is _not_ guaranteed to remain backwards compatible between releases. You must not parse and act based upon its content. */
13765
+ error: string;
13766
+ /** Indicates if this response was fetched from disk cache. */
13767
+ fromCache: boolean;
13768
+ /** The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address. */
13769
+ ip?: string;
13770
+ }
13344
13771
 
13345
- export type WebAuthenticationChallengeEvent = WebRequestEvent<
13346
- (
13347
- details: WebAuthenticationChallengeDetails,
13348
- callback?: (response: BlockingResponse) => void,
13349
- ) => void,
13350
- string[]
13351
- >;
13772
+ export interface OnHeadersReceivedDetails extends WebRequestDetails {
13773
+ /** The HTTP response headers that have been received with this response. */
13774
+ responseHeaders?: HttpHeader[];
13775
+ /** Standard HTTP status code returned by the server. */
13776
+ statusCode: number;
13777
+ /** HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.*/
13778
+ statusLine: string;
13779
+ }
13352
13780
 
13353
- export interface WebResponseErrorEvent extends _WebResponseHeadersEvent<WebResponseErrorDetails> {}
13781
+ export interface OnResponseStartedDetails extends WebRequestDetails {
13782
+ /** Indicates if this response was fetched from disk cache. */
13783
+ fromCache: boolean;
13784
+ /** The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address. */
13785
+ ip?: string;
13786
+ /** The HTTP response headers that were received along with this response. */
13787
+ responseHeaders?: HttpHeader[];
13788
+ /** Standard HTTP status code returned by the server. */
13789
+ statusCode: number;
13790
+ /** HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers. */
13791
+ statusLine: string;
13792
+ }
13354
13793
 
13355
- /**
13356
- * The maximum number of times that handlerBehaviorChanged can be called per 10 minute sustained interval. handlerBehaviorChanged is an expensive function call that shouldn't be called often.
13357
- * @since Chrome 23
13358
- */
13359
- export var MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: number;
13794
+ export interface OnSendHeadersDetails extends WebRequestDetails {
13795
+ /** The HTTP request headers that have been sent out with this request. */
13796
+ requestHeaders?: HttpHeader[];
13797
+ }
13360
13798
 
13361
13799
  /**
13362
13800
  * Needs to be called when the behavior of the webRequest handlers has changed to prevent incorrect handling due to caching. This function call is expensive. Don't call it often.
@@ -13365,17 +13803,39 @@ export namespace Browser {
13365
13803
  export function handlerBehaviorChanged(): Promise<void>;
13366
13804
  export function handlerBehaviorChanged(callback: () => void): void;
13367
13805
 
13806
+ export const onActionIgnored: events.Event<
13807
+ (details: {
13808
+ // The proposed action which was ignored.
13809
+ action: `${IgnoredActionType}`;
13810
+ // 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.
13811
+ requestId: string;
13812
+ }) => void
13813
+ >;
13814
+
13368
13815
  /** Fired when a request is about to occur. */
13369
- export const onBeforeRequest: WebRequestBodyEvent;
13816
+ export const onBeforeRequest: WebRequestEvent<
13817
+ (details: OnBeforeRequestDetails) => BlockingResponse | undefined,
13818
+ `${OnBeforeRequestOptions}`[]
13819
+ >;
13370
13820
 
13371
13821
  /** Fired before sending an HTTP request, once the request headers are available. This may occur after a TCP connection is made to the server, but before any HTTP data is sent. */
13372
- export const onBeforeSendHeaders: WebRequestHeadersSynchronousEvent;
13822
+ export const onBeforeSendHeaders: WebRequestEvent<
13823
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
13824
+ (details: OnBeforeSendHeadersDetails) => BlockingResponse | undefined,
13825
+ `${OnBeforeSendHeadersOptions}`[]
13826
+ >;
13373
13827
 
13374
13828
  /** Fired just before a request is going to be sent to the server (modifications of previous onBeforeSendHeaders callbacks are visible by the time onSendHeaders is fired). */
13375
- export const onSendHeaders: WebRequestHeadersEvent;
13829
+ export const onSendHeaders: WebRequestEvent<
13830
+ (details: OnSendHeadersDetails) => void,
13831
+ `${OnSendHeadersOptions}`[]
13832
+ >;
13376
13833
 
13377
13834
  /** Fired when HTTP response headers of a request have been received. */
13378
- export const onHeadersReceived: WebResponseHeadersEvent;
13835
+ export const onHeadersReceived: WebRequestEvent<
13836
+ (details: OnHeadersReceivedDetails) => BlockingResponse | undefined,
13837
+ `${OnHeadersReceivedOptions}`[]
13838
+ >;
13379
13839
 
13380
13840
  /**
13381
13841
  * Fired when an authentication failure is received.
@@ -13385,19 +13845,39 @@ export namespace Browser {
13385
13845
  *
13386
13846
  * Requires the `webRequestAuthProvider` permission.
13387
13847
  */
13388
- export const onAuthRequired: WebAuthenticationChallengeEvent;
13848
+ export const onAuthRequired: WebRequestEvent<
13849
+ (
13850
+ details: OnAuthRequiredDetails,
13851
+ /** @since Chrome 58 */
13852
+ asyncCallback?: (response: BlockingResponse) => void,
13853
+ ) => BlockingResponse | undefined,
13854
+ `${OnAuthRequiredOptions}`[]
13855
+ >;
13856
+ // export const onAuthRequired: WebAuthenticationChallengeEvent;
13389
13857
 
13390
13858
  /** Fired when the first byte of the response body is received. For HTTP requests, this means that the status line and response headers are available. */
13391
- export const onResponseStarted: WebResponseCacheEvent;
13859
+ export const onResponseStarted: WebRequestEvent<
13860
+ (details: OnResponseStartedDetails) => void,
13861
+ `${OnResponseStartedOptions}`[]
13862
+ >;
13392
13863
 
13393
13864
  /** Fired when a server-initiated redirect is about to occur. */
13394
- export const onBeforeRedirect: WebRedirectionResponseEvent;
13865
+ export const onBeforeRedirect: WebRequestEvent<
13866
+ (details: OnBeforeRedirectDetails) => void,
13867
+ `${OnBeforeRedirectOptions}`[]
13868
+ >;
13395
13869
 
13396
13870
  /** Fired when a request is completed. */
13397
- export const onCompleted: WebResponseCacheEvent;
13871
+ export const onCompleted: WebRequestEvent<
13872
+ (details: OnCompletedDetails) => void,
13873
+ `${OnCompletedOptions}`[]
13874
+ >;
13398
13875
 
13399
13876
  /** Fired when an error occurs. */
13400
- export const onErrorOccurred: WebResponseErrorEvent;
13877
+ export const onErrorOccurred: WebRequestEvent<
13878
+ (details: OnErrorOccurredDetails) => void,
13879
+ `${OnErrorOccurredOptions}`[]
13880
+ >;
13401
13881
  }
13402
13882
 
13403
13883
  ////////////////////
@@ -13934,7 +14414,7 @@ export namespace Browser {
13934
14414
  tabId: number;
13935
14415
 
13936
14416
  /** The resource type of the request. */
13937
- type: ResourceType;
14417
+ type: `${ResourceType}`;
13938
14418
 
13939
14419
  /** The URL of the request. */
13940
14420
  url: string;
@@ -13976,7 +14456,7 @@ export namespace Browser {
13976
14456
  responseHeaders?: ModifyHeaderInfo[] | undefined;
13977
14457
 
13978
14458
  /** The type of action to perform. */
13979
- type: RuleActionType;
14459
+ type: `${RuleActionType}`;
13980
14460
  }
13981
14461
 
13982
14462
  export interface RuleCondition {
@@ -13984,7 +14464,7 @@ export namespace Browser {
13984
14464
  * Specifies whether the network request is first-party or third-party to the domain from which it originated.
13985
14465
  * If omitted, all requests are accepted.
13986
14466
  */
13987
- domainType?: DomainType | undefined;
14467
+ domainType?: `${DomainType}` | undefined;
13988
14468
 
13989
14469
  /**
13990
14470
  * @deprecated since Chrome 101. Use initiatorDomains instead.
@@ -14071,7 +14551,7 @@ export namespace Browser {
14071
14551
  * Only one of requestMethods and excludedRequestMethods should be specified.
14072
14552
  * If neither of them is specified, all request methods are matched.
14073
14553
  */
14074
- excludedRequestMethods?: RequestMethod[] | undefined;
14554
+ excludedRequestMethods?: `${RequestMethod}`[] | undefined;
14075
14555
 
14076
14556
  /**
14077
14557
  * List of resource types which the rule won't match.
@@ -14079,7 +14559,7 @@ export namespace Browser {
14079
14559
  * and {@link Browser.declarativeNetRequest.RuleCondition.excludedResourceTypes} should be specified.
14080
14560
  * If neither of them is specified, all resource types except "main_frame" are blocked.
14081
14561
  */
14082
- excludedResourceTypes?: ResourceType[] | undefined;
14562
+ excludedResourceTypes?: `${ResourceType}`[] | undefined;
14083
14563
 
14084
14564
  /**
14085
14565
  * List of {@link Browser.tabs.Tab.id} which the rule should not match.
@@ -14110,7 +14590,7 @@ export namespace Browser {
14110
14590
  * Note: Specifying a {@link Browser.declarativeNetRequest.RuleCondition.requestMethods} rule condition will also exclude non-HTTP(s) requests,
14111
14591
  * whereas specifying {@link Browser.declarativeNetRequest.RuleCondition.excludedRequestMethods} will not.
14112
14592
  */
14113
- requestMethods?: RequestMethod[];
14593
+ requestMethods?: `${RequestMethod}`[] | undefined;
14114
14594
 
14115
14595
  /**
14116
14596
  * List of {@link Browser.tabs.Tab.id} which the rule should not match.
@@ -14152,7 +14632,7 @@ export namespace Browser {
14152
14632
  *
14153
14633
  * Note: this must be specified for allowAllRequests rules and may only include the sub_frame and main_frame resource types.
14154
14634
  */
14155
- resourceTypes?: ResourceType[] | undefined;
14635
+ resourceTypes?: `${ResourceType}`[] | undefined;
14156
14636
 
14157
14637
  /**
14158
14638
  * Rule does not match if the request matches any response header condition in this list (if specified). If both `excludedResponseHeaders` and `responseHeaders` are specified, then the `excludedResponseHeaders` property takes precedence.
@@ -14222,7 +14702,7 @@ export namespace Browser {
14222
14702
  header: string;
14223
14703
 
14224
14704
  /** The operation to be performed on a header. */
14225
- operation: HeaderOperation;
14705
+ operation: `${HeaderOperation}`;
14226
14706
 
14227
14707
  /** The new value for the header.
14228
14708
  * Must be specified for append and set operations.
@@ -14304,7 +14784,7 @@ export namespace Browser {
14304
14784
  /** Specifies the reason why the regular expression is not supported.
14305
14785
  * Only provided if isSupported is false.
14306
14786
  */
14307
- reason?: UnsupportedRegexReason | undefined;
14787
+ reason?: `${UnsupportedRegexReason}` | undefined;
14308
14788
  }
14309
14789
 
14310
14790
  export interface TabActionCountUpdate {