Skip to content

Gigya Web SDK integration - make example start properly on the web #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 186 commits into
base: main
Choose a base branch
from

Conversation

navaronbracke
Copy link
Contributor

@navaronbracke navaronbracke commented Mar 14, 2023

This PR has been migrated to the new "extension types" syntax for JS static interop. This is a new language feature, that is still in development. This PR will be ready to review after that feature has shipped into stable.

This PR should be merged after #69 has been merged, as it builds upon it.

This PR implements the following methods for the web plugin implementation, so that the example app runs without errors at startup.

  • initSdk()
  • isLoggedIn()
  • logout()
  • login()

This PR includes a stub for the InterruptionResolverFactory, to make the example app run on the web.
This implementation still needs further implementing. But I will do that later.

The other two services, OtpService and WebAuthenticationService have not yet been implemented.

Related #44

Note: Due to using Dart's static Javascript interop, I needed to add a dependency on js 0.6.6 or higher, which requires Flutter 3.10 or higher. For that I had to bump the minimum Flutter version to 3.10

@navaronbracke navaronbracke changed the base branch from main to develop April 4, 2023 06:57
@navaronbracke navaronbracke marked this pull request as ready for review April 4, 2023 07:13
@navaronbracke navaronbracke changed the title [WIP] Gigya Web SDK integration Gigya Web SDK integration - example app bootstrapping Apr 4, 2023
@navaronbracke
Copy link
Contributor Author

@tal-mi Since #41 has been merged (thanks for the amazing work getting this landed!), I updated this PR so we can get started with integrating the web SDK.

Currently, Flutter 3.7.8 (the current stable release) does not allow js 0.6.6 so we cannot ship a new version until it does.
Since my previous PR was very big, I'll split the web integration into smaller parts. This initial work will be the largest part, as it involves getting the basics working. For the other PR's, I'll take smaller sections of the API (i.e. one for account + social providers, or something like that)

this.verifiedTimestamp,
});

/// Construct an account from the given [json].
factory Account.fromJson(Map<String, dynamic> json) {
final Map<String, dynamic>? emails = json['emails'] == null ? null : json['emails'].cast<String, dynamic>() as Map<String, dynamic>;
final Map<String, dynamic>? profile = json['profile'] == null ? null : json['profile'].cast<String, dynamic>() as Map<String, dynamic>;
final Map<String, dynamic>? emails = json['emails'] as Map<String, dynamic>?;
Copy link
Contributor Author

@navaronbracke navaronbracke Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sagishm I noticed that you had changed to parsing of the emails / profile to handle the null case and casting to a Map.

Casting to a nullable Map, using as Map<String, dynamic>? should already handle both the null and Map<String, dynamic> cases (the ? handles nullable types). Also, using cast<K, V>() on a Map and then doing another cast using as, is redundant. So I restored the original code (from #41) here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
This change occurred because the code caused a parsing crash during our testing phase.
We believe it's a temporary Flutter version issue with LinkedHanshMap parsing.
We will keep it on hold until its clears and revert the change.
Thanks.

Copy link
Contributor Author

@navaronbracke navaronbracke Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tal-mi I think I know what might be happening. The actual map is probably a Map<Object?, Object?>, which is what the binary messenger of the method channel returns. That type will indeed fail the forced cast with as, so in that case using cast<K,V>() is correct. I pushed a commit that should fix it for the account class. If there are other cases, we should fix that as we go I think?

For reference, I had to do the same thing with the screenset events stream.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, think that might be it. We will fix it for sure.
We are currently going into the holidays so not many working days are available for the next two weeks.
One thing that is important. Because we are now on v1.0.0 of the plugin, breaking changes are a bit more difficult to approve due to how SAP handles customer notifications. Take that in mind for massive changes.
Of course, changes that are improving the plugin significantly will be prioritized.
Thanks again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that any version after 1.0.0 needs to take care of breaking changes. Flutter's first party packages under flutter/packages follow a similar rule. The breaking changes in this PR should be relatively minor. I'll follow up with smaller PR's for the remaining web API's.

The web portion of the plugin will stay experimental until we can get all the major features from the mobile SDK implemented.

Enjoy the holidays!

@navaronbracke
Copy link
Contributor Author

@tal-mi If you have time to get this reviewed, we should be able to land experimental web support for users of Flutter 3.10 now.
Flutter 3.10 requires js 0.6.7 which resolves the version conflict I had earlier (I needed 0.6.6 or higher for @staticInterop)

@navaronbracke
Copy link
Contributor Author

@tal-mi I tested all 4 methods that were implemented here and fixed the bugs I could find. (mostly null values, and one thing relating to Hot Reload)

If you have the time to review this one, it would be greatly appreciated.
Then we can start working towards landing more features for the web implementation.

@navaronbracke
Copy link
Contributor Author

@tal-mi This initial PR to start on the Web SDK has gotten a little large, I'll split it up into smaller pieces for easier review.

@navaronbracke navaronbracke reopened this Jun 5, 2023
@navaronbracke navaronbracke marked this pull request as draft June 5, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants