Skip to content

Commit

Permalink
New release: v1.2.14
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Jun 17, 2017
1 parent 20ee591 commit 3368d45
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 49 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Strophe.js Change Log

## Version 1.2.14 - Unreleased
## Version 1.2.14 - 2017-06-15
* #231 SASL OAuth Bearer authentication should not require a JID node, when a user identifer
can be retreived from the bearer token.
* #250 Show XHR error message
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SRC_DIR = src
DOC_DIR = doc
DOC_TEMP = doc-temp
NDPROJ_DIR = ndproj
SED ?= sed

STROPHE = strophe.js
STROPHE_MIN = strophe.min.js
Expand All @@ -19,7 +20,7 @@ all: doc $(STROPHE) $(STROPHE_MIN)
help:
@echo "Please use \`make <target>' where <target> is one of the following:"
@echo ""
@echo " release Prepare a new release of strophe.js. E.g. `make release VERSION=1.2.13`"
@echo " release Prepare a new release of strophe.js. E.g. `make release VERSION=1.2.14`"
@echo " serve Serve this directory via a webserver on port 8000."
@echo " stamp-npm Install NPM dependencies and create the guard file stamp-npm which will prevent those dependencies from being installed again."

Expand All @@ -42,8 +43,8 @@ doc:

.PHONY: release
release:
sed -i 's/\"version\":\ \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\":\ \"$(VERSION)\"/' package.json
sed -i "s/Unreleased/`date +%Y-%m-%d`/" CHANGELOG.md
$(SED) -i 's/\"version\":\ \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\":\ \"$(VERSION)\"/' package.json
$(SED) -i "s/Unreleased/`date +%Y-%m-%d`/" CHANGELOG.md
make dist
make doc

Expand All @@ -52,15 +53,15 @@ dist: $(STROPHE) $(STROPHE_MIN) $(STROPHE_LIGHT)

$(STROPHE_MIN): src node_modules Makefile
$(RJS) -o build.js insertRequire=strophe-polyfill include=strophe-polyfill out=$(STROPHE_MIN)
sed -i s/@VERSION@/$(VERSION)/ $(STROPHE_MIN)
$(SED) -i s/@VERSION@/$(VERSION)/ $(STROPHE_MIN)

$(STROPHE): src node_modules Makefile
$(RJS) -o build.js optimize=none insertRequire=strophe-polyfill include=strophe-polyfill out=$(STROPHE)
sed -i s/@VERSION@/$(VERSION)/ $(STROPHE)
$(SED) -i s/@VERSION@/$(VERSION)/ $(STROPHE)

$(STROPHE_LIGHT): src node_modules Makefile
$(RJS) -o build.js optimize=none out=$(STROPHE_LIGHT)
sed -i s/@VERSION@/$(VERSION)/ $(STROPHE_LIGHT)
$(SED) -i s/@VERSION@/$(VERSION)/ $(STROPHE_LIGHT)

.PHONY: jshint
jshint: stamp-npm
Expand Down
24 changes: 11 additions & 13 deletions RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Release Checklist

- Make sure all tests pass (run 'make check')
- Decide on version number
- Update CHANGELOG.md
- Check for correct version number in package.json and bower,json
- Run "make release"
- Commit the newly generated files (mention it's a new release)
- Tag code with version (git tag -s vVERSION )
- Push repo and tags (git push && git push --tags)
- Publish on NPM: "npm publish"
- Add documentation to strophe.im repo
- Update links in index.markdown in Strophe.im
- Update link to documentation in README
- Tell the world
1. Make sure all tests pass (run 'make check')
2. Update CHANGELOG.md
3. Run "make release VERSION=1.2.14" (on Mac, prefix with "SED=gsed" so that
GNU-sed is used).
4. Commit the newly generated files (mention it's a new release)
5. Tag code with version (git tag -s vVERSION )
6. Push repo and tags (git push && git push --tags)
7. Publish on NPM: "npm publish"
8. Add documentation to strophe.im repo
9. Update links in index.markdown in Strophe.im
10. Update link to documentation in README
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "strophe.js",
"description": "Strophe.js is an XMPP library for JavaScript",
"version": "1.2.13",
"version": "1.2.14",
"homepage": "http://strophe.im/strophejs",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ Strophe.Connection.prototype = {
* Patches that handle websocket errors would be very welcome.
*
* Parameters:
* (String) protocol - 'HTTP' or 'websocket'
* (String) protocol - 'HTTP' or 'websocket'
* (Integer) status_code - Error status code (e.g 500, 400 or 404)
* (Function) callback - Function that will fire on Http error
*
Expand Down
33 changes: 25 additions & 8 deletions src/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,23 @@ Strophe.Websocket.prototype = {
//_connect_cb will check for stream:error and disconnect on error
this._connect_cb(streamStart);
}
} else if (message.data.indexOf("<close ") === 0) { //'<close xmlns="urn:ietf:params:xml:ns:xmpp-framing />') {
} else if (message.data.indexOf("<close ") === 0) { // <close xmlns="urn:ietf:params:xml:ns:xmpp-framing />
this._conn.rawInput(message.data);
this._conn.xmlInput(message);
var see_uri = message.getAttribute("see-other-uri");
if (see_uri) {
this._conn._changeConnectStatus(Strophe.Status.REDIRECT, "Received see-other-uri, resetting connection");
this._conn._changeConnectStatus(
Strophe.Status.REDIRECT,
"Received see-other-uri, resetting connection"
);
this._conn.reset();
this._conn.service = see_uri;
this._connect();
} else {
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "Received closing stream");
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL,
"Received closing stream"
);
this._conn._doDisconnect();
}
} else {
Expand Down Expand Up @@ -347,10 +353,15 @@ Strophe.Websocket.prototype = {
Strophe.error("Websocket closed unexpectedly");
this._conn._doDisconnect();
} else if (e && e.code === 1006 && !this._conn.connected && this.socket) {
// in case the onError callback was not called (Safari 10 does not call onerror when the initial connection fails)
// we need to dispatch a CONNFAIL status update to be consistent with the behavior on other browsers
// in case the onError callback was not called (Safari 10 does not
// call onerror when the initial connection fails) we need to
// dispatch a CONNFAIL status update to be consistent with the
// behavior on other browsers.
Strophe.error("Websocket closed unexcectedly");
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established or was disconnected.");
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL,
"The WebSocket connection could not be established or was disconnected."
);
this._conn._doDisconnect();
} else {
Strophe.info("Websocket closed");
Expand All @@ -364,7 +375,10 @@ Strophe.Websocket.prototype = {
*/
_no_auth_received: function (_callback) {
Strophe.error("Server did not send any auth methods");
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "Server did not send any auth methods");
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL,
"Server did not send any auth methods"
);
if (_callback) {
_callback = _callback.bind(this._conn);
_callback();
Expand Down Expand Up @@ -392,7 +406,10 @@ Strophe.Websocket.prototype = {
*/
_onError: function(error) {
Strophe.error("Websocket error " + error);
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established or was disconnected.");
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL,
"The WebSocket connection could not be established or was disconnected."
);
this._disconnect();
},

Expand Down
67 changes: 50 additions & 17 deletions strophe.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ var requirejs, require, define;
};
}());

define("bower_components/almond/almond.js", function(){});
define("node_modules/almond/almond.js", function(){});

/*
This program is distributed under the terms of the MIT license.
Expand Down Expand Up @@ -1277,7 +1277,7 @@ function $pres(attrs) { return new Strophe.Builder("presence", attrs); }
*/
Strophe = {
/** Constant: VERSION */
VERSION: "1.2.13",
VERSION: "1.2.14",

/** Constants: XMPP Namespace Constants
* Common namespace constants from the XMPP RFCs and XEPs.
Expand Down Expand Up @@ -1398,6 +1398,7 @@ Strophe = {
* Status.DISCONNECTED - The connection has been terminated
* Status.DISCONNECTING - The connection is currently being terminated
* Status.ATTACHED - The connection has been attached
* Status.REDIRECT - The connection has been redirected
* Status.CONNTIMEOUT - The connection has timed out
*/
Status: {
Expand Down Expand Up @@ -2932,7 +2933,7 @@ Strophe.Connection.prototype = {
* Patches that handle websocket errors would be very welcome.
*
* Parameters:
* (String) protocol - 'HTTP' or 'websocket'
* (String) protocol - 'HTTP' or 'websocket'
* (Integer) status_code - Error status code (e.g 500, 400 or 404)
* (Function) callback - Function that will fire on Http error
*
Expand Down Expand Up @@ -2968,8 +2969,9 @@ Strophe.Connection.prototype = {
*
* Parameters:
* (String) jid - The user's JID. This may be a bare JID,
* or a full JID. If a node is not supplied, SASL ANONYMOUS
* authentication will be attempted.
* or a full JID. If a node is not supplied, SASL OAUTHBEARER or
* SASL ANONYMOUS authentication will be attempted (OAUTHBEARER will
* process the provided password value as an access token).
* (String) pass - The user's password.
* (Function) callback - The connect callback function.
* (Integer) wait - The optional HTTPBIND wait value. This is the
Expand Down Expand Up @@ -4769,18 +4771,21 @@ Strophe.SASLOAuthBearer = function() {};
Strophe.SASLOAuthBearer.prototype = new Strophe.SASLMechanism("OAUTHBEARER", true, 60);

Strophe.SASLOAuthBearer.prototype.test = function(connection) {
return connection.authcid !== null;
return connection.pass !== null;
};

Strophe.SASLOAuthBearer.prototype.onChallenge = function(connection) {
var auth_str = 'n,a=';
auth_str = auth_str + connection.authzid;
var auth_str = 'n,';
if (connection.authcid !== null) {
auth_str = auth_str + 'a=' + connection.authzid;
}
auth_str = auth_str + ',';
auth_str = auth_str + "\u0001";
auth_str = auth_str + 'auth=Bearer ';
auth_str = auth_str + connection.pass;
auth_str = auth_str + "\u0001";
auth_str = auth_str + "\u0001";

return utils.utf16to8(auth_str);
};

Expand Down Expand Up @@ -5460,7 +5465,9 @@ Strophe.Bosh.prototype = {
return;
}

if ((reqStatus > 0 && reqStatus < 500) || req.sends > 5) {
var valid_request = reqStatus > 0 && reqStatus < 500;
var too_many_retries = req.sends > this._conn.maxRetries;
if (valid_request || too_many_retries) {
// remove from internal queue
this._removeRequest(req);
Strophe.debug("request id "+req.id+" should now be removed");
Expand Down Expand Up @@ -5497,8 +5504,11 @@ Strophe.Bosh.prototype = {
} else {
Strophe.error("request id "+req.id+"."+req.sends+" error "+reqStatus+" happened");
}
if (!(reqStatus > 0 && reqStatus < 500) || req.sends > 5) {

if (!valid_request && !too_many_retries) {
this._throttledRequestHandler();
} else if (too_many_retries && !this._conn.connected) {
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "giving-up");
}
},

Expand Down Expand Up @@ -5560,7 +5570,7 @@ Strophe.Bosh.prototype = {
req.xhr.withCredentials = true;
}
} catch (e2) {
Strophe.error("XHR open failed.");
Strophe.error("XHR open failed: " + e2.toString());
if (!this._conn.connected) {
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL, "bad-service");
Expand Down Expand Up @@ -6006,17 +6016,23 @@ Strophe.Websocket.prototype = {
//_connect_cb will check for stream:error and disconnect on error
this._connect_cb(streamStart);
}
} else if (message.data.indexOf("<close ") === 0) { //'<close xmlns="urn:ietf:params:xml:ns:xmpp-framing />') {
} else if (message.data.indexOf("<close ") === 0) { // <close xmlns="urn:ietf:params:xml:ns:xmpp-framing />
this._conn.rawInput(message.data);
this._conn.xmlInput(message);
var see_uri = message.getAttribute("see-other-uri");
if (see_uri) {
this._conn._changeConnectStatus(Strophe.Status.REDIRECT, "Received see-other-uri, resetting connection");
this._conn._changeConnectStatus(
Strophe.Status.REDIRECT,
"Received see-other-uri, resetting connection"
);
this._conn.reset();
this._conn.service = see_uri;
this._connect();
} else {
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "Received closing stream");
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL,
"Received closing stream"
);
this._conn._doDisconnect();
}
} else {
Expand Down Expand Up @@ -6099,10 +6115,21 @@ Strophe.Websocket.prototype = {
*
* Nothing to do here for WebSockets
*/
_onClose: function() {
_onClose: function(e) {
if(this._conn.connected && !this._conn.disconnecting) {
Strophe.error("Websocket closed unexpectedly");
this._conn._doDisconnect();
} else if (e && e.code === 1006 && !this._conn.connected && this.socket) {
// in case the onError callback was not called (Safari 10 does not
// call onerror when the initial connection fails) we need to
// dispatch a CONNFAIL status update to be consistent with the
// behavior on other browsers.
Strophe.error("Websocket closed unexcectedly");
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL,
"The WebSocket connection could not be established or was disconnected."
);
this._conn._doDisconnect();
} else {
Strophe.info("Websocket closed");
}
Expand All @@ -6115,7 +6142,10 @@ Strophe.Websocket.prototype = {
*/
_no_auth_received: function (_callback) {
Strophe.error("Server did not send any auth methods");
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "Server did not send any auth methods");
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL,
"Server did not send any auth methods"
);
if (_callback) {
_callback = _callback.bind(this._conn);
_callback();
Expand Down Expand Up @@ -6143,7 +6173,10 @@ Strophe.Websocket.prototype = {
*/
_onError: function(error) {
Strophe.error("Websocket error " + error);
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established or was disconnected.");
this._conn._changeConnectStatus(
Strophe.Status.CONNFAIL,
"The WebSocket connection could not be established or was disconnected."
);
this._disconnect();
},

Expand Down
4 changes: 2 additions & 2 deletions strophe.min.js

Large diffs are not rendered by default.

0 comments on commit 3368d45

Please sign in to comment.