improve plugin creation: add input sanitization, logging, and error handling
This commit is contained in:
parent
854dfef197
commit
ad9b15801b
4
.gitignore
vendored
4
.gitignore
vendored
@ -69,7 +69,6 @@ android/keystores/debug.keystore
|
||||
!.yarn/versions
|
||||
|
||||
# Expo
|
||||
.expo/
|
||||
|
||||
# Turborepo
|
||||
.turbo/
|
||||
@ -82,3 +81,6 @@ ios/generated
|
||||
android/generated
|
||||
|
||||
.env
|
||||
/package-lock.json
|
||||
/example/package-lock.json
|
||||
/example/Gemfile.lock
|
||||
|
||||
@ -1,19 +1,3 @@
|
||||
buildscript {
|
||||
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
||||
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["WebIdMetaPlugin_kotlinVersion"]
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:7.2.1"
|
||||
// noinspection DifferentKotlinGradleVersion
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
def reactNativeArchitectures() {
|
||||
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
||||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
||||
@ -26,10 +10,6 @@ def isNewArchitectureEnabled() {
|
||||
apply plugin: "com.android.library"
|
||||
apply plugin: "kotlin-android"
|
||||
|
||||
if (isNewArchitectureEnabled()) {
|
||||
apply plugin: "com.facebook.react"
|
||||
}
|
||||
|
||||
def getExtOrDefault(name) {
|
||||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["WebIdMetaPlugin_" + name]
|
||||
}
|
||||
@ -82,18 +62,35 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
|
||||
def kotlin_version = getExtOrDefault("kotlinVersion")
|
||||
|
||||
dependencies {
|
||||
// For < 0.71, this will be from the local maven repo
|
||||
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
||||
//noinspection GradleDynamicVersion
|
||||
implementation "com.facebook.react:react-native:+"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation "com.google.code.gson:gson:2.10.1"
|
||||
|
||||
implementation("com.facebook.react:react-android")
|
||||
def product_catalog_version = "15.1.1"
|
||||
|
||||
implementation ("de.webid-solutions:android_meta_plugin:$product_catalog_version") {
|
||||
changing = true
|
||||
}
|
||||
|
||||
implementation ("de.webid-solutions:android_auto_ident_on_server_product_plugin:$product_catalog_version") {
|
||||
changing = true
|
||||
}
|
||||
|
||||
implementation ("de.webid-solutions:android_pay_on_server_product_plugin:$product_catalog_version") {
|
||||
changing = true
|
||||
}
|
||||
|
||||
implementation ("de.webid-solutions:android_video_ident_product_plugin:$product_catalog_version") {
|
||||
changing = true
|
||||
}
|
||||
|
||||
implementation ("de.webid-solutions:android_eid_on_server_product_plugin:$product_catalog_version") {
|
||||
changing = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
WebIdMetaPlugin_kotlinVersion=1.7.0
|
||||
WebIdMetaPlugin_kotlinVersion=2.1.20
|
||||
WebIdMetaPlugin_minSdkVersion=21
|
||||
WebIdMetaPlugin_targetSdkVersion=31
|
||||
WebIdMetaPlugin_compileSdkVersion=31
|
||||
|
||||
11
android/settings.gradle
Normal file
11
android/settings.gradle
Normal file
@ -0,0 +1,11 @@
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
url 'https://api.webid-solutions.de/releases/android/maven/repository/internal'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,25 +1,227 @@
|
||||
package com.webidmetaplugin
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.facebook.react.bridge.Promise
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
||||
import com.facebook.react.bridge.ReactMethod
|
||||
import com.facebook.react.bridge.Promise
|
||||
import com.facebook.react.bridge.ReadableArray
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule
|
||||
import de.webidsolutions.auto_ident_on_server_product_plugin.AutoIdentOnServerProductPlugin
|
||||
import de.webidsolutions.eid_on_server_product_plugin.EIdOnServerProductPlugin
|
||||
import de.webidsolutions.meta_plugin.WebIdMetaPlugin
|
||||
import de.webidsolutions.mobile_app.sdk.WebIdSdkEnvironment
|
||||
import de.webidsolutions.pay_on_server_product_plugin.PayOnServerProductPlugin
|
||||
import de.webidsolutions.plugin_core.IEPluginError
|
||||
import de.webidsolutions.plugin_core.IProductPluginWebId
|
||||
import de.webidsolutions.video_ident.plugin.videocall.VideoOptionsConfig
|
||||
import de.webidsolutions.video_ident_product_plugin.VideoIdentProductPlugin
|
||||
import java.net.URI
|
||||
import com.facebook.react.bridge.UiThreadUtil
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
|
||||
class WebIdMetaPluginModule(reactContext: ReactApplicationContext) :
|
||||
ReactContextBaseJavaModule(reactContext) {
|
||||
private const val TAG = "WebIdMetaPlugin"
|
||||
|
||||
override fun getName(): String {
|
||||
return NAME
|
||||
class WebIdMetaPluginModule(
|
||||
private val reactContext: ReactApplicationContext
|
||||
) : ReactContextBaseJavaModule(reactContext) {
|
||||
|
||||
private var metaPlugin: WebIdMetaPlugin? = null
|
||||
|
||||
override fun getName() = "WebIdMetaPlugin"
|
||||
|
||||
private fun sendEvent(eventName: String, data: String) {
|
||||
reactContext
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
||||
.emit(eventName, data)
|
||||
}
|
||||
|
||||
// Example method
|
||||
// See https://reactnative.dev/docs/native-modules-android
|
||||
private var listenerCount = 0
|
||||
|
||||
@ReactMethod
|
||||
fun multiply(a: Double, b: Double, promise: Promise) {
|
||||
promise.resolve(a * b)
|
||||
fun addListener(eventName: String) {
|
||||
listenerCount += 1
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
fun removeListeners(count: Int) {
|
||||
listenerCount = (listenerCount - count).coerceAtLeast(0)
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
fun createMetaPlugin(
|
||||
uri: String,
|
||||
username: String,
|
||||
apiKey: String,
|
||||
shaPins: ReadableArray,
|
||||
plugins: ReadableArray,
|
||||
promise: Promise
|
||||
) {
|
||||
val cleanUri = uri.trim()
|
||||
val cleanUsername = username.trim()
|
||||
val cleanApiKey = apiKey.trim()
|
||||
|
||||
val shaPinsList = shaPins.toArrayList().map { it.toString() }
|
||||
val pluginsList = plugins.toArrayList().map { it.toString() }
|
||||
|
||||
Log.i(TAG, "createMetaPlugin plugins(raw) len=${pluginsList.size} values=$pluginsList")
|
||||
|
||||
try {
|
||||
val environment = WebIdSdkEnvironment(
|
||||
URI.create(cleanUri),
|
||||
*shaPinsList.toTypedArray()
|
||||
)
|
||||
|
||||
val selectedPlugins = ArrayList<IProductPluginWebId>()
|
||||
|
||||
pluginsList.forEach { p ->
|
||||
when (p) {
|
||||
"AutoIdOnServer" -> selectedPlugins.add(AutoIdentOnServerProductPlugin())
|
||||
"PayOnServer" -> selectedPlugins.add(PayOnServerProductPlugin())
|
||||
"VideoId" -> selectedPlugins.add(VideoIdentProductPlugin(config = VideoOptionsConfig()))
|
||||
"EIdOnServer" -> selectedPlugins.add(EIdOnServerProductPlugin())
|
||||
else -> Log.w(TAG, "createMetaPlugin unknown plugin string='$p'")
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG, "createMetaPlugin plugins(mapped) len=${selectedPlugins.size} classes=${selectedPlugins.map { it.javaClass.simpleName }}")
|
||||
|
||||
metaPlugin = WebIdMetaPlugin(
|
||||
environment,
|
||||
cleanUsername,
|
||||
cleanApiKey,
|
||||
reactApplicationContext,
|
||||
selectedPlugins
|
||||
)
|
||||
|
||||
promise.resolve("MetaPluginCreated")
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "createMetaPlugin failed: ${e.message}", e)
|
||||
promise.reject("CREATE_ERROR", e.message, e)
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
fun verifyActionId(actionId: String, promise: Promise) {
|
||||
Log.i(TAG, "verifyActionId() called actionId=$actionId")
|
||||
|
||||
try {
|
||||
val plugin = metaPlugin
|
||||
if (plugin == null) {
|
||||
Log.w(TAG, "verifyActionId() blocked: SDK_NOT_INITIALIZED")
|
||||
promise.reject("SDK_NOT_INITIALIZED", "MetaPlugin not created. Call createMetaPlugin() first.")
|
||||
return
|
||||
}
|
||||
|
||||
val result = plugin.verify(actionId)
|
||||
|
||||
val json = Gson().toJson(result)
|
||||
Log.i(TAG, "verifyActionId() success, jsonLen=${json.length}")
|
||||
|
||||
promise.resolve(json)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "verifyActionId() failed: ${e.message}", e)
|
||||
promise.reject("VERIFY_ERROR", e.message, e)
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
fun start(promise: Promise) {
|
||||
val activity = reactApplicationContext.currentActivity
|
||||
|
||||
if (activity !is FragmentActivity) {
|
||||
promise.reject("NO_ACTIVITY", "Current activity is not a FragmentActivity")
|
||||
return
|
||||
}
|
||||
|
||||
val plugin = metaPlugin
|
||||
if (plugin == null) {
|
||||
promise.reject("SDK_NOT_INITIALIZED", "MetaPlugin not created. Call createMetaPlugin() first.")
|
||||
return
|
||||
}
|
||||
|
||||
UiThreadUtil.runOnUiThread {
|
||||
try {
|
||||
val fragment = WebIdResultHostFragment.getOrCreate(
|
||||
activity = activity,
|
||||
onResult = { resultCode, data ->
|
||||
try {
|
||||
val result = data?.let {
|
||||
IProductPluginWebId.getProductPluginResult<IEPluginError>(it, resultCode)
|
||||
}
|
||||
|
||||
if (result?.error == null) {
|
||||
sendEvent("WebIdSdkEvent.finishedSuccess", result?.info ?: "")
|
||||
} else {
|
||||
sendEvent("WebIdSdkEvent.finishedFailed", result.error.toString())
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
sendEvent("WebIdSdkEvent.finishedFailed", e.message ?: "Unknown")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
val customTheme: Int? = null
|
||||
|
||||
plugin.startPlugin(
|
||||
activity,
|
||||
fragment.launcher,
|
||||
customTheme
|
||||
)
|
||||
|
||||
promise.resolve("PluginStarted")
|
||||
} catch (e: Exception) {
|
||||
promise.reject("START_ERROR", e.message, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WebIdResultHostFragment : Fragment() {
|
||||
|
||||
private var onResult: ((resultCode: Int, data: Intent?) -> Unit)? = null
|
||||
|
||||
lateinit var launcher: ActivityResultLauncher<Intent>
|
||||
private set
|
||||
|
||||
override fun onCreate(savedInstanceState: android.os.Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
launcher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
onResult?.invoke(result.resultCode, result.data)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val NAME = "WebIdMetaPlugin"
|
||||
private const val TAG = "WebIdResultHostFragment"
|
||||
|
||||
fun getOrCreate(
|
||||
activity: FragmentActivity,
|
||||
onResult: (resultCode: Int, data: Intent?) -> Unit
|
||||
): WebIdResultHostFragment {
|
||||
val fm = activity.supportFragmentManager
|
||||
|
||||
val existing = fm.findFragmentByTag(TAG) as? WebIdResultHostFragment
|
||||
if (existing != null) {
|
||||
existing.onResult = onResult
|
||||
return existing
|
||||
}
|
||||
|
||||
val fragment = WebIdResultHostFragment().apply {
|
||||
this.onResult = onResult
|
||||
}
|
||||
|
||||
fm.beginTransaction()
|
||||
.add(fragment, TAG)
|
||||
.commitNowAllowingStateLoss()
|
||||
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,11 +7,9 @@ import com.facebook.react.uimanager.ViewManager
|
||||
|
||||
|
||||
class WebIdMetaPluginPackage : ReactPackage {
|
||||
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
||||
return listOf(WebIdMetaPluginModule(reactContext))
|
||||
}
|
||||
override fun createNativeModules(reactContext: ReactApplicationContext)
|
||||
= listOf(WebIdMetaPluginModule(reactContext))
|
||||
|
||||
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
||||
return emptyList()
|
||||
}
|
||||
override fun createViewManagers(reactContext: ReactApplicationContext)
|
||||
= emptyList<ViewManager<*, *>>()
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
apply plugin: "com.android.application"
|
||||
apply plugin: "org.jetbrains.kotlin.android"
|
||||
apply plugin: "com.facebook.react"
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("com.facebook.react")
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the configuration block to customize your React Native Android app.
|
||||
@ -75,7 +77,8 @@ def jscFlavor = 'org.webkit:android-jsc:+'
|
||||
android {
|
||||
ndkVersion rootProject.ext.ndkVersion
|
||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||
compileSdk rootProject.ext.compileSdkVersion
|
||||
compileSdk 35
|
||||
|
||||
|
||||
namespace "webidmetaplugin.example"
|
||||
defaultConfig {
|
||||
@ -84,6 +87,8 @@ android {
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", (project.hasProperty("newArchEnabled") ? project.getProperty("newArchEnabled") : "false")
|
||||
|
||||
}
|
||||
signingConfigs {
|
||||
debug {
|
||||
|
||||
@ -4,6 +4,7 @@ import com.facebook.react.ReactActivity
|
||||
import com.facebook.react.ReactActivityDelegate
|
||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
||||
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
||||
|
||||
class MainActivity : ReactActivity() {
|
||||
|
||||
@ -18,5 +19,5 @@ class MainActivity : ReactActivity() {
|
||||
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
||||
*/
|
||||
override fun createReactActivityDelegate(): ReactActivityDelegate =
|
||||
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
|
||||
DefaultReactActivityDelegate(this, mainComponentName, false)
|
||||
}
|
||||
|
||||
@ -9,7 +9,10 @@ import com.facebook.react.ReactPackage
|
||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
|
||||
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
||||
import com.facebook.react.defaults.DefaultReactNativeHost
|
||||
import com.facebook.react.soloader.OpenSourceMergedSoMapping
|
||||
import com.facebook.soloader.SoLoader
|
||||
import com.webidmetaplugin.WebIdMetaPluginPackage
|
||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
|
||||
|
||||
class MainApplication : Application(), ReactApplication {
|
||||
|
||||
@ -17,16 +20,16 @@ class MainApplication : Application(), ReactApplication {
|
||||
object : DefaultReactNativeHost(this) {
|
||||
override fun getPackages(): List<ReactPackage> =
|
||||
PackageList(this).packages.apply {
|
||||
// Packages that cannot be autolinked yet can be added manually here, for example:
|
||||
// add(MyReactNativePackage())
|
||||
add(WebIdMetaPluginPackage())
|
||||
}
|
||||
|
||||
override fun getJSMainModuleName(): String = "index"
|
||||
|
||||
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
||||
|
||||
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
||||
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
|
||||
|
||||
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
||||
}
|
||||
|
||||
override val reactHost: ReactHost
|
||||
@ -34,9 +37,8 @@ class MainApplication : Application(), ReactApplication {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
SoLoader.init(this, false)
|
||||
SoLoader.init(this, OpenSourceMergedSoMapping)
|
||||
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
||||
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
||||
load()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,20 @@
|
||||
buildscript {
|
||||
ext {
|
||||
buildToolsVersion = "34.0.0"
|
||||
minSdkVersion = 23
|
||||
compileSdkVersion = 34
|
||||
targetSdkVersion = 34
|
||||
buildToolsVersion = "35.0.0"
|
||||
minSdkVersion = 28
|
||||
compileSdkVersion = 35
|
||||
targetSdkVersion = 35
|
||||
ndkVersion = "26.1.10909125"
|
||||
kotlinVersion = "1.9.24"
|
||||
kotlinVersion = "2.1.20"
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle")
|
||||
classpath("com.facebook.react:react-native-gradle-plugin")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
|
||||
classpath("com.android.tools.build:gradle:8.6.0")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.20")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "com.facebook.react.rootproject"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@ -1,6 +1,43 @@
|
||||
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
|
||||
plugins { id("com.facebook.react.settings") }
|
||||
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
|
||||
rootProject.name = 'webidmetaplugin.example'
|
||||
include ':app'
|
||||
includeBuild('../node_modules/@react-native/gradle-plugin')
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "org.jetbrains.kotlin.android") {
|
||||
useVersion("2.1.20")
|
||||
}
|
||||
if (requested.id.id == "org.jetbrains.kotlin.jvm") {
|
||||
useVersion("2.1.20")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
includeBuild("../node_modules/@react-native/gradle-plugin")
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.facebook.react.settings")
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
url 'https://api.webid-solutions.de/releases/android/maven/repository/internal'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
|
||||
ex.autolinkLibrariesFromCommand()
|
||||
}
|
||||
|
||||
rootProject.name = "webidmetaplugin.example"
|
||||
include(":app")
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
4058D6922F19726100498E39 /* WebIdVideoIdentProductPlugin.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 48F71C442C80D0DF00BD6B5D /* WebIdVideoIdentProductPlugin.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
6DE0A3D7B22BC1FF2E727057 /* libPods-WebIdMetaPluginExample-WebIdMetaPluginExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4685DC1BED0D20ECAC1ED4EC /* libPods-WebIdMetaPluginExample-WebIdMetaPluginExampleTests.a */; };
|
||||
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
|
||||
B5ABC6AE66EFC36DA14A4175 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 3A271875C9F09281B4786E72 /* PrivacyInfo.xcprivacy */; };
|
||||
C88BC4EF9171E4119C4DE09A /* libPods-WebIdMetaPluginExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A790AFDC34C073FF67478665 /* libPods-WebIdMetaPluginExample.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@ -106,6 +107,7 @@
|
||||
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = WebIdMetaPluginExample/Images.xcassets; sourceTree = "<group>"; };
|
||||
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = WebIdMetaPluginExample/Info.plist; sourceTree = "<group>"; };
|
||||
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = WebIdMetaPluginExample/main.m; sourceTree = "<group>"; };
|
||||
3A271875C9F09281B4786E72 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = WebIdMetaPluginExample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
|
||||
40A7A7232F18352D00A4B1CE /* WebIdAutoIdentOnServerProductPlugin.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = WebIdAutoIdentOnServerProductPlugin.xcframework; path = Pods/WebIdAutoIdentOnServerProductPlugin/WebIdAutoIdentOnServerProductPlugin.xcframework; sourceTree = "<group>"; };
|
||||
40A7A7262F1835A400A4B1CE /* WebIdEIdOnServerProductPlugin.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = WebIdEIdOnServerProductPlugin.xcframework; path = Pods/WebIdEIdOnServerProductPlugin/WebIdEIdOnServerProductPlugin.xcframework; sourceTree = "<group>"; };
|
||||
40A7A7292F1835B400A4B1CE /* WebIdEIdentPlugin.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = WebIdEIdentPlugin.xcframework; path = Pods/WebIdEIdentPlugin/WebIdEIdentPlugin.xcframework; sourceTree = "<group>"; };
|
||||
@ -206,6 +208,7 @@
|
||||
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
|
||||
13B07FB71A68108700A75B9A /* main.m */,
|
||||
EF15005B197F2F6F6438D520 /* PrivacyInfo.xcprivacy */,
|
||||
3A271875C9F09281B4786E72 /* PrivacyInfo.xcprivacy */,
|
||||
);
|
||||
name = WebIdMetaPluginExample;
|
||||
sourceTree = "<group>";
|
||||
@ -377,6 +380,7 @@
|
||||
files = (
|
||||
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
|
||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
|
||||
B5ABC6AE66EFC36DA14A4175 /* PrivacyInfo.xcprivacy in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -733,7 +737,10 @@
|
||||
"-DFOLLY_CFG_NO_COROUTINES=1",
|
||||
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
|
||||
);
|
||||
OTHER_LDFLAGS = "$(inherited) ";
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
" ",
|
||||
);
|
||||
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
|
||||
@ -817,7 +824,10 @@
|
||||
"-DFOLLY_CFG_NO_COROUTINES=1",
|
||||
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
|
||||
);
|
||||
OTHER_LDFLAGS = "$(inherited) ";
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
" ",
|
||||
);
|
||||
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
|
||||
SDKROOT = iphoneos;
|
||||
USE_HERMES = true;
|
||||
|
||||
@ -10,17 +10,18 @@
|
||||
"build:ios": "react-native build-ios --scheme WebIdMetaPluginExample --mode Debug --extra-params \"-sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO\""
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "18.3.1",
|
||||
"react-native": "0.75.2",
|
||||
"react-native-bouncy-checkbox": "^4.1.4"
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3",
|
||||
"react-native": "0.84.0",
|
||||
"react-native-web-id-meta-plugin": "file:.."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.20.0",
|
||||
"@babel/preset-env": "^7.20.0",
|
||||
"@babel/runtime": "^7.20.0",
|
||||
"@react-native/babel-preset": "0.75.2",
|
||||
"@react-native/metro-config": "0.75.2",
|
||||
"@react-native/typescript-config": "0.75.2",
|
||||
"@react-native/babel-preset": "0.84.0",
|
||||
"@react-native/metro-config": "0.84.0",
|
||||
"@react-native/typescript-config": "0.84.0",
|
||||
"react-native-builder-bob": "^0.30.0",
|
||||
"react-native-dotenv": "^3.4.9"
|
||||
},
|
||||
|
||||
@ -25,11 +25,20 @@ import BouncyCheckbox from 'react-native-bouncy-checkbox';
|
||||
|
||||
export default function App() {
|
||||
const [actionId, onChangeActionId] = React.useState('');
|
||||
var selectedPlugins: Set<string> = new Set();
|
||||
|
||||
const [selectedPlugins, setSelectedPlugins] = React.useState<string[]>([]);
|
||||
|
||||
const togglePlugin = (name: string, isChecked: boolean) => {
|
||||
setSelectedPlugins((prev) => {
|
||||
const next = new Set(prev);
|
||||
if (isChecked) next.add(name);
|
||||
else next.delete(name);
|
||||
return Array.from(next);
|
||||
});
|
||||
};
|
||||
webIdEventEmitter.addListener(WebIdSdkEvent.finishedFailed, (eventData) => {
|
||||
let result = parseJSONToType<ProductPluginResultFailed>(eventData);
|
||||
if (result != undefined) {
|
||||
if (result !== undefined) {
|
||||
console.log(
|
||||
'received failed event with result code: ',
|
||||
result.genericResultCode
|
||||
@ -39,7 +48,7 @@ export default function App() {
|
||||
|
||||
webIdEventEmitter.addListener(WebIdSdkEvent.finishedSuccess, (eventData) => {
|
||||
let result = parseJSONToType<ProductPluginResultSuccess>(eventData);
|
||||
if (result != undefined) {
|
||||
if (result !== undefined) {
|
||||
console.log(
|
||||
'received failed event with process finished: ',
|
||||
result.processFinished
|
||||
@ -63,13 +72,7 @@ export default function App() {
|
||||
};
|
||||
|
||||
const onCreateMetaPlugin = () => {
|
||||
createMetaPlugin(
|
||||
URL,
|
||||
USERNAME,
|
||||
API_KEY,
|
||||
[CERT_BASE64],
|
||||
Array.from(selectedPlugins)
|
||||
)
|
||||
createMetaPlugin(URL, USERNAME, API_KEY, [CERT_BASE64], selectedPlugins)
|
||||
.then((data) => {
|
||||
showAlert('Success', data);
|
||||
})
|
||||
@ -125,44 +128,36 @@ export default function App() {
|
||||
<View>
|
||||
<View>
|
||||
<BouncyCheckbox
|
||||
isChecked={selectedPlugins.has('AutoIdOnServer')}
|
||||
isChecked={selectedPlugins.includes('AutoIdOnServer')}
|
||||
onPress={(isChecked: boolean) =>
|
||||
isChecked === true
|
||||
? selectedPlugins.add('AutoIdOnServer')
|
||||
: selectedPlugins.delete('AutoIdOnServer')
|
||||
togglePlugin('AutoIdOnServer', isChecked)
|
||||
}
|
||||
/>
|
||||
<Text>AutoIdOnServer</Text>
|
||||
</View>
|
||||
<View>
|
||||
<BouncyCheckbox
|
||||
isChecked={selectedPlugins.has('PayOnServer')}
|
||||
isChecked={selectedPlugins.includes('PayOnServer')}
|
||||
onPress={(isChecked: boolean) =>
|
||||
isChecked === true
|
||||
? selectedPlugins.add('PayOnServer')
|
||||
: selectedPlugins.delete('PayOnServer')
|
||||
togglePlugin('PayOnServer', isChecked)
|
||||
}
|
||||
/>
|
||||
<Text>PayOnServer</Text>
|
||||
</View>
|
||||
<View>
|
||||
<BouncyCheckbox
|
||||
isChecked={selectedPlugins.has('VideoId')}
|
||||
isChecked={selectedPlugins.includes('VideoId')}
|
||||
onPress={(isChecked: boolean) =>
|
||||
isChecked === true
|
||||
? selectedPlugins.add('VideoId')
|
||||
: selectedPlugins.delete('VideoId')
|
||||
togglePlugin('VideoId', isChecked)
|
||||
}
|
||||
/>
|
||||
<Text>VideoId</Text>
|
||||
</View>
|
||||
<View>
|
||||
<BouncyCheckbox
|
||||
isChecked={selectedPlugins.has('EIdOnServer')}
|
||||
isChecked={selectedPlugins.includes('EIdOnServer')}
|
||||
onPress={(isChecked: boolean) =>
|
||||
isChecked === true
|
||||
? selectedPlugins.add('EIdOnServer')
|
||||
: selectedPlugins.delete('EIdOnServer')
|
||||
togglePlugin('EIdOnServer', isChecked)
|
||||
}
|
||||
/>
|
||||
<Text>EIdOnServer</Text>
|
||||
|
||||
22
package.json
22
package.json
@ -7,6 +7,10 @@
|
||||
"module": "./lib/module/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"react-native": {
|
||||
"types": "./src/index.tsx",
|
||||
"default": "./src/index.tsx"
|
||||
},
|
||||
"import": {
|
||||
"types": "./lib/typescript/module/src/index.d.ts",
|
||||
"default": "./lib/module/index.js"
|
||||
@ -65,19 +69,21 @@
|
||||
"devDependencies": {
|
||||
"@commitlint/config-conventional": "^17.0.2",
|
||||
"@evilmartians/lefthook": "^1.5.0",
|
||||
"@react-native/eslint-config": "^0.73.1",
|
||||
"@react-native-community/cli": "latest",
|
||||
"@react-native/eslint-config": "^0.84.0",
|
||||
"@release-it/conventional-changelog": "^5.0.0",
|
||||
"@types/jest": "^29.5.5",
|
||||
"@types/react": "^18.2.44",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"commitlint": "^17.0.2",
|
||||
"del-cli": "^5.1.0",
|
||||
"eslint": "^8.51.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"eslint-config-prettier": "^9.1.2",
|
||||
"eslint-plugin-prettier": "^5.5.5",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.0.3",
|
||||
"react": "18.3.1",
|
||||
"react-native": "0.75.2",
|
||||
"prettier": "^3.8.1",
|
||||
"react": "^19.2.4",
|
||||
"react-native": "0.84.0",
|
||||
"react-native-builder-bob": "^0.30.0",
|
||||
"release-it": "^15.0.0",
|
||||
"turbo": "^1.10.7",
|
||||
@ -129,6 +135,7 @@
|
||||
"@react-native",
|
||||
"prettier"
|
||||
],
|
||||
"plugins": ["prettier"],
|
||||
"rules": {
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"prettier/prettier": [
|
||||
@ -185,6 +192,7 @@
|
||||
"version": "0.41.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-dom": "^19.2.4",
|
||||
"react-native-bouncy-checkbox": "^4.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,9 @@ const WebIdMetaPlugin = NativeModules.WebIdMetaPlugin
|
||||
}
|
||||
);
|
||||
|
||||
export const webIdEventEmitter = new NativeEventEmitter(WebIdMetaPlugin);
|
||||
export const webIdEventEmitter = new NativeEventEmitter(
|
||||
Platform.OS === 'android' ? undefined : WebIdMetaPlugin
|
||||
);
|
||||
|
||||
export function createMetaPlugin(
|
||||
uri: string,
|
||||
@ -40,7 +42,7 @@ export function verifyActionId(actionId: string): Promise<VerifyActionResult> {
|
||||
try {
|
||||
const json = await WebIdMetaPlugin.verifyActionId(actionId);
|
||||
let verifyActionResult = parseJSONToType<VerifyActionResult>(json);
|
||||
if (verifyActionId != undefined) {
|
||||
if (verifyActionId !== undefined) {
|
||||
resolve(verifyActionResult!);
|
||||
} else {
|
||||
reject('JSON parsing failed');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user