expo-tiddlywiki-filesystem-android-external-storage 2.4.0 → 2.4.1

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.
@@ -11,6 +11,7 @@ import org.eclipse.jgit.revwalk.RevWalk
11
11
  import org.eclipse.jgit.storage.file.FileRepositoryBuilder
12
12
  import org.eclipse.jgit.transport.RefSpec
13
13
  import org.eclipse.jgit.transport.TransportHttp
14
+ import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider
14
15
  import org.eclipse.jgit.treewalk.TreeWalk
15
16
  import org.eclipse.jgit.treewalk.filter.PathFilterGroup
16
17
  import org.json.JSONArray
@@ -43,7 +44,7 @@ internal object GitHelper {
43
44
  .build()
44
45
  }
45
46
 
46
- /** Apply custom HTTP headers to a JGit transport command. */
47
+ /** Apply custom HTTP headers and credentials to a JGit transport command. */
47
48
  private fun applyHeaders(
48
49
  command: org.eclipse.jgit.api.TransportCommand<*, *>,
49
50
  headers: String?
@@ -55,6 +56,23 @@ internal object GitHelper {
55
56
  for (key in headerObj.keys()) {
56
57
  headerMap[key] = headerObj.getString(key)
57
58
  }
59
+
60
+ // Extract Basic Auth from Authorization header and set as CredentialsProvider.
61
+ // JGit's TransportHttp needs this for proper smart-HTTP protocol negotiation;
62
+ // additional headers alone may not be replayed on auth-retry requests.
63
+ val authHeader = headerMap["Authorization"] ?: headerMap["authorization"]
64
+ if (authHeader != null && authHeader.startsWith("Basic ", ignoreCase = true)) {
65
+ try {
66
+ val decoded = String(Base64.decode(authHeader.substring(6), Base64.DEFAULT))
67
+ val colonIndex = decoded.indexOf(':')
68
+ val username = if (colonIndex >= 0) decoded.substring(0, colonIndex) else ""
69
+ val password = if (colonIndex >= 0) decoded.substring(colonIndex + 1) else decoded
70
+ command.setCredentialsProvider(UsernamePasswordCredentialsProvider(username, password))
71
+ } catch (e: Exception) {
72
+ android.util.Log.w("GitHelper", "Failed to decode Basic auth: ${e.message}")
73
+ }
74
+ }
75
+
58
76
  command.setTransportConfigCallback { transport ->
59
77
  if (transport is TransportHttp) {
60
78
  transport.setAdditionalHeaders(headerMap)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-tiddlywiki-filesystem-android-external-storage",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Expo native module for TidGi-Mobile: filesystem I/O + TiddlyWiki .tid/.meta/.json batch parsing + git status in Kotlin (Android) and Swift (iOS)",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",