[Pkg-javascript-commits] [ltx] 46/469: client: use new Buffer base64 functionality in Node v0.1.102

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:00:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit 7b0c711a85c88fa05bd5b7e9c0e019fd8702184d
Author: Astro <astro at spaceboyz.net>
Date:   Wed Jul 28 00:29:53 2010 +0200

    client: use new Buffer base64 functionality in Node v0.1.102
    
    Should work best with http://github.com/astro/node/commit/1b5758512045a9506956d51c0cedc9317fa470e1
---
 lib/xmpp/client.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/xmpp/client.js b/lib/xmpp/client.js
index 782fb54..e34ebed 100644
--- a/lib/xmpp/client.js
+++ b/lib/xmpp/client.js
@@ -4,7 +4,7 @@ var xml = require('./xml');
 var sasl = require('./sasl');
 var sys = require('sys');
 var dns = require('dns');
-var b64 = require('base64');
+var Buffer = require('buffer').Buffer;
 
 var NS_CLIENT = 'jabber:client';
 var NS_XMPP_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl';
@@ -84,9 +84,9 @@ Client.prototype.onRawStanza = function(stanza) {
 	this.useFeatures();
     } else if (this.state == STATE_AUTH) {
 	if (stanza.is('challenge', NS_XMPP_SASL)) {
-	    var challengeMsg = b64.decode(stanza.getText());
+	    var challengeMsg = decode64(stanza.getText());
 	    sys.puts("challengeMsg: " + challengeMsg);
-	    var responseMsg = b64.encode(
+	    var responseMsg = encode64(
 				  this.mech.challenge(challengeMsg));
 	    this.send(new xml.Element('response',
 				      { xmlns: NS_XMPP_SASL
@@ -158,7 +158,7 @@ Client.prototype.useFeatures = function() {
 	    this.mech.password = this.password;
 	    this.mech.realm = this.jid.domain;  // anything?
 	    this.mech.digest_uri = "xmpp/" + this.jid.domain;
-	    var authMsg = b64.encode(this.mech.auth());
+	    var authMsg = encode64(this.mech.auth());
 	    this.send(new xml.Element('auth',
 				      { xmlns: NS_XMPP_SASL,
 					mechanism: this.mech.name
@@ -199,3 +199,9 @@ Client.prototype.useFeatures = function() {
     }
 };
 
+function decode64(encoded) {
+    return (new Buffer(encoded, 'base64')).toString('utf8');
+}
+function encode64(decoded) {
+    return (new Buffer(decoded, 'utf8')).toString('base64');
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list