<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
        xmlns:android="http://schemas.android.com/apk/res/android"
        id="cordova-plugin-msal" version="4.1.2">
    <name>Cordova MSAL Plugin</name>
    <description>A Cordova plugin providing a wrapper for Microsoft's MSAL library for Android and iOS.</description>
    <author>Walter Robins</author>
    <keywords>cordova,android,outsystems,ios,microsoft,msal,azure,graphapi,authentication</keywords>
    <license>Apache 2.0</license>
    <repo>https://github.com/wrobins/cordova-plugin-msal.git</repo>
    <issue>https://github.com/wrobins/cordova-plugin-msal/issues</issue>
    <engines>
        <engine name="cordova-android" version=">=9.0.0"/>
        <engine name="cordova-ios" version=">=6.1.1"/>
        <engine name="cordova-browser" version=">=6.0.0"/>
    </engines> 
    <js-module src="www/msalplugin.js" name="msalPlugin">
        <clobbers target="cordova.plugins.msalPlugin" />
    </js-module>
    <preference name="KEY_HASH" default="not-provided" />
    <platform name="android">
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="MsalPlugin">
                <param name="android-package" value="com.wrobins.cordova.plugin.MsalPlugin" />
                <preference name="keyHash" value="$KEY_HASH" />
            </feature>
        </config-file>
        <config-file target="AndroidManifest.xml" parent="/*">
            <uses-permission android:name="android.permission.INTERNET "/>
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE "/>
        </config-file>
        <config-file target="AndroidManifest.xml" parent="application">
            <activity android:exported="true"
                android:name="com.microsoft.identity.client.BrowserTabActivity">
                <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <data
                        android:scheme="msauth"
                        android:host="$PACKAGE_NAME"
                        android:path="/$KEY_HASH" />
                </intent-filter>
            </activity>
        </config-file>
        <config-file target="config.xml" parent="/*">
            <preference name="AndroidXEnabled" value="true" />
        </config-file>
        <source-file src="src/android/MsalPlugin.java" target-dir="src/com/wrobins/cordova/plugin" />
        <framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />
        <framework src="com.microsoft.identity.client:msal:5.10.0" />
    </platform>
    <platform name="ios">
        <config-file target="config.xml" parent="/*">
            <feature name="MsalPlugin">
                <param name="ios-package" value="MsalPlugin" />
                <param name="onload" value="true" />
            </feature>
            <feature name="">
                <param name="ios-package" value="" />
            </feature>
            <feature name="MSALPublicClientApplication">
                <param name="ios-package" value="MSALPublicClientApplication" />
            </feature>
            <feature name="MSALPublicClientApplicationConfig">
                <param name="ios-package" value="MSALPublicClientApplicationConfig" />
            </feature>
            <feature name="MSALAccount">
                <param name="ios-package" value="MSALAccount" />
            </feature>
            <feature name="MSALSilentTokenParameters">
                <param name="ios-package" value="MSALSilentTokenParameters" />
            </feature>
            <feature name="MSALResult">
                <param name="ios-package" value="MSALResult" />
            </feature>
            <feature name="MSALWebviewParameters">
                <param name="ios-package" value="MSALWebviewParameters" />
            </feature>
            <feature name="MSALInteractiveTokenParameters">
                <param name="ios-package" value="MSALInteractiveTokenParameters" />
            </feature>
            <feature name="MSALError">
                <param name="ios-package" value="MSALError" />
            </feature>
        </config-file>
        <podspec>
            <config>
                <source url="https://cdn.cocoapods.org/"/>
            </config>
            <pods use_frameworks="true">
                <pod name="MSAL" />
            </pods>
        </podspec>
        <config-file target="*-Info.plist" parent="CFBundleURLTypes">
            <array>
                <dict>
                    <key>CFBundleURLSchemes</key>
                    <array>
                        <string>msauth.$PACKAGE_NAME</string>
                    </array>
                </dict>
            </array>
        </config-file>
        <config-file target="*-Info.plist" parent="LSApplicationQueriesSchemes">
            <array>
                <string>msauthv2</string>
                <string>msauthv3</string>
            </array>
        </config-file>
        <config-file parent="keychain-access-groups" target="*/Entitlements-Debug.plist">
            <array>
                <string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
            </array>
        </config-file>
        <config-file parent="keychain-access-groups" target="*/Entitlements-Release.plist">
            <array>
                <string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
            </array>
        </config-file>
        <header-file src="src/ios/MsalPlugin.h" />
        <header-file src="src/ios/AppDelegate+MsalCallback.h" />
        <source-file src="src/ios/MsalPlugin.m" />
        <source-file src="src/ios/AppDelegate+MsalCallback.m" />
    </platform>
    <platform name="browser">
        <config-file target="config.xml" parent="/*">
          <feature name="MsalPlugin">
            <param name="browser-package" value="MsalPlugin" />
          </feature>
        </config-file>
        <js-module src="src/browser/msal-browser.min.js" name="Msal">
            <merges target="msal" />
        </js-module>
        <js-module src="src/browser/MsalProxy.js" name="MsalProxy">
          <runs />
        </js-module>
      </platform>
</plugin>
