Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docs/apis/cookies.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ The Capacitor Cookies API provides native cookie support via patching `document.
By default, the patching of `document.cookie` to use native libraries is disabled.
If you would like to enable this feature, modify the configuration below in the `capacitor.config` file.

| Prop | Type | Description | Default |
| ------------- | -------------------- | ------------------------------------------------------------------------- | ------------------ |
| **`enabled`** | <code>boolean</code> | Enable the patching of `document.cookie` to use native libraries instead. | <code>false</code> |
| Prop | Type | Description | Default | Since |
| -------------- | -------------------- | ------------------------------------------------------------------------------------ | ------------------ | ----- |
| **`enabled`** | <code>boolean</code> | Enable the patching of `document.cookie` to use native libraries instead. | <code>false</code> | 4.3.0 |
| **`disabled`** | <code>boolean</code> | Prevent the plugin from loading on iOS and Android. Takes precedence over `enabled`. | <code>false</code> | 9.1.0 |

`enabled` only controls the patching. With `enabled` unset or `false`, `CapacitorCookies.setCookie()` and the other methods below still work.
Set `disabled` to `true` to stop the plugin from loading at all: its methods then fail as unimplemented, and `document.cookie` is not patched even if `enabled` is `true`.

On Android, this plugin is also what shares cookies between the web view and native requests made with `HttpURLConnection` (including `CapacitorHttp`), and it clears session cookies when it loads.
With `disabled: true`, neither happens.

### Example Configuration

Expand Down
10 changes: 7 additions & 3 deletions docs/apis/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ The Capacitor Http API provides native http support via patching `fetch` and `XM
By default, the patching of `window.fetch` and `XMLHttpRequest` to use native libraries is disabled.
If you would like to enable this feature, modify the configuration below in the `capacitor.config` file.

| Prop | Type | Description | Default |
| ------------- | -------------------- | ------------------------------------------------------------------------------------ | ------------------ |
| **`enabled`** | <code>boolean</code> | Enable the patching of `fetch` and `XMLHttpRequest` to use native libraries instead. | <code>false</code> |
| Prop | Type | Description | Default | Since |
| -------------- | -------------------- | ------------------------------------------------------------------------------------ | ------------------ | ----- |
| **`enabled`** | <code>boolean</code> | Enable the patching of `fetch` and `XMLHttpRequest` to use native libraries instead. | <code>false</code> | 4.3.0 |
| **`disabled`** | <code>boolean</code> | Prevent the plugin from loading on iOS and Android. Takes precedence over `enabled`. | <code>false</code> | 9.1.0 |

`enabled` only controls the patching. With `enabled` unset or `false`, `CapacitorHttp.request()` and the other methods below still work.
Set `disabled` to `true` to stop the plugin from loading at all: its methods then fail as unimplemented, and `fetch` and `XMLHttpRequest` are not patched even if `enabled` is `true`.

### Example Configuration

Expand Down
44 changes: 39 additions & 5 deletions docs/main/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,23 +779,29 @@ export interface PluginsConfig {
/**
* Plugin configuration by class name.
*
* Every plugin accepts `disabled` (see `PluginConfig`), for example
* `{ plugins: { MyPlugin: { disabled: true } } }`.
*
* @since 1.0.0
*/
[key: string]:
| {
| (PluginConfig & {
[key: string]: any;
}
})
| undefined;

/**
* Capacitor Cookies plugin configuration
*
* @since 4.3.0
*/
CapacitorCookies?: {
CapacitorCookies?: PluginConfig & {
/**
* Enable CapacitorCookies to override the global `document.cookie` on native.
*
* This only controls the patching. The plugin's own methods work either
* way; use `disabled` to stop the plugin from loading.
*
* @default false
*/
enabled?: boolean;
Expand All @@ -806,10 +812,13 @@ export interface PluginsConfig {
*
* @since 4.3.0
*/
CapacitorHttp?: {
CapacitorHttp?: PluginConfig & {
/**
* Enable CapacitorHttp to override the global `fetch` and `XMLHttpRequest` on native.
*
* This only controls the patching. The plugin's own methods work either
* way; use `disabled` to stop the plugin from loading.
*
* @default false
*/
enabled?: boolean;
Expand All @@ -820,7 +829,7 @@ export interface PluginsConfig {
*
* @since 8.0.0
*/
SystemBars?: {
SystemBars?: PluginConfig & {
/**
* Specifies how to handle problematic insets on Android.
*
Expand Down Expand Up @@ -881,6 +890,31 @@ export interface PluginsConfig {
};
}

export interface PluginConfig {
/**
* Prevent the plugin's native implementation from being registered and
* loaded on iOS and Android.
*
* A disabled plugin is not available to the app:
* `Capacitor.isPluginAvailable()` returns `false` and calls to its methods
* fail as unimplemented.
*
* This is different from the `enabled` option of `CapacitorHttp` and
* `CapacitorCookies`, which only controls the patching of `fetch`,
* `XMLHttpRequest` and `document.cookie`. `disabled: true` takes precedence
* over `enabled: true`.
*
* Plugins that declare their own configuration type don't list `disabled`,
* so TypeScript rejects it in `capacitor.config.ts`. Set it in
* `capacitor.config.json` instead, or cast the plugin's configuration, for
* example `SplashScreen: { disabled: true } as any`.
*
* @since 9.1.0
* @default false
*/
disabled?: boolean;
}

export interface PackageOptions {
/**
* Create a symlink to the plugin folder instead of pointing to the plugin path.
Expand Down