Skip to content

Commit 879c2c1

Browse files
committed
fix(extension): distinguish unreadable pages from missing access
1 parent be65263 commit 879c2c1

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎apps/extension/src/capture.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
pageSnapshotSchema,
55
} from '@sim/browser-extension-protocol'
66
import { generateId } from '@sim/utils/id'
7-
import { SIM_ORIGIN } from '@/config'
7+
import { PAGE_ACCESS_ORIGINS, SIM_ORIGIN } from '@/config'
88
import { extractPageText } from '@/extract'
99
import { digestUrl } from '@/utils'
1010

@@ -51,7 +51,12 @@ export async function captureActivePage(
5151
if (expected && expected.tabId !== tab.id) {
5252
throw new PageCaptureError('The page changed before reading. Attach it again.')
5353
}
54-
if (!tab.url) throw new SiteAccessRequiredError(tab.id, tab.windowId)
54+
if (!tab.url) {
55+
const allowed = await chrome.permissions.contains({ origins: PAGE_ACCESS_ORIGINS })
56+
signal?.throwIfAborted()
57+
if (allowed) throw new PageCaptureError('This page cannot be attached.')
58+
throw new SiteAccessRequiredError(tab.id, tab.windowId)
59+
}
5560
let changed = false
5661
const activated = (active: chrome.tabs.OnActivatedInfo) => {
5762
if (active.windowId === tab.windowId && active.tabId !== tab.id) changed = true

‎apps/extension/src/config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
declare const __SIM_ORIGIN__: string
22
export const SIM_ORIGIN = __SIM_ORIGIN__
3+
export const PAGE_ACCESS_ORIGINS = ['https://*/*', 'http://*/*']
34
export const REFERENCE_PAGE_KEY = 'referenceCurrentPage'
45
export const OPEN_SIM_COMMAND = 'open-sim'
56
export const CAPTURE_INTENT_KEY = 'captureIntent'

‎apps/extension/src/site-access.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useEffect, useRef, useState } from 'react'
22
import { Chip, ChipModalBody, ChipModalHeader, ChipModalSurface } from '@sim/emcn'
3-
4-
const PAGE_ACCESS_ORIGINS = ['https://*/*', 'http://*/*']
3+
import { PAGE_ACCESS_ORIGINS } from '@/config'
54

65
interface PageAccessButtonProps {
76
allowed?: boolean

‎apps/sim/app/(landing)/privacy/privacy-content.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ export const PRIVACY_CONFIG: LegalPageConfig = {
842842
{
843843
kind: 'paragraph',
844844
content: richText(
845-
'Browser shortcuts can optionally recover an explicit sim/ shortcut that Chrome sends to a supported search engine. After You enable a provider and approve access to its listed sites, Chrome applies request rules that send only the matching shortcut name and path values to Sim’s normal link resolver. Other search parameters and ordinary search terms are not sent to Sim by this feature. The extension stores Your provider choices locally and does not change Your default search engine. These site permissions can also allow page attachment when You explicitly request it; enabling shortcut recovery does not enable Reference current page or background capture. Turning recovery off stops these redirects. Site access remains until You revoke it in the extension or Chrome settings.'
845+
'Browser shortcuts can optionally recover an explicit sim/ shortcut that Chrome sends to a supported search engine. After You enable a provider and approve access to its listed sites, Chrome applies request rules that send only the matching shortcut name and path values to Sim’s normal link resolver. Other search parameters and ordinary search terms are not sent to Sim by this feature. The extension stores Your provider choices locally and does not change Your default search engine. These site permissions can also allow page attachment when You explicitly request it; enabling shortcut recovery does not enable Reference current page or background capture. Turning recovery off stops these redirects. Site access remains until You revoke or restrict it in Chrome settings.'
846846
),
847847
},
848848
{

0 commit comments

Comments
 (0)