]>
jfr.im git - irc/freenode/web-7.0.git/blob - static/files/cz_sasl.js
3 SASL plugin for ChatZilla.
5 ChatZilla is a clean, easy to use and highly extensible Internet Relay Chat (IRC) client.
6 Get it here: https://addons.mozilla.org/addon/16
8 How do I install scripts?
9 http://chatzilla.hacksrus.com/faq/#install-script
11 *****************************************************************************************
17 /plugin-pref cz_sasl sasl.username YOUR_USERNAME
18 /plugin-pref cz_sasl sasl.password YOUR_PASSWORD
19 /plugin-pref cz_sasl sasl.proceed_on_fail (true|false)
21 *****************************************************************************************
23 How to enable debug mode.
25 - Set ``browser.dom.window.dump.enabled'' to true in ``about:config''.
26 - Run ``/pref debugMode cdt'' in ChatZilla.
27 - Start ChatZilla from console, like ``seamonkey -chat'' or ``firefox.exe -chat -console''.
29 *****************************************************************************************
33 ~$ telnet irc.freenode.net 6667
35 Connected to chat.freenode.net.
36 Escape character is '^]'.
37 :barjavel.freenode.net NOTICE * :*** Looking up your hostname...
38 :barjavel.freenode.net NOTICE * :*** Checking Ident
39 :barjavel.freenode.net NOTICE * :*** Found your hostname
42 USER test test irc.freenode.net :test
43 :barjavel.freenode.net NOTICE * :*** No Ident response
44 :barjavel.freenode.net CAP * LS :identify-msg multi-prefix sasl
45 CAP REQ :multi-prefix sasl
46 :barjavel.freenode.net CAP test ACK :multi-prefix sasl
49 AUTHENTICATE R3...WYx <-- 'nick\0nick\0pass' encoded base64
50 :barjavel.freenode.net 900 test test!test@unaffiliated.test acnt :You are now logged in as Gryllida.
51 :barjavel.freenode.net 903 test :SASL authentication successful
56 *****************************************************************************************
58 (C) 2011 Gryllida A <Gryllida@gmail.com>
63 plugin
.id
= "cz_sasl";
67 function initPlugin(glob
){
70 plugin
.version
= plugin
.major
+ "." + plugin
.minor
;
71 plugin
.description
= "Adds sasl authentication support. To setup, |/plugin-pref cz_sasl|";
72 plugin
.prefary
= plugin
.prefary
.concat([
73 ["sasl.servername", "chat.freenode.net"],
76 ["sasl.proceed_on_fail",false]
78 display(plugin
.id
+ " loaded from url " + plugin
.url
);
83 function disablePlugin(status
){
84 display("disabling " + plugin
.id
);
85 client
.eventPump
.removeHookByName(plugin
.id
+"hook-cap");
86 client
.eventPump
.removeHookByName(plugin
.id
+"hook-connect");
87 return true; // Do NOT keep enabled without errors.
91 function enablePlugin(status
){
92 display("enabling " + plugin
.id
);
93 client
.eventPump
.addHook([{ set: /^(server|channel|user)$/, type: "parseddata" }], hook_cap
, plugin
.id
+"hook-cap");
94 client
.eventPump
.addHook([{ set: /^(server|channel|user)$/, type: "connect" }], hook_connect
, plugin
.id
+"hook-connect");
99 function hook_connect(e
){
100 if (e
.server
.hostname
==plugin
.prefs
["sasl.servername"] && e
.type
=="connect"){
101 e
.server
.sendData("CAP LS\n");
105 function hook_cap(e
){
106 if (e
.server
.hostname
==plugin
.prefs
["sasl.servername"]){
107 if (e
.params
[0]=="CAP" && e
.params
[2]=="LS"){
108 e
.server
.sendData("CAP REQ :sasl\n");
109 display("CAP REQ :multi-prefix sasl");
111 else if (e
.params
[3]=="sasl "){
112 e
.server
.sendData("AUTHENTICATE PLAIN\n");
113 display("AUTHENTICATE PLAIN");
115 else if (e
.data
== "AUTHENTICATE +"){
116 stuff
= window
.btoa(plugin
.prefs
["sasl.username"]+'\0'+plugin
.prefs
["sasl.username"]+'\0'+plugin
.prefs
["sasl.password"]);
117 e
.server
.sendData("AUTHENTICATE "+stuff
+"\n");
118 display("AUTHENTICATE "+stuff
);
120 else if (e
.params
[0]=="903"){
121 e
.server
.sendData("CAP END\n");
124 else if (e
.params
[0]=="904" || e
.params
[0]=="905"){
125 e
.server
.sendData("CAP END\n");
126 display("SASL authentication failed - invalid login or password. Please use the accountname (not a nick) as username, and try again.","warning");
127 if(plugin
.prefs
["sasl.proceed_on_fail"]==false){