react-native-kookit 0.3.3 → 0.3.5

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.
@@ -42,9 +42,8 @@ class JcifsShareEnumerator {
42
42
  } ?: emptyList()
43
43
 
44
44
  } catch (e: Exception) {
45
- // If JCIFS enumeration fails, return empty list
46
- // The caller can fall back to other methods
47
- emptyList()
45
+ // If JCIFS enumeration fails, throw exception
46
+ throw Exception("Failed to enumerate shares using JCIFS: " + e.message)
48
47
  }
49
48
  }
50
49
 
@@ -83,54 +83,33 @@ class SmbClient {
83
83
  fun listShares(): List<String> {
84
84
  val s = session ?: throw IOException("Not authenticated")
85
85
 
86
- // First try JCIFS for more complete share enumeration
87
- if (lastHost != null && lastUsername != null && lastPassword != null) {
88
- try {
89
- val shares = jcifsEnumerator.listShares(
90
- lastHost!!,
91
- lastUsername!!,
92
- lastPassword!!,
93
- lastDomain ?: ""
94
- )
95
- if (shares.isNotEmpty()) {
96
- return shares
97
- }
98
- } catch (e: Exception) {
99
- // JCIFS failed, fall back to SMBJ testing approach
100
- }
86
+ // Check if we have the necessary credentials
87
+ if (lastHost == null || lastUsername == null || lastPassword == null) {
88
+ throw IOException("Missing host or credentials for share enumeration")
101
89
  }
102
90
 
103
- return try {
104
- // Fallback: SMBJ testing approach
105
- val availableShares = mutableListOf<String>()
106
-
107
- // Common Windows shares
108
- val windowsShares = listOf("C$", "D$", "E$", "ADMIN$", "IPC$")
109
- // Common user-defined shares
110
- val commonShares = listOf("shared", "public", "data", "home", "Users", "files", "documents", "media")
111
-
112
- val allTestShares = windowsShares + commonShares
91
+ // Use JCIFS for share enumeration, no fallback to other methods
92
+ try {
93
+ val shares = jcifsEnumerator.listShares(
94
+ lastHost!!,
95
+ lastUsername!!,
96
+ lastPassword!!,
97
+ lastDomain ?: ""
98
+ )
113
99
 
114
- for (shareName in allTestShares) {
115
- try {
116
- // Try to connect briefly to test if share exists
117
- val testShare = s.connectShare(shareName)
118
- testShare.close()
119
- availableShares.add(shareName)
120
- } catch (e: Exception) {
121
- // Share doesn't exist, access denied, or other error - ignore
122
- }
100
+ // If shares list is empty, throw an error
101
+ if (shares.isEmpty()) {
102
+ throw IOException("No shares found on server")
123
103
  }
124
104
 
125
- // If no shares found, suggest some common ones
126
- if (availableShares.isEmpty()) {
127
- listOf("C$", "shared", "public")
105
+ return shares
106
+ } catch (e: Exception) {
107
+ // Directly propagate the error without fallback
108
+ if (e is IOException) {
109
+ throw e
128
110
  } else {
129
- availableShares
111
+ throw IOException("Failed to enumerate shares: " + e.message, e)
130
112
  }
131
- } catch (e: Exception) {
132
- // Final fallback to common share names if all enumeration methods fail
133
- listOf("C$", "shared", "public", "data")
134
113
  }
135
114
  }
136
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-kookit",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "React Native module for intercepting volume button presses on iOS and Android, with FTP client functionality",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",