@xmpp/debug
Advanced tools
Comparing version 0.11.0 to 0.12.0
64
index.js
@@ -1,25 +0,25 @@ | ||
'use strict' | ||
"use strict"; | ||
/* eslint no-console: 0 */ | ||
const serialize = require('@xmpp/xml/lib/serialize') | ||
const xml = require('@xmpp/xml') | ||
const clone = require('@xmpp/xml/lib/clone') | ||
const serialize = require("@xmpp/xml/lib/serialize"); | ||
const xml = require("@xmpp/xml"); | ||
const clone = require("@xmpp/xml/lib/clone"); | ||
const NS_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl' | ||
const NS_COMPONENT = 'jabber:component:accept' | ||
const NS_SASL = "urn:ietf:params:xml:ns:xmpp-sasl"; | ||
const NS_COMPONENT = "jabber:component:accept"; | ||
const SENSITIVES = [ | ||
['handshake', NS_COMPONENT], | ||
['auth', NS_SASL], | ||
['challenge', NS_SASL], | ||
['response', NS_SASL], | ||
['success', NS_SASL], | ||
] | ||
["handshake", NS_COMPONENT], | ||
["auth", NS_SASL], | ||
["challenge", NS_SASL], | ||
["response", NS_SASL], | ||
["success", NS_SASL], | ||
]; | ||
function isSensitive(element) { | ||
if (element.children.length === 0) return false | ||
return SENSITIVES.some(sensitive => { | ||
return element.is(...sensitive) | ||
}) | ||
if (element.children.length === 0) return false; | ||
return SENSITIVES.some((sensitive) => { | ||
return element.is(...sensitive); | ||
}); | ||
} | ||
@@ -29,11 +29,11 @@ | ||
if (isSensitive(element)) { | ||
element.children = [] | ||
element.append(xml('hidden', {xmlns: 'xmpp.js'})) | ||
element.children = []; | ||
element.append(xml("hidden", { xmlns: "xmpp.js" })); | ||
} | ||
return element | ||
return element; | ||
} | ||
function format(element) { | ||
return serialize(hideSensitive(clone(element), 2)) | ||
return serialize(hideSensitive(clone(element), 2)); | ||
} | ||
@@ -43,18 +43,18 @@ | ||
if (process.env.XMPP_DEBUG || force === true) { | ||
entity.on('element', data => { | ||
console.debug(`IN\n${format(data)}`) | ||
}) | ||
entity.on("element", (data) => { | ||
console.debug(`IN\n${format(data)}`); | ||
}); | ||
entity.on('send', data => { | ||
console.debug(`OUT\n${format(data)}`) | ||
}) | ||
entity.on("send", (data) => { | ||
console.debug(`OUT\n${format(data)}`); | ||
}); | ||
entity.on('error', console.error) | ||
entity.on("error", console.error); | ||
entity.on('status', (status, value) => { | ||
console.debug('status', status, value ? value.toString() : '') | ||
}) | ||
entity.on("status", (status, value) => { | ||
console.debug("status", status, value ? value.toString() : ""); | ||
}); | ||
} | ||
} | ||
}; | ||
module.exports.hideSensitive = hideSensitive | ||
module.exports.hideSensitive = hideSensitive; |
@@ -7,3 +7,3 @@ { | ||
"bugs": "http://github.com/xmppjs/xmpp.js/issues", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"license": "ISC", | ||
@@ -15,7 +15,7 @@ "keywords": [ | ||
"engines": { | ||
"node": ">= 10.0.0", | ||
"node": ">= 12.4.0", | ||
"yarn": ">= 1.0.0" | ||
}, | ||
"dependencies": { | ||
"@xmpp/xml": "^0.11.0" | ||
"@xmpp/xml": "^0.12.0" | ||
}, | ||
@@ -25,3 +25,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "c0548a598826ae55cf195f296058b344064af7fd" | ||
"gitHead": "75f7bdf7805dced03f616b66dc16e2a067b46480" | ||
} |
40
test.js
@@ -1,7 +0,7 @@ | ||
'use strict' | ||
"use strict"; | ||
const test = require('ava') | ||
const {hideSensitive} = require('.') | ||
const test = require("ava"); | ||
const { hideSensitive } = require("."); | ||
test('SASL', t => { | ||
test("SASL", (t) => { | ||
t.deepEqual( | ||
@@ -11,34 +11,34 @@ hideSensitive(<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl">foo</auth>), | ||
<hidden xmlns="xmpp.js" /> | ||
</auth> | ||
) | ||
</auth>, | ||
); | ||
t.deepEqual( | ||
hideSensitive( | ||
<challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">foo</challenge> | ||
<challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">foo</challenge>, | ||
), | ||
<challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> | ||
<hidden xmlns="xmpp.js" /> | ||
</challenge> | ||
) | ||
</challenge>, | ||
); | ||
t.deepEqual( | ||
hideSensitive( | ||
<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">foo</response> | ||
<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">foo</response>, | ||
), | ||
<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> | ||
<hidden xmlns="xmpp.js" /> | ||
</response> | ||
) | ||
</response>, | ||
); | ||
t.deepEqual( | ||
hideSensitive( | ||
<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">foo</success> | ||
<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">foo</success>, | ||
), | ||
<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> | ||
<hidden xmlns="xmpp.js" /> | ||
</success> | ||
) | ||
}) | ||
</success>, | ||
); | ||
}); | ||
test('component handshake', t => { | ||
test("component handshake", (t) => { | ||
t.deepEqual( | ||
@@ -48,4 +48,4 @@ hideSensitive(<handshake xmlns="jabber:component:accept">foo</handshake>), | ||
<hidden xmlns="xmpp.js" /> | ||
</handshake> | ||
) | ||
}) | ||
</handshake>, | ||
); | ||
}); |
7194
+ Added@xmpp/xml@0.12.1(transitive)
- Removed@xmpp/xml@0.11.0(transitive)
Updated@xmpp/xml@^0.12.0