Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions Assets/SequenceSDK/Authentication/AWSEmailSignIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ public class AWSEmailSignIn : IEmailSignIn
{
private string _region;
private string _cognitoClientId;
private string _nonce;

public AWSEmailSignIn(string region, string cognitoClientId)
public AWSEmailSignIn(string region, string cognitoClientId, string nonce)
{
_region = region;
_cognitoClientId = cognitoClientId;
_nonce = nonce;
}

public async Task<string> SignIn(string email)
Expand All @@ -34,7 +36,11 @@ public async Task<string> SignIn(string email)
{
{ "USERNAME", email }
},
ClientId = _cognitoClientId
ClientId = _cognitoClientId,
ClientMetadata = new Dictionary<string, string>()
{
{ "SESSION_HASH", _nonce}
}
};
try
{
Expand All @@ -59,15 +65,12 @@ public async Task<string> Login(string challengeSession, string email, string co
{ "ANSWER", code }
},
ClientId = _cognitoClientId,
Session = challengeSession
};
if (!string.IsNullOrWhiteSpace(sessionWalletAddress))
{
request.ClientMetadata = new Dictionary<string, string>
Session = challengeSession,
ClientMetadata = new Dictionary<string, string>()
{
{ "SESSION_HASH", sessionWalletAddress }
};
}
{ "SESSION_HASH", _nonce}
}
};

try
{
Expand Down
7 changes: 4 additions & 3 deletions Assets/SequenceSDK/WaaS/WaaSLogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ public WaaSLogin(IValidator validator = null)

_sessionWallet = new EthWallet();
_sessionId = IntentDataOpenSession.CreateSessionId(_sessionWallet.GetAddress());

_authenticator = new OpenIdAuthenticator(SequenceCoder.KeccakHashASCII(_sessionId).EnsureHexPrefix());

string nonce = SequenceCoder.KeccakHashASCII(_sessionId).EnsureHexPrefix();
_authenticator = new OpenIdAuthenticator(nonce);
_authenticator.PlatformSpecificSetup();
Application.deepLinkActivated += _authenticator.HandleDeepLink;
_authenticator.SignedIn += OnSocialLogin;
Expand All @@ -75,7 +76,7 @@ public WaaSLogin(IValidator validator = null)

try
{
_emailSignIn = new AWSEmailSignIn(configJwt.emailRegion, configJwt.emailClientId);
_emailSignIn = new AWSEmailSignIn(configJwt.emailRegion, configJwt.emailClientId, nonce);
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xyz.0xsequence.waas-unity",
"version": "2.4.4",
"version": "2.5.0",
"displayName": "Sequence WaaS SDK",
"description": "A Unity SDK for the Sequence WaaS API",
"unity": "2021.3",
Expand Down