-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: Fix/10029 background bridge origin #13698
base: main
Are you sure you want to change the base?
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
…0029-background-bridge-origin
New dependencies detected. Learn more about Socket for GitHub ↗︎
Have feedback? Participate in our User Experience Survey 📊 |
) => `(function () { | ||
try { | ||
window.postMessage(${JSON.stringify(message)}, '${origin}'); | ||
} catch (e) { | ||
//Nothing to do | ||
} | ||
})()`; | ||
|
||
export const JS_IFRAME_POST_MESSAGE_TO_PROVIDER = ( |
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.
Removed since not used for a while
@@ -18,7 +18,7 @@ const USER_REJECTED_ERROR_CODE = 4001; | |||
/** | |||
* Returns a middleware that appends the DApp origin to request | |||
* @param {{ origin: string }} opts - The middleware options | |||
* @returns {Function} |
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.
Updating to use the correct types
@@ -595,6 +626,7 @@ export function getNormalizedTxState(state) { | |||
: undefined; | |||
} | |||
|
|||
// FIXME: Check if the url here is origin and not hostname |
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.
verify that this is not hostname
@@ -40,6 +40,10 @@ module.exports = { | |||
test: './app/core/Engine/Engine.ts', | |||
plugins: [['@babel/plugin-transform-private-methods', { loose: true }]], | |||
}, | |||
{ | |||
test: './app/core/BackgroundBridge/BackgroundBridge.ts', |
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.
BackgroundBridge uses #
prefix for private
@@ -440,6 +441,7 @@ | |||
"@types/react-native-svg-charts": "^5.0.12", | |||
"@types/react-native-vector-icons": "^6.4.13", | |||
"@types/react-native-video": "^5.0.14", | |||
"@types/readable-stream": "^4.0.18", |
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.
Converted requires to imports, so needed types for both packages
* @param subject - The subject to get the permitted accounts for | ||
* @returns A selector that returns the permitted accounts for the given subject | ||
*/ | ||
export const selectPermittedAccounts = (subject: string) => |
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.
Add new selector for getting permitted accounts by subject
|
||
export const selectPermissionControllerState = (state: RootState) => | ||
state.engine.backgroundState.PermissionController; | ||
state.engine.backgroundState | ||
.PermissionController as PermissionControllerState<PermissionConstraint>; |
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.
Give selector return type
@@ -295,3 +295,7 @@ declare module '@metamask/react-native-actionsheet' { | |||
} | |||
|
|||
declare module '@metamask/react-native-search-api'; | |||
|
|||
// Resolve BackgroundBridge import errors related to TS | |||
declare module '@metamask/eth-json-rpc-filters'; |
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.
Both of these libs are JS. These are added to supress TS errors associated with importing them
|
Description
This PR updates the
BackgroundBridge
to properly set theorigin
property instead of usinghostname
. This is important because the origin that dependents consume. Previously, we used hostname, which omitted protocol. Changing to origin will resolve thatRelated issues
Fixes: #11029
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist