9a2da60b7d
Note: websocket s2s is not working yet, still WIP. New Features * Chat Federation: * You can now connect to a remote chat with your local account. * This remote connection is done using a custom implementation of [XEP-0468: WebSocket S2S](https://xmpp.org/extensions/xep-0468.html), using some specific discovering method (so that it will work without any DNS configuration). Minor changes and fixes * Possibility to debug Prosody in development environments. * Using process.spawn instead of process.exec to launch Prosody (safer, and more optimal). * Prosody AppImage: fix path mapping: we only map necessary /etc/ subdir, so that the AppImage can access to /etc/resolv.conf, /etc/hosts, ... * Prosody AppImage: hidden debug mode to disable lua-unbound, that seems broken in some docker dev environments.
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import type { LiveChatJSONLDAttribute } from './types'
|
|
|
|
interface AnonymousConnectionInfos {
|
|
roomJID: string
|
|
boshUri?: string
|
|
wsUri?: string
|
|
userJID: string
|
|
}
|
|
|
|
function anonymousConnectionInfos (livechatInfos: LiveChatJSONLDAttribute | false): AnonymousConnectionInfos | null {
|
|
if (!livechatInfos) { return null }
|
|
if (!livechatInfos.links) { return null }
|
|
if (livechatInfos.type !== 'xmpp') { return null }
|
|
const r: AnonymousConnectionInfos = {
|
|
roomJID: livechatInfos.jid,
|
|
userJID: ''
|
|
}
|
|
for (const link of livechatInfos.links) {
|
|
// Note: userJID is on both links. But should have the same value.
|
|
if (link.type === 'xmpp-bosh-anonymous') {
|
|
r.boshUri = link.url
|
|
r.userJID = link.jid
|
|
} else if (link.type === 'xmpp-websocket-anonymous') {
|
|
r.wsUri = link.url
|
|
r.userJID = link.jid
|
|
}
|
|
}
|
|
if (r.userJID === '') {
|
|
return null
|
|
}
|
|
return r
|
|
}
|
|
|
|
function remoteAuthenticatedConnectionEnabled (livechatInfos: LiveChatJSONLDAttribute | false): boolean {
|
|
if (!livechatInfos) { return false }
|
|
if (!livechatInfos.links) { return false }
|
|
if (livechatInfos.type !== 'xmpp') { return false }
|
|
for (const link of livechatInfos.links) {
|
|
if (link.type === 'xmpp-peertube-livechat-ws-s2s') { return true }
|
|
if (link.type === 'xmpp-s2s') { return true }
|
|
}
|
|
return false
|
|
}
|
|
|
|
export {
|
|
anonymousConnectionInfos,
|
|
remoteAuthenticatedConnectionEnabled
|
|
}
|