expo-dev-launcher 58.0.20 → 58.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Sign in to the launcher on a simulator or an emulator from the `__expo_device_code`, `__expo_device_match`, and `__expo_device_client` launch URL params. ([#53977](https://github.com/expo/expo/pull/53977) by [@gabrieldonadel](https://github.com/gabrieldonadel))
8
+
9
+ ## 58.0.21
10
+
11
+ ### Patch Changes
12
+
13
+ - Stop using the deprecated `profilePhoto` and `Update.runtimeVersion` GraphQL fields. ([#53410](https://github.com/expo/expo/pull/53410) by [@tchayen](https://github.com/tchayen))
14
+ - [iOS] Connect to the development server's `/message` socket and network inspector on port 443 when the bundle URL is `https` with no port, such as an `expo start --tunnel` URL. ([#53466](https://github.com/expo/expo/pull/53466) by [@vonovak](https://github.com/vonovak))
15
+
3
16
  ## 58.0.20
4
17
 
5
18
  ### Patch Changes
@@ -24,13 +24,13 @@ expoModule {
24
24
  }
25
25
 
26
26
  group = "host.exp.exponent"
27
- version = "58.0.20"
27
+ version = "58.1.0"
28
28
 
29
29
  android {
30
30
  namespace "expo.modules.devlauncher"
31
31
  defaultConfig {
32
32
  versionCode 9
33
- versionName "58.0.20"
33
+ versionName "58.1.0"
34
34
  }
35
35
 
36
36
  buildTypes {
@@ -41,6 +41,7 @@ import expo.modules.devlauncher.logs.DevLauncherRemoteLogManager
41
41
  import expo.modules.devlauncher.react.activitydelegates.DevLauncherReactActivityNOPDelegate
42
42
  import expo.modules.devlauncher.react.activitydelegates.DevLauncherReactActivityRedirectDelegate
43
43
  import expo.modules.devlauncher.services.DependencyInjection
44
+ import expo.modules.devlauncher.services.signInFromLaunchUrl
44
45
  import expo.modules.devmenu.launch.ExpoLauncherUrl
45
46
  import expo.modules.devmenu.launch.applyDevMenuLaunchParams
46
47
  import expo.modules.kotlin.weak
@@ -307,6 +308,7 @@ class DevLauncherController private constructor(
307
308
 
308
309
  // The dev menu params apply to every launcher command, with or without a `__expo_url`.
309
310
  DependencyInjection.devMenuPreferences?.let { launch.applyDevMenuLaunchParams(it) }
311
+ coroutineScope.launch { signInFromLaunchUrl(uri) }
310
312
 
311
313
  if (launch.targetUrl == null) {
312
314
  if (!launch.isLegacyHost && launch.remainderHasDestination) {
@@ -53,7 +53,7 @@ class ProfileViewModel : ViewModel() {
53
53
  Account(
54
54
  id = account.id,
55
55
  name = account.name,
56
- avatar = account.ownerUserActor?.profilePhoto,
56
+ avatar = account.ownerUserActor?.primaryAccountProfileImageUrl,
57
57
  isSelected = account.id == newUserState.selectedAccount?.id
58
58
  )
59
59
  } ?: emptyList()
@@ -100,7 +100,7 @@ fun AppHeader(
100
100
  modifier = Modifier.size(44.dp),
101
101
  contentAlignment = Alignment.Center
102
102
  ) {
103
- val profilePhoto = currentAccount?.ownerUserActor?.profilePhoto
103
+ val profilePhoto = currentAccount?.ownerUserActor?.primaryAccountProfileImageUrl
104
104
 
105
105
  if (profilePhoto != null) {
106
106
  AsyncImage(
@@ -0,0 +1,103 @@
1
+ package expo.modules.devlauncher.services
2
+
3
+ import android.net.Uri
4
+ import android.util.Log
5
+ import expo.modules.core.utilities.EmulatorUtilities
6
+ import expo.modules.devlauncher.compose.Session
7
+ import expo.modules.devlauncher.helpers.await
8
+ import okhttp3.MediaType.Companion.toMediaType
9
+ import okhttp3.Request
10
+ import okhttp3.RequestBody.Companion.toRequestBody
11
+ import org.json.JSONObject
12
+
13
+ private const val TAG = "DevLauncherDeviceLogin"
14
+
15
+ /** Set by a sign out and cleared by a sign in: a launch URL does not undo a sign out. */
16
+ internal const val SIGNED_OUT_KEY = "signed_out"
17
+
18
+ /** The `__expo_device_*` params of a launch URL. */
19
+ data class DeviceLoginRequest(
20
+ val deviceCode: String,
21
+ val matchValue: String,
22
+ val clientId: String
23
+ ) {
24
+ companion object {
25
+ fun parse(uri: Uri): DeviceLoginRequest? {
26
+ if (!uri.isHierarchical) {
27
+ return null
28
+ }
29
+ fun query(name: String) = uri.getQueryParameter(name)?.takeIf { it.isNotEmpty() }
30
+
31
+ return DeviceLoginRequest(
32
+ deviceCode = query("__expo_device_code") ?: return null,
33
+ matchValue = query("__expo_device_match") ?: return null,
34
+ clientId = query("__expo_device_client") ?: return null
35
+ )
36
+ }
37
+ }
38
+
39
+ /** The server sends two digits. Another two-digit value is a failed match, not a malformed request. */
40
+ val wrongMatchValue: String
41
+ get() = if (matchValue == "00") {
42
+ "01"
43
+ } else {
44
+ "00"
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Signs the launcher in from a launch URL. The tool that opens the URL (Expo CLI, Expo Orbit)
50
+ * creates an OAuth device code and approves it with its own session; the launcher exchanges the
51
+ * code for a session of its own. A failure only writes a log line: the launch continues signed out.
52
+ */
53
+ suspend fun signInFromLaunchUrl(uri: Uri) {
54
+ val sessionService = DependencyInjection.sessionService ?: return
55
+ val sessionStore = sessionService.sessionStore
56
+ // Emulator only: on a device, a link from another app could sign the launcher in to the
57
+ // sender's account. An emulator has the same risk, because the check does not look at the
58
+ // sender. That is the accepted risk: a launch URL can already open any project. The check reads
59
+ // `Build` properties, so a device with a custom ROM can pass it. This file is only in debug builds.
60
+ if (!EmulatorUtilities.isRunningOnEmulator()) {
61
+ return
62
+ }
63
+ val request = DeviceLoginRequest.parse(uri) ?: return
64
+ val redeems = Session.loadFromPreferences(sessionStore) == null &&
65
+ !sessionStore.getBoolean(SIGNED_OUT_KEY, false)
66
+
67
+ runCatching {
68
+ val payload = JSONObject()
69
+ .put("grant_type", "urn:ietf:params:oauth:grant-type:device_code")
70
+ .put("client_id", request.clientId)
71
+ .put("device_code", request.deviceCode)
72
+ // The running app gets this URL too. When the launcher does not redeem the code, a wrong
73
+ // match value makes the server reject the code from then on.
74
+ .put(
75
+ "match_value",
76
+ if (redeems) {
77
+ request.matchValue
78
+ } else {
79
+ request.wrongMatchValue
80
+ }
81
+ )
82
+ .toString()
83
+ val response = Request
84
+ .Builder()
85
+ .url("https://api.expo.dev/v2/auth/token")
86
+ .post(payload.toRequestBody("application/json".toMediaType()))
87
+ .build()
88
+ .await(DependencyInjection.httpClientService.httpClient)
89
+ val data = response.use { JSONObject(it.body?.string().orEmpty()) }.getJSONObject("data")
90
+ if (!redeems) {
91
+ return
92
+ }
93
+ if (!data.has("session_secret")) {
94
+ // Only the server error code: never log the device code or the session secret.
95
+ Log.w(TAG, "Could not sign in from the launch URL: ${data.optString("error")}")
96
+ return
97
+ }
98
+ sessionService.setSession(Session(data.getString("session_secret")))
99
+ }.onFailure {
100
+ // Only the class: the message of a JSON error can contain the response body.
101
+ Log.w(TAG, "Could not sign in from the launch URL: ${it.javaClass.simpleName}")
102
+ }
103
+ }
@@ -16,7 +16,6 @@ query Me {
16
16
  meUserActor {
17
17
  id
18
18
  appCount
19
- profilePhoto
20
19
  username
21
20
  isExpoAdmin
22
21
  accounts {
@@ -25,7 +24,7 @@ query Me {
25
24
  ownerUserActor {
26
25
  username
27
26
  fullName
28
- profilePhoto
27
+ primaryAccountProfileImageUrl
29
28
  }
30
29
  }
31
30
  }
@@ -53,7 +52,9 @@ query getBranchesWithCompatibleUpdate(
53
52
  ) {
54
53
  id
55
54
  message
56
- runtimeVersion
55
+ runtime {
56
+ version
57
+ }
57
58
  createdAt
58
59
  manifestPermalink
59
60
  }
@@ -95,7 +96,9 @@ query getUpdatesWithFilters(
95
96
  updates(offset: ${'$'}offset, limit: ${'$'}limit, filter: { platform: ${'$'}platform }) {
96
97
  id
97
98
  message
98
- runtimeVersion
99
+ runtime {
100
+ version
101
+ }
99
102
  createdAt
100
103
  manifestPermalink
101
104
  }
@@ -132,7 +135,7 @@ data class UserAccount(
132
135
  val ownerUserActor: OwnerUserActor? = null
133
136
  )
134
137
 
135
- data class OwnerUserActor(val profilePhoto: String? = null)
138
+ data class OwnerUserActor(val primaryAccountProfileImageUrl: String? = null)
136
139
 
137
140
  // branches (covers both getBranches and getBranchesWithCompatibleUpdate)
138
141
  data class BranchesData(val app: BranchesApp? = null) {
@@ -162,10 +165,15 @@ data class UpdateBranchByName(val updates: List<UpdateInfo> = emptyList())
162
165
  data class UpdateInfo(
163
166
  val id: String,
164
167
  val message: String? = null,
165
- val runtimeVersion: String? = null,
168
+ val runtime: UpdateRuntime? = null,
166
169
  val createdAt: String? = null,
167
170
  val manifestPermalink: String
168
- )
171
+ ) {
172
+ val runtimeVersion: String?
173
+ get() = runtime?.version
174
+ }
175
+
176
+ data class UpdateRuntime(val version: String)
169
177
 
170
178
  class GraphQLService(
171
179
  private val httpClientService: HttpClientService
@@ -46,6 +46,13 @@ class SessionService(
46
46
 
47
47
  val me = graphQLService.fetchMe()
48
48
  val data = me.data
49
+ // The server answers a rejected session with a null `meUserActor` and no errors. Remove the
50
+ // session without the signed-out flag, so a launch URL can sign in again.
51
+ if (!me.hasErrors() && data?.meUserActor == null && _session.compareAndSet(newSession, null)) {
52
+ null.saveToPreferences(sessionStore)
53
+ httpClientService.setSession(null)
54
+ return@onEach
55
+ }
49
56
  if (me.hasErrors() || data == null) {
50
57
  // TODO(@lukmccall): Handle errors properly
51
58
  _user.update { UserState.LoggedOut }
@@ -67,6 +74,8 @@ class SessionService(
67
74
 
68
75
  fun setSession(newSession: Session?) {
69
76
  newSession.saveToPreferences(sessionStore)
77
+ // A null session is always an explicit sign out.
78
+ sessionStore.edit(commit = true) { putBoolean(SIGNED_OUT_KEY, newSession == null) }
70
79
  httpClientService.setSession(newSession?.sessionSecret)
71
80
  _session.update { newSession }
72
81
  }
@@ -40,7 +40,7 @@ public final class DevLauncherNetworkInterceptor: NSObject, ExpoRequestCdpInterc
40
40
 
41
41
  private static func createNetworkInspectorUrl(bundleUrl: URL) -> URL {
42
42
  let host = bundleUrl.host ?? "localhost"
43
- let port = bundleUrl.port ?? 8081
43
+ let port = bundleUrl.port ?? (bundleUrl.scheme == "https" ? 443 : 8081)
44
44
  let scheme = bundleUrl.scheme == "https" ? "wss" : "ws"
45
45
  let urlString = "\(scheme)://\(host):\(port)/inspector/network"
46
46
  guard let url = URL(string: urlString) else {
@@ -325,6 +325,7 @@ static const NSTimeInterval EXDevLauncherDefaultRequestTimeout = 10.0;
325
325
  // The dev menu params apply to every launcher command, with or without a `__expo_url`.
326
326
  [[DevMenuManager shared] applyLaunchParamsFromURL:url];
327
327
  [EXDevLauncherURLHelper applyDevMenuPreferencesIfNeeded:url];
328
+ [EXDevLauncherDeviceLogin handle:url];
328
329
 
329
330
  if (![EXDevLauncherURLHelper hasUrlQueryParam:url]) {
330
331
  NSURL *externalDeepLink = [EXDevLauncherURLHelper externalDeepLinkFromLauncherURL:url];
@@ -0,0 +1,98 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ import Foundation
4
+
5
+ /** The `__expo_device_*` params of a launch URL. */
6
+ internal struct DeviceLoginRequest: Equatable {
7
+ let deviceCode: String
8
+ let matchValue: String
9
+ let clientId: String
10
+
11
+ internal static func parse(_ url: URL) -> DeviceLoginRequest? {
12
+ let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems ?? []
13
+ func query(_ name: String) -> String? {
14
+ guard let value = queryItems.first(where: { $0.name == name })?.value, !value.isEmpty else {
15
+ return nil
16
+ }
17
+ return value
18
+ }
19
+
20
+ guard let deviceCode = query("__expo_device_code"),
21
+ let matchValue = query("__expo_device_match"),
22
+ let clientId = query("__expo_device_client") else {
23
+ return nil
24
+ }
25
+ return DeviceLoginRequest(deviceCode: deviceCode, matchValue: matchValue, clientId: clientId)
26
+ }
27
+
28
+ /// The server sends two digits. Another two-digit value is a failed match, not a malformed request.
29
+ var wrongMatchValue: String {
30
+ return matchValue == "00" ? "01" : "00"
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Signs the launcher in from a launch URL. The tool that opens the URL (Expo CLI, Expo Orbit)
36
+ * creates an OAuth device code and approves it with its own session; the launcher exchanges the
37
+ * code for a session of its own. A failure only writes a log line: the launch continues signed out.
38
+ */
39
+ @objc(EXDevLauncherDeviceLogin)
40
+ public class EXDevLauncherDeviceLogin: NSObject {
41
+ static let didSignInNotification = Notification.Name("EXDevLauncherDeviceLoginDidSignIn")
42
+ /// Set by the sign out button and removed by a manual sign in: a launch URL does not undo a sign out.
43
+ static let signedOutKey = "expo-device-login-signed-out"
44
+
45
+ @objc public static func handle(_ url: URL) {
46
+ // Simulator only: on a device, a link from another app could sign the launcher in to the
47
+ // sender's account. A simulator has the same risk, because the check does not look at the
48
+ // sender. That is the accepted risk: a launch URL can already open any project.
49
+ #if targetEnvironment(simulator)
50
+ guard let request = DeviceLoginRequest.parse(url) else {
51
+ return
52
+ }
53
+ let defaults = UserDefaults.standard
54
+ let redeems = defaults.string(forKey: APIClient.sessionKey) == nil && !defaults.bool(forKey: signedOutKey)
55
+
56
+ Task {
57
+ do {
58
+ // The app's linking listeners get this URL too. When the launcher does not redeem the code,
59
+ // a wrong match value makes the server reject the code from then on.
60
+ let data = try await exchange(request, matchValue: redeems ? request.matchValue : request.wrongMatchValue)
61
+ guard redeems else {
62
+ return
63
+ }
64
+ guard let sessionSecret = data["session_secret"] as? String else {
65
+ // Only the server error code: never log the device code or the session secret.
66
+ NSLog("DevLauncher could not sign in from the launch URL: %@", data["error"] as? String ?? "no session in the response")
67
+ return
68
+ }
69
+ defaults.set(sessionSecret, forKey: APIClient.sessionKey)
70
+ NotificationCenter.default.post(name: didSignInNotification, object: nil)
71
+ } catch {
72
+ NSLog("DevLauncher could not sign in from the launch URL: %@", error.localizedDescription)
73
+ }
74
+ }
75
+ #endif
76
+ }
77
+
78
+ /** Returns the `data` object of the token response. */
79
+ private static func exchange(_ request: DeviceLoginRequest, matchValue: String) async throws -> [String: Any] {
80
+ guard let url = URL(string: "\(APIClient.shared.apiOrigin)/v2/auth/token") else {
81
+ return [:]
82
+ }
83
+ var urlRequest = URLRequest(url: url)
84
+ urlRequest.httpMethod = "POST"
85
+ urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
86
+ urlRequest.httpBody = try JSONSerialization.data(withJSONObject: [
87
+ "grant_type": "urn:ietf:params:oauth:grant-type:device_code",
88
+ "client_id": request.clientId,
89
+ "device_code": request.deviceCode,
90
+ "match_value": matchValue
91
+ ])
92
+ urlRequest.timeoutInterval = 10
93
+
94
+ let (data, _) = try await URLSession.shared.data(for: urlRequest)
95
+ let json = try JSONSerialization.jsonObject(with: data) as? [String: Any]
96
+ return json?["data"] as? [String: Any] ?? [:]
97
+ }
98
+ }
@@ -204,7 +204,7 @@ struct AccountSheet: View {
204
204
  @ViewBuilder
205
205
  private func createAvatar(account: UserAccount) -> some View {
206
206
  let isOrganization = account.ownerUserActor == nil
207
- let profilePhoto = account.ownerUserActor?.profilePhoto
207
+ let profilePhoto = account.ownerUserActor?.primaryAccountProfileImageUrl
208
208
  let name = account.ownerUserActor?.fullName ?? account.name
209
209
 
210
210
  if isOrganization {
@@ -7,7 +7,6 @@ import Network
7
7
  import EXDevMenu
8
8
 
9
9
  private let selectedAccountKey = "expo-selected-account-id"
10
- private let sessionKey = "expo-session-secret"
11
10
 
12
11
  private let DEV_LAUNCHER_DEFAULT_SCHEME = "expo-dev-launcher"
13
12
  private let BONJOUR_TYPE = "_expo._tcp"
@@ -138,6 +137,16 @@ class DevLauncherViewModel: ObservableObject {
138
137
  loadData()
139
138
  checkAuthenticationStatus()
140
139
  checkForStoredCrashes()
140
+
141
+ NotificationCenter.default.addObserver(
142
+ forName: EXDevLauncherDeviceLogin.didSignInNotification,
143
+ object: nil,
144
+ queue: .main
145
+ ) { [weak self] _ in
146
+ Task { @MainActor [weak self] in
147
+ self?.checkAuthenticationStatus()
148
+ }
149
+ }
141
150
  }
142
151
 
143
152
  private func updateDevServers(_ servers: [DevServer]) {
@@ -612,7 +621,7 @@ class DevLauncherViewModel: ObservableObject {
612
621
  }
613
622
 
614
623
  private func checkAuthenticationStatus() {
615
- let sessionSecret = UserDefaults.standard.string(forKey: sessionKey)
624
+ let sessionSecret = UserDefaults.standard.string(forKey: APIClient.sessionKey)
616
625
 
617
626
  if let sessionSecret {
618
627
  APIClient.shared.setSession(sessionSecret)
@@ -625,7 +634,7 @@ class DevLauncherViewModel: ObservableObject {
625
634
  }
626
635
 
627
636
  private func clearInvalidSession() {
628
- UserDefaults.standard.removeObject(forKey: sessionKey)
637
+ UserDefaults.standard.removeObject(forKey: APIClient.sessionKey)
629
638
  APIClient.shared.setSession(nil)
630
639
  isAuthenticated = false
631
640
  user = nil
@@ -695,7 +704,8 @@ class DevLauncherViewModel: ObservableObject {
695
704
  }
696
705
 
697
706
  func signOut() {
698
- UserDefaults.standard.removeObject(forKey: sessionKey)
707
+ UserDefaults.standard.removeObject(forKey: APIClient.sessionKey)
708
+ UserDefaults.standard.set(true, forKey: EXDevLauncherDeviceLogin.signedOutKey)
699
709
  UserDefaults.standard.removeObject(forKey: selectedAccountKey)
700
710
  APIClient.shared.setSession(nil)
701
711
  clearRecentlyOpenedApps()
@@ -742,7 +752,8 @@ class DevLauncherViewModel: ObservableObject {
742
752
  return
743
753
  }
744
754
 
745
- UserDefaults.standard.set(sessionSecret, forKey: sessionKey)
755
+ UserDefaults.standard.set(sessionSecret, forKey: APIClient.sessionKey)
756
+ UserDefaults.standard.removeObject(forKey: EXDevLauncherDeviceLogin.signedOutKey)
746
757
  APIClient.shared.setSession(sessionSecret)
747
758
  continuation.resume(returning: true)
748
759
  }
@@ -4,6 +4,8 @@ import Foundation
4
4
 
5
5
  class APIClient {
6
6
  static let shared = APIClient()
7
+ /// The `UserDefaults` key of the stored session secret.
8
+ static let sessionKey = "expo-session-secret"
7
9
 
8
10
  private var useStaging: Bool {
9
11
  return false
@@ -26,6 +28,12 @@ class APIClient {
26
28
  : "https://exp.host/--/graphql"
27
29
  }
28
30
 
31
+ var apiOrigin: String {
32
+ return useStaging
33
+ ? "https://staging-api.expo.dev"
34
+ : "https://api.expo.dev"
35
+ }
36
+
29
37
  var websiteOrigin: String {
30
38
  return useStaging
31
39
  ? "https://staging.expo.dev"
@@ -6,7 +6,6 @@ struct User: Codable {
6
6
  let id: String
7
7
  let appCount: Int?
8
8
  let username: String
9
- let profilePhoto: String?
10
9
  let accounts: [UserAccount]
11
10
  let isExpoAdmin: Bool
12
11
  }
@@ -20,7 +19,7 @@ struct UserAccount: Codable {
20
19
  struct OwnerUserActor: Codable {
21
20
  let username: String
22
21
  let fullName: String?
23
- let profilePhoto: String?
22
+ let primaryAccountProfileImageUrl: String?
24
23
  }
25
24
 
26
25
  struct MeUserActorResponse: Codable {
@@ -90,9 +89,17 @@ struct UpdateBranch: Codable {
90
89
  struct Update: Codable {
91
90
  let id: String
92
91
  let message: String
93
- let runtimeVersion: String
92
+ let runtime: UpdateRuntime
94
93
  let createdAt: String
95
94
  let manifestPermalink: String
95
+
96
+ var runtimeVersion: String {
97
+ runtime.version
98
+ }
99
+ }
100
+
101
+ struct UpdateRuntime: Codable {
102
+ let version: String
96
103
  }
97
104
 
98
105
  struct UpdatesResponse: Codable {
@@ -9,7 +9,6 @@ class Queries {
9
9
  meUserActor {
10
10
  id
11
11
  appCount
12
- profilePhoto
13
12
  username
14
13
  isExpoAdmin
15
14
  accounts {
@@ -18,7 +17,7 @@ class Queries {
18
17
  ownerUserActor {
19
18
  username
20
19
  fullName
21
- profilePhoto
20
+ primaryAccountProfileImageUrl
22
21
  }
23
22
  }
24
23
  }
@@ -117,7 +116,9 @@ class Queries {
117
116
  updates(offset: $offset, limit: $limit, filter: { platform: $platform }) {
118
117
  id
119
118
  message
120
- runtimeVersion
119
+ runtime {
120
+ version
121
+ }
121
122
  createdAt
122
123
  manifestPermalink
123
124
  }
@@ -64,7 +64,7 @@ private struct AccountAvatar: View {
64
64
 
65
65
  var body: some View {
66
66
  let isOrganization = account.ownerUserActor == nil
67
- let profilePhoto = account.ownerUserActor?.profilePhoto
67
+ let profilePhoto = account.ownerUserActor?.primaryAccountProfileImageUrl
68
68
  let name = account.ownerUserActor?.fullName ?? account.name
69
69
 
70
70
  if isOrganization {
@@ -0,0 +1,30 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ import Testing
4
+
5
+ @testable import EXDevLauncher
6
+
7
+ @Suite("EXDevLauncherDeviceLogin")
8
+ struct EXDevLauncherDeviceLoginTests {
9
+ // The parameter names are spelled out: these are the literals Expo CLI and Expo Orbit send.
10
+ @Test("reads the device code, match value and client ID next to a project URL")
11
+ func validRequest() {
12
+ let url = URL(string: "exp+app://?__expo_url=http%3A%2F%2Flocalhost%3A8081&__expo_device_code=abc&__expo_device_match=42&__expo_device_client=expo-go")!
13
+
14
+ #expect(DeviceLoginRequest.parse(url) == DeviceLoginRequest(deviceCode: "abc", matchValue: "42", clientId: "expo-go"))
15
+ }
16
+
17
+ @Test(
18
+ "rejects a URL with a missing or empty param",
19
+ arguments: [
20
+ "exp+app://?__expo_url=http%3A%2F%2Flocalhost%3A8081",
21
+ "exp+app://?__expo_device_match=42&__expo_device_client=expo-go",
22
+ "exp+app://?__expo_device_code=abc&__expo_device_client=expo-go",
23
+ "exp+app://?__expo_device_code=abc&__expo_device_match=42",
24
+ "exp+app://?__expo_device_code=&__expo_device_match=42&__expo_device_client=expo-go"
25
+ ]
26
+ )
27
+ func incompleteRequest(_ url: String) {
28
+ #expect(DeviceLoginRequest.parse(URL(string: url)!) == nil)
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-dev-launcher",
3
3
  "title": "Expo Development Launcher",
4
- "version": "58.0.20",
4
+ "version": "58.1.0",
5
5
  "description": "Pre-release version of the Expo development launcher package for testing.",
6
6
  "repository": {
7
7
  "type": "git",