Skip to content

Commit 8000f3a

Browse files
committed
Move wss request to optional host permission
1 parent 7b6b7e2 commit 8000f3a

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

manifest.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default defineManifest(async (env) => {
2020
action: {},
2121
host_permissions: [
2222
'https://*.bing.com/',
23-
'wss://*.bing.com/',
2423
'https://*.openai.com/',
2524
'https://bard.google.com/',
2625
'https://*.chathub.gg/',
@@ -29,7 +28,7 @@ export default defineManifest(async (env) => {
2928
'https://*.anthropic.com/',
3029
'https://*.claude.ai/',
3130
],
32-
optional_host_permissions: ['https://*/*'],
31+
optional_host_permissions: ['https://*/*', 'wss://*/*'],
3332
permissions: ['storage', 'unlimitedStorage', 'sidePanel', 'declarativeNetRequestWithHostAccess'],
3433
content_scripts: [
3534
{

src/app/bots/bing/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ofetch } from 'ofetch'
22
import WebSocketAsPromised from 'websocket-as-promised'
3+
import { requestHostPermission } from '~app/utils/permissions'
34
import { BingConversationStyle, getUserConfig } from '~services/user-config'
45
import { uuid } from '~utils'
56
import { ChatError, ErrorCode } from '~utils/errors'
@@ -98,6 +99,9 @@ export class BingWebBot extends AbstractBot {
9899
}
99100

100101
async doSendMessage(params: SendMessageParams) {
102+
if (!(await requestHostPermission('wss://*.bing.com/'))) {
103+
throw new ChatError('Missing bing.com permission', ErrorCode.MISSING_HOST_PERMISSION)
104+
}
101105
if (!this.conversationContext) {
102106
const [conversation, { bingConversationStyle }] = await Promise.all([createConversation(), getUserConfig()])
103107
this.conversationContext = {

0 commit comments

Comments
 (0)