xmppjs / hubot-xmpp

XMPP adapter for Hubot
181 stars 103 forks source link

Does not run under node v12 #127

Closed gloomytrousers closed 4 years ago

gloomytrousers commented 4 years ago

Attempting to run hubot with xmpp connector under node v12, I get:

[Sun Oct 13 2019 12:29:05 GMT-0100 (Greenwich Mean Time)] ERROR TypeError: crypto.createCredentials is not a function
  at connect (/opt/hubot/node_modules/tls-connect/starttls.js:231:51)
  at Connection.setSecure (/opt/hubot/node_modules/node-xmpp-core/lib/Connection.js:320:19)
  at Connection.onStanza (/opt/hubot/node_modules/node-xmpp-core/lib/Connection.js:367:10)
  at StreamParser.<anonymous> (/opt/hubot/node_modules/node-xmpp-core/lib/Connection.js:226:10)
  at StreamParser.emit (events.js:210:5)
  at SaxLtx.<anonymous> (/opt/hubot/node_modules/node-xmpp-core/lib/StreamParser.js:58:14)
  at SaxLtx.emit (events.js:210:5)
  at SaxLtx._handleTagOpening (/opt/hubot/node_modules/ltx/lib/parsers/ltx.js:37:14)
  at SaxLtx.write (/opt/hubot/node_modules/ltx/lib/parsers/ltx.js:159:18)
  at StreamParser.write (/opt/hubot/node_modules/node-xmpp-core/lib/StreamParser.js:123:17)
  at Connection.onData (/opt/hubot/node_modules/node-xmpp-core/lib/Connection.js:305:17)
  at Socket.emit (events.js:215:7)
  at addChunk (_stream_readable.js:308:12)
  at readableAddChunk (_stream_readable.js:289:11)
  at Socket.Readable.push (_stream_readable.js:223:10)
  at TCP.onStreamRead (internal/stream_base_commons.js:182:23)

It's OK under node v10, although I get these warnings, the first of which gives the obvious reason and the fix, and the second of which should also be addressed:

(node:10) [DEP0010] DeprecationWarning: crypto.createCredentials is deprecated. Use tls.createSecureContext instead.
(node:10) [DEP0107] DeprecationWarning: tls.convertNPNProtocols() is deprecated.
markstory commented 4 years ago

Any chance you would want to make a pull request for this? I no longer run a hubot on xmpp so this project is mostly in maintenance mode.

gloomytrousers commented 4 years ago

I've done some digging. The dependency chain to the offending package is hubot-xmpp@0.2.6 -> node-xmpp-client@3.0.0 -> node-xmpp-core@4.2.0-> tls-connect@0.2.2

The change in tls-connect is trivial, but isn't the way to go here.

https://www.npmjs.com/package/node-xmpp-client (currently at v3.2.0, 3 years old) says:

this package is deprecated please use https://www.npmjs.com/package/@xmpp/client

and https://www.npmjs.com/package/node-xmpp-core (currently v5.0.9, also 3 years old) says:

this package is deprecated please use https://github.com/xmppjs/xmpp.js

(https://www.npmjs.com/package/@xmpp/client code is https://github.com/xmppjs/xmpp.js)

So I think hubot-xmpp needs updating to use this. This isn't really my area of expertise; it appears it might be relatively straightforward for someone suitably skilled but isn't something I can commit to right now.

sonnyp commented 4 years ago

Author of xmpp.js here (and latest maintainer of node-xmpp).

node-xmpp is not maintained anymore I'd like to make a xmpp.js adapter for hubot.

Normally I would send a PR here but since it is in maintanance mode it doesn't make sense.

@markstory would you be willing to transfer the hubot-xmpp npm name?

markstory commented 4 years ago

Sure. I would be happy to transfer this repository as well if you're interested.

sonnyp commented 4 years ago

that'd be great to keep the history

Can you transfer to https://github.com/xmppjs ?

markstory commented 4 years ago

@sonnyp Sure. I've added you as a collaborator on this project but I don't think that will let you do the transfer. If I could be temporarily added to the xmppjs organization I could transfer the repository.

sonnyp commented 4 years ago

@markstory done

markstory commented 4 years ago

@sonnyp Thanks, I'll need 'create repository' privilege in order to do the transfer.

sonnyp commented 4 years ago

@markstory granted, sorry for the delay

markstory commented 4 years ago

@sonnyp Moved now. What username should I add to the npm package?

sonnyp commented 4 years ago

Thanks, sonny please

sonnyp commented 4 years ago

@gloomytrousers could you try hubot-xmpp 0.3.0 ?

https://github.com/xmppjs/hubot-xmpp/releases/tag/v0.3.0

It still uses node-xmpp for now but the last version which should fix your issue.

gloomytrousers commented 4 years ago

Seems to be running perfectly, thanks @sonnyp !