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

@xmpp/connection

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xmpp/connection - npm Package Compare versions

Comparing version 0.7.4 to 0.8.0

lib/util.js

64

index.js

@@ -7,2 +7,3 @@ 'use strict'

const StreamError = require('./lib/StreamError')
const {parseHost, parseService} = require('./lib/util')

@@ -49,3 +50,3 @@ const NS_STREAM = 'urn:ietf:params:xml:ns:xmpp-streams'

async _streamError(condition) {
async _streamError(condition, children) {
try {

@@ -55,5 +56,6 @@ await this.send(

xml('stream:error', {}, [
xml(condition, {xmlns: NS_STREAM}),
xml(condition, {xmlns: NS_STREAM}, children),
])
)
// eslint-disable-next-line no-unused-vars
} catch (err) {}

@@ -69,2 +71,3 @@

await this.parser.write(str)
// eslint-disable-next-line no-unused-vars
} catch (err) {

@@ -77,2 +80,3 @@ // https://xmpp.org/rfcs/rfc6120.html#streams-error-conditions-bad-format

this._streamError('bad-format')
// eslint-disable-next-line no-unused-vars
} catch (err) {}

@@ -121,5 +125,18 @@ }

this.emit(this.isStanza(element) ? 'stanza' : 'nonza', element)
// https://xmpp.org/rfcs/rfc6120.html#streams-error
if (element.name !== 'stream:error') return
this.emit('error', StreamError.fromElement(element))
if (element.name === 'stream:error') {
this._onStreamError(element)
}
}
// https://xmpp.org/rfcs/rfc6120.html#streams-error
_onStreamError(element) {
const error = StreamError.fromElement(element)
if (error.condition === 'see-other-host') {
this._onSeeOtherHost(error)
} else {
this.emit('error', error)
}
// "Stream Errors Are Unrecoverable"

@@ -130,2 +147,26 @@ // "The entity that receives the stream error then SHALL close the stream"

// https://xmpp.org/rfcs/rfc6120.html#streams-error-conditions-see-other-host
async _onSeeOtherHost(error) {
const {protocol} = parseService(this.options.service)
const host = error.element.getChildText('see-other-host')
const {port} = parseHost(host)
let service
if (port) {
service = `${protocol || 'xmpp:'}//${host}`
} else {
service = (protocol ? `${protocol}//` : '') + host
}
try {
await promise(this, 'disconnect')
const {domain, lang} = this.options
await this.connect(service)
await this.open({domain, lang})
} catch (err) {
this.emit('error', err)
}
}
_attachParser(p) {

@@ -177,2 +218,3 @@ const parser = (this.parser = p)

el = await this.close()
// eslint-disable-next-line no-unused-vars
} catch (err) {}

@@ -182,2 +224,3 @@

await this.disconnect()
// eslint-disable-next-line no-unused-vars
} catch (err) {}

@@ -210,3 +253,2 @@

*/
// eslint-disable-next-line require-await
async connect(service) {

@@ -289,3 +331,2 @@ this._status('connecting')

*/
// eslint-disable-next-line require-await
async restart() {

@@ -297,6 +338,4 @@ this._detachParser()

// eslint-disable-next-line require-await
async send(element) {
this.emit('outgoing', element)
await this.write(element)

@@ -336,8 +375,3 @@ this.emit('send', element)

const {name} = element
const NS = element.attrs.xmlns
return (
// This.online && FIXME
(NS ? NS === this.NS : true) &&
(name === 'iq' || name === 'message' || name === 'presence')
)
return name === 'iq' || name === 'message' || name === 'presence'
}

@@ -344,0 +378,0 @@

@@ -7,3 +7,3 @@ {

"bugs": "http://github.com/xmppjs/xmpp.js/issues",
"version": "0.7.4",
"version": "0.8.0",
"license": "ISC",

@@ -15,7 +15,6 @@ "keywords": [

"dependencies": {
"@xmpp/error": "^0.7.0",
"@xmpp/events": "^0.7.0",
"@xmpp/jid": "^0.7.4",
"@xmpp/streamparser": "^0.0.6",
"@xmpp/xml": "^0.7.4"
"@xmpp/error": "^0.8.0",
"@xmpp/events": "^0.8.0",
"@xmpp/jid": "^0.8.0",
"@xmpp/xml": "^0.8.0"
},

@@ -29,3 +28,3 @@ "engines": {

},
"gitHead": "feb8cec5dcfaf7571ed7259c6adfcf8be8394492"
"gitHead": "3ebafae0363444e21dd670a60eb202f4ce21f560"
}

@@ -17,27 +17,8 @@ 'use strict'

const conn = new Connection()
conn.NS = 'bar'
t.is(conn.isStanza(xml('foo')), false)
t.is(conn.isStanza(xml('foo', {xmlns: 'bar'})), false)
t.is(conn.isStanza(xml('presence', {xmlns: 'foo'})), false)
t.is(conn.isStanza(xml('iq', {xmlns: 'foo'})), false)
t.is(conn.isStanza(xml('message', {xmlns: 'foo'})), false)
t.is(conn.isStanza(xml('presence')), true)
t.is(conn.isStanza(xml('iq')), true)
t.is(conn.isStanza(xml('message')), true)
t.is(conn.isStanza(xml('presence', {xmlns: 'bar'})), true)
t.is(conn.isStanza(xml('iq', {xmlns: 'bar'})), true)
t.is(conn.isStanza(xml('message', {xmlns: 'bar'})), true)
// Conn.online = false
//
// t.is(conn.isStanza(xml`<presence/>`), false)
// t.is(conn.isStanza(xml`<iq/>`), false)
// t.is(conn.isStanza(xml`<message/>`), false)
// t.is(conn.isStanza(xml`<presence xmlns='bar'/>`), false)
// t.is(conn.isStanza(xml`<iq xmlns='bar'/>`), false)
// t.is(conn.isStanza(xml`<message xmlns='bar'/>`), false)
})

@@ -47,27 +28,8 @@

const conn = new Connection()
conn.NS = 'bar'
t.is(conn.isNonza(xml('foo')), true)
t.is(conn.isNonza(xml('foo', {xmlns: 'bar'})), true)
t.is(conn.isNonza(xml('presence', {xmlns: 'foo'})), true)
t.is(conn.isNonza(xml('iq', {xmlns: 'foo'})), true)
t.is(conn.isNonza(xml('message', {xmlns: 'foo'})), true)
t.is(conn.isNonza(xml('presence')), false)
t.is(conn.isNonza(xml('iq')), false)
t.is(conn.isNonza(xml('message')), false)
t.is(conn.isNonza(xml('presence', {xmlns: 'bar'})), false)
t.is(conn.isNonza(xml('iq', {xmlns: 'bar'})), false)
t.is(conn.isNonza(xml('message', {xmlns: 'bar'})), false)
// Conn.online = false
//
// t.is(conn.isNonza(xml`<presence/>`), true)
// t.is(conn.isNonza(xml`<iq/>`), true)
// t.is(conn.isNonza(xml`<message/>`), true)
// t.is(conn.isNonza(xml`<presence xmlns='bar'/>`), true)
// t.is(conn.isNonza(xml`<iq xmlns='bar'/>`), true)
// t.is(conn.isNonza(xml`<message xmlns='bar'/>`), true)
})
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