New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-xmpp-component

Package Overview
Dependencies
Maintainers
5
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-xmpp-component - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

lib/Component.js

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
[![build status](https://secure.travis-ci.org/node-xmpp/node-xmpp-component.png)](http://travis-ci.org/node-xmpp/node-xmpp-component)
[![build status](https://img.shields.io/travis/node-xmpp/node-xmpp-component/master.svg?style=flat-square)](https://travis-ci.org/node-xmpp/node-xmpp-component/branches)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc