Skip to content

Commit

Permalink
Feature/new waas auth (#146)
Browse files Browse the repository at this point in the history
* Attempt to restore session in Start as opposed to Awake so that UI pages have a chance to cache their gameobject and other references

* Allow us to call OpenInitialPage multiple times without creating a race condition by checking if the current page open is the InitialPage

* ILogin's should set themselves up; no need to rely on the UI to do it

* Increment package version

* Unsubscribe to the WaaSWallet.OnFailedToLoginWithStoredSessionWallet event in LoginPanel's OnDestroy so that we don't have duplicate event handlers when dealing with multiple scenes

* TearDownLoginHandler in OnDestroy for LoginPanel so we don't have duplicate event subscribers

* Try to recover session when LoginPanel is opened as opposed to in start - more flexible

* Revert "ILogin's should set themselves up; no need to rely on the UI to do it"

This reverts commit 1564e8e.

* Moved SDK to a LocalPackages folder and imported it locally

* Don't import editor scripts in with samples

* move tests under Assets so we can pick them up in the editor

* Update build settings

* Put editor scripts into editor assemdef so that they work from the packages folder

* increment package version

* Move mocks into Assets folder so they are not included in the package

* Move package to Packages folder (i.e. make it embedded instead of local) instead of LocalPackages

* Migrate email auth over to new auth system, including a refactoring such that the email auth logic is handled primarily in EmailConnector. Increment package version

* Remove AWSEmailSignIn and IEmailSignIn interface as they are no longer required. Update InitiateEmailSignInUnitTests

* Migrated OIDC-based auth to new auth system

* In MultifactorAuthenticationPage, subscribe to login fails event in open instead of awake because this leads to double error logging

* Added data types for account federation

* Added guest login

* Added playfab login support

* Update GuestLogin test implementation to work similar to the playfab auth implementation and sign in multiple times

* Modify LoginPanel such that it only displays the buttons available for the given platform

* Now that we have federated auth support on the API, we no longer need to notify users that they are logging in with the wrong account first.

* Show email used to login in default UI regardless of whether or not they
signed in with email - this will help to remind the user which email to
login with via social login or otherwise. Since this behaviour may not
be desired by all integrators, I've made Start a protected virtual
function so that it can easily be overriden by an inherriting class.

* Instead of overriding start, now you override SetEmailInputInitialText

* Added federated auth and account overriding

* validate guest logins work and update PlayFab test scene to cycle through the 3 login methods for playfab

* New end to end session management tests using guest logins

* More accurate text in confirmation page and renamed methods. Force create account doesn't replace your current account, it just creates a second account - so you have multiple wallets under the same email

* Added test for auth federation

* Added methods to federate auth for accounts that haven't yet initiated auth

* Prettier UI

* remove temporary playfab credentials

* Fix tests

* Remove nonce from OpenIdAuthenticator as it is no longer required

* Renamed WaaSWallet to EmbeddedWallet. Renamed EthWallet to EoaWallet

* renamed OnFailedToLoginWithStoredSessionWallet event to OnFailedToRecoverSession

* Renamed OnWaaSWalletCreated event to OnWalletCreated

* Remove Indexer from event names

* Rename EmbeddedWallet (originally WaaSWallet) to Wallet

* Rename WaaSSessionManager to SessionManager

* Rename WaaSToWalletAdapter to WalletToEoaWalletAdapter

* Rename EOAWalletLinker to EoaWalletLinker

* Rename Wallet (formerly WaaSWallet) to SequenceWallet

* rename WaaSLogin to SequenceLogin

* Remove hardcoded url for waas as this dev env link is included in dev credentials

* Rename WaaS assembly to EmbeddedWallet

* Rename Eoa instances to EOA

* Remove AWS sdk from sdk

* Fix apple auth

* Redirect to localhost when in editor and throw error for discord/facebook sign in

* Added SequenceConnector prefab to Useful Scripts sample

* Rename Sequence.WaaS namespace to Sequence.EmbeddedWallet

* Remove more mentions of waas

* More renamings

* Hardcode waas version in config - users shouldn't need to update this

* Fix broken test

* Fix broken test

* Fix formatting

* Fix test reference

* Add a formerly serialized as attribute so we don't need to re-attach the WaaSSessionManager prefab

* Remove trailing slash from state token if present

* Validate we receive a proper transaction hash from PermissionedMinter

* Rename sequenceconfig variable

* Fix email validation and error handling when initiating email auth (error was getting swallowed)

* Don't include Android Manifest in Packages folder as this may conflict with custom manifest files already defined by the integrator

* Fix configuration sequence for SequenceLogin

* Check if inputfield is null before setting text in LoginPage, if so try to find it and return early if unsuccessful

* Added test for signing messages with SequenceWallet

* Switch test back to Arbitrum Nova

* Fix account federation bug for email

* Add spacing between buttons in FederatedAuthPopupPanel prefab

* Don't log warning if aws config missing as it isn't needed

* Added delayedencode test

* Fix account federation logic in connectors. Added account federation test. Cleaner end to end test setup that doesn't subscribe to events increasingly more as the test gets ran more times in a session (a session being when the editor is open)

* Fix memory leaks when web requests throw exceptions

* Update email validator tests for new validator

* Added adrs for the new auth system and for the localpackage refactoring

* Fixed compile error in SequenceConnector and added a note to consequences section of ADR that Unity doesn't check for compile errors here
  • Loading branch information
BellringerQuinn authored Jul 25, 2024
1 parent 322bf16 commit 1580ecd
Show file tree
Hide file tree
Showing 1,545 changed files with 86,657 additions and 1,746 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/[Aa]ssets/Resources.meta
/[Aa]ssets/Samples
/[Aa]ssets/Samples~/Setup/Resources/SequenceConfig.asset
/[Aa]ssets/Samples.meta

# Recordings can get excessive in size
/[Rr]ecordings/
Expand Down Expand Up @@ -113,3 +114,6 @@ testchain/artifacts/build-info
testchain/cache/

package-lock.json

# Test config
Assets/SequenceSDK/WaaS/Tests/Resources/
2 changes: 1 addition & 1 deletion Assets/Plugins/AWS.meta → Assets/GuestLogin.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions Assets/GuestLogin/GuestLogin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections;
using System.Threading.Tasks;
using Sequence.Authentication;
using Sequence.EmbeddedWallet;
using TMPro;
using UnityEngine;

namespace GuestLogin
{
public class GuestLogin : MonoBehaviour
{
private ILogin _login;
private int _signOuts = 0;
private IWallet _wallet;
private void Awake()
{
_login = SequenceLogin.GetInstance();
_login.OnLoginFailed += (error, method, email) =>
{
Debug.LogError(error);
};
SequenceWallet.OnWalletCreated += OnWaaSWalletCreated;
}

private void Start()
{
_login.GuestLogin();
}

private void OnWaaSWalletCreated(SequenceWallet wallet)
{
TextMeshProUGUI text = GetComponent<TextMeshProUGUI>();
text.text = "Logged in as: " + wallet.GetWalletAddress();
_wallet = wallet;

StartCoroutine(SignOutThenSignBackIn());
}

private IEnumerator SignOutThenSignBackIn()
{
if (_signOuts > 1)
{
yield return null;
}
else
{
yield return new WaitForSeconds(3f);

TextMeshProUGUI text = GetComponent<TextMeshProUGUI>();
text.text = "Logged out";

Task signOutTask = _wallet.DropThisSession();
yield return new WaitUntil(() => signOutTask.IsCompleted);
_signOuts++;
_wallet = null;

_login.GuestLogin();
}
}
}
}
3 changes: 3 additions & 0 deletions Assets/GuestLogin/GuestLogin.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1580ecd

Please sign in to comment.