Skip to content

Commit 9b04e0c

Browse files
authored
Merge pull request #454 from immutable/feat/windows-deeplink
[DX-3682] feat: windows pkce (alpha)
2 parents 72434ec + 6e3c5c3 commit 9b04e0c

File tree

16 files changed

+435
-89
lines changed

16 files changed

+435
-89
lines changed

sample/Assets/Scenes/Passport/SelectAuthMethod.unity

+6-6
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ MonoBehaviour:
206206
m_TargetGraphic: {fileID: 416242725}
207207
m_HandleRect: {fileID: 416242724}
208208
m_Direction: 0
209-
m_Value: 0
209+
m_Value: 1
210210
m_Size: 1
211211
m_NumberOfSteps: 0
212212
m_OnValueChanged:
@@ -1323,7 +1323,7 @@ MonoBehaviour:
13231323
m_TargetGraphic: {fileID: 167431872}
13241324
m_HandleRect: {fileID: 167431871}
13251325
m_Direction: 2
1326-
m_Value: 1
1326+
m_Value: 0
13271327
m_Size: 1
13281328
m_NumberOfSteps: 0
13291329
m_OnValueChanged:
@@ -1673,8 +1673,8 @@ RectTransform:
16731673
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
16741674
m_AnchorMin: {x: 0, y: 0}
16751675
m_AnchorMax: {x: 0, y: 0}
1676-
m_AnchoredPosition: {x: 1016.24, y: 0}
1677-
m_SizeDelta: {x: 1992.48, y: 0}
1676+
m_AnchoredPosition: {x: 841.51855, y: 0}
1677+
m_SizeDelta: {x: 1643.0371, y: 0}
16781678
m_Pivot: {x: 0.5, y: 0.5}
16791679
--- !u!114 &1661390145
16801680
MonoBehaviour:
@@ -1768,8 +1768,8 @@ RectTransform:
17681768
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
17691769
m_AnchorMin: {x: 0, y: 0}
17701770
m_AnchorMax: {x: 0, y: 0}
1771-
m_AnchoredPosition: {x: 1016.24, y: 0}
1772-
m_SizeDelta: {x: 1992.48, y: 0}
1771+
m_AnchoredPosition: {x: 841.51855, y: 0}
1772+
m_SizeDelta: {x: 1643.0371, y: 0}
17731773
m_Pivot: {x: 0.5, y: 0.5}
17741774
--- !u!114 &1688502349
17751775
MonoBehaviour:

sample/Assets/Scripts/Passport/AuthenticatedScript.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,9 @@ public async void Logout()
186186
try
187187
{
188188
// Logout using the appropriate logout method
189-
if (SampleAppManager.SupportsPKCE && SampleAppManager.UsePKCE)
189+
if (SampleAppManager.UsePKCE)
190190
{
191-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
192191
await Passport.LogoutPKCE();
193-
#endif
194192
}
195193
else
196194
{

sample/Assets/Scripts/Passport/SampleAppManager.cs

-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
public static class SampleAppManager
22
{
3-
/// <summary>
4-
/// Indicates whether the running platform supports PKCE.
5-
/// </summary>
6-
public static bool SupportsPKCE { get; set; }
7-
83
/// <summary>
94
/// Indicates whether the selected authentication method is PKCE.
105
/// </summary>

sample/Assets/Scripts/Passport/SelectAuthMethodScript.cs

-21
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,9 @@ public class SelectAuthMethodScript : MonoBehaviour
1616

1717
void Start()
1818
{
19-
// Determine if PKCE is supported based on the platform
20-
SampleAppManager.SupportsPKCE = IsPKCESupported();
21-
2219
// WebGL does not support Device Code Auth, so we'll use PKCE by default instead.
2320
#if UNITY_WEBGL
2421
UsePKCE();
25-
#else
26-
// If PKCE is not supported, initialise Passport to use Device Code Auth
27-
if (!SampleAppManager.SupportsPKCE)
28-
{
29-
UseDeviceCodeAuth();
30-
}
31-
#endif
32-
}
33-
34-
/// <summary>
35-
/// Checks if the current platform supports PKCE authentication.
36-
/// </summary>
37-
private bool IsPKCESupported()
38-
{
39-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
40-
return true;
41-
#else
42-
return false;
4322
#endif
4423
}
4524

sample/Assets/Scripts/Passport/UnauthenticatedScript.cs

+3-9
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ public async void Login()
6767
try
6868
{
6969
// Login using the appropriate login method
70-
if (SampleAppManager.SupportsPKCE && SampleAppManager.UsePKCE)
70+
if (SampleAppManager.UsePKCE)
7171
{
72-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
7372
await Passport.LoginPKCE();
74-
#endif
7573
}
7674
else
7775
{
@@ -109,11 +107,9 @@ public async void Connect()
109107
try
110108
{
111109
// Login and connect to IMX using the appropriate connect method
112-
if (SampleAppManager.SupportsPKCE && SampleAppManager.UsePKCE)
110+
if (SampleAppManager.UsePKCE)
113111
{
114-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
115112
await Passport.ConnectImxPKCE();
116-
#endif
117113
}
118114
else
119115
{
@@ -206,11 +202,9 @@ private async UniTask Logout()
206202
try
207203
{
208204
// Logout using the appropriate logout method
209-
if (SampleAppManager.SupportsPKCE && SampleAppManager.UsePKCE)
205+
if (SampleAppManager.UsePKCE)
210206
{
211-
#if (UNITY_ANDROID && !UNITY_EDITOR_WIN) || (UNITY_IPHONE && !UNITY_EDITOR_WIN) || UNITY_STANDALONE_OSX || UNITY_WEBGL
212207
await Passport.LogoutPKCE();
213-
#endif
214208
}
215209
else
216210
{

sample/Tests/test/test_windows.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def tearDownClass(cls):
2020
stop_sample_app()
2121

2222
def test_1_device_code_login(self):
23+
# Select use device code auth
24+
self.altdriver.find_object(By.NAME, "DeviceCodeAuth").tap()
25+
2326
# Wait for unauthenticated screen
2427
self.altdriver.wait_for_current_scene_to_be("UnauthenticatedScene")
2528

@@ -48,9 +51,12 @@ def test_1_device_code_login(self):
4851
if attempt == 0:
4952
# Reset app
5053

51-
# Relogin
54+
# Relogin (optional: only if the button is present)
5255
print("Try reset the app and log out once...")
53-
self.altdriver.wait_for_object(By.NAME, "ReloginBtn").tap()
56+
try:
57+
self.altdriver.wait_for_object(By.NAME, "ReloginBtn").tap()
58+
except Exception as e:
59+
print("ReloginBtn not found, skipping relogin step. User may already be in AuthenticatedScene.")
5460

5561
# Wait for authenticated screen
5662
self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene")
@@ -95,6 +101,9 @@ def test_6_relogin(self):
95101
self.altdriver = AltDriver()
96102
time.sleep(5)
97103

104+
# Select use device code auth
105+
self.altdriver.find_object(By.NAME, "DeviceCodeAuth").tap()
106+
98107
# Relogin
99108
print("Re-logging in...")
100109
self.altdriver.wait_for_object(By.NAME, "ReloginBtn").tap()
@@ -124,6 +133,9 @@ def test_7_reconnect_device_code_connect_imx(self):
124133
self.altdriver = AltDriver()
125134
time.sleep(5)
126135

136+
# Select use device code auth
137+
self.altdriver.find_object(By.NAME, "DeviceCodeAuth").tap()
138+
127139
# Reconnect
128140
print("Reconnecting...")
129141
self.altdriver.wait_for_object(By.NAME, "ReconnectBtn").tap()

src/Packages/Passport/Private.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Packages/Passport/Private/Helpers.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)