swissmanu / harmonyhubjs-client

A Node.JS library which allows you to interact with your Logitech Harmony Hub.
https://github.com/swissmanu/harmonyhubjs-client
MIT License
155 stars 42 forks source link

Force node-xmpp-client version to 3.0.0 #29

Closed dale3h closed 7 years ago

dale3h commented 7 years ago

A recent update/overhaul of the node-xmpp package broke this module. The simplest workaround (for now) is to force the version of node-xmpp-client to 3.0.0 and node-xmpp-stanza to 1.1.0.

The parser now used in node-xmpp is stripping the <![CDATA[ ... ]]> from the stanza. Until this is resolved in the parser itself (ltx), it will not function properly.

While I was digging around, I did notice that you can use the options argument of the StreamParser to select your own parser. However, I do not know if this is something that is accessible from our side of the node-xmpp package.

node-xmpp-client 3.0.0 debug output:

  xmpp:connection send: <stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0" to="x.com">
  xmpp:connection receive: <?xml version='1.0' encoding='iso-8859-1'?><stream:stream from='x.com' id='XXXXXXX' version='1.0' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms></stream:features>
  xmpp:connection send: <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</auth>
  xmpp:connection receive: <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
  xmpp:connection send: <stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0" to="x.com">
  xmpp:connection receive: <stream:stream from='x.com' id='XXXXXXX' version='1.0' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:nx:xmpp-session'/></stream:features>
  xmpp:connection send: <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>gatorade</resource></bind>
  xmpp:connection receive: <iq id='bind' type='result'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>1111/gatorade</jid></bind></iq>
  harmonyhubjs:client:login:hub XMPP client connected
  xmpp:connection send: <iq type="get" id="XXXXXX" from="guest"><oa xmlns="connect.logitech.com" mime="vnd.logitech.connect/vnd.logitech.pair">method=pair:name=harmonyjs#iOS6.0.1#iPhone</oa></iq>
  xmpp:connection receive: <iq/>
  harmonyhubjs:client:login:hub received XMPP stanza: <iq xmlns:stream="http://etherx.jabber.org/streams"/>
  xmpp:connection receive: <iq id="XXXXXX" to="guest" type="get"><oa xmlns='connect.logitech.com' mime='vnd.logitech.connect/vnd.logitech.pair' errorcode='200' errorstring='OK'><![CDATA[serverIdentity=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:hubId=106:identity=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:status=succeeded:protocolVersion={XMPP="1.0", HTTP="1.0", RF="1.0", WEBSOCKET="1.0"}:hubProfiles={Harmony="2.0"}:productId=Pimento:friendlyName=Harmony Hub]]></oa></iq>
  harmonyhubjs:client:login:hub received XMPP stanza: <iq id="XXXXXX" to="guest" type="get" xmlns:stream="http://etherx.jabber.org/streams"><oa xmlns="connect.logitech.com" mime="vnd.logitech.connect/vnd.logitech.pair" errorcode="200" errorstring="OK">serverIdentity=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:hubId=106:identity=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:status=succeeded:protocolVersion={XMPP="1.0", HTTP="1.0", RF="1.0", WEBSOCKET="1.0"}:hubProfiles={Harmony="2.0"}:productId=Pimento:friendlyName=Harmony Hub</oa></iq>
  harmonyhubjs:client:login:hub received identity token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

node-xmpp-client 3.0.2 debug output:

  xmpp:connection send: <stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0" to="x.com">
  xmpp:connection receive: <?xml version='1.0' encoding='iso-8859-1'?><stream:stream from='x.com' id='XXXXXXX' version='1.0' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms></stream:features>
  xmpp:connection send: <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</auth>
  xmpp:connection receive: <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
  xmpp:connection send: <stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0" to="x.com">
  xmpp:connection receive: <stream:stream from='x.com' id='XXXXXXX' version='1.0' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:nx:xmpp-session'/></stream:features>
  xmpp:connection send: <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>gatorade</resource></bind>
  xmpp:connection receive: <iq id='bind' type='result'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>1111/gatorade</jid></bind></iq>
  harmonyhubjs:client:login:hub XMPP client connected
  xmpp:connection send: <iq type="get" id="XXXXXX" from="guest"><oa xmlns="connect.logitech.com" mime="vnd.logitech.connect/vnd.logitech.pair">method=pair:name=harmonyjs#iOS6.0.1#iPhone</oa></iq>
  xmpp:connection receive: <iq/>
  harmonyhubjs:client:login:hub received XMPP stanza: <iq xmlns:stream="http://etherx.jabber.org/streams"/>
  xmpp:connection receive: <iq id="XXXXXX" to="guest" type="get"><oa xmlns='connect.logitech.com' mime='vnd.logitech.connect/vnd.logitech.pair' errorcode='200' errorstring='OK'><![CDATA[serverIdentity=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:hubId=106:identity=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:status=succeeded:protocolVersion={XMPP="1.0", HTTP="1.0", RF="1.0", WEBSOCKET="1.0"}:hubProfiles={Harmony="2.0"}:productId=Pimento:friendlyName=Harmony Hub]]></oa></iq>
  harmonyhubjs:client:login:hub received XMPP stanza: <iq id="XXXXXX" to="guest" type="get" xmlns:stream="http://etherx.jabber.org/streams"><oa xmlns="connect.logitech.com" mime="vnd.logitech.connect/vnd.logitech.pair" errorcode="200" errorstring="OK"/></iq>
  harmonyhubjs:client:login:hub could not find identity token
swissmanu commented 7 years ago

hey @dale3h, sorry for getting back to you this late. thank you for your fix. had already some issues with the stripping of CDATA content and ltx, too bad it appears now again.

a possible workaround using a custom parser with StreamParser sounds very promising. though i also have not looked into it further.

swissmanu commented 7 years ago

version 1.1.10 is available on npm 👍

maddox commented 7 years ago

:heart: