comparison plugins/PLAIN.js @ 108:5cb4733c5189

many api changes
author Sonny Piers <sonny@fastmail.net>
date Fri, 13 Jul 2012 15:26:18 +0200
parents c06ec02217ee
children
comparison
equal deleted inserted replaced
107:704ce44c1a22 108:5cb4733c5189
31 'mechanisms': function (stanza) { 31 'mechanisms': function (stanza) {
32 if(stanza.mechanisms.indexOf('PLAIN') === -1) 32 if(stanza.mechanisms.indexOf('PLAIN') === -1)
33 return; 33 return;
34 34
35 var token = btoa( 35 var token = btoa(
36 this.jid + 36 this.jid.bare +
37 '\u0000' + 37 '\u0000' +
38 this.jid.node + 38 this.jid.local +
39 '\u0000' + 39 '\u0000' +
40 this.password 40 this.password
41 ); 41 );
42
42 this.send( 43 this.send(
43 "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'" + 44 "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'" +
44 " mechanism='PLAIN'>" + token + "</auth>" 45 " mechanism='PLAIN'>" + token + "</auth>"
45 ); 46 );
46 }, 47 },
54 }, 55 },
55 'features': function (stanza) { 56 'features': function (stanza) {
56 var Conn = this; 57 var Conn = this;
57 //TODO check if bind supported 58 //TODO check if bind supported
58 var bind = 59 var bind =
59 "<iq type='set' id='"+Lightstring.newId('sendiq:')+"'>" + 60 "<iq type='set' id='" + Lightstring.id() + "'>" +
60 "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>" + 61 "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>" +
61 (this.jid.resource? "<resource>" + this.jid.resource + "</resource>": "") + 62 (this.jid.resource? "<resource>" + this.jid.resource + "</resource>": "") +
62 "</bind>" + 63 "</bind>" +
63 "</iq>"; 64 "</iq>";
64 this.send( 65 this.send(
66 //Success 67 //Success
67 function(stanza) { 68 function(stanza) {
68 //Session http://xmpp.org/rfcs/rfc3921.html#session 69 //Session http://xmpp.org/rfcs/rfc3921.html#session
69 Conn.jid = new Lightstring.JID(stanza.el.textContent); 70 Conn.jid = new Lightstring.JID(stanza.el.textContent);
70 Conn.send( 71 Conn.send(
71 "<iq type='set' id='"+Lightstring.newId('sendiq:')+"'>" + 72 "<iq type='set' id='" + Lightstring.id() + "'>" +
72 "<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>" + 73 "<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>" +
73 "</iq>", 74 "</iq>",
74 function() { 75 function() {
75 Conn.emit('connected'); 76 Conn.emit('connected');
76 } 77 }