-
Notifications
You must be signed in to change notification settings - Fork 580
fix: secure SSL handling and Web3 provider injection timing #3438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
| import androidx.webkit.WebSettingsCompat; | ||
| import androidx.webkit.WebViewCompat; | ||
| import androidx.webkit.WebViewFeature; | ||
|
|
||
| import com.alphawallet.app.BuildConfig; | ||
|
|
@@ -31,8 +32,11 @@ | |
| import org.jetbrains.annotations.Contract; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import timber.log.Timber; | ||
|
|
||
|
|
@@ -206,6 +210,16 @@ public void init() | |
| { | ||
| WebSettingsCompat.setAlgorithmicDarkeningAllowed(getSettings(), true); | ||
| } | ||
|
|
||
| // Inject Web3 provider at document start so window.ethereum is available | ||
| // before any page scripts run. This fixes CSP timing issues where sites | ||
| // like exchange.idex.io fail to detect the provider. | ||
| if (WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) | ||
| { | ||
| String providerJs = webViewClient.getJsInjectorClient().providerJs(getContext()); | ||
| Set<String> origins = new HashSet<>(Collections.singletonList("*")); | ||
|
||
| WebViewCompat.addDocumentStartJavaScript(this, providerJs, origins); | ||
|
||
| } | ||
| } | ||
|
|
||
| @Nullable | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline comment is now inaccurate:
handler.cancel()rejects the SSL certificate error rather than ignoring it. Update the comment to reflect the actual behavior (e.g., 'Reject SSL certificate errors').