node-xmpp-component
Advanced tools
Comparing version 1.0.0 to 2.0.0
103
index.js
@@ -1,100 +0,9 @@ | ||
'use strict'; | ||
'use strict' | ||
var util = require('util') | ||
, crypto = require('crypto') | ||
, EventEmitter = require('events').EventEmitter | ||
, Connection = require('node-xmpp-core').Connection | ||
, JID = require('node-xmpp-core').JID | ||
, SRV = require('node-xmpp-core').SRV | ||
, ltx = require('node-xmpp-core').ltx | ||
var Component = require('./lib/Component') | ||
var core = require('node-xmpp-core') | ||
/** | ||
* opts: | ||
* jid: String (required) | ||
* password: String (required) | ||
* host: String (required) | ||
* port: Number (required) | ||
* reconnect: Boolean (optional) | ||
*/ | ||
function Component(opts) { | ||
EventEmitter.call(this) | ||
var self = this | ||
var conn = this.connection = new Connection(opts) | ||
this._addConnectionListeners() | ||
module.exports = Component | ||
module.exports.Component = Component | ||
if (typeof opts.jid === 'string') { | ||
this.connection.jid = new JID(opts.jid) | ||
} else { | ||
this.connection.jid = opts.jid | ||
} | ||
this.connection.password = opts.password | ||
this.connection.xmlns[''] = this.NS_COMPONENT | ||
this.connection.xmlns['stream'] = this.NS_STREAM | ||
this.connection.streamTo = this.connection.jid.domain | ||
this.connection.listen({ | ||
socket:SRV.connect({ | ||
services: [], | ||
domain: opts.host, | ||
defaultPort: opts.port, | ||
socket: opts.socket | ||
}) | ||
}) | ||
} | ||
util.inherits(Component, EventEmitter) | ||
Component.prototype.NS_COMPONENT = 'jabber:component:accept' | ||
Component.prototype.NS_STREAM = 'http://etherx.jabber.org/streams' | ||
Component.prototype.onStreamStart = function(streamAttrs) { | ||
var digest = this._sha1Hex(streamAttrs.id + this.connection.password) | ||
this.connection.send(new ltx.Element('handshake').t(digest)) | ||
} | ||
Component.prototype.onStanza = function(stanza) { | ||
if (stanza.is('handshake')) { | ||
this.emit('online') | ||
return | ||
} | ||
this.emit('stanza', stanza) | ||
} | ||
Component.prototype.send = function(stanza) { | ||
this.connection.send(stanza) | ||
} | ||
Component.prototype.end = function() { | ||
this.connection.end() | ||
} | ||
Component.prototype._addConnectionListeners = function (con) { | ||
con = con || this.connection | ||
con.on('streamStart', this.onStreamStart.bind(this)) | ||
con.on('stanza', this.onStanza.bind(this)) | ||
con.on('drain', this.emit.bind(this, 'drain')) | ||
con.on('data', this.emit.bind(this, 'data')) | ||
con.on('end', this.emit.bind(this, 'end')) | ||
con.on('close', this.emit.bind(this, 'close')) | ||
con.on('error', this.emit.bind(this, 'error')) | ||
con.on('connect', this.emit.bind(this, 'connect')) | ||
con.on('reconnect', this.emit.bind(this, 'reconnect')) | ||
con.on('disconnect', this.emit.bind(this, 'disconnect')) | ||
con.on('disconnect', this.emit.bind(this, 'offline')) | ||
if (con.startStream) { | ||
con.on('connect', function() { | ||
// Components start <stream:stream>, servers reply | ||
con.startStream() | ||
}) | ||
} | ||
} | ||
Component.prototype._sha1Hex = function(s) { | ||
var hash = crypto.createHash('sha1') | ||
hash.update(s) | ||
return hash.digest('hex') | ||
} | ||
Component.Component = Component | ||
module.exports = Component | ||
core.exportCoreUtils(module.exports) |
{ | ||
"name": "node-xmpp-component", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Component API for XMPP", | ||
"main": "index.js", | ||
"homepage": "https://github.com/node-xmpp/node-xmpp-component", | ||
"scripts": { | ||
"test": "grunt test", | ||
"integration-test": "grunt integration-test" | ||
"preversion": "npm test", | ||
"lint": "standard", | ||
"unit": "mocha --recursive test/unit", | ||
"integration": "mocha --recursive -t 60000 test/integration", | ||
"test": "npm run unit && npm run lint" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/node-xmpp/node-xmpp-component.git" | ||
}, | ||
"repository": "github:node-xmpp/node-xmpp-component", | ||
"keywords": [ | ||
"component", | ||
"xmpp" | ||
"XMPP" | ||
], | ||
"author": "Lloyd Watkin <lloyd@evilprofessor.co.uk>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/node-xmpp/node-xmpp-component/issues" | ||
}, | ||
"bugs": "https://github.com/node-xmpp/node-xmpp-component/issues", | ||
"dependencies": { | ||
"node-xmpp-core": "^3.0.0" | ||
"node-xmpp-core": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"grunt-mocha-cli": "^1.14.0", | ||
"grunt-contrib-jshint": "^0.11.3", | ||
"proxyquire": "^1.7.3", | ||
"should": "^7.1.0", | ||
"node-xmpp-client": "^2.0.0" | ||
"node-xmpp-client": "^3.0.0", | ||
"should": "^7.1.0" | ||
} | ||
} |
# node-xmpp-component | ||
Idiomatic XMPP component library for [node.js](http://nodejs.org/) | ||
XMPP component for Node.js | ||
[](http://travis-ci.org/node-xmpp/node-xmpp-component) | ||
[](https://travis-ci.org/node-xmpp/node-xmpp-component/branches) | ||
[](http://standardjs.com/) | ||
@@ -52,5 +53,1 @@ ## Manual | ||
* [node-xmpp-core](http://github.com/node-xmpp/node-xmpp-core) | ||
Optional | ||
* [node-stringprep](http://github.com/node-xmpp/node-stringprep): for [icu](http://icu-project.org/)-based string normalization. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
2
1
6439
5
90
53
1
+ Added@xmpp/jid@0.0.2(transitive)
+ Added@xmpp/streamparser@0.0.6(transitive)
+ Added@xmpp/xml@0.1.3(transitive)
+ Addedlodash.assign@4.2.0(transitive)
+ Addednode-xmpp-core@5.0.9(transitive)
+ Addednode-xmpp-tls-connect@1.0.1(transitive)
- Removedlodash._baseassign@3.2.0(transitive)
- Removedlodash._basecopy@3.0.1(transitive)
- Removedlodash._bindcallback@3.0.1(transitive)
- Removedlodash._createassigner@3.1.1(transitive)
- Removedlodash._getnative@3.9.1(transitive)
- Removedlodash._isiterateecall@3.0.9(transitive)
- Removedlodash.assign@3.2.0(transitive)
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.keys@3.1.2(transitive)
- Removedlodash.restparam@3.6.1(transitive)
- Removednode-xmpp-core@3.0.0(transitive)
- Removednode-xmpp-jid@1.0.2(transitive)
- Removedtls-connect@0.2.2(transitive)
Updatednode-xmpp-core@^5.0.0