Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.parser.addListener('startElement', function(name, attrs) {
// TODO: refuse anything but
if (!self.element && name == 'stream:stream') {
//console.log("StreamParser : emitting start");
//'start' event is captured by Connection (startParser)
self.emit('start', attrs);
} else {
var child;
if (!self.element) {
/* A new stanza */
child = new Stanza(name, attrs);
self.element = child;
self.bytesParsedOnStanzaBegin = self.bytesParsed;
} else {
/* A child element of a stanza */
child = new ltx.Element(name, attrs);
self.element = self.element.cnode(child);
}
}
});
resultQuery.c('identity', {'category': 'client', 'type': 'webinos'});
for (var i in currentFeatures) {
logger.trace('key found: ' + currentFeatures[i]);
var splitted = currentFeatures[i].split('#');
var id = splitted[splitted.length - 1];
logger.trace('Feature id found: ' + id);
if (id && this.sharedFeatures[id]) {
// a webinos feature
logger.trace('Feature found: ' + id);
var feature = this.sharedFeatures[id];
var instanceNode = new ltx.Element('instance', {'xmlns': 'webinos:rpc#disco', 'id': feature.id });
instanceNode.cnode(new ltx.Element('displayName').t(feature.displayName));
instanceNode.cnode(new ltx.Element('description').t(feature.description));
var featureNode = new ltx.Element('feature', {'var': feature.ns});
featureNode.cnode(instanceNode);
resultQuery.cnode(featureNode);
} else {
// an xmpp feature
var feature = currentFeatures[i];
var featureNode = new ltx.Element('feature', {'var': feature});
resultQuery.cnode(featureNode);
}
}
var result = new xmpp.Element('iq', { 'to': stanza.attrs.from, 'type': 'result', 'id': stanza.attrs.id });
result.cnode(resultQuery);
Publish.prototype.buildPublishedStanza = function (node, items) {
// send response to sender
var publishDetail = new ltx.Element('publish', {
node: node.name
});
publishDetail.children = items;
var detail = new ltx.Element(
'pubsub', {
'xmlns': 'http://jabber.org/protocol/pubsub'
}).cnode(publishDetail).up();
return detail;
};
// strip BOM; xml parser doesn't like it
if (xmlString.charCodeAt(0) === 0xFEFF) {
xmlString = xmlString.substr(1);
}
// parse sources xml
let xml: ltx.Element;
try {
xml = ltx.parse(xmlString);
} catch (e) {
throw new Error(tl.loc("NGCommon_NuGetConfigIsInvalid", configPath));
}
// give clearer errors if the user has set an invalid nuget.config
if(!xml.nameEquals(new ltx.Element("configuration"))) {
if(xml.nameEquals(new ltx.Element("packages"))) {
throw new Error(tl.loc(
"NGCommon_NuGetConfigIsPackagesConfig",
configPath,
tl.getVariable("Task.DisplayName")));
}
else {
throw new Error(tl.loc("NGCommon_NuGetConfigIsInvalid", configPath));
}
}
// check that the config contains packageSources entries
let hasSources = false;
let packageSources = xml.getChild("packageSources");
let addPackageSources: ltx.Element[];
if (packageSources) {
C2SStream.prototype.onRegistration = function(stanza) {
var self = this;
var register = stanza.getChild('query', NS_REGISTER);
var reply = new ltx.Element('iq', { type: 'result' });
if (stanza.attrs.id)
reply.attrs.id = stanza.attrs.id;
if (stanza.attrs.type === 'get') {
reply.c('query', { xmlns: NS_REGISTER }).
c("instructions").t("Choose a username and password for use with this service. ").up().
c("username").up().
c("password");
self.send(reply);
}
else if (stanza.attrs.type === 'set') {
var jid = new JID(register.getChildText('username'), this.server.options.domain_custom)
this.emit('register', { jid: jid,
username: register.getChildText('username'),
password: register.getChildText('password'),
client: self },
this.bindResource = function(res_name)
{
var resource = new ltx.Element("resource");
resource.t(res_name);
var bind = new ltx.Element("bind", {xmlns : NS_XMPP_BIND});
bind.cnode(resource);
var iq = new ltx.Element("iq", {id : "bind_1", type : "set", xmlns : NS_CLIENT});
iq.cnode(bind);
this.sendXml(iq);
}
this.sendMessage = function(to, mbody, type)
{
var message = new ltx.Element("message", {to : to, from : this.sess_attr.jid.toString(), type : type || "chat", "xml:lang" : "en"});
var body = new ltx.Element("body").t(mbody);
message.cnode(body);
this.send(message);
}
exports.$pres = function(attrib){
return new ltx.Element("presence", attrib);
}
function createDeleteAccountIQ() {
var removeEl = new ltx.Element('iq', { type: 'set' })
.c('query', { xmlns: 'jabber:iq:register' })
.c('remove')
return removeEl.root();
}
exports.dialbackResult = function(from, to, isValid) {
return new ltx.Element(
'db:result',
{
to: to,
from: from,
type: isValid ? 'valid' : 'invalid'
}
)
}