diff --git a/CHANGELOG.md b/CHANGELOG.md index c15963f..1ba9e60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Flutter + +#### Changed + +- Updated the internal handling of ExternalIdResult on Android (for `storeExternalId()` method) + ## [7.4.0] - 2026-02-10 - Android SDK version: 18.0.2 - iOS SDK version: 6.13.0 diff --git a/android/src/main/kotlin/com/aheaditec/freerasp/Extensions.kt b/android/src/main/kotlin/com/aheaditec/freerasp/Extensions.kt index ff4b0ee..a5e9a1b 100644 --- a/android/src/main/kotlin/com/aheaditec/freerasp/Extensions.kt +++ b/android/src/main/kotlin/com/aheaditec/freerasp/Extensions.kt @@ -3,6 +3,7 @@ package com.aheaditec.freerasp import android.content.Context import android.content.pm.PackageInfo import android.os.Build +import com.aheaditec.talsec_security.security.api.ExternalIdResult import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo import io.flutter.plugin.common.MethodChannel import com.aheaditec.freerasp.generated.PackageInfo as FlutterPackageInfo @@ -68,3 +69,17 @@ internal fun PackageInfo.getVersionString(): String { @Suppress("DEPRECATION") return versionCode.toString() } + +/** + * Resolves the result of a storeExternalId operation and sends it back to the Flutter side. + * If the [ExternalIdResult] is [ExternalIdResult.Success], it sends the result using success. + * If the [ExternalIdResult] is [ExternalIdResult.Error], it sends the result using error. + * + * @param result The [MethodChannel.Result] handler to send the result/error to. + */ +internal fun ExternalIdResult.resolve(result: MethodChannel.Result) { + when (this) { + is ExternalIdResult.Success -> result.success(null) + is ExternalIdResult.Error -> result.error("external-id-failure", this.errorMsg, null) + } +} diff --git a/android/src/main/kotlin/com/aheaditec/freerasp/handlers/MethodCallHandler.kt b/android/src/main/kotlin/com/aheaditec/freerasp/handlers/MethodCallHandler.kt index 7d740f4..7771e01 100644 --- a/android/src/main/kotlin/com/aheaditec/freerasp/handlers/MethodCallHandler.kt +++ b/android/src/main/kotlin/com/aheaditec/freerasp/handlers/MethodCallHandler.kt @@ -10,6 +10,7 @@ import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner import com.aheaditec.freerasp.Utils import com.aheaditec.freerasp.generated.TalsecPigeonApi +import com.aheaditec.freerasp.resolve import com.aheaditec.freerasp.runResultCatching import com.aheaditec.freerasp.toPigeon import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo @@ -216,8 +217,7 @@ internal class MethodCallHandler : MethodCallHandler, LifecycleEventObserver { runResultCatching(result) { context?.let { val data = call.argument("data") ?: throw NullPointerException("External ID data cannot be null.") - Talsec.storeExternalId(it, data) - result.success(null) + Talsec.storeExternalId(it, data).resolve(result) return@runResultCatching } throw IllegalStateException("Unable to store external ID - context is null")