Skip to content

Commit e438b59

Browse files
committed
support webgl
1 parent d4ab0ef commit e438b59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+713
-21
lines changed

src/Packages/Passport/Runtime/Scripts/Private/Core/BrowserCommunicationsManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public BrowserCommunicationsManager(IWebBrowserClient webBrowserClient)
5858
{
5959
this.webBrowserClient = webBrowserClient;
6060
this.webBrowserClient.OnUnityPostMessage += InvokeOnUnityPostMessage;
61-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
61+
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
6262
this.webBrowserClient.OnAuthPostMessage += InvokeOnAuthPostMessage;
6363
this.webBrowserClient.OnPostMessageError += InvokeOnPostMessageError;
6464
#endif

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public async UniTask Init(string clientId, string environment, string redirectUr
5555
this.redirectUri = redirectUri;
5656
this.logoutRedirectUri = logoutRedirectUri;
5757

58-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
58+
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
5959
this.communicationsManager.OnAuthPostMessage += OnDeepLinkActivated;
6060
this.communicationsManager.OnPostMessageError += OnPostMessageError;
6161
#endif
@@ -317,11 +317,14 @@ public async void OnDeepLinkActivated(string url)
317317
PassportLogger.Info($"{TAG} Received deeplink URL: {url}");
318318

319319
Uri uri = new Uri(url);
320-
string domain = $"{uri.Scheme}://{uri.Host}{uri.AbsolutePath}";
321-
if (domain.EndsWith("/"))
320+
string hostWithPort = uri.IsDefaultPort ? uri.Host : $"{uri.Host}:{uri.Port}";
321+
322+
if (hostWithPort.EndsWith("/"))
322323
{
323-
domain = domain.Remove(domain.Length - 1);
324+
hostWithPort = hostWithPort.Remove(hostWithPort.Length - 1);
324325
}
326+
327+
string domain = $"{uri.Scheme}://{hostWithPort}{uri.AbsolutePath}";
325328

326329
if (domain.Equals(logoutRedirectUri))
327330
{
@@ -433,7 +436,7 @@ public async UniTask CompleteLoginPKCEFlow(string uriString)
433436
Uri uri = new Uri(uriString);
434437
string state = uri.GetQueryParameter("state");
435438
string authCode = uri.GetQueryParameter("code");
436-
439+
PassportLogger.Debug($"{TAG} CompleteLoginPKCEFlow: {state} {authCode}");
437440
if (String.IsNullOrEmpty(state) || String.IsNullOrEmpty(authCode))
438441
{
439442
Track(

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,18 @@ private async UniTask Initialise(
189189
#endif
190190

191191
// Set up browser communication
192-
// BrowserCommunicationsManager communicationsManager = new BrowserCommunicationsManager(webBrowserClient);
192+
BrowserCommunicationsManager communicationsManager = new BrowserCommunicationsManager(webBrowserClient);
193193

194194
#if UNITY_WEBGL
195195
readySignalReceived = true;
196196
#else
197197
// Mark ready when browser is initialised and game bridge file is loaded
198-
// communicationsManager.OnReady += () => readySignalReceived = true;
198+
communicationsManager.OnReady += () => readySignalReceived = true;
199199
#endif
200200
// Set up Passport implementation
201-
// passportImpl = new PassportImpl(communicationsManager);
202-
// // Subscribe to Passport authentication events
203-
// passportImpl.OnAuthEvent += OnPassportAuthEvent;
201+
passportImpl = new PassportImpl(communicationsManager);
202+
// Subscribe to Passport authentication events
203+
passportImpl.OnAuthEvent += OnPassportAuthEvent;
204204
}
205205
catch (Exception ex)
206206
{
@@ -241,7 +241,7 @@ public async UniTask<bool> ConnectImx(bool useCachedSession = false, Nullable<lo
241241
return await GetPassportImpl().ConnectImx(useCachedSession, timeoutMs);
242242
}
243243

244-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX
244+
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
245245
/// <summary>
246246
/// Connects the user into Passport via PKCE auth.
247247
/// </summary>

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebGLTemplates.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebGLTemplates/unity-webview.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebGLTemplates/unity-webview/Passport.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)