@goodandready/dsh-messenger-gateway 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapters/telegram.js +597 -596
- package/lib/client.js +11 -6
- package/lib/forum-mirror.js +105 -105
- package/lib/gateway-callbacks.js +188 -187
- package/lib/gateway-commands.js +587 -584
- package/lib/gateway.js +7 -1
- package/lib/http.js +16 -3
- package/lib/index.js +544 -540
- package/lib/models.js +29 -2
- package/package.json +1 -1
package/lib/gateway.js
CHANGED
|
@@ -519,7 +519,13 @@ export class Gateway {
|
|
|
519
519
|
for (const [key, chat] of this.chats) {
|
|
520
520
|
if (!chat.turnActive && now - chat.lastUsed > timeout) {
|
|
521
521
|
if (chat.agent?.session?.id) {
|
|
522
|
-
|
|
522
|
+
const sid = String(chat.agent.session.id)
|
|
523
|
+
this.sessionToChat.delete(sid)
|
|
524
|
+
const threadInfo = this.sessionToThread.get(sid)
|
|
525
|
+
if (threadInfo) {
|
|
526
|
+
this.threadToSession.delete(`${threadInfo.chatId}:${threadInfo.threadId}`)
|
|
527
|
+
this.sessionToThread.delete(sid)
|
|
528
|
+
}
|
|
523
529
|
}
|
|
524
530
|
this.chats.delete(key)
|
|
525
531
|
chat.dispose().catch(() => {})
|
package/lib/http.js
CHANGED
|
@@ -13,10 +13,23 @@ export function writeJson(res, status, body) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function isTrustedSettingsRequest(req) {
|
|
16
|
-
const origin = String(req.headers?.origin || '')
|
|
17
16
|
const host = String(req.headers?.host || '')
|
|
18
|
-
if (!
|
|
19
|
-
|
|
17
|
+
if (!host) return false
|
|
18
|
+
|
|
19
|
+
const origin = String(req.headers?.origin || '')
|
|
20
|
+
if (origin) {
|
|
21
|
+
try { return new URL(origin).host === host } catch { return false }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const secFetchSite = String(req.headers?.['sec-fetch-site'] || '').toLowerCase()
|
|
25
|
+
if (secFetchSite === 'same-origin') return true
|
|
26
|
+
|
|
27
|
+
const referer = String(req.headers?.referer || '')
|
|
28
|
+
if (referer) {
|
|
29
|
+
try { return new URL(referer).host === host } catch { return false }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return false
|
|
20
33
|
}
|
|
21
34
|
|
|
22
35
|
export function timingSafeCompare(a, b) {
|