Skip to content

Commit 72bfc3f

Browse files
committed
Fix bing wss origin error
1 parent b6b28bb commit 72bfc3f

4 files changed

Lines changed: 42 additions & 30 deletions

File tree

manifest.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ export default defineManifest(async (env) => {
2020
action: {},
2121
host_permissions: [
2222
'https://*.bing.com/',
23+
'wss://*.bing.com/',
2324
'https://*.openai.com/',
2425
'https://bard.google.com/',
2526
'https://*.chathub.gg/',
27+
'https://*.duckduckgo.com/',
28+
'https://*.poe.com/',
29+
'https://*.anthropic.com/',
30+
'https://*.claude.ai/',
2631
],
2732
optional_host_permissions: ['https://*/*'],
2833
permissions: ['storage', 'unlimitedStorage', 'sidePanel', 'declarativeNetRequestWithHostAccess'],

src/app/bots/bing/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const API_ENDPOINT = 'https://www.bing.com/turing/conversation/create'
1414
export async function createConversation(): Promise<ConversationResponse> {
1515
const headers = {
1616
'x-ms-client-request-id': uuid(),
17-
'x-ms-useragent': 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/Win32',
17+
'x-ms-useragent': 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.3 OS/macOS',
1818
}
1919

2020
let resp: ConversationResponse

src/app/bots/bing/index.ts

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ofetch } from 'ofetch'
22
import WebSocketAsPromised from 'websocket-as-promised'
33
import { BingConversationStyle, getUserConfig } from '~services/user-config'
4+
import { uuid } from '~utils'
45
import { ChatError, ErrorCode } from '~utils/errors'
56
import { AbstractBot, SendMessageParams } from '../abstract-bot'
67
import { createConversation } from './api'
@@ -13,23 +14,25 @@ const OPTIONS_SETS = [
1314
'disable_emoji_spoken_text',
1415
'responsible_ai_policy_235',
1516
'enablemm',
16-
'iycapbing',
17-
'iyxapbing',
18-
'objopinion',
19-
'rweasgv2',
20-
'dagslnv1',
2117
'dv3sugg',
22-
'autosave',
23-
'iyoloxap',
24-
'iyoloneutral',
25-
'clgalileo',
26-
'gencontentv3',
18+
'iyxapbing',
19+
'iycapbing',
20+
'galileo',
21+
'saharagenconv5',
22+
'fluxhint',
23+
'glfluxv13',
24+
'uquopt',
25+
'bof107v2',
26+
'streamw',
27+
'rctechalwlst',
28+
'agicert',
2729
]
2830

2931
export class BingWebBot extends AbstractBot {
3032
private conversationContext?: ConversationInfo
3133

3234
private buildChatRequest(conversation: ConversationInfo, message: string, imageUrl?: string) {
35+
const requestId = uuid()
3336
const optionsSets = OPTIONS_SETS
3437
if (conversation.conversationStyle === BingConversationStyle.Precise) {
3538
optionsSets.push('h3precise')
@@ -51,34 +54,38 @@ export class BingWebBot extends AbstractBot {
5154
'SearchQuery',
5255
],
5356
sliceIds: [
54-
'winmuid1tf',
55-
'anssupfor_c',
56-
'imgchatgptv2',
57-
'tts2cf',
58-
'contansperf',
59-
'mlchatpc8500w',
60-
'mlchatpc2',
61-
'ctrlworkpay',
62-
'winshortmsgtf',
63-
'cibctrl',
64-
'sydtransctrl',
57+
'825asmetrics',
58+
'gbacf',
59+
'divkorbl2p',
60+
'emovoice',
61+
'tts3',
62+
'wrapuxslimt',
63+
'rbingchromecf',
6564
'sydconfigoptc',
66-
'0705trt4',
67-
'517opinion',
68-
'628ajcopus0',
69-
'330uaugs0',
70-
'529rwea',
71-
'0626snptrcs0',
72-
'424dagslnv1',
65+
'0824cntor',
66+
'816bof107v2',
67+
'0529streamw',
68+
'streamw',
69+
'178gentech',
70+
'824fluxhi52s0',
71+
'0825agicert',
72+
'621alllocs0',
73+
'727nrprdrs0',
7374
],
75+
scenario: 'SERP',
76+
plugins: [],
7477
isStartOfSession: conversation.invocationId === 0,
7578
message: {
79+
timestamp: new Date().toISOString(),
7680
author: 'user',
7781
inputMethod: 'Keyboard',
7882
text: message,
7983
imageUrl,
8084
messageType: 'Chat',
85+
requestId,
86+
messageId: requestId,
8187
},
88+
requestId,
8289
conversationId: conversation.conversationId,
8390
conversationSignature: conversation.conversationSignature,
8491
participant: { id: conversation.clientId },

src/rules/bing.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"condition": {
2121
"urlFilter": "bing",
2222
"isUrlFilterCaseSensitive": false,
23-
"resourceTypes": ["xmlhttprequest"]
23+
"resourceTypes": ["xmlhttprequest", "websocket"]
2424
}
2525
}
2626
]

0 commit comments

Comments
 (0)