Comparing version 1.0.12 to 1.0.13
@@ -410,4 +410,4 @@ /* | ||
Connection.prototype.sasl_failed = function (text) { | ||
this.transport_error = new errors.ConnectionError(text, 'amqp:unauthorized-access', this); | ||
Connection.prototype.sasl_failed = function (text, condition) { | ||
this.transport_error = new errors.ConnectionError(text, condition ? condition : 'amqp:unauthorized-access', this); | ||
this._handle_error(); | ||
@@ -414,0 +414,0 @@ this.socket.end(); |
@@ -62,8 +62,12 @@ /* | ||
} | ||
if (this.callback(fields[1], fields[2], hostname)) { | ||
this.outcome = true; | ||
this.username = fields[1]; | ||
} else { | ||
this.outcome = false; | ||
} | ||
var self = this; | ||
return Promise.resolve(this.callback(fields[1], fields[2], hostname)) | ||
.then(function (result) { | ||
if (result) { | ||
self.outcome = true; | ||
self.username = fields[1]; | ||
} else { | ||
self.outcome = false; | ||
} | ||
}); | ||
}; | ||
@@ -171,5 +175,8 @@ | ||
this.transport.encode(frames.sasl_frame(frames.sasl_challenge({'challenge':challenge}))); | ||
this.connection.output(); | ||
} else { | ||
this.outcome = this.mechanism.outcome ? sasl_codes.OK : sasl_codes.AUTH; | ||
this.transport.encode(frames.sasl_frame(frames.sasl_outcome({code: this.outcome}))); | ||
var frame = frames.sasl_frame(frames.sasl_outcome({code: this.outcome})); | ||
this.transport.encode(frame); | ||
this.connection.output(); | ||
if (this.outcome === sasl_codes.OK) { | ||
@@ -184,7 +191,8 @@ this.username = this.mechanism.username; | ||
SaslServer.prototype.on_sasl_init = function (frame) { | ||
var f = this.mechanisms[frame.performative.mechanism]; | ||
if (f) { | ||
this.mechanism = f(); | ||
var challenge = this.mechanism.start(frame.performative.initial_response, frame.performative.hostname); | ||
this.do_step(challenge); | ||
var saslctor = this.mechanisms[frame.performative.mechanism]; | ||
if (saslctor) { | ||
this.mechanism = saslctor(); | ||
Promise.resolve(this.mechanism.start(frame.performative.initial_response, frame.performative.hostname)) | ||
.then(this.do_step.bind(this)) | ||
.catch(this.do_fail.bind(this)); | ||
} else { | ||
@@ -195,6 +203,16 @@ this.outcome = sasl_codes.AUTH; | ||
}; | ||
SaslServer.prototype.on_sasl_response = function (frame) { | ||
this.do_step(this.mechanism.step(frame.performative.response)); | ||
Promise.resolve(this.mechanism.step(frame.performative.response)) | ||
.then(this.do_step.bind(this)) | ||
.catch(this.do_fail.bind(this)); | ||
}; | ||
SaslServer.prototype.do_fail = function (e) { | ||
var frame = frames.sasl_frame(frames.sasl_outcome({code: sasl_codes.SYS})); | ||
this.transport.encode(frame); | ||
this.connection.output(); | ||
this.connection.sasl_failed('Sasl callback promise failed' + e, 'amqp:internal-error'); | ||
}; | ||
SaslServer.prototype.has_writes_pending = function () { | ||
@@ -284,2 +302,8 @@ return this.transport.has_writes_pending() || this.next.has_writes_pending(); | ||
break; | ||
case sasl_codes.SYS: | ||
case sasl_codes.SYS_PERM: | ||
case sasl_codes.SYS_TEMP: | ||
this.transport.write_complete = true; | ||
this.connection.sasl_failed('Failed to authenticate: ' + frame.performative.code, 'amqp:internal-error'); | ||
break; | ||
default: | ||
@@ -286,0 +310,0 @@ this.transport.write_complete = true; |
{ | ||
"name": "rhea", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "reactive AMQP 1.0 library", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/amqp/rhea", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
889174
14079