MetaMask / MetaMask/metamask-mobile
Derive subject ID
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 1.7k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
**What is this about?**
As of today, mobile uses the hostname of subjects as the subject ID that is stored in the permission system. The first issue is that if a subject originates from a url, the subject ID should be the origin and not the hostname. The second issue is that subject IDs do not always resemble that of a url. For example, we would use the origin of a Dapp as a subject ID for a Dapp. But for Wallet Connect and SDK, the subject IDs are channel IDs. This task would be for introducing a subject ID property to the `BackgroundBridge` and to be shared with the `RPCMethodMiddleware`, and eventually the UI that consumes the data from those flows. This subject ID should be set on bridge construction.
The examples below illustrate what this might look like. Note - these are just examples and may not reflect the exact changes of the task.
Subjects
- Dapp
- subject ID: `https://app.uniswap.org`
- display name: `app.uniswap.org`
- WalletConnect
- subject ID: `CHANNEL_ID`
- display name: `app.uniswap.org`
- SDK
- subject ID: `CHANNEL_ID`
- display name: `Unity Game Name`
- Snap
- subject ID: `SNAP_ID`
- display name: `Solana Snap`
**Technical Details**
- Add a subject ID property to `BackgroundBridge`, which is set when each subject initializes the bridge
- WC, SDK, Browser, Snap
- Ensure the same property is passed into `RPCMethodMiddleware` so the name used is consistent across flows
- Update UI to use this subject ID property instead of `origin`
- Due to how WC and SDK services are created, there may be areas to pay special attention to. For example, we need to ensure that the subject ID passed into `removeChannel` for `SDKConnect` is using this new subject ID property
- Remove old usage of old subject ID (usually instances of hostname)
**Acceptance Criteria**
- Check WC, SDK, Browser, and Snaps
- Flows are using the correct subject ID for permissioning
- Permission flows are working as expected using the new subject IDs
**Stakeholder review needed before the work gets merged**
- [ ] Engineering (needed in most cases)
- [ ] Design
- [ ] Product
- [ ] QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
- [ ] Security
- [ ] Legal
- [ ] Marketing
- [ ] Management (please specify)
- [ ] Other (please specify)
**References**
- Old WIP PR - https://github.com/MetaMask/metamask-mobile/pull/13698
_No response_
Contributor guide
Research direction
Start by reviewing the old WIP PR #13698, then trace bridge initialization for WalletConnect, SDK, Browser, and Snaps. Follow how the subject ID reaches RPCMethodMiddleware, the UI, and SDKConnect's removeChannel; done means each flow uses the correct subject ID for permissioning and permission flows work as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- authorization, mobile-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100