Commit 3c08db6
authored
fix(keyring-snap-bridge)!: re-forward keyring Snap ID in callbacks (#520)
We need this since the `snapId` is injected through `deserialize`. While
"baking" the `snapId` in `SnapKeyring.ts` is working fine for the legacy
keyring, this cannot work when we use standalone `SnapKeyringV2`
instances (as the `KeyringController` uses a builder to create the
instance AND THEN call `deserialize` with the `snapId`, making it
impossible to auto-capture the `snapId` at build-time for those).
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Medium risk because it is a **breaking** change to callback signatures
(`addAccount`, `removeAccount`, `redirectUser`) that downstream
consumers must update; incorrect wiring could mis-associate
accounts/redirects with the wrong Snap.
>
> **Overview**
> Reintroduces forwarding of `snapId` through the parent-level callbacks
used by per-snap keyrings, so standalone `SnapKeyring` v2 instances
(where `snapId` is only known after `deserialize`) can still pass the
correct Snap identity to host integrations.
>
> Updates the v2 keyring bridge in `SnapKeyring.ts` to use the `snapId`
coming from `deserialize` when invoking
`addAccount`/`removeAccount`/`redirectUser`, and adjusts
`SnapKeyringV1Callbacks` plus call sites in `SnapKeyringV1.ts` so
`redirectUser` (and the account mutation callbacks) explicitly receive
`snapId`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7fe1dc1. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent deb171f commit 3c08db6
3 files changed
Lines changed: 32 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
| 202 | + | |
201 | 203 | | |
| 204 | + | |
| 205 | + | |
202 | 206 | | |
203 | 207 | | |
204 | 208 | | |
205 | 209 | | |
206 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
207 | 214 | | |
208 | 215 | | |
| 216 | + | |
209 | 217 | | |
210 | 218 | | |
211 | 219 | | |
212 | 220 | | |
213 | 221 | | |
214 | 222 | | |
215 | 223 | | |
216 | | - | |
| 224 | + | |
217 | 225 | | |
218 | 226 | | |
219 | 227 | | |
220 | 228 | | |
221 | 229 | | |
222 | | - | |
223 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
224 | 240 | | |
225 | | - | |
226 | | - | |
| 241 | + | |
| 242 | + | |
227 | 243 | | |
228 | 244 | | |
229 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | 105 | | |
107 | 106 | | |
108 | 107 | | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| |||
776 | 776 | | |
777 | 777 | | |
778 | 778 | | |
| 779 | + | |
779 | 780 | | |
780 | 781 | | |
781 | 782 | | |
| |||
910 | 911 | | |
911 | 912 | | |
912 | 913 | | |
| 914 | + | |
913 | 915 | | |
914 | 916 | | |
915 | 917 | | |
| |||
1180 | 1182 | | |
1181 | 1183 | | |
1182 | 1184 | | |
1183 | | - | |
| 1185 | + | |
1184 | 1186 | | |
1185 | 1187 | | |
1186 | 1188 | | |
| |||
0 commit comments