Repository navigation
Conversation
|
Hi! What would be the purpose of a disallow list vs the allowlist functionality that ships today ( |
|
We currently rely on native code that uses Android's CookieManager, but the stored information is removed whenever the web application loads. As a result, we're looking for a way to block the loading of the core plugins (CapacitorCookies,CapacitorHttp ...) themselves. If you know of an alternative approach, I'd be glad to try it. |
|
@jtsnova — those plugins shouldn't load unless you explicitly enable them. Could you share your |
Bridge has a mechanism that registers the core plugins. This ensures they are always properly instantiated through the registerAllPlugins function, which unconditionally registers all of them and loads them into memory. What you mentioned about plugins only loading when explicitly enabled applies to third-party plugins, rather than the core plugins handled by Bridge. |
|
Thanks @jtsnova! We'd like to ship this in the next 9.x minor, so I pushed a few changes on top:
Notes for reviewers:
|
disabled already wins over enabled for registration and for patching fetch, XHR and document.cookie, but the HTTP interceptor still read only enabled, so with both set a page script could call the proxy directly. Also adds an iOS test for loading a disabled plugin by class name.
Description
Adds a
plugins.<PluginName>.disabledconfig option to prevent a native Capacitor plugin from being registered and loaded:The setting is read from the native
capacitor.config.jsongenerated bynpx cap sync.Bridge.registerPlugin()andBridge.registerPluginInstance()check the plugin configuration before creating aPluginHandle.CapacitorBridge.loadPlugin(type:)checks the configuration before loading, registering, and exporting the plugin to JavaScript.Change Type
Rationale / Problems Fixed
There is currently no runtime configuration mechanism to prevent an installed native plugin from loading. This makes it difficult to selectively disable a plugin while retaining it as a project dependency or while sharing configuration across builds.
disabledis intentionally separate fromenabled, because plugins such asCapacitorHttpandCapacitorCookiesalready useenabledwith plugin-specific behavior.Nothing changes unless
plugins.<PluginName>.disabledis set totrue. Plugins remain enabled by default.Tests or Reproductions
npm run build --workspace @capacitor/clicompletes successfully.plugins.<PluginName>.disabled.Platforms Affected
Notes / Comments
A disabled plugin is not registered, instantiated, loaded, or exported through the native bridge. Therefore, it is not exposed through native plugin headers and
Capacitor.isPluginAvailable('MyPlugin')returnsfalse.