0.3.1 • Published 1 year ago

capacitor-plugin-xframe v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

capacitor-plugin-xframe

Capacitor plugin to bypass CORS & same origin policy for iframe.

Important note

This plugin overrides the shouldInterceptRequest behavior of your webview.

As the core purpose of this plugin, shouldInterceptRequest needs to be leveraged to determine the outgoing requests and eliminate the X-Frame-Options and Content-Security-Policy headers present on the incoming responses for them to work in the embeded iframes.

Supported platforms

  • Android

Install

npm install capacitor-plugin-xframe
npx cap sync

Config options

Add these options in either capacitor.config.json or capacitor.config.ts.

userAgent

Customize the outgoing requests' User-Agent header. Useful to modify the resulted responses.

{
  ...
  "plugins": {
    "Xframe": {
      "userAgent": "<your_custom_user_agent>"
    }
  }
}

ignore

A list of domains/URLs to ignore from intercepting.

{
  ...
  "plugins": {
    "Xframe": {
      "ignore": ["google.com", "https://www.facebook.com"]
    }
  }
}

API

register()

register() => Promise<void>

Registers the plugin to your app.

Registering this plugin will override the shouldInterceptRequest behavior of your webview.


addListener('onLoad', ...)

addListener(eventName: 'onLoad', listener: LoadEventListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listens to requests of document type and returns some useful information.

ParamType
eventName'onLoad'
listenerLoadEventListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('onError', ...)

addListener(eventName: 'onError', listener: ErrorEventListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listens to failed requests (of any type)

ParamType
eventName'onError'
listenerErrorEventListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

PluginListenerHandle

PropType
remove() => Promise<void>

LoadEventData

PropType
urlstring
titlestring
faviconstring

ErrorEventData

PropType
urlstring
statusCodenumber
messagestring

Type Aliases

LoadEventListener

(eventData: LoadEventData): void

ErrorEventListener

(eventData: ErrorEventData): void