Skip to content

Commit

Permalink
Implement ssl client certificate on expo-file-system
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello committed Jun 10, 2024
1 parent 506a719 commit b91cba0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.dylanvann.fastimage.FastImageOkHttpUrlLoader;

import expo.modules.av.player.datasource.SharedCookiesDataSourceFactory;
import expo.modules.filesystem.FileSystemModule;

public class SSLPinningModule extends ReactContextBaseJavaModule implements KeyChainAliasCallback {

Expand Down Expand Up @@ -113,6 +114,8 @@ public void setCertificate(String data, Promise promise) {
FastImageOkHttpUrlLoader.setOkHttpClient(getOkHttpClient());
// Expo AV network layer
SharedCookiesDataSourceFactory.setOkHttpClient(getOkHttpClient());
// Expo File System network layer
FileSystemModule.setOkHttpClient(getOkHttpClient());

promise.resolve(null);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"expo-av": "^13.10.5",
"expo-camera": "^14.1.1",
"expo-document-picker": "11.10.1",
"expo-file-system": "^16.0.8",
"expo-file-system": "16.0.8",
"expo-haptics": "^12.8.1",
"expo-keep-awake": "^12.8.2",
"expo-local-authentication": "^13.8.0",
Expand Down
26 changes: 26 additions & 0 deletions patches/expo-file-system+16.0.8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/node_modules/expo-file-system/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt b/node_modules/expo-file-system/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt
index 59c4ce3..1f9186d 100644
--- a/node_modules/expo-file-system/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt
+++ b/node_modules/expo-file-system/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt
@@ -82,11 +82,20 @@ private fun slashifyFilePath(path: String?): String? {
open class FileSystemModule : Module() {
private val context: Context
get() = appContext.reactContext ?: throw Exceptions.AppContextLost()
- private var client: OkHttpClient? = null
private var dirPermissionsRequest: Promise? = null
private val taskHandlers: MutableMap<String, TaskHandler> = HashMap()
private val moduleCoroutineScope = CoroutineScope(Dispatchers.Default)

+ companion object {
+ @JvmStatic
+ var client: OkHttpClient? = null
+
+ @JvmStatic
+ fun setOkHttpClient(okHttpClient: OkHttpClient) {
+ client = okHttpClient
+ }
+ }
+
@SuppressLint("WrongConstant", "DiscouragedApi")
override fun definition() = ModuleDefinition {
Name("ExponentFileSystem")
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7693,7 +7693,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/expo-document-picker/-/expo-document-picker-11.10.1.tgz#03394d77842a2fd7cb0a784a60098ee1ddd1012e"
integrity sha512-A1MiLfyXQ+KxanRO5lYxYQy3ryV+25JHe5Ai/BLV+FJU0QXByUF+Y/dn35WVPx5gpdZXC8UJ4ejg5SKSoeconw==

expo-file-system@^16.0.8, expo-file-system@~16.0.0, expo-file-system@~16.0.8:
[email protected], expo-file-system@~16.0.0, expo-file-system@~16.0.8:
version "16.0.8"
resolved "https://registry.yarnpkg.com/expo-file-system/-/expo-file-system-16.0.8.tgz#13c79a8e06e42a8e76e9297df6920597a011d989"
integrity sha512-yDbVT0TUKd7ewQjaY5THum2VRFx2n/biskGhkUmLh3ai21xjIVtaeIzHXyv9ir537eVgt4ReqDNWi7jcXjdUcA==
Expand Down

0 comments on commit b91cba0

Please sign in to comment.