Skip to content

Commit 98be2e0

Browse files
vveerrggclaude
andcommitted
fix: permission bottom sheet and hosts TypeError on fresh profiles
Add missing tabs.sendMessage to browser-polyfill so the inline permission bottom sheet works instead of falling back to a new tab. Guard getPermission against undefined profile on fresh installs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cea1126 commit 98be2e0

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/utilities/browser-polyfill.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ api.tabs = {
181181
}
182182
return promisify(_browser.tabs, _browser.tabs.getCurrent)(...args);
183183
},
184+
sendMessage(...args) {
185+
if (!isChrome) {
186+
return _browser.tabs.sendMessage(...args);
187+
}
188+
return promisify(_browser.tabs, _browser.tabs.sendMessage)(...args);
189+
},
184190
};
185191

186192
export { api, isChrome };

src/utilities/utils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { api } from './browser-polyfill';
22
import { encrypt, decrypt, hashPassword, verifyPassword } from './crypto';
3+
import { looksLikeSeedPhrase, isValidSeedPhrase } from './seedphrase';
34

45
const DB_VERSION = 5;
56
const storage = api.storage.local;
@@ -263,7 +264,7 @@ export async function getPermissions(index = null) {
263264
export async function getPermission(host, action) {
264265
let index = await getProfileIndex();
265266
let profile = await getProfile(index);
266-
return profile.hosts?.[host]?.[action] || 'ask';
267+
return profile?.hosts?.[host]?.[action] || 'ask';
267268
}
268269

269270
export async function setPermission(host, action, perm, index = null) {
@@ -312,9 +313,12 @@ export function validateKey(key) {
312313
const hexMatch = /^[\da-f]{64}$/i.test(key);
313314
const b32Match = /^nsec1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58}$/.test(key);
314315

315-
return hexMatch || b32Match || isNcryptsec(key);
316+
return hexMatch || b32Match || isNcryptsec(key) || isValidSeedPhrase(key);
316317
}
317318

319+
export { looksLikeSeedPhrase };
320+
export const isSeedPhrase = isValidSeedPhrase;
321+
318322
export function isNcryptsec(key) {
319323
return /^ncryptsec1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]+$/.test(key);
320324
}

0 commit comments

Comments
 (0)