From 12c3965417cae1125d143245373d5db2b5e1feed Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 5 Jun 2023 12:58:06 +0200 Subject: [PATCH 001/256] update .metadata file --- .metadata | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.metadata b/.metadata index 4129ce95..b05acbb3 100644 --- a/.metadata +++ b/.metadata @@ -1,10 +1,36 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled and should not be manually edited. +# This file should be version controlled. version: - revision: 84f3d28555368a70270e9ac8390a9441df95e752 + revision: 2ad6cd72c040113b47ee9055e722606a490ef0da channel: stable project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + - platform: android + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + - platform: ios + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + - platform: web + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' From bd380fd2cd8b6fe07121fe761264e8cfa71ed45f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 5 Jun 2023 12:59:59 +0200 Subject: [PATCH 002/256] add web entrypoint for example app --- example/web/favicon.png | Bin 0 -> 917 bytes example/web/icons/Icon-192.png | Bin 0 -> 5292 bytes example/web/icons/Icon-512.png | Bin 0 -> 8252 bytes example/web/icons/Icon-maskable-192.png | Bin 0 -> 5594 bytes example/web/icons/Icon-maskable-512.png | Bin 0 -> 20998 bytes example/web/index.html | 59 ++++++++++++++++++++++++ example/web/manifest.json | 35 ++++++++++++++ 7 files changed, 94 insertions(+) create mode 100644 example/web/favicon.png create mode 100644 example/web/icons/Icon-192.png create mode 100644 example/web/icons/Icon-512.png create mode 100644 example/web/icons/Icon-maskable-192.png create mode 100644 example/web/icons/Icon-maskable-512.png create mode 100644 example/web/index.html create mode 100644 example/web/manifest.json diff --git a/example/web/favicon.png b/example/web/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..8aaa46ac1ae21512746f852a42ba87e4165dfdd1 GIT binary patch literal 917 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0X7 zltGxWVyS%@P(fs7NJL45ua8x7ey(0(N`6wRUPW#JP&EUCO@$SZnVVXYs8ErclUHn2 zVXFjIVFhG^g!Ppaz)DK8ZIvQ?0~DO|i&7O#^-S~(l1AfjnEK zjFOT9D}DX)@^Za$W4-*MbbUihOG|wNBYh(yU7!lx;>x^|#0uTKVr7USFmqf|i<65o z3raHc^AtelCMM;Vme?vOfh>Xph&xL%(-1c06+^uR^q@XSM&D4+Kp$>4P^%3{)XKjo zGZknv$b36P8?Z_gF{nK@`XI}Z90TzwSQO}0J1!f2c(B=V`5aP@1P1a|PZ!4!3&Gl8 zTYqUsf!gYFyJnXpu0!n&N*SYAX-%d(5gVjrHJWqXQshj@!Zm{!01WsQrH~9=kTxW#6SvuapgMqt>$=j#%eyGrQzr zP{L-3gsMA^$I1&gsBAEL+vxi1*Igl=8#8`5?A-T5=z-sk46WA1IUT)AIZHx1rdUrf zVJrJn<74DDw`j)Ki#gt}mIT-Q`XRa2-jQXQoI%w`nb|XblvzK${ZzlV)m-XcwC(od z71_OEC5Bt9GEXosOXaPTYOia#R4ID2TiU~`zVMl08TV_C%DnU4^+HE>9(CE4D6?Fz oujB08i7adh9xk7*FX66dWH6F5TM;?E2b5PlUHx3vIVCg!0Dx9vYXATM literal 0 HcmV?d00001 diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png new file mode 100644 index 0000000000000000000000000000000000000000..b749bfef07473333cf1dd31e9eed89862a5d52aa GIT binary patch literal 5292 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 literal 0 HcmV?d00001 diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png new file mode 100644 index 0000000000000000000000000000000000000000..88cfd48dff1169879ba46840804b412fe02fefd6 GIT binary patch literal 8252 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 literal 0 HcmV?d00001 diff --git a/example/web/icons/Icon-maskable-192.png b/example/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9b4d76e525556d5d89141648c724331630325d GIT binary patch literal 5594 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 X>c!)3PgKfL&lX^$Z>Cpu&6)6jvi^Z! literal 0 HcmV?d00001 diff --git a/example/web/icons/Icon-maskable-512.png b/example/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000000000000000000000000000000000000..d69c56691fbdb0b7efa65097c7cc1edac12a6d3e GIT binary patch literal 20998 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 MPgg&ebxsLQ025IeI{*Lx literal 0 HcmV?d00001 diff --git a/example/web/index.html b/example/web/index.html new file mode 100644 index 00000000..8ccf713b --- /dev/null +++ b/example/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + gigya_flutter_plugin_example + + + + + + + + + + diff --git a/example/web/manifest.json b/example/web/manifest.json new file mode 100644 index 00000000..7db4a594 --- /dev/null +++ b/example/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "gigya_flutter_plugin_example", + "short_name": "gigya_flutter_plugin_example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "Demonstrates how to use the gigya_flutter_plugin plugin.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} From ee90bab70fab6073dbeefd1d36bc7668f1b98db6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 5 Jun 2023 13:00:26 +0200 Subject: [PATCH 003/256] bump example app Dart & Flutter version --- example/pubspec.lock | 6 +++--- example/pubspec.yaml | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 1e32caed..14aaae56 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -102,7 +102,7 @@ packages: path: ".." relative: true source: path - version: "1.0.0" + version: "1.0.1" google_sign_in: dependency: "direct main" description: @@ -269,5 +269,5 @@ packages: source: hosted version: "2.1.4" sdks: - dart: ">=3.0.0-417 <4.0.0" - flutter: ">=3.3.0" + dart: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9f4dd951..51cc89b2 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,7 +5,8 @@ homepage: https://www.sap.com publish_to: none environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" dependencies: flutter: From f4f2c105a23fbc06c4c075de9c2b9787b8895ff6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 5 Jun 2023 13:00:48 +0200 Subject: [PATCH 004/256] update example app Android resources --- .../res/drawable-v21/launch_background.xml | 12 ++++++++++++ .../app/src/main/res/values-night/styles.xml | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 example/android/app/src/main/res/values-night/styles.xml diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + From 87580554a95c83a5271f04f760026c177e7d83cd Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 5 Jun 2023 13:01:39 +0200 Subject: [PATCH 005/256] fix minor issues with the example app --- example/lib/routes/account_information_page.dart | 4 ++-- example/lib/routes/home_page.dart | 4 ++-- example/lib/routes/login_with_credentials_page.dart | 13 +++++++------ example/lib/routes/manage_connections_page.dart | 12 +++++++----- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/example/lib/routes/account_information_page.dart b/example/lib/routes/account_information_page.dart index df9462a8..f200f9f4 100644 --- a/example/lib/routes/account_information_page.dart +++ b/example/lib/routes/account_information_page.dart @@ -238,9 +238,9 @@ class _AccountInformationPageState extends State { case ConnectionState.active: case ConnectionState.none: case ConnectionState.waiting: - return Column( + return const Column( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ CircularProgressIndicator(), Text('Fetching account...'), ], diff --git a/example/lib/routes/home_page.dart b/example/lib/routes/home_page.dart index c0e2acb3..381db7af 100644 --- a/example/lib/routes/home_page.dart +++ b/example/lib/routes/home_page.dart @@ -192,9 +192,9 @@ class _HomePageState extends State { case ConnectionState.none: case ConnectionState.active: case ConnectionState.waiting: - return Column( + return const Column( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ CircularProgressIndicator(), Padding( padding: EdgeInsets.all(8), diff --git a/example/lib/routes/login_with_credentials_page.dart b/example/lib/routes/login_with_credentials_page.dart index c7827dca..3b926e92 100644 --- a/example/lib/routes/login_with_credentials_page.dart +++ b/example/lib/routes/login_with_credentials_page.dart @@ -66,7 +66,7 @@ class _LoginWithCredentialsPageState extends State { if (mounted) { setState(() { _inProgress = false; - _requestResult = 'Login success: \n\n ${account.uid}'; + _requestResult = 'Login success: \n\n ${account.toJson()}'; }); } } @@ -112,15 +112,14 @@ class _LoginWithCredentialsPageState extends State { } void _resolveLinkAccount(LinkAccountResolver resolver) async { - final ConflictingAccounts? conflictingAccounts = - await resolver.conflictingAccounts; + final ConflictingAccount? conflictingAccount = await resolver.conflictingAccount; - if (!mounted || conflictingAccounts == null) { + if (!mounted || conflictingAccount == null) { return; } - if (conflictingAccounts.loginProviders.contains('site')) { - _showLinkToSiteBottomSheet(conflictingAccounts.loginID, resolver); + if (conflictingAccount.loginProviders.contains('site')) { + _showLinkToSiteBottomSheet(conflictingAccount.loginID, resolver); } else { _showLinkToSocialBottomSheet(resolver); } @@ -234,6 +233,7 @@ class _LoginWithCredentialsPageState extends State { ), TextField( controller: _linkPasswordController, + obscureText: true, decoration: const InputDecoration(hintText: 'password'), ), Padding( @@ -351,6 +351,7 @@ class _LoginWithCredentialsPageState extends State { padding: const EdgeInsets.all(8.0), child: TextFormField( controller: _passwordController, + obscureText: true, decoration: const InputDecoration(hintText: 'Enter password'), validator: (String? value) { if (value == null || value.trim().isEmpty) { diff --git a/example/lib/routes/manage_connections_page.dart b/example/lib/routes/manage_connections_page.dart index 581e913f..c53accf1 100644 --- a/example/lib/routes/manage_connections_page.dart +++ b/example/lib/routes/manage_connections_page.dart @@ -79,9 +79,9 @@ class _ManageConnectionsPageState extends State { case ConnectionState.none: case ConnectionState.active: case ConnectionState.waiting: - return Column( + return const Column( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ CircularProgressIndicator(), Text('Fetching account...'), ], @@ -109,19 +109,21 @@ class _ManageConnectionsPageState extends State { } final Account account = snapshot.data!; - final String socialProviders = account.socialProviders ?? ''; return Column( children: [ const Text('Social connections for this account'), Expanded( - child: socialProviders.isEmpty + child: account.socialProviders.isEmpty ? const Center( child: Text( 'No social connections for this account', ), ) - : Text(socialProviders), + : ListView.builder( + itemBuilder: (_, int index) => Text(account.socialProviders[index]), + itemCount: account.socialProviders.length, + ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 16), From 9e971141fce1e376053d2f569334ba0f9428499e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 5 Jun 2023 13:03:48 +0200 Subject: [PATCH 006/256] move method channel impl to subfolder --- lib/gigya_flutter_plugin.dart | 14 ++++++------ .../gigya_flutter_plugin_method_channel.dart | 14 ++++++------ .../method_channel_interruption_resolver.dart | 22 +++++++++---------- .../method_channel_otp_service.dart | 6 ++--- ...od_channel_web_authentication_service.dart | 7 +++--- ...gya_flutter_plugin_platform_interface.dart | 8 +++---- .../interruption_resolver.dart | 8 +++---- .../{otp_service => }/otp_service.dart | 0 .../web_authentication_service.dart | 0 9 files changed, 39 insertions(+), 40 deletions(-) rename lib/src/{platform_interface => method_channel}/gigya_flutter_plugin_method_channel.dart (96%) rename lib/src/{services/interruption_resolver => method_channel}/method_channel_interruption_resolver.dart (83%) rename lib/src/{services/otp_service => method_channel}/method_channel_otp_service.dart (95%) rename lib/src/{services/web_authentication_service => method_channel}/method_channel_web_authentication_service.dart (90%) rename lib/src/services/{interruption_resolver => }/interruption_resolver.dart (91%) rename lib/src/services/{otp_service => }/otp_service.dart (100%) rename lib/src/services/{web_authentication_service => }/web_authentication_service.dart (100%) diff --git a/lib/gigya_flutter_plugin.dart b/lib/gigya_flutter_plugin.dart index 074f9205..1dfc6dc1 100644 --- a/lib/gigya_flutter_plugin.dart +++ b/lib/gigya_flutter_plugin.dart @@ -1,14 +1,14 @@ import 'src/models/enums/social_provider.dart'; import 'src/models/screenset_event.dart'; import 'src/platform_interface/gigya_flutter_plugin_platform_interface.dart'; -import 'src/services/interruption_resolver/interruption_resolver.dart'; -import 'src/services/otp_service/otp_service.dart'; -import 'src/services/web_authentication_service/web_authentication_service.dart'; +import 'src/services/interruption_resolver.dart'; +import 'src/services/otp_service.dart'; +import 'src/services/web_authentication_service.dart'; export 'src/models/account.dart'; export 'src/models/address.dart'; export 'src/models/certification.dart'; -export 'src/models/conflicting_accounts.dart'; +export 'src/models/conflicting_account.dart'; export 'src/models/education.dart'; export 'src/models/emails.dart'; export 'src/models/enums/screen_set_event_type.dart'; @@ -26,9 +26,9 @@ export 'src/models/screenset_event.dart'; export 'src/models/session_info.dart'; export 'src/models/skill.dart'; export 'src/models/work.dart'; -export 'src/services/interruption_resolver/interruption_resolver.dart'; -export 'src/services/otp_service/otp_service.dart'; -export 'src/services/web_authentication_service/web_authentication_service.dart'; +export 'src/services/interruption_resolver.dart'; +export 'src/services/otp_service.dart'; +export 'src/services/web_authentication_service.dart'; /// This class represents the Gigya SDK plugin. class GigyaSdk { diff --git a/lib/src/platform_interface/gigya_flutter_plugin_method_channel.dart b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart similarity index 96% rename from lib/src/platform_interface/gigya_flutter_plugin_method_channel.dart rename to lib/src/method_channel/gigya_flutter_plugin_method_channel.dart index 278f481b..a3301ff7 100644 --- a/lib/src/platform_interface/gigya_flutter_plugin_method_channel.dart +++ b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart @@ -7,13 +7,13 @@ import '../models/enums/methods.dart'; import '../models/enums/social_provider.dart'; import '../models/gigya_error.dart'; import '../models/screenset_event.dart'; -import '../services/interruption_resolver/interruption_resolver.dart'; -import '../services/interruption_resolver/method_channel_interruption_resolver.dart'; -import '../services/otp_service/method_channel_otp_service.dart'; -import '../services/otp_service/otp_service.dart'; -import '../services/web_authentication_service/method_channel_web_authentication_service.dart'; -import '../services/web_authentication_service/web_authentication_service.dart'; -import 'gigya_flutter_plugin_platform_interface.dart'; +import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; +import '../services/interruption_resolver.dart'; +import '../services/otp_service.dart'; +import '../services/web_authentication_service.dart'; +import 'method_channel_interruption_resolver.dart'; +import 'method_channel_otp_service.dart'; +import 'method_channel_web_authentication_service.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses method channels. class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform { diff --git a/lib/src/services/interruption_resolver/method_channel_interruption_resolver.dart b/lib/src/method_channel/method_channel_interruption_resolver.dart similarity index 83% rename from lib/src/services/interruption_resolver/method_channel_interruption_resolver.dart rename to lib/src/method_channel/method_channel_interruption_resolver.dart index ed50eb9b..8af6d252 100644 --- a/lib/src/services/interruption_resolver/method_channel_interruption_resolver.dart +++ b/lib/src/method_channel/method_channel_interruption_resolver.dart @@ -1,10 +1,10 @@ import 'package:flutter/services.dart' show MethodChannel, PlatformException; -import '../../models/conflicting_accounts.dart'; -import '../../models/enums/methods.dart'; -import '../../models/enums/social_provider.dart'; -import '../../models/gigya_error.dart'; -import 'interruption_resolver.dart'; +import '../models/conflicting_account.dart'; +import '../models/enums/methods.dart'; +import '../models/enums/social_provider.dart'; +import '../models/gigya_error.dart'; +import '../services/interruption_resolver.dart'; /// This class represents an [InterruptionResolver] that uses a [MethodChannel] /// for its implementation. @@ -32,25 +32,25 @@ class MethodChannelInterruptionResolverFactory class _MethodChannelLinkAccountResolver extends LinkAccountResolver { _MethodChannelLinkAccountResolver(this._channel) { - _conflictingAccounts = _getConflictingAccounts(); + _conflictingAccount = _getConflictingAccount(); } final MethodChannel _channel; - late final Future? _conflictingAccounts; + late final Future? _conflictingAccount; @override - Future? get conflictingAccounts => _conflictingAccounts; + Future? get conflictingAccount => _conflictingAccount; - /// Get the conflicting accounts for the user. - Future _getConflictingAccounts() async { + /// Get the conflicting account for the user. + Future _getConflictingAccount() async { try { final Map? result = await _channel.invokeMapMethod( Methods.getConflictingAccounts.methodName, ); - return ConflictingAccounts.fromJson(result ?? const {}); + return ConflictingAccount.fromJson(result ?? const {}); } on PlatformException catch (exception) { throw GigyaError.fromPlatformException(exception); } diff --git a/lib/src/services/otp_service/method_channel_otp_service.dart b/lib/src/method_channel/method_channel_otp_service.dart similarity index 95% rename from lib/src/services/otp_service/method_channel_otp_service.dart rename to lib/src/method_channel/method_channel_otp_service.dart index 1bc03122..e57155b4 100644 --- a/lib/src/services/otp_service/method_channel_otp_service.dart +++ b/lib/src/method_channel/method_channel_otp_service.dart @@ -1,8 +1,8 @@ import 'package:flutter/services.dart' show MethodChannel, PlatformException; -import '../../models/enums/methods.dart'; -import '../../models/gigya_error.dart'; -import 'otp_service.dart'; +import '../models/enums/methods.dart'; +import '../models/gigya_error.dart'; +import '../services/otp_service.dart'; /// This class represents an [OtpService] that uses a [MethodChannel] /// for its implementation. diff --git a/lib/src/services/web_authentication_service/method_channel_web_authentication_service.dart b/lib/src/method_channel/method_channel_web_authentication_service.dart similarity index 90% rename from lib/src/services/web_authentication_service/method_channel_web_authentication_service.dart rename to lib/src/method_channel/method_channel_web_authentication_service.dart index 4b905a0d..5f0f40ad 100644 --- a/lib/src/services/web_authentication_service/method_channel_web_authentication_service.dart +++ b/lib/src/method_channel/method_channel_web_authentication_service.dart @@ -1,9 +1,9 @@ import 'dart:convert'; import 'package:flutter/services.dart' show MethodChannel, PlatformException; -import 'package:gigya_flutter_plugin/gigya_flutter_plugin.dart'; -import '../../models/enums/methods.dart'; +import '../../gigya_flutter_plugin.dart'; +import '../models/enums/methods.dart'; /// This class represents a [WebAuthenticationService] that uses a [MethodChannel] /// for its implementation. @@ -16,8 +16,7 @@ class MethodChannelWebAuthenticationService extends WebAuthenticationService { @override Future> login() async { try { - final Map? result = - await _channel.invokeMapMethod( + final Map? result = await _channel.invokeMapMethod( WebAuthnMethods.login.methodName, {}, ).timeout( diff --git a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart index d32096b2..b4754dd0 100644 --- a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart +++ b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart @@ -1,11 +1,11 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import '../method_channel/gigya_flutter_plugin_method_channel.dart'; import '../models/enums/social_provider.dart'; import '../models/screenset_event.dart'; -import '../services/interruption_resolver/interruption_resolver.dart'; -import '../services/otp_service/otp_service.dart'; -import '../services/web_authentication_service/web_authentication_service.dart'; -import 'gigya_flutter_plugin_method_channel.dart'; +import '../services/interruption_resolver.dart'; +import '../services/otp_service.dart'; +import '../services/web_authentication_service.dart'; /// The platform interface for the Gigya Flutter Plugin. abstract class GigyaFlutterPluginPlatform extends PlatformInterface { diff --git a/lib/src/services/interruption_resolver/interruption_resolver.dart b/lib/src/services/interruption_resolver.dart similarity index 91% rename from lib/src/services/interruption_resolver/interruption_resolver.dart rename to lib/src/services/interruption_resolver.dart index 4dba769d..7888fd14 100644 --- a/lib/src/services/interruption_resolver/interruption_resolver.dart +++ b/lib/src/services/interruption_resolver.dart @@ -1,6 +1,6 @@ -import '../../models/conflicting_accounts.dart'; -import '../../models/enums/social_provider.dart'; -import '../../models/gigya_error.dart'; +import '../models/conflicting_account.dart'; +import '../models/enums/social_provider.dart'; +import '../models/gigya_error.dart'; /// This interface represents the base interruption resolver. abstract class InterruptionResolver { @@ -22,7 +22,7 @@ abstract class InterruptionResolverFactory { /// The resolver for a link account flow interruption. abstract class LinkAccountResolver extends InterruptionResolver { /// Get the conflicting accounts of the user. - Future? get conflictingAccounts { + Future? get conflictingAccount { throw UnimplementedError('conflictingAccounts is not implemented.'); } diff --git a/lib/src/services/otp_service/otp_service.dart b/lib/src/services/otp_service.dart similarity index 100% rename from lib/src/services/otp_service/otp_service.dart rename to lib/src/services/otp_service.dart diff --git a/lib/src/services/web_authentication_service/web_authentication_service.dart b/lib/src/services/web_authentication_service.dart similarity index 100% rename from lib/src/services/web_authentication_service/web_authentication_service.dart rename to lib/src/services/web_authentication_service.dart From 97e78dad81fd2b9628b9083f4eaf3fa8b115701d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 5 Jun 2023 13:04:35 +0200 Subject: [PATCH 007/256] model fixes --- lib/src/models/account.dart | 105 +++++++++--------- lib/src/models/certification.dart | 12 +- ...accounts.dart => conflicting_account.dart} | 17 +-- lib/src/models/favorite.dart | 1 + lib/src/models/like.dart | 12 +- lib/src/models/oidc_data.dart | 2 +- lib/src/models/patent.dart | 2 +- lib/src/models/profile.dart | 34 +++++- lib/src/models/publication.dart | 2 +- lib/src/models/session_info.dart | 35 +++++- lib/src/models/work.dart | 23 ++-- 11 files changed, 147 insertions(+), 98 deletions(-) rename lib/src/models/{conflicting_accounts.dart => conflicting_account.dart} (56%) diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index 159a196d..a77317fc 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -1,13 +1,11 @@ import 'emails.dart'; import 'profile.dart'; -import 'session_info.dart'; /// This class represents an account. class Account { /// The default constructor. Account({ required this.emails, - this.created, this.createdTimestamp, this.isActive, this.isRegistered, @@ -15,51 +13,59 @@ class Account { this.lastLoginTimestamp, this.lastUpdatedTimestamp, this.loginProvider, - this.oldestUpdateTimestamp, + this.oldestDataUpdateTimestamp, this.profile, - this.registered, this.registeredTimestamp, this.signatureTimestamp, - this.socialProviders, + this.socialProviders = const [], this.uid, this.uidSignature, - this.verified, this.verifiedTimestamp, }); /// Construct an account from the given [json]. factory Account.fromJson(Map json) { - final Map? emails = json['emails'] == null ? null : json['emails'].cast() as Map; - final Map? profile = json['profile'] == null ? null : json['profile'].cast() as Map; + final String? createdTimestamp = json['createdTimestamp'] as String?; + final Map? emails = (json['emails'] as Map?)?.cast(); + final Map? profile = (json['profile'] as Map?)?.cast(); + final String? lastLoginTimestamp = json['lastLogin'] as String?; + final String? lastUpdatedTimestamp = json['lastUpdated'] as String?; + final String? oldestDataUpdateTimestamp = json['oldestDataUpdated'] as String?; + final String? registeredTimestamp = json['registered'] as String?; + final String? verifiedTimestamp = json['verified'] as String?; + final String socialProviders = json['socialProviders'] as String? ?? ''; + + // The signature timestamp can be either an ISO 8601 date, + // or the number of seconds since the UNIX epoch (1 Jan 1970). + final DateTime? signatureTimestamp = switch (json['signatureTimestamp']) { + final String timestamp => DateTime.parse(timestamp), + final int timestamp => DateTime.fromMillisecondsSinceEpoch(timestamp * 1000), + final double timestamp => DateTime.fromMillisecondsSinceEpoch(timestamp.toInt() * 1000), + _ => null, + }; return Account( emails: emails == null ? const Emails() : Emails.fromJson(emails), - created: json['created'] as String?, - createdTimestamp: json['createdTimestamp'] as Object?, + createdTimestamp: DateTime.tryParse(createdTimestamp ?? ''), isActive: json['isActive'] as bool?, isRegistered: json['isRegistered'] as bool?, isVerified: json['isVerified'] as bool?, - lastLoginTimestamp: json['lastLoginTimestamp'] as Object?, - lastUpdatedTimestamp: json['lastUpdatedTimestamp'] as Object?, + lastLoginTimestamp: DateTime.tryParse(lastLoginTimestamp ?? ''), + lastUpdatedTimestamp: DateTime.tryParse(lastUpdatedTimestamp ?? ''), loginProvider: json['loginProvider'] as String?, - oldestUpdateTimestamp: json['oldestDataUpdatedTimestamp'] as Object?, + oldestDataUpdateTimestamp: DateTime.tryParse(oldestDataUpdateTimestamp ?? ''), profile: profile == null ? null : Profile.fromJson(profile), - registered: json['registered'] as String?, - registeredTimestamp: json['registeredTimestamp'] as Object?, - signatureTimestamp: json['signatureTimestamp'] as Object?, - socialProviders: json['socialProviders'] as String?, + registeredTimestamp: DateTime.tryParse(registeredTimestamp ?? ''), + signatureTimestamp: signatureTimestamp, + socialProviders: socialProviders.split(','), uid: json['UID'] as String?, uidSignature: json['UIDSignature'] as String?, - verified: json['verified'] as String?, - verifiedTimestamp: json['verifiedTimestamp'] as Object?, + verifiedTimestamp: DateTime.tryParse(verifiedTimestamp ?? ''), ); } - /// The created status of the account. - final String? created; - - /// The creation timestamp of the account. - final Object? createdTimestamp; // TODO: this should be a `DateTime?`. + /// The timestamp, in UTC, on which the account was created. + final DateTime? createdTimestamp; /// Whether this account is active. final bool? isActive; @@ -73,11 +79,12 @@ class Account { /// The list of email addresses for the account. final Emails emails; - /// The timestamp of the last login. - final Object? lastLoginTimestamp; // TODO: this should be a `DateTime?`. + /// The timestamp of the last login of the user. + final DateTime? lastLoginTimestamp; - /// The timestamp of the last update. - final Object? lastUpdatedTimestamp; // TODO: this should be a `DateTime?`. + /// The timestamp, in UTC, when the user's profile, preferences, + /// or subscriptions data was last updated. + final DateTime? lastUpdatedTimestamp; /// The name of current login provider for this account. /// @@ -85,23 +92,21 @@ class Account { /// then the value of this attribute will be `site`. final String? loginProvider; - /// The timestamp of the oldest data update. - final Object? oldestUpdateTimestamp; // TODO: this should be a `DateTime?`. + /// The timestamp, in UTC, when the oldest data of the user was refreshed. + final DateTime? oldestDataUpdateTimestamp; /// The profile linked to this account. final Profile? profile; - /// The registered status of the account. - final String? registered; + /// The timestamp, in UTC, when the user was registered. + final DateTime? registeredTimestamp; - /// The timestamp of the account registration. - final Object? registeredTimestamp; // TODO: this should be a `DateTime?`. - - /// The timestamp of the [uidSignature]. - final Object? signatureTimestamp; // TODO: this should be a `DateTime?`. + /// The timestamp of the [uidSignature], in UTC. + /// This signature should be used for login validation. + final DateTime? signatureTimestamp; /// The social providers linked to this account. - final String? socialProviders; // TODO: This should be a `List` + final List socialProviders; /// The UID of the account. final String? uid; @@ -109,36 +114,30 @@ class Account { /// The UID signature of the account. final String? uidSignature; - /// The verified status of this account. - final String? verified; - - /// The timestamp of the [verified] status. - final Object? verifiedTimestamp; // TODO: this should be a `DateTime?`. + /// The timestamp, in UTC, when the user was verified. + final DateTime? verifiedTimestamp; /// Convert this object into a JSON object. Map toJson() { final Profile? accountProfile = profile; return { - 'created': created, - 'createdTimestamp': createdTimestamp?.toString(), + 'createdTimestamp': createdTimestamp?.toIso8601String(), 'emails': emails.toJson(), 'isActive': isActive, 'isRegistered': isRegistered, 'isVerified': isVerified, - 'lastLoginTimestamp': lastLoginTimestamp?.toString(), - 'lastUpdatedTimestamp': lastUpdatedTimestamp?.toString(), + 'lastLoginTimestamp': lastLoginTimestamp?.toIso8601String(), + 'lastUpdatedTimestamp': lastUpdatedTimestamp?.toIso8601String(), 'loginProvider': loginProvider, - 'oldestDataUpdatedTimestamp': oldestUpdateTimestamp?.toString(), + 'oldestDataUpdatedTimestamp': oldestDataUpdateTimestamp?.toIso8601String(), if (accountProfile != null) 'profile': accountProfile.toJson(), - 'registered': registered, - 'registeredTimestamp': registeredTimestamp?.toString(), - 'signatureTimestamp': signatureTimestamp?.toString(), + 'registeredTimestamp': registeredTimestamp?.toIso8601String(), + 'signatureTimestamp': signatureTimestamp?.toIso8601String(), 'socialProviders': socialProviders, 'UID': uid, 'UIDSignature': uidSignature, - 'verified': verified, - 'verifiedTimestamp': verifiedTimestamp?.toString(), + 'verifiedTimestamp': verifiedTimestamp?.toIso8601String(), }; } } diff --git a/lib/src/models/certification.dart b/lib/src/models/certification.dart index 03d4c3bc..c5ebe554 100644 --- a/lib/src/models/certification.dart +++ b/lib/src/models/certification.dart @@ -13,10 +13,10 @@ class Certification { factory Certification.fromJson(Map json) { return Certification._( authority: json['authority'] as String?, - endDate: json['endDate'] as String?, + endDate: DateTime.tryParse(json['endDate'] as String? ?? ''), name: json['name'] as String?, number: json['number'] as String?, - startDate: json['startDate'] as String?, + startDate: DateTime.tryParse(json['startDate'] as String? ?? ''), ); } @@ -24,7 +24,7 @@ class Certification { final String? authority; /// The end date of the validity of the certification. - final String? endDate; // TODO: this should be a DateTime? + final DateTime? endDate; /// The name of the certification. final String? name; @@ -33,16 +33,16 @@ class Certification { final String? number; /// The start date of the validity of the certification. - final String? startDate; // TODO: this should be a DateTime? + final DateTime? startDate; /// Convert this object to a JSON object. Map toJson() { return { 'authority': authority, - 'endDate': endDate, + 'endDate': endDate?.toIso8601String(), 'name': name, 'number': number, - 'startDate': startDate, + 'startDate': startDate?.toIso8601String(), }; } } diff --git a/lib/src/models/conflicting_accounts.dart b/lib/src/models/conflicting_account.dart similarity index 56% rename from lib/src/models/conflicting_accounts.dart rename to lib/src/models/conflicting_account.dart index add986fa..1244d3d7 100644 --- a/lib/src/models/conflicting_accounts.dart +++ b/lib/src/models/conflicting_account.dart @@ -1,16 +1,19 @@ /// This class represents a model that is used to resolve an account conflict. -class ConflictingAccounts { - /// The private constructor. - const ConflictingAccounts._(this.loginID, this.loginProviders); +class ConflictingAccount { + /// The default constructor. + const ConflictingAccount({ + this.loginID, + this.loginProviders = const [], + }); /// The default constructor. - factory ConflictingAccounts.fromJson(Map json) { + factory ConflictingAccount.fromJson(Map json) { // Lists coming from `jsonDecode` always have dynamic as type. final List? providers = json['loginProviders'] as List?; - return ConflictingAccounts._( - json['loginID'] as String?, - providers?.cast() ?? [], + return ConflictingAccount( + loginID: json['loginID'] as String?, + loginProviders: providers?.cast() ?? [], ); } diff --git a/lib/src/models/favorite.dart b/lib/src/models/favorite.dart index ef7ec437..5a954015 100644 --- a/lib/src/models/favorite.dart +++ b/lib/src/models/favorite.dart @@ -103,6 +103,7 @@ class Favorites { 'books': books.map((Favorite b) => b.toJson()).toList(), 'interests': interests.map((Favorite i) => i.toJson()).toList(), 'movies': movies.map((Favorite m) => m.toJson()).toList(), + 'music': music.map((Favorite m) => m.toJson()).toList(), 'television': television.map((Favorite t) => t.toJson()).toList(), }; } diff --git a/lib/src/models/like.dart b/lib/src/models/like.dart index ca9df63c..dc54c11c 100644 --- a/lib/src/models/like.dart +++ b/lib/src/models/like.dart @@ -6,7 +6,6 @@ class Like { this.id, this.name, this.time, - this.timestamp, }); /// The default constructor. @@ -15,8 +14,7 @@ class Like { category: json['category'] as String?, id: json['id'] as String?, name: json['name'] as String?, - time: json['time'] as String?, - timestamp: json['timestamp'] as double?, + time: DateTime.tryParse(json['time'] as String? ?? ''), ); } @@ -29,11 +27,8 @@ class Like { /// The name of the like. final String? name; - /// The formatted time of the like. - final String? time; // TODO: this parameter is redundant, timestamp is enough? - /// The timestamp of the like. - final double? timestamp; // TODO: this should be a `DateTime?` + final DateTime? time; /// Convert this object into a JSON object. Map toJson() { @@ -41,8 +36,7 @@ class Like { 'category': category, 'id': id, 'name': name, - 'time': time, - 'timestamp': timestamp, + 'time': time?.toIso8601String(), }; } } diff --git a/lib/src/models/oidc_data.dart b/lib/src/models/oidc_data.dart index 22c5a451..d7787627 100644 --- a/lib/src/models/oidc_data.dart +++ b/lib/src/models/oidc_data.dart @@ -76,7 +76,7 @@ class OidcData { 'name': name, 'phone_number': phoneNumber, 'phone_number_verified': phoneNumberVerified, - 'updated_at': updatedAt?.toString(), + 'updated_at': updatedAt?.toIso8601String(), 'website': website, 'zoneinfo': zoneInfo, }; diff --git a/lib/src/models/patent.dart b/lib/src/models/patent.dart index d912a626..ef79ec63 100644 --- a/lib/src/models/patent.dart +++ b/lib/src/models/patent.dart @@ -50,7 +50,7 @@ class Patent { /// Convert this object into a JSON object. Map toJson() { return { - 'date': date?.toString(), + 'date': date?.toIso8601String(), 'number': number, 'office': office, 'status': status, diff --git a/lib/src/models/profile.dart b/lib/src/models/profile.dart index 6e273c67..c993ae67 100644 --- a/lib/src/models/profile.dart +++ b/lib/src/models/profile.dart @@ -36,11 +36,15 @@ class Profile { this.honors, this.industry, this.interests, + this.isConnected, + this.isSiteUser, this.languages, this.lastLoginLocation, this.lastName, this.likes = const [], this.locale, + this.loginProvider, + this.loginProviderUID, this.name, this.nickname, this.oidcData, @@ -50,6 +54,7 @@ class Profile { this.politicalView, this.professionalHeadline, this.profileUrl, + this.providers = const [], this.proxyEmail, this.publications = const [], this.relationshipStatus, @@ -98,13 +103,15 @@ class Profile { email: json['email'] as String?, favorites: _listFromJson(favorites, Favorite.fromJson), firstName: json['firstName'] as String?, - followers: json['followersCounts'] as int?, + followers: json['followersCount'] as int?, following: json['followingCount'] as int?, gender: json['gender'] as String?, hometown: json['hometown'] as String?, honors: json['honors'] as String?, industry: json['industry'] as String?, interests: json['interests'] as String?, + isConnected: json['isConnected'] as bool?, + isSiteUser: json['isSiteUser'] as bool?, languages: json['languages'] as String?, lastLoginLocation: lastLoginLocation == null ? null @@ -112,6 +119,8 @@ class Profile { lastName: json['lastName'] as String?, likes: _listFromJson(likes, Like.fromJson), locale: json['locale'] as String?, + loginProvider: json['loginProvider'] as String?, + loginProviderUID: json['loginProviderUID'] as String?, name: json['name'] as String?, nickname: json['nickname'] as String?, oidcData: oidcStruct == null ? null : OidcData.fromJson(oidcStruct), @@ -121,6 +130,7 @@ class Profile { politicalView: json['politicalView'] as String?, professionalHeadline: json['professionalHeadline'] as String?, profileUrl: json['profileURL'] as String?, + providers: json['providers'] as List? ?? const [], proxyEmail: json['proxyEmail'] as String?, publications: _listFromJson(publications, Publication.fromJson), @@ -204,6 +214,12 @@ class Profile { /// The person's interests. final String? interests; + /// Whether the user is connected to any available provider. + final bool? isConnected; + + /// Whether the current user is a user of the site. + final bool? isSiteUser; + /// The different languages that the person is proficient in. final String? languages; @@ -219,6 +235,12 @@ class Profile { /// The language locale of the person's primary language. final String? locale; + /// The name of the provider that the user used in order to log in. + final String? loginProvider; + + /// The user's ID from the login provider. + final String? loginProviderUID; + /// The person's full name. final String? name; @@ -246,6 +268,9 @@ class Profile { /// The url to the person's profile page. final String? profileUrl; + /// The names of the providers to which the user is connected/logged in. + final List providers; + /// The person's proxy email address. final String? proxyEmail; @@ -323,18 +348,22 @@ class Profile { if (favorites.isNotEmpty) 'favorites': favorites.map((Favorite f) => f.toJson()).toList(), 'firstName': firstName, - 'followersCounts': followers, + 'followersCount': followers, 'followingCount': following, 'gender': gender, 'hometown': hometown, 'honors': honors, 'industry': industry, 'interests': interests, + 'isConnected': isConnected, + 'isSiteUser': isSiteUser, 'languages': languages, if (lastLogin != null) 'lastLoginLocation': lastLogin.toJson(), 'lastName': lastName, if (likes.isNotEmpty) 'likes': likes.map((Like l) => l.toJson()).toList(), 'locale': locale, + 'loginProvider': loginProvider, + 'loginProviderUID': loginProviderUID, 'name': name, 'nickname': nickname, if (oidcStruct != null) 'oidcData': oidcStruct.toJson(), @@ -346,6 +375,7 @@ class Profile { 'politicalView': politicalView, 'professionalHeadline': professionalHeadline, 'profileURL': profileUrl, + 'providers': providers, 'proxyEmail': proxyEmail, if (publications.isNotEmpty) 'publications': diff --git a/lib/src/models/publication.dart b/lib/src/models/publication.dart index 06d37062..729e8a29 100644 --- a/lib/src/models/publication.dart +++ b/lib/src/models/publication.dart @@ -40,7 +40,7 @@ class Publication { /// Convert this object to a JSON object. Map toJson() { return { - 'date': date?.toString(), + 'date': date?.toIso8601String(), 'publisher': publisher, 'summary': summary, 'title': title, diff --git a/lib/src/models/session_info.dart b/lib/src/models/session_info.dart index 4dce0f42..7a140a6d 100644 --- a/lib/src/models/session_info.dart +++ b/lib/src/models/session_info.dart @@ -1,21 +1,44 @@ /// This class represents a session info object. +/// +/// When running on native platforms, this session info contains a session token and secret. +/// When running on the web, this session info contains a session cookie. class SessionInfo { /// The default constructor. SessionInfo.fromJson(Map json) - : expiresIn = json['expires_in'] as int, - sessionSecret = json['sessionSecret'] as String, - sessionToken = json['sessionToken'] as String; + : cookieName = json['cookieName'] as String?, + cookieValue = json['cookieValue'] as String?, + expiresIn = json['expires_in'] as int?, + sessionSecret = json['sessionSecret'] as String?, + sessionToken = json['sessionToken'] as String?; + + /// The name of the session cookie. + /// + /// This is null when not running on the web. + final String? cookieName; + + /// The value of the session cookie. + /// + /// This is null when not running on the web. + final String? cookieValue; /// The expiration time of the session, in seconds. - final int expiresIn; + /// + /// This is null when running on the web. + final int? expiresIn; /// The session secret. - final String sessionSecret; + /// + /// This is null when running on the web. + final String? sessionSecret; /// The session token. - final String sessionToken; + /// + /// This is null when running on the web. + final String? sessionToken; /// Convert this object into a JSON object. + /// + /// The session cookie is not serialized when calling this method. Map toJson() { return { 'sessionToken': sessionToken, diff --git a/lib/src/models/work.dart b/lib/src/models/work.dart index 7f48f020..db4728c1 100644 --- a/lib/src/models/work.dart +++ b/lib/src/models/work.dart @@ -16,22 +16,22 @@ class Work { /// The default constructor. factory Work.fromJson(Map json) { - final String? endDate = json['endDate'] as String?; - final String? startDate = json['startDate'] as String?; - - // TODO: company size should be an int, not a double. - final double? companySize = json['companySize'] as double?; + final int? companySize = switch (json['companySize']) { + final int size => size, + final double size => size.toInt(), + _ => null, + }; return Work._( company: json['company'] as String?, companyID: json['companyID'] as String?, - companySize: companySize?.toInt(), + companySize: companySize, description: json['description'] as String?, - endDate: endDate == null ? null : DateTime.tryParse(endDate), + endDate: DateTime.tryParse(json['endDate'] as String? ?? ''), industry: json['industry'] as String?, isCurrent: json['isCurrent'] as bool?, location: json['location'] as String?, - startDate: startDate == null ? null : DateTime.tryParse(startDate), + startDate: DateTime.tryParse(json['startDate'] as String? ?? ''), title: json['title'] as String?, ); } @@ -71,14 +71,13 @@ class Work { return { 'company': company, 'companyID': companyID, - // TODO: company size should be an int, not a double. - 'companySize': companySize?.toDouble(), + 'companySize': companySize, 'description': description, - 'endDate': endDate?.toString(), + 'endDate': endDate?.toIso8601String(), 'industry': industry, 'isCurrent': isCurrent, 'location': location, - 'startDate': startDate?.toString(), + 'startDate': startDate?.toIso8601String(), 'title': title, }; } From 04c07ad577fe5048ba6d437efccd2e90837fff9f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 5 Jun 2023 13:17:17 +0200 Subject: [PATCH 008/256] format --- example/lib/main.dart | 3 +-- .../routes/login_with_credentials_page.dart | 3 ++- .../lib/routes/manage_connections_page.dart | 4 +++- ...od_channel_web_authentication_service.dart | 3 ++- lib/src/models/account.dart | 21 ++++++++++++------- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index e9ffcb71..56aab2bd 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,8 +17,7 @@ void main() async { // Demonstrate explicit initialization before calling `runApp()`, // using the configuration for the example app. - const String exampleAppApiKey = - 'YOUR-API-KEY-HERE'; + const String exampleAppApiKey = 'YOUR-API-KEY-HERE'; const String exampleAppApiDomain = 'us1.gigya.com'; try { diff --git a/example/lib/routes/login_with_credentials_page.dart b/example/lib/routes/login_with_credentials_page.dart index 3b926e92..d88c327f 100644 --- a/example/lib/routes/login_with_credentials_page.dart +++ b/example/lib/routes/login_with_credentials_page.dart @@ -112,7 +112,8 @@ class _LoginWithCredentialsPageState extends State { } void _resolveLinkAccount(LinkAccountResolver resolver) async { - final ConflictingAccount? conflictingAccount = await resolver.conflictingAccount; + final ConflictingAccount? conflictingAccount = + await resolver.conflictingAccount; if (!mounted || conflictingAccount == null) { return; diff --git a/example/lib/routes/manage_connections_page.dart b/example/lib/routes/manage_connections_page.dart index c53accf1..74bf268e 100644 --- a/example/lib/routes/manage_connections_page.dart +++ b/example/lib/routes/manage_connections_page.dart @@ -121,7 +121,9 @@ class _ManageConnectionsPageState extends State { ), ) : ListView.builder( - itemBuilder: (_, int index) => Text(account.socialProviders[index]), + itemBuilder: (_, int index) => Text( + account.socialProviders[index], + ), itemCount: account.socialProviders.length, ), ), diff --git a/lib/src/method_channel/method_channel_web_authentication_service.dart b/lib/src/method_channel/method_channel_web_authentication_service.dart index 5f0f40ad..cf06eb3e 100644 --- a/lib/src/method_channel/method_channel_web_authentication_service.dart +++ b/lib/src/method_channel/method_channel_web_authentication_service.dart @@ -16,7 +16,8 @@ class MethodChannelWebAuthenticationService extends WebAuthenticationService { @override Future> login() async { try { - final Map? result = await _channel.invokeMapMethod( + final Map? result = + await _channel.invokeMapMethod( WebAuthnMethods.login.methodName, {}, ).timeout( diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index a77317fc..71bc0b85 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -26,11 +26,14 @@ class Account { /// Construct an account from the given [json]. factory Account.fromJson(Map json) { final String? createdTimestamp = json['createdTimestamp'] as String?; - final Map? emails = (json['emails'] as Map?)?.cast(); - final Map? profile = (json['profile'] as Map?)?.cast(); + final Map? emails = + (json['emails'] as Map?)?.cast(); + final Map? profile = + (json['profile'] as Map?)?.cast(); final String? lastLoginTimestamp = json['lastLogin'] as String?; final String? lastUpdatedTimestamp = json['lastUpdated'] as String?; - final String? oldestDataUpdateTimestamp = json['oldestDataUpdated'] as String?; + final String? oldestDataUpdateTimestamp = + json['oldestDataUpdated'] as String?; final String? registeredTimestamp = json['registered'] as String?; final String? verifiedTimestamp = json['verified'] as String?; final String socialProviders = json['socialProviders'] as String? ?? ''; @@ -39,8 +42,10 @@ class Account { // or the number of seconds since the UNIX epoch (1 Jan 1970). final DateTime? signatureTimestamp = switch (json['signatureTimestamp']) { final String timestamp => DateTime.parse(timestamp), - final int timestamp => DateTime.fromMillisecondsSinceEpoch(timestamp * 1000), - final double timestamp => DateTime.fromMillisecondsSinceEpoch(timestamp.toInt() * 1000), + final int timestamp => + DateTime.fromMillisecondsSinceEpoch(timestamp * 1000), + final double timestamp => + DateTime.fromMillisecondsSinceEpoch(timestamp.toInt() * 1000), _ => null, }; @@ -53,7 +58,8 @@ class Account { lastLoginTimestamp: DateTime.tryParse(lastLoginTimestamp ?? ''), lastUpdatedTimestamp: DateTime.tryParse(lastUpdatedTimestamp ?? ''), loginProvider: json['loginProvider'] as String?, - oldestDataUpdateTimestamp: DateTime.tryParse(oldestDataUpdateTimestamp ?? ''), + oldestDataUpdateTimestamp: + DateTime.tryParse(oldestDataUpdateTimestamp ?? ''), profile: profile == null ? null : Profile.fromJson(profile), registeredTimestamp: DateTime.tryParse(registeredTimestamp ?? ''), signatureTimestamp: signatureTimestamp, @@ -130,7 +136,8 @@ class Account { 'lastLoginTimestamp': lastLoginTimestamp?.toIso8601String(), 'lastUpdatedTimestamp': lastUpdatedTimestamp?.toIso8601String(), 'loginProvider': loginProvider, - 'oldestDataUpdatedTimestamp': oldestDataUpdateTimestamp?.toIso8601String(), + 'oldestDataUpdatedTimestamp': + oldestDataUpdateTimestamp?.toIso8601String(), if (accountProfile != null) 'profile': accountProfile.toJson(), 'registeredTimestamp': registeredTimestamp?.toIso8601String(), 'signatureTimestamp': signatureTimestamp?.toIso8601String(), From 43a18813ae8f143374dd157ed6445f8df6ba99b9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 7 Jun 2023 11:50:20 +0200 Subject: [PATCH 009/256] convert screenset yield generator to use a tear-off --- .../gigya_flutter_plugin_method_channel.dart | 27 +++++-------------- lib/src/models/screenset_event.dart | 13 +++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart index a3301ff7..983c4ee5 100644 --- a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart +++ b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart @@ -350,26 +350,13 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform { throw GigyaError.fromPlatformException(exception); } - yield* screenSetEvents.receiveBroadcastStream().map((dynamic event) { - // The binary messenger sends things back as `dynamic`. - // If the event is a `Map`, - // it does not have type information and comes back as `Map`. - // Cast it using `Map.cast()` to at least recover the type of the key. - // The values are still `Object?`, though. - final Map typedEvent = - (event as Map).cast(); - - // Now grab the data of the event, - // using `Map.cast()` to recover the type of the keys. - final Map? data = - (typedEvent['data'] as Map?) - ?.cast(); - - return ScreensetEvent( - typedEvent['event'] as String, - data ?? {}, - ); - }); + // The binary messenger sends things back as `dynamic`, + // but the events are actually a `Map`. + // Cast using the `map()` Stream transformer. + yield* screenSetEvents + .receiveBroadcastStream() + .cast>() + .map(ScreensetEvent.fromMap); } @override diff --git a/lib/src/models/screenset_event.dart b/lib/src/models/screenset_event.dart index f4d26951..8929c6ad 100644 --- a/lib/src/models/screenset_event.dart +++ b/lib/src/models/screenset_event.dart @@ -13,6 +13,19 @@ class ScreensetEvent { return ScreensetEvent._(resolvedType, data); } + /// Construct a new [ScreensetEvent] from the given, loosely-typed [map]. + /// + /// The map is expected to have an `event` key, denoting the name of the event. + /// The map can have a `data` key, which is a [Map] that contains any data for the event. + factory ScreensetEvent.fromMap(Map map) { + final Map? data = map['data'] as Map?; + + return ScreensetEvent( + map['event'] as String, + data?.cast() ?? const {}, + ); + } + /// The private constructor. const ScreensetEvent._(this.type, this.data); From 3910ebbbb424d10e4824f873d4be5b2bf733c77c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 7 Jun 2023 12:03:41 +0200 Subject: [PATCH 010/256] fix cast failure --- lib/src/models/profile.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/models/profile.dart b/lib/src/models/profile.dart index c993ae67..57210f03 100644 --- a/lib/src/models/profile.dart +++ b/lib/src/models/profile.dart @@ -82,6 +82,7 @@ class Profile { json['oidcData'] as Map?; final List? patents = json['patents'] as List?; final List? phones = json['phones'] as List?; + final List? providers = json['providers'] as List?; final List? publications = json['publications'] as List?; final List? skills = json['skills'] as List?; final List? work = json['work'] as List?; @@ -130,7 +131,7 @@ class Profile { politicalView: json['politicalView'] as String?, professionalHeadline: json['professionalHeadline'] as String?, profileUrl: json['profileURL'] as String?, - providers: json['providers'] as List? ?? const [], + providers: providers?.cast() ?? const [], proxyEmail: json['proxyEmail'] as String?, publications: _listFromJson(publications, Publication.fromJson), From e5913b1976b28c4a87cff7f661a2ed0d9055dbde Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 8 Sep 2023 14:12:04 +0200 Subject: [PATCH 011/256] add TODO for biometrics service --- .../gigya_flutter_plugin_platform_interface.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart index b4754dd0..c5c17e3e 100644 --- a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart +++ b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart @@ -30,6 +30,9 @@ abstract class GigyaFlutterPluginPlatform extends PlatformInterface { _instance = instance; } + // TODO(navaronbracke): Move the Biometrics service to `src/method_channel/method_channel_biometrics_service.dart` + // during the next rebase. See https://github.com/SAP/gigya-flutter-plugin/pull/77 + /// Get the interruption resolver factory provided by the Gigya SDK. InterruptionResolverFactory get interruptionResolverFactory { throw UnimplementedError( From 1d0cd6a490527d0b0ab60a076ea868772e54b48b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 24 Sep 2023 19:58:30 +0200 Subject: [PATCH 012/256] remove outdated comment --- lib/src/method_channel/gigya_flutter_plugin_method_channel.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart index 983c4ee5..f2f28fdc 100644 --- a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart +++ b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart @@ -352,7 +352,6 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform { // The binary messenger sends things back as `dynamic`, // but the events are actually a `Map`. - // Cast using the `map()` Stream transformer. yield* screenSetEvents .receiveBroadcastStream() .cast>() From 15f15426b31d7d03c4d176b72583f04cdaa31061 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 24 Sep 2023 20:54:50 +0200 Subject: [PATCH 013/256] correct timestamp attribute names in account --- lib/src/models/account.dart | 77 +++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index 71bc0b85..272bdda5 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -6,72 +6,66 @@ class Account { /// The default constructor. Account({ required this.emails, - this.createdTimestamp, + this.created, this.isActive, this.isRegistered, this.isVerified, - this.lastLoginTimestamp, - this.lastUpdatedTimestamp, + this.lastLogin, + this.lastUpdated, this.loginProvider, - this.oldestDataUpdateTimestamp, + this.oldestDataUpdated, this.profile, - this.registeredTimestamp, + this.registered, this.signatureTimestamp, this.socialProviders = const [], this.uid, this.uidSignature, - this.verifiedTimestamp, + this.verified, }); /// Construct an account from the given [json]. factory Account.fromJson(Map json) { - final String? createdTimestamp = json['createdTimestamp'] as String?; - final Map? emails = - (json['emails'] as Map?)?.cast(); - final Map? profile = - (json['profile'] as Map?)?.cast(); - final String? lastLoginTimestamp = json['lastLogin'] as String?; - final String? lastUpdatedTimestamp = json['lastUpdated'] as String?; - final String? oldestDataUpdateTimestamp = - json['oldestDataUpdated'] as String?; - final String? registeredTimestamp = json['registered'] as String?; - final String? verifiedTimestamp = json['verified'] as String?; + final String? created = json['created'] as String?; + final Map? emails = (json['emails'] as Map?)?.cast(); + final Map? profile = (json['profile'] as Map?)?.cast(); + final String? lastLogin = json['lastLogin'] as String?; + final String? lastUpdated = json['lastUpdated'] as String?; + final String? oldestDataUpdated = json['oldestDataUpdated'] as String?; + final String? registered = json['registered'] as String?; + final String? verified = json['verified'] as String?; final String socialProviders = json['socialProviders'] as String? ?? ''; // The signature timestamp can be either an ISO 8601 date, // or the number of seconds since the UNIX epoch (1 Jan 1970). final DateTime? signatureTimestamp = switch (json['signatureTimestamp']) { final String timestamp => DateTime.parse(timestamp), - final int timestamp => - DateTime.fromMillisecondsSinceEpoch(timestamp * 1000), - final double timestamp => - DateTime.fromMillisecondsSinceEpoch(timestamp.toInt() * 1000), + final int timestamp => DateTime.fromMillisecondsSinceEpoch(timestamp * 1000), + final double timestamp => DateTime.fromMillisecondsSinceEpoch(timestamp.toInt() * 1000), _ => null, }; return Account( emails: emails == null ? const Emails() : Emails.fromJson(emails), - createdTimestamp: DateTime.tryParse(createdTimestamp ?? ''), + created: DateTime.tryParse(created ?? ''), isActive: json['isActive'] as bool?, isRegistered: json['isRegistered'] as bool?, isVerified: json['isVerified'] as bool?, - lastLoginTimestamp: DateTime.tryParse(lastLoginTimestamp ?? ''), - lastUpdatedTimestamp: DateTime.tryParse(lastUpdatedTimestamp ?? ''), + lastLogin: DateTime.tryParse(lastLogin ?? ''), + lastUpdated: DateTime.tryParse(lastUpdated ?? ''), loginProvider: json['loginProvider'] as String?, - oldestDataUpdateTimestamp: - DateTime.tryParse(oldestDataUpdateTimestamp ?? ''), + oldestDataUpdated: DateTime.tryParse(oldestDataUpdated ?? ''), profile: profile == null ? null : Profile.fromJson(profile), - registeredTimestamp: DateTime.tryParse(registeredTimestamp ?? ''), + registered: DateTime.tryParse(registered ?? ''), signatureTimestamp: signatureTimestamp, socialProviders: socialProviders.split(','), uid: json['UID'] as String?, uidSignature: json['UIDSignature'] as String?, - verifiedTimestamp: DateTime.tryParse(verifiedTimestamp ?? ''), + verified: DateTime.tryParse(verified ?? ''), ); } /// The timestamp, in UTC, on which the account was created. - final DateTime? createdTimestamp; + final DateTime? created; /// Whether this account is active. final bool? isActive; @@ -86,11 +80,11 @@ class Account { final Emails emails; /// The timestamp of the last login of the user. - final DateTime? lastLoginTimestamp; + final DateTime? lastLogin; /// The timestamp, in UTC, when the user's profile, preferences, /// or subscriptions data was last updated. - final DateTime? lastUpdatedTimestamp; + final DateTime? lastUpdated; /// The name of current login provider for this account. /// @@ -98,14 +92,14 @@ class Account { /// then the value of this attribute will be `site`. final String? loginProvider; - /// The timestamp, in UTC, when the oldest data of the user was refreshed. - final DateTime? oldestDataUpdateTimestamp; + /// The timestamp, in UTC, of the oldest update to the user's account data. + final DateTime? oldestDataUpdated; /// The profile linked to this account. final Profile? profile; /// The timestamp, in UTC, when the user was registered. - final DateTime? registeredTimestamp; + final DateTime? registered; /// The timestamp of the [uidSignature], in UTC. /// This signature should be used for login validation. @@ -121,30 +115,29 @@ class Account { final String? uidSignature; /// The timestamp, in UTC, when the user was verified. - final DateTime? verifiedTimestamp; + final DateTime? verified; /// Convert this object into a JSON object. Map toJson() { final Profile? accountProfile = profile; return { - 'createdTimestamp': createdTimestamp?.toIso8601String(), + 'created': created?.toIso8601String(), 'emails': emails.toJson(), 'isActive': isActive, 'isRegistered': isRegistered, 'isVerified': isVerified, - 'lastLoginTimestamp': lastLoginTimestamp?.toIso8601String(), - 'lastUpdatedTimestamp': lastUpdatedTimestamp?.toIso8601String(), + 'lastLogin': lastLogin?.toIso8601String(), + 'lastUpdated': lastUpdated?.toIso8601String(), 'loginProvider': loginProvider, - 'oldestDataUpdatedTimestamp': - oldestDataUpdateTimestamp?.toIso8601String(), + 'oldestDataUpdated': oldestDataUpdated?.toIso8601String(), if (accountProfile != null) 'profile': accountProfile.toJson(), - 'registeredTimestamp': registeredTimestamp?.toIso8601String(), + 'registered': registered?.toIso8601String(), 'signatureTimestamp': signatureTimestamp?.toIso8601String(), 'socialProviders': socialProviders, 'UID': uid, 'UIDSignature': uidSignature, - 'verifiedTimestamp': verifiedTimestamp?.toIso8601String(), + 'verified': verified?.toIso8601String(), }; } } From cdba9497e9afa23e627d34c8957f48132c5d28c6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 24 Sep 2023 21:01:56 +0200 Subject: [PATCH 014/256] make emails optional in the account constructor; support data map --- lib/src/models/account.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index 272bdda5..cebeef3f 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -5,8 +5,9 @@ import 'profile.dart'; class Account { /// The default constructor. Account({ - required this.emails, + this.emails = const Emails(), this.created, + this.data = const {}, this.isActive, this.isRegistered, this.isVerified, @@ -45,8 +46,9 @@ class Account { }; return Account( - emails: emails == null ? const Emails() : Emails.fromJson(emails), created: DateTime.tryParse(created ?? ''), + data: (json['data'] as Map?)?.cast(), + emails: emails == null ? const Emails() : Emails.fromJson(emails), isActive: json['isActive'] as bool?, isRegistered: json['isRegistered'] as bool?, isVerified: json['isVerified'] as bool?, @@ -67,6 +69,12 @@ class Account { /// The timestamp, in UTC, on which the account was created. final DateTime? created; + /// The custom data for the account, which is not part of the [profile]. + final Map? data; + + /// The list of email addresses for the account. + final Emails emails; + /// Whether this account is active. final bool? isActive; @@ -76,9 +84,6 @@ class Account { /// Whether this account is verified. final bool? isVerified; - /// The list of email addresses for the account. - final Emails emails; - /// The timestamp of the last login of the user. final DateTime? lastLogin; @@ -123,6 +128,7 @@ class Account { return { 'created': created?.toIso8601String(), + 'data': data, 'emails': emails.toJson(), 'isActive': isActive, 'isRegistered': isRegistered, From 9fe1cef124e6224d048f6875324e0ebe2b6c9297 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 24 Sep 2023 21:03:14 +0200 Subject: [PATCH 015/256] fix version constraint --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 59c0c0e3..6efee1c3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,8 +4,8 @@ version: 1.0.1 homepage: https://github.com/SAP/gigya-flutter-plugin environment: - sdk: ">=2.18.0 <4.0.0" - flutter: ">=3.3.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" dependencies: flutter: From 59e1ab711258c5fc15b370320e2ca9107cb30344 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 24 Sep 2023 21:16:10 +0200 Subject: [PATCH 016/256] format --- lib/src/models/account.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index cebeef3f..70fbd5f3 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -27,8 +27,10 @@ class Account { /// Construct an account from the given [json]. factory Account.fromJson(Map json) { final String? created = json['created'] as String?; - final Map? emails = (json['emails'] as Map?)?.cast(); - final Map? profile = (json['profile'] as Map?)?.cast(); + final Map? emails = + (json['emails'] as Map?)?.cast(); + final Map? profile = + (json['profile'] as Map?)?.cast(); final String? lastLogin = json['lastLogin'] as String?; final String? lastUpdated = json['lastUpdated'] as String?; final String? oldestDataUpdated = json['oldestDataUpdated'] as String?; @@ -40,8 +42,10 @@ class Account { // or the number of seconds since the UNIX epoch (1 Jan 1970). final DateTime? signatureTimestamp = switch (json['signatureTimestamp']) { final String timestamp => DateTime.parse(timestamp), - final int timestamp => DateTime.fromMillisecondsSinceEpoch(timestamp * 1000), - final double timestamp => DateTime.fromMillisecondsSinceEpoch(timestamp.toInt() * 1000), + final int timestamp => + DateTime.fromMillisecondsSinceEpoch(timestamp * 1000), + final double timestamp => + DateTime.fromMillisecondsSinceEpoch(timestamp.toInt() * 1000), _ => null, }; From c9b732a270484cc9b7fa530ce24e326394b26385 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 12:42:16 +0100 Subject: [PATCH 017/256] implement stub for GigyaFlutterPlugin on the web --- .../gigya_flutter_plugin_web.dart | 15 +++++++++++++++ pubspec.yaml | 5 +++++ 2 files changed, 20 insertions(+) create mode 100644 lib/src/platform_interface/gigya_flutter_plugin_web.dart diff --git a/lib/src/platform_interface/gigya_flutter_plugin_web.dart b/lib/src/platform_interface/gigya_flutter_plugin_web.dart new file mode 100644 index 00000000..0dcbeb6f --- /dev/null +++ b/lib/src/platform_interface/gigya_flutter_plugin_web.dart @@ -0,0 +1,15 @@ +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +import 'gigya_flutter_plugin_platform_interface.dart'; + +/// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. +class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { + /// Register [GigyaFlutterPluginWeb] as the default implementation for the web plugin. + /// + /// This method is used by the `GeneratedPluginRegistrant` class. + static void registerWith(Registrar registrar) { + GigyaFlutterPluginPlatform.instance = GigyaFlutterPluginWeb(); + } + + // TODO: implement the platform interface +} diff --git a/pubspec.yaml b/pubspec.yaml index 6efee1c3..0f08ad03 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,8 @@ environment: dependencies: flutter: sdk: flutter + flutter_web_plugins: + sdk: flutter plugin_platform_interface: ^2.0.2 dev_dependencies: @@ -27,6 +29,9 @@ flutter: pluginClass: GigyaFlutterPlugin ios: pluginClass: GigyaFlutterPlugin + web: + pluginClass: GigyaFlutterPluginWeb + fileName: src/platform_interface/gigya_flutter_plugin_web.dart false_secrets: - example/android/app/src/main/res/values/strings.xml From d5a185916ede50771d5d16d6aefb5458ec57704e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 12:58:32 +0100 Subject: [PATCH 018/256] move method channel implementation to src/method_channel; move service interfaces to src/services; move web stub to src/web --- .../{platform_interface => web}/gigya_flutter_plugin_web.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename lib/src/{platform_interface => web}/gigya_flutter_plugin_web.dart (87%) diff --git a/lib/src/platform_interface/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart similarity index 87% rename from lib/src/platform_interface/gigya_flutter_plugin_web.dart rename to lib/src/web/gigya_flutter_plugin_web.dart index 0dcbeb6f..af93e543 100644 --- a/lib/src/platform_interface/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -1,6 +1,6 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; -import 'gigya_flutter_plugin_platform_interface.dart'; +import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { From 2a4a47f9f7ba96203af96782d4656b9158148a99 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 13:00:55 +0100 Subject: [PATCH 019/256] update web implementation path in pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 0f08ad03..81f6b512 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,7 +31,7 @@ flutter: pluginClass: GigyaFlutterPlugin web: pluginClass: GigyaFlutterPluginWeb - fileName: src/platform_interface/gigya_flutter_plugin_web.dart + fileName: src/web/gigya_flutter_plugin_web.dart false_secrets: - example/android/app/src/main/res/values/strings.xml From f6f17fff729836f4b91d4ec13741c4e8ccfbfc70 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 14:16:40 +0100 Subject: [PATCH 020/256] depend on package:js --- example/pubspec.lock | 42 +++++++++++++++++++++++++----------------- pubspec.yaml | 5 +++-- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 14aaae56..07ba346e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.18.0" fake_async: dependency: transitive description: @@ -163,26 +163,26 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" path: dependency: transitive description: @@ -216,26 +216,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -256,10 +256,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.1" vector_math: dependency: transitive description: @@ -268,6 +268,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: "14f1f70c51119012600c5f1f60ca68efda5a9b6077748163c6af2893ec5df8fc" + url: "https://pub.dev" + source: hosted + version: "0.2.1-beta" sdks: - dart: ">=3.0.0 <4.0.0" + dart: ">=3.2.0-157.0.dev <4.0.0" flutter: ">=3.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 81f6b512..cabf1f6e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,9 @@ dependencies: flutter: sdk: flutter flutter_web_plugins: - sdk: flutter + sdk: flutter + + js: ">=0.6.6" plugin_platform_interface: ^2.0.2 dev_dependencies: @@ -21,7 +23,6 @@ dev_dependencies: sdk: flutter flutter: - plugin: platforms: android: From 857cc8900ee2c3fc5e287e58af6d2bfa9b3ac776 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 14:47:17 +0100 Subject: [PATCH 021/256] create static interop class for JSWindow --- lib/src/web/gigya_js_interop.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/src/web/gigya_js_interop.dart diff --git a/lib/src/web/gigya_js_interop.dart b/lib/src/web/gigya_js_interop.dart new file mode 100644 index 00000000..3be10c62 --- /dev/null +++ b/lib/src/web/gigya_js_interop.dart @@ -0,0 +1,17 @@ +import 'dart:html' as html; + +import 'package:js/js.dart'; + +/// The static interop class for [html.Window]. +@JS() +@staticInterop +class JSWindow {} + +/// This extension defines the static interop definition +/// for the [html.Window] class. +extension JSWindowExtension on JSWindow { + /// Set the `onGigyaServiceReady` function on the [html.Window]. + /// + /// This function is called when the Gigya Web SDK has been initialized. + external set onGigyaServiceReady(void Function() onReady); +} From 337baf34e52285cb65be55aa5879bebad7f7682c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 14:49:13 +0100 Subject: [PATCH 022/256] implement initSdk() for web --- lib/src/web/gigya_flutter_plugin_web.dart | 40 ++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index af93e543..13f04b7f 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -1,6 +1,10 @@ +import 'dart:async'; +import 'dart:html' as html; + import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; +import 'gigya_js_interop.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { @@ -11,5 +15,39 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { GigyaFlutterPluginPlatform.instance = GigyaFlutterPluginWeb(); } - // TODO: implement the platform interface + @override + Future initSdk({ + required String apiDomain, + required String apiKey, + bool forceLogout = true, + }) async { + final Completer onGigyaServiceReadyCompleter = Completer(); + final JSWindow domWindow = html.window as JSWindow; + + // Set `window.onGigyaServiceReady` before creating the script. + // That function is called when the SDK has been initialized. + domWindow.onGigyaServiceReady = () { + if (!onGigyaServiceReadyCompleter.isCompleted) { + onGigyaServiceReadyCompleter.complete(); + } + }; + + final html.ScriptElement script = html.ScriptElement() + ..async = true + ..defer = false + ..type = 'text/javascript' + ..lang = 'javascript' + ..crossOrigin = 'anonymous' + ..src = 'cdns.$apiDomain/js/gigya.js?apikey=$apiKey'; + + html.document.head!.append(script); + + await script.onLoad.first; + + if (forceLogout) { + await logout(); + } + + return onGigyaServiceReadyCompleter.future; + } } From 4c84d13bb7fb69f20b5086bc08e0fc6a19b8367a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 15:17:24 +0100 Subject: [PATCH 023/256] fix bug with initSdk() --- lib/src/web/gigya_flutter_plugin_web.dart | 7 ++++--- lib/src/web/gigya_js_interop.dart | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 13f04b7f..dc22a895 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:html' as html; +import 'dart:js_util'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; @@ -26,11 +27,11 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { // Set `window.onGigyaServiceReady` before creating the script. // That function is called when the SDK has been initialized. - domWindow.onGigyaServiceReady = () { + domWindow.onGigyaServiceReady = allowInterop((Object? arguments) { if (!onGigyaServiceReadyCompleter.isCompleted) { onGigyaServiceReadyCompleter.complete(); } - }; + }); final html.ScriptElement script = html.ScriptElement() ..async = true @@ -38,7 +39,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { ..type = 'text/javascript' ..lang = 'javascript' ..crossOrigin = 'anonymous' - ..src = 'cdns.$apiDomain/js/gigya.js?apikey=$apiKey'; + ..src = 'https://cdns.$apiDomain/js/gigya.js?apikey=$apiKey'; html.document.head!.append(script); diff --git a/lib/src/web/gigya_js_interop.dart b/lib/src/web/gigya_js_interop.dart index 3be10c62..f76767d9 100644 --- a/lib/src/web/gigya_js_interop.dart +++ b/lib/src/web/gigya_js_interop.dart @@ -13,5 +13,5 @@ extension JSWindowExtension on JSWindow { /// Set the `onGigyaServiceReady` function on the [html.Window]. /// /// This function is called when the Gigya Web SDK has been initialized. - external set onGigyaServiceReady(void Function() onReady); + external set onGigyaServiceReady(void Function(Object? arguments) onReady); } From 9b99f19ca920e54b693048d27119091175bd56d6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 15:17:54 +0100 Subject: [PATCH 024/256] add stubs for login & logout --- lib/src/web/gigya_flutter_plugin_web.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index dc22a895..5193a963 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -51,4 +51,14 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return onGigyaServiceReadyCompleter.future; } + + @override + Future isLoggedIn() { + return Future.value(false); + } + + @override + Future logout() { + return Future.value(); + } } From e9a25a919ce181d48ee48d16a7a49291124229f8 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 15:47:32 +0100 Subject: [PATCH 025/256] add stub for gigya JS object through static interop --- lib/src/web/gigya_js_interop.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/web/gigya_js_interop.dart b/lib/src/web/gigya_js_interop.dart index f76767d9..32277397 100644 --- a/lib/src/web/gigya_js_interop.dart +++ b/lib/src/web/gigya_js_interop.dart @@ -15,3 +15,12 @@ extension JSWindowExtension on JSWindow { /// This function is called when the Gigya Web SDK has been initialized. external set onGigyaServiceReady(void Function(Object? arguments) onReady); } + +/// The static interop class for the `gigya` JavaScript object. +@JS('gigya') +@staticInterop +class GigyaWebSdk {} + +/// This extension defines the static interop definition +/// for the [GigyaWebSdk] class. +extension GigyaWebSdkExtension on GigyaWebSdk {} From 2d38e5f565b290fee0acaa82007e1b95a2bb9015 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 14 Mar 2023 16:48:00 +0100 Subject: [PATCH 026/256] fix window.gigya getter --- lib/src/web/gigya_js_interop.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/web/gigya_js_interop.dart b/lib/src/web/gigya_js_interop.dart index 32277397..d98e35c3 100644 --- a/lib/src/web/gigya_js_interop.dart +++ b/lib/src/web/gigya_js_interop.dart @@ -16,8 +16,12 @@ extension JSWindowExtension on JSWindow { external set onGigyaServiceReady(void Function(Object? arguments) onReady); } +/// Get the `gigya` JavaScript object. +@JS('window.gigya') +external GigyaWebSdk get gigyaWebSdk; + /// The static interop class for the `gigya` JavaScript object. -@JS('gigya') +@JS() @staticInterop class GigyaWebSdk {} From 6bbdc45307951e845def231c47f688029d6cc900 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 13:20:13 +0100 Subject: [PATCH 027/256] remove the old static interop file --- lib/src/web/gigya_js_interop.dart | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 lib/src/web/gigya_js_interop.dart diff --git a/lib/src/web/gigya_js_interop.dart b/lib/src/web/gigya_js_interop.dart deleted file mode 100644 index d98e35c3..00000000 --- a/lib/src/web/gigya_js_interop.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'dart:html' as html; - -import 'package:js/js.dart'; - -/// The static interop class for [html.Window]. -@JS() -@staticInterop -class JSWindow {} - -/// This extension defines the static interop definition -/// for the [html.Window] class. -extension JSWindowExtension on JSWindow { - /// Set the `onGigyaServiceReady` function on the [html.Window]. - /// - /// This function is called when the Gigya Web SDK has been initialized. - external set onGigyaServiceReady(void Function(Object? arguments) onReady); -} - -/// Get the `gigya` JavaScript object. -@JS('window.gigya') -external GigyaWebSdk get gigyaWebSdk; - -/// The static interop class for the `gigya` JavaScript object. -@JS() -@staticInterop -class GigyaWebSdk {} - -/// This extension defines the static interop definition -/// for the [GigyaWebSdk] class. -extension GigyaWebSdkExtension on GigyaWebSdk {} From b2f5740bb09bb7a8953b62cd434e8ffce837b96e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 13:20:50 +0100 Subject: [PATCH 028/256] move the window JS interop to its own file --- lib/src/web/static_interop/window.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/src/web/static_interop/window.dart diff --git a/lib/src/web/static_interop/window.dart b/lib/src/web/static_interop/window.dart new file mode 100644 index 00000000..f76767d9 --- /dev/null +++ b/lib/src/web/static_interop/window.dart @@ -0,0 +1,17 @@ +import 'dart:html' as html; + +import 'package:js/js.dart'; + +/// The static interop class for [html.Window]. +@JS() +@staticInterop +class JSWindow {} + +/// This extension defines the static interop definition +/// for the [html.Window] class. +extension JSWindowExtension on JSWindow { + /// Set the `onGigyaServiceReady` function on the [html.Window]. + /// + /// This function is called when the Gigya Web SDK has been initialized. + external set onGigyaServiceReady(void Function(Object? arguments) onReady); +} From 5bdc2f1ea2a4cfe562ce89016f9d4a4ffc18b155 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 13:21:44 +0100 Subject: [PATCH 029/256] move the gigya web sdk interop to its own file --- lib/src/web/static_interop/gigya_web_sdk.dart | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/src/web/static_interop/gigya_web_sdk.dart diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart new file mode 100644 index 00000000..c25546bf --- /dev/null +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -0,0 +1,21 @@ +import 'package:js/js.dart'; + +import 'account.dart'; + +/// Get the `gigya` JavaScript object. +@JS('window.gigya') +external GigyaWebSdk get gigyaWebSdk; + +/// The static interop class for the `gigya` JavaScript object. +@JS() +@staticInterop +class GigyaWebSdk {} + +/// This extension defines the static interop definition +/// for the [GigyaWebSdk] class. +extension GigyaWebSdkExtension on GigyaWebSdk { + /// Get the accounts namespace in the Gigya Web SDK. + external Accounts get accounts; + + // TODO: socialize & sso namespace +} From 4687c6b55b3505c952ea95e821b085b150ede607 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 13:24:19 +0100 Subject: [PATCH 030/256] add link to docs --- lib/src/web/static_interop/gigya_web_sdk.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index c25546bf..1cdef814 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -7,6 +7,8 @@ import 'account.dart'; external GigyaWebSdk get gigyaWebSdk; /// The static interop class for the `gigya` JavaScript object. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417f6b5e70b21014bbc5a10ce4041860.html @JS() @staticInterop class GigyaWebSdk {} From c9a758fdb57c1d082597982b88d8a4a07c4ef26f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 13:24:41 +0100 Subject: [PATCH 031/256] add static interop for the response class --- lib/src/web/static_interop/response.dart | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/src/web/static_interop/response.dart diff --git a/lib/src/web/static_interop/response.dart b/lib/src/web/static_interop/response.dart new file mode 100644 index 00000000..25a4399c --- /dev/null +++ b/lib/src/web/static_interop/response.dart @@ -0,0 +1,28 @@ +import 'package:js/js.dart'; + +/// The static interop class for the Gigya `Response` class. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d55f070b21014bbc5a10ce4041860.html +@JS() +@anonymous +class Response { + /// Construct a [Response] object. + external factory Response({String callId, Object? context, int errorCode, String errorMessage}); + + /// The unique identifier of the transaction. + external String get callId; + + /// The context that was passed to the method that responded with this [Response]. + external Object? get context; + + /// The response error code. + /// + /// A value of zero indicates success. + /// Any other number indicates a failure. + /// + /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html + external int get errorCode; + + /// The error message for the given [errorCode]. + external String get errorMessage; +} From b685a96c5e05af635b1fd5c997c4d4bea1270c7b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 13:34:55 +0100 Subject: [PATCH 032/256] use relative import for implementation details --- .../method_channel_web_authentication_service.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/method_channel/method_channel_web_authentication_service.dart b/lib/src/method_channel/method_channel_web_authentication_service.dart index cf06eb3e..5f0f40ad 100644 --- a/lib/src/method_channel/method_channel_web_authentication_service.dart +++ b/lib/src/method_channel/method_channel_web_authentication_service.dart @@ -16,8 +16,7 @@ class MethodChannelWebAuthenticationService extends WebAuthenticationService { @override Future> login() async { try { - final Map? result = - await _channel.invokeMapMethod( + final Map? result = await _channel.invokeMapMethod( WebAuthnMethods.login.methodName, {}, ).timeout( From 5a5451c51787f4952db7ad267ec01703f3abace3 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 14:01:54 +0100 Subject: [PATCH 033/256] implement opaque object for Gigya Web SDK method params --- .../web/static_interop/gigya_method_parameters.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lib/src/web/static_interop/gigya_method_parameters.dart diff --git a/lib/src/web/static_interop/gigya_method_parameters.dart b/lib/src/web/static_interop/gigya_method_parameters.dart new file mode 100644 index 00000000..782ee4a7 --- /dev/null +++ b/lib/src/web/static_interop/gigya_method_parameters.dart @@ -0,0 +1,11 @@ +import 'package:js/js.dart'; + +import 'response.dart'; + +/// This class represents the parameters object for the various Gigya Web SDK methods. +@JS() +@anonymous +class GigyaMethodParameters { + /// Create a [GigyaMethodParameters] instance using the given [callback] and [context]. + external factory GigyaMethodParameters({void Function(Response response) callback, Object? context}); +} From 6705edd552dc946ec791fd786bce49a45f028c41 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 14:02:12 +0100 Subject: [PATCH 034/256] remove TODO for now --- lib/src/web/static_interop/gigya_web_sdk.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index 1cdef814..d86116f4 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -18,6 +18,4 @@ class GigyaWebSdk {} extension GigyaWebSdkExtension on GigyaWebSdk { /// Get the accounts namespace in the Gigya Web SDK. external Accounts get accounts; - - // TODO: socialize & sso namespace } From 4df546c0d384deaa3054d23bc3e68a8c4e0b4cb0 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 14:27:23 +0100 Subject: [PATCH 035/256] add error details & api version to web response --- lib/src/web/static_interop/response.dart | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/response.dart b/lib/src/web/static_interop/response.dart index 25a4399c..18d5299d 100644 --- a/lib/src/web/static_interop/response.dart +++ b/lib/src/web/static_interop/response.dart @@ -7,7 +7,17 @@ import 'package:js/js.dart'; @anonymous class Response { /// Construct a [Response] object. - external factory Response({String callId, Object? context, int errorCode, String errorMessage}); + external factory Response({ + int? apiVersion, + String callId, + Object? context, + int errorCode, + String? errorDetails, + String errorMessage, + }); + + /// The version of the Gigya API that was used. + external int? get apiVersion; /// The unique identifier of the transaction. external String get callId; @@ -23,6 +33,9 @@ class Response { /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html external int get errorCode; + /// The additional details of the encountered error. + external String? get errorDetails; + /// The error message for the given [errorCode]. external String get errorMessage; } From 3a14c84f2147115e9a412a2a4f8750198ad10965 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 14:58:50 +0100 Subject: [PATCH 036/256] implement web error code enum --- lib/src/web/web_error_code.dart | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/src/web/web_error_code.dart diff --git a/lib/src/web/web_error_code.dart b/lib/src/web/web_error_code.dart new file mode 100644 index 00000000..d74df1cd --- /dev/null +++ b/lib/src/web/web_error_code.dart @@ -0,0 +1,31 @@ +/// This enum defines the error codes for the Gigya Web SDK. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html#error-code-definitions-table +enum WebErrorCode { + /// This value indicates that an unspecified error occurred. + genericError(-1), + + /// This value indicates a success result. + success(0), + + /// This value indicates that a user has no valid session. + unauthorizedUser(403005); + + /// The default constructor. + const WebErrorCode(this.errorCode); + + /// Create a [WebErrorCode] from the given [errorCode]. + factory WebErrorCode.fromErrorCode(int errorCode) { + switch (errorCode) { + case 0: + return success; + case 403005: + return unauthorizedUser; + default: + return genericError; + } + } + + /// The error code for this enum value. + final int errorCode; +} From cfea2d2d1f7a4e694abe84531c3bb698171920e1 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 15:00:41 +0100 Subject: [PATCH 037/256] add TODO for method channel error codes enum --- lib/src/method_channel/method_channel_interruption_resolver.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/method_channel/method_channel_interruption_resolver.dart b/lib/src/method_channel/method_channel_interruption_resolver.dart index 8af6d252..d45b0274 100644 --- a/lib/src/method_channel/method_channel_interruption_resolver.dart +++ b/lib/src/method_channel/method_channel_interruption_resolver.dart @@ -17,6 +17,7 @@ class MethodChannelInterruptionResolverFactory @override InterruptionResolver? fromErrorCode(GigyaError exception) { + // TODO: create an enum for these error codes. See web_error_code.dart. switch (exception.errorCode) { case 403043: return _MethodChannelLinkAccountResolver(_channel); From 02fac62671fc0aa6440f1925d1f2ca1c39f286d1 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 15:53:48 +0100 Subject: [PATCH 038/256] implement account & session interop classes --- lib/src/web/static_interop/account.dart | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lib/src/web/static_interop/account.dart diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart new file mode 100644 index 00000000..ce3adee1 --- /dev/null +++ b/lib/src/web/static_interop/account.dart @@ -0,0 +1,45 @@ +import 'package:js/js.dart'; + +import 'gigya_method_parameters.dart'; + +/// The static interop class for the `gigya.accounts` JavaScript object. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4130da0f70b21014bbc5a10ce4041860.html +@JS() +@staticInterop +class Accounts {} + +/// This extension defines the static interop definition +/// for the [Accounts] class. +extension AccountsExtension on Accounts { + /// Log in using the given parameters. + external void Function(LoginParameters parameters) login; + + /// Log out of the current session. + external void Function(GigyaMethodParameters parameters) logout; + + /// Get the session namespace within the accounts namespace. + external Session get session; +} + +/// This class represents the parameters for the login method. +@JS() +@anonymous +class LoginParameters { + /// Create a new [LoginParameters] instance. + external factory LoginParameters({String loginID, String password}); +} + +/// This class represents the session namespace in the [Accounts] class. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/7fc882712f2e4011982171ea612466ca.html +@JS() +@staticInterop +class Session {} + +/// This extension defines the static interop definition +/// for the [Session] class. +extension SessionExtension on Session { + /// Verify the current session. + external void Function(GigyaMethodParameters parameters) verify; +} From 5caa3c04641f3e373bd61ee852e1a1363982f146 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 15:58:13 +0100 Subject: [PATCH 039/256] implment isLoggedIn & logout --- lib/src/web/gigya_flutter_plugin_web.dart | 66 +++++++++++++++++++++-- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 5193a963..246f9267 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -4,8 +4,14 @@ import 'dart:js_util'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; +import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; -import 'gigya_js_interop.dart'; +import 'static_interop/account.dart'; +import 'static_interop/gigya_method_parameters.dart'; +import 'static_interop/gigya_web_sdk.dart'; +import 'static_interop/response.dart'; +import 'static_interop/window.dart'; +import 'web_error_code.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { @@ -54,11 +60,65 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { @override Future isLoggedIn() { - return Future.value(false); + final Completer completer = Completer(); + final GigyaMethodParameters parameters = GigyaMethodParameters( + callback: (Response response) { + if (completer.isCompleted) { + return; + } + + switch (WebErrorCode.fromErrorCode(response.errorCode)) { + case WebErrorCode.success: + completer.complete(true); + break; + case WebErrorCode.unauthorizedUser: + completer.complete(false); + break; + default: + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + ), + ); + break; + } + }, + ); + + gigyaWebSdk.accounts.session.verify(parameters); + + return completer.future; } @override Future logout() { - return Future.value(); + final Completer completer = Completer(); + final GigyaMethodParameters parameters = GigyaMethodParameters( + callback: (Response response) { + if (completer.isCompleted) { + return; + } + + if (response.errorCode == 0) { + completer.complete(); + } else { + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + ), + ); + } + }, + ); + + gigyaWebSdk.accounts.logout(parameters); + + return completer.future; } } From 77ccf7447dd80085d2996526447baffcac943cf5 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 15 Mar 2023 16:02:43 +0100 Subject: [PATCH 040/256] wrap callbacks in allowInterop() --- lib/src/web/gigya_flutter_plugin_web.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 246f9267..49d0c00d 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -62,7 +62,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { Future isLoggedIn() { final Completer completer = Completer(); final GigyaMethodParameters parameters = GigyaMethodParameters( - callback: (Response response) { + callback: allowInterop((Response response) { if (completer.isCompleted) { return; } @@ -85,7 +85,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { ); break; } - }, + }), ); gigyaWebSdk.accounts.session.verify(parameters); @@ -97,7 +97,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { Future logout() { final Completer completer = Completer(); final GigyaMethodParameters parameters = GigyaMethodParameters( - callback: (Response response) { + callback: allowInterop((Response response) { if (completer.isCompleted) { return; } @@ -114,7 +114,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { ), ); } - }, + }), ); gigyaWebSdk.accounts.logout(parameters); From 24e0be01a7afff957c79c6836ec3d7a6ded16523 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 10:07:36 +0100 Subject: [PATCH 041/256] move login parameters into parameters.dart --- lib/src/web/static_interop/account.dart | 10 +--------- .../gigya_method_parameters.dart | 11 ---------- lib/src/web/static_interop/parameters.dart | 20 +++++++++++++++++++ 3 files changed, 21 insertions(+), 20 deletions(-) delete mode 100644 lib/src/web/static_interop/gigya_method_parameters.dart create mode 100644 lib/src/web/static_interop/parameters.dart diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index ce3adee1..60ea90bf 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -1,6 +1,6 @@ import 'package:js/js.dart'; -import 'gigya_method_parameters.dart'; +import 'parameters.dart'; /// The static interop class for the `gigya.accounts` JavaScript object. /// @@ -22,14 +22,6 @@ extension AccountsExtension on Accounts { external Session get session; } -/// This class represents the parameters for the login method. -@JS() -@anonymous -class LoginParameters { - /// Create a new [LoginParameters] instance. - external factory LoginParameters({String loginID, String password}); -} - /// This class represents the session namespace in the [Accounts] class. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/7fc882712f2e4011982171ea612466ca.html diff --git a/lib/src/web/static_interop/gigya_method_parameters.dart b/lib/src/web/static_interop/gigya_method_parameters.dart deleted file mode 100644 index 782ee4a7..00000000 --- a/lib/src/web/static_interop/gigya_method_parameters.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:js/js.dart'; - -import 'response.dart'; - -/// This class represents the parameters object for the various Gigya Web SDK methods. -@JS() -@anonymous -class GigyaMethodParameters { - /// Create a [GigyaMethodParameters] instance using the given [callback] and [context]. - external factory GigyaMethodParameters({void Function(Response response) callback, Object? context}); -} diff --git a/lib/src/web/static_interop/parameters.dart b/lib/src/web/static_interop/parameters.dart new file mode 100644 index 00000000..18f74175 --- /dev/null +++ b/lib/src/web/static_interop/parameters.dart @@ -0,0 +1,20 @@ +import 'package:js/js.dart'; + +import 'response.dart'; + +/// This class represents the parameters object for the various Gigya Web SDK methods +/// that use a callback function which provides a [Response], along with a `context` object. +@JS() +@anonymous +class GigyaMethodParameters { + /// Create a [GigyaMethodParameters] instance using the given [callback] and [context]. + external factory GigyaMethodParameters({void Function(Response response) callback, Object? context}); +} + +/// This class represents the parameters for the `accounts.login()` method. +@JS() +@anonymous +class LoginParameters { + /// Create a new [LoginParameters] instance. + external factory LoginParameters({String loginID, String password, void Function(Response response) callback}); +} From 4958ae54a6c741829d0991f28fc2a2a4468f9381 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 11:04:25 +0100 Subject: [PATCH 042/256] refactor Account.lastLoginTimestamp to be a `DateTime?` --- lib/src/models/account.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index 70fbd5f3..4ec880c9 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -5,9 +5,9 @@ import 'profile.dart'; class Account { /// The default constructor. Account({ - this.emails = const Emails(), this.created, this.data = const {}, + this.emails = const Emails(), this.isActive, this.isRegistered, this.isVerified, From be585f9f6e90e833cf7e4032c93ef08359e70f5b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 12:35:12 +0100 Subject: [PATCH 043/256] make response error message nullable in interop binding --- lib/src/web/static_interop/response.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/response.dart b/lib/src/web/static_interop/response.dart index 18d5299d..a0ae11c5 100644 --- a/lib/src/web/static_interop/response.dart +++ b/lib/src/web/static_interop/response.dart @@ -13,7 +13,7 @@ class Response { Object? context, int errorCode, String? errorDetails, - String errorMessage, + String? errorMessage, }); /// The version of the Gigya API that was used. @@ -37,5 +37,5 @@ class Response { external String? get errorDetails; /// The error message for the given [errorCode]. - external String get errorMessage; + external String? get errorMessage; } From 7b0e99762cd192a80d728093e78dd8760911ff64 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 12:39:16 +0100 Subject: [PATCH 044/256] add base login response static interop class --- lib/src/web/static_interop/response.dart | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/src/web/static_interop/response.dart b/lib/src/web/static_interop/response.dart index a0ae11c5..7a2bf33d 100644 --- a/lib/src/web/static_interop/response.dart +++ b/lib/src/web/static_interop/response.dart @@ -39,3 +39,39 @@ class Response { /// The error message for the given [errorCode]. external String? get errorMessage; } + +/// The static interop class for the Gigya Login API response. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/eb93d538b9ae45bfadd9a8aaa8806753.html#response-data +@JS() +@anonymous +class LoginResponse { + /// Construct a [LoginResponse] object. + external factory LoginResponse({ + int? apiVersion, + String callId, + int errorCode, + String? errorDetails, + String? errorMessage, + }); + + /// The version of the Gigya API that was used. + external int? get apiVersion; + + /// The unique identifier of the transaction. + external String get callId; + + /// The response error code. + /// + /// A value of zero indicates success. + /// Any other number indicates a failure. + /// + /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html + external int get errorCode; + + /// The additional details of the encountered error. + external String? get errorDetails; + + /// The error message for the given [errorCode]. + external String? get errorMessage; +} From 5e24be2295218812deb0d7a1663548c7baebbf10 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 12:41:03 +0100 Subject: [PATCH 045/256] use a login response object as callback argument; format --- lib/src/web/static_interop/parameters.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/parameters.dart b/lib/src/web/static_interop/parameters.dart index 18f74175..b88b8ff4 100644 --- a/lib/src/web/static_interop/parameters.dart +++ b/lib/src/web/static_interop/parameters.dart @@ -8,7 +8,10 @@ import 'response.dart'; @anonymous class GigyaMethodParameters { /// Create a [GigyaMethodParameters] instance using the given [callback] and [context]. - external factory GigyaMethodParameters({void Function(Response response) callback, Object? context}); + external factory GigyaMethodParameters({ + void Function(Response response) callback, + Object? context, + }); } /// This class represents the parameters for the `accounts.login()` method. @@ -16,5 +19,9 @@ class GigyaMethodParameters { @anonymous class LoginParameters { /// Create a new [LoginParameters] instance. - external factory LoginParameters({String loginID, String password, void Function(Response response) callback}); + external factory LoginParameters({ + String loginID, + String password, + void Function(LoginResponse response) callback, + }); } From f456791cef17956a1535d3d9e270a5214973291f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 13:20:44 +0100 Subject: [PATCH 046/256] implement emails static interop class --- lib/src/web/static_interop/emails.dart | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/src/web/static_interop/emails.dart diff --git a/lib/src/web/static_interop/emails.dart b/lib/src/web/static_interop/emails.dart new file mode 100644 index 00000000..d3e4fada --- /dev/null +++ b/lib/src/web/static_interop/emails.dart @@ -0,0 +1,19 @@ +import 'package:js/js.dart'; + +/// The static interop class for the emails object +/// that is nested within a profile object. +@JS() +@anonymous +class Emails { + /// Create a new [Emails] instance. + external factory Emails({ + List unverified, + List verified, + }); + + /// The list of unverified email addresses. + external List get unverified; + + /// The list of verified email addresses. + external List get verified; +} From fdd5c2945c5a23876277e9f174463d9cb31416f9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 13:25:04 +0100 Subject: [PATCH 047/256] implement session info static interop class; fix typo --- lib/src/web/static_interop/emails.dart | 3 +-- lib/src/web/static_interop/session_info.dart | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 lib/src/web/static_interop/session_info.dart diff --git a/lib/src/web/static_interop/emails.dart b/lib/src/web/static_interop/emails.dart index d3e4fada..512e751e 100644 --- a/lib/src/web/static_interop/emails.dart +++ b/lib/src/web/static_interop/emails.dart @@ -1,7 +1,6 @@ import 'package:js/js.dart'; -/// The static interop class for the emails object -/// that is nested within a profile object. +/// The static interop class for the emails object. @JS() @anonymous class Emails { diff --git a/lib/src/web/static_interop/session_info.dart b/lib/src/web/static_interop/session_info.dart new file mode 100644 index 00000000..584d2938 --- /dev/null +++ b/lib/src/web/static_interop/session_info.dart @@ -0,0 +1,18 @@ +import 'package:js/js.dart'; + +/// The static interop class for the session info object. +@JS() +@anonymous +class SessionInfo { + /// Construct a new [SessionInfo] instance. + external factory SessionInfo({ + String? cookieName, + String? cookieValue, + }); + + /// The name of the session cookie. + external String? get cookieName; + + /// The value of the session cookie. + external String get cookieValue; +} From 0307289ad8e03cca7ef42ca9c81c36d9b84aa8ce Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 13:31:09 +0100 Subject: [PATCH 048/256] add remaining properties for login response static interop implementation --- lib/src/web/static_interop/response.dart | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/src/web/static_interop/response.dart b/lib/src/web/static_interop/response.dart index 7a2bf33d..6823a494 100644 --- a/lib/src/web/static_interop/response.dart +++ b/lib/src/web/static_interop/response.dart @@ -1,5 +1,9 @@ import 'package:js/js.dart'; +import 'emails.dart'; +import 'profile.dart'; +import 'session_info.dart'; + /// The static interop class for the Gigya `Response` class. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d55f070b21014bbc5a10ce4041860.html @@ -61,6 +65,12 @@ class LoginResponse { /// The unique identifier of the transaction. external String get callId; + /// The timestamp of the creation of the user. + external String? get createdTimestamp; + + /// The verified and unverified email addresses of the user. + external Emails get emails; + /// The response error code. /// /// A value of zero indicates success. @@ -74,4 +84,51 @@ class LoginResponse { /// The error message for the given [errorCode]. external String? get errorMessage; + + /// Whether the user is active. + external bool? get isActive; + + /// Whether the user is registered. + external bool? get isRegistered; + + /// Whether the user is verified. + external bool? get isVerified; + + /// The timestamp of the lat login of the user. + external String? get lastLogin; + + /// The timestamp of the last update to the user's profile, + /// preferences or subscriptions data. + external String? get lastUpdated; + + /// The login provider that was last used to log in. + external String? get loginProvider; + + /// The timestamp, when the oldest data of the user was refreshed. + external String? get oldestDataUpdated; + + /// The user's profile. + external Profile? get profile; + + /// The timestamp when the user was registered. + external String? get registered; + + /// The session info for the user's session. + external SessionInfo get sessionInfo; + + /// The timestamp of the [UIDSignature]. + /// This value can be a [String] or a [num]. + external Object? get signatureTimestamp; + + /// The comma separated list of social providers linked to this user. + external String? get socialProviders; + + /// The unique id of this user. + external String? get UID; // ignore: non_constant_identifier_names + + /// The verification signature of the [UID]. + external String? get UIDSignature; // ignore: non_constant_identifier_names + + /// The timestamp when the user was verified. + external String? get verified; } From 4ec4086311bade6d6e1aa3569680491daecd29d6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 13:35:06 +0100 Subject: [PATCH 049/256] add profile stub for static interop --- lib/src/web/static_interop/profile.dart | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lib/src/web/static_interop/profile.dart diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart new file mode 100644 index 00000000..c94a6141 --- /dev/null +++ b/lib/src/web/static_interop/profile.dart @@ -0,0 +1,7 @@ +import 'package:js/js.dart'; + +@JS() +@anonymous +class Profile {} + +// TODO: fill in the properties + add anon classes for work, cert etc. \ No newline at end of file From dcc7ffb7cd8972b5a3c10f7cbd8039d0f1dc25b4 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 13:59:08 +0100 Subject: [PATCH 050/256] move response interop classes to their own files --- lib/src/web/gigya_flutter_plugin_web.dart | 5 +- lib/src/web/static_interop/parameters.dart | 3 +- .../login_response.dart} | 46 ++----------------- .../web/static_interop/response/response.dart | 41 +++++++++++++++++ 4 files changed, 49 insertions(+), 46 deletions(-) rename lib/src/web/static_interop/{response.dart => response/login_response.dart} (68%) create mode 100644 lib/src/web/static_interop/response/response.dart diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 49d0c00d..b776ea2b 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -7,9 +7,10 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; import 'static_interop/account.dart'; -import 'static_interop/gigya_method_parameters.dart'; import 'static_interop/gigya_web_sdk.dart'; -import 'static_interop/response.dart'; +import 'static_interop/parameters.dart'; +import 'static_interop/response/login_response.dart'; +import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; import 'web_error_code.dart'; diff --git a/lib/src/web/static_interop/parameters.dart b/lib/src/web/static_interop/parameters.dart index b88b8ff4..c4a7863a 100644 --- a/lib/src/web/static_interop/parameters.dart +++ b/lib/src/web/static_interop/parameters.dart @@ -1,6 +1,7 @@ import 'package:js/js.dart'; -import 'response.dart'; +import 'response/login_response.dart'; +import 'response/response.dart'; /// This class represents the parameters object for the various Gigya Web SDK methods /// that use a callback function which provides a [Response], along with a `context` object. diff --git a/lib/src/web/static_interop/response.dart b/lib/src/web/static_interop/response/login_response.dart similarity index 68% rename from lib/src/web/static_interop/response.dart rename to lib/src/web/static_interop/response/login_response.dart index 6823a494..fe88604f 100644 --- a/lib/src/web/static_interop/response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -1,48 +1,8 @@ import 'package:js/js.dart'; -import 'emails.dart'; -import 'profile.dart'; -import 'session_info.dart'; - -/// The static interop class for the Gigya `Response` class. -/// -/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d55f070b21014bbc5a10ce4041860.html -@JS() -@anonymous -class Response { - /// Construct a [Response] object. - external factory Response({ - int? apiVersion, - String callId, - Object? context, - int errorCode, - String? errorDetails, - String? errorMessage, - }); - - /// The version of the Gigya API that was used. - external int? get apiVersion; - - /// The unique identifier of the transaction. - external String get callId; - - /// The context that was passed to the method that responded with this [Response]. - external Object? get context; - - /// The response error code. - /// - /// A value of zero indicates success. - /// Any other number indicates a failure. - /// - /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html - external int get errorCode; - - /// The additional details of the encountered error. - external String? get errorDetails; - - /// The error message for the given [errorCode]. - external String? get errorMessage; -} +import '../emails.dart'; +import '../profile.dart'; +import '../session_info.dart'; /// The static interop class for the Gigya Login API response. /// diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart new file mode 100644 index 00000000..a0ae11c5 --- /dev/null +++ b/lib/src/web/static_interop/response/response.dart @@ -0,0 +1,41 @@ +import 'package:js/js.dart'; + +/// The static interop class for the Gigya `Response` class. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d55f070b21014bbc5a10ce4041860.html +@JS() +@anonymous +class Response { + /// Construct a [Response] object. + external factory Response({ + int? apiVersion, + String callId, + Object? context, + int errorCode, + String? errorDetails, + String? errorMessage, + }); + + /// The version of the Gigya API that was used. + external int? get apiVersion; + + /// The unique identifier of the transaction. + external String get callId; + + /// The context that was passed to the method that responded with this [Response]. + external Object? get context; + + /// The response error code. + /// + /// A value of zero indicates success. + /// Any other number indicates a failure. + /// + /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html + external int get errorCode; + + /// The additional details of the encountered error. + external String? get errorDetails; + + /// The error message for the given [errorCode]. + external String? get errorMessage; +} From d427b852d222037a101b2deb0a7806fc24f6c0d0 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 14:34:54 +0100 Subject: [PATCH 051/256] implement static interop class for Profile --- lib/src/web/static_interop/profile.dart | 204 +++++++++++++++++++++++- 1 file changed, 202 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index c94a6141..4598c973 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -1,7 +1,207 @@ import 'package:js/js.dart'; +/// This class represents the static interop implementation +/// for the profile object. @JS() @anonymous -class Profile {} +class Profile { + /// Construct a new [Profile] instance. + external factory Profile({ + String? activities, + String? address, + int? age, + String? bio, + int? birthDay, + int? birthMonth, + int birthYear, + List certifications, + String? city, + String? country, + List education, + String? educationLevel, + String? email, + List favorites, + String? firstName, + int? followers, + int? following, + String? gender, + String? hometown, + String? honors, + String? industry, + String? interests, + String? languages, + Location? lastLoginLocation, + String? lastName, + List likes, + String? locale, + String? name, + String? nickname, + OidcData? oidcData, + List patents, + List phones, + String? photoUrl, + String? politicalView, + String? professionalHeadline, + String? profileUrl, + String? proxyEmail, + List publications, + String? relationshipStatus, + String? religion, + List skills, + String? specialities, + String? state, + String? thumbnailUrl, + String? timezone, + String? username, + String? verified, + List work, + String? zip, + }); -// TODO: fill in the properties + add anon classes for work, cert etc. \ No newline at end of file + /// The person's activities. + external String? get activities; + + /// The person's address. + external String? get address; + + /// The person's age. + external int? get age; + + /// The person's biography. + external String? get bio; + + /// The person's birth day. + external int? get birthDay; + + /// The person's birth month. + external int? get birthMonth; + + /// The person's birth year. + external int? get birthYear; + + /// The person's certifications. + external List get certifications; + + /// The city in which the person resides. + external String? get city; + + /// The country in which the person resides. + external String? get country; + + /// The different educations of the person. + external List get education; + + /// The education level of the person. + external String? get educationLevel; + + /// The person's email address. + external String? get email; + + /// The person's favorites. + external List get favorites; + + /// The person's first name. + external String? get firstName; + + /// The amount of followers of this person. + external int? get followers; + + /// The amount of people that this person is following. + external int? get following; + + /// The person's gender. + external String? get gender; + + /// The person's home town. + external String? get hometown; + + /// The person's honorary titles. + external String? get honors; + + /// The industry in which this person is employed. + external String? get industry; + + /// The person's interests. + external String? get interests; + + /// The different languages that the person is proficient in. + external String? get languages; + + /// The last location where the user was logged in. + external Location? get lastLoginLocation; + + /// The person's last name. + external String? get lastName; + + /// The person's likes. + external List get likes; + + /// The language locale of the person's primary language. + external String? get locale; + + /// The person's full name. + external String? get name; + + /// The person's nickname. + external String? get nickname; + + /// The OIDC data linked to this person. + external OidcData? get oidcData; + + /// The different patents that this person owns. + external List get patents; + + /// The different phone numbers belonging to this person. + external List get phones; + + /// The url to the person's photo. + external String? get photoUrl; + + /// The person's political view. + external String? get politicalView; + + /// The person's professional headline. + external String? get professionalHeadline; + + /// The url to the person's profile page. + external String? get profileUrl; + + /// The person's proxy email address. + external String? get proxyEmail; + + /// The list of publications belonging to this person. + external List get publications; + + /// The person's relationship status. + external String? get relationshipStatus; + + /// The person's religion. + external String? get religion; + + /// The different skills of the person. + external List get skills; + + /// The person's specialities. + external String? get specialities; + + /// The state in which the person resides. + external String? get state; + + /// The url to the person's thumbnail image. + external String? get thumbnailUrl; + + /// The person's timezone. + external String? get timezone; + + /// The person's username. + external String? get username; + + /// The verified status of the person. + external String? get verified; + + /// The person's career, divided into the different employments. + external List get work; + + /// The ZIP code of the person's address. + external String? get zip; +} From a74be9e1185415ab5d04870b4978011f6ea56d72 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:04:40 +0100 Subject: [PATCH 052/256] implement certification static interop class --- lib/src/web/static_interop/certification.dart | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/src/web/static_interop/certification.dart diff --git a/lib/src/web/static_interop/certification.dart b/lib/src/web/static_interop/certification.dart new file mode 100644 index 00000000..fa20f6e2 --- /dev/null +++ b/lib/src/web/static_interop/certification.dart @@ -0,0 +1,30 @@ +import 'package:js/js.dart'; + +/// The static interop class for the Certification object. +@JS() +@anonymous +class Certification { + /// Create a new [Certification] instance. + external factory Certification({ + String? authority, + String? endDate, + String? name, + String? number, + String? startDate, + }); + + /// The certification authority. + external String? get authority; + + /// The date that the certification expired. + external String? get endDate; + + /// The name of the certification. + external String? get name; + + /// The certification number. + external String? get number; + + /// The date that the certification was issued. + external String? get startDate; +} From 16869eb60c0ee9d1bad3be2ba94ea3f4927f773a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:06:02 +0100 Subject: [PATCH 053/256] implement static LoginResponse.toMap() method --- .../response/login_response.dart | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index fe88604f..089af34c 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -91,4 +91,38 @@ class LoginResponse { /// The timestamp when the user was verified. external String? get verified; + + /// Convert the given [response] to a [Map]. + /// + /// Since the [LoginResponse] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(LoginResponse response) { + final Profile? profile = response.profile; + + return { + 'createdTimestamp': response.createdTimestamp, + 'emails': { + 'unverified': response.emails.unverified, + 'verified': response.emails.verified, + }, + 'isActive': response.isActive, + 'isRegistered': response.isRegistered, + 'isVerified': response.isVerified, + 'lastLogin': response.lastLogin, + 'lastUpdated': response.lastUpdated, + 'loginProvider': response.loginProvider, + 'oldestDataUpdated': response.oldestDataUpdated, + if (profile != null) 'profile': Profile.toMap(profile), + 'registered': response.registered, + 'sessionInfo': { + 'cookieName': response.sessionInfo.cookieName, + 'cookieValue': response.sessionInfo.cookieValue, + }, + 'signatureTimestamp': response.signatureTimestamp, + 'socialProviders': response.socialProviders, + 'UID': response.UID, + 'UIDSignature': response.UIDSignature, + 'verified': response.verified, + }; + } } From 2ee8ca3ceffd90d2282911e5dfb9970c9398f0e6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:13:28 +0100 Subject: [PATCH 054/256] implement education static interop class --- lib/src/web/static_interop/education.dart | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/src/web/static_interop/education.dart diff --git a/lib/src/web/static_interop/education.dart b/lib/src/web/static_interop/education.dart new file mode 100644 index 00000000..fff96202 --- /dev/null +++ b/lib/src/web/static_interop/education.dart @@ -0,0 +1,34 @@ +import 'package:js/js.dart'; + +/// The static interop class for the Education object. +@JS() +@anonymous +class Education { + /// Construct a new [Education] instance. + external factory Education({ + String? degree, + String? endYear, + String? fieldOfStudy, + String? school, + String? schoolType, + String? startYear, + }); + + /// The degree for the education. + external String? get degree; + + /// The year in which the education was finished. + external String? get endYear; + + /// The field of study of the education. + external String? get fieldOfStudy; + + /// The name of the school at which the education took place. + external String? get school; + + /// The type of school at which the education took place. + external String? get schoolType; + + /// The year in which the education was started. + external String? get startYear; +} From 298921caa353ec67685f043c988b5754b460b8ea Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:17:48 +0100 Subject: [PATCH 055/256] implement phone static interop class --- lib/src/web/static_interop/phone.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/src/web/static_interop/phone.dart diff --git a/lib/src/web/static_interop/phone.dart b/lib/src/web/static_interop/phone.dart new file mode 100644 index 00000000..4a8f0bfd --- /dev/null +++ b/lib/src/web/static_interop/phone.dart @@ -0,0 +1,15 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Phone` object. +@JS() +@anonymous +class Phone { + /// Construct a new [Phone] instance. + external factory Phone({String? number, String? type}); + + /// The value of the phone number. + external String? get number; + + /// The type of phone number. + external String? get type; +} From 0fe57a11ac70f8aae14add88d801087a043c75ae Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:27:01 +0100 Subject: [PATCH 056/256] implement work static interop class --- lib/src/web/static_interop/work.dart | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/src/web/static_interop/work.dart diff --git a/lib/src/web/static_interop/work.dart b/lib/src/web/static_interop/work.dart new file mode 100644 index 00000000..5e313d53 --- /dev/null +++ b/lib/src/web/static_interop/work.dart @@ -0,0 +1,42 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Work` object. +@JS() +@anonymous +class Work { + /// Construct a new [Work] instance. + external factory Work({ + String? company, + int? companySize, + String? companyID, + String? endDate, + String? industry, + bool? isCurrent, + String? startDate, + String? title, + }); + + /// The name of the company. + external String? get company; + + /// The size of the company in number of employees. + external int? get companySize; + + /// The id of the company. + external String? get companyID; + + /// The date the user stopped working at the company. + external String? get endDate; + + /// The industry of the company. + external String? get industry; + + /// Whether the user currently works at the company. + external bool? get isCurrent; + + /// The date the user started working at the company. + external String? get startDate; + + /// The user's title in the company. + external String? get title; +} From f44363120c59cbb1e926edacf3c49a26c7c60d18 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:32:20 +0100 Subject: [PATCH 057/256] implement skill static interop class --- lib/src/web/static_interop/skill.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/src/web/static_interop/skill.dart diff --git a/lib/src/web/static_interop/skill.dart b/lib/src/web/static_interop/skill.dart new file mode 100644 index 00000000..a28e557f --- /dev/null +++ b/lib/src/web/static_interop/skill.dart @@ -0,0 +1,18 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Skill` object. +@JS() +@anonymous +class Skill { + /// Construct a new [Skill] instance. + external factory Skill({String? level, String? skill, int? years}); + + /// The user's proficiency in the skill. + external String? get level; + + /// The user's skill. + external String? get skill; + + /// The years of the user's skill. + external int? get years; +} From 7b90f0fd1d7506552ce1b0e6b055b44a88bb7c17 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:38:20 +0100 Subject: [PATCH 058/256] implement the static interop class for the publication object --- lib/src/web/static_interop/publication.dart | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/src/web/static_interop/publication.dart diff --git a/lib/src/web/static_interop/publication.dart b/lib/src/web/static_interop/publication.dart new file mode 100644 index 00000000..55bbd5f0 --- /dev/null +++ b/lib/src/web/static_interop/publication.dart @@ -0,0 +1,30 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Publication` object. +@JS() +@anonymous +class Publication { + /// Construct a new [Publication] instance. + external factory Publication({ + String? date, + String? publisher, + String? summary, + String? title, + String? url, + }); + + /// The publication date. + external String? get date; + + /// The name of the publisher that published the publication. + external String? get publisher; + + /// The summary of the publication. + external String? get summary; + + /// The title of the publication. + external String? get title; + + /// The url to the publication's document. + external String? get url; +} From 18622ee5880325475bf1c09bdf9c3b6b34ce11b6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:41:13 +0100 Subject: [PATCH 059/256] remove non-existent oidc data from web profile implementation --- lib/src/web/static_interop/profile.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 4598c973..36ebae56 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -36,7 +36,6 @@ class Profile { String? locale, String? name, String? nickname, - OidcData? oidcData, List patents, List phones, String? photoUrl, @@ -145,9 +144,6 @@ class Profile { /// The person's nickname. external String? get nickname; - /// The OIDC data linked to this person. - external OidcData? get oidcData; - /// The different patents that this person owns. external List get patents; From 1f4626031c8010613258c19fde43d04f1d76929d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:45:34 +0100 Subject: [PATCH 060/256] remove non-existent lastLoginLocation from web profile implementation --- lib/src/web/static_interop/profile.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 36ebae56..b9d16822 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -30,7 +30,6 @@ class Profile { String? industry, String? interests, String? languages, - Location? lastLoginLocation, String? lastName, List likes, String? locale, @@ -126,9 +125,6 @@ class Profile { /// The different languages that the person is proficient in. external String? get languages; - /// The last location where the user was logged in. - external Location? get lastLoginLocation; - /// The person's last name. external String? get lastName; From d634236d17c0512fee3f008cf3b4e25eec51723d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 17:54:00 +0100 Subject: [PATCH 061/256] implement like static interop class --- lib/src/web/static_interop/like.dart | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/src/web/static_interop/like.dart diff --git a/lib/src/web/static_interop/like.dart b/lib/src/web/static_interop/like.dart new file mode 100644 index 00000000..641b3dc6 --- /dev/null +++ b/lib/src/web/static_interop/like.dart @@ -0,0 +1,26 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Like` object. +@JS() +@anonymous +class Like { + /// Create a new [Like] instance. + external factory Like({ + String? category, + String? id, + String? name, + String? time, + }); + + /// The category of the like. + external String? get category; + + /// The identifier of the like. + external String? get id; + + /// The name of the like. + external String? get name; + + /// The timestamp, in UTC, on which the like was created. + external String? get time; +} From 24406b9a9d10eae2dfe86243cb832cb3828dd28b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 18:01:16 +0100 Subject: [PATCH 062/256] implement patent static interop class --- lib/src/web/static_interop/patent.dart | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/src/web/static_interop/patent.dart diff --git a/lib/src/web/static_interop/patent.dart b/lib/src/web/static_interop/patent.dart new file mode 100644 index 00000000..4112d26b --- /dev/null +++ b/lib/src/web/static_interop/patent.dart @@ -0,0 +1,38 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Patent` object. +@JS() +@anonymous +class Patent { + /// Construct a new [Patent] instance. + external factory Patent({ + String? date, + String? number, + String? office, + String? status, + String? summary, + String? title, + String? url, + }); + + /// The issue date of the patent. + external String? get date; + + /// The patent number. + external String? get number; + + /// The name of the office that issued the patent. + external String? get office; + + /// The status of the patent. + external String? get status; + + /// The summary of the patent. + external String? get summary; + + /// The title of the patent. + external String? get title; + + /// The url to the patent document. + external String? get url; +} From fb45209828f2e50168f9a7df66e5205879ae2971 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 18:10:28 +0100 Subject: [PATCH 063/256] implement favorite / favorites static interop class --- lib/src/web/static_interop/favorites.dart | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lib/src/web/static_interop/favorites.dart diff --git a/lib/src/web/static_interop/favorites.dart b/lib/src/web/static_interop/favorites.dart new file mode 100644 index 00000000..38b2bbde --- /dev/null +++ b/lib/src/web/static_interop/favorites.dart @@ -0,0 +1,55 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Favorite` object. +@JS() +@anonymous +class Favorite { + /// Construct a new [Favorite] instance. + external factory Favorite({ + String? category, + String? id, + String? name, + }); + + /// The category of the favorite. + external String? get category; + + /// The id of the favorite. + external String? get id; + + /// The name of the favorite. + external String? get name; +} + +/// The static interop class for the `Favorites` object. +@JS() +@anonymous +class Favorites { + /// Construct a new [Favorites] instance. + external factory Favorites({ + List activities, + List books, + List interests, + List movies, + List music, + List television, + }); + + /// The user's favorite activities. + external List get activities; + + /// The user's favorite books. + external List get books; + + /// The user's interests. + external List get interests; + + /// The user's favorite movies. + external List get movies; + + /// The user's favorite music. + external List get music; + + /// The user's favorite television programmes. + external List get television; +} From e28af50abe3fcbe78e6ae599dab5c100b6882ebf Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 18:34:50 +0100 Subject: [PATCH 064/256] implement static certification to map method --- lib/src/web/static_interop/certification.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/src/web/static_interop/certification.dart b/lib/src/web/static_interop/certification.dart index fa20f6e2..5af6851c 100644 --- a/lib/src/web/static_interop/certification.dart +++ b/lib/src/web/static_interop/certification.dart @@ -27,4 +27,18 @@ class Certification { /// The date that the certification was issued. external String? get startDate; + + /// Convert the given [certification] to a [Map]. + /// + /// Since the [Certification] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Certification certification) { + return { + 'authority': certification.authority, + 'endDate': certification.endDate, + 'name': certification.name, + 'number': certification.number, + 'startDate': certification.startDate, + }; + } } From c2e40fb9deef8aab138dc7c4138fdb3d279cfc23 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 18:38:15 +0100 Subject: [PATCH 065/256] implement static like to map method --- lib/src/web/static_interop/like.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/src/web/static_interop/like.dart b/lib/src/web/static_interop/like.dart index 641b3dc6..91e16be2 100644 --- a/lib/src/web/static_interop/like.dart +++ b/lib/src/web/static_interop/like.dart @@ -23,4 +23,17 @@ class Like { /// The timestamp, in UTC, on which the like was created. external String? get time; + + /// Convert the given [like] to a [Map]. + /// + /// Since the [Like] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Like like) { + return { + 'category': like.category, + 'id': like.id, + 'name': like.name, + 'time': like.time, + }; + } } From 872dde049efac39023527a67ae3d881587a2ca78 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 18:46:00 +0100 Subject: [PATCH 066/256] implement static work to map method --- lib/src/web/static_interop/work.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/src/web/static_interop/work.dart b/lib/src/web/static_interop/work.dart index 5e313d53..6dbe3c6a 100644 --- a/lib/src/web/static_interop/work.dart +++ b/lib/src/web/static_interop/work.dart @@ -39,4 +39,21 @@ class Work { /// The user's title in the company. external String? get title; + + /// Convert the given [work] to a [Map]. + /// + /// Since the [Work] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Work work) { + return { + 'company': work.company, + 'companyID': work.companyID, + 'companySize': work.companySize, + 'endDate': work.endDate, + 'industry': work.industry, + 'isCurrent': work.isCurrent, + 'startDate': work.startDate, + 'title': work.title, + }; + } } From c254d443b82a3fd98273283f7c380b277691eec8 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 18:48:31 +0100 Subject: [PATCH 067/256] implement static education to map method --- lib/src/web/static_interop/education.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/src/web/static_interop/education.dart b/lib/src/web/static_interop/education.dart index fff96202..6939b73b 100644 --- a/lib/src/web/static_interop/education.dart +++ b/lib/src/web/static_interop/education.dart @@ -31,4 +31,19 @@ class Education { /// The year in which the education was started. external String? get startYear; + + /// Convert the given [education] to a [Map]. + /// + /// Since the [Education] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Education education) { + return { + 'degree': education.degree, + 'endYear': education.endYear, + 'fieldOfStudy': education.fieldOfStudy, + 'school': education.school, + 'schoolType': education.schoolType, + 'startYear': education.startYear, + }; + } } From f56f57a44da3db6c20d99a3debb5744c48ff1d50 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 18:58:10 +0100 Subject: [PATCH 068/256] implement static favorite(s) to map method; fix missing music key in favorites toJson() --- lib/src/web/static_interop/favorites.dart | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/src/web/static_interop/favorites.dart b/lib/src/web/static_interop/favorites.dart index 38b2bbde..94f0b2d4 100644 --- a/lib/src/web/static_interop/favorites.dart +++ b/lib/src/web/static_interop/favorites.dart @@ -19,6 +19,18 @@ class Favorite { /// The name of the favorite. external String? get name; + + /// Convert the given [favorite] to a [Map]. + /// + /// Since the [Favorite] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Favorite favorite) { + return { + 'id': favorite.id, + 'name': favorite.name, + 'category': favorite.category, + }; + } } /// The static interop class for the `Favorites` object. @@ -52,4 +64,19 @@ class Favorites { /// The user's favorite television programmes. external List get television; + + /// Convert the given [favorites] to a [Map]. + /// + /// Since the [Favorites] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Favorites favorites) { + return { + 'activities': favorites.activities.map(Favorite.toMap).toList(), + 'books': favorites.books.map(Favorite.toMap).toList(), + 'interests': favorites.interests.map(Favorite.toMap).toList(), + 'movies': favorites.movies.map(Favorite.toMap).toList(), + 'music': favorites.music.map(Favorite.toMap).toList(), + 'television': favorites.television.map(Favorite.toMap).toList(), + }; + } } From 46b1c74c1da718854155f27cfc63094f442b13bc Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 19:02:05 +0100 Subject: [PATCH 069/256] fix type --- lib/src/web/static_interop/profile.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index b9d16822..c42ac0e5 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -20,7 +20,7 @@ class Profile { List education, String? educationLevel, String? email, - List favorites, + Favorites favorites, String? firstName, int? followers, int? following, @@ -96,7 +96,7 @@ class Profile { external String? get email; /// The person's favorites. - external List get favorites; + external Favorites get favorites; /// The person's first name. external String? get firstName; From 3b1916bdc20238de9fc8db3ef143fad9b1e7c788 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 19:06:01 +0100 Subject: [PATCH 070/256] implement static patent to map method --- lib/src/web/static_interop/patent.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/src/web/static_interop/patent.dart b/lib/src/web/static_interop/patent.dart index 4112d26b..3271eecd 100644 --- a/lib/src/web/static_interop/patent.dart +++ b/lib/src/web/static_interop/patent.dart @@ -35,4 +35,20 @@ class Patent { /// The url to the patent document. external String? get url; + + /// Convert the given [patent] to a [Map]. + /// + /// Since the [Patent] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Patent patent) { + return { + 'date': patent.date, + 'number': patent.number, + 'office': patent.office, + 'status': patent.status, + 'summary': patent.summary, + 'title': patent.title, + 'url': patent.url, + }; + } } From f982a5d6d143e626263ecf085200d0ea313ba323 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 19:10:04 +0100 Subject: [PATCH 071/256] implement static publication to map method --- lib/src/web/static_interop/publication.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/src/web/static_interop/publication.dart b/lib/src/web/static_interop/publication.dart index 55bbd5f0..9e722f84 100644 --- a/lib/src/web/static_interop/publication.dart +++ b/lib/src/web/static_interop/publication.dart @@ -27,4 +27,18 @@ class Publication { /// The url to the publication's document. external String? get url; + + /// Convert the given [publication] to a [Map]. + /// + /// Since the [Publication] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Publication publication) { + return { + 'date': publication.date, + 'publisher': publication.publisher, + 'summary': publication.summary, + 'title': publication.title, + 'url': publication.url, + }; + } } From e785b6ec07186bda21ffb881821c930cd11dc5cd Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 19:13:09 +0100 Subject: [PATCH 072/256] implement static phone to map method --- lib/src/web/static_interop/phone.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/web/static_interop/phone.dart b/lib/src/web/static_interop/phone.dart index 4a8f0bfd..957e5e58 100644 --- a/lib/src/web/static_interop/phone.dart +++ b/lib/src/web/static_interop/phone.dart @@ -12,4 +12,15 @@ class Phone { /// The type of phone number. external String? get type; + + /// Convert the given [phone] to a [Map]. + /// + /// Since the [Phone] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Phone phone) { + return { + 'number': phone.number, + 'type': phone.type, + }; + } } From bfead48a54631d156311ba58cd539fd4fc9e1a2d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 19:13:23 +0100 Subject: [PATCH 073/256] implement static skill to map method --- lib/src/web/static_interop/skill.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/web/static_interop/skill.dart b/lib/src/web/static_interop/skill.dart index a28e557f..c9a85ca8 100644 --- a/lib/src/web/static_interop/skill.dart +++ b/lib/src/web/static_interop/skill.dart @@ -15,4 +15,16 @@ class Skill { /// The years of the user's skill. external int? get years; + + /// Convert the given [skill] to a [Map]. + /// + /// Since the [Skill] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Skill skill) { + return { + 'level': skill.level, + 'skill': skill.skill, + 'years': skill.years, + }; + } } From 751435675961429e7a523a9f8ec579aa6cd4cc1c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 19:17:25 +0100 Subject: [PATCH 074/256] implement Profile to map static method --- lib/src/web/static_interop/profile.dart | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index c42ac0e5..34a97874 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -1,5 +1,15 @@ import 'package:js/js.dart'; +import 'certification.dart'; +import 'education.dart'; +import 'favorites.dart'; +import 'like.dart'; +import 'patent.dart'; +import 'phone.dart'; +import 'publication.dart'; +import 'skill.dart'; +import 'work.dart'; + /// This class represents the static interop implementation /// for the profile object. @JS() @@ -196,4 +206,68 @@ class Profile { /// The ZIP code of the person's address. external String? get zip; + + /// Convert the given [profile] to a [Map]. + /// + /// Since the [Profile] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Profile profile) { + final List> certs = profile.certifications.map(Certification.toMap).toList(); + final List> education = profile.education.map(Education.toMap).toList(); + final List> likes = profile.likes.map(Like.toMap).toList(); + final List> patents = profile.patents.map(Patent.toMap).toList(); + final List> phones = profile.phones.map(Phone.toMap).toList(); + final List> publications = profile.publications.map(Publication.toMap).toList(); + final List> skills = profile.skills.map(Skill.toMap).toList(); + final List> work = profile.work.map(Work.toMap).toList(); + + return { + 'activities': profile.activities, + 'address': profile.address, + 'age': profile.age, + 'bio': profile.bio, + 'birthDay': profile.birthDay, + 'birthMonth': profile.birthMonth, + 'birthYear': profile.birthYear, + 'certifications': certs, + 'city': profile.city, + 'country': profile.country, + 'education': education, + 'educationLevel': profile.educationLevel, + 'email': profile.email, + 'favorites': Favorites.toMap(profile.favorites), + 'firstName': profile.firstName, + 'followersCount': profile.followers, + 'followingCount': profile.following, + 'gender': profile.gender, + 'hometown': profile.hometown, + 'honors': profile.honors, + 'industry': profile.industry, + 'interests': profile.interests, + 'languages': profile.languages, + 'lastName': profile.lastName, + 'likes': likes, + 'locale': profile.locale, + 'name': profile.name, + 'nickname': profile.nickname, + 'patents': patents, + 'phones': phones, + 'photoURL': profile.photoUrl, + 'politicalView': profile.politicalView, + 'professionalHeadline': profile.professionalHeadline, + 'proxyEmail': profile.proxyEmail, + 'publications': publications, + 'relationshipStatus': profile.relationshipStatus, + 'religion': profile.religion, + 'skills': skills, + 'specialities': profile.specialities, + 'state': profile.state, + 'thumbnailURL': profile.thumbnailUrl, + 'timezone': profile.timezone, + 'username': profile.username, + 'verified': profile.verified, + 'work': work, + 'zip': profile.zip, + }; + } } From 9f368861dba8adefda915f9cf3033ea5afe29e69 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 19:32:15 +0100 Subject: [PATCH 075/256] add missing attributes to login response constructor --- .../response/login_response.dart | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 089af34c..b5a4d852 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -14,9 +14,26 @@ class LoginResponse { external factory LoginResponse({ int? apiVersion, String callId, + String? createdTimestamp, + Emails? emails, int errorCode, String? errorDetails, String? errorMessage, + bool? isActive, + bool? isRegistered, + bool? isVerified, + String? lastLogin, + String? lastUpdated, + String? loginProvider, + String? oldestDataUpdated, + Profile? profile, + String? registered, + SessionInfo? sessionInfo, + Object? signatureTimestamp, + String? socialProviders, + String? UID, // ignore: non_constant_identifier_names + String? UIDSignature, // ignore: non_constant_identifier_names + String? verified, }); /// The version of the Gigya API that was used. @@ -29,7 +46,7 @@ class LoginResponse { external String? get createdTimestamp; /// The verified and unverified email addresses of the user. - external Emails get emails; + external Emails? get emails; /// The response error code. /// @@ -54,7 +71,7 @@ class LoginResponse { /// Whether the user is verified. external bool? get isVerified; - /// The timestamp of the lat login of the user. + /// The timestamp of the last login of the user. external String? get lastLogin; /// The timestamp of the last update to the user's profile, @@ -74,7 +91,7 @@ class LoginResponse { external String? get registered; /// The session info for the user's session. - external SessionInfo get sessionInfo; + external SessionInfo? get sessionInfo; /// The timestamp of the [UIDSignature]. /// This value can be a [String] or a [num]. From 6fa824e036cf86bc684ecaaab9eb35be7de500d4 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 19:41:18 +0100 Subject: [PATCH 076/256] implement static interop class for coordinates and location --- lib/src/web/static_interop/location.dart | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/src/web/static_interop/location.dart diff --git a/lib/src/web/static_interop/location.dart b/lib/src/web/static_interop/location.dart new file mode 100644 index 00000000..efeb0bb5 --- /dev/null +++ b/lib/src/web/static_interop/location.dart @@ -0,0 +1,35 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Coordinates` object. +@JS() +@anonymous +class Coordinates { + /// Construct a new [Coordinates] instance. + external factory Coordinates(String? lat, String? lon); + + /// The longitude of the coordinate. + external double? get lat; + + /// The latitude of the coordinate. + external double? get lon; +} + +/// The static interop class for the `Location` object. +@JS() +@anonymous +class Location { + /// Construct a new [Location] instance. + external factory Location(); + + /// The name of the city in which the location is located. + external String? get city; + + /// The coordinates of the location. + external Coordinates? get coordinates; + + /// The two character country code of the location. + external String? get country; + + /// The state in which the location is located. + external String? get state; +} From eb58ab1b1d80f2c9b26ce466d6876e8f73930960 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 08:36:05 +0100 Subject: [PATCH 077/256] implement to map static method for location static interop class; fix factory constructor --- lib/src/web/static_interop/location.dart | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/location.dart b/lib/src/web/static_interop/location.dart index efeb0bb5..31b48c85 100644 --- a/lib/src/web/static_interop/location.dart +++ b/lib/src/web/static_interop/location.dart @@ -19,7 +19,12 @@ class Coordinates { @anonymous class Location { /// Construct a new [Location] instance. - external factory Location(); + external factory Location({ + String? city, + Coordinates? coordinates, + String? country, + String? state, + }); /// The name of the city in which the location is located. external String? get city; @@ -32,4 +37,20 @@ class Location { /// The state in which the location is located. external String? get state; + + /// Convert the given [location] to a [Map]. + /// + /// Since the [Location] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Location location) { + return { + 'city': location.city, + 'country': location.country, + 'coordinates': { + 'lat': location.coordinates?.lat, + 'lon': location.coordinates?.lon, + }, + 'state': location.state, + }; + } } From 53490bc01aeee37aea6f4484a9400484f069210b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 08:42:17 +0100 Subject: [PATCH 078/256] add last login location to login response --- lib/src/web/static_interop/response/login_response.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index b5a4d852..a8656a3f 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -23,6 +23,7 @@ class LoginResponse { bool? isRegistered, bool? isVerified, String? lastLogin, + Location? lastLoginLocation, String? lastUpdated, String? loginProvider, String? oldestDataUpdated, @@ -74,6 +75,9 @@ class LoginResponse { /// The timestamp of the last login of the user. external String? get lastLogin; + /// The last login location of the user. + external Location? get lastLoginLocation; + /// The timestamp of the last update to the user's profile, /// preferences or subscriptions data. external String? get lastUpdated; From 9b821ec430586880faa71575071306bd4f1a5729 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 08:43:19 +0100 Subject: [PATCH 079/256] handle null session info & emails --- .../response/login_response.dart | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index a8656a3f..839fd068 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -118,14 +118,18 @@ class LoginResponse { /// Since the [LoginResponse] class is an anonymous JavaScript type, /// this has to be a static method instead of an instance method. static Map toMap(LoginResponse response) { + final Emails? emails = response.emails; + final SessionInfo? sessionInfo = response.sessionInfo; + final Profile? profile = response.profile; return { 'createdTimestamp': response.createdTimestamp, - 'emails': { - 'unverified': response.emails.unverified, - 'verified': response.emails.verified, - }, + if (emails != null) + 'emails': { + 'unverified': emails.unverified, + 'verified': emails.verified, + }, 'isActive': response.isActive, 'isRegistered': response.isRegistered, 'isVerified': response.isVerified, @@ -135,10 +139,11 @@ class LoginResponse { 'oldestDataUpdated': response.oldestDataUpdated, if (profile != null) 'profile': Profile.toMap(profile), 'registered': response.registered, - 'sessionInfo': { - 'cookieName': response.sessionInfo.cookieName, - 'cookieValue': response.sessionInfo.cookieValue, - }, + if (sessionInfo != null) + 'sessionInfo': { + 'cookieName': sessionInfo.cookieName, + 'cookieValue': sessionInfo.cookieValue, + }, 'signatureTimestamp': response.signatureTimestamp, 'socialProviders': response.socialProviders, 'UID': response.UID, From 255be5263cfaaca89fc4f162c906ac8b9ed750fe Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 08:44:12 +0100 Subject: [PATCH 080/256] amend last login location to profile --- .../static_interop/response/login_response.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 839fd068..4e0ca80a 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -122,6 +122,21 @@ class LoginResponse { final SessionInfo? sessionInfo = response.sessionInfo; final Profile? profile = response.profile; + Map? profileAsMap; + + if (profile != null) { + profileAsMap = Profile.toMap(profile); + + // The lastLoginLocation field is not in the profile + // when using the Gigya Web SDK. + // Instead, it is located inside the login response. + // Add it to the profile map. + final Location? lastLoginLocation = response.lastLoginLocation; + + if (lastLoginLocation != null) { + profileAsMap['lastLoginLocation'] = Location.toMap(lastLoginLocation); + } + } return { 'createdTimestamp': response.createdTimestamp, @@ -137,7 +152,7 @@ class LoginResponse { 'lastUpdated': response.lastUpdated, 'loginProvider': response.loginProvider, 'oldestDataUpdated': response.oldestDataUpdated, - if (profile != null) 'profile': Profile.toMap(profile), + if (profileAsMap != null) 'profile': profileAsMap, 'registered': response.registered, if (sessionInfo != null) 'sessionInfo': { From 7835ac8404bb8e0472dcd3272725bc47e5208bd9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 08:44:29 +0100 Subject: [PATCH 081/256] fix import --- lib/src/web/static_interop/response/login_response.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 4e0ca80a..be98597b 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -1,6 +1,7 @@ import 'package:js/js.dart'; import '../emails.dart'; +import '../location.dart'; import '../profile.dart'; import '../session_info.dart'; From bd93f019c65d1cbceb851979f22b861a94e7ae4c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 08:57:26 +0100 Subject: [PATCH 082/256] fix constructor --- lib/src/web/static_interop/location.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/location.dart b/lib/src/web/static_interop/location.dart index 31b48c85..86008434 100644 --- a/lib/src/web/static_interop/location.dart +++ b/lib/src/web/static_interop/location.dart @@ -5,7 +5,7 @@ import 'package:js/js.dart'; @anonymous class Coordinates { /// Construct a new [Coordinates] instance. - external factory Coordinates(String? lat, String? lon); + external factory Coordinates({String? lat, String? lon}); /// The longitude of the coordinate. external double? get lat; From 50cfec5b9ddf73ea623b25b092ff70e36d1f297a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 08:59:36 +0100 Subject: [PATCH 083/256] implement login function --- lib/src/web/gigya_flutter_plugin_web.dart | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index b776ea2b..6d37aa06 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -94,6 +94,42 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return completer.future; } + @override + Future> login({ + required String loginId, + required String password, + Map parameters = const {}, + }) { + final Completer> completer = Completer>(); + + final LoginParameters loginParameters = LoginParameters( + loginID: loginId, + password: password, + callback: allowInterop((LoginResponse response) { + if (completer.isCompleted) { + return; + } + + if (response.errorCode == 0) { + completer.complete(LoginResponse.toMap(response)); + } else { + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + ), + ); + } + }), + ); + + gigyaWebSdk.accounts.login(loginParameters); + + return completer.future; + } + @override Future logout() { final Completer completer = Completer(); From c1f13ef5e8a31680aa7174b33b5f03d0b3d821f4 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 12:05:11 +0100 Subject: [PATCH 084/256] remove context from response class --- lib/src/web/static_interop/response/response.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index a0ae11c5..d98f0ec9 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -10,7 +10,6 @@ class Response { external factory Response({ int? apiVersion, String callId, - Object? context, int errorCode, String? errorDetails, String? errorMessage, @@ -22,9 +21,6 @@ class Response { /// The unique identifier of the transaction. external String get callId; - /// The context that was passed to the method that responded with this [Response]. - external Object? get context; - /// The response error code. /// /// A value of zero indicates success. From a0c4705069e9e3cf4a65e0308c0304f17ece89dd Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 12:21:09 +0100 Subject: [PATCH 085/256] convert response classes to `@staticInterop` and add inheritance --- lib/src/web/gigya_flutter_plugin_web.dart | 2 +- .../response/login_response.dart | 81 +++++++------------ .../web/static_interop/response/response.dart | 5 ++ 3 files changed, 35 insertions(+), 53 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 6d37aa06..1bce0451 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -111,7 +111,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { } if (response.errorCode == 0) { - completer.complete(LoginResponse.toMap(response)); + completer.complete(response.toMap()); } else { completer.completeError( GigyaError( diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index be98597b..db198ae9 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -4,13 +4,15 @@ import '../emails.dart'; import '../location.dart'; import '../profile.dart'; import '../session_info.dart'; +import 'response.dart'; /// The static interop class for the Gigya Login API response. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/eb93d538b9ae45bfadd9a8aaa8806753.html#response-data @JS() @anonymous -class LoginResponse { +@staticInterop +class LoginResponse extends Response { /// Construct a [LoginResponse] object. external factory LoginResponse({ int? apiVersion, @@ -37,33 +39,17 @@ class LoginResponse { String? UIDSignature, // ignore: non_constant_identifier_names String? verified, }); +} - /// The version of the Gigya API that was used. - external int? get apiVersion; - - /// The unique identifier of the transaction. - external String get callId; - +/// This extension defines the static interop definition +/// for the [LoginResponse] class. +extension LoginResponseExtension on LoginResponse { /// The timestamp of the creation of the user. external String? get createdTimestamp; /// The verified and unverified email addresses of the user. external Emails? get emails; - /// The response error code. - /// - /// A value of zero indicates success. - /// Any other number indicates a failure. - /// - /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html - external int get errorCode; - - /// The additional details of the encountered error. - external String? get errorDetails; - - /// The error message for the given [errorCode]. - external String? get errorMessage; - /// Whether the user is active. external bool? get isActive; @@ -114,57 +100,48 @@ class LoginResponse { /// The timestamp when the user was verified. external String? get verified; - /// Convert the given [response] to a [Map]. - /// - /// Since the [LoginResponse] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(LoginResponse response) { - final Emails? emails = response.emails; - final SessionInfo? sessionInfo = response.sessionInfo; - - final Profile? profile = response.profile; + /// Convert this response to a [Map]. + Map toMap() { Map? profileAsMap; if (profile != null) { - profileAsMap = Profile.toMap(profile); + profileAsMap = Profile.toMap(profile!); // The lastLoginLocation field is not in the profile // when using the Gigya Web SDK. // Instead, it is located inside the login response. // Add it to the profile map. - final Location? lastLoginLocation = response.lastLoginLocation; - if (lastLoginLocation != null) { - profileAsMap['lastLoginLocation'] = Location.toMap(lastLoginLocation); + profileAsMap['lastLoginLocation'] = Location.toMap(lastLoginLocation!); } } return { - 'createdTimestamp': response.createdTimestamp, + 'createdTimestamp': createdTimestamp, if (emails != null) 'emails': { - 'unverified': emails.unverified, - 'verified': emails.verified, + 'unverified': emails!.unverified, + 'verified': emails!.verified, }, - 'isActive': response.isActive, - 'isRegistered': response.isRegistered, - 'isVerified': response.isVerified, - 'lastLogin': response.lastLogin, - 'lastUpdated': response.lastUpdated, - 'loginProvider': response.loginProvider, - 'oldestDataUpdated': response.oldestDataUpdated, + 'isActive': isActive, + 'isRegistered': isRegistered, + 'isVerified': isVerified, + 'lastLogin': lastLogin, + 'lastUpdated': lastUpdated, + 'loginProvider': loginProvider, + 'oldestDataUpdated': oldestDataUpdated, if (profileAsMap != null) 'profile': profileAsMap, - 'registered': response.registered, + 'registered': registered, if (sessionInfo != null) 'sessionInfo': { - 'cookieName': sessionInfo.cookieName, - 'cookieValue': sessionInfo.cookieValue, + 'cookieName': sessionInfo!.cookieName, + 'cookieValue': sessionInfo!.cookieValue, }, - 'signatureTimestamp': response.signatureTimestamp, - 'socialProviders': response.socialProviders, - 'UID': response.UID, - 'UIDSignature': response.UIDSignature, - 'verified': response.verified, + 'signatureTimestamp': signatureTimestamp, + 'socialProviders': socialProviders, + 'UID': UID, + 'UIDSignature': UIDSignature, + 'verified': verified, }; } } diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index d98f0ec9..8505f8f6 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -5,6 +5,7 @@ import 'package:js/js.dart'; /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d55f070b21014bbc5a10ce4041860.html @JS() @anonymous +@staticInterop class Response { /// Construct a [Response] object. external factory Response({ @@ -14,7 +15,11 @@ class Response { String? errorDetails, String? errorMessage, }); +} +/// This extension defines the static interop definition +/// for the [Response] class. +extension ResponseExtension on Response { /// The version of the Gigya API that was used. external int? get apiVersion; From c6be6848d2d7163910729336aece99018aa8bd7b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 12:25:19 +0100 Subject: [PATCH 086/256] add getConflictingAccount to the static interop binding --- lib/src/web/static_interop/account.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 60ea90bf..22661b9d 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -12,6 +12,9 @@ class Accounts {} /// This extension defines the static interop definition /// for the [Accounts] class. extension AccountsExtension on Accounts { + /// Get the conflicting accounts of the user. + external void Function(ConflictingAccountParameters parameters) getConflictingAccount; + /// Log in using the given parameters. external void Function(LoginParameters parameters) login; From 684a9bca47d327a28efabfbe658e5a7b4fb10f04 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 12:36:11 +0100 Subject: [PATCH 087/256] convert certification to static interop --- lib/src/web/static_interop/certification.dart | 22 ++++++++++--------- lib/src/web/static_interop/profile.dart | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/src/web/static_interop/certification.dart b/lib/src/web/static_interop/certification.dart index 5af6851c..be2bbedb 100644 --- a/lib/src/web/static_interop/certification.dart +++ b/lib/src/web/static_interop/certification.dart @@ -3,6 +3,7 @@ import 'package:js/js.dart'; /// The static interop class for the Certification object. @JS() @anonymous +@staticInterop class Certification { /// Create a new [Certification] instance. external factory Certification({ @@ -12,7 +13,11 @@ class Certification { String? number, String? startDate, }); +} +/// This extension defines the static interop definition +/// for the [Certification] class. +extension CertificationExtension on Certification { /// The certification authority. external String? get authority; @@ -28,17 +33,14 @@ class Certification { /// The date that the certification was issued. external String? get startDate; - /// Convert the given [certification] to a [Map]. - /// - /// Since the [Certification] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Certification certification) { + /// Convert this certification to a [Map]. + Map toMap() { return { - 'authority': certification.authority, - 'endDate': certification.endDate, - 'name': certification.name, - 'number': certification.number, - 'startDate': certification.startDate, + 'authority': authority, + 'endDate': endDate, + 'name': name, + 'number': number, + 'startDate': startDate, }; } } diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 34a97874..77f3f073 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -212,7 +212,7 @@ class Profile { /// Since the [Profile] class is an anonymous JavaScript type, /// this has to be a static method instead of an instance method. static Map toMap(Profile profile) { - final List> certs = profile.certifications.map(Certification.toMap).toList(); + final List> certs = profile.certifications.map((Certification c) => c.toMap()).toList(); final List> education = profile.education.map(Education.toMap).toList(); final List> likes = profile.likes.map(Like.toMap).toList(); final List> patents = profile.patents.map(Patent.toMap).toList(); From c6b2412b159bb623f019fe14d27518137ec97d6a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 12:49:39 +0100 Subject: [PATCH 088/256] convert education to static interop --- lib/src/web/static_interop/education.dart | 24 ++++++++++++----------- lib/src/web/static_interop/profile.dart | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/src/web/static_interop/education.dart b/lib/src/web/static_interop/education.dart index 6939b73b..98c14687 100644 --- a/lib/src/web/static_interop/education.dart +++ b/lib/src/web/static_interop/education.dart @@ -3,6 +3,7 @@ import 'package:js/js.dart'; /// The static interop class for the Education object. @JS() @anonymous +@staticInterop class Education { /// Construct a new [Education] instance. external factory Education({ @@ -13,7 +14,11 @@ class Education { String? schoolType, String? startYear, }); +} +/// This extension defines the static interop definition +/// for the [Education] class. +extension EducationExtension on Education { /// The degree for the education. external String? get degree; @@ -32,18 +37,15 @@ class Education { /// The year in which the education was started. external String? get startYear; - /// Convert the given [education] to a [Map]. - /// - /// Since the [Education] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Education education) { + /// Convert this education to a [Map]. + Map toMap() { return { - 'degree': education.degree, - 'endYear': education.endYear, - 'fieldOfStudy': education.fieldOfStudy, - 'school': education.school, - 'schoolType': education.schoolType, - 'startYear': education.startYear, + 'degree': degree, + 'endYear': endYear, + 'fieldOfStudy': fieldOfStudy, + 'school': school, + 'schoolType': schoolType, + 'startYear': startYear, }; } } diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 77f3f073..5c008b0c 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -213,7 +213,7 @@ class Profile { /// this has to be a static method instead of an instance method. static Map toMap(Profile profile) { final List> certs = profile.certifications.map((Certification c) => c.toMap()).toList(); - final List> education = profile.education.map(Education.toMap).toList(); + final List> education = profile.education.map((Education e) => e.toMap()).toList(); final List> likes = profile.likes.map(Like.toMap).toList(); final List> patents = profile.patents.map(Patent.toMap).toList(); final List> phones = profile.phones.map(Phone.toMap).toList(); From 09e163ba1c443a283aefa081f6678bfed04a70e8 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 12:51:11 +0100 Subject: [PATCH 089/256] convert emails to static interop --- lib/src/web/static_interop/emails.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/web/static_interop/emails.dart b/lib/src/web/static_interop/emails.dart index 512e751e..e2124755 100644 --- a/lib/src/web/static_interop/emails.dart +++ b/lib/src/web/static_interop/emails.dart @@ -3,13 +3,18 @@ import 'package:js/js.dart'; /// The static interop class for the emails object. @JS() @anonymous +@staticInterop class Emails { /// Create a new [Emails] instance. external factory Emails({ List unverified, List verified, }); +} +/// This extension defines the static interop definition +/// for the [Emails] class. +extension EmailsExtension on Emails { /// The list of unverified email addresses. external List get unverified; From b8ea419a42b04836ad6f497a010ffebec13815af Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 12:58:37 +0100 Subject: [PATCH 090/256] convert favorites to static interop --- lib/src/web/static_interop/favorites.dart | 42 +++++++++++++---------- lib/src/web/static_interop/profile.dart | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/src/web/static_interop/favorites.dart b/lib/src/web/static_interop/favorites.dart index 94f0b2d4..8f5045dc 100644 --- a/lib/src/web/static_interop/favorites.dart +++ b/lib/src/web/static_interop/favorites.dart @@ -3,6 +3,7 @@ import 'package:js/js.dart'; /// The static interop class for the `Favorite` object. @JS() @anonymous +@staticInterop class Favorite { /// Construct a new [Favorite] instance. external factory Favorite({ @@ -10,7 +11,11 @@ class Favorite { String? id, String? name, }); +} +/// This extension defines the static interop definition +/// for the [Favorite] class. +extension FavoriteExtension on Favorite { /// The category of the favorite. external String? get category; @@ -20,15 +25,12 @@ class Favorite { /// The name of the favorite. external String? get name; - /// Convert the given [favorite] to a [Map]. - /// - /// Since the [Favorite] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Favorite favorite) { + /// Convert this favorite to a [Map]. + Map toMap() { return { - 'id': favorite.id, - 'name': favorite.name, - 'category': favorite.category, + 'id': id, + 'name': name, + 'category': category, }; } } @@ -36,6 +38,7 @@ class Favorite { /// The static interop class for the `Favorites` object. @JS() @anonymous +@staticInterop class Favorites { /// Construct a new [Favorites] instance. external factory Favorites({ @@ -46,7 +49,11 @@ class Favorites { List music, List television, }); +} +/// This extension defines the static interop definition +/// for the [Favorites] class. +extension FavoritesExtension on Favorites { /// The user's favorite activities. external List get activities; @@ -65,18 +72,15 @@ class Favorites { /// The user's favorite television programmes. external List get television; - /// Convert the given [favorites] to a [Map]. - /// - /// Since the [Favorites] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Favorites favorites) { + /// Convert this favorites object to a [Map]. + Map toMap() { return { - 'activities': favorites.activities.map(Favorite.toMap).toList(), - 'books': favorites.books.map(Favorite.toMap).toList(), - 'interests': favorites.interests.map(Favorite.toMap).toList(), - 'movies': favorites.movies.map(Favorite.toMap).toList(), - 'music': favorites.music.map(Favorite.toMap).toList(), - 'television': favorites.television.map(Favorite.toMap).toList(), + 'activities': activities.map((Favorite f) => f.toMap()).toList(), + 'books': books.map((Favorite f) => f.toMap()).toList(), + 'interests': interests.map((Favorite f) => f.toMap()).toList(), + 'movies': movies.map((Favorite f) => f.toMap()).toList(), + 'music': music.map((Favorite f) => f.toMap()).toList(), + 'television': television.map((Favorite f) => f.toMap()).toList(), }; } } diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 5c008b0c..6b9c4955 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -235,7 +235,7 @@ class Profile { 'education': education, 'educationLevel': profile.educationLevel, 'email': profile.email, - 'favorites': Favorites.toMap(profile.favorites), + 'favorites': profile.favorites.toMap(), 'firstName': profile.firstName, 'followersCount': profile.followers, 'followingCount': profile.following, From fd462aa094fbbc445c3cb786364d74d6eac58dc5 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:03:00 +0100 Subject: [PATCH 091/256] convert like to static interop --- lib/src/web/static_interop/like.dart | 20 +++++++++++--------- lib/src/web/static_interop/profile.dart | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/src/web/static_interop/like.dart b/lib/src/web/static_interop/like.dart index 91e16be2..aaa11844 100644 --- a/lib/src/web/static_interop/like.dart +++ b/lib/src/web/static_interop/like.dart @@ -3,6 +3,7 @@ import 'package:js/js.dart'; /// The static interop class for the `Like` object. @JS() @anonymous +@staticInterop class Like { /// Create a new [Like] instance. external factory Like({ @@ -11,7 +12,11 @@ class Like { String? name, String? time, }); +} +/// This extension defines the static interop definition +/// for the [Like] class. +extension LikeExtension on Like { /// The category of the like. external String? get category; @@ -24,16 +29,13 @@ class Like { /// The timestamp, in UTC, on which the like was created. external String? get time; - /// Convert the given [like] to a [Map]. - /// - /// Since the [Like] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Like like) { + /// Convert this like to a [Map]. + Map toMap() { return { - 'category': like.category, - 'id': like.id, - 'name': like.name, - 'time': like.time, + 'category': category, + 'id': id, + 'name': name, + 'time': time, }; } } diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 6b9c4955..eb3abfb0 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -214,7 +214,7 @@ class Profile { static Map toMap(Profile profile) { final List> certs = profile.certifications.map((Certification c) => c.toMap()).toList(); final List> education = profile.education.map((Education e) => e.toMap()).toList(); - final List> likes = profile.likes.map(Like.toMap).toList(); + final List> likes = profile.likes.map((Like l) => l.toMap()).toList(); final List> patents = profile.patents.map(Patent.toMap).toList(); final List> phones = profile.phones.map(Phone.toMap).toList(); final List> publications = profile.publications.map(Publication.toMap).toList(); From 074f3664cc13346f0f39f0792384768e5d2b2265 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:07:11 +0100 Subject: [PATCH 092/256] convert location to static interop --- lib/src/web/static_interop/location.dart | 27 ++++++++++++------- .../response/login_response.dart | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/src/web/static_interop/location.dart b/lib/src/web/static_interop/location.dart index 86008434..f3b807ab 100644 --- a/lib/src/web/static_interop/location.dart +++ b/lib/src/web/static_interop/location.dart @@ -3,10 +3,15 @@ import 'package:js/js.dart'; /// The static interop class for the `Coordinates` object. @JS() @anonymous +@staticInterop class Coordinates { /// Construct a new [Coordinates] instance. external factory Coordinates({String? lat, String? lon}); +} +/// This extension defines the static interop definition +/// for the [Coordinates] class. +extension CoordinatesExtension on Coordinates { /// The longitude of the coordinate. external double? get lat; @@ -17,6 +22,7 @@ class Coordinates { /// The static interop class for the `Location` object. @JS() @anonymous +@staticInterop class Location { /// Construct a new [Location] instance. external factory Location({ @@ -25,7 +31,11 @@ class Location { String? country, String? state, }); +} +/// This extension defines the static interop definition +/// for the [Location] class. +extension LocationExtension on Location { /// The name of the city in which the location is located. external String? get city; @@ -38,19 +48,16 @@ class Location { /// The state in which the location is located. external String? get state; - /// Convert the given [location] to a [Map]. - /// - /// Since the [Location] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Location location) { + /// Convert this location to a [Map]. + Map toMap() { return { - 'city': location.city, - 'country': location.country, + 'city': city, + 'country': country, 'coordinates': { - 'lat': location.coordinates?.lat, - 'lon': location.coordinates?.lon, + 'lat': coordinates?.lat, + 'lon': coordinates?.lon, }, - 'state': location.state, + 'state': state, }; } } diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index db198ae9..36a9592c 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -112,7 +112,7 @@ extension LoginResponseExtension on LoginResponse { // Instead, it is located inside the login response. // Add it to the profile map. if (lastLoginLocation != null) { - profileAsMap['lastLoginLocation'] = Location.toMap(lastLoginLocation!); + profileAsMap['lastLoginLocation'] = lastLoginLocation!.toMap(); } } From 437695b4707b4d392fb54662438942d9382d50c9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:10:00 +0100 Subject: [PATCH 093/256] convert phone to static interop --- lib/src/web/static_interop/phone.dart | 16 +++++++++------- lib/src/web/static_interop/profile.dart | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/src/web/static_interop/phone.dart b/lib/src/web/static_interop/phone.dart index 957e5e58..7423af2f 100644 --- a/lib/src/web/static_interop/phone.dart +++ b/lib/src/web/static_interop/phone.dart @@ -3,24 +3,26 @@ import 'package:js/js.dart'; /// The static interop class for the `Phone` object. @JS() @anonymous +@staticInterop class Phone { /// Construct a new [Phone] instance. external factory Phone({String? number, String? type}); +} +/// This extension defines the static interop definition +/// for the [Phone] class. +extension PhoneExtension on Phone { /// The value of the phone number. external String? get number; /// The type of phone number. external String? get type; - /// Convert the given [phone] to a [Map]. - /// - /// Since the [Phone] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Phone phone) { + /// Convert this phone into a [Map]. + Map toMap() { return { - 'number': phone.number, - 'type': phone.type, + 'number': number, + 'type': type, }; } } diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index eb3abfb0..52862d57 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -216,7 +216,7 @@ class Profile { final List> education = profile.education.map((Education e) => e.toMap()).toList(); final List> likes = profile.likes.map((Like l) => l.toMap()).toList(); final List> patents = profile.patents.map(Patent.toMap).toList(); - final List> phones = profile.phones.map(Phone.toMap).toList(); + final List> phones = profile.phones.map((Phone p) => p.toMap()).toList(); final List> publications = profile.publications.map(Publication.toMap).toList(); final List> skills = profile.skills.map(Skill.toMap).toList(); final List> work = profile.work.map(Work.toMap).toList(); From 292182b4ca3f6865b2537b9b298cc787171b6a24 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:14:37 +0100 Subject: [PATCH 094/256] convert patent to static interop --- lib/src/web/static_interop/patent.dart | 26 +++++++++++++------------ lib/src/web/static_interop/profile.dart | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/src/web/static_interop/patent.dart b/lib/src/web/static_interop/patent.dart index 3271eecd..fcba1396 100644 --- a/lib/src/web/static_interop/patent.dart +++ b/lib/src/web/static_interop/patent.dart @@ -3,6 +3,7 @@ import 'package:js/js.dart'; /// The static interop class for the `Patent` object. @JS() @anonymous +@staticInterop class Patent { /// Construct a new [Patent] instance. external factory Patent({ @@ -14,7 +15,11 @@ class Patent { String? title, String? url, }); +} +/// This extension defines the static interop definition +/// for the [Patent] class. +extension PatentExtension on Patent { /// The issue date of the patent. external String? get date; @@ -36,19 +41,16 @@ class Patent { /// The url to the patent document. external String? get url; - /// Convert the given [patent] to a [Map]. - /// - /// Since the [Patent] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Patent patent) { + /// Convert this patent into a [Map]. + Map toMap() { return { - 'date': patent.date, - 'number': patent.number, - 'office': patent.office, - 'status': patent.status, - 'summary': patent.summary, - 'title': patent.title, - 'url': patent.url, + 'date': date, + 'number': number, + 'office': office, + 'status': status, + 'summary': summary, + 'title': title, + 'url': url, }; } } diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 52862d57..3214c331 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -215,7 +215,7 @@ class Profile { final List> certs = profile.certifications.map((Certification c) => c.toMap()).toList(); final List> education = profile.education.map((Education e) => e.toMap()).toList(); final List> likes = profile.likes.map((Like l) => l.toMap()).toList(); - final List> patents = profile.patents.map(Patent.toMap).toList(); + final List> patents = profile.patents.map((Patent p) => p.toMap()).toList(); final List> phones = profile.phones.map((Phone p) => p.toMap()).toList(); final List> publications = profile.publications.map(Publication.toMap).toList(); final List> skills = profile.skills.map(Skill.toMap).toList(); From 429349db0f68d0cbb43aead5d78414662e1811a0 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:17:33 +0100 Subject: [PATCH 095/256] convert publication to static interop --- lib/src/web/static_interop/profile.dart | 2 +- lib/src/web/static_interop/publication.dart | 22 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 3214c331..29f6de5e 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -217,7 +217,7 @@ class Profile { final List> likes = profile.likes.map((Like l) => l.toMap()).toList(); final List> patents = profile.patents.map((Patent p) => p.toMap()).toList(); final List> phones = profile.phones.map((Phone p) => p.toMap()).toList(); - final List> publications = profile.publications.map(Publication.toMap).toList(); + final List> publications = profile.publications.map((Publication p) => p.toMap()).toList(); final List> skills = profile.skills.map(Skill.toMap).toList(); final List> work = profile.work.map(Work.toMap).toList(); diff --git a/lib/src/web/static_interop/publication.dart b/lib/src/web/static_interop/publication.dart index 9e722f84..f938e221 100644 --- a/lib/src/web/static_interop/publication.dart +++ b/lib/src/web/static_interop/publication.dart @@ -3,6 +3,7 @@ import 'package:js/js.dart'; /// The static interop class for the `Publication` object. @JS() @anonymous +@staticInterop class Publication { /// Construct a new [Publication] instance. external factory Publication({ @@ -12,7 +13,11 @@ class Publication { String? title, String? url, }); +} +/// This extension defines the static interop definition +/// for the [Publication] class. +extension PublicationExtension on Publication { /// The publication date. external String? get date; @@ -28,17 +33,14 @@ class Publication { /// The url to the publication's document. external String? get url; - /// Convert the given [publication] to a [Map]. - /// - /// Since the [Publication] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Publication publication) { + /// Convert this publication into a [Map]. + Map toMap() { return { - 'date': publication.date, - 'publisher': publication.publisher, - 'summary': publication.summary, - 'title': publication.title, - 'url': publication.url, + 'date': date, + 'publisher': publisher, + 'summary': summary, + 'title': title, + 'url': url, }; } } From b396f3b826ab78b656eee5a26d096ed3bd978079 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:19:06 +0100 Subject: [PATCH 096/256] convert session info to static interop --- lib/src/web/static_interop/session_info.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/web/static_interop/session_info.dart b/lib/src/web/static_interop/session_info.dart index 584d2938..ddff67a7 100644 --- a/lib/src/web/static_interop/session_info.dart +++ b/lib/src/web/static_interop/session_info.dart @@ -3,13 +3,18 @@ import 'package:js/js.dart'; /// The static interop class for the session info object. @JS() @anonymous +@staticInterop class SessionInfo { /// Construct a new [SessionInfo] instance. external factory SessionInfo({ String? cookieName, String? cookieValue, }); +} +/// This extension defines the static interop definition +/// for the [SessionInfo] class. +extension SessionInfoExtension on SessionInfo { /// The name of the session cookie. external String? get cookieName; From 5c80f2d9fa1bf5d5e6a1a9acbd90c22dcec22161 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:21:45 +0100 Subject: [PATCH 097/256] convert skill to static interop --- lib/src/web/static_interop/profile.dart | 2 +- lib/src/web/static_interop/skill.dart | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 29f6de5e..ef272aee 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -218,7 +218,7 @@ class Profile { final List> patents = profile.patents.map((Patent p) => p.toMap()).toList(); final List> phones = profile.phones.map((Phone p) => p.toMap()).toList(); final List> publications = profile.publications.map((Publication p) => p.toMap()).toList(); - final List> skills = profile.skills.map(Skill.toMap).toList(); + final List> skills = profile.skills.map((Skill s) => s.toMap()).toList(); final List> work = profile.work.map(Work.toMap).toList(); return { diff --git a/lib/src/web/static_interop/skill.dart b/lib/src/web/static_interop/skill.dart index c9a85ca8..795e76f2 100644 --- a/lib/src/web/static_interop/skill.dart +++ b/lib/src/web/static_interop/skill.dart @@ -3,10 +3,15 @@ import 'package:js/js.dart'; /// The static interop class for the `Skill` object. @JS() @anonymous +@staticInterop class Skill { /// Construct a new [Skill] instance. external factory Skill({String? level, String? skill, int? years}); +} +/// This extension defines the static interop definition +/// for the [Skill] class. +extension SkillExtension on Skill { /// The user's proficiency in the skill. external String? get level; @@ -16,15 +21,12 @@ class Skill { /// The years of the user's skill. external int? get years; - /// Convert the given [skill] to a [Map]. - /// - /// Since the [Skill] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Skill skill) { + /// Convert this skill to a [Map]. + Map toMap() { return { - 'level': skill.level, - 'skill': skill.skill, - 'years': skill.years, + 'level': level, + 'skill': skill, + 'years': years, }; } } From c933e103bfd070a5b2405461d3d879930751990b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:24:25 +0100 Subject: [PATCH 098/256] convert work to static interop --- lib/src/web/static_interop/profile.dart | 2 +- lib/src/web/static_interop/work.dart | 28 +++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index ef272aee..58ba02e5 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -219,7 +219,7 @@ class Profile { final List> phones = profile.phones.map((Phone p) => p.toMap()).toList(); final List> publications = profile.publications.map((Publication p) => p.toMap()).toList(); final List> skills = profile.skills.map((Skill s) => s.toMap()).toList(); - final List> work = profile.work.map(Work.toMap).toList(); + final List> work = profile.work.map((Work w) => w.toMap()).toList(); return { 'activities': profile.activities, diff --git a/lib/src/web/static_interop/work.dart b/lib/src/web/static_interop/work.dart index 6dbe3c6a..5f0b26b1 100644 --- a/lib/src/web/static_interop/work.dart +++ b/lib/src/web/static_interop/work.dart @@ -3,6 +3,7 @@ import 'package:js/js.dart'; /// The static interop class for the `Work` object. @JS() @anonymous +@staticInterop class Work { /// Construct a new [Work] instance. external factory Work({ @@ -15,7 +16,11 @@ class Work { String? startDate, String? title, }); +} +/// This extension defines the static interop definition +/// for the [Work] class. +extension WorkExtension on Work { /// The name of the company. external String? get company; @@ -40,20 +45,17 @@ class Work { /// The user's title in the company. external String? get title; - /// Convert the given [work] to a [Map]. - /// - /// Since the [Work] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Work work) { + /// Convert this work object into a [Map]. + Map toMap() { return { - 'company': work.company, - 'companyID': work.companyID, - 'companySize': work.companySize, - 'endDate': work.endDate, - 'industry': work.industry, - 'isCurrent': work.isCurrent, - 'startDate': work.startDate, - 'title': work.title, + 'company': company, + 'companyID': companyID, + 'companySize': companySize, + 'endDate': endDate, + 'industry': industry, + 'isCurrent': isCurrent, + 'startDate': startDate, + 'title': title, }; } } From 2670716b47fca527f4854cb2f899d667c5536840 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:34:15 +0100 Subject: [PATCH 099/256] convert profile to static interop --- lib/src/web/static_interop/profile.dart | 113 ++++++++---------- .../response/login_response.dart | 10 +- 2 files changed, 56 insertions(+), 67 deletions(-) diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/profile.dart index 58ba02e5..4e68a401 100644 --- a/lib/src/web/static_interop/profile.dart +++ b/lib/src/web/static_interop/profile.dart @@ -14,6 +14,7 @@ import 'work.dart'; /// for the profile object. @JS() @anonymous +@staticInterop class Profile { /// Construct a new [Profile] instance. external factory Profile({ @@ -65,7 +66,11 @@ class Profile { List work, String? zip, }); +} +/// This extension defines the static interop definition +/// for the [Profile] class. +extension ProfileExtension on Profile { /// The person's activities. external String? get activities; @@ -207,67 +212,55 @@ class Profile { /// The ZIP code of the person's address. external String? get zip; - /// Convert the given [profile] to a [Map]. - /// - /// Since the [Profile] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Profile profile) { - final List> certs = profile.certifications.map((Certification c) => c.toMap()).toList(); - final List> education = profile.education.map((Education e) => e.toMap()).toList(); - final List> likes = profile.likes.map((Like l) => l.toMap()).toList(); - final List> patents = profile.patents.map((Patent p) => p.toMap()).toList(); - final List> phones = profile.phones.map((Phone p) => p.toMap()).toList(); - final List> publications = profile.publications.map((Publication p) => p.toMap()).toList(); - final List> skills = profile.skills.map((Skill s) => s.toMap()).toList(); - final List> work = profile.work.map((Work w) => w.toMap()).toList(); - + /// Convert this profile into a [Map]. + Map toMap() { return { - 'activities': profile.activities, - 'address': profile.address, - 'age': profile.age, - 'bio': profile.bio, - 'birthDay': profile.birthDay, - 'birthMonth': profile.birthMonth, - 'birthYear': profile.birthYear, - 'certifications': certs, - 'city': profile.city, - 'country': profile.country, - 'education': education, - 'educationLevel': profile.educationLevel, - 'email': profile.email, - 'favorites': profile.favorites.toMap(), - 'firstName': profile.firstName, - 'followersCount': profile.followers, - 'followingCount': profile.following, - 'gender': profile.gender, - 'hometown': profile.hometown, - 'honors': profile.honors, - 'industry': profile.industry, - 'interests': profile.interests, - 'languages': profile.languages, - 'lastName': profile.lastName, - 'likes': likes, - 'locale': profile.locale, - 'name': profile.name, - 'nickname': profile.nickname, - 'patents': patents, - 'phones': phones, - 'photoURL': profile.photoUrl, - 'politicalView': profile.politicalView, - 'professionalHeadline': profile.professionalHeadline, - 'proxyEmail': profile.proxyEmail, - 'publications': publications, - 'relationshipStatus': profile.relationshipStatus, - 'religion': profile.religion, - 'skills': skills, - 'specialities': profile.specialities, - 'state': profile.state, - 'thumbnailURL': profile.thumbnailUrl, - 'timezone': profile.timezone, - 'username': profile.username, - 'verified': profile.verified, - 'work': work, - 'zip': profile.zip, + 'activities': activities, + 'address': address, + 'age': age, + 'bio': bio, + 'birthDay': birthDay, + 'birthMonth': birthMonth, + 'birthYear': birthYear, + 'certifications': certifications.map((Certification c) => c.toMap()).toList(), + 'city': city, + 'country': country, + 'education': education.map((Education e) => e.toMap()).toList(), + 'educationLevel': educationLevel, + 'email': email, + 'favorites': favorites.toMap(), + 'firstName': firstName, + 'followersCount': followers, + 'followingCount': following, + 'gender': gender, + 'hometown': hometown, + 'honors': honors, + 'industry': industry, + 'interests': interests, + 'languages': languages, + 'lastName': lastName, + 'likes': likes.map((Like l) => l.toMap()).toList(), + 'locale': locale, + 'name': name, + 'nickname': nickname, + 'patents': patents.map((Patent p) => p.toMap()).toList(), + 'phones': phones.map((Phone p) => p.toMap()).toList(), + 'photoURL': photoUrl, + 'politicalView': politicalView, + 'professionalHeadline': professionalHeadline, + 'proxyEmail': proxyEmail, + 'publications': publications.map((Publication p) => p.toMap()).toList(), + 'relationshipStatus': relationshipStatus, + 'religion': religion, + 'skills': skills.map((Skill s) => s.toMap()).toList(), + 'specialities': specialities, + 'state': state, + 'thumbnailURL': thumbnailUrl, + 'timezone': timezone, + 'username': username, + 'verified': verified, + 'work': work.map((Work w) => w.toMap()).toList(), + 'zip': zip, }; } } diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 36a9592c..0b63afa4 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -102,18 +102,14 @@ extension LoginResponseExtension on LoginResponse { /// Convert this response to a [Map]. Map toMap() { - Map? profileAsMap; - - if (profile != null) { - profileAsMap = Profile.toMap(profile!); + final Map? profileAsMap = profile?.toMap(); + if (profileAsMap != null) { // The lastLoginLocation field is not in the profile // when using the Gigya Web SDK. // Instead, it is located inside the login response. // Add it to the profile map. - if (lastLoginLocation != null) { - profileAsMap['lastLoginLocation'] = lastLoginLocation!.toMap(); - } + profileAsMap['lastLoginLocation'] = lastLoginLocation?.toMap(); } return { From 7f81e6bed590d9aa82bc974dd11edf00c73359c1 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:40:56 +0100 Subject: [PATCH 100/256] move static interop model classes into /models sub folder --- lib/src/web/static_interop/{ => models}/certification.dart | 0 lib/src/web/static_interop/{ => models}/education.dart | 0 lib/src/web/static_interop/{ => models}/emails.dart | 0 lib/src/web/static_interop/{ => models}/favorites.dart | 0 lib/src/web/static_interop/{ => models}/like.dart | 0 lib/src/web/static_interop/{ => models}/location.dart | 0 lib/src/web/static_interop/{ => models}/patent.dart | 0 lib/src/web/static_interop/{ => models}/phone.dart | 0 lib/src/web/static_interop/{ => models}/profile.dart | 0 lib/src/web/static_interop/{ => models}/publication.dart | 0 lib/src/web/static_interop/{ => models}/session_info.dart | 0 lib/src/web/static_interop/{ => models}/skill.dart | 0 lib/src/web/static_interop/{ => models}/work.dart | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename lib/src/web/static_interop/{ => models}/certification.dart (100%) rename lib/src/web/static_interop/{ => models}/education.dart (100%) rename lib/src/web/static_interop/{ => models}/emails.dart (100%) rename lib/src/web/static_interop/{ => models}/favorites.dart (100%) rename lib/src/web/static_interop/{ => models}/like.dart (100%) rename lib/src/web/static_interop/{ => models}/location.dart (100%) rename lib/src/web/static_interop/{ => models}/patent.dart (100%) rename lib/src/web/static_interop/{ => models}/phone.dart (100%) rename lib/src/web/static_interop/{ => models}/profile.dart (100%) rename lib/src/web/static_interop/{ => models}/publication.dart (100%) rename lib/src/web/static_interop/{ => models}/session_info.dart (100%) rename lib/src/web/static_interop/{ => models}/skill.dart (100%) rename lib/src/web/static_interop/{ => models}/work.dart (100%) diff --git a/lib/src/web/static_interop/certification.dart b/lib/src/web/static_interop/models/certification.dart similarity index 100% rename from lib/src/web/static_interop/certification.dart rename to lib/src/web/static_interop/models/certification.dart diff --git a/lib/src/web/static_interop/education.dart b/lib/src/web/static_interop/models/education.dart similarity index 100% rename from lib/src/web/static_interop/education.dart rename to lib/src/web/static_interop/models/education.dart diff --git a/lib/src/web/static_interop/emails.dart b/lib/src/web/static_interop/models/emails.dart similarity index 100% rename from lib/src/web/static_interop/emails.dart rename to lib/src/web/static_interop/models/emails.dart diff --git a/lib/src/web/static_interop/favorites.dart b/lib/src/web/static_interop/models/favorites.dart similarity index 100% rename from lib/src/web/static_interop/favorites.dart rename to lib/src/web/static_interop/models/favorites.dart diff --git a/lib/src/web/static_interop/like.dart b/lib/src/web/static_interop/models/like.dart similarity index 100% rename from lib/src/web/static_interop/like.dart rename to lib/src/web/static_interop/models/like.dart diff --git a/lib/src/web/static_interop/location.dart b/lib/src/web/static_interop/models/location.dart similarity index 100% rename from lib/src/web/static_interop/location.dart rename to lib/src/web/static_interop/models/location.dart diff --git a/lib/src/web/static_interop/patent.dart b/lib/src/web/static_interop/models/patent.dart similarity index 100% rename from lib/src/web/static_interop/patent.dart rename to lib/src/web/static_interop/models/patent.dart diff --git a/lib/src/web/static_interop/phone.dart b/lib/src/web/static_interop/models/phone.dart similarity index 100% rename from lib/src/web/static_interop/phone.dart rename to lib/src/web/static_interop/models/phone.dart diff --git a/lib/src/web/static_interop/profile.dart b/lib/src/web/static_interop/models/profile.dart similarity index 100% rename from lib/src/web/static_interop/profile.dart rename to lib/src/web/static_interop/models/profile.dart diff --git a/lib/src/web/static_interop/publication.dart b/lib/src/web/static_interop/models/publication.dart similarity index 100% rename from lib/src/web/static_interop/publication.dart rename to lib/src/web/static_interop/models/publication.dart diff --git a/lib/src/web/static_interop/session_info.dart b/lib/src/web/static_interop/models/session_info.dart similarity index 100% rename from lib/src/web/static_interop/session_info.dart rename to lib/src/web/static_interop/models/session_info.dart diff --git a/lib/src/web/static_interop/skill.dart b/lib/src/web/static_interop/models/skill.dart similarity index 100% rename from lib/src/web/static_interop/skill.dart rename to lib/src/web/static_interop/models/skill.dart diff --git a/lib/src/web/static_interop/work.dart b/lib/src/web/static_interop/models/work.dart similarity index 100% rename from lib/src/web/static_interop/work.dart rename to lib/src/web/static_interop/models/work.dart From 7b7a2b285610aedf825bfe6899f4625dcf682353 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:41:53 +0100 Subject: [PATCH 101/256] update import --- lib/src/web/static_interop/response/login_response.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 0b63afa4..f4e58303 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -1,9 +1,9 @@ import 'package:js/js.dart'; -import '../emails.dart'; -import '../location.dart'; -import '../profile.dart'; -import '../session_info.dart'; +import '../models/emails.dart'; +import '../models/location.dart'; +import '../models/profile.dart'; +import '../models/session_info.dart'; import 'response.dart'; /// The static interop class for the Gigya Login API response. From bbf0eb47b36f43fd3eb5595e28cb2b5c59c3579d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 13:53:04 +0100 Subject: [PATCH 102/256] move login parameters to subfolder --- lib/src/web/gigya_flutter_plugin_web.dart | 1 + lib/src/web/static_interop/account.dart | 1 + lib/src/web/static_interop/parameters/login.dart | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 lib/src/web/static_interop/parameters/login.dart diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 1bce0451..b8a850c0 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -9,6 +9,7 @@ import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; import 'static_interop/account.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/parameters.dart'; +import 'static_interop/parameters/login.dart'; import 'static_interop/response/login_response.dart'; import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 22661b9d..3169308c 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -1,6 +1,7 @@ import 'package:js/js.dart'; import 'parameters.dart'; +import 'parameters/login.dart'; /// The static interop class for the `gigya.accounts` JavaScript object. /// diff --git a/lib/src/web/static_interop/parameters/login.dart b/lib/src/web/static_interop/parameters/login.dart new file mode 100644 index 00000000..21cae80e --- /dev/null +++ b/lib/src/web/static_interop/parameters/login.dart @@ -0,0 +1,16 @@ +import 'package:js/js.dart'; + +import '../response/login_response.dart'; + +/// This class represents the parameters for the `Accounts.login` method. +@JS() +@anonymous +@staticInterop +class LoginParameters { + /// Create a new [LoginParameters] instance. + external factory LoginParameters({ + String loginID, + String password, + void Function(LoginResponse response) callback, + }); +} From c6fc328c2b6a4a79fd1e1b513fcb1fc938bfac3a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 14:01:07 +0100 Subject: [PATCH 103/256] rename GigyaMethodParameters to BasicParameters and move to different file --- lib/src/web/gigya_flutter_plugin_web.dart | 6 ++-- lib/src/web/static_interop/account.dart | 6 ++-- lib/src/web/static_interop/parameters.dart | 28 ------------------- .../web/static_interop/parameters/basic.dart | 13 +++++++++ 4 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 lib/src/web/static_interop/parameters.dart create mode 100644 lib/src/web/static_interop/parameters/basic.dart diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index b8a850c0..07ccd544 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -8,7 +8,7 @@ import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; import 'static_interop/account.dart'; import 'static_interop/gigya_web_sdk.dart'; -import 'static_interop/parameters.dart'; +import 'static_interop/parameters/basic.dart'; import 'static_interop/parameters/login.dart'; import 'static_interop/response/login_response.dart'; import 'static_interop/response/response.dart'; @@ -63,7 +63,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { @override Future isLoggedIn() { final Completer completer = Completer(); - final GigyaMethodParameters parameters = GigyaMethodParameters( + final BasicParameters parameters = BasicParameters( callback: allowInterop((Response response) { if (completer.isCompleted) { return; @@ -134,7 +134,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { @override Future logout() { final Completer completer = Completer(); - final GigyaMethodParameters parameters = GigyaMethodParameters( + final BasicParameters parameters = BasicParameters( callback: allowInterop((Response response) { if (completer.isCompleted) { return; diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 3169308c..b1dec665 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -1,6 +1,6 @@ import 'package:js/js.dart'; -import 'parameters.dart'; +import 'parameters/basic.dart'; import 'parameters/login.dart'; /// The static interop class for the `gigya.accounts` JavaScript object. @@ -20,7 +20,7 @@ extension AccountsExtension on Accounts { external void Function(LoginParameters parameters) login; /// Log out of the current session. - external void Function(GigyaMethodParameters parameters) logout; + external void Function(BasicParameters parameters) logout; /// Get the session namespace within the accounts namespace. external Session get session; @@ -37,5 +37,5 @@ class Session {} /// for the [Session] class. extension SessionExtension on Session { /// Verify the current session. - external void Function(GigyaMethodParameters parameters) verify; + external void Function(BasicParameters parameters) verify; } diff --git a/lib/src/web/static_interop/parameters.dart b/lib/src/web/static_interop/parameters.dart deleted file mode 100644 index c4a7863a..00000000 --- a/lib/src/web/static_interop/parameters.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:js/js.dart'; - -import 'response/login_response.dart'; -import 'response/response.dart'; - -/// This class represents the parameters object for the various Gigya Web SDK methods -/// that use a callback function which provides a [Response], along with a `context` object. -@JS() -@anonymous -class GigyaMethodParameters { - /// Create a [GigyaMethodParameters] instance using the given [callback] and [context]. - external factory GigyaMethodParameters({ - void Function(Response response) callback, - Object? context, - }); -} - -/// This class represents the parameters for the `accounts.login()` method. -@JS() -@anonymous -class LoginParameters { - /// Create a new [LoginParameters] instance. - external factory LoginParameters({ - String loginID, - String password, - void Function(LoginResponse response) callback, - }); -} diff --git a/lib/src/web/static_interop/parameters/basic.dart b/lib/src/web/static_interop/parameters/basic.dart new file mode 100644 index 00000000..f0848023 --- /dev/null +++ b/lib/src/web/static_interop/parameters/basic.dart @@ -0,0 +1,13 @@ +import 'package:js/js.dart'; + +import '../response/response.dart'; + +/// This class represents the parameters for functions within the Gigya Web SDK, +/// that accept a `callback` function, which in turn receives a [Response] as argument. +@JS() +@anonymous +@staticInterop +class BasicParameters { + /// Create a [BasicParameters] instance using the given [callback]. + external factory BasicParameters({void Function(Response response) callback}); +} From ba026d60ddf310df70e0faeb1bf69325513f2e9d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 14:21:55 +0100 Subject: [PATCH 104/256] implement conflicting account parameters class --- lib/src/web/static_interop/account.dart | 1 + .../parameters/conflicting_account.dart | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 lib/src/web/static_interop/parameters/conflicting_account.dart diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index b1dec665..688bce28 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -1,6 +1,7 @@ import 'package:js/js.dart'; import 'parameters/basic.dart'; +import 'parameters/conflicting_account.dart'; import 'parameters/login.dart'; /// The static interop class for the `gigya.accounts` JavaScript object. diff --git a/lib/src/web/static_interop/parameters/conflicting_account.dart b/lib/src/web/static_interop/parameters/conflicting_account.dart new file mode 100644 index 00000000..037887be --- /dev/null +++ b/lib/src/web/static_interop/parameters/conflicting_account.dart @@ -0,0 +1,15 @@ +import 'package:js/js.dart'; + +import '../response/conflicting_account_response.dart'; + +/// This class represents the parameters for the `Accounts.getConflictingAccount` method. +@JS() +@anonymous +@staticInterop +class ConflictingAccountParameters { + /// Create a [ConflictingAccountParameters] instance using the given [callback] and [regToken]. + external factory ConflictingAccountParameters({ + void Function(ConflictingAccountResponse response) callback, + String regToken, + }); +} From bf4879c17bd11e2f4943386cf13f2450d3b34e81 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 14:45:40 +0100 Subject: [PATCH 105/256] implement conflciting account static interop class --- .../models/conflicting_account.dart | 24 +++++++++++++++++++ .../conflicting_account_response.dart | 22 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 lib/src/web/static_interop/models/conflicting_account.dart create mode 100644 lib/src/web/static_interop/response/conflicting_account_response.dart diff --git a/lib/src/web/static_interop/models/conflicting_account.dart b/lib/src/web/static_interop/models/conflicting_account.dart new file mode 100644 index 00000000..6a032e13 --- /dev/null +++ b/lib/src/web/static_interop/models/conflicting_account.dart @@ -0,0 +1,24 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Conflicting Account` object. +@JS() +@anonymous +@staticInterop +class ConflictingAccount { + /// Construct a new [ConflictingAccount] instance. + external factory ConflictingAccount({ + String? loginID, + List? loginProviders, + }); +} + +/// This extension defines the static interop definition +/// for the [ConflictingAccount] class. +extension ConflictingAccountExtension on ConflictingAccount { + /// The username or email address + /// of the user that has a conflicting account. + external String? get loginID; + + /// The login providers for the that has a conflicting account. + external List? get loginProviders; +} diff --git a/lib/src/web/static_interop/response/conflicting_account_response.dart b/lib/src/web/static_interop/response/conflicting_account_response.dart new file mode 100644 index 00000000..ccdf6427 --- /dev/null +++ b/lib/src/web/static_interop/response/conflicting_account_response.dart @@ -0,0 +1,22 @@ +import 'package:js/js.dart'; + +import '../models/conflicting_account.dart'; +import 'response.dart'; + +/// The static interop class for the Gigya Conflicting Account API response. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4134c49270b21014bbc5a10ce4041860.html +@JS() +@anonymous +@staticInterop +class ConflictingAccountResponse extends Response { + /// Construct a [ConflictingAccountResponse] object. + external factory ConflictingAccountResponse({ + int? apiVersion, + String callId, + ConflictingAccount? conflictingAccount, + int errorCode, + String? errorDetails, + String? errorMessage, + }); +} From 0250da09b0961fe4e73d4a0fec9ca96b1b971517 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 14:54:49 +0100 Subject: [PATCH 106/256] add missing getter --- .../response/conflicting_account_response.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/src/web/static_interop/response/conflicting_account_response.dart b/lib/src/web/static_interop/response/conflicting_account_response.dart index ccdf6427..1c49662b 100644 --- a/lib/src/web/static_interop/response/conflicting_account_response.dart +++ b/lib/src/web/static_interop/response/conflicting_account_response.dart @@ -20,3 +20,10 @@ class ConflictingAccountResponse extends Response { String? errorMessage, }); } + +/// This extension defines the static interop definition +/// for the [ConflictingAccountResponse] class. +extension ConflictingAccountResponseExtension on ConflictingAccountResponse { + /// Get the conflicting account that is included in the response. + external ConflictingAccount? get conflictingAccount; +} From 7e61f4b454ab9138397a4cbb85ee8bcf6ebf5d49 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 15:32:40 +0100 Subject: [PATCH 107/256] export response classes in response.dart --- lib/src/web/static_interop/response/response.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index 8505f8f6..51ba3f61 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -1,5 +1,11 @@ import 'package:js/js.dart'; +// Export the response classes, +// since importing one does not include the extension getters, +// which are defined here. +export 'conflicting_account_response.dart'; +export 'login_response.dart'; + /// The static interop class for the Gigya `Response` class. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d55f070b21014bbc5a10ce4041860.html From 7bc2ae9935da7a632e57627fc204933fc3857285 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 15:48:51 +0100 Subject: [PATCH 108/256] prefix javascript conflciting account to avoid name clash with model --- .../web/static_interop/models/conflicting_account.dart | 10 +++++----- .../response/conflicting_account_response.dart | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/models/conflicting_account.dart b/lib/src/web/static_interop/models/conflicting_account.dart index 6a032e13..f17a3e44 100644 --- a/lib/src/web/static_interop/models/conflicting_account.dart +++ b/lib/src/web/static_interop/models/conflicting_account.dart @@ -4,17 +4,17 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class ConflictingAccount { - /// Construct a new [ConflictingAccount] instance. - external factory ConflictingAccount({ +class JsConflictingAccount { + /// Construct a new [JsConflictingAccount] instance. + external factory JsConflictingAccount({ String? loginID, List? loginProviders, }); } /// This extension defines the static interop definition -/// for the [ConflictingAccount] class. -extension ConflictingAccountExtension on ConflictingAccount { +/// for the [JsConflictingAccount] class. +extension ConflictingAccountExtension on JsConflictingAccount { /// The username or email address /// of the user that has a conflicting account. external String? get loginID; diff --git a/lib/src/web/static_interop/response/conflicting_account_response.dart b/lib/src/web/static_interop/response/conflicting_account_response.dart index 1c49662b..8c441dea 100644 --- a/lib/src/web/static_interop/response/conflicting_account_response.dart +++ b/lib/src/web/static_interop/response/conflicting_account_response.dart @@ -14,7 +14,7 @@ class ConflictingAccountResponse extends Response { external factory ConflictingAccountResponse({ int? apiVersion, String callId, - ConflictingAccount? conflictingAccount, + JsConflictingAccount? conflictingAccount, int errorCode, String? errorDetails, String? errorMessage, @@ -25,5 +25,5 @@ class ConflictingAccountResponse extends Response { /// for the [ConflictingAccountResponse] class. extension ConflictingAccountResponseExtension on ConflictingAccountResponse { /// Get the conflicting account that is included in the response. - external ConflictingAccount? get conflictingAccount; + external JsConflictingAccount? get conflictingAccount; } From c23c54b50b1dd936e60234be9d1c7202618e22ec Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 16:14:34 +0100 Subject: [PATCH 109/256] add stub for interruption resolver factory --- .../static_interop_interruption_resolver.dart | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 lib/src/web/static_interop_interruption_resolver.dart diff --git a/lib/src/web/static_interop_interruption_resolver.dart b/lib/src/web/static_interop_interruption_resolver.dart new file mode 100644 index 00000000..f50db675 --- /dev/null +++ b/lib/src/web/static_interop_interruption_resolver.dart @@ -0,0 +1,90 @@ +import 'dart:async'; + +import '../models/conflicting_account.dart'; +import '../models/gigya_error.dart'; +import '../services/interruption_resolver.dart'; +import 'static_interop/account.dart'; +import 'static_interop/gigya_web_sdk.dart'; +import 'static_interop/models/conflicting_account.dart'; +import 'static_interop/parameters/conflicting_account.dart'; +import 'static_interop/response/response.dart'; + +// TODO: implement linkToSite & linkToSocial in _StaticInteropLinkAccountResolver +// TODO: return `_StaticInteropLinkAccountResolver` when required +// TODO: implement setAccount in _StaticInteropPendingRegistrationResolver, using `account.setAccountInfo` endpoint + +/// This class represents an [InterruptionResolver] +/// that uses static interop for its implementation. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html#error-code-definitions-table +class StaticInteropInterruptionResolverFactory extends InterruptionResolverFactory { + /// The default constructor. + const StaticInteropInterruptionResolverFactory(); + + @override + InterruptionResolver? fromErrorCode(GigyaError exception) { + // TODO: what is the error code for the `_StaticInteropLinkAccountResolver`? + switch (exception.errorCode) { + case 206001: + return const _StaticInteropPendingRegistrationResolver(); + case 206002: + return PendingVerificationResolver(exception.registrationToken ?? ''); + default: + return null; + } + } +} + +class _StaticInteropLinkAccountResolver extends LinkAccountResolver { + _StaticInteropLinkAccountResolver({required this.registrationToken}) { + _conflictingAccounts = _getConflictingAccounts(); + } + + final String registrationToken; + + late final Future? _conflictingAccounts; + + @override + Future? get conflictingAccount => _conflictingAccounts; + + /// Get the conflicting accounts for the user. + Future _getConflictingAccounts() { + final Completer completer = Completer(); + final ConflictingAccountParameters parameters = ConflictingAccountParameters( + regToken: registrationToken, + callback: (ConflictingAccountResponse response) { + if (completer.isCompleted) { + return; + } + + if (response.errorCode == 0) { + final JsConflictingAccount? account = response.conflictingAccount; + + completer.complete( + ConflictingAccount( + loginID: account?.loginID, + loginProviders: account?.loginProviders ?? const [], + ), + ); + } else { + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + ), + ); + } + }, + ); + + gigyaWebSdk.accounts.getConflictingAccount(parameters); + + return completer.future; + } +} + +class _StaticInteropPendingRegistrationResolver extends PendingRegistrationResolver { + const _StaticInteropPendingRegistrationResolver(); +} From 9812f0df2dc6ea5a49f35b908d5c24eaaee3178b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 16:15:00 +0100 Subject: [PATCH 110/256] return resolver factory on web --- lib/src/web/gigya_flutter_plugin_web.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 07ccd544..b83d43d5 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -6,13 +6,14 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; +import '../services/interruption_resolver.dart'; import 'static_interop/account.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/parameters/basic.dart'; import 'static_interop/parameters/login.dart'; -import 'static_interop/response/login_response.dart'; import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; +import 'static_interop_interruption_resolver.dart'; import 'web_error_code.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. @@ -24,6 +25,9 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { GigyaFlutterPluginPlatform.instance = GigyaFlutterPluginWeb(); } + @override + InterruptionResolverFactory get interruptionResolverFactory => const StaticInteropInterruptionResolverFactory(); + @override Future initSdk({ required String apiDomain, From c2579ebff2a9c0e56439a6d1c1441c14b48dbe61 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 17 Mar 2023 16:18:15 +0100 Subject: [PATCH 111/256] remove TODO --- lib/src/method_channel/method_channel_interruption_resolver.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/method_channel/method_channel_interruption_resolver.dart b/lib/src/method_channel/method_channel_interruption_resolver.dart index d45b0274..8af6d252 100644 --- a/lib/src/method_channel/method_channel_interruption_resolver.dart +++ b/lib/src/method_channel/method_channel_interruption_resolver.dart @@ -17,7 +17,6 @@ class MethodChannelInterruptionResolverFactory @override InterruptionResolver? fromErrorCode(GigyaError exception) { - // TODO: create an enum for these error codes. See web_error_code.dart. switch (exception.errorCode) { case 403043: return _MethodChannelLinkAccountResolver(_channel); From 91a58fe3c1adec62d42d2527d7beb588b34d31be Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 12:57:35 +0200 Subject: [PATCH 112/256] fix import --- lib/src/web/gigya_flutter_plugin_web.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index b83d43d5..5e4932d1 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'dart:html' as html; -import 'dart:js_util'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; +import 'package:js/js.dart'; import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; From ca7cc114cf53499360607477d6977e0de00d123e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 13:06:33 +0200 Subject: [PATCH 113/256] remove unnecessary external factory constructors from response interop classes --- .../conflicting_account_response.dart | 12 +------- .../response/login_response.dart | 29 +------------------ .../web/static_interop/response/response.dart | 11 +------ 3 files changed, 3 insertions(+), 49 deletions(-) diff --git a/lib/src/web/static_interop/response/conflicting_account_response.dart b/lib/src/web/static_interop/response/conflicting_account_response.dart index 8c441dea..71fcdce3 100644 --- a/lib/src/web/static_interop/response/conflicting_account_response.dart +++ b/lib/src/web/static_interop/response/conflicting_account_response.dart @@ -9,17 +9,7 @@ import 'response.dart'; @JS() @anonymous @staticInterop -class ConflictingAccountResponse extends Response { - /// Construct a [ConflictingAccountResponse] object. - external factory ConflictingAccountResponse({ - int? apiVersion, - String callId, - JsConflictingAccount? conflictingAccount, - int errorCode, - String? errorDetails, - String? errorMessage, - }); -} +class ConflictingAccountResponse extends Response {} /// This extension defines the static interop definition /// for the [ConflictingAccountResponse] class. diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index f4e58303..31f67f31 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -12,34 +12,7 @@ import 'response.dart'; @JS() @anonymous @staticInterop -class LoginResponse extends Response { - /// Construct a [LoginResponse] object. - external factory LoginResponse({ - int? apiVersion, - String callId, - String? createdTimestamp, - Emails? emails, - int errorCode, - String? errorDetails, - String? errorMessage, - bool? isActive, - bool? isRegistered, - bool? isVerified, - String? lastLogin, - Location? lastLoginLocation, - String? lastUpdated, - String? loginProvider, - String? oldestDataUpdated, - Profile? profile, - String? registered, - SessionInfo? sessionInfo, - Object? signatureTimestamp, - String? socialProviders, - String? UID, // ignore: non_constant_identifier_names - String? UIDSignature, // ignore: non_constant_identifier_names - String? verified, - }); -} +class LoginResponse extends Response {} /// This extension defines the static interop definition /// for the [LoginResponse] class. diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index 51ba3f61..90b09d33 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -12,16 +12,7 @@ export 'login_response.dart'; @JS() @anonymous @staticInterop -class Response { - /// Construct a [Response] object. - external factory Response({ - int? apiVersion, - String callId, - int errorCode, - String? errorDetails, - String? errorMessage, - }); -} +class Response {} /// This extension defines the static interop definition /// for the [Response] class. From 376ad0b8effd31558070994d7a1e7c0f3572cbf6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 13:12:29 +0200 Subject: [PATCH 114/256] remove external factory constructors from model classes --- .../static_interop/models/certification.dart | 11 +--- .../models/conflicting_account.dart | 8 +-- .../web/static_interop/models/education.dart | 12 +---- lib/src/web/static_interop/models/emails.dart | 8 +-- .../web/static_interop/models/favorites.dart | 21 +------- lib/src/web/static_interop/models/like.dart | 10 +--- .../web/static_interop/models/location.dart | 15 +----- lib/src/web/static_interop/models/patent.dart | 13 +---- lib/src/web/static_interop/models/phone.dart | 5 +- .../web/static_interop/models/profile.dart | 53 +------------------ .../static_interop/models/publication.dart | 11 +--- .../static_interop/models/session_info.dart | 8 +-- lib/src/web/static_interop/models/skill.dart | 5 +- lib/src/web/static_interop/models/work.dart | 14 +---- 14 files changed, 16 insertions(+), 178 deletions(-) diff --git a/lib/src/web/static_interop/models/certification.dart b/lib/src/web/static_interop/models/certification.dart index be2bbedb..a93c3aa3 100644 --- a/lib/src/web/static_interop/models/certification.dart +++ b/lib/src/web/static_interop/models/certification.dart @@ -4,16 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Certification { - /// Create a new [Certification] instance. - external factory Certification({ - String? authority, - String? endDate, - String? name, - String? number, - String? startDate, - }); -} +class Certification {} /// This extension defines the static interop definition /// for the [Certification] class. diff --git a/lib/src/web/static_interop/models/conflicting_account.dart b/lib/src/web/static_interop/models/conflicting_account.dart index f17a3e44..92929c5d 100644 --- a/lib/src/web/static_interop/models/conflicting_account.dart +++ b/lib/src/web/static_interop/models/conflicting_account.dart @@ -4,13 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class JsConflictingAccount { - /// Construct a new [JsConflictingAccount] instance. - external factory JsConflictingAccount({ - String? loginID, - List? loginProviders, - }); -} +class JsConflictingAccount {} /// This extension defines the static interop definition /// for the [JsConflictingAccount] class. diff --git a/lib/src/web/static_interop/models/education.dart b/lib/src/web/static_interop/models/education.dart index 98c14687..acd799b8 100644 --- a/lib/src/web/static_interop/models/education.dart +++ b/lib/src/web/static_interop/models/education.dart @@ -4,17 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Education { - /// Construct a new [Education] instance. - external factory Education({ - String? degree, - String? endYear, - String? fieldOfStudy, - String? school, - String? schoolType, - String? startYear, - }); -} +class Education {} /// This extension defines the static interop definition /// for the [Education] class. diff --git a/lib/src/web/static_interop/models/emails.dart b/lib/src/web/static_interop/models/emails.dart index e2124755..32ca819f 100644 --- a/lib/src/web/static_interop/models/emails.dart +++ b/lib/src/web/static_interop/models/emails.dart @@ -4,13 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Emails { - /// Create a new [Emails] instance. - external factory Emails({ - List unverified, - List verified, - }); -} +class Emails {} /// This extension defines the static interop definition /// for the [Emails] class. diff --git a/lib/src/web/static_interop/models/favorites.dart b/lib/src/web/static_interop/models/favorites.dart index 8f5045dc..8d5c070f 100644 --- a/lib/src/web/static_interop/models/favorites.dart +++ b/lib/src/web/static_interop/models/favorites.dart @@ -4,14 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Favorite { - /// Construct a new [Favorite] instance. - external factory Favorite({ - String? category, - String? id, - String? name, - }); -} +class Favorite {} /// This extension defines the static interop definition /// for the [Favorite] class. @@ -39,17 +32,7 @@ extension FavoriteExtension on Favorite { @JS() @anonymous @staticInterop -class Favorites { - /// Construct a new [Favorites] instance. - external factory Favorites({ - List activities, - List books, - List interests, - List movies, - List music, - List television, - }); -} +class Favorites {} /// This extension defines the static interop definition /// for the [Favorites] class. diff --git a/lib/src/web/static_interop/models/like.dart b/lib/src/web/static_interop/models/like.dart index aaa11844..a11d15dc 100644 --- a/lib/src/web/static_interop/models/like.dart +++ b/lib/src/web/static_interop/models/like.dart @@ -4,15 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Like { - /// Create a new [Like] instance. - external factory Like({ - String? category, - String? id, - String? name, - String? time, - }); -} +class Like {} /// This extension defines the static interop definition /// for the [Like] class. diff --git a/lib/src/web/static_interop/models/location.dart b/lib/src/web/static_interop/models/location.dart index f3b807ab..b78bb7b7 100644 --- a/lib/src/web/static_interop/models/location.dart +++ b/lib/src/web/static_interop/models/location.dart @@ -4,10 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Coordinates { - /// Construct a new [Coordinates] instance. - external factory Coordinates({String? lat, String? lon}); -} +class Coordinates {} /// This extension defines the static interop definition /// for the [Coordinates] class. @@ -23,15 +20,7 @@ extension CoordinatesExtension on Coordinates { @JS() @anonymous @staticInterop -class Location { - /// Construct a new [Location] instance. - external factory Location({ - String? city, - Coordinates? coordinates, - String? country, - String? state, - }); -} +class Location {} /// This extension defines the static interop definition /// for the [Location] class. diff --git a/lib/src/web/static_interop/models/patent.dart b/lib/src/web/static_interop/models/patent.dart index fcba1396..3b06add6 100644 --- a/lib/src/web/static_interop/models/patent.dart +++ b/lib/src/web/static_interop/models/patent.dart @@ -4,18 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Patent { - /// Construct a new [Patent] instance. - external factory Patent({ - String? date, - String? number, - String? office, - String? status, - String? summary, - String? title, - String? url, - }); -} +class Patent {} /// This extension defines the static interop definition /// for the [Patent] class. diff --git a/lib/src/web/static_interop/models/phone.dart b/lib/src/web/static_interop/models/phone.dart index 7423af2f..a493c63b 100644 --- a/lib/src/web/static_interop/models/phone.dart +++ b/lib/src/web/static_interop/models/phone.dart @@ -4,10 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Phone { - /// Construct a new [Phone] instance. - external factory Phone({String? number, String? type}); -} +class Phone {} /// This extension defines the static interop definition /// for the [Phone] class. diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 4e68a401..96dbe063 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -15,58 +15,7 @@ import 'work.dart'; @JS() @anonymous @staticInterop -class Profile { - /// Construct a new [Profile] instance. - external factory Profile({ - String? activities, - String? address, - int? age, - String? bio, - int? birthDay, - int? birthMonth, - int birthYear, - List certifications, - String? city, - String? country, - List education, - String? educationLevel, - String? email, - Favorites favorites, - String? firstName, - int? followers, - int? following, - String? gender, - String? hometown, - String? honors, - String? industry, - String? interests, - String? languages, - String? lastName, - List likes, - String? locale, - String? name, - String? nickname, - List patents, - List phones, - String? photoUrl, - String? politicalView, - String? professionalHeadline, - String? profileUrl, - String? proxyEmail, - List publications, - String? relationshipStatus, - String? religion, - List skills, - String? specialities, - String? state, - String? thumbnailUrl, - String? timezone, - String? username, - String? verified, - List work, - String? zip, - }); -} +class Profile {} /// This extension defines the static interop definition /// for the [Profile] class. diff --git a/lib/src/web/static_interop/models/publication.dart b/lib/src/web/static_interop/models/publication.dart index f938e221..d46f38d6 100644 --- a/lib/src/web/static_interop/models/publication.dart +++ b/lib/src/web/static_interop/models/publication.dart @@ -4,16 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Publication { - /// Construct a new [Publication] instance. - external factory Publication({ - String? date, - String? publisher, - String? summary, - String? title, - String? url, - }); -} +class Publication {} /// This extension defines the static interop definition /// for the [Publication] class. diff --git a/lib/src/web/static_interop/models/session_info.dart b/lib/src/web/static_interop/models/session_info.dart index ddff67a7..b7a06d5e 100644 --- a/lib/src/web/static_interop/models/session_info.dart +++ b/lib/src/web/static_interop/models/session_info.dart @@ -4,13 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class SessionInfo { - /// Construct a new [SessionInfo] instance. - external factory SessionInfo({ - String? cookieName, - String? cookieValue, - }); -} +class SessionInfo {} /// This extension defines the static interop definition /// for the [SessionInfo] class. diff --git a/lib/src/web/static_interop/models/skill.dart b/lib/src/web/static_interop/models/skill.dart index 795e76f2..28cda429 100644 --- a/lib/src/web/static_interop/models/skill.dart +++ b/lib/src/web/static_interop/models/skill.dart @@ -4,10 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Skill { - /// Construct a new [Skill] instance. - external factory Skill({String? level, String? skill, int? years}); -} +class Skill {} /// This extension defines the static interop definition /// for the [Skill] class. diff --git a/lib/src/web/static_interop/models/work.dart b/lib/src/web/static_interop/models/work.dart index 5f0b26b1..76a5f5a9 100644 --- a/lib/src/web/static_interop/models/work.dart +++ b/lib/src/web/static_interop/models/work.dart @@ -4,19 +4,7 @@ import 'package:js/js.dart'; @JS() @anonymous @staticInterop -class Work { - /// Construct a new [Work] instance. - external factory Work({ - String? company, - int? companySize, - String? companyID, - String? endDate, - String? industry, - bool? isCurrent, - String? startDate, - String? title, - }); -} +class Work {} /// This extension defines the static interop definition /// for the [Work] class. From 50889307a400f19f855831c56c2931954ac5d627 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 13:33:11 +0200 Subject: [PATCH 115/256] fix interop for conflicting account login provider list type --- lib/src/web/static_interop/models/conflicting_account.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/models/conflicting_account.dart b/lib/src/web/static_interop/models/conflicting_account.dart index 92929c5d..65e919a0 100644 --- a/lib/src/web/static_interop/models/conflicting_account.dart +++ b/lib/src/web/static_interop/models/conflicting_account.dart @@ -13,6 +13,9 @@ extension ConflictingAccountExtension on JsConflictingAccount { /// of the user that has a conflicting account. external String? get loginID; + @JS('loginProviders') + external List? get _loginProviders; + /// The login providers for the that has a conflicting account. - external List? get loginProviders; + List? get loginProviders => _loginProviders?.cast(); } From 24dd17d2b57e239b2cce1c5301131b089dcf710c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 13:35:16 +0200 Subject: [PATCH 116/256] fix interop for emails list type --- lib/src/web/static_interop/models/emails.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/models/emails.dart b/lib/src/web/static_interop/models/emails.dart index 32ca819f..d746e4af 100644 --- a/lib/src/web/static_interop/models/emails.dart +++ b/lib/src/web/static_interop/models/emails.dart @@ -9,9 +9,15 @@ class Emails {} /// This extension defines the static interop definition /// for the [Emails] class. extension EmailsExtension on Emails { + @JS('unverified') + external List get _unverified; + + @JS('verified') + external List get _verified; + /// The list of unverified email addresses. - external List get unverified; + List get unverified => _unverified.cast(); /// The list of verified email addresses. - external List get verified; + List get verified => _verified.cast(); } From 7ab9432e4e6d360f99390981c08a3a2e89cb3365 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 13:37:26 +0200 Subject: [PATCH 117/256] fix interop for favorites list type --- .../web/static_interop/models/favorites.dart | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/src/web/static_interop/models/favorites.dart b/lib/src/web/static_interop/models/favorites.dart index 8d5c070f..a9eb7127 100644 --- a/lib/src/web/static_interop/models/favorites.dart +++ b/lib/src/web/static_interop/models/favorites.dart @@ -37,23 +37,41 @@ class Favorites {} /// This extension defines the static interop definition /// for the [Favorites] class. extension FavoritesExtension on Favorites { + @JS('activities') + external List get _activities; + + @JS('books') + external List get _books; + + @JS('interests') + external List get _interests; + + @JS('movies') + external List get _movies; + + @JS('music') + external List get _music; + + @JS('television') + external List get _television; + /// The user's favorite activities. - external List get activities; + List get activities => _activities.cast(); /// The user's favorite books. - external List get books; + List get books => _books.cast(); /// The user's interests. - external List get interests; + List get interests => _interests.cast(); /// The user's favorite movies. - external List get movies; + List get movies => _movies.cast(); /// The user's favorite music. - external List get music; + List get music => _music.cast(); /// The user's favorite television programmes. - external List get television; + List get television => _television.cast(); /// Convert this favorites object to a [Map]. Map toMap() { From 0ad65a09b03a66533f0e7e9769f1b6bfef8190f8 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 13:54:54 +0200 Subject: [PATCH 118/256] fix list types in interop definition of Profile --- .../web/static_interop/models/profile.dart | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 96dbe063..64fa14e4 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -41,8 +41,11 @@ extension ProfileExtension on Profile { /// The person's birth year. external int? get birthYear; + @JS('certifications') + external List get _certifications; + /// The person's certifications. - external List get certifications; + List get certifications => _certifications.cast(); /// The city in which the person resides. external String? get city; @@ -50,8 +53,11 @@ extension ProfileExtension on Profile { /// The country in which the person resides. external String? get country; + @JS('education') + external List get _education; + /// The different educations of the person. - external List get education; + List get education => _education.cast(); /// The education level of the person. external String? get educationLevel; @@ -92,8 +98,11 @@ extension ProfileExtension on Profile { /// The person's last name. external String? get lastName; + @JS('likes') + external List get _likes; + /// The person's likes. - external List get likes; + List get likes => _likes.cast(); /// The language locale of the person's primary language. external String? get locale; @@ -104,11 +113,17 @@ extension ProfileExtension on Profile { /// The person's nickname. external String? get nickname; + @JS('patents') + external List get _patents; + /// The different patents that this person owns. - external List get patents; + List get patents => _patents.cast(); + + @JS('phones') + external List get _phones; /// The different phone numbers belonging to this person. - external List get phones; + List get phones => _phones.cast(); /// The url to the person's photo. external String? get photoUrl; @@ -125,8 +140,11 @@ extension ProfileExtension on Profile { /// The person's proxy email address. external String? get proxyEmail; + @JS('publications') + external List get _publications; + /// The list of publications belonging to this person. - external List get publications; + List get publications => _publications.cast(); /// The person's relationship status. external String? get relationshipStatus; @@ -134,8 +152,11 @@ extension ProfileExtension on Profile { /// The person's religion. external String? get religion; + @JS('skills') + external List get _skills; + /// The different skills of the person. - external List get skills; + List get skills => _skills.cast(); /// The person's specialities. external String? get specialities; @@ -155,8 +176,11 @@ extension ProfileExtension on Profile { /// The verified status of the person. external String? get verified; + @JS('work') + external List get _work; + /// The person's career, divided into the different employments. - external List get work; + List get work => _work.cast(); /// The ZIP code of the person's address. external String? get zip; From 898025547188930c394f1af75c1d85191faeed3e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 14:47:49 +0200 Subject: [PATCH 119/256] add additional parameters to the login method for web --- lib/src/web/gigya_flutter_plugin_web.dart | 6 ++++++ lib/src/web/static_interop/parameters/login.dart | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 5e4932d1..b446620f 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -110,6 +110,12 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { final LoginParameters loginParameters = LoginParameters( loginID: loginId, password: password, + captchaToken: parameters['captchaToken'] as String?, + include: parameters['include'] as String?, + loginMode: parameters['loginMode'] as String?, + redirectURL: parameters['redirectURL'] as String?, + regToken: parameters['regToken'] as String?, + sessionExpiration: parameters['sessionExpiration'] as int?, callback: allowInterop((LoginResponse response) { if (completer.isCompleted) { return; diff --git a/lib/src/web/static_interop/parameters/login.dart b/lib/src/web/static_interop/parameters/login.dart index 21cae80e..f242c018 100644 --- a/lib/src/web/static_interop/parameters/login.dart +++ b/lib/src/web/static_interop/parameters/login.dart @@ -9,8 +9,14 @@ import '../response/login_response.dart'; class LoginParameters { /// Create a new [LoginParameters] instance. external factory LoginParameters({ + void Function(LoginResponse response) callback, + String? captchaToken, + String? include, String loginID, + String? loginMode, String password, - void Function(LoginResponse response) callback, + String? redirectURL, + String? regToken, + int? sessionExpiration, }); } From 028bffa38dcbb96dc5419c78875b03c0ad6c3784 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 12 Apr 2023 10:48:39 +0200 Subject: [PATCH 120/256] add regToken, regSource and isNewUser to web login response --- .../web/static_interop/response/login_response.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 31f67f31..219fdb87 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -26,6 +26,9 @@ extension LoginResponseExtension on LoginResponse { /// Whether the user is active. external bool? get isActive; + /// Whether the user that is logging in is a new user. + external bool? get isNewUser; + /// Whether the user is registered. external bool? get isRegistered; @@ -54,6 +57,12 @@ extension LoginResponseExtension on LoginResponse { /// The timestamp when the user was registered. external String? get registered; + /// The source of the registration. + external String? get regSource; + + /// The registration token. + external String? get regToken; + /// The session info for the user's session. external SessionInfo? get sessionInfo; @@ -93,6 +102,7 @@ extension LoginResponseExtension on LoginResponse { 'verified': emails!.verified, }, 'isActive': isActive, + 'isNewUser': isNewUser, 'isRegistered': isRegistered, 'isVerified': isVerified, 'lastLogin': lastLogin, @@ -101,6 +111,8 @@ extension LoginResponseExtension on LoginResponse { 'oldestDataUpdated': oldestDataUpdated, if (profileAsMap != null) 'profile': profileAsMap, 'registered': registered, + 'regSource': regSource, + 'regToken': regToken, if (sessionInfo != null) 'sessionInfo': { 'cookieName': sessionInfo!.cookieName, From 6a286f54286edac3deee497fa8d507ac383f19ea Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 12 Apr 2023 10:50:26 +0200 Subject: [PATCH 121/256] add TODO --- lib/src/web/static_interop/response/login_response.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 219fdb87..0791132b 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -14,6 +14,8 @@ import 'response.dart'; @staticInterop class LoginResponse extends Response {} +// TODO: preferences, subscriptions should be in the login response + /// This extension defines the static interop definition /// for the [LoginResponse] class. extension LoginResponseExtension on LoginResponse { From cfc164152a6d94604fb613d11fbc0963b3f311b9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 12 Apr 2023 14:49:25 +0200 Subject: [PATCH 122/256] fix typo: createdTimestamp should be the created field --- lib/src/web/static_interop/response/login_response.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 0791132b..4346defd 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -20,7 +20,7 @@ class LoginResponse extends Response {} /// for the [LoginResponse] class. extension LoginResponseExtension on LoginResponse { /// The timestamp of the creation of the user. - external String? get createdTimestamp; + external String? get created; /// The verified and unverified email addresses of the user. external Emails? get emails; @@ -97,7 +97,7 @@ extension LoginResponseExtension on LoginResponse { } return { - 'createdTimestamp': createdTimestamp, + 'created': created, if (emails != null) 'emails': { 'unverified': emails!.unverified, From fc59d48c0f7e7cc04fd19577bf4c111d80c4a74e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 14:47:00 +0200 Subject: [PATCH 123/256] fix profile attribute names in static interop definition --- lib/src/web/static_interop/models/profile.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 64fa14e4..83c9e169 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -72,10 +72,10 @@ extension ProfileExtension on Profile { external String? get firstName; /// The amount of followers of this person. - external int? get followers; + external int? get followersCount; /// The amount of people that this person is following. - external int? get following; + external int? get followingCount; /// The person's gender. external String? get gender; @@ -126,7 +126,7 @@ extension ProfileExtension on Profile { List get phones => _phones.cast(); /// The url to the person's photo. - external String? get photoUrl; + external String? get photoURL; /// The person's political view. external String? get politicalView; @@ -203,8 +203,8 @@ extension ProfileExtension on Profile { 'email': email, 'favorites': favorites.toMap(), 'firstName': firstName, - 'followersCount': followers, - 'followingCount': following, + 'followersCount': followersCount, + 'followingCount': followingCount, 'gender': gender, 'hometown': hometown, 'honors': honors, @@ -218,7 +218,7 @@ extension ProfileExtension on Profile { 'nickname': nickname, 'patents': patents.map((Patent p) => p.toMap()).toList(), 'phones': phones.map((Phone p) => p.toMap()).toList(), - 'photoURL': photoUrl, + 'photoURL': photoURL, 'politicalView': politicalView, 'professionalHeadline': professionalHeadline, 'proxyEmail': proxyEmail, From 87b6e4ec7e1b095d0be5ec7f13b8be828c0cd81a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 15:09:57 +0200 Subject: [PATCH 124/256] add isConnected, isSiteUID, isSiteUser, loginProvider, loginProviderUID, providers to static interop definition of profile --- .../web/static_interop/models/profile.dart | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 83c9e169..436ea236 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -92,6 +92,16 @@ extension ProfileExtension on Profile { /// The person's interests. external String? get interests; + /// Indicates whether the user is connected to any available provider. + external bool? get isConnected; + + /// This field indicates if the UID is a site UID (provided by your site) + /// or an ID generated by SAP Customer Data Cloud. + external bool? get isSiteUID; + + /// Indicates whether the user is a user of the site. + external bool? get isSiteUser; + /// The different languages that the person is proficient in. external String? get languages; @@ -107,6 +117,13 @@ extension ProfileExtension on Profile { /// The language locale of the person's primary language. external String? get locale; + /// The name of the provider that the user used in order to log in. + /// If the user logged in using your site login mechanism, then `site` is used. + external String? get loginProvider; + + /// The user's id from the given [loginProvider]. + external String? get loginProviderUID; + /// The person's full name. external String? get name; @@ -137,6 +154,12 @@ extension ProfileExtension on Profile { /// The url to the person's profile page. external String? get profileUrl; + @JS('providers') + external List get _providers; + + /// The names of the providers to which the user is connected/logged in. + List get providers => _providers.cast(); + /// The person's proxy email address. external String? get proxyEmail; @@ -210,10 +233,15 @@ extension ProfileExtension on Profile { 'honors': honors, 'industry': industry, 'interests': interests, + 'isConnected': isConnected, + 'isSiteUID': isSiteUID, + 'isSiteUser': isSiteUser, 'languages': languages, 'lastName': lastName, 'likes': likes.map((Like l) => l.toMap()).toList(), 'locale': locale, + 'loginProvider': loginProvider, + 'loginProviderUID': loginProviderUID, 'name': name, 'nickname': nickname, 'patents': patents.map((Patent p) => p.toMap()).toList(), @@ -221,6 +249,7 @@ extension ProfileExtension on Profile { 'photoURL': photoURL, 'politicalView': politicalView, 'professionalHeadline': professionalHeadline, + 'providers': providers, 'proxyEmail': proxyEmail, 'publications': publications.map((Publication p) => p.toMap()).toList(), 'relationshipStatus': relationshipStatus, From 4ab9fb725942b12279e7b386caaf694fcf4d9a8a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 15:50:58 +0200 Subject: [PATCH 125/256] remove isSiteUID; fix profile url in static interop definition --- lib/src/web/static_interop/models/profile.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 436ea236..86e52112 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -95,10 +95,6 @@ extension ProfileExtension on Profile { /// Indicates whether the user is connected to any available provider. external bool? get isConnected; - /// This field indicates if the UID is a site UID (provided by your site) - /// or an ID generated by SAP Customer Data Cloud. - external bool? get isSiteUID; - /// Indicates whether the user is a user of the site. external bool? get isSiteUser; @@ -152,7 +148,7 @@ extension ProfileExtension on Profile { external String? get professionalHeadline; /// The url to the person's profile page. - external String? get profileUrl; + external String? get profileURL; @JS('providers') external List get _providers; @@ -234,7 +230,6 @@ extension ProfileExtension on Profile { 'industry': industry, 'interests': interests, 'isConnected': isConnected, - 'isSiteUID': isSiteUID, 'isSiteUser': isSiteUser, 'languages': languages, 'lastName': lastName, @@ -249,6 +244,7 @@ extension ProfileExtension on Profile { 'photoURL': photoURL, 'politicalView': politicalView, 'professionalHeadline': professionalHeadline, + 'profileURL': profileURL, 'providers': providers, 'proxyEmail': proxyEmail, 'publications': publications.map((Publication p) => p.toMap()).toList(), From d358216042d741a1cfeaba58df1f766f60c3aa59 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 17:00:58 +0200 Subject: [PATCH 126/256] fix thumbnail url in static interop binding of profile object --- lib/src/web/static_interop/models/profile.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 86e52112..85e45999 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -184,7 +184,7 @@ extension ProfileExtension on Profile { external String? get state; /// The url to the person's thumbnail image. - external String? get thumbnailUrl; + external String? get thumbnailURL; /// The person's timezone. external String? get timezone; @@ -253,7 +253,7 @@ extension ProfileExtension on Profile { 'skills': skills.map((Skill s) => s.toMap()).toList(), 'specialities': specialities, 'state': state, - 'thumbnailURL': thumbnailUrl, + 'thumbnailURL': thumbnailURL, 'timezone': timezone, 'username': username, 'verified': verified, From 70304fe222a75fd960b735e3bfff9a64cf55721e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 24 Apr 2023 14:07:31 +0200 Subject: [PATCH 127/256] await onGigyaService before calling logout(); fail if onGigyaServiceReady takes too long to be called --- lib/src/web/gigya_flutter_plugin_web.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index b446620f..f4e42902 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -57,11 +57,17 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { await script.onLoad.first; + // If `onGigyaServiceReady` takes too long to be called + // (for instance if the network is unavailable, or Gigya does not initialize properly), + // exit with a timeout error. + await onGigyaServiceReadyCompleter.future.timeout( + const Duration(seconds: 5), + onTimeout: () => throw const GigyaTimeoutError(), + ); + if (forceLogout) { await logout(); } - - return onGigyaServiceReadyCompleter.future; } @override From 9f602394d355a7b5fdd8b36347839469df83b001 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 5 May 2023 13:20:02 +0200 Subject: [PATCH 128/256] abort logout on web if not logged in --- lib/src/web/gigya_flutter_plugin_web.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index f4e42902..04861890 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -148,7 +148,11 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { } @override - Future logout() { + Future logout() async { + if (!await isLoggedIn()) { + return; + } + final Completer completer = Completer(); final BasicParameters parameters = BasicParameters( callback: allowInterop((Response response) { From 4ec595cda10f004334f5a70ef6fdcd4e6a9bb02f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 11 May 2023 16:21:21 +0200 Subject: [PATCH 129/256] fix hot reload on the web --- lib/src/web/gigya_flutter_plugin_web.dart | 33 ++++++++++++------- lib/src/web/static_interop/gigya_web_sdk.dart | 3 ++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 04861890..5984bfc8 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:html' as html; +import 'dart:js_interop'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:js/js.dart'; @@ -45,17 +46,27 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { } }); - final html.ScriptElement script = html.ScriptElement() - ..async = true - ..defer = false - ..type = 'text/javascript' - ..lang = 'javascript' - ..crossOrigin = 'anonymous' - ..src = 'https://cdns.$apiDomain/js/gigya.js?apikey=$apiKey'; - - html.document.head!.append(script); - - await script.onLoad.first; + // If the Gigya SDK is ready beforehand, complete directly. + // This is the case when doing a Hot Reload, where the application starts from scratch, + // even though the Gigya SDK script is still attached to the DOM and ready. + // See https://docs.flutter.dev/tools/hot-reload#how-to-perform-a-hot-reload + if (gigyaWebSdk.isDefinedAndNotNull && gigyaWebSdk.isReady) { + if (!onGigyaServiceReadyCompleter.isCompleted) { + onGigyaServiceReadyCompleter.complete(); + } + } else { + final html.ScriptElement script = html.ScriptElement() + ..async = true + ..defer = false + ..type = 'text/javascript' + ..lang = 'javascript' + ..crossOrigin = 'anonymous' + ..src = 'https://cdns.$apiDomain/js/gigya.js?apikey=$apiKey'; + + html.document.head!.append(script); + + await script.onLoad.first; + } // If `onGigyaServiceReady` takes too long to be called // (for instance if the network is unavailable, or Gigya does not initialize properly), diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index d86116f4..289c74c4 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -18,4 +18,7 @@ class GigyaWebSdk {} extension GigyaWebSdkExtension on GigyaWebSdk { /// Get the accounts namespace in the Gigya Web SDK. external Accounts get accounts; + + /// Whether the Gigya Web SDK is ready. + external bool get isReady; } From ec79205cfc45fd38218fd62ab095e0db324ae549 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 11 May 2023 16:52:53 +0200 Subject: [PATCH 130/256] use nullable lists in interop types --- lib/src/web/static_interop/models/emails.dart | 8 ++-- .../web/static_interop/models/favorites.dart | 26 ++++++------ .../web/static_interop/models/profile.dart | 42 +++++++++++-------- 3 files changed, 42 insertions(+), 34 deletions(-) diff --git a/lib/src/web/static_interop/models/emails.dart b/lib/src/web/static_interop/models/emails.dart index d746e4af..e8953f9c 100644 --- a/lib/src/web/static_interop/models/emails.dart +++ b/lib/src/web/static_interop/models/emails.dart @@ -10,14 +10,14 @@ class Emails {} /// for the [Emails] class. extension EmailsExtension on Emails { @JS('unverified') - external List get _unverified; + external List? get _unverified; @JS('verified') - external List get _verified; + external List? get _verified; /// The list of unverified email addresses. - List get unverified => _unverified.cast(); + List get unverified => _unverified?.cast() ?? []; /// The list of verified email addresses. - List get verified => _verified.cast(); + List get verified => _verified?.cast() ?? []; } diff --git a/lib/src/web/static_interop/models/favorites.dart b/lib/src/web/static_interop/models/favorites.dart index a9eb7127..f1f18cbb 100644 --- a/lib/src/web/static_interop/models/favorites.dart +++ b/lib/src/web/static_interop/models/favorites.dart @@ -38,40 +38,42 @@ class Favorites {} /// for the [Favorites] class. extension FavoritesExtension on Favorites { @JS('activities') - external List get _activities; + external List? get _activities; @JS('books') - external List get _books; + external List? get _books; @JS('interests') - external List get _interests; + external List? get _interests; @JS('movies') - external List get _movies; + external List? get _movies; @JS('music') - external List get _music; + external List? get _music; @JS('television') - external List get _television; + external List? get _television; /// The user's favorite activities. - List get activities => _activities.cast(); + List get activities { + return _activities?.cast() ?? []; + } /// The user's favorite books. - List get books => _books.cast(); + List get books => _books?.cast() ?? []; /// The user's interests. - List get interests => _interests.cast(); + List get interests => _interests?.cast() ?? []; /// The user's favorite movies. - List get movies => _movies.cast(); + List get movies => _movies?.cast() ?? []; /// The user's favorite music. - List get music => _music.cast(); + List get music => _music?.cast() ?? []; /// The user's favorite television programmes. - List get television => _television.cast(); + List get television => _television?.cast() ?? []; /// Convert this favorites object to a [Map]. Map toMap() { diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 85e45999..909956ee 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -42,10 +42,12 @@ extension ProfileExtension on Profile { external int? get birthYear; @JS('certifications') - external List get _certifications; + external List? get _certifications; /// The person's certifications. - List get certifications => _certifications.cast(); + List get certifications { + return _certifications?.cast() ?? []; + } /// The city in which the person resides. external String? get city; @@ -54,10 +56,12 @@ extension ProfileExtension on Profile { external String? get country; @JS('education') - external List get _education; + external List? get _education; /// The different educations of the person. - List get education => _education.cast(); + List get education { + return _education?.cast() ?? []; + } /// The education level of the person. external String? get educationLevel; @@ -105,10 +109,10 @@ extension ProfileExtension on Profile { external String? get lastName; @JS('likes') - external List get _likes; + external List? get _likes; /// The person's likes. - List get likes => _likes.cast(); + List get likes => _likes?.cast() ?? []; /// The language locale of the person's primary language. external String? get locale; @@ -127,16 +131,16 @@ extension ProfileExtension on Profile { external String? get nickname; @JS('patents') - external List get _patents; + external List? get _patents; /// The different patents that this person owns. - List get patents => _patents.cast(); + List get patents => _patents?.cast() ?? []; @JS('phones') - external List get _phones; + external List? get _phones; /// The different phone numbers belonging to this person. - List get phones => _phones.cast(); + List get phones => _phones?.cast() ?? []; /// The url to the person's photo. external String? get photoURL; @@ -151,19 +155,21 @@ extension ProfileExtension on Profile { external String? get profileURL; @JS('providers') - external List get _providers; + external List? get _providers; /// The names of the providers to which the user is connected/logged in. - List get providers => _providers.cast(); + List get providers => _providers?.cast() ?? []; /// The person's proxy email address. external String? get proxyEmail; @JS('publications') - external List get _publications; + external List? get _publications; /// The list of publications belonging to this person. - List get publications => _publications.cast(); + List get publications { + return _publications?.cast() ?? []; + } /// The person's relationship status. external String? get relationshipStatus; @@ -172,10 +178,10 @@ extension ProfileExtension on Profile { external String? get religion; @JS('skills') - external List get _skills; + external List? get _skills; /// The different skills of the person. - List get skills => _skills.cast(); + List get skills => _skills?.cast() ?? []; /// The person's specialities. external String? get specialities; @@ -196,10 +202,10 @@ extension ProfileExtension on Profile { external String? get verified; @JS('work') - external List get _work; + external List? get _work; /// The person's career, divided into the different employments. - List get work => _work.cast(); + List get work => _work?.cast() ?? []; /// The ZIP code of the person's address. external String? get zip; From 1aeb3f81036921ae324dac90d21cd9f4449fd4d9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 11 May 2023 16:56:17 +0200 Subject: [PATCH 131/256] fix null favorites --- lib/src/web/static_interop/models/profile.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 909956ee..446b4ccf 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -70,7 +70,7 @@ extension ProfileExtension on Profile { external String? get email; /// The person's favorites. - external Favorites get favorites; + external Favorites? get favorites; /// The person's first name. external String? get firstName; @@ -226,7 +226,7 @@ extension ProfileExtension on Profile { 'education': education.map((Education e) => e.toMap()).toList(), 'educationLevel': educationLevel, 'email': email, - 'favorites': favorites.toMap(), + 'favorites': favorites?.toMap(), 'firstName': firstName, 'followersCount': followersCount, 'followingCount': followingCount, From 91b627a586bb4f85e4dfae13c79b2f274716b3bf Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 11 May 2023 17:00:23 +0200 Subject: [PATCH 132/256] fix session info null value --- lib/src/web/static_interop/models/session_info.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/models/session_info.dart b/lib/src/web/static_interop/models/session_info.dart index b7a06d5e..22b8ab8e 100644 --- a/lib/src/web/static_interop/models/session_info.dart +++ b/lib/src/web/static_interop/models/session_info.dart @@ -13,5 +13,5 @@ extension SessionInfoExtension on SessionInfo { external String? get cookieName; /// The value of the session cookie. - external String get cookieValue; + external String? get cookieValue; } From 30fb424de5e320e4f1f4f8cede589381efe19d36 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 1 Jun 2023 13:53:47 +0200 Subject: [PATCH 133/256] fix error details on the web --- example/pubspec.lock | 126 ++++++++++++++++-- lib/src/web/gigya_flutter_plugin_web.dart | 6 +- .../web/static_interop/response/response.dart | 7 + .../static_interop_interruption_resolver.dart | 2 +- 4 files changed, 126 insertions(+), 15 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 07ba346e..768b558e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,6 +1,30 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a + url: "https://pub.dev" + source: hosted + version: "61.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 + url: "https://pub.dev" + source: hosted + version: "5.13.0" + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: @@ -41,6 +65,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" fake_async: dependency: transitive description: @@ -49,6 +89,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" flutter: dependency: "direct main" description: flutter @@ -82,10 +130,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -103,6 +151,14 @@ packages: relative: true source: path version: "1.0.1" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" google_sign_in: dependency: "direct main" description: @@ -115,26 +171,26 @@ packages: dependency: transitive description: name: google_sign_in_android - sha256: "2a8b90b766ce00b03e7543f4ffeec97b6eb51fb6c3f31ce2a364bd1f1b9dd7fc" + sha256: "6031f59074a337fdd81be821aba84cee3a41338c6e958499a5cd34d3e1db80ef" url: "https://pub.dev" source: hosted - version: "6.1.14" + version: "6.1.20" google_sign_in_ios: dependency: transitive description: name: google_sign_in_ios - sha256: "6ec0e13a4c5c646471b9f6a25ceb3ae76d339889d4c0f79b729bf0714215a63e" + sha256: "974944859f9cd40eb8a15b3fe8efb2d47fb7e99438f763f61a1ccd28d74ff4ce" url: "https://pub.dev" source: hosted - version: "5.6.2" + version: "5.6.4" google_sign_in_platform_interface: dependency: transitive description: name: google_sign_in_platform_interface - sha256: e69553c0fc6a76216e9d06a8c3767e291ad9be42171f879aab7ab708569d4393 + sha256: "35ceee5f0eadc1c07b0b4af7553246e315c901facbb7d3dadf734ba2693ceec4" url: "https://pub.dev" source: hosted - version: "2.4.1" + version: "2.4.2" google_sign_in_web: dependency: transitive description: @@ -155,10 +211,10 @@ packages: dependency: transitive description: name: lints - sha256: "6b0206b0bf4f04961fc5438198ccb3a885685cd67d4d4a32cc20ad7f8adbe015" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" matcher: dependency: transitive description: @@ -183,6 +239,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -191,11 +255,27 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" + pigeon: + dependency: transitive + description: + name: pigeon + sha256: "5a79fd0b10423f6b5705525e32015597f861c31220b522a67d1e6b580da96719" + url: "https://pub.dev" + source: hosted + version: "11.0.1" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + url: "https://pub.dev" + source: hosted + version: "2.1.6" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted version: "2.1.4" @@ -260,6 +340,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" vector_math: dependency: transitive description: @@ -268,6 +356,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" web: dependency: transitive description: @@ -276,6 +372,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.1-beta" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" sdks: dart: ">=3.2.0-157.0.dev <4.0.0" flutter: ">=3.10.0" diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 5984bfc8..d7dbd893 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -102,8 +102,8 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { GigyaError( apiVersion: response.apiVersion, callId: response.callId, + details: response.details, errorCode: response.errorCode, - errorDetails: response.errorDetails, ), ); break; @@ -145,8 +145,8 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { GigyaError( apiVersion: response.apiVersion, callId: response.callId, + details: response.details, errorCode: response.errorCode, - errorDetails: response.errorDetails, ), ); } @@ -178,8 +178,8 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { GigyaError( apiVersion: response.apiVersion, callId: response.callId, + details: response.details, errorCode: response.errorCode, - errorDetails: response.errorDetails, ), ); } diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index 90b09d33..ab535be7 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -23,6 +23,13 @@ extension ResponseExtension on Response { /// The unique identifier of the transaction. external String get callId; + /// Get the error details. + Map get details { + return { + 'errorDetails': errorDetails, + }; + } + /// The response error code. /// /// A value of zero indicates success. diff --git a/lib/src/web/static_interop_interruption_resolver.dart b/lib/src/web/static_interop_interruption_resolver.dart index f50db675..5873758b 100644 --- a/lib/src/web/static_interop_interruption_resolver.dart +++ b/lib/src/web/static_interop_interruption_resolver.dart @@ -71,8 +71,8 @@ class _StaticInteropLinkAccountResolver extends LinkAccountResolver { GigyaError( apiVersion: response.apiVersion, callId: response.callId, + details: response.details, errorCode: response.errorCode, - errorDetails: response.errorDetails, ), ); } From b608e064bad098015091be9c17e22f7bd6b531f8 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 7 Jul 2023 13:05:46 +0200 Subject: [PATCH 134/256] fix isDefinedAndNotNull check; bump lockfile --- lib/src/web/static_interop/gigya_web_sdk.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index 289c74c4..0f8b468f 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -1,3 +1,5 @@ +import 'dart:js_interop'; + import 'package:js/js.dart'; import 'account.dart'; @@ -11,7 +13,7 @@ external GigyaWebSdk get gigyaWebSdk; /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417f6b5e70b21014bbc5a10ce4041860.html @JS() @staticInterop -class GigyaWebSdk {} +class GigyaWebSdk implements JSObject {} /// This extension defines the static interop definition /// for the [GigyaWebSdk] class. From 1092fb664425ffeb6c636ce2151d6fb4bb393156 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 18:58:10 +0100 Subject: [PATCH 135/256] implement static favorite(s) to map method; fix missing music key in favorites toJson() --- lib/src/web/static_interop/favorites.dart | 82 +++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 lib/src/web/static_interop/favorites.dart diff --git a/lib/src/web/static_interop/favorites.dart b/lib/src/web/static_interop/favorites.dart new file mode 100644 index 00000000..619254b3 --- /dev/null +++ b/lib/src/web/static_interop/favorites.dart @@ -0,0 +1,82 @@ +import 'package:js/js.dart'; + +/// The static interop class for the `Favorite` object. +@JS() +@anonymous +class Favorite { + /// Construct a new [Favorite] instance. + external factory Favorite({ + String? category, + String? id, + String? name, + }); + + /// The category of the favorite. + external String? get category; + + /// The id of the favorite. + external String? get id; + + /// The name of the favorite. + external String? get name; + + /// Convert the given [favorite] to a [Map]. + /// + /// Since the [Favorite] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Favorite favorite) { + return { + 'category': favorite.category, + 'id': favorite.id, + 'name': favorite.name, + }; + } +} + +/// The static interop class for the `Favorites` object. +@JS() +@anonymous +class Favorites { + /// Construct a new [Favorites] instance. + external factory Favorites({ + List activities, + List books, + List interests, + List movies, + List music, + List television, + }); + + /// The user's favorite activities. + external List get activities; + + /// The user's favorite books. + external List get books; + + /// The user's interests. + external List get interests; + + /// The user's favorite movies. + external List get movies; + + /// The user's favorite music. + external List get music; + + /// The user's favorite television programmes. + external List get television; + + /// Convert the given [favorites] to a [Map]. + /// + /// Since the [Favorites] class is an anonymous JavaScript type, + /// this has to be a static method instead of an instance method. + static Map toMap(Favorites favorites) { + return { + 'activities': favorites.activities.map(Favorite.toMap).toList(), + 'books': favorites.books.map(Favorite.toMap).toList(), + 'interests': favorites.interests.map(Favorite.toMap).toList(), + 'movies': favorites.movies.map(Favorite.toMap).toList(), + 'music': favorites.music.map(Favorite.toMap).toList(), + 'television': favorites.television.map(Favorite.toMap).toList(), + }; + } +} From b8b6b660505154c13d0c1cffdd1b4226c7f9bad3 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 11:34:48 +0200 Subject: [PATCH 136/256] depend on package:web; enable extension types experiment --- analysis_options.yaml | 4 ++++ pubspec.yaml | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 252a174a..1093cbfd 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -11,6 +11,10 @@ analyzer: strict-inference: true strict-raw-types: true + # TODO: remove this once it is no longer an experiment + enable-experiment: + - inline-class + linter: rules: always_declare_return_types: true diff --git a/pubspec.yaml b/pubspec.yaml index cabf1f6e..6d24389e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.1 homepage: https://github.com/SAP/gigya-flutter-plugin environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.2.0-140.0.dev <4.0.0" flutter: ">=3.10.0" dependencies: @@ -15,6 +15,7 @@ dependencies: js: ">=0.6.6" plugin_platform_interface: ^2.0.2 + web: ^0.2.1-beta dev_dependencies: flutter_lints: ^2.0.0 From 3fac157349806f35502bae00a146f7431d1d7cb7 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 11:42:36 +0200 Subject: [PATCH 137/256] convert the window to extension type --- lib/src/web/static_interop/window.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/web/static_interop/window.dart b/lib/src/web/static_interop/window.dart index f76767d9..3649ad13 100644 --- a/lib/src/web/static_interop/window.dart +++ b/lib/src/web/static_interop/window.dart @@ -1,16 +1,16 @@ -import 'dart:html' as html; - import 'package:js/js.dart'; +import 'package:web/web.dart' show Window; + +import 'gigya_web_sdk.dart'; -/// The static interop class for [html.Window]. +/// The static interop extension type for the [Window]. @JS() @staticInterop -class JSWindow {} +extension type GigyaWindow(Window window) { + /// Get the `gigya` JavaScript object on the [Window]. + external GigyaWebSdk get gigya; -/// This extension defines the static interop definition -/// for the [html.Window] class. -extension JSWindowExtension on JSWindow { - /// Set the `onGigyaServiceReady` function on the [html.Window]. + /// Set the `onGigyaServiceReady` function on the [Window]. /// /// This function is called when the Gigya Web SDK has been initialized. external set onGigyaServiceReady(void Function(Object? arguments) onReady); From 52a1ac26598a9febc10efeacfde3fbe338e62edf Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 11:49:52 +0200 Subject: [PATCH 138/256] convert the GigyaWebSdk JS definition to extension type; move 'window.gigya' to window.dart; add instance getter --- lib/src/web/static_interop/gigya_web_sdk.dart | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index 0f8b468f..b25f69c5 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -1,23 +1,20 @@ import 'dart:js_interop'; import 'package:js/js.dart'; +import 'package:web/web.dart' as web; import 'account.dart'; +import 'window.dart'; -/// Get the `gigya` JavaScript object. -@JS('window.gigya') -external GigyaWebSdk get gigyaWebSdk; - -/// The static interop class for the `gigya` JavaScript object. +/// The static interop extension type for the `gigya` JavaScript object. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417f6b5e70b21014bbc5a10ce4041860.html @JS() @staticInterop -class GigyaWebSdk implements JSObject {} +extension type GigyaWebSdk(JSObject _) implements JSObject { + /// Get the Gigya Web SDK instance from the window. + static GigyaWebSdk get instance => GigyaWindow(web.window).gigya; -/// This extension defines the static interop definition -/// for the [GigyaWebSdk] class. -extension GigyaWebSdkExtension on GigyaWebSdk { /// Get the accounts namespace in the Gigya Web SDK. external Accounts get accounts; From 79bfe9ecfa4d86da6edf0023771b216e4025ecd4 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 11:59:31 +0200 Subject: [PATCH 139/256] use instance getter --- lib/src/web/gigya_flutter_plugin_web.dart | 10 ++++++---- lib/src/web/static_interop_interruption_resolver.dart | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index d7dbd893..230ef064 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -50,7 +50,9 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { // This is the case when doing a Hot Reload, where the application starts from scratch, // even though the Gigya SDK script is still attached to the DOM and ready. // See https://docs.flutter.dev/tools/hot-reload#how-to-perform-a-hot-reload - if (gigyaWebSdk.isDefinedAndNotNull && gigyaWebSdk.isReady) { + final bool sdkIsReady = GigyaWebSdk.instance.isDefinedAndNotNull && GigyaWebSdk.instance.isReady; + + if (sdkIsReady) { if (!onGigyaServiceReadyCompleter.isCompleted) { onGigyaServiceReadyCompleter.complete(); } @@ -111,7 +113,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }), ); - gigyaWebSdk.accounts.session.verify(parameters); + GigyaWebSdk.instance.accounts.session.verify(parameters); return completer.future; } @@ -153,7 +155,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }), ); - gigyaWebSdk.accounts.login(loginParameters); + GigyaWebSdk.instance.accounts.login(loginParameters); return completer.future; } @@ -186,7 +188,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }), ); - gigyaWebSdk.accounts.logout(parameters); + GigyaWebSdk.instance.accounts.logout(parameters); return completer.future; } diff --git a/lib/src/web/static_interop_interruption_resolver.dart b/lib/src/web/static_interop_interruption_resolver.dart index 5873758b..13fbd20c 100644 --- a/lib/src/web/static_interop_interruption_resolver.dart +++ b/lib/src/web/static_interop_interruption_resolver.dart @@ -79,7 +79,7 @@ class _StaticInteropLinkAccountResolver extends LinkAccountResolver { }, ); - gigyaWebSdk.accounts.getConflictingAccount(parameters); + GigyaWebSdk.instance.accounts.getConflictingAccount(parameters); return completer.future; } From b630b22588a3267fba9b12b900bad21dc5ca76db Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 12:20:02 +0200 Subject: [PATCH 140/256] refactor window setup with package:web --- lib/src/web/gigya_flutter_plugin_web.dart | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 230ef064..65f08960 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -1,9 +1,9 @@ import 'dart:async'; -import 'dart:html' as html; import 'dart:js_interop'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:js/js.dart'; +import 'package:web/web.dart' as web; import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; @@ -36,7 +36,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { bool forceLogout = true, }) async { final Completer onGigyaServiceReadyCompleter = Completer(); - final JSWindow domWindow = html.window as JSWindow; + final GigyaWindow domWindow = GigyaWindow(web.window); // Set `window.onGigyaServiceReady` before creating the script. // That function is called when the SDK has been initialized. @@ -57,17 +57,24 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { onGigyaServiceReadyCompleter.complete(); } } else { - final html.ScriptElement script = html.ScriptElement() + final Completer scriptLoadCompleter = Completer(); + + final web.HTMLScriptElement script = web.HTMLScriptElement() ..async = true ..defer = false ..type = 'text/javascript' ..lang = 'javascript' ..crossOrigin = 'anonymous' - ..src = 'https://cdns.$apiDomain/js/gigya.js?apikey=$apiKey'; + ..src = 'https://cdns.$apiDomain/js/gigya.js?apikey=$apiKey' + ..onload = allowInterop(() { + if (!scriptLoadCompleter.isCompleted) { + scriptLoadCompleter.complete(); + } + }).toJS; - html.document.head!.append(script); + web.document.head!.append(script); - await script.onLoad.first; + await scriptLoadCompleter.future; } // If `onGigyaServiceReady` takes too long to be called From bd031d9cbcdba026910201a8c9da70298040bdfb Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 12:55:42 +0200 Subject: [PATCH 141/256] fix import --- lib/src/web/static_interop/gigya_web_sdk.dart | 1 - lib/src/web/static_interop/window.dart | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index b25f69c5..04b78968 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -1,6 +1,5 @@ import 'dart:js_interop'; -import 'package:js/js.dart'; import 'package:web/web.dart' as web; import 'account.dart'; diff --git a/lib/src/web/static_interop/window.dart b/lib/src/web/static_interop/window.dart index 3649ad13..b7cd7b10 100644 --- a/lib/src/web/static_interop/window.dart +++ b/lib/src/web/static_interop/window.dart @@ -1,4 +1,5 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; + import 'package:web/web.dart' show Window; import 'gigya_web_sdk.dart'; From fdb078627aed04522d8a55cc047ec01d31ac420f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 14:28:11 +0200 Subject: [PATCH 142/256] use forceLogout false as default everywhere --- lib/src/method_channel/gigya_flutter_plugin_method_channel.dart | 2 +- .../gigya_flutter_plugin_platform_interface.dart | 2 +- lib/src/web/gigya_flutter_plugin_web.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart index f2f28fdc..280489ea 100644 --- a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart +++ b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart @@ -122,7 +122,7 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform { Future initSdk({ required String apiDomain, required String apiKey, - bool forceLogout = true, + bool forceLogout = false, }) async { // First, initialize the Gigya SDK. try { diff --git a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart index c5c17e3e..d4f9e53c 100644 --- a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart +++ b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart @@ -87,7 +87,7 @@ abstract class GigyaFlutterPluginPlatform extends PlatformInterface { Future initSdk({ required String apiDomain, required String apiKey, - bool forceLogout = true, + bool forceLogout = false, }) { throw UnimplementedError('initSdk() is not implemented.'); } diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 65f08960..2ce5c626 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -33,7 +33,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { Future initSdk({ required String apiDomain, required String apiKey, - bool forceLogout = true, + bool forceLogout = false, }) async { final Completer onGigyaServiceReadyCompleter = Completer(); final GigyaWindow domWindow = GigyaWindow(web.window); From de2965daccef027c5641f5d11f52bb67f4cb15da Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 14:36:32 +0200 Subject: [PATCH 143/256] fix script constructor; fix onReady function signature --- lib/src/web/gigya_flutter_plugin_web.dart | 8 ++++---- lib/src/web/static_interop/window.dart | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 2ce5c626..97653206 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -40,11 +40,11 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { // Set `window.onGigyaServiceReady` before creating the script. // That function is called when the SDK has been initialized. - domWindow.onGigyaServiceReady = allowInterop((Object? arguments) { + domWindow.onGigyaServiceReady = allowInterop((JSAny? _) { if (!onGigyaServiceReadyCompleter.isCompleted) { onGigyaServiceReadyCompleter.complete(); } - }); + }).toJS; // If the Gigya SDK is ready beforehand, complete directly. // This is the case when doing a Hot Reload, where the application starts from scratch, @@ -59,14 +59,14 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { } else { final Completer scriptLoadCompleter = Completer(); - final web.HTMLScriptElement script = web.HTMLScriptElement() + final web.HTMLScriptElement script = (web.document.createElement('script') as web.HTMLScriptElement) ..async = true ..defer = false ..type = 'text/javascript' ..lang = 'javascript' ..crossOrigin = 'anonymous' ..src = 'https://cdns.$apiDomain/js/gigya.js?apikey=$apiKey' - ..onload = allowInterop(() { + ..onload = allowInterop((JSAny _) { if (!scriptLoadCompleter.isCompleted) { scriptLoadCompleter.complete(); } diff --git a/lib/src/web/static_interop/window.dart b/lib/src/web/static_interop/window.dart index b7cd7b10..ad894711 100644 --- a/lib/src/web/static_interop/window.dart +++ b/lib/src/web/static_interop/window.dart @@ -14,5 +14,10 @@ extension type GigyaWindow(Window window) { /// Set the `onGigyaServiceReady` function on the [Window]. /// /// This function is called when the Gigya Web SDK has been initialized. - external set onGigyaServiceReady(void Function(Object? arguments) onReady); + /// + /// The [onReady] function receives a [JSAny] object, + /// containing the arguments that were passed to the method. + /// + /// See https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417f6b5e70b21014bbc5a10ce4041860.html#ongigyaserviceready + external set onGigyaServiceReady(JSFunction onReady); } From 6ed9771e11c84eb4ca58e20cb3cffaea5bd6f6f7 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 19 Sep 2023 15:24:02 +0200 Subject: [PATCH 144/256] make window.gigya nullable --- lib/src/web/gigya_flutter_plugin_web.dart | 2 +- lib/src/web/static_interop/gigya_web_sdk.dart | 12 +++++++++++- lib/src/web/static_interop/window.dart | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 97653206..25da3fb7 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -50,7 +50,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { // This is the case when doing a Hot Reload, where the application starts from scratch, // even though the Gigya SDK script is still attached to the DOM and ready. // See https://docs.flutter.dev/tools/hot-reload#how-to-perform-a-hot-reload - final bool sdkIsReady = GigyaWebSdk.instance.isDefinedAndNotNull && GigyaWebSdk.instance.isReady; + final bool sdkIsReady = domWindow.gigya != null && GigyaWebSdk.instance.isReady; if (sdkIsReady) { if (!onGigyaServiceReadyCompleter.isCompleted) { diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index 04b78968..f9cedc47 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -12,7 +12,17 @@ import 'window.dart'; @staticInterop extension type GigyaWebSdk(JSObject _) implements JSObject { /// Get the Gigya Web SDK instance from the window. - static GigyaWebSdk get instance => GigyaWindow(web.window).gigya; + /// + /// Throws a [StateError] if the Gigya Web SDK instance is null. + static GigyaWebSdk get instance { + final GigyaWebSdk? gigya = GigyaWindow(web.window).gigya; + + if (gigya == null) { + throw StateError('The Gigya Web SDK is null.'); + } + + return gigya; + } /// Get the accounts namespace in the Gigya Web SDK. external Accounts get accounts; diff --git a/lib/src/web/static_interop/window.dart b/lib/src/web/static_interop/window.dart index ad894711..4a2b47ef 100644 --- a/lib/src/web/static_interop/window.dart +++ b/lib/src/web/static_interop/window.dart @@ -9,7 +9,9 @@ import 'gigya_web_sdk.dart'; @staticInterop extension type GigyaWindow(Window window) { /// Get the `gigya` JavaScript object on the [Window]. - external GigyaWebSdk get gigya; + /// + /// If `window.gigya` is null or undefined, this getter returns null. + external GigyaWebSdk? get gigya; /// Set the `onGigyaServiceReady` function on the [Window]. /// From 46e66a1dc8794e789f831fc1ef0c36a671702a86 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 13:06:59 +0200 Subject: [PATCH 145/256] convert BasicParameters to extension type --- lib/src/web/static_interop/parameters/basic.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/web/static_interop/parameters/basic.dart b/lib/src/web/static_interop/parameters/basic.dart index f0848023..215ddfa1 100644 --- a/lib/src/web/static_interop/parameters/basic.dart +++ b/lib/src/web/static_interop/parameters/basic.dart @@ -1,13 +1,15 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import '../response/response.dart'; -/// This class represents the parameters for functions within the Gigya Web SDK, +/// This extension type represents the parameters for functions within the Gigya Web SDK, /// that accept a `callback` function, which in turn receives a [Response] as argument. @JS() @anonymous @staticInterop -class BasicParameters { +extension type BasicParameters._(JSObject _) { /// Create a [BasicParameters] instance using the given [callback]. - external factory BasicParameters({void Function(Response response) callback}); + /// + /// The [callback] function will receive a [Response] as argument. + external factory BasicParameters({JSFunction callback}); } From 57006196cd82061412c08f7f207b80eb9da8a8b9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 13:08:25 +0200 Subject: [PATCH 146/256] convert Response to extension type --- .../web/static_interop/response/response.dart | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index ab535be7..625944b1 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -1,22 +1,15 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -// Export the response classes, -// since importing one does not include the extension getters, -// which are defined here. export 'conflicting_account_response.dart'; export 'login_response.dart'; -/// The static interop class for the Gigya `Response` class. +/// The extension type for the Gigya `Response` class. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d55f070b21014bbc5a10ce4041860.html @JS() @anonymous @staticInterop -class Response {} - -/// This extension defines the static interop definition -/// for the [Response] class. -extension ResponseExtension on Response { +extension type Response(JSObject _) { /// The version of the Gigya API that was used. external int? get apiVersion; @@ -24,6 +17,10 @@ extension ResponseExtension on Response { external String get callId; /// Get the error details. + /// + /// This getter can be redefined (not overridden) by extension types, + /// that have [Response] as representation type, + /// to include additional details. Map get details { return { 'errorDetails': errorDetails, From a054a0114f2886deeff8d572bffa199ab770ffe9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 13:23:46 +0200 Subject: [PATCH 147/256] convert LoginResponse to extension type; fix type for signatureTimestamp --- .../static_interop/response/login_response.dart | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 4346defd..0ee10c3a 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -1,4 +1,4 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import '../models/emails.dart'; import '../models/location.dart'; @@ -6,19 +6,15 @@ import '../models/profile.dart'; import '../models/session_info.dart'; import 'response.dart'; -/// The static interop class for the Gigya Login API response. +/// The extension type for the Gigya Login API response. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/eb93d538b9ae45bfadd9a8aaa8806753.html#response-data @JS() @anonymous @staticInterop -class LoginResponse extends Response {} +extension type LoginResponse(Response baseResponse) { + // TODO: preferences, subscriptions should be in the login response -// TODO: preferences, subscriptions should be in the login response - -/// This extension defines the static interop definition -/// for the [LoginResponse] class. -extension LoginResponseExtension on LoginResponse { /// The timestamp of the creation of the user. external String? get created; @@ -69,8 +65,7 @@ extension LoginResponseExtension on LoginResponse { external SessionInfo? get sessionInfo; /// The timestamp of the [UIDSignature]. - /// This value can be a [String] or a [num]. - external Object? get signatureTimestamp; + external String? get signatureTimestamp; /// The comma separated list of social providers linked to this user. external String? get socialProviders; From af651424625a1e6be89ddad55dd6f4fe9e0f70a1 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 13:36:40 +0200 Subject: [PATCH 148/256] convert ConflictingAccountParameters to extension type --- .../static_interop/parameters/conflicting_account.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/web/static_interop/parameters/conflicting_account.dart b/lib/src/web/static_interop/parameters/conflicting_account.dart index 037887be..0fd21996 100644 --- a/lib/src/web/static_interop/parameters/conflicting_account.dart +++ b/lib/src/web/static_interop/parameters/conflicting_account.dart @@ -1,15 +1,17 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import '../response/conflicting_account_response.dart'; -/// This class represents the parameters for the `Accounts.getConflictingAccount` method. +/// This extension type represents the parameters for the `Accounts.getConflictingAccount` method. @JS() @anonymous @staticInterop -class ConflictingAccountParameters { +extension type ConflictingAccountParameters._(JSObject _) { /// Create a [ConflictingAccountParameters] instance using the given [callback] and [regToken]. + /// + /// The [callback] receives a [ConflictingAccountResponse] as argument. external factory ConflictingAccountParameters({ - void Function(ConflictingAccountResponse response) callback, + JSFunction callback, String regToken, }); } From 33ecd2c22a4077cec8699bac3bde6ca3d708094e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 15:31:12 +0200 Subject: [PATCH 149/256] convert LoginParameters to extension type --- lib/src/web/static_interop/parameters/login.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/web/static_interop/parameters/login.dart b/lib/src/web/static_interop/parameters/login.dart index f242c018..cfccfcf9 100644 --- a/lib/src/web/static_interop/parameters/login.dart +++ b/lib/src/web/static_interop/parameters/login.dart @@ -1,15 +1,17 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import '../response/login_response.dart'; -/// This class represents the parameters for the `Accounts.login` method. +/// This extension type represents the parameters for the `Accounts.login` method. @JS() @anonymous @staticInterop -class LoginParameters { +extension type LoginParameters._(JSObject _) { /// Create a new [LoginParameters] instance. + /// + /// The [callback] receives a [LoginResponse] as argument. external factory LoginParameters({ - void Function(LoginResponse response) callback, + JSFunction callback, String? captchaToken, String? include, String loginID, From 739e96145253acf193e2bbbabf17a97019c87750 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 15:44:11 +0200 Subject: [PATCH 150/256] convert conflicting account response to extension type --- .../response/conflicting_account_response.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/response/conflicting_account_response.dart b/lib/src/web/static_interop/response/conflicting_account_response.dart index 71fcdce3..c545518c 100644 --- a/lib/src/web/static_interop/response/conflicting_account_response.dart +++ b/lib/src/web/static_interop/response/conflicting_account_response.dart @@ -1,19 +1,15 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import '../models/conflicting_account.dart'; import 'response.dart'; -/// The static interop class for the Gigya Conflicting Account API response. +/// The extension type for the Gigya Conflicting Account API response. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4134c49270b21014bbc5a10ce4041860.html @JS() @anonymous @staticInterop -class ConflictingAccountResponse extends Response {} - -/// This extension defines the static interop definition -/// for the [ConflictingAccountResponse] class. -extension ConflictingAccountResponseExtension on ConflictingAccountResponse { +extension type ConflictingAccountResponse(Response baseResponse) { /// Get the conflicting account that is included in the response. external JsConflictingAccount? get conflictingAccount; } From cb2232213976bc5f0ac6f26da9b538f84acc2ea9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 15:49:26 +0200 Subject: [PATCH 151/256] move web error code enum to web/enums --- lib/src/web/{ => enums}/web_error_code.dart | 0 lib/src/web/gigya_flutter_plugin_web.dart | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/src/web/{ => enums}/web_error_code.dart (100%) diff --git a/lib/src/web/web_error_code.dart b/lib/src/web/enums/web_error_code.dart similarity index 100% rename from lib/src/web/web_error_code.dart rename to lib/src/web/enums/web_error_code.dart diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 25da3fb7..9069b742 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -8,6 +8,7 @@ import 'package:web/web.dart' as web; import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; import '../services/interruption_resolver.dart'; +import 'enums/web_error_code.dart'; import 'static_interop/account.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/parameters/basic.dart'; @@ -15,7 +16,6 @@ import 'static_interop/parameters/login.dart'; import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; import 'static_interop_interruption_resolver.dart'; -import 'web_error_code.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { From a9124118b4ea6203042fd2796798efd48642054d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 15:53:54 +0200 Subject: [PATCH 152/256] rename web interruption resolver classes to shorter names --- lib/src/web/gigya_flutter_plugin_web.dart | 6 ++++-- ...esolver.dart => web_interruption_resolver.dart} | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) rename lib/src/web/{static_interop_interruption_resolver.dart => web_interruption_resolver.dart} (84%) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 9069b742..d55713f0 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -15,7 +15,7 @@ import 'static_interop/parameters/basic.dart'; import 'static_interop/parameters/login.dart'; import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; -import 'static_interop_interruption_resolver.dart'; +import 'web_interruption_resolver.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { @@ -27,7 +27,9 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { } @override - InterruptionResolverFactory get interruptionResolverFactory => const StaticInteropInterruptionResolverFactory(); + InterruptionResolverFactory get interruptionResolverFactory { + return const WebInterruptionResolverFactory(); + } @override Future initSdk({ diff --git a/lib/src/web/static_interop_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart similarity index 84% rename from lib/src/web/static_interop_interruption_resolver.dart rename to lib/src/web/web_interruption_resolver.dart index 13fbd20c..8a50f2d8 100644 --- a/lib/src/web/static_interop_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -17,16 +17,16 @@ import 'static_interop/response/response.dart'; /// that uses static interop for its implementation. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/416d41b170b21014bbc5a10ce4041860.html#error-code-definitions-table -class StaticInteropInterruptionResolverFactory extends InterruptionResolverFactory { +class WebInterruptionResolverFactory extends InterruptionResolverFactory { /// The default constructor. - const StaticInteropInterruptionResolverFactory(); + const WebInterruptionResolverFactory(); @override InterruptionResolver? fromErrorCode(GigyaError exception) { // TODO: what is the error code for the `_StaticInteropLinkAccountResolver`? switch (exception.errorCode) { case 206001: - return const _StaticInteropPendingRegistrationResolver(); + return const _PendingRegistrationResolver(); case 206002: return PendingVerificationResolver(exception.registrationToken ?? ''); default: @@ -35,8 +35,8 @@ class StaticInteropInterruptionResolverFactory extends InterruptionResolverFacto } } -class _StaticInteropLinkAccountResolver extends LinkAccountResolver { - _StaticInteropLinkAccountResolver({required this.registrationToken}) { +class _LinkAccountResolver extends LinkAccountResolver { + _LinkAccountResolver({required this.registrationToken}) { _conflictingAccounts = _getConflictingAccounts(); } @@ -85,6 +85,6 @@ class _StaticInteropLinkAccountResolver extends LinkAccountResolver { } } -class _StaticInteropPendingRegistrationResolver extends PendingRegistrationResolver { - const _StaticInteropPendingRegistrationResolver(); +class _PendingRegistrationResolver extends PendingRegistrationResolver { + const _PendingRegistrationResolver(); } From 8a3730dcfec8b5ad074339f350f5cc8d73f6b96b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 16:14:59 +0200 Subject: [PATCH 153/256] convert the accounts namespace to an extension type --- lib/src/web/static_interop/account.dart | 41 +++++++++---------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 688bce28..01eb407a 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -1,42 +1,31 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; +import './session.dart'; import 'parameters/basic.dart'; import 'parameters/conflicting_account.dart'; import 'parameters/login.dart'; -/// The static interop class for the `gigya.accounts` JavaScript object. +/// The extension type for the `gigya.accounts` JavaScript object. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4130da0f70b21014bbc5a10ce4041860.html @JS() @staticInterop -class Accounts {} - -/// This extension defines the static interop definition -/// for the [Accounts] class. -extension AccountsExtension on Accounts { +extension type Accounts(JSObject _) { /// Get the conflicting accounts of the user. - external void Function(ConflictingAccountParameters parameters) getConflictingAccount; + /// + /// This function receives a [ConflictingAccountParameters] instance as argument. + external JSFunction getConflictingAccount; - /// Log in using the given parameters. - external void Function(LoginParameters parameters) login; + /// Log the user in. + /// + /// This function receives a [LoginParameters] instance as argument. + external JSFunction login; /// Log out of the current session. - external void Function(BasicParameters parameters) logout; + /// + /// This function receives a [BasicParameters] instance as argument. + external JSFunction logout; - /// Get the session namespace within the accounts namespace. + /// Get the `gigya.accounts.session` namespace. external Session get session; } - -/// This class represents the session namespace in the [Accounts] class. -/// -/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/7fc882712f2e4011982171ea612466ca.html -@JS() -@staticInterop -class Session {} - -/// This extension defines the static interop definition -/// for the [Session] class. -extension SessionExtension on Session { - /// Verify the current session. - external void Function(BasicParameters parameters) verify; -} From a74578cefb2dfef97fc20c29c5846e7c8c575c1d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 16:18:06 +0200 Subject: [PATCH 154/256] convert the session namespace to an extension type --- lib/src/web/static_interop/session.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/src/web/static_interop/session.dart diff --git a/lib/src/web/static_interop/session.dart b/lib/src/web/static_interop/session.dart new file mode 100644 index 00000000..5aa96680 --- /dev/null +++ b/lib/src/web/static_interop/session.dart @@ -0,0 +1,15 @@ +import 'dart:js_interop'; + +import 'parameters/basic.dart'; + +/// This extension type represents the session namespace. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/7fc882712f2e4011982171ea612466ca.html +@JS() +@staticInterop +extension type Session(JSObject _) { + /// Verify the current session. + /// + /// This function receives a [BasicParameters] instance as argument. + external JSFunction verify; +} From 1218c92c398be72c3814caccb3d546299ac68845 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:24:28 +0200 Subject: [PATCH 155/256] convert like into extension type --- lib/src/web/static_interop/models/like.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/models/like.dart b/lib/src/web/static_interop/models/like.dart index a11d15dc..29f1f172 100644 --- a/lib/src/web/static_interop/models/like.dart +++ b/lib/src/web/static_interop/models/like.dart @@ -1,14 +1,10 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Like` object. +/// The extension type for the `Like` object. @JS() @anonymous @staticInterop -class Like {} - -/// This extension defines the static interop definition -/// for the [Like] class. -extension LikeExtension on Like { +extension type Like(JSObject _) { /// The category of the like. external String? get category; From b6c9cfbaea9776ec6ec75b39db4a0a9fbd100f6d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:25:26 +0200 Subject: [PATCH 156/256] convert work into extension type --- lib/src/web/static_interop/models/work.dart | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/src/web/static_interop/models/work.dart b/lib/src/web/static_interop/models/work.dart index 76a5f5a9..b367982d 100644 --- a/lib/src/web/static_interop/models/work.dart +++ b/lib/src/web/static_interop/models/work.dart @@ -1,18 +1,14 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Work` object. +/// The extension type for the `Work` object. @JS() @anonymous @staticInterop -class Work {} - -/// This extension defines the static interop definition -/// for the [Work] class. -extension WorkExtension on Work { +extension type Work(JSObject _) { /// The name of the company. external String? get company; - /// The size of the company in number of employees. + /// The size of the [company] in number of employees. external int? get companySize; /// The id of the company. @@ -30,7 +26,7 @@ extension WorkExtension on Work { /// The date the user started working at the company. external String? get startDate; - /// The user's title in the company. + /// The user's title in the [company]. external String? get title; /// Convert this work object into a [Map]. From 2859e46f0e7012639dc18213f0fdf3a4f970a93a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:25:54 +0200 Subject: [PATCH 157/256] convert skill into extension type --- lib/src/web/static_interop/models/skill.dart | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/src/web/static_interop/models/skill.dart b/lib/src/web/static_interop/models/skill.dart index 28cda429..118716ac 100644 --- a/lib/src/web/static_interop/models/skill.dart +++ b/lib/src/web/static_interop/models/skill.dart @@ -1,21 +1,17 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Skill` object. +/// The extension type for the `Skill` object. @JS() @anonymous @staticInterop -class Skill {} - -/// This extension defines the static interop definition -/// for the [Skill] class. -extension SkillExtension on Skill { +extension type Skill(JSObject _) { /// The user's proficiency in the skill. external String? get level; /// The user's skill. external String? get skill; - /// The years of the user's skill. + /// The amount of years the user is proficient in the given skill. external int? get years; /// Convert this skill to a [Map]. From 7b10c6cc090383c08ff394aadb0296c2d3c811c6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:26:31 +0200 Subject: [PATCH 158/256] convert certifiation into extension type --- lib/src/web/static_interop/models/certification.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/models/certification.dart b/lib/src/web/static_interop/models/certification.dart index a93c3aa3..756dc229 100644 --- a/lib/src/web/static_interop/models/certification.dart +++ b/lib/src/web/static_interop/models/certification.dart @@ -1,14 +1,10 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the Certification object. +/// The extension type for the Certification object. @JS() @anonymous @staticInterop -class Certification {} - -/// This extension defines the static interop definition -/// for the [Certification] class. -extension CertificationExtension on Certification { +extension type Certification(JSObject _) { /// The certification authority. external String? get authority; From 0b76f9af8b3b51b1834b8d317d3a66a71d47d7fb Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:27:20 +0200 Subject: [PATCH 159/256] convert patent into extension type --- lib/src/web/static_interop/models/patent.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/models/patent.dart b/lib/src/web/static_interop/models/patent.dart index 3b06add6..5413b2b3 100644 --- a/lib/src/web/static_interop/models/patent.dart +++ b/lib/src/web/static_interop/models/patent.dart @@ -1,14 +1,10 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Patent` object. +/// The extension type for the `Patent` object. @JS() @anonymous @staticInterop -class Patent {} - -/// This extension defines the static interop definition -/// for the [Patent] class. -extension PatentExtension on Patent { +extension type Patent(JSObject _) { /// The issue date of the patent. external String? get date; From c9ac2cd9b5bac33bb65dfa7ee51f2851807be52f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:27:59 +0200 Subject: [PATCH 160/256] convert publication into extension type --- lib/src/web/static_interop/models/publication.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/models/publication.dart b/lib/src/web/static_interop/models/publication.dart index d46f38d6..4a4c2e08 100644 --- a/lib/src/web/static_interop/models/publication.dart +++ b/lib/src/web/static_interop/models/publication.dart @@ -1,14 +1,10 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Publication` object. +/// The extension type for the `Publication` object. @JS() @anonymous @staticInterop -class Publication {} - -/// This extension defines the static interop definition -/// for the [Publication] class. -extension PublicationExtension on Publication { +extension type Publication(JSObject _) { /// The publication date. external String? get date; From 05c16b78e1a430c06e38523e47b907c8a86a26e7 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:28:37 +0200 Subject: [PATCH 161/256] convert phone into extension type --- lib/src/web/static_interop/models/phone.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/models/phone.dart b/lib/src/web/static_interop/models/phone.dart index a493c63b..6da1810d 100644 --- a/lib/src/web/static_interop/models/phone.dart +++ b/lib/src/web/static_interop/models/phone.dart @@ -1,14 +1,10 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Phone` object. +/// The extension type for the `Phone` object. @JS() @anonymous @staticInterop -class Phone {} - -/// This extension defines the static interop definition -/// for the [Phone] class. -extension PhoneExtension on Phone { +extension type Phone(JSObject _) { /// The value of the phone number. external String? get number; From 09a4b63faf396ab14d786233e2f5d7b134d9c0bd Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:29:35 +0200 Subject: [PATCH 162/256] convert education into extension type --- lib/src/web/static_interop/models/education.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/models/education.dart b/lib/src/web/static_interop/models/education.dart index acd799b8..343434d7 100644 --- a/lib/src/web/static_interop/models/education.dart +++ b/lib/src/web/static_interop/models/education.dart @@ -1,14 +1,10 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the Education object. +/// The extension type for the Education object. @JS() @anonymous @staticInterop -class Education {} - -/// This extension defines the static interop definition -/// for the [Education] class. -extension EducationExtension on Education { +extension type Education(JSObject _) { /// The degree for the education. external String? get degree; From b5285e7253178b3f0611ab9d74219825487da22e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:32:06 +0200 Subject: [PATCH 163/256] convert session info into extension type; make session info attributes non-null --- .../static_interop/models/session_info.dart | 22 +++++++++++-------- .../response/login_response.dart | 6 +---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/src/web/static_interop/models/session_info.dart b/lib/src/web/static_interop/models/session_info.dart index 22b8ab8e..91c4ce2c 100644 --- a/lib/src/web/static_interop/models/session_info.dart +++ b/lib/src/web/static_interop/models/session_info.dart @@ -1,17 +1,21 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the session info object. +/// The extension type for the session info object. @JS() @anonymous @staticInterop -class SessionInfo {} - -/// This extension defines the static interop definition -/// for the [SessionInfo] class. -extension SessionInfoExtension on SessionInfo { +extension type SessionInfo(JSObject _) { /// The name of the session cookie. - external String? get cookieName; + external String get cookieName; /// The value of the session cookie. - external String? get cookieValue; + external String get cookieValue; + + /// Convert this session info into a [Map]. + Map toMap() { + return { + 'cookieName': cookieName, + 'cookieValue': cookieValue, + }; + } } diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 0ee10c3a..4279c4c2 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -110,11 +110,7 @@ extension type LoginResponse(Response baseResponse) { 'registered': registered, 'regSource': regSource, 'regToken': regToken, - if (sessionInfo != null) - 'sessionInfo': { - 'cookieName': sessionInfo!.cookieName, - 'cookieValue': sessionInfo!.cookieValue, - }, + if (sessionInfo != null) 'sessionInfo': sessionInfo!.toMap(), 'signatureTimestamp': signatureTimestamp, 'socialProviders': socialProviders, 'UID': UID, From 1cc17afc2ae9f2a8cce3cf392f904f5e9d84adb7 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:36:46 +0200 Subject: [PATCH 164/256] convert location & coordinates to extension types; make lat & lon non-null --- .../web/static_interop/models/location.dart | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/src/web/static_interop/models/location.dart b/lib/src/web/static_interop/models/location.dart index b78bb7b7..f977c9e9 100644 --- a/lib/src/web/static_interop/models/location.dart +++ b/lib/src/web/static_interop/models/location.dart @@ -1,30 +1,30 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Coordinates` object. +/// The extension type for the `Coordinates` object. @JS() @anonymous @staticInterop -class Coordinates {} +extension type Coordinates(JSObject _) { + /// The latitude of the coordinate. + external double get lat; -/// This extension defines the static interop definition -/// for the [Coordinates] class. -extension CoordinatesExtension on Coordinates { /// The longitude of the coordinate. - external double? get lat; + external double get lon; - /// The latitude of the coordinate. - external double? get lon; + /// Convert these coordinates to a [Map]. + Map toMap() { + return { + 'lat': lat, + 'lon': lon, + }; + } } -/// The static interop class for the `Location` object. +/// The extension type for the `Location` object. @JS() @anonymous @staticInterop -class Location {} - -/// This extension defines the static interop definition -/// for the [Location] class. -extension LocationExtension on Location { +extension type Location(JSObject _) { /// The name of the city in which the location is located. external String? get city; @@ -42,10 +42,7 @@ extension LocationExtension on Location { return { 'city': city, 'country': country, - 'coordinates': { - 'lat': coordinates?.lat, - 'lon': coordinates?.lon, - }, + if (coordinates != null) 'coordinates': coordinates!.toMap(), 'state': state, }; } From 2ad158cfcf96e3a4b662cd0d1153aa1361550d72 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 22 Sep 2023 20:37:15 +0200 Subject: [PATCH 165/256] fix check --- lib/src/web/static_interop/response/login_response.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 4279c4c2..1757315b 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -83,12 +83,12 @@ extension type LoginResponse(Response baseResponse) { Map toMap() { final Map? profileAsMap = profile?.toMap(); - if (profileAsMap != null) { + if (profileAsMap != null && lastLoginLocation != null) { // The lastLoginLocation field is not in the profile // when using the Gigya Web SDK. // Instead, it is located inside the login response. // Add it to the profile map. - profileAsMap['lastLoginLocation'] = lastLoginLocation?.toMap(); + profileAsMap['lastLoginLocation'] = lastLoginLocation!.toMap(); } return { From d1b2a1d4890333d42f42ee1ce7d211ec406fbd7e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 23 Sep 2023 10:35:50 +0200 Subject: [PATCH 166/256] convert emails to extension type; add toMap() method --- lib/src/web/static_interop/models/emails.dart | 30 ++++++++++++------- .../response/login_response.dart | 6 +--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/src/web/static_interop/models/emails.dart b/lib/src/web/static_interop/models/emails.dart index e8953f9c..828bd313 100644 --- a/lib/src/web/static_interop/models/emails.dart +++ b/lib/src/web/static_interop/models/emails.dart @@ -1,23 +1,31 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the emails object. +/// The extension type for the emails object. @JS() @anonymous @staticInterop -class Emails {} - -/// This extension defines the static interop definition -/// for the [Emails] class. -extension EmailsExtension on Emails { +extension type Emails(JSObject _) { @JS('unverified') - external List? get _unverified; + external JSArray? get _unverified; @JS('verified') - external List? get _verified; + external JSArray? get _verified; /// The list of unverified email addresses. - List get unverified => _unverified?.cast() ?? []; + List get unverified { + return _unverified?.toDart.cast() ?? const []; + } /// The list of verified email addresses. - List get verified => _verified?.cast() ?? []; + List get verified { + return _verified?.toDart.cast() ?? const []; + } + + /// Convert this object to a [Map]. + Map toMap() { + return { + 'unverified': unverified, + 'verified': verified, + }; + } } diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 1757315b..752ed0f2 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -93,11 +93,7 @@ extension type LoginResponse(Response baseResponse) { return { 'created': created, - if (emails != null) - 'emails': { - 'unverified': emails!.unverified, - 'verified': emails!.verified, - }, + if (emails != null) 'emails': emails.toMap(), 'isActive': isActive, 'isNewUser': isNewUser, 'isRegistered': isRegistered, From 3cc6bfccf939e961f41495b8c3cc2fbf07135160 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 23 Sep 2023 10:42:37 +0200 Subject: [PATCH 167/256] convert favorites to extension type --- .../web/static_interop/models/favorites.dart | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/lib/src/web/static_interop/models/favorites.dart b/lib/src/web/static_interop/models/favorites.dart index f1f18cbb..5eb9008a 100644 --- a/lib/src/web/static_interop/models/favorites.dart +++ b/lib/src/web/static_interop/models/favorites.dart @@ -1,14 +1,10 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Favorite` object. +/// The extension type for the `Favorite` object. @JS() @anonymous @staticInterop -class Favorite {} - -/// This extension defines the static interop definition -/// for the [Favorite] class. -extension FavoriteExtension on Favorite { +extension type Favorite(JSObject _) { /// The category of the favorite. external String? get category; @@ -28,54 +24,60 @@ extension FavoriteExtension on Favorite { } } -/// The static interop class for the `Favorites` object. +/// The extension type for the `Favorites` object. @JS() @anonymous @staticInterop -class Favorites {} - -/// This extension defines the static interop definition -/// for the [Favorites] class. -extension FavoritesExtension on Favorites { +extension type Favorites(JSObject _) { @JS('activities') - external List? get _activities; + external JSArray? get _activities; @JS('books') - external List? get _books; + external JSArray? get _books; @JS('interests') - external List? get _interests; + external JSArray? get _interests; @JS('movies') - external List? get _movies; + external JSArray? get _movies; @JS('music') - external List? get _music; + external JSArray? get _music; @JS('television') - external List? get _television; + external JSArray? get _television; /// The user's favorite activities. List get activities { - return _activities?.cast() ?? []; + return _activities?.toDart.cast() ?? const []; } /// The user's favorite books. - List get books => _books?.cast() ?? []; + List get books { + return _books?.toDart.cast() ?? const []; + } /// The user's interests. - List get interests => _interests?.cast() ?? []; + List get interests { + return _interests?.toDart.cast() ?? const []; + } /// The user's favorite movies. - List get movies => _movies?.cast() ?? []; + List get movies { + return _movies?.toDart.cast() ?? const []; + } /// The user's favorite music. - List get music => _music?.cast() ?? []; + List get music { + return _music?.toDart.cast() ?? const []; + } /// The user's favorite television programmes. - List get television => _television?.cast() ?? []; + List get television { + return _television?.toDart.cast() ?? const []; + } - /// Convert this favorites object to a [Map]. + /// Convert this object to a [Map]. Map toMap() { return { 'activities': activities.map((Favorite f) => f.toMap()).toList(), From 9c0410795320c1ac0ca46aaf98de185cbd1bda54 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 23 Sep 2023 11:04:38 +0200 Subject: [PATCH 168/256] convert profile to extension type --- .../web/static_interop/models/profile.dart | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 446b4ccf..89e5aa1f 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -1,4 +1,4 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import 'certification.dart'; import 'education.dart'; @@ -10,16 +10,11 @@ import 'publication.dart'; import 'skill.dart'; import 'work.dart'; -/// This class represents the static interop implementation -/// for the profile object. +/// The extension type for the `Profile` object. @JS() @anonymous @staticInterop -class Profile {} - -/// This extension defines the static interop definition -/// for the [Profile] class. -extension ProfileExtension on Profile { +extension type Profile(JSObject _) { /// The person's activities. external String? get activities; @@ -42,11 +37,11 @@ extension ProfileExtension on Profile { external int? get birthYear; @JS('certifications') - external List? get _certifications; + external JSArray? get _certifications; /// The person's certifications. List get certifications { - return _certifications?.cast() ?? []; + return _certifications?.toDart.cast() ?? const []; } /// The city in which the person resides. @@ -56,11 +51,11 @@ extension ProfileExtension on Profile { external String? get country; @JS('education') - external List? get _education; + external JSArray? get _education; /// The different educations of the person. List get education { - return _education?.cast() ?? []; + return _education?.toDart.cast() ?? const []; } /// The education level of the person. @@ -109,10 +104,10 @@ extension ProfileExtension on Profile { external String? get lastName; @JS('likes') - external List? get _likes; + external JSArray? get _likes; /// The person's likes. - List get likes => _likes?.cast() ?? []; + List get likes => _likes?.toDart.cast() ?? const []; /// The language locale of the person's primary language. external String? get locale; @@ -131,16 +126,18 @@ extension ProfileExtension on Profile { external String? get nickname; @JS('patents') - external List? get _patents; + external JSArray? get _patents; /// The different patents that this person owns. - List get patents => _patents?.cast() ?? []; + List get patents { + return _patents?.toDart.cast() ?? const []; + } @JS('phones') - external List? get _phones; + external JSArray? get _phones; /// The different phone numbers belonging to this person. - List get phones => _phones?.cast() ?? []; + List get phones => _phones?.toDart.cast() ?? const []; /// The url to the person's photo. external String? get photoURL; @@ -155,20 +152,22 @@ extension ProfileExtension on Profile { external String? get profileURL; @JS('providers') - external List? get _providers; + external JSArray? get _providers; /// The names of the providers to which the user is connected/logged in. - List get providers => _providers?.cast() ?? []; + List get providers { + return _providers?.toDart.cast() ?? const []; + } /// The person's proxy email address. external String? get proxyEmail; @JS('publications') - external List? get _publications; + external JSArray? get _publications; /// The list of publications belonging to this person. List get publications { - return _publications?.cast() ?? []; + return _publications?.toDart.cast() ?? const []; } /// The person's relationship status. @@ -178,10 +177,10 @@ extension ProfileExtension on Profile { external String? get religion; @JS('skills') - external List? get _skills; + external JSArray? get _skills; /// The different skills of the person. - List get skills => _skills?.cast() ?? []; + List get skills => _skills?.toDart.cast() ?? const []; /// The person's specialities. external String? get specialities; @@ -202,10 +201,10 @@ extension ProfileExtension on Profile { external String? get verified; @JS('work') - external List? get _work; + external JSArray? get _work; /// The person's career, divided into the different employments. - List get work => _work?.cast() ?? []; + List get work => _work?.toDart.cast() ?? const []; /// The ZIP code of the person's address. external String? get zip; From 7387f949b3c1c7dc1db33edc05fc76f112419e5c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 23 Sep 2023 11:11:31 +0200 Subject: [PATCH 169/256] convert conflicting account to extension type --- .../models/conflicting_account.dart | 16 ++++++---------- .../response/conflicting_account_response.dart | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/src/web/static_interop/models/conflicting_account.dart b/lib/src/web/static_interop/models/conflicting_account.dart index 65e919a0..32c11335 100644 --- a/lib/src/web/static_interop/models/conflicting_account.dart +++ b/lib/src/web/static_interop/models/conflicting_account.dart @@ -1,21 +1,17 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the `Conflicting Account` object. +/// The extension type for the `Conflicting Account` object. @JS() @anonymous @staticInterop -class JsConflictingAccount {} - -/// This extension defines the static interop definition -/// for the [JsConflictingAccount] class. -extension ConflictingAccountExtension on JsConflictingAccount { +extension type ConflictingAccount(JSObject _) { /// The username or email address /// of the user that has a conflicting account. external String? get loginID; @JS('loginProviders') - external List? get _loginProviders; + external JSArray? get _loginProviders; - /// The login providers for the that has a conflicting account. - List? get loginProviders => _loginProviders?.cast(); + /// The login providers for the [loginID] that has a conflicting account. + List? get loginProviders => _loginProviders?.toDart.cast(); } diff --git a/lib/src/web/static_interop/response/conflicting_account_response.dart b/lib/src/web/static_interop/response/conflicting_account_response.dart index c545518c..5c25d41e 100644 --- a/lib/src/web/static_interop/response/conflicting_account_response.dart +++ b/lib/src/web/static_interop/response/conflicting_account_response.dart @@ -11,5 +11,5 @@ import 'response.dart'; @staticInterop extension type ConflictingAccountResponse(Response baseResponse) { /// Get the conflicting account that is included in the response. - external JsConflictingAccount? get conflictingAccount; + external ConflictingAccount? get conflictingAccount; } From a6d236a33c91ec2073ff2df26fdbcb510d880b8d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 23 Sep 2023 11:24:46 +0200 Subject: [PATCH 170/256] fix name conflict --- lib/src/web/static_interop/models/conflicting_account.dart | 5 ++++- .../response/conflicting_account_response.dart | 2 +- lib/src/web/web_interruption_resolver.dart | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/web/static_interop/models/conflicting_account.dart b/lib/src/web/static_interop/models/conflicting_account.dart index 32c11335..1168db08 100644 --- a/lib/src/web/static_interop/models/conflicting_account.dart +++ b/lib/src/web/static_interop/models/conflicting_account.dart @@ -1,10 +1,13 @@ import 'dart:js_interop'; /// The extension type for the `Conflicting Account` object. +/// +/// The name of this extension type is `WebConflictingAccount`, +/// to prevent collisions with the existing `ConflictingAccount` class. @JS() @anonymous @staticInterop -extension type ConflictingAccount(JSObject _) { +extension type WebConflictingAccount(JSObject _) { /// The username or email address /// of the user that has a conflicting account. external String? get loginID; diff --git a/lib/src/web/static_interop/response/conflicting_account_response.dart b/lib/src/web/static_interop/response/conflicting_account_response.dart index 5c25d41e..592db403 100644 --- a/lib/src/web/static_interop/response/conflicting_account_response.dart +++ b/lib/src/web/static_interop/response/conflicting_account_response.dart @@ -11,5 +11,5 @@ import 'response.dart'; @staticInterop extension type ConflictingAccountResponse(Response baseResponse) { /// Get the conflicting account that is included in the response. - external ConflictingAccount? get conflictingAccount; + external WebConflictingAccount? get conflictingAccount; } diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index 8a50f2d8..d12b2473 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -3,7 +3,6 @@ import 'dart:async'; import '../models/conflicting_account.dart'; import '../models/gigya_error.dart'; import '../services/interruption_resolver.dart'; -import 'static_interop/account.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/models/conflicting_account.dart'; import 'static_interop/parameters/conflicting_account.dart'; @@ -58,7 +57,7 @@ class _LinkAccountResolver extends LinkAccountResolver { } if (response.errorCode == 0) { - final JsConflictingAccount? account = response.conflictingAccount; + final WebConflictingAccount? account = response.conflictingAccount; completer.complete( ConflictingAccount( From 2adabf92990ebf9579318431d7876274b36eacf3 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 23 Sep 2023 11:26:30 +0200 Subject: [PATCH 171/256] fix allowInterop() handles; use representation type for missing attributes --- lib/src/web/gigya_flutter_plugin_web.dart | 17 ++++++++--------- lib/src/web/web_interruption_resolver.dart | 16 +++++++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index d55713f0..6a515533 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -9,7 +9,6 @@ import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; import '../services/interruption_resolver.dart'; import 'enums/web_error_code.dart'; -import 'static_interop/account.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/parameters/basic.dart'; import 'static_interop/parameters/login.dart'; @@ -119,7 +118,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { ); break; } - }), + }).toJS, ); GigyaWebSdk.instance.accounts.session.verify(parameters); @@ -149,19 +148,19 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return; } - if (response.errorCode == 0) { + if (response.baseResponse.errorCode == 0) { completer.complete(response.toMap()); } else { completer.completeError( GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - details: response.details, - errorCode: response.errorCode, + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.baseResponse.details, + errorCode: response.baseResponse.errorCode, ), ); } - }), + }).toJS, ); GigyaWebSdk.instance.accounts.login(loginParameters); @@ -194,7 +193,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { ), ); } - }), + }).toJS, ); GigyaWebSdk.instance.accounts.logout(parameters); diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index d12b2473..73459b0e 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -1,4 +1,6 @@ import 'dart:async'; +import 'dart:js_interop'; +import 'package:js/js.dart'; import '../models/conflicting_account.dart'; import '../models/gigya_error.dart'; @@ -51,12 +53,12 @@ class _LinkAccountResolver extends LinkAccountResolver { final Completer completer = Completer(); final ConflictingAccountParameters parameters = ConflictingAccountParameters( regToken: registrationToken, - callback: (ConflictingAccountResponse response) { + callback: allowInterop((ConflictingAccountResponse response) { if (completer.isCompleted) { return; } - if (response.errorCode == 0) { + if (response.baseResponse.errorCode == 0) { final WebConflictingAccount? account = response.conflictingAccount; completer.complete( @@ -68,14 +70,14 @@ class _LinkAccountResolver extends LinkAccountResolver { } else { completer.completeError( GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - details: response.details, - errorCode: response.errorCode, + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.baseResponse.details, + errorCode: response.baseResponse.errorCode, ), ); } - }, + }).toJS, ); GigyaWebSdk.instance.accounts.getConflictingAccount(parameters); From 6bae9f86ff0a6c46176ad74b58f5daac2d6d3659 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 23 Sep 2023 12:10:54 +0200 Subject: [PATCH 172/256] document JS return types for JSFunction handles; adjust type of onReady --- lib/src/web/gigya_flutter_plugin_web.dart | 2 +- lib/src/web/static_interop/account.dart | 9 ++++++--- lib/src/web/static_interop/parameters/basic.dart | 3 ++- .../static_interop/parameters/conflicting_account.dart | 3 ++- lib/src/web/static_interop/parameters/login.dart | 3 ++- lib/src/web/static_interop/session.dart | 3 ++- lib/src/web/static_interop/window.dart | 4 ++-- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 6a515533..cbc98e11 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -41,7 +41,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { // Set `window.onGigyaServiceReady` before creating the script. // That function is called when the SDK has been initialized. - domWindow.onGigyaServiceReady = allowInterop((JSAny? _) { + domWindow.onGigyaServiceReady = allowInterop((JSString? _) { if (!onGigyaServiceReadyCompleter.isCompleted) { onGigyaServiceReadyCompleter.complete(); } diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 01eb407a..4d49be6b 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -13,17 +13,20 @@ import 'parameters/login.dart'; extension type Accounts(JSObject _) { /// Get the conflicting accounts of the user. /// - /// This function receives a [ConflictingAccountParameters] instance as argument. + /// This function receives a [ConflictingAccountParameters] instance as argument, + /// and has [JSVoid] as return type. external JSFunction getConflictingAccount; /// Log the user in. /// - /// This function receives a [LoginParameters] instance as argument. + /// This function receives a [LoginParameters] instance as argument, + /// and has [JSVoid] as return type. external JSFunction login; /// Log out of the current session. /// - /// This function receives a [BasicParameters] instance as argument. + /// This function receives a [BasicParameters] instance as argument, + /// and has [JSVoid] as return type. external JSFunction logout; /// Get the `gigya.accounts.session` namespace. diff --git a/lib/src/web/static_interop/parameters/basic.dart b/lib/src/web/static_interop/parameters/basic.dart index 215ddfa1..33f05766 100644 --- a/lib/src/web/static_interop/parameters/basic.dart +++ b/lib/src/web/static_interop/parameters/basic.dart @@ -10,6 +10,7 @@ import '../response/response.dart'; extension type BasicParameters._(JSObject _) { /// Create a [BasicParameters] instance using the given [callback]. /// - /// The [callback] function will receive a [Response] as argument. + /// The [callback] function will receive a [Response] as argument, + /// and has [JSVoid] as return type. external factory BasicParameters({JSFunction callback}); } diff --git a/lib/src/web/static_interop/parameters/conflicting_account.dart b/lib/src/web/static_interop/parameters/conflicting_account.dart index 0fd21996..9d029930 100644 --- a/lib/src/web/static_interop/parameters/conflicting_account.dart +++ b/lib/src/web/static_interop/parameters/conflicting_account.dart @@ -9,7 +9,8 @@ import '../response/conflicting_account_response.dart'; extension type ConflictingAccountParameters._(JSObject _) { /// Create a [ConflictingAccountParameters] instance using the given [callback] and [regToken]. /// - /// The [callback] receives a [ConflictingAccountResponse] as argument. + /// The [callback] receives a [ConflictingAccountResponse] as argument, + /// and has [JSVoid] as return type. external factory ConflictingAccountParameters({ JSFunction callback, String regToken, diff --git a/lib/src/web/static_interop/parameters/login.dart b/lib/src/web/static_interop/parameters/login.dart index cfccfcf9..2706017c 100644 --- a/lib/src/web/static_interop/parameters/login.dart +++ b/lib/src/web/static_interop/parameters/login.dart @@ -9,7 +9,8 @@ import '../response/login_response.dart'; extension type LoginParameters._(JSObject _) { /// Create a new [LoginParameters] instance. /// - /// The [callback] receives a [LoginResponse] as argument. + /// The [callback] receives a [LoginResponse] as argument, + /// and has [JSVoid] as return type. external factory LoginParameters({ JSFunction callback, String? captchaToken, diff --git a/lib/src/web/static_interop/session.dart b/lib/src/web/static_interop/session.dart index 5aa96680..f84a7326 100644 --- a/lib/src/web/static_interop/session.dart +++ b/lib/src/web/static_interop/session.dart @@ -10,6 +10,7 @@ import 'parameters/basic.dart'; extension type Session(JSObject _) { /// Verify the current session. /// - /// This function receives a [BasicParameters] instance as argument. + /// This function receives a [BasicParameters] instance as argument, + /// and has [JSVoid] as return type. external JSFunction verify; } diff --git a/lib/src/web/static_interop/window.dart b/lib/src/web/static_interop/window.dart index 4a2b47ef..a7b3428a 100644 --- a/lib/src/web/static_interop/window.dart +++ b/lib/src/web/static_interop/window.dart @@ -17,8 +17,8 @@ extension type GigyaWindow(Window window) { /// /// This function is called when the Gigya Web SDK has been initialized. /// - /// The [onReady] function receives a [JSAny] object, - /// containing the arguments that were passed to the method. + /// The [onReady] function receives a nullable [JSString] as argument, + /// and has [JSVoid] as return type. /// /// See https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417f6b5e70b21014bbc5a10ce4041860.html#ongigyaserviceready external set onGigyaServiceReady(JSFunction onReady); From fdff9875c16038f93bf51fbfab39886db539b047 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 26 Sep 2023 08:13:45 +0200 Subject: [PATCH 173/256] let parameter interop types implement JSObject --- lib/src/web/static_interop/parameters/basic.dart | 2 +- lib/src/web/static_interop/parameters/conflicting_account.dart | 2 +- lib/src/web/static_interop/parameters/login.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/web/static_interop/parameters/basic.dart b/lib/src/web/static_interop/parameters/basic.dart index 33f05766..d533b2d2 100644 --- a/lib/src/web/static_interop/parameters/basic.dart +++ b/lib/src/web/static_interop/parameters/basic.dart @@ -7,7 +7,7 @@ import '../response/response.dart'; @JS() @anonymous @staticInterop -extension type BasicParameters._(JSObject _) { +extension type BasicParameters._(JSObject _) implements JSObject { /// Create a [BasicParameters] instance using the given [callback]. /// /// The [callback] function will receive a [Response] as argument, diff --git a/lib/src/web/static_interop/parameters/conflicting_account.dart b/lib/src/web/static_interop/parameters/conflicting_account.dart index 9d029930..5ba720d6 100644 --- a/lib/src/web/static_interop/parameters/conflicting_account.dart +++ b/lib/src/web/static_interop/parameters/conflicting_account.dart @@ -6,7 +6,7 @@ import '../response/conflicting_account_response.dart'; @JS() @anonymous @staticInterop -extension type ConflictingAccountParameters._(JSObject _) { +extension type ConflictingAccountParameters._(JSObject _) implements JSObject { /// Create a [ConflictingAccountParameters] instance using the given [callback] and [regToken]. /// /// The [callback] receives a [ConflictingAccountResponse] as argument, diff --git a/lib/src/web/static_interop/parameters/login.dart b/lib/src/web/static_interop/parameters/login.dart index 2706017c..9fa089d6 100644 --- a/lib/src/web/static_interop/parameters/login.dart +++ b/lib/src/web/static_interop/parameters/login.dart @@ -6,7 +6,7 @@ import '../response/login_response.dart'; @JS() @anonymous @staticInterop -extension type LoginParameters._(JSObject _) { +extension type LoginParameters._(JSObject _) implements JSObject { /// Create a new [LoginParameters] instance. /// /// The [callback] receives a [LoginResponse] as argument, From e3cbf4c8cb7c05a45f719bb4d4cf2f05214f1f85 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 26 Sep 2023 08:15:52 +0200 Subject: [PATCH 174/256] fix JSFunction callables with callAsFunction() --- lib/src/web/gigya_flutter_plugin_web.dart | 15 ++++++++++++--- lib/src/web/web_interruption_resolver.dart | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index cbc98e11..f869bfa4 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -121,7 +121,10 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }).toJS, ); - GigyaWebSdk.instance.accounts.session.verify(parameters); + GigyaWebSdk.instance.accounts.session.verify.callAsFunction( + null, + parameters, + ); return completer.future; } @@ -163,7 +166,10 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }).toJS, ); - GigyaWebSdk.instance.accounts.login(loginParameters); + GigyaWebSdk.instance.accounts.login.callAsFunction( + null, + loginParameters, + ); return completer.future; } @@ -196,7 +202,10 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }).toJS, ); - GigyaWebSdk.instance.accounts.logout(parameters); + GigyaWebSdk.instance.accounts.logout.callAsFunction( + null, + parameters, + ); return completer.future; } diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index 73459b0e..8fc40f8c 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -80,7 +80,10 @@ class _LinkAccountResolver extends LinkAccountResolver { }).toJS, ); - GigyaWebSdk.instance.accounts.getConflictingAccount(parameters); + GigyaWebSdk.instance.accounts.getConflictingAccount.callAsFunction( + null, + parameters, + ); return completer.future; } From a412103bfa070f06c424a1a2599e42fef7ea2363 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 26 Sep 2023 08:28:06 +0200 Subject: [PATCH 175/256] fix non-null cast for getter --- lib/src/web/static_interop/response/login_response.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index 752ed0f2..f22477eb 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -93,7 +93,7 @@ extension type LoginResponse(Response baseResponse) { return { 'created': created, - if (emails != null) 'emails': emails.toMap(), + if (emails != null) 'emails': emails!.toMap(), 'isActive': isActive, 'isNewUser': isNewUser, 'isRegistered': isRegistered, From 13a257bb503e2ff94798ef7793f4ca455c650a2a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 26 Sep 2023 08:59:14 +0200 Subject: [PATCH 176/256] make session cookie nullable again --- lib/src/web/static_interop/models/session_info.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/models/session_info.dart b/lib/src/web/static_interop/models/session_info.dart index 91c4ce2c..687f9cbb 100644 --- a/lib/src/web/static_interop/models/session_info.dart +++ b/lib/src/web/static_interop/models/session_info.dart @@ -6,10 +6,10 @@ import 'dart:js_interop'; @staticInterop extension type SessionInfo(JSObject _) { /// The name of the session cookie. - external String get cookieName; + external String? get cookieName; /// The value of the session cookie. - external String get cookieValue; + external String? get cookieValue; /// Convert this session info into a [Map]. Map toMap() { From b7693b1455b2886a1da1aae4b0988c0100e10f7a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 28 Sep 2023 14:22:50 +0200 Subject: [PATCH 177/256] remove unused file --- lib/src/web/static_interop/favorites.dart | 82 ----------------------- 1 file changed, 82 deletions(-) delete mode 100644 lib/src/web/static_interop/favorites.dart diff --git a/lib/src/web/static_interop/favorites.dart b/lib/src/web/static_interop/favorites.dart deleted file mode 100644 index 619254b3..00000000 --- a/lib/src/web/static_interop/favorites.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'package:js/js.dart'; - -/// The static interop class for the `Favorite` object. -@JS() -@anonymous -class Favorite { - /// Construct a new [Favorite] instance. - external factory Favorite({ - String? category, - String? id, - String? name, - }); - - /// The category of the favorite. - external String? get category; - - /// The id of the favorite. - external String? get id; - - /// The name of the favorite. - external String? get name; - - /// Convert the given [favorite] to a [Map]. - /// - /// Since the [Favorite] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Favorite favorite) { - return { - 'category': favorite.category, - 'id': favorite.id, - 'name': favorite.name, - }; - } -} - -/// The static interop class for the `Favorites` object. -@JS() -@anonymous -class Favorites { - /// Construct a new [Favorites] instance. - external factory Favorites({ - List activities, - List books, - List interests, - List movies, - List music, - List television, - }); - - /// The user's favorite activities. - external List get activities; - - /// The user's favorite books. - external List get books; - - /// The user's interests. - external List get interests; - - /// The user's favorite movies. - external List get movies; - - /// The user's favorite music. - external List get music; - - /// The user's favorite television programmes. - external List get television; - - /// Convert the given [favorites] to a [Map]. - /// - /// Since the [Favorites] class is an anonymous JavaScript type, - /// this has to be a static method instead of an instance method. - static Map toMap(Favorites favorites) { - return { - 'activities': favorites.activities.map(Favorite.toMap).toList(), - 'books': favorites.books.map(Favorite.toMap).toList(), - 'interests': favorites.interests.map(Favorite.toMap).toList(), - 'movies': favorites.movies.map(Favorite.toMap).toList(), - 'music': favorites.music.map(Favorite.toMap).toList(), - 'television': favorites.television.map(Favorite.toMap).toList(), - }; - } -} From 226ac46263e58077383f87116299d266b16b2e2a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 09:09:46 +0200 Subject: [PATCH 178/256] fix import with show combinator --- lib/src/web/gigya_flutter_plugin_web.dart | 2 +- lib/src/web/web_interruption_resolver.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index f869bfa4..e0505e95 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:js_interop'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; -import 'package:js/js.dart'; +import 'package:js/js_util.dart' show allowInterop; import 'package:web/web.dart' as web; import '../models/gigya_error.dart'; diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index 8fc40f8c..2519c097 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -1,6 +1,6 @@ import 'dart:async'; import 'dart:js_interop'; -import 'package:js/js.dart'; +import 'package:js/js_util.dart' show allowInterop; import '../models/conflicting_account.dart'; import '../models/gigya_error.dart'; From 84fdfff517e48a26b77725665ee81246a5de46a5 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 11:50:28 +0200 Subject: [PATCH 179/256] include regToken for login errors --- lib/src/web/gigya_flutter_plugin_web.dart | 2 +- .../web/static_interop/response/login_response.dart | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index e0505e95..03dde941 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -158,7 +158,7 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { GigyaError( apiVersion: response.baseResponse.apiVersion, callId: response.baseResponse.callId, - details: response.baseResponse.details, + details: response.details, errorCode: response.baseResponse.errorCode, ), ); diff --git a/lib/src/web/static_interop/response/login_response.dart b/lib/src/web/static_interop/response/login_response.dart index f22477eb..4813b09b 100644 --- a/lib/src/web/static_interop/response/login_response.dart +++ b/lib/src/web/static_interop/response/login_response.dart @@ -18,6 +18,16 @@ extension type LoginResponse(Response baseResponse) { /// The timestamp of the creation of the user. external String? get created; + /// Get the error details for this response. + /// + /// The [regToken] is included in the details. + Map get details { + return { + ...baseResponse.details, + 'regToken': regToken, + }; + } + /// The verified and unverified email addresses of the user. external Emails? get emails; From d24eaafe552abc94b6b73f975af82e9e4664a555 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 11:24:50 +0100 Subject: [PATCH 180/256] refactor Account.registeredTimestamp to be a `DateTime?` --- lib/src/models/account.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index 4ec880c9..b87b2875 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -1,5 +1,6 @@ import 'emails.dart'; import 'profile.dart'; +import 'session_info.dart'; /// This class represents an account. class Account { @@ -17,6 +18,7 @@ class Account { this.oldestDataUpdated, this.profile, this.registered, + this.sessionInfo, this.signatureTimestamp, this.socialProviders = const [], this.uid, @@ -31,6 +33,9 @@ class Account { (json['emails'] as Map?)?.cast(); final Map? profile = (json['profile'] as Map?)?.cast(); + final Map? session = + (json['sessionInfo'] as Map?) + ?.cast(); final String? lastLogin = json['lastLogin'] as String?; final String? lastUpdated = json['lastUpdated'] as String?; final String? oldestDataUpdated = json['oldestDataUpdated'] as String?; @@ -62,6 +67,7 @@ class Account { oldestDataUpdated: DateTime.tryParse(oldestDataUpdated ?? ''), profile: profile == null ? null : Profile.fromJson(profile), registered: DateTime.tryParse(registered ?? ''), + sessionInfo: session == null ? null : SessionInfo.fromJson(session), signatureTimestamp: signatureTimestamp, socialProviders: socialProviders.split(','), uid: json['UID'] as String?, @@ -110,6 +116,9 @@ class Account { /// The timestamp, in UTC, when the user was registered. final DateTime? registered; + /// The session info for the account. + final SessionInfo? sessionInfo; + /// The timestamp of the [uidSignature], in UTC. /// This signature should be used for login validation. final DateTime? signatureTimestamp; @@ -143,6 +152,7 @@ class Account { 'oldestDataUpdated': oldestDataUpdated?.toIso8601String(), if (accountProfile != null) 'profile': accountProfile.toJson(), 'registered': registered?.toIso8601String(), + if (sessionInfo != null) 'sessionInfo': sessionInfo!.toJson(), 'signatureTimestamp': signatureTimestamp?.toIso8601String(), 'socialProviders': socialProviders, 'UID': uid, From b0a8a0ece6461e8d5fc18d7d54a40864514cc808 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 16 Mar 2023 11:56:38 +0100 Subject: [PATCH 181/256] fix Account.toJson() --- lib/src/models/account.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index b87b2875..56c5aeaf 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -138,6 +138,7 @@ class Account { /// Convert this object into a JSON object. Map toJson() { final Profile? accountProfile = profile; + final SessionInfo? session = sessionInfo; return { 'created': created?.toIso8601String(), @@ -152,7 +153,7 @@ class Account { 'oldestDataUpdated': oldestDataUpdated?.toIso8601String(), if (accountProfile != null) 'profile': accountProfile.toJson(), 'registered': registered?.toIso8601String(), - if (sessionInfo != null) 'sessionInfo': sessionInfo!.toJson(), + if (session != null) 'sessionInfo': session.toJson(), 'signatureTimestamp': signatureTimestamp?.toIso8601String(), 'socialProviders': socialProviders, 'UID': uid, From 4e48e6c45275430978e68afac1597ce89e0ac470 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 15:25:30 +0200 Subject: [PATCH 182/256] Revert "remove external factory constructors from model classes" This reverts commit b726d7ad73c2d2142c377babacfaa6a2821ec395. --- .../static_interop/models/certification.dart | 11 +++- .../web/static_interop/models/education.dart | 12 ++++- lib/src/web/static_interop/models/emails.dart | 8 ++- .../web/static_interop/models/favorites.dart | 21 +++++++- lib/src/web/static_interop/models/like.dart | 10 +++- lib/src/web/static_interop/models/patent.dart | 13 ++++- lib/src/web/static_interop/models/phone.dart | 8 ++- .../web/static_interop/models/profile.dart | 52 ++++++++++++++++++- .../static_interop/models/publication.dart | 11 +++- lib/src/web/static_interop/models/skill.dart | 9 +++- lib/src/web/static_interop/models/work.dart | 14 ++++- 11 files changed, 157 insertions(+), 12 deletions(-) diff --git a/lib/src/web/static_interop/models/certification.dart b/lib/src/web/static_interop/models/certification.dart index 756dc229..ba9231f0 100644 --- a/lib/src/web/static_interop/models/certification.dart +++ b/lib/src/web/static_interop/models/certification.dart @@ -4,7 +4,16 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Certification(JSObject _) { +extension type Certification._(JSObject _) { + /// Create a new [Certification] instance. + external factory Certification({ + String? authority, + String? endDate, + String? name, + String? number, + String? startDate, + }); + /// The certification authority. external String? get authority; diff --git a/lib/src/web/static_interop/models/education.dart b/lib/src/web/static_interop/models/education.dart index 343434d7..ee4be181 100644 --- a/lib/src/web/static_interop/models/education.dart +++ b/lib/src/web/static_interop/models/education.dart @@ -4,7 +4,17 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Education(JSObject _) { +extension type Education._(JSObject _) { + /// Construct a new [Education] instance. + external factory Education({ + String? degree, + String? endYear, + String? fieldOfStudy, + String? school, + String? schoolType, + String? startYear, + }); + /// The degree for the education. external String? get degree; diff --git a/lib/src/web/static_interop/models/emails.dart b/lib/src/web/static_interop/models/emails.dart index 828bd313..6d928d13 100644 --- a/lib/src/web/static_interop/models/emails.dart +++ b/lib/src/web/static_interop/models/emails.dart @@ -4,7 +4,13 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Emails(JSObject _) { +extension type Emails._(JSObject _) { + /// Create a new [Emails] instance. + external factory Emails({ + JSArray unverified, + JSArray verified, + }); + @JS('unverified') external JSArray? get _unverified; diff --git a/lib/src/web/static_interop/models/favorites.dart b/lib/src/web/static_interop/models/favorites.dart index 5eb9008a..6df4229f 100644 --- a/lib/src/web/static_interop/models/favorites.dart +++ b/lib/src/web/static_interop/models/favorites.dart @@ -4,7 +4,14 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Favorite(JSObject _) { +extension type Favorite._(JSObject _) { + /// Construct a new [Favorite] instance. + external factory Favorite({ + String? category, + String? id, + String? name, + }); + /// The category of the favorite. external String? get category; @@ -28,7 +35,17 @@ extension type Favorite(JSObject _) { @JS() @anonymous @staticInterop -extension type Favorites(JSObject _) { +extension type Favorites._(JSObject _) { + /// Construct a new [Favorites] instance. + external factory Favorites({ + JSArray activities, + JSArray books, + JSArray interests, + JSArray movies, + JSArray music, + JSArray television, + }); + @JS('activities') external JSArray? get _activities; diff --git a/lib/src/web/static_interop/models/like.dart b/lib/src/web/static_interop/models/like.dart index 29f1f172..6223aab1 100644 --- a/lib/src/web/static_interop/models/like.dart +++ b/lib/src/web/static_interop/models/like.dart @@ -4,7 +4,15 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Like(JSObject _) { +extension type Like._(JSObject _) { + /// Create a new [Like] instance. + external factory Like({ + String? category, + String? id, + String? name, + String? time, + }); + /// The category of the like. external String? get category; diff --git a/lib/src/web/static_interop/models/patent.dart b/lib/src/web/static_interop/models/patent.dart index 5413b2b3..1fbfa580 100644 --- a/lib/src/web/static_interop/models/patent.dart +++ b/lib/src/web/static_interop/models/patent.dart @@ -4,7 +4,18 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Patent(JSObject _) { +extension type Patent._(JSObject _) { + /// Construct a new [Patent] instance. + external factory Patent({ + String? date, + String? number, + String? office, + String? status, + String? summary, + String? title, + String? url, + }); + /// The issue date of the patent. external String? get date; diff --git a/lib/src/web/static_interop/models/phone.dart b/lib/src/web/static_interop/models/phone.dart index 6da1810d..e3c20e2a 100644 --- a/lib/src/web/static_interop/models/phone.dart +++ b/lib/src/web/static_interop/models/phone.dart @@ -4,7 +4,13 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Phone(JSObject _) { +extension type Phone._(JSObject _) { + /// Construct a new [Phone] instance. + external factory Phone({ + String? number, + String? type, + }); + /// The value of the phone number. external String? get number; diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 89e5aa1f..5c83bac2 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -14,7 +14,57 @@ import 'work.dart'; @JS() @anonymous @staticInterop -extension type Profile(JSObject _) { +extension type Profile._(JSObject _) { + /// Construct a new [Profile] instance. + external factory Profile({ + String? activities, + String? address, + int? age, + String? bio, + int? birthDay, + int? birthMonth, + int birthYear, + JSArray certifications, + String? city, + String? country, + JSArray education, + String? educationLevel, + String? email, + Favorites favorites, + String? firstName, + int? followers, + int? following, + String? gender, + String? hometown, + String? honors, + String? industry, + String? interests, + String? languages, + String? lastName, + JSArray likes, + String? locale, + String? name, + String? nickname, + JSArray patents, + JSArray phones, + String? photoUrl, + String? politicalView, + String? professionalHeadline, + String? profileUrl, + String? proxyEmail, + JSArray publications, + String? relationshipStatus, + String? religion, + JSArray skills, + String? specialities, + String? state, + String? thumbnailUrl, + String? timezone, + String? username, + String? verified, + JSArray work, + String? zip, + }); /// The person's activities. external String? get activities; diff --git a/lib/src/web/static_interop/models/publication.dart b/lib/src/web/static_interop/models/publication.dart index 4a4c2e08..77121366 100644 --- a/lib/src/web/static_interop/models/publication.dart +++ b/lib/src/web/static_interop/models/publication.dart @@ -4,7 +4,16 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Publication(JSObject _) { +extension type Publication._(JSObject _) { + /// Construct a new [Publication] instance. + external factory Publication({ + String? date, + String? publisher, + String? summary, + String? title, + String? url, + }); + /// The publication date. external String? get date; diff --git a/lib/src/web/static_interop/models/skill.dart b/lib/src/web/static_interop/models/skill.dart index 118716ac..dd22e655 100644 --- a/lib/src/web/static_interop/models/skill.dart +++ b/lib/src/web/static_interop/models/skill.dart @@ -4,7 +4,14 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Skill(JSObject _) { +extension type Skill._(JSObject _) { + /// Construct a new [Skill] instance. + external factory Skill({ + String? level, + String? skill, + int? years, + }); + /// The user's proficiency in the skill. external String? get level; diff --git a/lib/src/web/static_interop/models/work.dart b/lib/src/web/static_interop/models/work.dart index b367982d..4bc0b603 100644 --- a/lib/src/web/static_interop/models/work.dart +++ b/lib/src/web/static_interop/models/work.dart @@ -4,7 +4,19 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Work(JSObject _) { +extension type Work._(JSObject _) { + /// Construct a new [Work] instance. + external factory Work({ + String? company, + int? companySize, + String? companyID, + String? endDate, + String? industry, + bool? isCurrent, + String? startDate, + String? title, + }); + /// The name of the company. external String? get company; From 5d5833bca0d8308b292b99f2f762b55824124c9b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 15:50:12 +0200 Subject: [PATCH 183/256] implement registration parameters interop classes --- .../parameters/registration.dart | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/src/web/static_interop/parameters/registration.dart diff --git a/lib/src/web/static_interop/parameters/registration.dart b/lib/src/web/static_interop/parameters/registration.dart new file mode 100644 index 00000000..323794b9 --- /dev/null +++ b/lib/src/web/static_interop/parameters/registration.dart @@ -0,0 +1,41 @@ +import 'package:js/js.dart'; + +import '../models/profile.dart'; +import '../response/login_response.dart'; +import '../response/registration_response.dart'; + +/// This class represents the parameters for the `Accounts.initRegistration` method. +@JS() +@anonymous +@staticInterop +class InitRegistrationParameters { + /// Create a new [InitRegistrationParameters] instance. + external factory InitRegistrationParameters({ + void Function(InitRegistrationResponse response) callback, + bool isLite, + }); +} + +/// This class represents the parameters for the `Accounts.registration` method. +@JS() +@anonymous +@staticInterop +class RegistrationParameters { + /// Create a new [RegistrationParameters] instance. + external factory RegistrationParameters({ + void Function(LoginResponse response) callback, + String? captchaToken, + String email, + bool finalizeRegistration, + String? include, + String? lang, + String password, + Profile? profile, + String? regSource, + String regToken, + String? secretQuestion, + String? secretAnswer, + int? sessionExpiration, + String? siteUID, + }); +} From 1d56ce1396d9209d1e867be593fc04793498e114 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 15:50:33 +0200 Subject: [PATCH 184/256] implement init registration response interop class --- .../static_interop/response/registration_response.dart | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 lib/src/web/static_interop/response/registration_response.dart diff --git a/lib/src/web/static_interop/response/registration_response.dart b/lib/src/web/static_interop/response/registration_response.dart new file mode 100644 index 00000000..bb9ad8f8 --- /dev/null +++ b/lib/src/web/static_interop/response/registration_response.dart @@ -0,0 +1,9 @@ +import 'response.dart'; + +/// The static interop class for the Gigya InitRegistration API response. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4136cef070b21014bbc5a10ce4041860.html?locale=en-US#response-example +class InitRegistrationResponse extends Response { + /// The registration token for the registration. + external String? get regToken; +} From 997f55ed3e392329d7ecdb1e494f222cc9e1ae63 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 15:50:58 +0200 Subject: [PATCH 185/256] add registration interop definition to the account namespace --- lib/src/web/static_interop/account.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 4d49be6b..839d2350 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -4,6 +4,7 @@ import './session.dart'; import 'parameters/basic.dart'; import 'parameters/conflicting_account.dart'; import 'parameters/login.dart'; +import 'parameters/registration.dart'; /// The extension type for the `gigya.accounts` JavaScript object. /// @@ -17,6 +18,12 @@ extension type Accounts(JSObject _) { /// and has [JSVoid] as return type. external JSFunction getConflictingAccount; + /// Start a registration. + /// + /// This function receives an [InitRegistrationParameters] instance as argument, + /// and has [JSVoid] as return type. + external JSFunction initRegistration; + /// Log the user in. /// /// This function receives a [LoginParameters] instance as argument, @@ -29,6 +36,12 @@ extension type Accounts(JSObject _) { /// and has [JSVoid] as return type. external JSFunction logout; + /// Register a new user using the given parameters. + /// + /// This function receives a [RegistrationParameters] instance as argument, + /// and has [JSVoid] as return type. + external JSFunction register; + /// Get the `gigya.accounts.session` namespace. external Session get session; } From ccf438bfc3f2bfb55eb3c394981e9910f1959131 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 15:54:30 +0200 Subject: [PATCH 186/256] fix param type --- lib/src/web/static_interop/parameters/registration.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/parameters/registration.dart b/lib/src/web/static_interop/parameters/registration.dart index 323794b9..439e1488 100644 --- a/lib/src/web/static_interop/parameters/registration.dart +++ b/lib/src/web/static_interop/parameters/registration.dart @@ -12,7 +12,7 @@ class InitRegistrationParameters { /// Create a new [InitRegistrationParameters] instance. external factory InitRegistrationParameters({ void Function(InitRegistrationResponse response) callback, - bool isLite, + bool? isLite, }); } From 1bfe89cdab2fc9a70e82212901c4ae0354e23c58 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 16:28:16 +0200 Subject: [PATCH 187/256] make birth year nullable for static interop type --- lib/src/web/static_interop/models/profile.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 5c83bac2..b7865d61 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -23,7 +23,7 @@ extension type Profile._(JSObject _) { String? bio, int? birthDay, int? birthMonth, - int birthYear, + int? birthYear, JSArray certifications, String? city, String? country, From c34107bfde468ec3a2d1a954eccdc05b92211ecf Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 16:44:30 +0200 Subject: [PATCH 188/256] implement favorites from map for static interop class --- .../web/static_interop/models/favorites.dart | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/models/favorites.dart b/lib/src/web/static_interop/models/favorites.dart index 6df4229f..a0a41874 100644 --- a/lib/src/web/static_interop/models/favorites.dart +++ b/lib/src/web/static_interop/models/favorites.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Favorite._(JSObject _) { +extension type Favorite._(JSObject _) implements JSObject { /// Construct a new [Favorite] instance. external factory Favorite({ String? category, @@ -12,6 +12,15 @@ extension type Favorite._(JSObject _) { String? name, }); + /// Create a new [Favorite] instance from the given [map]. + factory Favorite.fromMap(Map map) { + return Favorite( + category: map['category'] as String?, + id: map['id'] as String?, + name: map['name'] as String?, + ); + } + /// The category of the favorite. external String? get category; @@ -45,6 +54,31 @@ extension type Favorites._(JSObject _) { JSArray music, JSArray television, }); + + /// Create a new [Favorites] instance from the given [map]. + factory Favorites.fromMap(Map map) { + final List> activities = + map['activities'] as List>? ?? const >[]; + final List> books = + map['books'] as List>? ?? const >[]; + final List> interests = + map['interests'] as List>? ?? const >[]; + final List> movies = + map['movies'] as List>? ?? const >[]; + final List> music = + map['music'] as List>? ?? const >[]; + final List> television = + map['television'] as List>? ?? const >[]; + + return Favorites( + activities: activities.map(Favorite.fromMap).toList().toJS, + books: books.map(Favorite.fromMap).toList().toJS, + interests: interests.map(Favorite.fromMap).toList().toJS, + movies: movies.map(Favorite.fromMap).toList().toJS, + music: music.map(Favorite.fromMap).toList().toJS, + television: television.map(Favorite.fromMap).toList().toJS, + ); + } @JS('activities') external JSArray? get _activities; From dc30399e0e12758dc3f07f730d5c10d071f97c55 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 16:53:07 +0200 Subject: [PATCH 189/256] implement certification from map for static interop definition --- lib/src/web/static_interop/models/certification.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/web/static_interop/models/certification.dart b/lib/src/web/static_interop/models/certification.dart index ba9231f0..b6a89e4d 100644 --- a/lib/src/web/static_interop/models/certification.dart +++ b/lib/src/web/static_interop/models/certification.dart @@ -14,6 +14,17 @@ extension type Certification._(JSObject _) { String? startDate, }); + /// Create a new [Certification] instance from the given [map]. + factory Certification.fromMap(Map map) { + return Certification( + authority: map['authority'] as String?, + endDate: map['endDate'] as String?, + name: map['name'] as String?, + number: map['number'] as String?, + startDate: map['startDate'] as String?, + ); + } + /// The certification authority. external String? get authority; From 4c1b101d68f41c68b235376c81ffb9144c526550 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 16:53:21 +0200 Subject: [PATCH 190/256] implement education from map for static interop definition --- lib/src/web/static_interop/models/education.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/web/static_interop/models/education.dart b/lib/src/web/static_interop/models/education.dart index ee4be181..4f4a9191 100644 --- a/lib/src/web/static_interop/models/education.dart +++ b/lib/src/web/static_interop/models/education.dart @@ -15,6 +15,18 @@ extension type Education._(JSObject _) { String? startYear, }); + /// Create a new [Education] instance from the given [map]. + factory Education.fromMap(Map map) { + return Education( + degree: map['degree'] as String?, + endYear: map['endYear'] as String?, + fieldOfStudy: map['fieldOfStudy'] as String?, + school: map['school'] as String?, + schoolType: map['schoolType'] as String?, + startYear: map['startYear'] as String?, + ); + } + /// The degree for the education. external String? get degree; From d1fee2e9a301d712f121d4c3993b6b42b2a8cc97 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 16:55:00 +0200 Subject: [PATCH 191/256] implement like from map for static interop definition --- lib/src/web/static_interop/models/like.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/models/like.dart b/lib/src/web/static_interop/models/like.dart index 6223aab1..efa9f27e 100644 --- a/lib/src/web/static_interop/models/like.dart +++ b/lib/src/web/static_interop/models/like.dart @@ -12,7 +12,17 @@ extension type Like._(JSObject _) { String? name, String? time, }); - + + /// Create a new [Like] instance from the given [map]. + factory Like.fromMap(Map map) { + return Like( + category: map['category'] as String?, + id: map['id'] as String?, + name: map['name'] as String?, + time: map['time'] as String?, + ); + } + /// The category of the like. external String? get category; From ce279997411064990dc656789926d64c0c83f4a6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 16:57:56 +0200 Subject: [PATCH 192/256] implement work from map for static interop definition --- lib/src/web/static_interop/models/work.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/src/web/static_interop/models/work.dart b/lib/src/web/static_interop/models/work.dart index 4bc0b603..28a05783 100644 --- a/lib/src/web/static_interop/models/work.dart +++ b/lib/src/web/static_interop/models/work.dart @@ -17,6 +17,20 @@ extension type Work._(JSObject _) { String? title, }); + /// Create a new [Work] instance from the given [map]. + factory Work.fromMap(Map map) { + return Work( + company: map['company'] as String?, + companyID: map['companyID'] as String?, + companySize: map['companySize'] as int?, + endDate: map['endDate'] as String?, + industry: map['industry'] as String?, + isCurrent: map['isCurrent'] as bool?, + startDate: map['startDate'] as String?, + title: map['title'] as String?, + ); + } + /// The name of the company. external String? get company; From 8dde4a47139d01d659eb0cf4d17ebff33a2c166b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 16:59:02 +0200 Subject: [PATCH 193/256] implement skill from map for static interop definition --- lib/src/web/static_interop/models/skill.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/web/static_interop/models/skill.dart b/lib/src/web/static_interop/models/skill.dart index dd22e655..464d937b 100644 --- a/lib/src/web/static_interop/models/skill.dart +++ b/lib/src/web/static_interop/models/skill.dart @@ -12,6 +12,15 @@ extension type Skill._(JSObject _) { int? years, }); + /// Create a new [Skill] instance from the given [map]. + factory Skill.fromMap(Map map) { + return Skill( + level: map['level'] as String?, + skill: map['skill'] as String?, + years: map['years'] as int?, + ); + } + /// The user's proficiency in the skill. external String? get level; From 15a06fbde7cda054a0586049a81884be32e6dc73 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 17:00:48 +0200 Subject: [PATCH 194/256] implement publication from map for static interop definition --- lib/src/web/static_interop/models/publication.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/web/static_interop/models/publication.dart b/lib/src/web/static_interop/models/publication.dart index 77121366..ce6ba6f1 100644 --- a/lib/src/web/static_interop/models/publication.dart +++ b/lib/src/web/static_interop/models/publication.dart @@ -14,6 +14,17 @@ extension type Publication._(JSObject _) { String? url, }); + /// Create a new [Publication] instance from the given [map]. + factory Publication.fromMap(Map map) { + return Publication( + date: map['date'] as String?, + publisher: map['publisher'] as String?, + summary: map['summary'] as String?, + title: map['title'] as String?, + url: map['url'] as String?, + ); + } + /// The publication date. external String? get date; From 4eb1e54db5b78243f4cc8efa86f3a398ad9d0c78 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 17:03:00 +0200 Subject: [PATCH 195/256] implement patent from map for static interop definition --- lib/src/web/static_interop/models/patent.dart | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/models/patent.dart b/lib/src/web/static_interop/models/patent.dart index 1fbfa580..4704b150 100644 --- a/lib/src/web/static_interop/models/patent.dart +++ b/lib/src/web/static_interop/models/patent.dart @@ -15,7 +15,20 @@ extension type Patent._(JSObject _) { String? title, String? url, }); - + + /// Create a new [Patent] instance from the given [map]. + factory Patent.fromMap(Map map) { + return Patent( + date: map['date'] as String?, + number: map['number'] as String?, + office: map['office'] as String?, + status: map['status'] as String?, + summary: map['summary'] as String?, + title: map['title'] as String?, + url: map['url'] as String?, + ); + } + /// The issue date of the patent. external String? get date; From 83bdcf00e3afc95eaa75cb91e7c0fbdc132d59d2 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 17:04:02 +0200 Subject: [PATCH 196/256] implement phone from map for static interop definition --- lib/src/web/static_interop/models/phone.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/web/static_interop/models/phone.dart b/lib/src/web/static_interop/models/phone.dart index e3c20e2a..712a48a0 100644 --- a/lib/src/web/static_interop/models/phone.dart +++ b/lib/src/web/static_interop/models/phone.dart @@ -10,6 +10,14 @@ extension type Phone._(JSObject _) { String? number, String? type, }); + + /// Create a new [Phone] instance from the given [map]. + factory Phone.fromMap(Map map) { + return Phone( + number: map['number'] as String?, + type: map['type'] as String?, + ); + } /// The value of the phone number. external String? get number; From 07ca0b7f066d886f1f41e970cf87616e7334aa32 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 17:11:23 +0200 Subject: [PATCH 197/256] implement profile from map for static interop definition --- .../static_interop/models/certification.dart | 2 +- .../web/static_interop/models/education.dart | 2 +- lib/src/web/static_interop/models/like.dart | 2 +- lib/src/web/static_interop/models/patent.dart | 2 +- lib/src/web/static_interop/models/phone.dart | 2 +- .../web/static_interop/models/profile.dart | 75 ++++++++++++++++++- .../static_interop/models/publication.dart | 2 +- lib/src/web/static_interop/models/skill.dart | 2 +- lib/src/web/static_interop/models/work.dart | 2 +- 9 files changed, 82 insertions(+), 9 deletions(-) diff --git a/lib/src/web/static_interop/models/certification.dart b/lib/src/web/static_interop/models/certification.dart index b6a89e4d..a8cab328 100644 --- a/lib/src/web/static_interop/models/certification.dart +++ b/lib/src/web/static_interop/models/certification.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Certification._(JSObject _) { +extension type Certification._(JSObject _) implements JSObject { /// Create a new [Certification] instance. external factory Certification({ String? authority, diff --git a/lib/src/web/static_interop/models/education.dart b/lib/src/web/static_interop/models/education.dart index 4f4a9191..f858d988 100644 --- a/lib/src/web/static_interop/models/education.dart +++ b/lib/src/web/static_interop/models/education.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Education._(JSObject _) { +extension type Education._(JSObject _) implements JSObject { /// Construct a new [Education] instance. external factory Education({ String? degree, diff --git a/lib/src/web/static_interop/models/like.dart b/lib/src/web/static_interop/models/like.dart index efa9f27e..ebbe4261 100644 --- a/lib/src/web/static_interop/models/like.dart +++ b/lib/src/web/static_interop/models/like.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Like._(JSObject _) { +extension type Like._(JSObject _) implements JSObject { /// Create a new [Like] instance. external factory Like({ String? category, diff --git a/lib/src/web/static_interop/models/patent.dart b/lib/src/web/static_interop/models/patent.dart index 4704b150..c579ba03 100644 --- a/lib/src/web/static_interop/models/patent.dart +++ b/lib/src/web/static_interop/models/patent.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Patent._(JSObject _) { +extension type Patent._(JSObject _) implements JSObject { /// Construct a new [Patent] instance. external factory Patent({ String? date, diff --git a/lib/src/web/static_interop/models/phone.dart b/lib/src/web/static_interop/models/phone.dart index 712a48a0..d3c82878 100644 --- a/lib/src/web/static_interop/models/phone.dart +++ b/lib/src/web/static_interop/models/phone.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Phone._(JSObject _) { +extension type Phone._(JSObject _) implements JSObject { /// Construct a new [Phone] instance. external factory Phone({ String? number, diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index b7865d61..60b4399f 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -64,7 +64,80 @@ extension type Profile._(JSObject _) { String? verified, JSArray work, String? zip, - }); + }); + + /// Create a new [Profile] instance from the given [map]. + factory Profile.fromMap(Map map) { + final List> certifications = + map['certifications'] as List>? ?? const >[]; + final List> education = + map['education'] as List>? ?? const >[]; + final List> likes = + map['likes'] as List>? ?? const >[]; + final List> patents = + map['patents'] as List>? ?? const >[]; + final List> phones = + map['phones'] as List>? ?? const >[]; + final List> publications = + map['publications'] as List>? ?? const >[]; + final List> skills = + map['skills'] as List>? ?? const >[]; + final List> work = + map['work'] as List>? ?? const >[]; + + return Profile( + activities: map['activities'] as String?, + address: map['address'] as String?, + age: map['age'] as int?, + bio: map['bio'] as String?, + birthDay: map['birthDay'] as int?, + birthMonth: map['birthMonth'] as int?, + birthYear: map['birthYear'] as int?, + certifications: certifications.map(Certification.fromMap).toList().toJS, + city: map['city'] as String?, + country: map['country'] as String?, + education: education.map(Education.fromMap).toList().toJS, + educationLevel: map['educationLevel'] as String?, + email: map['email'] as String?, + favorites: Favorites.fromMap( + map['favorites'] as Map? ?? const {}, + ), + firstName: map['firstName'] as String?, + followers: map['followers'] as int?, + following: map['following'] as int?, + gender: map['gender'] as String?, + hometown: map['hometown'] as String?, + honors: map['honors'] as String?, + industry: map['industry'] as String?, + interests: map['interests'] as String?, + languages: map['languages'] as String?, + lastName: map['lastName'] as String?, + likes: likes.map(Like.fromMap).toList().toJS, + locale: map['locale'] as String?, + name: map['name'] as String?, + nickname: map['nickname'] as String?, + patents: patents.map(Patent.fromMap).toList().toJS, + phones: phones.map(Phone.fromMap).toList().toJS, + photoUrl: map['photoUrl'] as String?, + politicalView: map['politicalView'] as String?, + professionalHeadline: map['professionalHeadline'] as String?, + profileUrl: map['profileUrl'] as String?, + proxyEmail: map['proxyEmail'] as String?, + publications: publications.map(Publication.fromMap).toList().toJS, + relationshipStatus: map['relationshipStatus'] as String?, + religion: map['religion'] as String?, + skills: skills.map(Skill.fromMap).toList().toJS, + specialities: map['specialities'] as String?, + state: map['state'] as String?, + thumbnailUrl: map['thumbnailUrl'] as String?, + timezone: map['timezone'] as String?, + username: map['username'] as String?, + verified: map['verified'] as String?, + work: work.map(Work.fromMap).toList().toJS, + zip: map['zip'] as String?, + ); + } + /// The person's activities. external String? get activities; diff --git a/lib/src/web/static_interop/models/publication.dart b/lib/src/web/static_interop/models/publication.dart index ce6ba6f1..17e2442d 100644 --- a/lib/src/web/static_interop/models/publication.dart +++ b/lib/src/web/static_interop/models/publication.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Publication._(JSObject _) { +extension type Publication._(JSObject _) implements JSObject { /// Construct a new [Publication] instance. external factory Publication({ String? date, diff --git a/lib/src/web/static_interop/models/skill.dart b/lib/src/web/static_interop/models/skill.dart index 464d937b..ff59d8e5 100644 --- a/lib/src/web/static_interop/models/skill.dart +++ b/lib/src/web/static_interop/models/skill.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Skill._(JSObject _) { +extension type Skill._(JSObject _) implements JSObject { /// Construct a new [Skill] instance. external factory Skill({ String? level, diff --git a/lib/src/web/static_interop/models/work.dart b/lib/src/web/static_interop/models/work.dart index 28a05783..192adca1 100644 --- a/lib/src/web/static_interop/models/work.dart +++ b/lib/src/web/static_interop/models/work.dart @@ -4,7 +4,7 @@ import 'dart:js_interop'; @JS() @anonymous @staticInterop -extension type Work._(JSObject _) { +extension type Work._(JSObject _) implements JSObject { /// Construct a new [Work] instance. external factory Work({ String? company, From 2cad06e600ef3d6485fd5ae14ffb5a4247148c87 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Tue, 11 Apr 2023 17:20:26 +0200 Subject: [PATCH 198/256] implement register method for web --- lib/src/web/gigya_flutter_plugin_web.dart | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 03dde941..33a23e69 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -10,8 +10,11 @@ import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; import '../services/interruption_resolver.dart'; import 'enums/web_error_code.dart'; import 'static_interop/gigya_web_sdk.dart'; +import 'static_interop/models/profile.dart'; import 'static_interop/parameters/basic.dart'; import 'static_interop/parameters/login.dart'; +import 'static_interop/parameters/registration.dart'; +import 'static_interop/response/registration_response.dart'; import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; import 'web_interruption_resolver.dart'; @@ -209,4 +212,88 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return completer.future; } + + @override + Future> register({ + required String loginId, + required String password, + Map parameters = const {}, + }) async { + final Completer initRegistrationCompleter = Completer(); + + gigyaWebSdk.accounts.initRegistration( + InitRegistrationParameters( + isLite: parameters['isLite'] as bool?, + callback: allowInterop((InitRegistrationResponse response) { + if (initRegistrationCompleter.isCompleted) { + return; + } + + final String regToken = response.regToken ?? ''; + + if (response.errorCode == 0 && regToken.isNotEmpty) { + initRegistrationCompleter.complete(regToken); + } else { + // If the registration token is empty, the next step will fail. + // Abort with an error instead. + initRegistrationCompleter.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + registrationToken: response.regToken, + ), + ); + } + }), + ), + ); + + final String registrationToken = await initRegistrationCompleter.future; + final Map? profile = parameters['profile'] as Map?; + + final Completer> registrationCompleter = Completer>(); + + gigyaWebSdk.accounts.register( + RegistrationParameters( + // Explicitly finalize using the register endpoint. + // This way, calling `finalizeRegistration` is not needed. + finalizeRegistration: true, + regToken: registrationToken, + email: loginId, + password: password, + captchaToken: parameters['captchaToken'] as String?, + include: parameters['include'] as String?, + lang: parameters['lang'] as String?, + profile: profile == null ? null : Profile.fromMap(profile), + regSource: parameters['regSource'] as String?, + secretAnswer: parameters['secretAnswer'] as String?, + secretQuestion: parameters['secretQuestion'] as String?, + sessionExpiration: parameters['sessionExpiration'] as int?, + siteUID: parameters['siteUID'] as String?, + callback: allowInterop((LoginResponse response) { + if (registrationCompleter.isCompleted) { + return; + } + + if (response.errorCode == 0) { + registrationCompleter.complete(response.toMap()); + } else { + registrationCompleter.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + registrationToken: registrationToken, + ), + ); + } + }), + ), + ); + + return registrationCompleter.future; + } } From 58b3b45f19f2aed9559b06c1a1ca0245206afafc Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 12 Apr 2023 09:26:28 +0200 Subject: [PATCH 199/256] implement finalize registration for the web --- .../gigya_flutter_plugin_method_channel.dart | 9 +++++ ...gya_flutter_plugin_platform_interface.dart | 9 +++++ lib/src/web/gigya_flutter_plugin_web.dart | 38 +++++++++++++++++++ lib/src/web/static_interop/account.dart | 6 +++ .../parameters/registration.dart | 19 ++++++++++ 5 files changed, 81 insertions(+) diff --git a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart index 280489ea..ee4441a0 100644 --- a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart +++ b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart @@ -60,6 +60,15 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform { } } + @override + Future> finalizeRegistration( + String registrationToken, { + String? include, + bool allowAccountsLinking = false, + }) { + throw UnsupportedError('Calling finalizeRegistration() is only supported on the web.'); + } + @override Future> forgotPassword(String loginId) async { try { diff --git a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart index d4f9e53c..e20b1c86 100644 --- a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart +++ b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart @@ -57,6 +57,15 @@ abstract class GigyaFlutterPluginPlatform extends PlatformInterface { throw UnimplementedError('addConnection() is not implemented.'); } + /// Finalize a pending registration. + Future> finalizeRegistration( + String registrationToken, { + String? include, + bool allowAccountsLinking = false, + }) { + throw UnimplementedError('finalizeRegistration() is not implemented.'); + } + /// Start the forgot password flow for the given [loginId]. Future> forgotPassword(String loginId) { throw UnimplementedError('forgotPassword() is not implemented.'); diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 33a23e69..965f4a02 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -33,6 +33,44 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return const WebInterruptionResolverFactory(); } + @override + Future> finalizeRegistration( + String registrationToken, { + String? include, + bool allowAccountsLinking = false, + }) { + final Completer> completer = Completer>(); + + gigyaWebSdk.accounts.finalizeRegistration( + FinalizeRegistrationParameters( + allowAccountsLinking: allowAccountsLinking, + include: include, + regToken: registrationToken, + callback: allowInterop((LoginResponse response) { + if (completer.isCompleted) { + return; + } + + if (response.errorCode == 0) { + completer.complete(response.toMap()); + } else { + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + registrationToken: registrationToken, + ), + ); + } + }), + ), + ); + + return completer.future; + } + @override Future initSdk({ required String apiDomain, diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 839d2350..dd75793e 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -12,6 +12,12 @@ import 'parameters/registration.dart'; @JS() @staticInterop extension type Accounts(JSObject _) { + /// Finalize a pending registration. + /// + /// This function receives a [FinalizeRegistrationParameters] instance as argument, + /// and has [JSVoid] as return type. + external JSFunction finalizeRegistration; + /// Get the conflicting accounts of the user. /// /// This function receives a [ConflictingAccountParameters] instance as argument, diff --git a/lib/src/web/static_interop/parameters/registration.dart b/lib/src/web/static_interop/parameters/registration.dart index 439e1488..51a73b8a 100644 --- a/lib/src/web/static_interop/parameters/registration.dart +++ b/lib/src/web/static_interop/parameters/registration.dart @@ -4,6 +4,24 @@ import '../models/profile.dart'; import '../response/login_response.dart'; import '../response/registration_response.dart'; +// TODO: convert registration params to extension types + +/* + +/// This class represents the parameters for the `Accounts.finalizeRegistration` method. +@JS() +@anonymous +@staticInterop +class FinalizeRegistrationParameters { + /// Create a new [FinalizeRegistrationParameters] instance. + external factory FinalizeRegistrationParameters({ + void Function(LoginResponse response) callback, + bool allowAccountsLinking, + String? include, + String regToken, + }); +} + /// This class represents the parameters for the `Accounts.initRegistration` method. @JS() @anonymous @@ -39,3 +57,4 @@ class RegistrationParameters { String? siteUID, }); } +*/ From cfcedc6808e5c61609468fccfcf3345f5bd93f8d Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 09:19:43 +0200 Subject: [PATCH 200/256] fix InitRegistrationResponse static interop definition --- .../response/registration_response.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/response/registration_response.dart b/lib/src/web/static_interop/response/registration_response.dart index bb9ad8f8..5b137895 100644 --- a/lib/src/web/static_interop/response/registration_response.dart +++ b/lib/src/web/static_interop/response/registration_response.dart @@ -1,9 +1,18 @@ +import 'package:js/js.dart'; + import 'response.dart'; /// The static interop class for the Gigya InitRegistration API response. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4136cef070b21014bbc5a10ce4041860.html?locale=en-US#response-example -class InitRegistrationResponse extends Response { +@JS() +@anonymous +@staticInterop +class InitRegistrationResponse extends Response {} + +/// This extension defines the static interop definition +/// for the [InitRegistrationResponse] class. +extension InitRegistrationResponseExtension on InitRegistrationResponse { /// The registration token for the registration. external String? get regToken; } From 5e7ed7c647167d2a485670f26eb0d2da5f22833f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 17:31:48 +0200 Subject: [PATCH 201/256] update profile static interop constructor --- .../web/static_interop/models/profile.dart | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/src/web/static_interop/models/profile.dart b/lib/src/web/static_interop/models/profile.dart index 60b4399f..71de7ac6 100644 --- a/lib/src/web/static_interop/models/profile.dart +++ b/lib/src/web/static_interop/models/profile.dart @@ -32,25 +32,30 @@ extension type Profile._(JSObject _) { String? email, Favorites favorites, String? firstName, - int? followers, - int? following, + int? followersCount, + int? followingCount, String? gender, String? hometown, String? honors, String? industry, String? interests, + bool? isConnected, + bool? isSiteUser, String? languages, String? lastName, JSArray likes, String? locale, + String? loginProvider, + String? loginProviderUID, String? name, String? nickname, JSArray patents, JSArray phones, - String? photoUrl, + String? photoURL, String? politicalView, String? professionalHeadline, - String? profileUrl, + String? profileURL, + JSArray providers, String? proxyEmail, JSArray publications, String? relationshipStatus, @@ -58,7 +63,7 @@ extension type Profile._(JSObject _) { JSArray skills, String? specialities, String? state, - String? thumbnailUrl, + String? thumbnailURL, String? timezone, String? username, String? verified, @@ -84,6 +89,7 @@ extension type Profile._(JSObject _) { map['skills'] as List>? ?? const >[]; final List> work = map['work'] as List>? ?? const >[]; + final List providers = map['providers'] as List? ?? []; return Profile( activities: map['activities'] as String?, @@ -103,25 +109,30 @@ extension type Profile._(JSObject _) { map['favorites'] as Map? ?? const {}, ), firstName: map['firstName'] as String?, - followers: map['followers'] as int?, - following: map['following'] as int?, + followersCount: map['followersCount'] as int?, + followingCount: map['followingCount'] as int?, gender: map['gender'] as String?, hometown: map['hometown'] as String?, honors: map['honors'] as String?, industry: map['industry'] as String?, interests: map['interests'] as String?, + isConnected: map['isConnected'] as bool?, + isSiteUser: map['isSiteUser'] as bool?, languages: map['languages'] as String?, lastName: map['lastName'] as String?, likes: likes.map(Like.fromMap).toList().toJS, locale: map['locale'] as String?, + loginProvider: map['loginProvider'] as String?, + loginProviderUID: map['loginProviderUID'] as String?, name: map['name'] as String?, nickname: map['nickname'] as String?, patents: patents.map(Patent.fromMap).toList().toJS, phones: phones.map(Phone.fromMap).toList().toJS, - photoUrl: map['photoUrl'] as String?, + photoURL: map['photoURL'] as String?, politicalView: map['politicalView'] as String?, professionalHeadline: map['professionalHeadline'] as String?, - profileUrl: map['profileUrl'] as String?, + profileURL: map['profileURL'] as String?, + providers: providers.map((String p) => p.toJS).toList().toJS, proxyEmail: map['proxyEmail'] as String?, publications: publications.map(Publication.fromMap).toList().toJS, relationshipStatus: map['relationshipStatus'] as String?, @@ -129,7 +140,7 @@ extension type Profile._(JSObject _) { skills: skills.map(Skill.fromMap).toList().toJS, specialities: map['specialities'] as String?, state: map['state'] as String?, - thumbnailUrl: map['thumbnailUrl'] as String?, + thumbnailURL: map['thumbnailURL'] as String?, timezone: map['timezone'] as String?, username: map['username'] as String?, verified: map['verified'] as String?, From 3df53ac3c35e653506382882a203f0757a9d497e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 09:18:40 +0200 Subject: [PATCH 202/256] convert registration parameters to extension types --- .../parameters/registration.dart | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/src/web/static_interop/parameters/registration.dart b/lib/src/web/static_interop/parameters/registration.dart index 51a73b8a..d03959bb 100644 --- a/lib/src/web/static_interop/parameters/registration.dart +++ b/lib/src/web/static_interop/parameters/registration.dart @@ -1,47 +1,52 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import '../models/profile.dart'; import '../response/login_response.dart'; import '../response/registration_response.dart'; -// TODO: convert registration params to extension types - -/* - -/// This class represents the parameters for the `Accounts.finalizeRegistration` method. +/// The extension type for the parameters for the `Accounts.finalizeRegistration` method. @JS() @anonymous @staticInterop -class FinalizeRegistrationParameters { +extension type FinalizeRegistrationParameters._(JSObject _) implements JSObject { /// Create a new [FinalizeRegistrationParameters] instance. + /// + /// The [callback] function receives a [LoginResponse] as argument + /// and has [JSVoid] as return type. external factory FinalizeRegistrationParameters({ - void Function(LoginResponse response) callback, + JSFunction callback, bool allowAccountsLinking, String? include, String regToken, }); } -/// This class represents the parameters for the `Accounts.initRegistration` method. +/// The extension type for the parameters for the `Accounts.initRegistration` method. @JS() @anonymous @staticInterop -class InitRegistrationParameters { +extension type InitRegistrationParameters._(JSObject _) implements JSObject { /// Create a new [InitRegistrationParameters] instance. + /// + /// The [callback] function receives a [InitRegistrationResponse] as argument + /// and has [JSVoid] as return type. external factory InitRegistrationParameters({ - void Function(InitRegistrationResponse response) callback, + JSFunction callback, bool? isLite, }); } -/// This class represents the parameters for the `Accounts.registration` method. +/// The extension type for the parameters for the `Accounts.registration` method. @JS() @anonymous @staticInterop -class RegistrationParameters { +extension type RegistrationParameters._(JSObject _) implements JSObject { /// Create a new [RegistrationParameters] instance. + /// + /// The [callback] function receives a [LoginResponse] as argument + /// and has [JSVoid] as return type. external factory RegistrationParameters({ - void Function(LoginResponse response) callback, + JSFunction callback, String? captchaToken, String email, bool finalizeRegistration, @@ -57,4 +62,3 @@ class RegistrationParameters { String? siteUID, }); } -*/ From 7c4c81d871e8c7eb58c3e6f7c691c8ff8f325144 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 09:20:30 +0200 Subject: [PATCH 203/256] convert init registration response to extension type --- .../response/registration_response.dart | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/src/web/static_interop/response/registration_response.dart b/lib/src/web/static_interop/response/registration_response.dart index 5b137895..3d3de1cb 100644 --- a/lib/src/web/static_interop/response/registration_response.dart +++ b/lib/src/web/static_interop/response/registration_response.dart @@ -1,18 +1,14 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import 'response.dart'; -/// The static interop class for the Gigya InitRegistration API response. +/// The extension type for the Gigya InitRegistration API response. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4136cef070b21014bbc5a10ce4041860.html?locale=en-US#response-example @JS() @anonymous @staticInterop -class InitRegistrationResponse extends Response {} - -/// This extension defines the static interop definition -/// for the [InitRegistrationResponse] class. -extension InitRegistrationResponseExtension on InitRegistrationResponse { +extension type InitRegistrationResponse(Response baseResponse) { /// The registration token for the registration. external String? get regToken; -} +} \ No newline at end of file From 8b4f68e5cda7754b96fcbf4997b4c78207a91821 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 14:06:07 +0200 Subject: [PATCH 204/256] add TODO for setAccount --- lib/src/web/web_interruption_resolver.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index 2519c097..8a067728 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -91,4 +91,6 @@ class _LinkAccountResolver extends LinkAccountResolver { class _PendingRegistrationResolver extends PendingRegistrationResolver { const _PendingRegistrationResolver(); + + // TODO: implement set account info & call it here } From 7f9750570bd320e9f307b14141ce5ac6bc3617c4 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 14:07:42 +0200 Subject: [PATCH 205/256] convert accounts.register() to use the extension types --- lib/src/web/gigya_flutter_plugin_web.dart | 105 ++++++++++++---------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 965f4a02..509bad61 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -257,48 +257,51 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { required String password, Map parameters = const {}, }) async { + // TODO: make `initRegistration` public final Completer initRegistrationCompleter = Completer(); - gigyaWebSdk.accounts.initRegistration( + // Start registration by retrieving the regToken. + GigyaWebSdk.instance.accounts.initRegistration.callAsFunction( + null, InitRegistrationParameters( isLite: parameters['isLite'] as bool?, - callback: allowInterop((InitRegistrationResponse response) { - if (initRegistrationCompleter.isCompleted) { - return; - } - - final String regToken = response.regToken ?? ''; - - if (response.errorCode == 0 && regToken.isNotEmpty) { - initRegistrationCompleter.complete(regToken); - } else { - // If the registration token is empty, the next step will fail. - // Abort with an error instead. - initRegistrationCompleter.completeError( - GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - errorCode: response.errorCode, - errorDetails: response.errorDetails, - registrationToken: response.regToken, - ), - ); - } - }), + callback: allowInterop( + (InitRegistrationResponse response) { + if (initRegistrationCompleter.isCompleted) { + return; + } + + if (response.baseResponse.errorCode == 0) { + initRegistrationCompleter.complete(response.regToken ?? ''); + } else { + initRegistrationCompleter.completeError( + GigyaError( + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.baseResponse.details, + errorCode: response.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, ), ); - final String registrationToken = await initRegistrationCompleter.future; - final Map? profile = parameters['profile'] as Map?; + final String regToken = await initRegistrationCompleter.future; - final Completer> registrationCompleter = Completer>(); + final Map? profile = parameters['profile'] as Map?; + final Completer> registrationCompleter = Completer>(); - gigyaWebSdk.accounts.register( + GigyaWebSdk.instance.accounts.register.callAsFunction( + null, RegistrationParameters( // Explicitly finalize using the register endpoint. // This way, calling `finalizeRegistration` is not needed. + // For lite accounts, the `accounts.register` endpoint is never used anyway. + // That flow uses `accounts.initRegistration` and `accounts.setAccountInfo` instead. finalizeRegistration: true, - regToken: registrationToken, + regToken: regToken, email: loginId, password: password, captchaToken: parameters['captchaToken'] as String?, @@ -310,25 +313,31 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { secretQuestion: parameters['secretQuestion'] as String?, sessionExpiration: parameters['sessionExpiration'] as int?, siteUID: parameters['siteUID'] as String?, - callback: allowInterop((LoginResponse response) { - if (registrationCompleter.isCompleted) { - return; - } - - if (response.errorCode == 0) { - registrationCompleter.complete(response.toMap()); - } else { - registrationCompleter.completeError( - GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - errorCode: response.errorCode, - errorDetails: response.errorDetails, - registrationToken: registrationToken, - ), - ); - } - }), + callback: allowInterop( + (LoginResponse response) { + if (registrationCompleter.isCompleted) { + return; + } + + if (response.baseResponse.errorCode == 0) { + registrationCompleter.complete(response.toMap()); + } else { + // The error response does not seem to return the regToken. + // Forward it manually. + registrationCompleter.completeError( + GigyaError( + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: { + ...response.baseResponse.details, + 'regToken': regToken, + }, + errorCode: response.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, ), ); From 85dbed1411fc3ca3f039048163260e7150e39254 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 14:13:34 +0200 Subject: [PATCH 206/256] convert finalizeRegistration to use extension types --- lib/src/web/gigya_flutter_plugin_web.dart | 40 ++++++++++++----------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 509bad61..bcb04115 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -41,30 +41,32 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }) { final Completer> completer = Completer>(); - gigyaWebSdk.accounts.finalizeRegistration( + GigyaWebSdk.instance.accounts.finalizeRegistration.callAsFunction( + null, FinalizeRegistrationParameters( allowAccountsLinking: allowAccountsLinking, include: include, regToken: registrationToken, - callback: allowInterop((LoginResponse response) { - if (completer.isCompleted) { - return; - } + callback: allowInterop( + (LoginResponse response) { + if (completer.isCompleted) { + return; + } - if (response.errorCode == 0) { - completer.complete(response.toMap()); - } else { - completer.completeError( - GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - errorCode: response.errorCode, - errorDetails: response.errorDetails, - registrationToken: registrationToken, - ), - ); - } - }), + if (response.baseResponse.errorCode == 0) { + completer.complete(response.toMap()); + } else { + completer.completeError( + GigyaError( + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.baseResponse.details, + errorCode: response.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, ), ); From 5591e2f4a7da82bcbad68542b0f3a351fcd27f3e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 14:14:59 +0200 Subject: [PATCH 207/256] update a TODO --- lib/src/web/web_interruption_resolver.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index 8a067728..b696e237 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -10,9 +10,8 @@ import 'static_interop/models/conflicting_account.dart'; import 'static_interop/parameters/conflicting_account.dart'; import 'static_interop/response/response.dart'; -// TODO: implement linkToSite & linkToSocial in _StaticInteropLinkAccountResolver -// TODO: return `_StaticInteropLinkAccountResolver` when required -// TODO: implement setAccount in _StaticInteropPendingRegistrationResolver, using `account.setAccountInfo` endpoint +// TODO: implement linkToSite & linkToSocial in _LinkAccountResolver +// TODO: return `_LinkAccountResolver` when required /// This class represents an [InterruptionResolver] /// that uses static interop for its implementation. From 44ca2168f20f29afc15a3d7d2ee536cc8512f903 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 14:30:03 +0200 Subject: [PATCH 208/256] make initRegistration public; skip initRegistration if the token is provided --- ...gya_flutter_plugin_platform_interface.dart | 13 ++++ lib/src/web/gigya_flutter_plugin_web.dart | 71 +++++++++++-------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart index e20b1c86..5fc9e3b3 100644 --- a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart +++ b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart @@ -90,6 +90,19 @@ abstract class GigyaFlutterPluginPlatform extends PlatformInterface { throw UnimplementedError('getSession() is not implemented.'); } + /// Start a registration flow. + /// + /// The [isLite] parameter determines if a full + /// or a lite account registration should be started. + /// + /// This is typically only required for lite accounts, + /// as [register] automatically starts a registration. + Future initRegistration({ + required bool isLite, + }) { + throw UnimplementedError('initRegistration() is not implemented.'); + } + /// Initialize the Gigya SDK with the given [apiKey] and [apiDomain]. /// /// If [forceLogout] is true, the user will be logged out. diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index bcb04115..81a756c5 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -73,6 +73,40 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return completer.future; } + @override + Future initRegistration({required bool isLite}) { + final Completer initRegistrationCompleter = Completer(); + + GigyaWebSdk.instance.accounts.initRegistration.callAsFunction( + null, + InitRegistrationParameters( + isLite: isLite, + callback: allowInterop( + (InitRegistrationResponse response) { + if (initRegistrationCompleter.isCompleted) { + return; + } + + if (response.baseResponse.errorCode == 0) { + initRegistrationCompleter.complete(response.regToken ?? ''); + } else { + initRegistrationCompleter.completeError( + GigyaError( + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.baseResponse.details, + errorCode: response.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, + ), + ); + + return initRegistrationCompleter.future; + } + @override Future initSdk({ required String apiDomain, @@ -259,38 +293,15 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { required String password, Map parameters = const {}, }) async { - // TODO: make `initRegistration` public - final Completer initRegistrationCompleter = Completer(); - // Start registration by retrieving the regToken. - GigyaWebSdk.instance.accounts.initRegistration.callAsFunction( - null, - InitRegistrationParameters( - isLite: parameters['isLite'] as bool?, - callback: allowInterop( - (InitRegistrationResponse response) { - if (initRegistrationCompleter.isCompleted) { - return; - } + // If it was already provided, skip the initRegistration step. + String regToken = parameters['regToken'] as String? ?? ''; - if (response.baseResponse.errorCode == 0) { - initRegistrationCompleter.complete(response.regToken ?? ''); - } else { - initRegistrationCompleter.completeError( - GigyaError( - apiVersion: response.baseResponse.apiVersion, - callId: response.baseResponse.callId, - details: response.baseResponse.details, - errorCode: response.baseResponse.errorCode, - ), - ); - } - }, - ).toJS, - ), - ); - - final String regToken = await initRegistrationCompleter.future; + if (regToken.isEmpty) { + regToken = await initRegistration( + isLite: parameters['isLite'] as bool? ?? false, + ); + } final Map? profile = parameters['profile'] as Map?; final Completer> registrationCompleter = Completer>(); From 86fdcf782ca32ac684497546fabc32314268a4ad Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 29 Sep 2023 14:46:17 +0200 Subject: [PATCH 209/256] add stub for initRegistration in method channel --- .../method_channel/gigya_flutter_plugin_method_channel.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart index ee4441a0..a7d93b47 100644 --- a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart +++ b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart @@ -127,6 +127,11 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform { } } + @override + Future initRegistration({required bool isLite}) { + throw UnsupportedError('Calling initRegistration() is only supported on the web.'); + } + @override Future initSdk({ required String apiDomain, From 0dd5d37e0cefc12fb60d818736601742f54fdca3 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 13:23:49 +0200 Subject: [PATCH 210/256] inline use of profile --- lib/src/models/account.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart index 56c5aeaf..e568b35b 100644 --- a/lib/src/models/account.dart +++ b/lib/src/models/account.dart @@ -137,9 +137,6 @@ class Account { /// Convert this object into a JSON object. Map toJson() { - final Profile? accountProfile = profile; - final SessionInfo? session = sessionInfo; - return { 'created': created?.toIso8601String(), 'data': data, @@ -151,9 +148,9 @@ class Account { 'lastUpdated': lastUpdated?.toIso8601String(), 'loginProvider': loginProvider, 'oldestDataUpdated': oldestDataUpdated?.toIso8601String(), - if (accountProfile != null) 'profile': accountProfile.toJson(), + if (profile != null) 'profile': profile!.toJson(), 'registered': registered?.toIso8601String(), - if (session != null) 'sessionInfo': session.toJson(), + if (sessionInfo != null) 'sessionInfo': sessionInfo!.toJson(), 'signatureTimestamp': signatureTimestamp?.toIso8601String(), 'socialProviders': socialProviders, 'UID': uid, From a12f2c3aee7fa9818a6338726ceb3992dbf9673c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Mon, 9 Oct 2023 10:48:03 +0200 Subject: [PATCH 211/256] bump Dart to version 3.3.0-dev; bump package web to version 0.2.2-beta --- analysis_options.yaml | 2 +- example/pubspec.lock | 6 +++--- pubspec.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 1093cbfd..9d827d7d 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -13,7 +13,7 @@ analyzer: # TODO: remove this once it is no longer an experiment enable-experiment: - - inline-class + - inline-class linter: rules: diff --git a/example/pubspec.lock b/example/pubspec.lock index 768b558e..8b174d1a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -368,10 +368,10 @@ packages: dependency: transitive description: name: web - sha256: "14f1f70c51119012600c5f1f60ca68efda5a9b6077748163c6af2893ec5df8fc" + sha256: ccbbfbf29732ee1b391c4c6d13e7032d851f675f47365e81904e4c6fd669c854 url: "https://pub.dev" source: hosted - version: "0.2.1-beta" + version: "0.2.2-beta" yaml: dependency: transitive description: @@ -381,5 +381,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.0-157.0.dev <4.0.0" + dart: ">=3.3.0-1.0.dev <4.0.0" flutter: ">=3.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6d24389e..b6ae8309 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.1 homepage: https://github.com/SAP/gigya-flutter-plugin environment: - sdk: ">=3.2.0-140.0.dev <4.0.0" + sdk: ">=3.3.0-1.0.dev <4.0.0" flutter: ">=3.10.0" dependencies: @@ -15,7 +15,7 @@ dependencies: js: ">=0.6.6" plugin_platform_interface: ^2.0.2 - web: ^0.2.1-beta + web: ^0.2.2-beta dev_dependencies: flutter_lints: ^2.0.0 From e039a8556970c3f4b70661d537549c5977c52d54 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 12 Apr 2023 16:46:41 +0200 Subject: [PATCH 212/256] implement account login id static interop definition --- .../models/account_login_id.dart | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/src/web/static_interop/models/account_login_id.dart diff --git a/lib/src/web/static_interop/models/account_login_id.dart b/lib/src/web/static_interop/models/account_login_id.dart new file mode 100644 index 00000000..d88ef498 --- /dev/null +++ b/lib/src/web/static_interop/models/account_login_id.dart @@ -0,0 +1,35 @@ +import 'package:js/js.dart'; + +/// The static interop class for the login id of a user. +@JS() +@anonymous +@staticInterop +class AccountLoginId {} + +/// This extension defines the static interop definition +/// for the [AccountLoginId] class. +extension AccountLoginIdExtension on AccountLoginId { + @JS('emails') + external List get _emails; + + @JS('unverifiedEmails') + external List get _unverifiedEmails; + + /// The list of verified email addresses of the user. + List get emails => _emails.cast(); + + /// The username of the user. + external String get username; + + /// The list of unverified email addresses of the user. + List get unverifiedEmails => _unverifiedEmails.cast(); + + /// Convert this object into a map. + Map toMap() { + return { + 'emails': emails, + 'username': username, + 'unverifiedEmails': unverifiedEmails, + }; + } +} From 39f6753b013d158bb3e116c8ea3ab62b03ef0243 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 08:37:07 +0200 Subject: [PATCH 213/256] export account response from response.dart --- lib/src/web/static_interop/response/response.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index 625944b1..5208920f 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -1,5 +1,6 @@ import 'dart:js_interop'; +export 'account_response.dart'; export 'conflicting_account_response.dart'; export 'login_response.dart'; From 1716c4b4b9bf2385761f290688897a423f811339 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 11:49:04 +0200 Subject: [PATCH 214/256] implement base account response; implement account info response --- .../response/account_response.dart | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 lib/src/web/static_interop/response/account_response.dart diff --git a/lib/src/web/static_interop/response/account_response.dart b/lib/src/web/static_interop/response/account_response.dart new file mode 100644 index 00000000..5c100b3f --- /dev/null +++ b/lib/src/web/static_interop/response/account_response.dart @@ -0,0 +1,102 @@ +import 'package:js/js.dart'; + +import '../models/account_login_id.dart'; +import '../models/emails.dart'; +import '../models/location.dart'; +import '../models/profile.dart'; +import 'response.dart'; + +// TODO: preferences, subscriptions should be in `AccountResponse` + +// TODO: make the `BaseAccountResponse` class sealed once Class Modifiers is available + +/// The static interop class for the base account response. +@JS() +@anonymous +@staticInterop +class BaseAccountResponse extends Response {} + +/// This extension defines the static interop definition +/// for the [BaseAccountResponse] class. +extension BaseAccountResponseExtension on BaseAccountResponse { + /// The timestamp of the creation of the user. + external String? get created; + + /// The verified and unverified email addresses of the user. + external Emails? get emails; + + /// Whether the user is active. + external bool? get isActive; + + /// Whether the user is registered. + external bool? get isRegistered; + + /// Whether the user is verified. + external bool? get isVerified; + + /// The timestamp of the last login of the user. + external String? get lastLogin; + + /// The last login location of the user. + external Location? get lastLoginLocation; + + /// The timestamp of the last update to the user's profile, + /// preferences or subscriptions data. + external String? get lastUpdated; + + @JS('loginIDs') + external List? get _loginIds; + + /// The login IDs for the user. + List? get loginIds => _loginIds?.cast(); + + /// The login provider that was last used to log in. + external String? get loginProvider; + + /// The timestamp, when the oldest data of the user was refreshed. + external String? get oldestDataUpdated; + + /// The user's profile. + external Profile? get profile; + + /// The timestamp when the user was registered. + external String? get registered; + + /// The source of the registration. + external String? get regSource; + + /// The timestamp of the [UIDSignature]. + /// This value can be a [String] or a [num]. + external Object? get signatureTimestamp; + + /// The comma separated list of social providers linked to this user. + external String? get socialProviders; + + /// The unique id of this user. + external String? get UID; // ignore: non_constant_identifier_names + + /// The verification signature of the [UID]. + external String? get UIDSignature; // ignore: non_constant_identifier_names + + /// The timestamp when the user was verified. + external String? get verified; +} + +/// The static interop class for the account info response. +@JS() +@anonymous +@staticInterop +class AccountInfoResponse extends BaseAccountResponse {} + +/// This extension defines the static interop definition +/// for the [AccountInfoResponse] class. +extension AccountInfoResponseExtension on AccountInfoResponse { + /// Whether this account is currently in transition. + /// + /// An account that is in transition cannot be modified. + external bool? get inTransition; + + // TODO: add lockedUntil when DateTime static interop is fixed. + // Currently it is not supported, so add a static interop type for the date class + // See: https://github.com/dart-lang/sdk/issues/52021 +} From ac7c2e3e8169d86e59eb7e2ed36dc10d236b6747 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 11:52:04 +0200 Subject: [PATCH 215/256] implement static interop utils --- .../static_interop/static_interop_utils.dart | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 lib/src/web/static_interop/static_interop_utils.dart diff --git a/lib/src/web/static_interop/static_interop_utils.dart b/lib/src/web/static_interop/static_interop_utils.dart new file mode 100644 index 00000000..7d21a0a1 --- /dev/null +++ b/lib/src/web/static_interop/static_interop_utils.dart @@ -0,0 +1,100 @@ +import 'models/account_login_id.dart'; +import 'models/emails.dart'; +import 'models/location.dart'; +import 'models/profile.dart'; +import 'models/session_info.dart'; +import 'response/response.dart'; + +// TODO: convert this class to an `abstract final class` once Class Modifiers are available. + +/// This class represents a namespace with utilities for static JS interop. +abstract class StaticInteropUtils { + /// Convert a [BaseAccountResponse] (or one of its subclasses) to a map. + static Map _accountResponseToMap( + BaseAccountResponse response, + ) { + Map? accountInfo; + Map? loginInfo; + + final Map? profileAsMap = response.profile?.toMap(); + + if (profileAsMap != null) { + // The lastLoginLocation field is not in the profile + // when using the Gigya Web SDK. + // Instead, it is located inside the login response. + // Add it to the profile map. + profileAsMap['lastLoginLocation'] = response.lastLoginLocation?.toMap(); + } + + // TODO: once `BaseAccountResponse` is sealed, use a switch here + + if (response is AccountInfoResponse) { + accountInfo = { + 'inTransition': response.inTransition, + }; + } + + if (response is LoginResponse) { + final SessionInfo? sessionInfo = response.sessionInfo; + + loginInfo = { + 'isNewUser': response.isNewUser, + 'regToken': response.regToken, + if (sessionInfo != null) + 'sessionInfo': { + 'cookieName': sessionInfo.cookieName, + 'cookieValue': sessionInfo.cookieValue, + }, + }; + } + + // First, add the base `BaseAccountResponse` fields. + return { + 'created': response.created, + if (response.emails != null) + 'emails': { + 'unverified': response.emails!.unverified, + 'verified': response.emails!.verified, + }, + 'isActive': response.isActive, + 'isRegistered': response.isRegistered, + 'isVerified': response.isVerified, + 'lastLogin': response.lastLogin, + 'lastUpdated': response.lastUpdated, + if (response.loginIds != null) 'loginIDs': response.loginIds!.map((AccountLoginId l) => l.toMap()).toList(), + 'loginProvider': response.loginProvider, + 'oldestDataUpdated': response.oldestDataUpdated, + if (profileAsMap != null) 'profile': profileAsMap, + 'registered': response.registered, + 'regSource': response.regSource, + 'signatureTimestamp': response.signatureTimestamp, + 'socialProviders': response.socialProviders, + 'UID': response.UID, + 'UIDSignature': response.UIDSignature, + 'verified': response.verified, + // Then amend the specific fields per subclass. + if (accountInfo != null) ...accountInfo, + if (loginInfo != null) ...loginInfo, + }; + } + + /// Convert the given [response] to a [Map]. + /// + /// Since methods that are defined in an extension cannot be overridden + /// (because extensions are resolved against their static type), + /// the [Response] class cannot define an overridable `toMap()` function. + /// + /// See: https://dart.dev/language/extension-methods#static-types-and-dynamic + static Map responseToMap(T response) { + // First, add the base `Response` fields. + return { + 'apiVersion': response.apiVersion, + 'callId': response.callId, + 'errorCode': response.errorCode, + 'errorDetails': response.errorDetails, + 'errorMessage': response.errorDetails, + // Then amend the specific fields per subclass. + if (response is BaseAccountResponse) ..._accountResponseToMap(response), + }; + } +} From 4d8f232f56c5c6ee138b97c695ad9b16a02bee1b Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 11:53:55 +0200 Subject: [PATCH 216/256] use utils to serialize login response --- .../static_interop/static_interop_utils.dart | 100 ------------------ 1 file changed, 100 deletions(-) delete mode 100644 lib/src/web/static_interop/static_interop_utils.dart diff --git a/lib/src/web/static_interop/static_interop_utils.dart b/lib/src/web/static_interop/static_interop_utils.dart deleted file mode 100644 index 7d21a0a1..00000000 --- a/lib/src/web/static_interop/static_interop_utils.dart +++ /dev/null @@ -1,100 +0,0 @@ -import 'models/account_login_id.dart'; -import 'models/emails.dart'; -import 'models/location.dart'; -import 'models/profile.dart'; -import 'models/session_info.dart'; -import 'response/response.dart'; - -// TODO: convert this class to an `abstract final class` once Class Modifiers are available. - -/// This class represents a namespace with utilities for static JS interop. -abstract class StaticInteropUtils { - /// Convert a [BaseAccountResponse] (or one of its subclasses) to a map. - static Map _accountResponseToMap( - BaseAccountResponse response, - ) { - Map? accountInfo; - Map? loginInfo; - - final Map? profileAsMap = response.profile?.toMap(); - - if (profileAsMap != null) { - // The lastLoginLocation field is not in the profile - // when using the Gigya Web SDK. - // Instead, it is located inside the login response. - // Add it to the profile map. - profileAsMap['lastLoginLocation'] = response.lastLoginLocation?.toMap(); - } - - // TODO: once `BaseAccountResponse` is sealed, use a switch here - - if (response is AccountInfoResponse) { - accountInfo = { - 'inTransition': response.inTransition, - }; - } - - if (response is LoginResponse) { - final SessionInfo? sessionInfo = response.sessionInfo; - - loginInfo = { - 'isNewUser': response.isNewUser, - 'regToken': response.regToken, - if (sessionInfo != null) - 'sessionInfo': { - 'cookieName': sessionInfo.cookieName, - 'cookieValue': sessionInfo.cookieValue, - }, - }; - } - - // First, add the base `BaseAccountResponse` fields. - return { - 'created': response.created, - if (response.emails != null) - 'emails': { - 'unverified': response.emails!.unverified, - 'verified': response.emails!.verified, - }, - 'isActive': response.isActive, - 'isRegistered': response.isRegistered, - 'isVerified': response.isVerified, - 'lastLogin': response.lastLogin, - 'lastUpdated': response.lastUpdated, - if (response.loginIds != null) 'loginIDs': response.loginIds!.map((AccountLoginId l) => l.toMap()).toList(), - 'loginProvider': response.loginProvider, - 'oldestDataUpdated': response.oldestDataUpdated, - if (profileAsMap != null) 'profile': profileAsMap, - 'registered': response.registered, - 'regSource': response.regSource, - 'signatureTimestamp': response.signatureTimestamp, - 'socialProviders': response.socialProviders, - 'UID': response.UID, - 'UIDSignature': response.UIDSignature, - 'verified': response.verified, - // Then amend the specific fields per subclass. - if (accountInfo != null) ...accountInfo, - if (loginInfo != null) ...loginInfo, - }; - } - - /// Convert the given [response] to a [Map]. - /// - /// Since methods that are defined in an extension cannot be overridden - /// (because extensions are resolved against their static type), - /// the [Response] class cannot define an overridable `toMap()` function. - /// - /// See: https://dart.dev/language/extension-methods#static-types-and-dynamic - static Map responseToMap(T response) { - // First, add the base `Response` fields. - return { - 'apiVersion': response.apiVersion, - 'callId': response.callId, - 'errorCode': response.errorCode, - 'errorDetails': response.errorDetails, - 'errorMessage': response.errorDetails, - // Then amend the specific fields per subclass. - if (response is BaseAccountResponse) ..._accountResponseToMap(response), - }; - } -} From 3f47d8c713be19e7bd8c04b3cd53165bc1c87069 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 11:58:31 +0200 Subject: [PATCH 217/256] rename account parameters interop file --- .../parameters/{conflicting_account.dart => account.dart} | 0 lib/src/web/web_interruption_resolver.dart | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/src/web/static_interop/parameters/{conflicting_account.dart => account.dart} (100%) diff --git a/lib/src/web/static_interop/parameters/conflicting_account.dart b/lib/src/web/static_interop/parameters/account.dart similarity index 100% rename from lib/src/web/static_interop/parameters/conflicting_account.dart rename to lib/src/web/static_interop/parameters/account.dart diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index b696e237..70cd476d 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -7,7 +7,7 @@ import '../models/gigya_error.dart'; import '../services/interruption_resolver.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/models/conflicting_account.dart'; -import 'static_interop/parameters/conflicting_account.dart'; +import 'static_interop/parameters/account.dart'; import 'static_interop/response/response.dart'; // TODO: implement linkToSite & linkToSocial in _LinkAccountResolver From 1112ccd35f2a28af4d9b31a1ba78b99aca5a9e2a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 12:02:19 +0200 Subject: [PATCH 218/256] implement get account parameters; add getAccountInfo static interop definition --- lib/src/web/static_interop/account.dart | 8 +++++++- .../web/static_interop/parameters/account.dart | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index dd75793e..61370bdb 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -1,8 +1,8 @@ import 'dart:js_interop'; import './session.dart'; +import 'parameters/account.dart'; import 'parameters/basic.dart'; -import 'parameters/conflicting_account.dart'; import 'parameters/login.dart'; import 'parameters/registration.dart'; @@ -18,6 +18,12 @@ extension type Accounts(JSObject _) { /// and has [JSVoid] as return type. external JSFunction finalizeRegistration; + /// Get the account info of a user. + /// + /// This function receives a [GetAccountParameters] instance as argument, + /// and has [JSVoid] as return type. + external JSFunction getAccountInfo; + /// Get the conflicting accounts of the user. /// /// This function receives a [ConflictingAccountParameters] instance as argument, diff --git a/lib/src/web/static_interop/parameters/account.dart b/lib/src/web/static_interop/parameters/account.dart index 5ba720d6..033497c9 100644 --- a/lib/src/web/static_interop/parameters/account.dart +++ b/lib/src/web/static_interop/parameters/account.dart @@ -1,6 +1,6 @@ import 'dart:js_interop'; -import '../response/conflicting_account_response.dart'; +import '../response/response.dart'; /// This extension type represents the parameters for the `Accounts.getConflictingAccount` method. @JS() @@ -16,3 +16,19 @@ extension type ConflictingAccountParameters._(JSObject _) implements JSObject { String regToken, }); } + +/// This extension type represents the parameters for the `Accounts.getAccountInfo` method. +@JS() +@anonymous +@staticInterop +extension type GetAccountParameters._(JSObject _) implements JSObject { + /// Create a [GetAccountParameters] instance. + /// + /// The [callback] receives an [AccountInfoResponse] as argument, + /// and has [JSVoid] as return type. + external factory GetAccountParameters({ + JSFunction callback, + String? extraProfileFields, + String? include, + }); +} From a6540a495b0dfcf26bd06297e70fbde586471d02 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 12:23:14 +0200 Subject: [PATCH 219/256] implement get account info --- lib/src/web/gigya_flutter_plugin_web.dart | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 81a756c5..07a1b71d 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -11,6 +11,7 @@ import '../services/interruption_resolver.dart'; import 'enums/web_error_code.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/models/profile.dart'; +import 'static_interop/parameters/account.dart'; import 'static_interop/parameters/basic.dart'; import 'static_interop/parameters/login.dart'; import 'static_interop/parameters/registration.dart'; @@ -107,6 +108,41 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return initRegistrationCompleter.future; } + @override + Future> getAccount({ + bool invalidate = false, + Map parameters = const {}, + }) async { + final Completer> completer = Completer>(); + + gigyaWebSdk.accounts.getAccountInfo( + GetAccountParameters( + extraProfileFields: parameters['extraProfileFields'] as String?, + include: parameters['include'] as String?, + callback: allowInterop((AccountInfoResponse response) { + if (completer.isCompleted) { + return; + } + + if (response.errorCode == 0) { + completer.complete(StaticInteropUtils.responseToMap(response)); + } else { + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + ), + ); + } + }), + ), + ); + + return completer.future; + } + @override Future initSdk({ required String apiDomain, From 1725eb58d288ffaf6c7159f6107485616b8255dc Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 12:35:36 +0200 Subject: [PATCH 220/256] implement set account parameters --- .../static_interop/parameters/account.dart | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/src/web/static_interop/parameters/account.dart b/lib/src/web/static_interop/parameters/account.dart index 033497c9..e8f2cbd3 100644 --- a/lib/src/web/static_interop/parameters/account.dart +++ b/lib/src/web/static_interop/parameters/account.dart @@ -1,5 +1,6 @@ import 'dart:js_interop'; +import '../models/profile.dart'; import '../response/response.dart'; /// This extension type represents the parameters for the `Accounts.getConflictingAccount` method. @@ -32,3 +33,25 @@ extension type GetAccountParameters._(JSObject _) implements JSObject { String? include, }); } + +/// This extension type represents the parameters for the `Accounts.setAccountInfo` method. +@JS() +@anonymous +@staticInterop +extension type SetAccountParameters._(JSObject _) implements JSObject { + // TODO: add preferences and subscriptions object once the static interop definition is ready + + /// Create a [SetAccountParameters] instance. + external factory SetAccountParameters({ + String? addLoginEmails, + String? conflictHandling, + String? newPassword, + String? password, + Profile? profile, + String? removeLoginEmails, + bool? requirePasswordChange, + String? secretAnswer, + String? secretQuestion, + String? username, + }); +} From edf9a7dbe68caebc7f992e90169c143f4dc38717 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 12:46:48 +0200 Subject: [PATCH 221/256] implement validation error static interop type --- .../models/validation_error.dart | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/src/web/static_interop/models/validation_error.dart diff --git a/lib/src/web/static_interop/models/validation_error.dart b/lib/src/web/static_interop/models/validation_error.dart new file mode 100644 index 00000000..1f3e6a58 --- /dev/null +++ b/lib/src/web/static_interop/models/validation_error.dart @@ -0,0 +1,31 @@ +import 'package:js/js.dart'; + +/// The static interop class for the validation error object. +@JS() +@anonymous +@staticInterop +class ValidationError {} + +/// This extension defines the static interop definition +/// for the [ValidationError] class. +extension ValidationErrorExtension on ValidationError { + /// The validation error code. + external int get errorCode; + + /// The name of the field that caused the validation error. + /// + /// This field name uses dot notation, i.e. `profile.name`. + external String get fieldName; + + /// The validation error message. + external String get message; + + /// COnvert this validation error message to a map. + Map toMap() { + return { + 'errorCode': errorCode, + 'fieldName': fieldName, + 'message': message, + }; + } +} From 0962cb96b9f87e608611f459b11f380b33a29aaa Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 12:48:44 +0200 Subject: [PATCH 222/256] implement set account response --- .../response/set_account_response.dart | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/src/web/static_interop/response/set_account_response.dart diff --git a/lib/src/web/static_interop/response/set_account_response.dart b/lib/src/web/static_interop/response/set_account_response.dart new file mode 100644 index 00000000..e51aec2e --- /dev/null +++ b/lib/src/web/static_interop/response/set_account_response.dart @@ -0,0 +1,22 @@ +import 'package:js/js.dart'; + +import '../models/validation_error.dart'; +import 'response.dart'; + +/// /// The static interop class for the Gigya Set Account API response. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4139777d70b21014bbc5a10ce4041860.html?locale=en-US#response-object-data-members +@JS() +@anonymous +@staticInterop +class SetAccountResponse extends Response {} + +/// This extension defines the static interop definition +/// for the [SetAccountResponse] class. +extension SetAccountResponseExtension on SetAccountResponse { + @JS('validationErrors') + external List get _validationErrors; + + /// The validation errors for the set account payload. + List get validationErrors => _validationErrors.cast(); +} From a9afb4c4ab8ddcfcc748e952074f02fcb280cec6 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 12:51:31 +0200 Subject: [PATCH 223/256] add callback to set account info --- lib/src/web/static_interop/parameters/account.dart | 1 + lib/src/web/static_interop/response/response.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/src/web/static_interop/parameters/account.dart b/lib/src/web/static_interop/parameters/account.dart index e8f2cbd3..6ec1fa6e 100644 --- a/lib/src/web/static_interop/parameters/account.dart +++ b/lib/src/web/static_interop/parameters/account.dart @@ -44,6 +44,7 @@ extension type SetAccountParameters._(JSObject _) implements JSObject { /// Create a [SetAccountParameters] instance. external factory SetAccountParameters({ String? addLoginEmails, + void Function(SetAccountResponse response) callback, String? conflictHandling, String? newPassword, String? password, diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index 5208920f..a1512b10 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -3,6 +3,7 @@ import 'dart:js_interop'; export 'account_response.dart'; export 'conflicting_account_response.dart'; export 'login_response.dart'; +export 'set_account_response.dart'; /// The extension type for the Gigya `Response` class. /// From 3046bc6d27d8e38c9102e636f059c0d5054c3e2c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 12:52:42 +0200 Subject: [PATCH 224/256] add set account info function static interop definition --- lib/src/web/static_interop/account.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 61370bdb..a4b268ff 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -56,4 +56,7 @@ extension type Accounts(JSObject _) { /// Get the `gigya.accounts.session` namespace. external Session get session; + + /// Update the user's account info. + external void Function(SetAccountParameters parameters) setAccountInfo; } From 781e25d0ef50d68bd8d52f50c823cc10425a700c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 13:28:15 +0200 Subject: [PATCH 225/256] implement set account --- lib/src/web/gigya_flutter_plugin_web.dart | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 07a1b71d..e9d65fa2 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -392,4 +392,46 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return registrationCompleter.future; } + + @override + Future> setAccount(Map account) { + final Completer> completer = Completer>(); + + final Map? profile = account['profile'] as Map?; + + gigyaWebSdk.accounts.setAccountInfo( + SetAccountParameters( + addLoginEmails: account['addLoginEmails'] as String?, + conflictHandling: account['conflictHandling'] as String?, + newPassword: account['newPassword'] as String?, + password: account['password'] as String?, + profile: profile == null ? null : Profile.fromMap(profile), + removeLoginEmails: account['removeLoginEmails'] as String?, + requirePasswordChange: account['requirePasswordChange'] as bool?, + secretAnswer: account['secretAnswer'] as String?, + secretQuestion: account['secretQuestion'] as String?, + username: account['username'] as String?, + callback: allowInterop((SetAccountResponse response) { + if (completer.isCompleted) { + return; + } + + if (response.errorCode == 0) { + completer.complete(StaticInteropUtils.responseToMap(response)); + } else { + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + ), + ); + } + }), + ), + ); + + return completer.future; + } } From 54d5e6de7c6e45c911e483650a99638392d53cbf Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 08:55:52 +0200 Subject: [PATCH 226/256] fix typo --- lib/src/web/static_interop/response/set_account_response.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/response/set_account_response.dart b/lib/src/web/static_interop/response/set_account_response.dart index e51aec2e..21a75da7 100644 --- a/lib/src/web/static_interop/response/set_account_response.dart +++ b/lib/src/web/static_interop/response/set_account_response.dart @@ -3,7 +3,7 @@ import 'package:js/js.dart'; import '../models/validation_error.dart'; import 'response.dart'; -/// /// The static interop class for the Gigya Set Account API response. +/// The static interop class for the Gigya Set Account API response. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4139777d70b21014bbc5a10ce4041860.html?locale=en-US#response-object-data-members @JS() From c339103ff03068244564db1bee678b09a1202108 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 13:09:07 +0200 Subject: [PATCH 227/256] add data field to account info using dartify rather than static interop definition --- .../static_interop/response/account_response.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/src/web/static_interop/response/account_response.dart b/lib/src/web/static_interop/response/account_response.dart index 5c100b3f..0c2f96db 100644 --- a/lib/src/web/static_interop/response/account_response.dart +++ b/lib/src/web/static_interop/response/account_response.dart @@ -1,4 +1,5 @@ import 'package:js/js.dart'; +import 'package:js/js_util.dart'; import '../models/account_login_id.dart'; import '../models/emails.dart'; @@ -22,6 +23,19 @@ extension BaseAccountResponseExtension on BaseAccountResponse { /// The timestamp of the creation of the user. external String? get created; + @JS('data') + external Object? get _data; + + /// The custom user data that is not part of the [profile]. + /// + /// Any [List] or [Map] values within this map will have `Object?` as type argument(s). + Map? get data { + // The underlying structure of `data` is a flexible, user-defined definition + // and does not fit within a specific static interop definition. + // Instead use `dartify` to convert the Javascript Object into a Map. + return (dartify(_data) as Map?)?.cast(); + } + /// The verified and unverified email addresses of the user. external Emails? get emails; From 68fb82d54470fab097366bd1eb1841161bcdef14 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 28 Apr 2023 11:59:27 +0200 Subject: [PATCH 228/256] add data argument to set account; jsify the data object from the parameters map --- lib/src/web/gigya_flutter_plugin_web.dart | 2 ++ lib/src/web/static_interop/parameters/account.dart | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index e9d65fa2..c725cfe3 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -398,11 +398,13 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { final Completer> completer = Completer>(); final Map? profile = account['profile'] as Map?; + final Map? data = account['data'] as Map?; gigyaWebSdk.accounts.setAccountInfo( SetAccountParameters( addLoginEmails: account['addLoginEmails'] as String?, conflictHandling: account['conflictHandling'] as String?, + data: data.jsify(), newPassword: account['newPassword'] as String?, password: account['password'] as String?, profile: profile == null ? null : Profile.fromMap(profile), diff --git a/lib/src/web/static_interop/parameters/account.dart b/lib/src/web/static_interop/parameters/account.dart index 6ec1fa6e..739cc553 100644 --- a/lib/src/web/static_interop/parameters/account.dart +++ b/lib/src/web/static_interop/parameters/account.dart @@ -42,10 +42,14 @@ extension type SetAccountParameters._(JSObject _) implements JSObject { // TODO: add preferences and subscriptions object once the static interop definition is ready /// Create a [SetAccountParameters] instance. + /// + /// The [callback] receives a [SetAccountResponse] as argument, + /// and has [JSVoid] as return type. external factory SetAccountParameters({ String? addLoginEmails, - void Function(SetAccountResponse response) callback, + JSFunction callback, String? conflictHandling, + JSAny? data, String? newPassword, String? password, Profile? profile, From ad5fdef104038f46df31537cd0f59accbf3360e9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 15:06:39 +0200 Subject: [PATCH 229/256] fix function handle for setAccount --- lib/src/web/static_interop/account.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index a4b268ff..4fc79b59 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -58,5 +58,8 @@ extension type Accounts(JSObject _) { external Session get session; /// Update the user's account info. - external void Function(SetAccountParameters parameters) setAccountInfo; + /// + /// This function receives a [SetAccountParameters] instance as argument, + /// and has [JSVoid] as return type. + external JSFunction setAccountInfo; } From de8ff8ca9a25bca015db983c26176996c83ba833 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 15:12:42 +0200 Subject: [PATCH 230/256] convert account login id to extension type --- .../models/account_login_id.dart | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/src/web/static_interop/models/account_login_id.dart b/lib/src/web/static_interop/models/account_login_id.dart index d88ef498..3bdd652f 100644 --- a/lib/src/web/static_interop/models/account_login_id.dart +++ b/lib/src/web/static_interop/models/account_login_id.dart @@ -1,35 +1,31 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the login id of a user. +/// The extension type for the login id of a user. @JS() @anonymous @staticInterop -class AccountLoginId {} - -/// This extension defines the static interop definition -/// for the [AccountLoginId] class. -extension AccountLoginIdExtension on AccountLoginId { +extension type AccountLoginId(JSObject _) { @JS('emails') - external List get _emails; + external JSArray get _emails; @JS('unverifiedEmails') - external List get _unverifiedEmails; + external JSArray get _unverifiedEmails; /// The list of verified email addresses of the user. - List get emails => _emails.cast(); - - /// The username of the user. - external String get username; + List get emails => _emails.toDart.cast(); /// The list of unverified email addresses of the user. - List get unverifiedEmails => _unverifiedEmails.cast(); + List get unverifiedEmails => _unverifiedEmails.toDart.cast(); + + /// The username of the user. + external String? get username; /// Convert this object into a map. Map toMap() { return { 'emails': emails, - 'username': username, 'unverifiedEmails': unverifiedEmails, + 'username': username, }; } } From f1e2dd891b5cb617118f426bbfe1fbf542fb4be0 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 15:19:32 +0200 Subject: [PATCH 231/256] convert validation error to extension type --- .../web/static_interop/models/validation_error.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/models/validation_error.dart b/lib/src/web/static_interop/models/validation_error.dart index 1f3e6a58..8559c22a 100644 --- a/lib/src/web/static_interop/models/validation_error.dart +++ b/lib/src/web/static_interop/models/validation_error.dart @@ -1,14 +1,10 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; -/// The static interop class for the validation error object. +/// The extensino type for the validation error object. @JS() @anonymous @staticInterop -class ValidationError {} - -/// This extension defines the static interop definition -/// for the [ValidationError] class. -extension ValidationErrorExtension on ValidationError { +extension type ValidationError(JSObject _) { /// The validation error code. external int get errorCode; From 04ed940a8e2cd27652ffe887535d109395143e26 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 15:53:28 +0200 Subject: [PATCH 232/256] refactor base account response to extension type; rename account info response to get account response --- .../static_interop/parameters/account.dart | 2 +- .../response/account_response.dart | 77 +++++++++++-------- 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/lib/src/web/static_interop/parameters/account.dart b/lib/src/web/static_interop/parameters/account.dart index 739cc553..ff8d4eb2 100644 --- a/lib/src/web/static_interop/parameters/account.dart +++ b/lib/src/web/static_interop/parameters/account.dart @@ -25,7 +25,7 @@ extension type ConflictingAccountParameters._(JSObject _) implements JSObject { extension type GetAccountParameters._(JSObject _) implements JSObject { /// Create a [GetAccountParameters] instance. /// - /// The [callback] receives an [AccountInfoResponse] as argument, + /// The [callback] receives a [GetAccountResponse] as argument, /// and has [JSVoid] as return type. external factory GetAccountParameters({ JSFunction callback, diff --git a/lib/src/web/static_interop/response/account_response.dart b/lib/src/web/static_interop/response/account_response.dart index 0c2f96db..8cbedd1d 100644 --- a/lib/src/web/static_interop/response/account_response.dart +++ b/lib/src/web/static_interop/response/account_response.dart @@ -1,5 +1,4 @@ -import 'package:js/js.dart'; -import 'package:js/js_util.dart'; +import 'dart:js_interop'; import '../models/account_login_id.dart'; import '../models/emails.dart'; @@ -9,32 +8,16 @@ import 'response.dart'; // TODO: preferences, subscriptions should be in `AccountResponse` -// TODO: make the `BaseAccountResponse` class sealed once Class Modifiers is available - -/// The static interop class for the base account response. +/// The extension type for the account response. @JS() @anonymous @staticInterop -class BaseAccountResponse extends Response {} - -/// This extension defines the static interop definition -/// for the [BaseAccountResponse] class. -extension BaseAccountResponseExtension on BaseAccountResponse { +extension type AccountResponse(Response baseResponse) { /// The timestamp of the creation of the user. external String? get created; - @JS('data') - external Object? get _data; - /// The custom user data that is not part of the [profile]. - /// - /// Any [List] or [Map] values within this map will have `Object?` as type argument(s). - Map? get data { - // The underlying structure of `data` is a flexible, user-defined definition - // and does not fit within a specific static interop definition. - // Instead use `dartify` to convert the Javascript Object into a Map. - return (dartify(_data) as Map?)?.cast(); - } + external JSAny? get data; /// The verified and unverified email addresses of the user. external Emails? get emails; @@ -59,10 +42,12 @@ extension BaseAccountResponseExtension on BaseAccountResponse { external String? get lastUpdated; @JS('loginIDs') - external List? get _loginIds; + external JSArray? get _loginIds; /// The login IDs for the user. - List? get loginIds => _loginIds?.cast(); + List? get loginIds { + return _loginIds?.toDart.cast(); + } /// The login provider that was last used to log in. external String? get loginProvider; @@ -80,8 +65,7 @@ extension BaseAccountResponseExtension on BaseAccountResponse { external String? get regSource; /// The timestamp of the [UIDSignature]. - /// This value can be a [String] or a [num]. - external Object? get signatureTimestamp; + external String? get signatureTimestamp; /// The comma separated list of social providers linked to this user. external String? get socialProviders; @@ -94,17 +78,40 @@ extension BaseAccountResponseExtension on BaseAccountResponse { /// The timestamp when the user was verified. external String? get verified; + + /// Convert this response to a [Map]. + Map toMap() { + return { + 'created': created, + 'data': data.dartify(), + 'emails': emails?.toMap(), + 'isActive': isActive, + 'isRegistered': isRegistered, + 'isVerified': isVerified, + 'lastLogin': lastLogin, + 'lastLoginLocation': lastLoginLocation?.toMap(), + 'lastUpdated': lastUpdated, + if (loginIds != null) + 'loginIds': loginIds!.map((AccountLoginId id) => id.toMap()).toList(), + 'loginProvider': loginProvider, + 'oldestDataUpdated': oldestDataUpdated, + 'profile': profile?.toMap(), + 'registered': registered, + 'regSource': regSource, + 'signatureTimestamp': signatureTimestamp, + 'socialProviders': socialProviders, + 'UID': UID, + 'UIDSignature': UIDSignature, + 'verified': verified, + }; + } } -/// The static interop class for the account info response. +/// The extension type for the get account response. @JS() @anonymous @staticInterop -class AccountInfoResponse extends BaseAccountResponse {} - -/// This extension defines the static interop definition -/// for the [AccountInfoResponse] class. -extension AccountInfoResponseExtension on AccountInfoResponse { +extension type GetAccountResponse(AccountResponse baseResponse) { /// Whether this account is currently in transition. /// /// An account that is in transition cannot be modified. @@ -113,4 +120,12 @@ extension AccountInfoResponseExtension on AccountInfoResponse { // TODO: add lockedUntil when DateTime static interop is fixed. // Currently it is not supported, so add a static interop type for the date class // See: https://github.com/dart-lang/sdk/issues/52021 + + /// Convert this response to a [Map]. + Map toMap() { + return { + ...baseResponse.toMap(), + 'inTransition': inTransition, + }; + } } From 1fffc33af6bb3fcb2915f7cefcb109f45c0b2cb1 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 16:01:08 +0200 Subject: [PATCH 233/256] move set account response to account_reponse.dart & convert to extension type --- .../response/account_response.dart | 24 +++++++++++++++++++ .../web/static_interop/response/response.dart | 1 - .../response/set_account_response.dart | 22 ----------------- 3 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 lib/src/web/static_interop/response/set_account_response.dart diff --git a/lib/src/web/static_interop/response/account_response.dart b/lib/src/web/static_interop/response/account_response.dart index 8cbedd1d..baf667a0 100644 --- a/lib/src/web/static_interop/response/account_response.dart +++ b/lib/src/web/static_interop/response/account_response.dart @@ -4,6 +4,7 @@ import '../models/account_login_id.dart'; import '../models/emails.dart'; import '../models/location.dart'; import '../models/profile.dart'; +import '../models/validation_error.dart'; import 'response.dart'; // TODO: preferences, subscriptions should be in `AccountResponse` @@ -129,3 +130,26 @@ extension type GetAccountResponse(AccountResponse baseResponse) { }; } } + +/// The extension type for the Gigya Set Account API response. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4139777d70b21014bbc5a10ce4041860.html?locale=en-US#response-object-data-members +@JS() +@anonymous +@staticInterop +extension type SetAccountResponse(Response baseResponse) { + @JS('validationErrors') + external JSArray? get _validationErrors; + + /// The validation errors for the set account payload. + List get validationErrors { + return _validationErrors?.toDart.cast() ?? const []; + } + + /// Convert this response to a [Map]. + Map toMap() { + return { + 'validationErrors': validationErrors.map((ValidationError e) => e.toMap()).toList(), + }; + } +} diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index a1512b10..5208920f 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -3,7 +3,6 @@ import 'dart:js_interop'; export 'account_response.dart'; export 'conflicting_account_response.dart'; export 'login_response.dart'; -export 'set_account_response.dart'; /// The extension type for the Gigya `Response` class. /// diff --git a/lib/src/web/static_interop/response/set_account_response.dart b/lib/src/web/static_interop/response/set_account_response.dart deleted file mode 100644 index 21a75da7..00000000 --- a/lib/src/web/static_interop/response/set_account_response.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:js/js.dart'; - -import '../models/validation_error.dart'; -import 'response.dart'; - -/// The static interop class for the Gigya Set Account API response. -/// -/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4139777d70b21014bbc5a10ce4041860.html?locale=en-US#response-object-data-members -@JS() -@anonymous -@staticInterop -class SetAccountResponse extends Response {} - -/// This extension defines the static interop definition -/// for the [SetAccountResponse] class. -extension SetAccountResponseExtension on SetAccountResponse { - @JS('validationErrors') - external List get _validationErrors; - - /// The validation errors for the set account payload. - List get validationErrors => _validationErrors.cast(); -} From ef6862f41e7a88b1d0ba2b5bba41af749613892c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 16:27:42 +0200 Subject: [PATCH 234/256] fix getAccount to use extension types --- lib/src/web/gigya_flutter_plugin_web.dart | 39 ++++++++++--------- .../response/account_response.dart | 4 +- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index c725cfe3..eef36e4f 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -115,28 +115,31 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }) async { final Completer> completer = Completer>(); - gigyaWebSdk.accounts.getAccountInfo( + GigyaWebSdk.instance.accounts.getAccountInfo.callAsFunction( + null, GetAccountParameters( extraProfileFields: parameters['extraProfileFields'] as String?, include: parameters['include'] as String?, - callback: allowInterop((AccountInfoResponse response) { - if (completer.isCompleted) { - return; - } + callback: allowInterop( + (GetAccountResponse response) { + if (completer.isCompleted) { + return; + } - if (response.errorCode == 0) { - completer.complete(StaticInteropUtils.responseToMap(response)); - } else { - completer.completeError( - GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - errorCode: response.errorCode, - errorDetails: response.errorDetails, - ), - ); - } - }), + if (response.accountResponse.baseResponse.errorCode == 0) { + completer.complete(response.toMap()); + } else { + completer.completeError( + GigyaError( + apiVersion: response.accountResponse.baseResponse.apiVersion, + callId: response.accountResponse.baseResponse.callId, + details: response.accountResponse.baseResponse.details, + errorCode: response.accountResponse.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, ), ); diff --git a/lib/src/web/static_interop/response/account_response.dart b/lib/src/web/static_interop/response/account_response.dart index baf667a0..0bd2f136 100644 --- a/lib/src/web/static_interop/response/account_response.dart +++ b/lib/src/web/static_interop/response/account_response.dart @@ -112,7 +112,7 @@ extension type AccountResponse(Response baseResponse) { @JS() @anonymous @staticInterop -extension type GetAccountResponse(AccountResponse baseResponse) { +extension type GetAccountResponse(AccountResponse accountResponse) { /// Whether this account is currently in transition. /// /// An account that is in transition cannot be modified. @@ -125,7 +125,7 @@ extension type GetAccountResponse(AccountResponse baseResponse) { /// Convert this response to a [Map]. Map toMap() { return { - ...baseResponse.toMap(), + ...accountResponse.toMap(), 'inTransition': inTransition, }; } From ad50c762d406d2f958e996789a9e61a1dc46e274 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 16:30:17 +0200 Subject: [PATCH 235/256] let setAccount use extension types; move validation errors to error details --- lib/src/web/gigya_flutter_plugin_web.dart | 41 +++++++++++-------- .../response/account_response.dart | 17 ++++---- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index eef36e4f..83ea2a68 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -403,7 +403,8 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { final Map? profile = account['profile'] as Map?; final Map? data = account['data'] as Map?; - gigyaWebSdk.accounts.setAccountInfo( + GigyaWebSdk.instance.accounts.setAccountInfo.callAsFunction( + null, SetAccountParameters( addLoginEmails: account['addLoginEmails'] as String?, conflictHandling: account['conflictHandling'] as String?, @@ -416,24 +417,28 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { secretAnswer: account['secretAnswer'] as String?, secretQuestion: account['secretQuestion'] as String?, username: account['username'] as String?, - callback: allowInterop((SetAccountResponse response) { - if (completer.isCompleted) { - return; - } + callback: allowInterop( + (SetAccountResponse response) { + if (completer.isCompleted) { + return; + } - if (response.errorCode == 0) { - completer.complete(StaticInteropUtils.responseToMap(response)); - } else { - completer.completeError( - GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - errorCode: response.errorCode, - errorDetails: response.errorDetails, - ), - ); - } - }), + // If the call succeeded, there is no data of value to send back. + // However, if the call failed, the error details will include the validation errors. + if (response.baseResponse.errorCode == 0) { + completer.complete(const {}); + } else { + completer.completeError( + GigyaError( + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.details, + errorCode: response.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, ), ); diff --git a/lib/src/web/static_interop/response/account_response.dart b/lib/src/web/static_interop/response/account_response.dart index 0bd2f136..c9404405 100644 --- a/lib/src/web/static_interop/response/account_response.dart +++ b/lib/src/web/static_interop/response/account_response.dart @@ -138,6 +138,16 @@ extension type GetAccountResponse(AccountResponse accountResponse) { @anonymous @staticInterop extension type SetAccountResponse(Response baseResponse) { + /// Get the error details. + /// + /// The error details will include the [validationErrors]. + Map get details { + return { + ...baseResponse.details, + 'validationErrors': validationErrors.map((ValidationError e) => e.toMap()).toList(), + }; + } + @JS('validationErrors') external JSArray? get _validationErrors; @@ -145,11 +155,4 @@ extension type SetAccountResponse(Response baseResponse) { List get validationErrors { return _validationErrors?.toDart.cast() ?? const []; } - - /// Convert this response to a [Map]. - Map toMap() { - return { - 'validationErrors': validationErrors.map((ValidationError e) => e.toMap()).toList(), - }; - } } From 0a6151e8ee90b5c62aa606b50e04a25835341db9 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 16:47:17 +0200 Subject: [PATCH 236/256] move get/set account implementation to delegate --- lib/src/web/gigya_flutter_plugin_web.dart | 83 ++--------------- lib/src/web/web_account_delegate.dart | 104 ++++++++++++++++++++++ 2 files changed, 111 insertions(+), 76 deletions(-) create mode 100644 lib/src/web/web_account_delegate.dart diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 83ea2a68..2564e218 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -11,13 +11,13 @@ import '../services/interruption_resolver.dart'; import 'enums/web_error_code.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/models/profile.dart'; -import 'static_interop/parameters/account.dart'; import 'static_interop/parameters/basic.dart'; import 'static_interop/parameters/login.dart'; import 'static_interop/parameters/registration.dart'; import 'static_interop/response/registration_response.dart'; import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; +import 'web_account_delegate.dart'; import 'web_interruption_resolver.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. @@ -34,6 +34,8 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return const WebInterruptionResolverFactory(); } + final WebAccountDelegate _accountDelegate = const WebAccountDelegate(); + @override Future> finalizeRegistration( String registrationToken, { @@ -113,37 +115,10 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { bool invalidate = false, Map parameters = const {}, }) async { - final Completer> completer = Completer>(); - - GigyaWebSdk.instance.accounts.getAccountInfo.callAsFunction( - null, - GetAccountParameters( - extraProfileFields: parameters['extraProfileFields'] as String?, - include: parameters['include'] as String?, - callback: allowInterop( - (GetAccountResponse response) { - if (completer.isCompleted) { - return; - } - - if (response.accountResponse.baseResponse.errorCode == 0) { - completer.complete(response.toMap()); - } else { - completer.completeError( - GigyaError( - apiVersion: response.accountResponse.baseResponse.apiVersion, - callId: response.accountResponse.baseResponse.callId, - details: response.accountResponse.baseResponse.details, - errorCode: response.accountResponse.baseResponse.errorCode, - ), - ); - } - }, - ).toJS, - ), + return _accountDelegate.getAccount( + invalidate: invalidate, + parameters: parameters, ); - - return completer.future; } @override @@ -398,50 +373,6 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { @override Future> setAccount(Map account) { - final Completer> completer = Completer>(); - - final Map? profile = account['profile'] as Map?; - final Map? data = account['data'] as Map?; - - GigyaWebSdk.instance.accounts.setAccountInfo.callAsFunction( - null, - SetAccountParameters( - addLoginEmails: account['addLoginEmails'] as String?, - conflictHandling: account['conflictHandling'] as String?, - data: data.jsify(), - newPassword: account['newPassword'] as String?, - password: account['password'] as String?, - profile: profile == null ? null : Profile.fromMap(profile), - removeLoginEmails: account['removeLoginEmails'] as String?, - requirePasswordChange: account['requirePasswordChange'] as bool?, - secretAnswer: account['secretAnswer'] as String?, - secretQuestion: account['secretQuestion'] as String?, - username: account['username'] as String?, - callback: allowInterop( - (SetAccountResponse response) { - if (completer.isCompleted) { - return; - } - - // If the call succeeded, there is no data of value to send back. - // However, if the call failed, the error details will include the validation errors. - if (response.baseResponse.errorCode == 0) { - completer.complete(const {}); - } else { - completer.completeError( - GigyaError( - apiVersion: response.baseResponse.apiVersion, - callId: response.baseResponse.callId, - details: response.details, - errorCode: response.baseResponse.errorCode, - ), - ); - } - }, - ).toJS, - ), - ); - - return completer.future; + return _accountDelegate.setAccount(account); } } diff --git a/lib/src/web/web_account_delegate.dart b/lib/src/web/web_account_delegate.dart new file mode 100644 index 00000000..829baf2a --- /dev/null +++ b/lib/src/web/web_account_delegate.dart @@ -0,0 +1,104 @@ +import 'dart:async'; +import 'dart:js_interop'; +import 'package:js/js_util.dart' show allowInterop; + +import '../models/gigya_error.dart'; +import 'static_interop/gigya_web_sdk.dart'; +import 'static_interop/models/profile.dart'; +import 'static_interop/parameters/account.dart'; +import 'static_interop/response/account_response.dart'; + +/// This class handles the updating or retrieving of, account information. +class WebAccountDelegate { + /// Create an instance of [WebAccountDelegate]. + const WebAccountDelegate(); + + // TODO: invalidate is never used? + + /// Get the account information for the current user. + Future> getAccount({ + bool invalidate = false, + Map parameters = const {}, + }) async { + final Completer> completer = Completer>(); + + GigyaWebSdk.instance.accounts.getAccountInfo.callAsFunction( + null, + GetAccountParameters( + extraProfileFields: parameters['extraProfileFields'] as String?, + include: parameters['include'] as String?, + callback: allowInterop( + (GetAccountResponse response) { + if (completer.isCompleted) { + return; + } + + if (response.accountResponse.baseResponse.errorCode == 0) { + completer.complete(response.toMap()); + } else { + completer.completeError( + GigyaError( + apiVersion: response.accountResponse.baseResponse.apiVersion, + callId: response.accountResponse.baseResponse.callId, + details: response.accountResponse.baseResponse.details, + errorCode: response.accountResponse.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, + ), + ); + + return completer.future; + } + + /// Set the account information using the given [account]. + Future> setAccount(Map account) { + final Completer> completer = Completer>(); + + final Map? profile = account['profile'] as Map?; + final Map? data = account['data'] as Map?; + + GigyaWebSdk.instance.accounts.setAccountInfo.callAsFunction( + null, + SetAccountParameters( + addLoginEmails: account['addLoginEmails'] as String?, + conflictHandling: account['conflictHandling'] as String?, + data: data.jsify(), + newPassword: account['newPassword'] as String?, + password: account['password'] as String?, + profile: profile == null ? null : Profile.fromMap(profile), + removeLoginEmails: account['removeLoginEmails'] as String?, + requirePasswordChange: account['requirePasswordChange'] as bool?, + secretAnswer: account['secretAnswer'] as String?, + secretQuestion: account['secretQuestion'] as String?, + username: account['username'] as String?, + callback: allowInterop( + (SetAccountResponse response) { + if (completer.isCompleted) { + return; + } + + // If the call succeeded, there is no data of value to send back. + // However, if the call failed, the error details will include the validation errors. + if (response.baseResponse.errorCode == 0) { + completer.complete(const {}); + } else { + completer.completeError( + GigyaError( + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.details, + errorCode: response.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, + ), + ); + + return completer.future; + } +} From de9b74813587a2874bea49f8910a6a7e51b1ef4a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 16:48:48 +0200 Subject: [PATCH 237/256] implement pending registration resolver for web --- lib/src/web/web_account_delegate.dart | 2 -- lib/src/web/web_interruption_resolver.dart | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/src/web/web_account_delegate.dart b/lib/src/web/web_account_delegate.dart index 829baf2a..fb9edbaa 100644 --- a/lib/src/web/web_account_delegate.dart +++ b/lib/src/web/web_account_delegate.dart @@ -13,8 +13,6 @@ class WebAccountDelegate { /// Create an instance of [WebAccountDelegate]. const WebAccountDelegate(); - // TODO: invalidate is never used? - /// Get the account information for the current user. Future> getAccount({ bool invalidate = false, diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index 70cd476d..794a4d8a 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:js_interop'; +import 'package:gigya_flutter_plugin/src/web/web_account_delegate.dart'; import 'package:js/js_util.dart' show allowInterop; import '../models/conflicting_account.dart'; @@ -91,5 +92,10 @@ class _LinkAccountResolver extends LinkAccountResolver { class _PendingRegistrationResolver extends PendingRegistrationResolver { const _PendingRegistrationResolver(); - // TODO: implement set account info & call it here + final WebAccountDelegate _accountDelegate = const WebAccountDelegate(); + + @override + Future> setAccount(Map parameters) { + return _accountDelegate.setAccount(parameters); + } } From 36be073d892ff2a8888e80914c1e6b3cb279fb8a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 16:52:18 +0200 Subject: [PATCH 238/256] add comment for invalidate flag --- lib/src/web/gigya_flutter_plugin_web.dart | 6 ++---- lib/src/web/web_account_delegate.dart | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 2564e218..a592c469 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -115,10 +115,8 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { bool invalidate = false, Map parameters = const {}, }) async { - return _accountDelegate.getAccount( - invalidate: invalidate, - parameters: parameters, - ); + // Apparently, web does not support the invalidate argument. + return _accountDelegate.getAccount(parameters: parameters); } @override diff --git a/lib/src/web/web_account_delegate.dart b/lib/src/web/web_account_delegate.dart index fb9edbaa..93ab5543 100644 --- a/lib/src/web/web_account_delegate.dart +++ b/lib/src/web/web_account_delegate.dart @@ -15,7 +15,6 @@ class WebAccountDelegate { /// Get the account information for the current user. Future> getAccount({ - bool invalidate = false, Map parameters = const {}, }) async { final Completer> completer = Completer>(); From 97215f14107374a6e36cc0550a6bb7271d698824 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 16:57:03 +0200 Subject: [PATCH 239/256] fix doc --- lib/src/web/web_account_delegate.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/web_account_delegate.dart b/lib/src/web/web_account_delegate.dart index 93ab5543..84be13a9 100644 --- a/lib/src/web/web_account_delegate.dart +++ b/lib/src/web/web_account_delegate.dart @@ -8,7 +8,7 @@ import 'static_interop/models/profile.dart'; import 'static_interop/parameters/account.dart'; import 'static_interop/response/account_response.dart'; -/// This class handles the updating or retrieving of, account information. +/// This class handles updating and retrieving account information for the web. class WebAccountDelegate { /// Create an instance of [WebAccountDelegate]. const WebAccountDelegate(); From 55d6d5a6e158dac4593d5b43ffbac57b222ac3d5 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sat, 30 Sep 2023 16:58:14 +0200 Subject: [PATCH 240/256] fix typo --- lib/src/web/static_interop/models/validation_error.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/models/validation_error.dart b/lib/src/web/static_interop/models/validation_error.dart index 8559c22a..c59b93ca 100644 --- a/lib/src/web/static_interop/models/validation_error.dart +++ b/lib/src/web/static_interop/models/validation_error.dart @@ -1,6 +1,6 @@ import 'dart:js_interop'; -/// The extensino type for the validation error object. +/// The extension type for the validation error object. @JS() @anonymous @staticInterop From 0d825986c5dfaf7aa38d2b27b3ee3541a340a081 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 13 Apr 2023 14:13:46 +0200 Subject: [PATCH 241/256] cherry pick social provider changes --- lib/src/models/enums/social_provider.dart | 108 +++++++++++++++++++--- 1 file changed, 97 insertions(+), 11 deletions(-) diff --git a/lib/src/models/enums/social_provider.dart b/lib/src/models/enums/social_provider.dart index 337aa1fd..fd3e4927 100644 --- a/lib/src/models/enums/social_provider.dart +++ b/lib/src/models/enums/social_provider.dart @@ -1,26 +1,112 @@ +// TODO: investigate if this can be a `final class` once Class Modifiers are available in Dart 3.0 +// https://github.com/dart-lang/language/blob/master/accepted/future-releases/class-modifiers/feature-specification.md#syntax + /// The currently supported social providers. -enum SocialProvider { +/// +/// Depending on the platform; some social providers might be unavailable. +class SocialProvider { + /// The private constructor. + const SocialProvider._(this.name); + + /// Create a new SAML-based [SocialProvider] from a given [value]. + /// + /// The [value] will be prefixed by `saml-`. + factory SocialProvider.saml(String value) { + if (value.isEmpty) { + throw ArgumentError.value( + value, + 'value', + 'The value of a SAML SocialProvider should not be empty.', + ); + } + + return SocialProvider._('saml-$value'); + } + + /// The name of this provider. + final String name; + /// The social provider for Amazon. - amazon, + static const SocialProvider amazon = SocialProvider._('amazon'); /// The social provider for Apple. - apple, + static const SocialProvider apple = SocialProvider._('apple'); + + /// The social provider for Blogger. + static const SocialProvider blogger = SocialProvider._('blogger'); /// The social provider for Facebook. - facebook, + static const SocialProvider facebook = SocialProvider._('facebook'); + + /// The social provider for Foursquare. + static const SocialProvider foursquare = SocialProvider._('foursquare'); /// The social provider for Google. - google, + static const SocialProvider google = SocialProvider._('google'); - /// The social provider for Line. - line, + /// The social provider for GooglePlus. + static const SocialProvider googleplus = SocialProvider._('googleplus'); + + /// The social provider for Kakao. + static const SocialProvider kakao = SocialProvider._('kakao'); + + /// The social provider for LINE. + static const SocialProvider line = SocialProvider._('line'); /// The social provider for LinkedIn. - linkedin, + static const SocialProvider linkedin = SocialProvider._('linkedin'); + + /// The social provider for Livedoor. + static const SocialProvider livedoor = SocialProvider._('livedoor'); + + /// The social provider for Messenger. + static const SocialProvider messenger = SocialProvider._('messenger'); + + /// The social provider for mixi. + static const SocialProvider mixi = SocialProvider._('mixi'); + + /// The social provider for Naver. + static const SocialProvider naver = SocialProvider._('naver'); + + /// The social provider for Netlog. + static const SocialProvider netlog = SocialProvider._('netlog'); + + /// The social provider for Odnoklassniki. + static const SocialProvider odnoklassniki = SocialProvider._('odnoklassniki'); + + /// The social provider for Paypal. + static const SocialProvider paypal = SocialProvider._('paypaloauth'); + + /// The social provider for TencentQQ. + static const SocialProvider qq = SocialProvider._('qq'); + + /// The social provider for renren. + static const SocialProvider renren = SocialProvider._('renren'); + + /// The social provider for SinaWeibo. + static const SocialProvider sina = SocialProvider._('sina'); + + /// The social provider for Spiceworks. + static const SocialProvider spiceworks = SocialProvider._('spiceworks'); + + /// The social provider for Twitter. + static const SocialProvider twitter = SocialProvider._('twitter'); + + /// The social provider for VKontakte. + static const SocialProvider vkontakte = SocialProvider._('vkontakte'); /// The social provider for WeChat. - wechat, + static const SocialProvider wechat = SocialProvider._('wechat'); + + /// The social provider for WordPress. + static const SocialProvider wordpress = SocialProvider._('wordpress'); + + /// The social provider for Xing. + static const SocialProvider xing = SocialProvider._('xing'); + + /// The social provider for Yahoo!. + static const SocialProvider yahoo = SocialProvider._('yahoo'); - /// The soocial provider for Yahoo. - yahoo, + /// The social provider for Yahoo! Japan. + static const SocialProvider yahooJapan = SocialProvider._('yahoojapan'); } From eeea3d6637602fa4f325f029f4befbfc2c28884c Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 08:39:27 +0200 Subject: [PATCH 242/256] add socialize namespace to static interop definition --- lib/src/web/static_interop/gigya_web_sdk.dart | 4 ++++ lib/src/web/static_interop/socialize.dart | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 lib/src/web/static_interop/socialize.dart diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index f9cedc47..0adf5a1b 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -3,6 +3,7 @@ import 'dart:js_interop'; import 'package:web/web.dart' as web; import 'account.dart'; +import 'socialize.dart'; import 'window.dart'; /// The static interop extension type for the `gigya` JavaScript object. @@ -29,4 +30,7 @@ extension type GigyaWebSdk(JSObject _) implements JSObject { /// Whether the Gigya Web SDK is ready. external bool get isReady; + + /// Get the socialize namespace in the Gigya Web SDK. + external Socialize get socialize; } diff --git a/lib/src/web/static_interop/socialize.dart b/lib/src/web/static_interop/socialize.dart new file mode 100644 index 00000000..90a3b6ae --- /dev/null +++ b/lib/src/web/static_interop/socialize.dart @@ -0,0 +1,8 @@ +import 'dart:js_interop'; + +/// The extension type for the `gigya.socialize` JavaScript object. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4173357f70b21014bbc5a10ce4041860.html +@JS() +@staticInterop +extension type Socialize(JSObject _) {} From 63632359f948cfc085058d69369fc1a92c24c533 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 08:53:16 +0200 Subject: [PATCH 243/256] implement add social connection parameters static interop type --- .../parameters/social_connection.dart | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/src/web/static_interop/parameters/social_connection.dart diff --git a/lib/src/web/static_interop/parameters/social_connection.dart b/lib/src/web/static_interop/parameters/social_connection.dart new file mode 100644 index 00000000..c167e23a --- /dev/null +++ b/lib/src/web/static_interop/parameters/social_connection.dart @@ -0,0 +1,25 @@ +import 'package:js/js.dart'; + +import '../response/social_connection.dart'; + +/// This class represents the parameters for the `Socialize.addConnection` method. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417376f070b21014bbc5a10ce4041860.html#parameters +@JS() +@anonymous +@staticInterop +class AddSocialConnectionParameters { + /// Create a new [AddSocialConnectionParameters] instance. + external factory AddSocialConnectionParameters({ + String? authFlow, + void Function(SocialConnectionResponse response) callback, + String? extraFields, + String? facebookExtraPermissions, + bool? forceAuthentication, + String? googleExtraPermissions, + String provider, + String? redirectMethod, + String? redirectURL, + int? sessionExpiration, + }); +} From 0961c023bcf64af82d2bd3e56f038debcbaba12a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 08:54:50 +0200 Subject: [PATCH 244/256] implement add social connection method static interop definition --- lib/src/web/static_interop/socialize.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/socialize.dart b/lib/src/web/static_interop/socialize.dart index 90a3b6ae..a52607c8 100644 --- a/lib/src/web/static_interop/socialize.dart +++ b/lib/src/web/static_interop/socialize.dart @@ -1,8 +1,18 @@ import 'dart:js_interop'; +import 'parameters/social_connection.dart'; + /// The extension type for the `gigya.socialize` JavaScript object. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4173357f70b21014bbc5a10ce4041860.html @JS() @staticInterop -extension type Socialize(JSObject _) {} +extension type Socialize(JSObject _) { + /// Add a new social connection. + /// + /// This function receives a [AddSocialConnectionParameters] argument, + /// and has [JSVoid] as return type. + external JSFunction addConnection; + + // TODO: remove connection +} From 313e5035f323e39198372d6ab25d37306dea9673 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 09:13:10 +0200 Subject: [PATCH 245/256] implement remove social connection response parameters static interop definition; add removeConnection method to socialize namespace --- .../parameters/social_connection.dart | 17 +++++++++++++++++ lib/src/web/static_interop/socialize.dart | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/parameters/social_connection.dart b/lib/src/web/static_interop/parameters/social_connection.dart index c167e23a..b14e8a21 100644 --- a/lib/src/web/static_interop/parameters/social_connection.dart +++ b/lib/src/web/static_interop/parameters/social_connection.dart @@ -23,3 +23,20 @@ class AddSocialConnectionParameters { int? sessionExpiration, }); } + +/// This class represents the parameters for the `Socialize.removeConnection` method. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4177c60370b21014bbc5a10ce4041860.html#parameters +@JS() +@anonymous +@staticInterop +class RemoveSocialConnectionParameters { + /// Create a new [RemoveSocialConnectionParameters] instance. + external factory RemoveSocialConnectionParameters({ + void Function(SocialConnectionResponse response) callback, + String provider, + bool? forceProvidersLogout, + String? lastIdentityHandling, + bool? removeLoginID, + }); +} diff --git a/lib/src/web/static_interop/socialize.dart b/lib/src/web/static_interop/socialize.dart index a52607c8..c0e1e84e 100644 --- a/lib/src/web/static_interop/socialize.dart +++ b/lib/src/web/static_interop/socialize.dart @@ -14,5 +14,9 @@ extension type Socialize(JSObject _) { /// and has [JSVoid] as return type. external JSFunction addConnection; - // TODO: remove connection + /// Remove a social connection. + /// + /// This function receives a [RemoveSocialConnectionParameters] argument, + /// and has [JSVoid] as return type. + external JSFunction removeConnection; } From 2e80c15d722500bc79210ea4669b724c4a3e7e67 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 09:22:53 +0200 Subject: [PATCH 246/256] implement social connection response --- .../parameters/social_connection.dart | 2 +- .../web/static_interop/response/response.dart | 1 + .../response/social_connection_response.dart | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lib/src/web/static_interop/response/social_connection_response.dart diff --git a/lib/src/web/static_interop/parameters/social_connection.dart b/lib/src/web/static_interop/parameters/social_connection.dart index b14e8a21..ede62492 100644 --- a/lib/src/web/static_interop/parameters/social_connection.dart +++ b/lib/src/web/static_interop/parameters/social_connection.dart @@ -1,6 +1,6 @@ import 'package:js/js.dart'; -import '../response/social_connection.dart'; +import '../response/social_connection_response.dart'; /// This class represents the parameters for the `Socialize.addConnection` method. /// diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index 5208920f..332070a6 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -3,6 +3,7 @@ import 'dart:js_interop'; export 'account_response.dart'; export 'conflicting_account_response.dart'; export 'login_response.dart'; +export 'social_connection_response.dart'; /// The extension type for the Gigya `Response` class. /// diff --git a/lib/src/web/static_interop/response/social_connection_response.dart b/lib/src/web/static_interop/response/social_connection_response.dart new file mode 100644 index 00000000..7497133d --- /dev/null +++ b/lib/src/web/static_interop/response/social_connection_response.dart @@ -0,0 +1,17 @@ +import 'dart:js_interop'; + +import '../models/profile.dart'; +import 'response.dart'; + +/// The static interop class for the Gigya add/remove social connection API response. +/// +/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417376f070b21014bbc5a10ce4041860.html#response-object-data-members +@JS() +@anonymous +@staticInterop +extension type SocialConnectionResponse(Response baseResponse) { + /// The user object with updated information about the current user. + /// + /// In the web SDK, the `User` and `Profile` objects share the same shape. + external Profile get user; +} From 223196b459200cddf3f312d04ad57693a59c6214 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 11:29:33 +0200 Subject: [PATCH 247/256] add parameters map to add/remove connection in platform interface --- lib/gigya_flutter_plugin.dart | 14 ++++++++++---- .../gigya_flutter_plugin_platform_interface.dart | 10 ++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/gigya_flutter_plugin.dart b/lib/gigya_flutter_plugin.dart index 1dfc6dc1..1a203850 100644 --- a/lib/gigya_flutter_plugin.dart +++ b/lib/gigya_flutter_plugin.dart @@ -51,8 +51,11 @@ class GigyaSdk { } /// Add a social connection to an existing account. - Future> addConnection(SocialProvider provider) { - return GigyaFlutterPluginPlatform.instance.addConnection(provider); + Future> addConnection( + SocialProvider provider, { + Map parameters = const {}, + }) { + return GigyaFlutterPluginPlatform.instance.addConnection(provider, parameters: parameters); } /// Start the forgot password flow for the given [loginId]. @@ -145,8 +148,11 @@ class GigyaSdk { } /// Remove a social connection from an existing account. - Future> removeConnection(SocialProvider provider) { - return GigyaFlutterPluginPlatform.instance.removeConnection(provider); + Future> removeConnection( + SocialProvider provider, { + Map parameters = const {}, + }) { + return GigyaFlutterPluginPlatform.instance.removeConnection(provider, parameters: parameters); } /// Send a request to the Gigya SDK. diff --git a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart index 5fc9e3b3..709e3caf 100644 --- a/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart +++ b/lib/src/platform_interface/gigya_flutter_plugin_platform_interface.dart @@ -53,7 +53,10 @@ abstract class GigyaFlutterPluginPlatform extends PlatformInterface { } /// Add a social connection to an existing account. - Future> addConnection(SocialProvider provider) { + Future> addConnection( + SocialProvider provider, { + Map parameters = const {}, + }) { throw UnimplementedError('addConnection() is not implemented.'); } @@ -155,7 +158,10 @@ abstract class GigyaFlutterPluginPlatform extends PlatformInterface { } /// Remove a social connection from an existing account. - Future> removeConnection(SocialProvider provider) { + Future> removeConnection( + SocialProvider provider, { + Map parameters = const {}, + }) { throw UnimplementedError('removeConnection() is not implemented.'); } From a1842b370733045846ca1720227b7acd726088cb Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 11:32:24 +0200 Subject: [PATCH 248/256] fix parameter map for add/remove connection in method channel impl --- .../gigya_flutter_plugin_method_channel.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart index a7d93b47..c4160d01 100644 --- a/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart +++ b/lib/src/method_channel/gigya_flutter_plugin_method_channel.dart @@ -43,7 +43,10 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform { } @override - Future> addConnection(SocialProvider provider) async { + Future> addConnection( + SocialProvider provider, { + Map parameters = const {}, + }) async { try { final Map? result = await methodChannel.invokeMapMethod( @@ -262,7 +265,10 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform { } @override - Future> removeConnection(SocialProvider provider) async { + Future> removeConnection( + SocialProvider provider, { + Map parameters = const {}, + }) async { try { final Map? result = await methodChannel.invokeMapMethod( From 9702580fa8269a45c149b2fa0d02382e0b92aa4a Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 11:45:34 +0200 Subject: [PATCH 249/256] implement add connection for web --- lib/src/web/gigya_flutter_plugin_web.dart | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index a592c469..8b16af45 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -5,6 +5,7 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:js/js_util.dart' show allowInterop; import 'package:web/web.dart' as web; +import '../models/enums/social_provider.dart'; import '../models/gigya_error.dart'; import '../platform_interface/gigya_flutter_plugin_platform_interface.dart'; import '../services/interruption_resolver.dart'; @@ -36,6 +37,48 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { final WebAccountDelegate _accountDelegate = const WebAccountDelegate(); + @override + Future> addConnection( + SocialProvider provider, { + Map parameters = const {}, + }) { + final Completer> completer = Completer>(); + + gigyaWebSdk.socialize.addConnection( + AddSocialConnectionParameters( + authFlow: parameters['authFlow'] as String?, + extraFields: parameters['extraFields'] as String?, + facebookExtraPermissions: parameters['facebookExtraPermissions'] as String?, + forceAuthentication: parameters['forceAuthentication'] as bool?, + googleExtraPermissions: parameters['googleExtraPermissions'] as String?, + provider: provider.name, + redirectMethod: parameters['redirectMethod'] as String?, + redirectURL: parameters['redirectURL'] as String?, + sessionExpiration: parameters['sessionExpiration'] as int?, + callback: allowInterop((SocialConnectionResponse response) { + if (completer.isCompleted) { + return; + } + + if (response.errorCode == 0) { + completer.complete(StaticInteropUtils.responseToMap(response)); + } else { + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + ), + ); + } + }), + ), + ); + + return completer.future; + } + @override Future> finalizeRegistration( String registrationToken, { From e5b60b14fc3fccefc0c0ffdf0f4eb7ff36564952 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Fri, 14 Apr 2023 11:53:19 +0200 Subject: [PATCH 250/256] implement remove connection for web --- lib/src/web/gigya_flutter_plugin_web.dart | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index 8b16af45..d6af22da 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -412,6 +412,43 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return registrationCompleter.future; } + @override + Future> removeConnection( + SocialProvider provider, { + Map parameters = const {}, + }) { + final Completer> completer = Completer>(); + + gigyaWebSdk.socialize.removeConnection( + RemoveSocialConnectionParameters( + forceProvidersLogout: parameters['forceProvidersLogout'] as bool?, + lastIdentityHandling: parameters['lastIdentityHandling'] as String?, + provider: provider.name, + removeLoginID: parameters['removeLoginID'] as bool?, + callback: allowInterop((SocialConnectionResponse response) { + if (completer.isCompleted) { + return; + } + + if (response.errorCode == 0) { + completer.complete(StaticInteropUtils.responseToMap(response)); + } else { + completer.completeError( + GigyaError( + apiVersion: response.apiVersion, + callId: response.callId, + errorCode: response.errorCode, + errorDetails: response.errorDetails, + ), + ); + } + }), + ), + ); + + return completer.future; + } + @override Future> setAccount(Map account) { return _accountDelegate.setAccount(account); From 8fea54679a5734dbb57fb82a6ede9cc2e61d7492 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Thu, 11 May 2023 16:21:21 +0200 Subject: [PATCH 251/256] fix hot reload on the web --- lib/src/web/static_interop/gigya_web_sdk.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/web/static_interop/gigya_web_sdk.dart b/lib/src/web/static_interop/gigya_web_sdk.dart index 0adf5a1b..a9b4792c 100644 --- a/lib/src/web/static_interop/gigya_web_sdk.dart +++ b/lib/src/web/static_interop/gigya_web_sdk.dart @@ -30,7 +30,7 @@ extension type GigyaWebSdk(JSObject _) implements JSObject { /// Whether the Gigya Web SDK is ready. external bool get isReady; - + /// Get the socialize namespace in the Gigya Web SDK. external Socialize get socialize; } From 245ccb970c1a984256b90c9ba480a6e1134c68c2 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 1 Oct 2023 19:11:37 +0200 Subject: [PATCH 252/256] remove diff from account info --- lib/src/web/gigya_flutter_plugin_web.dart | 17 -- lib/src/web/static_interop/account.dart | 14 +- .../models/account_login_id.dart | 31 ---- .../models/validation_error.dart | 27 --- .../static_interop/parameters/account.dart | 62 ------- .../parameters/conflicting_account.dart | 18 ++ .../response/account_response.dart | 158 ------------------ .../web/static_interop/response/response.dart | 1 - lib/src/web/web_account_delegate.dart | 101 ----------- lib/src/web/web_interruption_resolver.dart | 10 +- 10 files changed, 21 insertions(+), 418 deletions(-) delete mode 100644 lib/src/web/static_interop/models/account_login_id.dart delete mode 100644 lib/src/web/static_interop/models/validation_error.dart delete mode 100644 lib/src/web/static_interop/parameters/account.dart create mode 100644 lib/src/web/static_interop/parameters/conflicting_account.dart delete mode 100644 lib/src/web/static_interop/response/account_response.dart delete mode 100644 lib/src/web/web_account_delegate.dart diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index d6af22da..bebfbeac 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -18,7 +18,6 @@ import 'static_interop/parameters/registration.dart'; import 'static_interop/response/registration_response.dart'; import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; -import 'web_account_delegate.dart'; import 'web_interruption_resolver.dart'; /// An implementation of [GigyaFlutterPluginPlatform] that uses JavaScript static interop. @@ -35,8 +34,6 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return const WebInterruptionResolverFactory(); } - final WebAccountDelegate _accountDelegate = const WebAccountDelegate(); - @override Future> addConnection( SocialProvider provider, { @@ -153,15 +150,6 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return initRegistrationCompleter.future; } - @override - Future> getAccount({ - bool invalidate = false, - Map parameters = const {}, - }) async { - // Apparently, web does not support the invalidate argument. - return _accountDelegate.getAccount(parameters: parameters); - } - @override Future initSdk({ required String apiDomain, @@ -448,9 +436,4 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { return completer.future; } - - @override - Future> setAccount(Map account) { - return _accountDelegate.setAccount(account); - } } diff --git a/lib/src/web/static_interop/account.dart b/lib/src/web/static_interop/account.dart index 4fc79b59..dd75793e 100644 --- a/lib/src/web/static_interop/account.dart +++ b/lib/src/web/static_interop/account.dart @@ -1,8 +1,8 @@ import 'dart:js_interop'; import './session.dart'; -import 'parameters/account.dart'; import 'parameters/basic.dart'; +import 'parameters/conflicting_account.dart'; import 'parameters/login.dart'; import 'parameters/registration.dart'; @@ -18,12 +18,6 @@ extension type Accounts(JSObject _) { /// and has [JSVoid] as return type. external JSFunction finalizeRegistration; - /// Get the account info of a user. - /// - /// This function receives a [GetAccountParameters] instance as argument, - /// and has [JSVoid] as return type. - external JSFunction getAccountInfo; - /// Get the conflicting accounts of the user. /// /// This function receives a [ConflictingAccountParameters] instance as argument, @@ -56,10 +50,4 @@ extension type Accounts(JSObject _) { /// Get the `gigya.accounts.session` namespace. external Session get session; - - /// Update the user's account info. - /// - /// This function receives a [SetAccountParameters] instance as argument, - /// and has [JSVoid] as return type. - external JSFunction setAccountInfo; } diff --git a/lib/src/web/static_interop/models/account_login_id.dart b/lib/src/web/static_interop/models/account_login_id.dart deleted file mode 100644 index 3bdd652f..00000000 --- a/lib/src/web/static_interop/models/account_login_id.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'dart:js_interop'; - -/// The extension type for the login id of a user. -@JS() -@anonymous -@staticInterop -extension type AccountLoginId(JSObject _) { - @JS('emails') - external JSArray get _emails; - - @JS('unverifiedEmails') - external JSArray get _unverifiedEmails; - - /// The list of verified email addresses of the user. - List get emails => _emails.toDart.cast(); - - /// The list of unverified email addresses of the user. - List get unverifiedEmails => _unverifiedEmails.toDart.cast(); - - /// The username of the user. - external String? get username; - - /// Convert this object into a map. - Map toMap() { - return { - 'emails': emails, - 'unverifiedEmails': unverifiedEmails, - 'username': username, - }; - } -} diff --git a/lib/src/web/static_interop/models/validation_error.dart b/lib/src/web/static_interop/models/validation_error.dart deleted file mode 100644 index c59b93ca..00000000 --- a/lib/src/web/static_interop/models/validation_error.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'dart:js_interop'; - -/// The extension type for the validation error object. -@JS() -@anonymous -@staticInterop -extension type ValidationError(JSObject _) { - /// The validation error code. - external int get errorCode; - - /// The name of the field that caused the validation error. - /// - /// This field name uses dot notation, i.e. `profile.name`. - external String get fieldName; - - /// The validation error message. - external String get message; - - /// COnvert this validation error message to a map. - Map toMap() { - return { - 'errorCode': errorCode, - 'fieldName': fieldName, - 'message': message, - }; - } -} diff --git a/lib/src/web/static_interop/parameters/account.dart b/lib/src/web/static_interop/parameters/account.dart deleted file mode 100644 index ff8d4eb2..00000000 --- a/lib/src/web/static_interop/parameters/account.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'dart:js_interop'; - -import '../models/profile.dart'; -import '../response/response.dart'; - -/// This extension type represents the parameters for the `Accounts.getConflictingAccount` method. -@JS() -@anonymous -@staticInterop -extension type ConflictingAccountParameters._(JSObject _) implements JSObject { - /// Create a [ConflictingAccountParameters] instance using the given [callback] and [regToken]. - /// - /// The [callback] receives a [ConflictingAccountResponse] as argument, - /// and has [JSVoid] as return type. - external factory ConflictingAccountParameters({ - JSFunction callback, - String regToken, - }); -} - -/// This extension type represents the parameters for the `Accounts.getAccountInfo` method. -@JS() -@anonymous -@staticInterop -extension type GetAccountParameters._(JSObject _) implements JSObject { - /// Create a [GetAccountParameters] instance. - /// - /// The [callback] receives a [GetAccountResponse] as argument, - /// and has [JSVoid] as return type. - external factory GetAccountParameters({ - JSFunction callback, - String? extraProfileFields, - String? include, - }); -} - -/// This extension type represents the parameters for the `Accounts.setAccountInfo` method. -@JS() -@anonymous -@staticInterop -extension type SetAccountParameters._(JSObject _) implements JSObject { - // TODO: add preferences and subscriptions object once the static interop definition is ready - - /// Create a [SetAccountParameters] instance. - /// - /// The [callback] receives a [SetAccountResponse] as argument, - /// and has [JSVoid] as return type. - external factory SetAccountParameters({ - String? addLoginEmails, - JSFunction callback, - String? conflictHandling, - JSAny? data, - String? newPassword, - String? password, - Profile? profile, - String? removeLoginEmails, - bool? requirePasswordChange, - String? secretAnswer, - String? secretQuestion, - String? username, - }); -} diff --git a/lib/src/web/static_interop/parameters/conflicting_account.dart b/lib/src/web/static_interop/parameters/conflicting_account.dart new file mode 100644 index 00000000..cbd5fd99 --- /dev/null +++ b/lib/src/web/static_interop/parameters/conflicting_account.dart @@ -0,0 +1,18 @@ +import 'dart:js_interop'; + +import '../response/response.dart'; + +/// This extension type represents the parameters for the `Accounts.getConflictingAccount` method. +@JS() +@anonymous +@staticInterop +extension type ConflictingAccountParameters._(JSObject _) implements JSObject { + /// Create a [ConflictingAccountParameters] instance using the given [callback] and [regToken]. + /// + /// The [callback] receives a [ConflictingAccountResponse] as argument, + /// and has [JSVoid] as return type. + external factory ConflictingAccountParameters({ + JSFunction callback, + String regToken, + }); +} diff --git a/lib/src/web/static_interop/response/account_response.dart b/lib/src/web/static_interop/response/account_response.dart deleted file mode 100644 index c9404405..00000000 --- a/lib/src/web/static_interop/response/account_response.dart +++ /dev/null @@ -1,158 +0,0 @@ -import 'dart:js_interop'; - -import '../models/account_login_id.dart'; -import '../models/emails.dart'; -import '../models/location.dart'; -import '../models/profile.dart'; -import '../models/validation_error.dart'; -import 'response.dart'; - -// TODO: preferences, subscriptions should be in `AccountResponse` - -/// The extension type for the account response. -@JS() -@anonymous -@staticInterop -extension type AccountResponse(Response baseResponse) { - /// The timestamp of the creation of the user. - external String? get created; - - /// The custom user data that is not part of the [profile]. - external JSAny? get data; - - /// The verified and unverified email addresses of the user. - external Emails? get emails; - - /// Whether the user is active. - external bool? get isActive; - - /// Whether the user is registered. - external bool? get isRegistered; - - /// Whether the user is verified. - external bool? get isVerified; - - /// The timestamp of the last login of the user. - external String? get lastLogin; - - /// The last login location of the user. - external Location? get lastLoginLocation; - - /// The timestamp of the last update to the user's profile, - /// preferences or subscriptions data. - external String? get lastUpdated; - - @JS('loginIDs') - external JSArray? get _loginIds; - - /// The login IDs for the user. - List? get loginIds { - return _loginIds?.toDart.cast(); - } - - /// The login provider that was last used to log in. - external String? get loginProvider; - - /// The timestamp, when the oldest data of the user was refreshed. - external String? get oldestDataUpdated; - - /// The user's profile. - external Profile? get profile; - - /// The timestamp when the user was registered. - external String? get registered; - - /// The source of the registration. - external String? get regSource; - - /// The timestamp of the [UIDSignature]. - external String? get signatureTimestamp; - - /// The comma separated list of social providers linked to this user. - external String? get socialProviders; - - /// The unique id of this user. - external String? get UID; // ignore: non_constant_identifier_names - - /// The verification signature of the [UID]. - external String? get UIDSignature; // ignore: non_constant_identifier_names - - /// The timestamp when the user was verified. - external String? get verified; - - /// Convert this response to a [Map]. - Map toMap() { - return { - 'created': created, - 'data': data.dartify(), - 'emails': emails?.toMap(), - 'isActive': isActive, - 'isRegistered': isRegistered, - 'isVerified': isVerified, - 'lastLogin': lastLogin, - 'lastLoginLocation': lastLoginLocation?.toMap(), - 'lastUpdated': lastUpdated, - if (loginIds != null) - 'loginIds': loginIds!.map((AccountLoginId id) => id.toMap()).toList(), - 'loginProvider': loginProvider, - 'oldestDataUpdated': oldestDataUpdated, - 'profile': profile?.toMap(), - 'registered': registered, - 'regSource': regSource, - 'signatureTimestamp': signatureTimestamp, - 'socialProviders': socialProviders, - 'UID': UID, - 'UIDSignature': UIDSignature, - 'verified': verified, - }; - } -} - -/// The extension type for the get account response. -@JS() -@anonymous -@staticInterop -extension type GetAccountResponse(AccountResponse accountResponse) { - /// Whether this account is currently in transition. - /// - /// An account that is in transition cannot be modified. - external bool? get inTransition; - - // TODO: add lockedUntil when DateTime static interop is fixed. - // Currently it is not supported, so add a static interop type for the date class - // See: https://github.com/dart-lang/sdk/issues/52021 - - /// Convert this response to a [Map]. - Map toMap() { - return { - ...accountResponse.toMap(), - 'inTransition': inTransition, - }; - } -} - -/// The extension type for the Gigya Set Account API response. -/// -/// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4139777d70b21014bbc5a10ce4041860.html?locale=en-US#response-object-data-members -@JS() -@anonymous -@staticInterop -extension type SetAccountResponse(Response baseResponse) { - /// Get the error details. - /// - /// The error details will include the [validationErrors]. - Map get details { - return { - ...baseResponse.details, - 'validationErrors': validationErrors.map((ValidationError e) => e.toMap()).toList(), - }; - } - - @JS('validationErrors') - external JSArray? get _validationErrors; - - /// The validation errors for the set account payload. - List get validationErrors { - return _validationErrors?.toDart.cast() ?? const []; - } -} diff --git a/lib/src/web/static_interop/response/response.dart b/lib/src/web/static_interop/response/response.dart index 332070a6..a366dd7a 100644 --- a/lib/src/web/static_interop/response/response.dart +++ b/lib/src/web/static_interop/response/response.dart @@ -1,6 +1,5 @@ import 'dart:js_interop'; -export 'account_response.dart'; export 'conflicting_account_response.dart'; export 'login_response.dart'; export 'social_connection_response.dart'; diff --git a/lib/src/web/web_account_delegate.dart b/lib/src/web/web_account_delegate.dart deleted file mode 100644 index 84be13a9..00000000 --- a/lib/src/web/web_account_delegate.dart +++ /dev/null @@ -1,101 +0,0 @@ -import 'dart:async'; -import 'dart:js_interop'; -import 'package:js/js_util.dart' show allowInterop; - -import '../models/gigya_error.dart'; -import 'static_interop/gigya_web_sdk.dart'; -import 'static_interop/models/profile.dart'; -import 'static_interop/parameters/account.dart'; -import 'static_interop/response/account_response.dart'; - -/// This class handles updating and retrieving account information for the web. -class WebAccountDelegate { - /// Create an instance of [WebAccountDelegate]. - const WebAccountDelegate(); - - /// Get the account information for the current user. - Future> getAccount({ - Map parameters = const {}, - }) async { - final Completer> completer = Completer>(); - - GigyaWebSdk.instance.accounts.getAccountInfo.callAsFunction( - null, - GetAccountParameters( - extraProfileFields: parameters['extraProfileFields'] as String?, - include: parameters['include'] as String?, - callback: allowInterop( - (GetAccountResponse response) { - if (completer.isCompleted) { - return; - } - - if (response.accountResponse.baseResponse.errorCode == 0) { - completer.complete(response.toMap()); - } else { - completer.completeError( - GigyaError( - apiVersion: response.accountResponse.baseResponse.apiVersion, - callId: response.accountResponse.baseResponse.callId, - details: response.accountResponse.baseResponse.details, - errorCode: response.accountResponse.baseResponse.errorCode, - ), - ); - } - }, - ).toJS, - ), - ); - - return completer.future; - } - - /// Set the account information using the given [account]. - Future> setAccount(Map account) { - final Completer> completer = Completer>(); - - final Map? profile = account['profile'] as Map?; - final Map? data = account['data'] as Map?; - - GigyaWebSdk.instance.accounts.setAccountInfo.callAsFunction( - null, - SetAccountParameters( - addLoginEmails: account['addLoginEmails'] as String?, - conflictHandling: account['conflictHandling'] as String?, - data: data.jsify(), - newPassword: account['newPassword'] as String?, - password: account['password'] as String?, - profile: profile == null ? null : Profile.fromMap(profile), - removeLoginEmails: account['removeLoginEmails'] as String?, - requirePasswordChange: account['requirePasswordChange'] as bool?, - secretAnswer: account['secretAnswer'] as String?, - secretQuestion: account['secretQuestion'] as String?, - username: account['username'] as String?, - callback: allowInterop( - (SetAccountResponse response) { - if (completer.isCompleted) { - return; - } - - // If the call succeeded, there is no data of value to send back. - // However, if the call failed, the error details will include the validation errors. - if (response.baseResponse.errorCode == 0) { - completer.complete(const {}); - } else { - completer.completeError( - GigyaError( - apiVersion: response.baseResponse.apiVersion, - callId: response.baseResponse.callId, - details: response.details, - errorCode: response.baseResponse.errorCode, - ), - ); - } - }, - ).toJS, - ), - ); - - return completer.future; - } -} diff --git a/lib/src/web/web_interruption_resolver.dart b/lib/src/web/web_interruption_resolver.dart index 794a4d8a..b696e237 100644 --- a/lib/src/web/web_interruption_resolver.dart +++ b/lib/src/web/web_interruption_resolver.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:js_interop'; -import 'package:gigya_flutter_plugin/src/web/web_account_delegate.dart'; import 'package:js/js_util.dart' show allowInterop; import '../models/conflicting_account.dart'; @@ -8,7 +7,7 @@ import '../models/gigya_error.dart'; import '../services/interruption_resolver.dart'; import 'static_interop/gigya_web_sdk.dart'; import 'static_interop/models/conflicting_account.dart'; -import 'static_interop/parameters/account.dart'; +import 'static_interop/parameters/conflicting_account.dart'; import 'static_interop/response/response.dart'; // TODO: implement linkToSite & linkToSocial in _LinkAccountResolver @@ -92,10 +91,5 @@ class _LinkAccountResolver extends LinkAccountResolver { class _PendingRegistrationResolver extends PendingRegistrationResolver { const _PendingRegistrationResolver(); - final WebAccountDelegate _accountDelegate = const WebAccountDelegate(); - - @override - Future> setAccount(Map parameters) { - return _accountDelegate.setAccount(parameters); - } + // TODO: implement set account info & call it here } From 275f3cba37de640e983f458033414416239dc36e Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 1 Oct 2023 19:19:40 +0200 Subject: [PATCH 253/256] fix typo --- .../web/static_interop/response/social_connection_response.dart | 2 +- lib/src/web/static_interop/socialize.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/web/static_interop/response/social_connection_response.dart b/lib/src/web/static_interop/response/social_connection_response.dart index 7497133d..68d595e5 100644 --- a/lib/src/web/static_interop/response/social_connection_response.dart +++ b/lib/src/web/static_interop/response/social_connection_response.dart @@ -3,7 +3,7 @@ import 'dart:js_interop'; import '../models/profile.dart'; import 'response.dart'; -/// The static interop class for the Gigya add/remove social connection API response. +/// The extension type for the Gigya add/remove social connection API response. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417376f070b21014bbc5a10ce4041860.html#response-object-data-members @JS() diff --git a/lib/src/web/static_interop/socialize.dart b/lib/src/web/static_interop/socialize.dart index c0e1e84e..ffef998f 100644 --- a/lib/src/web/static_interop/socialize.dart +++ b/lib/src/web/static_interop/socialize.dart @@ -10,7 +10,7 @@ import 'parameters/social_connection.dart'; extension type Socialize(JSObject _) { /// Add a new social connection. /// - /// This function receives a [AddSocialConnectionParameters] argument, + /// This function receives an [AddSocialConnectionParameters] argument, /// and has [JSVoid] as return type. external JSFunction addConnection; From 69c595183718d98d63c75bd7b029a61be3351af8 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 1 Oct 2023 19:25:50 +0200 Subject: [PATCH 254/256] make SocialProvider a final class --- lib/src/models/enums/social_provider.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/src/models/enums/social_provider.dart b/lib/src/models/enums/social_provider.dart index fd3e4927..284ab7a8 100644 --- a/lib/src/models/enums/social_provider.dart +++ b/lib/src/models/enums/social_provider.dart @@ -1,10 +1,7 @@ -// TODO: investigate if this can be a `final class` once Class Modifiers are available in Dart 3.0 -// https://github.com/dart-lang/language/blob/master/accepted/future-releases/class-modifiers/feature-specification.md#syntax - /// The currently supported social providers. /// /// Depending on the platform; some social providers might be unavailable. -class SocialProvider { +final class SocialProvider { /// The private constructor. const SocialProvider._(this.name); From 1f9f26ba2665f235bc2995339670a32346c30fba Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 1 Oct 2023 19:31:29 +0200 Subject: [PATCH 255/256] convert social connection namespace to extension types --- .../parameters/social_connection.dart | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/src/web/static_interop/parameters/social_connection.dart b/lib/src/web/static_interop/parameters/social_connection.dart index ede62492..14a73683 100644 --- a/lib/src/web/static_interop/parameters/social_connection.dart +++ b/lib/src/web/static_interop/parameters/social_connection.dart @@ -1,18 +1,21 @@ -import 'package:js/js.dart'; +import 'dart:js_interop'; import '../response/social_connection_response.dart'; -/// This class represents the parameters for the `Socialize.addConnection` method. +/// This extension type represents the parameters for the `Socialize.addConnection` method. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/417376f070b21014bbc5a10ce4041860.html#parameters @JS() @anonymous @staticInterop -class AddSocialConnectionParameters { +extension type AddSocialConnectionParameters._(JSObject _) implements JSObject { /// Create a new [AddSocialConnectionParameters] instance. + /// + /// The [callback] function receives a [SocialConnectionResponse] as argument + /// and has [JSVoid] as return type. external factory AddSocialConnectionParameters({ String? authFlow, - void Function(SocialConnectionResponse response) callback, + JSFunction callback, String? extraFields, String? facebookExtraPermissions, bool? forceAuthentication, @@ -24,16 +27,19 @@ class AddSocialConnectionParameters { }); } -/// This class represents the parameters for the `Socialize.removeConnection` method. +/// This extension type represents the parameters for the `Socialize.removeConnection` method. /// /// See also: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/4177c60370b21014bbc5a10ce4041860.html#parameters @JS() @anonymous @staticInterop -class RemoveSocialConnectionParameters { +extension type RemoveSocialConnectionParameters._(JSObject _) implements JSObject { /// Create a new [RemoveSocialConnectionParameters] instance. + /// + /// The [callback] function receives a [SocialConnectionResponse] as argument + /// and has [JSVoid] as return type. external factory RemoveSocialConnectionParameters({ - void Function(SocialConnectionResponse response) callback, + JSFunction callback, String provider, bool? forceProvidersLogout, String? lastIdentityHandling, From 8139b8bf136f57dac44cd8610809ac2acaa7d001 Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Sun, 1 Oct 2023 19:42:44 +0200 Subject: [PATCH 256/256] fix the function handles for add / remove connection --- lib/src/models/enums/social_provider.dart | 2 +- lib/src/web/gigya_flutter_plugin_web.dart | 79 ++++++++++--------- .../response/social_connection_response.dart | 7 ++ 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/lib/src/models/enums/social_provider.dart b/lib/src/models/enums/social_provider.dart index 284ab7a8..ee87ff35 100644 --- a/lib/src/models/enums/social_provider.dart +++ b/lib/src/models/enums/social_provider.dart @@ -1,6 +1,6 @@ /// The currently supported social providers. /// -/// Depending on the platform; some social providers might be unavailable. +/// Depending on the platform some social providers might be unavailable. final class SocialProvider { /// The private constructor. const SocialProvider._(this.name); diff --git a/lib/src/web/gigya_flutter_plugin_web.dart b/lib/src/web/gigya_flutter_plugin_web.dart index bebfbeac..faddbe39 100644 --- a/lib/src/web/gigya_flutter_plugin_web.dart +++ b/lib/src/web/gigya_flutter_plugin_web.dart @@ -15,6 +15,7 @@ import 'static_interop/models/profile.dart'; import 'static_interop/parameters/basic.dart'; import 'static_interop/parameters/login.dart'; import 'static_interop/parameters/registration.dart'; +import 'static_interop/parameters/social_connection.dart'; import 'static_interop/response/registration_response.dart'; import 'static_interop/response/response.dart'; import 'static_interop/window.dart'; @@ -41,7 +42,8 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }) { final Completer> completer = Completer>(); - gigyaWebSdk.socialize.addConnection( + GigyaWebSdk.instance.socialize.addConnection.callAsFunction( + null, AddSocialConnectionParameters( authFlow: parameters['authFlow'] as String?, extraFields: parameters['extraFields'] as String?, @@ -52,24 +54,26 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { redirectMethod: parameters['redirectMethod'] as String?, redirectURL: parameters['redirectURL'] as String?, sessionExpiration: parameters['sessionExpiration'] as int?, - callback: allowInterop((SocialConnectionResponse response) { - if (completer.isCompleted) { - return; - } + callback: allowInterop( + (SocialConnectionResponse response) { + if (completer.isCompleted) { + return; + } - if (response.errorCode == 0) { - completer.complete(StaticInteropUtils.responseToMap(response)); - } else { - completer.completeError( - GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - errorCode: response.errorCode, - errorDetails: response.errorDetails, - ), - ); - } - }), + if (response.baseResponse.errorCode == 0) { + completer.complete(response.toMap()); + } else { + completer.completeError( + GigyaError( + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.baseResponse.details, + errorCode: response.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, ), ); @@ -407,30 +411,33 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform { }) { final Completer> completer = Completer>(); - gigyaWebSdk.socialize.removeConnection( + GigyaWebSdk.instance.socialize.removeConnection.callAsFunction( + null, RemoveSocialConnectionParameters( forceProvidersLogout: parameters['forceProvidersLogout'] as bool?, lastIdentityHandling: parameters['lastIdentityHandling'] as String?, provider: provider.name, removeLoginID: parameters['removeLoginID'] as bool?, - callback: allowInterop((SocialConnectionResponse response) { - if (completer.isCompleted) { - return; - } + callback: allowInterop( + (SocialConnectionResponse response) { + if (completer.isCompleted) { + return; + } - if (response.errorCode == 0) { - completer.complete(StaticInteropUtils.responseToMap(response)); - } else { - completer.completeError( - GigyaError( - apiVersion: response.apiVersion, - callId: response.callId, - errorCode: response.errorCode, - errorDetails: response.errorDetails, - ), - ); - } - }), + if (response.baseResponse.errorCode == 0) { + completer.complete(response.toMap()); + } else { + completer.completeError( + GigyaError( + apiVersion: response.baseResponse.apiVersion, + callId: response.baseResponse.callId, + details: response.baseResponse.details, + errorCode: response.baseResponse.errorCode, + ), + ); + } + }, + ).toJS, ), ); diff --git a/lib/src/web/static_interop/response/social_connection_response.dart b/lib/src/web/static_interop/response/social_connection_response.dart index 68d595e5..a54a270f 100644 --- a/lib/src/web/static_interop/response/social_connection_response.dart +++ b/lib/src/web/static_interop/response/social_connection_response.dart @@ -14,4 +14,11 @@ extension type SocialConnectionResponse(Response baseResponse) { /// /// In the web SDK, the `User` and `Profile` objects share the same shape. external Profile get user; + + /// Convert this response to a [Map]. + Map toMap() { + return { + 'user': user.toMap(), + }; + } }