8
0
This commit is contained in:
andre 2026-02-12 16:47:18 +01:00
parent 854dfef197
commit c47bf91d62
16 changed files with 2236 additions and 1143 deletions

View File

@ -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,33 @@ 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.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
}
}

View File

@ -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
View 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'
}
}
}

View File

@ -1,25 +1,197 @@
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
class WebIdMetaPluginModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
class WebIdMetaPluginModule(
private val reactContext: ReactApplicationContext
) : ReactContextBaseJavaModule(reactContext) {
override fun getName(): String {
return NAME
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
// ------------------------------------------------
// CREATE
// ------------------------------------------------
@ReactMethod
fun multiply(a: Double, b: Double, promise: Promise) {
promise.resolve(a * b)
fun createMetaPlugin(
uri: String,
username: String,
apiKey: String,
shaPins: ReadableArray,
plugins: ReadableArray,
promise: Promise
) {
try {
val environment = WebIdSdkEnvironment(
URI.create(uri),
*shaPins.toArrayList().map { it.toString() }.toTypedArray()
)
val selectedPlugins = ArrayList<de.webidsolutions.plugin_core.IProductPluginWebId>()
plugins.toArrayList().forEach {
when (it.toString()) {
"AutoIdOnServer" -> selectedPlugins.add(AutoIdentOnServerProductPlugin())
"PayOnServer" -> selectedPlugins.add(PayOnServerProductPlugin())
"VideoId" -> selectedPlugins.add(VideoIdentProductPlugin(config = VideoOptionsConfig()))
"EIdOnServer" -> selectedPlugins.add(EIdOnServerProductPlugin())
}
}
metaPlugin = WebIdMetaPlugin(
environment,
username,
apiKey,
reactApplicationContext,
selectedPlugins
)
promise.resolve("MetaPluginCreated")
} catch (e: Exception) {
promise.reject("CREATE_ERROR", e.message)
}
}
companion object {
const val NAME = "WebIdMetaPlugin"
// ------------------------------------------------
// VERIFY
// ------------------------------------------------
@ReactMethod
fun verifyActionId(actionId: String, promise: Promise) {
try {
val result = metaPlugin?.verify(actionId)
promise.resolve(result.toString())
} catch (e: Exception) {
promise.reject("VERIFY_ERROR", e.message)
}
}
// ------------------------------------------------
// START (needs ActivityResultLauncher)
// ------------------------------------------------
@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
}
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)
}
}
// ------------------------------------------------
// Helper fragment
// ------------------------------------------------
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 {
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
}
}
}
}

View File

@ -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<*, *>>()
}

View File

@ -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,15 +77,18 @@ def jscFlavor = 'org.webkit:android-jsc:+'
android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
compileSdk 35
namespace "webidmetaplugin.example"
namespace "webidmetaplugin.example"
defaultConfig {
applicationId "webidmetaplugin.example"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", (project.hasProperty("newArchEnabled") ? project.getProperty("newArchEnabled") : "false")
}
signingConfigs {
debug {

View File

@ -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() {

View File

@ -9,34 +9,34 @@ 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 {
override val reactNativeHost: ReactNativeHost =
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())
}
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
add(WebIdMetaPluginPackage())
}
override fun getJSMainModuleName(): String = "index"
override fun getJSMainModuleName(): String = "index"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
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 isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)
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()
}
}

View File

@ -1,21 +1,27 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.24"
}
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")
}
}
ext {
buildToolsVersion = "35.0.0"
minSdkVersion = 28
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "26.1.10909125"
kotlinVersion = "2.1.20"
}
apply plugin: "com.facebook.react.rootproject"
repositories {
google()
mavenCentral()
}
configurations.classpath {
resolutionStrategy {
force("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
force("org.jetbrains.kotlin:kotlin-gradle-plugin-api:${kotlinVersion}")
}
}
dependencies {
classpath("com.android.tools.build:gradle:8.6.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
}
}

View File

@ -32,7 +32,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
newArchEnabled=true
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.

View File

@ -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

View File

@ -1,6 +1,40 @@
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()
}
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")
includeBuild("../node_modules/@react-native/gradle-plugin")
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
ex.autolinkLibrariesFromCommand()
}
rootProject.name = "webidmetaplugin.example"
include(":app")
includeBuild("../node_modules/@react-native/gradle-plugin")

View File

@ -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;

View File

@ -11,16 +11,15 @@
},
"dependencies": {
"react": "18.3.1",
"react-native": "0.75.2",
"react-native-bouncy-checkbox": "^4.1.4"
"react-native": "0.84.0"
},
"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"
},

View File

@ -65,7 +65,8 @@
"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",
@ -77,7 +78,7 @@
"jest": "^29.7.0",
"prettier": "^3.0.3",
"react": "18.3.1",
"react-native": "0.75.2",
"react-native": "0.84.0",
"react-native-builder-bob": "^0.30.0",
"release-it": "^15.0.0",
"turbo": "^1.10.7",

2949
yarn.lock

File diff suppressed because it is too large Load Diff