@sockethub/platform-xmpp 5.0.0-beta.0 → 5.0.0-beta.1

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/README.md CHANGED
@@ -26,6 +26,11 @@ updates through ActivityStreams messages.
26
26
  Credentials are sent to Sockethub via a `credentials` message before the
27
27
  `connect` verb. The XMPP platform accepts a single `password` field.
28
28
 
29
+ Authentication requires an encrypted connection: direct TLS (`xmpps://`) or
30
+ a successful STARTTLS upgrade. If the server does not offer encryption, the
31
+ connection fails before credentials are sent.
32
+ This requirement also applies to automatic reconnections.
33
+
29
34
  ### Credentials object
30
35
 
31
36
  | Field | Type | Required | Description |
@@ -34,8 +39,40 @@ Credentials are sent to Sockethub via a `credentials` message before the
34
39
  | `userAddress` | string | yes | Bare JID, e.g. `user@jabber.net`. |
35
40
  | `resource` | string | yes | XMPP resource identifier (e.g. `"phone"`). |
36
41
  | `password` | string | yes | SASL password. Use this field for PLAIN-slot tokens too. |
37
- | `server` | string | no | Overrides the hostname from `userAddress`. |
38
- | `port` | number | no | Overrides the default port. |
42
+ | `server` | string | no | Overrides the host from `userAddress`. Host name or `xmpp(s)://` URI. |
43
+ | `port` | integer | no | Overrides the default port (1-65535). |
44
+
45
+ Without a `port`, a bare host is looked up through its `_xmpps-client` and
46
+ `_xmpp-client` SRV records, and its own addresses on ports 5223 (direct TLS)
47
+ and 5222. A bare host with a `port` skips SRV lookup and connects with
48
+ `xmpp://` (STARTTLS) on that port. For direct TLS, set `server` to an
49
+ `xmpps://` URI. The platform does not use HTTP host-meta discovery or the
50
+ WebSocket transport.
51
+
52
+ An internationalized host name (such as `bücher.example`) works only as a bare
53
+ host without a `port`. With a `port`, or inside an `xmpp(s)://` URI, it is
54
+ refused; use its ASCII form (`xn--bcher-kva.example`) instead.
55
+
56
+ ### Private addresses
57
+
58
+ The platform refuses to connect to loopback, private, link-local, and cloud
59
+ metadata addresses, using the same address rules as the
60
+ [outbound URL guard](../../docs/configuration.md#outbound-url-guard). To reach
61
+ an XMPP server on a private network, set `allowPrivateAddresses` in this
62
+ platform's `packageConfig` entry:
63
+
64
+ ```json
65
+ {
66
+ "packageConfig": {
67
+ "@sockethub/platform-xmpp": {
68
+ "allowPrivateAddresses": true
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ Do not enable it on a server that accepts untrusted clients. Any client could
75
+ then make Sockethub connect to internal services.
39
76
 
40
77
  ### Password authentication
41
78
 
@@ -0,0 +1,16 @@
1
+ import type { XmppClientInstance } from "@xmpp/client";
2
+ /**
3
+ * Refuse XMPP connections to loopback, private, link-local, and cloud
4
+ * metadata addresses, matching the outbound guard used by the HTTP platforms.
5
+ *
6
+ * Every socket gets the shared guarded DNS lookup, which checks the address
7
+ * actually connected to. IP-literal hosts skip DNS, so they are checked
8
+ * directly; `@xmpp/resolve` turns SRV and A records into IP literals, so
9
+ * discovered candidates are checked here too. Transports that do not use a
10
+ * host/port socket (WebSocket) are refused outright. xmpp.js treats a
11
+ * refusal as "no transport" and skips that candidate.
12
+ *
13
+ * The wrapper lives on the shared module-level prototypes, like
14
+ * {@link setTlsServername}, and its setting is refreshed on every call.
15
+ */
16
+ export declare function guardXmppConnections(client: XmppClientInstance, allowPrivateAddresses: boolean): void;
package/dist/index.d.ts CHANGED
@@ -48,6 +48,8 @@ export default class XMPP implements PersistentPlatformInterface {
48
48
  readonly sendToClient: PlatformSendToClient;
49
49
  /** @internal Set of bare JIDs for rooms this client has joined. */
50
50
  __knownRooms: Set<string>;
51
+ /** @internal Bare JID of the authenticated account, used by IncomingHandlers. */
52
+ __bareJid: string | undefined;
51
53
  protected __clientConstructor: (options: XmppClientOptions) => XmppClientInstance;
52
54
  protected __xml: (name: string, attrs?: Record<string, string | undefined>, ...children: (XmppElement | undefined)[]) => XmppElement;
53
55
  private readonly id;