Skip to content

Add support for XEP-0114 Components (in Node)#873

Merged
jcbrand merged 5 commits into
masterfrom
feature/xep-0114-component-support
Jul 15, 2026
Merged

Add support for XEP-0114 Components (in Node)#873
jcbrand merged 5 commits into
masterfrom
feature/xep-0114-component-support

Conversation

@jcbrand

@jcbrand jcbrand commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

No description provided.

jcbrand added 5 commits July 12, 2026 22:42
Move the BOSH, WebSocket and shared-worker WebSocket protocol-manager classes
into a dedicated src/transports/ directory and update their imports and the
references from index.ts and connection.ts. Pure code move, no behaviour change.
Connect to an XMPP server as an external component over a raw TCP stream.
Adds a new component transport alongside the existing BOSH and WebSocket ones.

Select it with the protocol: 'component' option and a tcp://host:port service URL.
`connect(domain, secret, ...)` opens the stream, performs the SHA-1 handshake
(XEP-0114) and reaches Status.CONNECTED. Stanza builders, addHandler, IQ
callbacks and plugins all work unchanged; outgoing stanzas are stamped with a
'from' under the component domain.
The Node build only ever used jsdom to supply three XML-DOM globals
(document.implementation, DOMParser, XMLSerializer) plus ws, a fraction of
what a full HTML browser emulation provides. Swap it for @xmldom/xmldom, a
small, pure-JavaScript, XML-only W3C DOM.
Formalise the informal contract that Connection invokes on `this._proto`
into a `Transport` interface implemented by Bosh, Websocket,
WorkerWebsocket and Component.
… built

Handlers registered by namespace (e.g. addHandler(cb, NS.PUBSUB, 'iq',
'set')) silently failed to match stanzas received over the XEP-0114
component transport.

Root cause was a disagreement between how the component parser produces
DOM and how handler matching reads it. The component parser builds
elements with `createElementNS` and omits the redundant `xmlns`
attribute (the namespace is carried on `namespaceURI`), whereas
Handler.getNamespace read only `elem.getAttribute('xmlns')`.

Neither accessor is reliable on its own: locally-built stanzas ($iq,
stx, Builder) use createElement and carry the namespace only in the
xmlns attribute (namespaceURI is null). Component stanzas carry it only
on namespaceURI. DOMParser stanzas carry both except on children that
inherit the default namespace. Reading both is the transport-agnostic
way to resolve an element's namespace.

Extract that logic as a blessed `Strophe.getNamespace(elem)` helper
so downstream consumers have one correct accessor.
@jcbrand jcbrand merged commit ce2c5f5 into master Jul 15, 2026
1 check passed
@jcbrand jcbrand deleted the feature/xep-0114-component-support branch July 15, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant