Skip to content

Commit 73e4347

Browse files
authored
feat: improve handling of externalId response (#195)
1 parent efee676 commit 73e4347

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
### Flutter
11+
12+
#### Changed
13+
14+
- Updated the internal handling of ExternalIdResult on Android (for `storeExternalId()` method)
15+
816
## [7.4.0] - 2026-02-10
917
- Android SDK version: 18.0.2
1018
- iOS SDK version: 6.13.0

android/src/main/kotlin/com/aheaditec/freerasp/Extensions.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.aheaditec.freerasp
33
import android.content.Context
44
import android.content.pm.PackageInfo
55
import android.os.Build
6+
import com.aheaditec.talsec_security.security.api.ExternalIdResult
67
import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo
78
import io.flutter.plugin.common.MethodChannel
89
import com.aheaditec.freerasp.generated.PackageInfo as FlutterPackageInfo
@@ -68,3 +69,17 @@ internal fun PackageInfo.getVersionString(): String {
6869
@Suppress("DEPRECATION")
6970
return versionCode.toString()
7071
}
72+
73+
/**
74+
* Resolves the result of a storeExternalId operation and sends it back to the Flutter side.
75+
* If the [ExternalIdResult] is [ExternalIdResult.Success], it sends the result using success.
76+
* If the [ExternalIdResult] is [ExternalIdResult.Error], it sends the result using error.
77+
*
78+
* @param result The [MethodChannel.Result] handler to send the result/error to.
79+
*/
80+
internal fun ExternalIdResult.resolve(result: MethodChannel.Result) {
81+
when (this) {
82+
is ExternalIdResult.Success -> result.success(null)
83+
is ExternalIdResult.Error -> result.error("external-id-failure", this.errorMsg, null)
84+
}
85+
}

android/src/main/kotlin/com/aheaditec/freerasp/handlers/MethodCallHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.lifecycle.LifecycleEventObserver
1010
import androidx.lifecycle.LifecycleOwner
1111
import com.aheaditec.freerasp.Utils
1212
import com.aheaditec.freerasp.generated.TalsecPigeonApi
13+
import com.aheaditec.freerasp.resolve
1314
import com.aheaditec.freerasp.runResultCatching
1415
import com.aheaditec.freerasp.toPigeon
1516
import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo
@@ -216,8 +217,7 @@ internal class MethodCallHandler : MethodCallHandler, LifecycleEventObserver {
216217
runResultCatching(result) {
217218
context?.let {
218219
val data = call.argument<String>("data") ?: throw NullPointerException("External ID data cannot be null.")
219-
Talsec.storeExternalId(it, data)
220-
result.success(null)
220+
Talsec.storeExternalId(it, data).resolve(result)
221221
return@runResultCatching
222222
}
223223
throw IllegalStateException("Unable to store external ID - context is null")

0 commit comments

Comments
 (0)