Add support for XEP-0114 Components (in Node)#873
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.