Skip to content

Commit 6b4f899

Browse files
committed
Merge branch 'develop'
2 parents 7d1d6e8 + 97f41fe commit 6b4f899

File tree

20 files changed

+419
-31
lines changed

20 files changed

+419
-31
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.0.13
2+
1.0.13
3+
* Fix: Aligned SSO cancellation error Android/iOS
4+
* Fix: Missing link account v2 error support.
5+
* Feature: Added Custom Identifier login support.
6+
17
# 1.0.12
28
1.0.12
39
* Fix: Android SDK Wrapper nullable "reason" in screen-set onHide callback.

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ buildscript {
1010
repositories {
1111
google()
1212
mavenCentral()
13+
mavenLocal()
1314
}
1415

1516
dependencies {

android/src/main/kotlin/com/sap/gigya_flutter_plugin/GigyaFlutterPlugin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class GigyaFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, Scre
105105
"biometricLockSession" -> sdk.biometricLockSession(result)
106106
"biometricUnlockSession" -> sdk.biometricUnlockSession (call.arguments, result)
107107
"getAuthCode" -> sdk.getAuthCode(result)
108+
"loginWithCustomIdentifier" -> sdk.loginWithCustomIdentifier(call.arguments, result)
108109
else -> result.notImplemented()
109110
}
110111
}

android/src/main/kotlin/com/sap/gigya_flutter_plugin/GigyaSDKWrapper.kt

Lines changed: 91 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ import com.gigya.android.sdk.ui.plugin.IGigyaWebBridge
2828
import com.gigya.android.sdk.utils.CustomGSONDeserializer
2929
import com.google.gson.GsonBuilder
3030
import com.google.gson.reflect.TypeToken
31+
import com.sap.gigya_flutter_plugin.GigyaSDKWrapper.Companion.BIOMETRIC_RECOGNITION_FAILED
32+
import com.sap.gigya_flutter_plugin.GigyaSDKWrapper.Companion.CANCELED_ERROR
33+
import com.sap.gigya_flutter_plugin.GigyaSDKWrapper.Companion.CANCELED_ERROR_MESSAGE
34+
import com.sap.gigya_flutter_plugin.GigyaSDKWrapper.Companion.GENERAL_ERROR
35+
import com.sap.gigya_flutter_plugin.GigyaSDKWrapper.Companion.MISSING_PARAMETER_ERROR
36+
import com.sap.gigya_flutter_plugin.GigyaSDKWrapper.Companion.MISSING_PARAMETER_MESSAGE
3137
import io.flutter.plugin.common.MethodChannel
3238
import java.lang.ref.WeakReference
3339
import java.util.*
@@ -229,6 +235,76 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
229235
})
230236
}
231237

238+
/**
239+
* Login using custom identifier (identifier/identifierType/password combination with optional parameter map).
240+
*/
241+
fun loginWithCustomIdentifier(arguments: Any, channelResult: MethodChannel.Result) {
242+
currentResult = channelResult
243+
val identifier: String? = (arguments as Map<*, *>)["identifier"] as String?
244+
val identifierType: String? = (arguments as Map<*, *>)["identifierType"] as String?
245+
val password: String? = arguments["password"] as String?
246+
if (identifier == null || password == null || identifierType == null) {
247+
currentResult?.error(
248+
MISSING_PARAMETER_ERROR,
249+
MISSING_PARAMETER_MESSAGE,
250+
mapOf<String, Any>()
251+
)
252+
return
253+
}
254+
255+
val parameters: Map<String, Any>? = arguments["parameters"] as Map<String, Any>?
256+
sdk.login(identifier, identifierType, password, parameters, object : GigyaLoginCallback<T>() {
257+
override fun onSuccess(p0: T) {
258+
resolverHelper.clear()
259+
val mapped = mapObject(p0)
260+
currentResult?.success(mapped)
261+
}
262+
263+
override fun onError(p0: GigyaError?) {
264+
p0?.let {
265+
currentResult?.error(
266+
p0.errorCode.toString(),
267+
p0.localizedMessage,
268+
mapJson(p0.data)
269+
)
270+
} ?: currentResult?.notImplemented()
271+
}
272+
273+
override fun onConflictingAccounts(
274+
response: GigyaApiResponse,
275+
resolver: ILinkAccountsResolver
276+
) {
277+
resolverHelper.linkAccountResolver = resolver
278+
currentResult?.error(
279+
response.errorCode.toString(),
280+
response.errorDetails,
281+
response.asMap()
282+
)
283+
}
284+
285+
override fun onPendingRegistration(
286+
response: GigyaApiResponse,
287+
resolver: IPendingRegistrationResolver
288+
) {
289+
resolverHelper.pendingRegistrationResolver = resolver
290+
currentResult?.error(
291+
response.errorCode.toString(),
292+
response.errorDetails,
293+
response.asMap()
294+
)
295+
}
296+
297+
override fun onPendingVerification(response: GigyaApiResponse, regToken: String?) {
298+
resolverHelper.regToken = regToken
299+
currentResult?.error(
300+
response.errorCode.toString(),
301+
response.errorDetails,
302+
response.asMap()
303+
)
304+
}
305+
})
306+
}
307+
232308
/**
233309
* Register a new user using credentials (email/password combination with optional parameter map).
234310
*/
@@ -583,7 +659,10 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
583659
}
584660

585661
override fun onOperationCanceled() {
586-
currentResult?.error(CANCELED_ERROR, CANCELED_ERROR_MESSAGE, null)
662+
currentResult?.error(
663+
CANCELED_ERROR,
664+
CANCELED_ERROR_MESSAGE,
665+
null)
587666
}
588667

589668
override fun onConflictingAccounts(
@@ -708,9 +787,9 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
708787
})
709788
}
710789

711-
//endregion
790+
//endregion
712791

713-
//region SCREENSETS
792+
//region SCREENSETS
714793

715794
/**
716795
* Trigger embedded web screen sets.
@@ -877,9 +956,9 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
877956
channelResult.success(null)
878957
}
879958

880-
//endregion
959+
//endregion
881960

882-
//region FIDO
961+
//region FIDO
883962

884963
/**
885964
* Fido2/WebAuthn register.
@@ -1062,9 +1141,9 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
10621141
})
10631142
}
10641143

1065-
//endregion
1144+
//endregion
10661145

1067-
//region OTP
1146+
//region OTP
10681147

10691148
/**
10701149
* Login via phone OTP.
@@ -1183,9 +1262,9 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
11831262
resolverHelper.otpResolver?.verify(code)
11841263
}
11851264

1186-
//endregion
1265+
//endregion
11871266

1188-
//region RESOLVERS
1267+
//region RESOLVERS
11891268

11901269
/**
11911270
* Link account - handler for fetching conflicting accounts from current interruption state.
@@ -1248,9 +1327,9 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
12481327
} ?: currentResult?.notImplemented()
12491328
}
12501329

1251-
//endregion
1330+
//endregion
12521331

1253-
//region BIOMETRIC
1332+
//region BIOMETRIC
12541333

12551334
fun biometricIsAvailable(channelResult: MethodChannel.Result) {
12561335
channelResult.success(sdkBiometric.isAvailable)
@@ -1394,7 +1473,7 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
13941473
})
13951474
}
13961475

1397-
//endregion
1476+
//endregion
13981477

13991478
/**
14001479
* Map typed object to a Map<String, Any> object in order to pass on to

example/android/app/src/main/kotlin/com/sap/gigya_flutter_plugin_example/gigya/providers/GoogleProviderWrapper.java

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.gigya.android.sdk.providers.external.ProviderWrapper;
2626
import com.gigya.android.sdk.ui.HostActivity;
2727
import com.google.android.libraries.identity.googleid.GetGoogleIdOption;
28+
import com.google.android.libraries.identity.googleid.GetSignInWithGoogleOption;
2829
import com.google.android.libraries.identity.googleid.GoogleIdTokenCredential;
2930

3031
import java.util.Map;
@@ -59,7 +60,7 @@ public void login(Context context, final Map<String, Object> params, final IProv
5960
return;
6061
}
6162
// Not using cached account. Server auth code can be used only once.
62-
authenticate(params, callback, true);
63+
tryAuthenticateWithGetGoogleIdOption(params, callback, true);
6364
}
6465

6566
private void handleSignIn(GetCredentialResponse getCredentialResponse, final Map<String, Object> params, final IProviderWrapperCallback callback) {
@@ -76,9 +77,9 @@ private void handleSignIn(GetCredentialResponse getCredentialResponse, final Map
7677
}
7778
}
7879

79-
private void authenticate(final Map<String, Object> params,
80-
final IProviderWrapperCallback callback,
81-
boolean setFilterByAuthorizedAccounts) {
80+
private void tryAuthenticateWithGetGoogleIdOption(final Map<String, Object> params,
81+
final IProviderWrapperCallback callback,
82+
boolean setFilterByAuthorizedAccounts) {
8283
HostActivity.present(context, new HostActivity.HostActivityLifecycleCallbacks() {
8384

8485
@Override
@@ -99,6 +100,34 @@ public void onCreate(AppCompatActivity activity, @Nullable Bundle savedInstanceS
99100
});
100101
}
101102

103+
private void tryAuthenticateWithGetSignInWithGoogleOption(AppCompatActivity activity, final Map<String, Object> params, final IProviderWrapperCallback callback) {
104+
105+
GetSignInWithGoogleOption option = new GetSignInWithGoogleOption.Builder(pId).build();
106+
107+
GetCredentialRequest request = new GetCredentialRequest.Builder()
108+
.addCredentialOption(option)
109+
.build();
110+
111+
_credentialsManager.getCredentialAsync(context, request,
112+
new CancellationSignal(),
113+
_executor,
114+
new CredentialManagerCallback<GetCredentialResponse, GetCredentialException>() {
115+
@Override
116+
public void onResult(GetCredentialResponse getCredentialResponse) {
117+
handleSignIn(getCredentialResponse, params, callback);
118+
activity.finish();
119+
}
120+
121+
@Override
122+
public void onError(@NonNull GetCredentialException e) {
123+
GigyaLogger.debug("GoogleProviderWrapper", "login exception: " + e);
124+
callback.onFailed(e.getLocalizedMessage());
125+
activity.finish();
126+
}
127+
}
128+
);
129+
}
130+
102131
private void credentialsSignIn(AppCompatActivity activity,
103132
final Map<String, Object> params,
104133
GetCredentialRequest request,
@@ -118,10 +147,10 @@ public void onResult(GetCredentialResponse getCredentialResponse) {
118147
public void onError(@NonNull GetCredentialException e) {
119148
GigyaLogger.debug("GoogleProviderWrapper", "login exception: " + e);
120149
if (e instanceof NoCredentialException && setFilterByAuthorizedAccounts) {
121-
authenticate(params, callback, false);
122-
} else {
123-
callback.onFailed(e.getLocalizedMessage());
124150
activity.finish();
151+
tryAuthenticateWithGetGoogleIdOption(params, callback, false);
152+
} else {
153+
tryAuthenticateWithGetSignInWithGoogleOption(activity, params, callback);
125154
}
126155
}
127156
}

example/ios/Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ PODS:
1010
- GoogleUtilities/UserDefaults (~> 8.0)
1111
- PromisesObjC (~> 2.4)
1212
- Flutter (1.0.0)
13-
- Gigya (1.7.6)
13+
- Gigya (1.8.0)
1414
- gigya_flutter_plugin (1.0.0):
1515
- Flutter
16-
- Gigya (>= 1.7.6)
16+
- Gigya (>= 1.8.0)
1717
- GigyaAuth (>= 1.1.2)
18-
- GigyaAuth (1.1.2):
18+
- GigyaAuth (1.1.3):
1919
- Gigya (>= 1.6.0)
2020
- google_sign_in_ios (0.0.1):
2121
- AppAuth (>= 1.7.4)
@@ -76,9 +76,9 @@ SPEC CHECKSUMS:
7676
AppAuth: d4f13a8fe0baf391b2108511793e4b479691fb73
7777
AppCheckCore: cc8fd0a3a230ddd401f326489c99990b013f0c4f
7878
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
79-
Gigya: 4f318c2e24ce3f0c8bac8dc7715232bde47f9184
80-
gigya_flutter_plugin: d11e1b7dc93b0bf1661ad4c2c4a9a74d741fe971
81-
GigyaAuth: 32cd49aa9eb380275ad10d85543a90ce326fe4fb
79+
Gigya: 5b4278ad3be3357b84a67458d9219c99c80a7d09
80+
gigya_flutter_plugin: 6c4f93c75906ae99966d8ccd518cfca0af6e43f1
81+
GigyaAuth: 8dd0835266373a201a00abe4489d65efc8c18ab3
8282
google_sign_in_ios: 7411fab6948df90490dc4620ecbcabdc3ca04017
8383
GoogleSignIn: ce8c89bb9b37fb624b92e7514cc67335d1e277e4
8484
GoogleUtilities: 00c88b9a86066ef77f0da2fab05f65d7768ed8e1

example/lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'routes/biometrics_page.dart';
66
import 'routes/forgot_password_page.dart';
77
import 'routes/home_page.dart';
88
import 'routes/login_with_credentials_page.dart';
9+
import 'routes/login_with_custom_id_page.dart';
910
import 'routes/manage_connections_page.dart';
1011
import 'routes/one_time_password_login_page.dart';
1112
import 'routes/register_with_email_page.dart';
@@ -59,6 +60,7 @@ class _MyAppState extends State<MyApp> {
5960
'/': (_) => HomePage(sdk: widget.sdk),
6061
'/send_request': (_) => SendRequestPage(sdk: widget.sdk),
6162
'/login_credentials': (_) => LoginWithCredentialsPage(sdk: widget.sdk),
63+
'/login_custom_id': (_) => LoginWithCustomIdPage(sdk: widget.sdk),
6264
'/register_email': (_) => RegisterWithEmailPage(sdk: widget.sdk),
6365
'/account_information': (_) => AccountInformationPage(sdk: widget.sdk),
6466
'/manage_connections': (_) => ManageConnectionsPage(sdk: widget.sdk),

example/lib/routes/home_page.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
183183
child: const Text('Login with credentials'),
184184
),
185185
),
186+
Padding(
187+
padding: const EdgeInsets.only(bottom: 8),
188+
child: ElevatedButton(
189+
onPressed: () async {
190+
await Navigator.pushNamed(context, '/login_custom_id');
191+
192+
_refreshLogin();
193+
},
194+
child: const Text('Login with Custom ID'),
195+
),
196+
),
186197
Padding(
187198
padding: const EdgeInsets.only(bottom: 8),
188199
child: ElevatedButton(

0 commit comments

Comments
 (0)