Skip to content

Commit 74cddc8

Browse files
Merge branch 'main' into feat/embedded-login-webviews
2 parents 1970ee8 + c1766a9 commit 74cddc8

39 files changed

Lines changed: 640 additions & 43 deletions

src/Packages/Marketplace/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.immutable.marketplace",
3-
"version": "1.36.4",
3+
"version": "1.36.5",
44
"description": "Marketplace package for the Immutable SDK for Unity",
55
"displayName": "Immutable Marketplace",
66
"author": {

src/Packages/Passport/Runtime/Resources/index.html

Lines changed: 3 additions & 4 deletions
Large diffs are not rendered by default.

src/Packages/Passport/Runtime/Scripts/Private/Core/Model/BrowserResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ public class BrowserResponse
88
public string requestId;
99
public bool success;
1010
public string errorType;
11-
public string error;
11+
public string? error;
1212
}
1313

1414
public class StringResponse : BrowserResponse
1515
{
16-
public string result;
16+
public string? result;
1717
}
1818

1919
public class StringListResponse : BrowserResponse

src/Packages/Passport/Runtime/Scripts/Private/Helpers/SdkVersionInfoHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public class SdkVersionInfoHelpers
44
{
55
public static string GetSdkVersionInfo()
66
{
7-
return "1.36.4";
7+
return "1.36.5";
88
}
99
}
1010
}

src/Packages/Passport/Runtime/Scripts/Private/Helpers/WindowsDeepLink.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ private static string GetGameExecutablePath(string suffix)
299299
if (suffix == ".exe")
300300
{
301301
// Get the path of the currently running executable
302+
#if !ENABLE_IL2CPP
303+
// Process.MainModule is only supported in Mono builds, not in IL2CPP, and will cause a crash
302304
try
303305
{
304306
var process = System.Diagnostics.Process.GetCurrentProcess();
@@ -315,6 +317,7 @@ private static string GetGameExecutablePath(string suffix)
315317
{
316318
PassportLogger.Warn($"Process inaccessible: {ex.Message}. Using fallback method.");
317319
}
320+
#endif
318321

319322
// Fallback: Use command line args
320323
var args = System.Environment.GetCommandLineArgs();

src/Packages/Passport/Runtime/Scripts/Private/Model/Response/TokenResponse.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ namespace Immutable.Passport.Model
55
[Serializable]
66
public class TokenResponse
77
{
8-
public string accessToken;
9-
public string refreshToken;
10-
public string idToken;
11-
public string tokenType;
12-
public int expiresIn;
8+
public string access_token;
9+
public string refresh_token;
10+
public string id_token;
11+
public string token_type;
12+
public int expires_in;
1313
}
1414
}

src/Packages/Passport/Runtime/Scripts/Private/PassportFunction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static class PassportFunction
1414
public const string GET_EMAIL = "getEmail";
1515
public const string GET_PASSPORT_ID = "getPassportId";
1616
public const string GET_LINKED_ADDRESSES = "getLinkedAddresses";
17+
public const string STORE_TOKENS = "storeTokens";
1718
public static class IMX
1819
{
1920
public const string GET_ADDRESS = "getAddress";

src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,13 @@ public async UniTask<bool> HasCredentialsSaved()
517517
}
518518
}
519519

520+
public async UniTask<bool> CompleteLogin(TokenResponse request)
521+
{
522+
var json = JsonUtility.ToJson(request);
523+
var callResponse = await _communicationsManager.Call(PassportFunction.STORE_TOKENS, json);
524+
return callResponse.GetBoolResponse() ?? false;
525+
}
526+
520527
public async UniTask<string?> GetAddress()
521528
{
522529
var response = await _communicationsManager.Call(PassportFunction.IMX.GET_ADDRESS);

src/Packages/Passport/Runtime/Scripts/Public/Passport.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,19 @@ public async UniTask<bool> ConnectImx(bool useCachedSession = false, DirectLogin
314314
return await GetPassportImpl().ConnectImx(useCachedSession, directLoginOptions);
315315
}
316316

317+
/// <summary>
318+
/// Completes the login process by storing tokens received from the Bring Your Own Auth API token exchange endpoint.
319+
/// This method enables authentication using existing auth systems without requiring users to log in twice.q
320+
/// </summary>
321+
/// <param name="request">The token request</param>
322+
/// <returns>
323+
/// True if successful, otherwise false.
324+
/// </returns>
325+
public async UniTask<bool> CompleteLogin(TokenResponse request)
326+
{
327+
return await GetPassportImpl().CompleteLogin(request);
328+
}
329+
317330
/// <summary>
318331
/// Gets the wallet address of the logged in user.
319332
/// <returns>

src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/Passport/Login/LoginScript.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,51 +27,52 @@ void Start()
2727
ShowOutput("Passport Instance is null");
2828
}
2929

30-
// Set up button listeners if buttons are assigned
31-
if (DefaultLoginButton != null) DefaultLoginButton.onClick.AddListener(() => Login(DirectLoginMethod.None));
32-
if (GoogleLoginButton != null) GoogleLoginButton.onClick.AddListener(() => Login(DirectLoginMethod.Google));
33-
if (AppleLoginButton != null) AppleLoginButton.onClick.AddListener(() => Login(DirectLoginMethod.Apple));
34-
if (FacebookLoginButton != null) FacebookLoginButton.onClick.AddListener(() => Login(DirectLoginMethod.Facebook));
30+
// Set up button listeners using DirectLoginOptions
31+
if (DefaultLoginButton != null) DefaultLoginButton.onClick.AddListener(() => Login(new DirectLoginOptions()));
32+
if (GoogleLoginButton != null) GoogleLoginButton.onClick.AddListener(() => Login(new DirectLoginOptions(DirectLoginMethod.Google)));
33+
if (AppleLoginButton != null) AppleLoginButton.onClick.AddListener(() => Login(new DirectLoginOptions(DirectLoginMethod.Apple)));
34+
if (FacebookLoginButton != null) FacebookLoginButton.onClick.AddListener(() => Login(new DirectLoginOptions(DirectLoginMethod.Facebook)));
3535
}
3636

3737
/// <summary>
3838
/// Logs into Passport using the default auth method.
3939
/// </summary>
4040
public async void Login()
4141
{
42-
await LoginAsync(DirectLoginMethod.None);
42+
await LoginAsync(new DirectLoginOptions());
4343
}
4444

4545
/// <summary>
46-
/// Logs into Passport using the specified direct login method.
46+
/// Logs into Passport using the specified direct login options.
4747
/// </summary>
48-
/// <param name="directLoginMethod">The direct login method to use (Google, Apple, Facebook, or None for default)</param>
49-
public async void Login(DirectLoginMethod directLoginMethod)
48+
/// <param name="directLoginOptions">The direct login options</param>
49+
public async void Login(DirectLoginOptions directLoginOptions)
5050
{
51-
await LoginAsync(directLoginMethod);
51+
await LoginAsync(directLoginOptions);
5252
}
5353

5454
/// <summary>
5555
/// Internal async method that performs the actual login logic.
5656
/// </summary>
57-
/// <param name="directLoginMethod">The direct login method to use</param>
58-
private async System.Threading.Tasks.Task LoginAsync(DirectLoginMethod directLoginMethod)
57+
/// <param name="directLoginOptions">The direct login options</param>
58+
private async System.Threading.Tasks.Task LoginAsync(DirectLoginOptions directLoginOptions)
5959
{
6060
try
6161
{
62-
string methodName = directLoginMethod == DirectLoginMethod.None ? "default" : directLoginMethod.ToString();
63-
ShowOutput($"Logging in with {methodName} method...");
62+
string directLoginMethod = directLoginOptions.directLoginMethod.ToString().ToLower();
6463

65-
bool success = await Passport.Login(useCachedSession: false, directLoginMethod: directLoginMethod);
64+
ShowOutput($"Logging in with {directLoginMethod} method...");
65+
66+
bool success = await Passport.Login(useCachedSession: false, directLoginOptions: directLoginOptions);
6667

6768
if (success)
6869
{
69-
ShowOutput($"Successfully logged in with {methodName}");
70+
ShowOutput($"Successfully logged in with {directLoginMethod}");
7071
SceneManager.LoadScene("AuthenticatedScene");
7172
}
7273
else
7374
{
74-
ShowOutput($"Failed to log in with {methodName}");
75+
ShowOutput($"Failed to log in with {directLoginMethod}");
7576
}
7677
}
7778
catch (OperationCanceledException ex)

0 commit comments

Comments
 (0)