Skip to content

Commit

Permalink
Regenerate and release version 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonWoolf committed Apr 7, 2017
1 parent 2c36823 commit 4c6c8e1
Show file tree
Hide file tree
Showing 13 changed files with 699 additions and 711 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Javascript client library for [Ably Realtime](https://www.ably.io), a realtime data delivery platform.

## Version: 1.0.2
## Version: 1.0.3

This repo contains the Ably Javascript client library, for the browser (including IE8+), Nodejs, React Native, NativeScript and Cordova.

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Ably",
"version": "1.0.2",
"version": "1.0.3",
"homepage": "https://www.ably.io/",
"authors": [
"Paddy Byers <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion browser/fragments/license.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Copyright 2017, Ably
*
* Ably JavaScript Library v1.0.2
* Ably JavaScript Library v1.0.3
* https://github.com/ably/ably-js
*
* Ably Realtime Messaging
Expand Down
62 changes: 30 additions & 32 deletions browser/static/ably-commonjs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Copyright 2017, Ably
*
* Ably JavaScript Library v1.0.2
* Ably JavaScript Library v1.0.3
* https://github.com/ably/ably-js
*
* Ably Realtime Messaging
Expand Down Expand Up @@ -3137,6 +3137,7 @@ var Platform = {
binaryType: 'arraybuffer',
WebSocket: window.WebSocket || window.MozWebSocket,
xhrSupported: (window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()),
streamingSupported: true,
useProtocolHeartbeats: true,
createHmac: null,
msgpack: msgpack,
Expand Down Expand Up @@ -4078,7 +4079,7 @@ Defaults.TIMEOUTS = {
};
Defaults.httpMaxRetryCount = 3;

Defaults.version = '1.0.2';
Defaults.version = '1.0.3';
Defaults.libstring = Platform.libver + Defaults.version;
Defaults.apiVersion = '1.0';

Expand Down Expand Up @@ -6342,8 +6343,12 @@ var ConnectionManager = (function() {
* on a new connection, with implications for msgSerial and channel state */
var self = this;
connectionSerial = (connectionSerial === undefined) ? -1 : connectionSerial;
if(this.connectionId && this.connectionId !== connectionId) {
Logger.logAction(Logger.LOG_MINOR, 'ConnectionManager.setConnection()', 'connectionId has changed; resetting msgSerial and reattaching channels');
/* Note that this is also run on clean connections; the msgSerial is a
* noop, but the channel reattach is needed for channels that were
* previously in the attached state even though the connection mode was
* 'clean' due to a freshness check - see https://github.com/ably/ably-js/issues/394 */
if(this.connectionId !== connectionId) {
Logger.logAction(Logger.LOG_MINOR, 'ConnectionManager.setConnection()', 'New connectionId; resetting msgSerial and reattaching any attached channels');
this.msgSerial = 0;
/* Wait till next tick before reattaching channels, so that connection
* state will be updated and so that it will be applied after
Expand Down Expand Up @@ -6375,12 +6380,14 @@ var ConnectionManager = (function() {
};

ConnectionManager.prototype.checkConnectionStateFreshness = function() {
if(!this.lastActivity) { return; }
if(!this.lastActivity || !this.connectionId) { return; }

var sinceLast = Utils.now() - this.lastActivity;
if(sinceLast > this.connectionStateTtl + this.maxIdleInterval) {
Logger.logAction(Logger.LOG_MINOR, 'ConnectionManager.checkConnectionStateFreshness()', 'Last known activity from realtime was ' + sinceLast + 'ms ago; discarding connection state');
this.clearConnection();
this.states.connecting.failState = 'suspended';
this.states.connecting.queueEvents = false;
}
};

Expand Down Expand Up @@ -8634,22 +8641,14 @@ var Auth = (function() {

var client = this.client;
var tokenRequest = function(signedTokenParams, tokenCb) {
var requestHeaders,
keyName = signedTokenParams.keyName,
tokenUri = function(host) { return client.baseUri(host) + '/keys/' + keyName + '/requestToken';};

if(Http.post) {
requestHeaders = Utils.defaultPostHeaders(format);
if(authOptions.requestHeaders) Utils.mixin(requestHeaders, authOptions.requestHeaders);
Logger.logAction(Logger.LOG_MICRO, 'Auth.requestToken().requestToken', 'Sending POST; ' + tokenUri + '; Token params: ' + JSON.stringify(signedTokenParams));
signedTokenParams = (format == 'msgpack') ? msgpack.encode(signedTokenParams, true): JSON.stringify(signedTokenParams);
Http.post(client, tokenUri, requestHeaders, signedTokenParams, null, tokenCb);
} else {
requestHeaders = Utils.defaultGetHeaders();
if(authOptions.requestHeaders) Utils.mixin(requestHeaders, authOptions.requestHeaders);
Logger.logAction(Logger.LOG_MICRO, 'Auth.requestToken().requestToken', 'Sending GET; ' + tokenUri + '; Token params: ' + JSON.stringify(signedTokenParams));
Http.get(client, tokenUri, requestHeaders, signedTokenParams, tokenCb);
}
var keyName = signedTokenParams.keyName,
tokenUri = function(host) { return client.baseUri(host) + '/keys/' + keyName + '/requestToken'; };

var requestHeaders = Utils.defaultPostHeaders(format);
if(authOptions.requestHeaders) Utils.mixin(requestHeaders, authOptions.requestHeaders);
Logger.logAction(Logger.LOG_MICRO, 'Auth.requestToken().requestToken', 'Sending POST; ' + tokenUri + '; Token params: ' + JSON.stringify(signedTokenParams));
signedTokenParams = (format == 'msgpack') ? msgpack.encode(signedTokenParams, true) : JSON.stringify(signedTokenParams);
Http.post(client, tokenUri, requestHeaders, signedTokenParams, null, tokenCb);
};

var tokenRequestCallbackTimeoutExpired = false,
Expand Down Expand Up @@ -10712,11 +10711,7 @@ var XHRRequest = (function() {
pendingRequests[id].dispose();
}

var xhrSupported = Platform.xhrSupported;
var isIE = typeof window !== 'undefined' && window.XDomainRequest;
function isAvailable() {
return xhrSupported;
};

function ieVersion() {
var match = navigator.userAgent.toString().match(/MSIE\s([\d.]+)/);
Expand Down Expand Up @@ -10768,7 +10763,6 @@ var XHRRequest = (function() {
pendingRequests[this.id = String(++idCounter)] = this;
}
Utils.inherits(XHRRequest, EventEmitter);
XHRRequest.isAvailable = isAvailable;

var createRequest = XHRRequest.createRequest = function(uri, headers, params, body, requestMode, timeouts) {
/* XHR requests are used either with the context being a realtime
Expand Down Expand Up @@ -10814,7 +10808,7 @@ var XHRRequest = (function() {

if(body) {
var contentType = headers['content-type'] || (headers['content-type'] = 'application/json');
if(contentType == 'application/json' && typeof(body) != 'string')
if(contentType.indexOf('application/json') > -1 && typeof(body) != 'string')
body = JSON.stringify(body);
}

Expand Down Expand Up @@ -10871,7 +10865,7 @@ var XHRRequest = (function() {
var contentType = getHeader(xhr, 'content-type'),
headers,
server,
json = contentType ? (contentType == 'application/json') : (xhr.responseType == 'text');
json = contentType ? (contentType.indexOf('application/json') >= 0) : (xhr.responseType == 'text');

responseBody = json ? xhr.responseText : xhr.response;

Expand Down Expand Up @@ -10980,12 +10974,12 @@ var XHRRequest = (function() {
delete pendingRequests[this.id];
};

if(isAvailable()) {
if(Platform.xhrSupported) {
if(typeof DomEvent === 'object') {
DomEvent.addUnloadListener(clearPendingRequests);
}
if(typeof(Http) !== 'undefined') {
Http.supportsAuthHeaders = xhrSupported;
Http.supportsAuthHeaders = true;
Http.Request = function(rest, uri, headers, params, body, callback) {
var req = createRequest(uri, headers, params, body, REQ_SEND, rest && rest.options.timeouts);
req.once('complete', callback);
Expand Down Expand Up @@ -11018,7 +11012,9 @@ var XHRStreamingTransport = (function() {
}
Utils.inherits(XHRStreamingTransport, CometTransport);

XHRStreamingTransport.isAvailable = XHRRequest.isAvailable;
XHRStreamingTransport.isAvailable = function() {
return Platform.xhrSupported && Platform.streamingSupported;
};

XHRStreamingTransport.tryConnect = function(connectionManager, auth, params, callback) {
var transport = new XHRStreamingTransport(connectionManager, auth, params);
Expand Down Expand Up @@ -11055,7 +11051,9 @@ var XHRPollingTransport = (function() {
}
Utils.inherits(XHRPollingTransport, CometTransport);

XHRPollingTransport.isAvailable = XHRRequest.isAvailable;
XHRPollingTransport.isAvailable = function() {
return Platform.xhrSupported;
};

XHRPollingTransport.tryConnect = function(connectionManager, auth, params, callback) {
var transport = new XHRPollingTransport(connectionManager, auth, params);
Expand Down
62 changes: 30 additions & 32 deletions browser/static/ably-commonjs.noencryption.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Copyright 2017, Ably
*
* Ably JavaScript Library v1.0.2
* Ably JavaScript Library v1.0.3
* https://github.com/ably/ably-js
*
* Ably Realtime Messaging
Expand Down Expand Up @@ -2014,6 +2014,7 @@ var Platform = {
binaryType: 'arraybuffer',
WebSocket: window.WebSocket || window.MozWebSocket,
xhrSupported: (window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()),
streamingSupported: true,
useProtocolHeartbeats: true,
createHmac: null,
msgpack: msgpack,
Expand Down Expand Up @@ -2646,7 +2647,7 @@ Defaults.TIMEOUTS = {
};
Defaults.httpMaxRetryCount = 3;

Defaults.version = '1.0.2';
Defaults.version = '1.0.3';
Defaults.libstring = Platform.libver + Defaults.version;
Defaults.apiVersion = '1.0';

Expand Down Expand Up @@ -4910,8 +4911,12 @@ var ConnectionManager = (function() {
* on a new connection, with implications for msgSerial and channel state */
var self = this;
connectionSerial = (connectionSerial === undefined) ? -1 : connectionSerial;
if(this.connectionId && this.connectionId !== connectionId) {
Logger.logAction(Logger.LOG_MINOR, 'ConnectionManager.setConnection()', 'connectionId has changed; resetting msgSerial and reattaching channels');
/* Note that this is also run on clean connections; the msgSerial is a
* noop, but the channel reattach is needed for channels that were
* previously in the attached state even though the connection mode was
* 'clean' due to a freshness check - see https://github.com/ably/ably-js/issues/394 */
if(this.connectionId !== connectionId) {
Logger.logAction(Logger.LOG_MINOR, 'ConnectionManager.setConnection()', 'New connectionId; resetting msgSerial and reattaching any attached channels');
this.msgSerial = 0;
/* Wait till next tick before reattaching channels, so that connection
* state will be updated and so that it will be applied after
Expand Down Expand Up @@ -4943,12 +4948,14 @@ var ConnectionManager = (function() {
};

ConnectionManager.prototype.checkConnectionStateFreshness = function() {
if(!this.lastActivity) { return; }
if(!this.lastActivity || !this.connectionId) { return; }

var sinceLast = Utils.now() - this.lastActivity;
if(sinceLast > this.connectionStateTtl + this.maxIdleInterval) {
Logger.logAction(Logger.LOG_MINOR, 'ConnectionManager.checkConnectionStateFreshness()', 'Last known activity from realtime was ' + sinceLast + 'ms ago; discarding connection state');
this.clearConnection();
this.states.connecting.failState = 'suspended';
this.states.connecting.queueEvents = false;
}
};

Expand Down Expand Up @@ -7202,22 +7209,14 @@ var Auth = (function() {

var client = this.client;
var tokenRequest = function(signedTokenParams, tokenCb) {
var requestHeaders,
keyName = signedTokenParams.keyName,
tokenUri = function(host) { return client.baseUri(host) + '/keys/' + keyName + '/requestToken';};

if(Http.post) {
requestHeaders = Utils.defaultPostHeaders(format);
if(authOptions.requestHeaders) Utils.mixin(requestHeaders, authOptions.requestHeaders);
Logger.logAction(Logger.LOG_MICRO, 'Auth.requestToken().requestToken', 'Sending POST; ' + tokenUri + '; Token params: ' + JSON.stringify(signedTokenParams));
signedTokenParams = (format == 'msgpack') ? msgpack.encode(signedTokenParams, true): JSON.stringify(signedTokenParams);
Http.post(client, tokenUri, requestHeaders, signedTokenParams, null, tokenCb);
} else {
requestHeaders = Utils.defaultGetHeaders();
if(authOptions.requestHeaders) Utils.mixin(requestHeaders, authOptions.requestHeaders);
Logger.logAction(Logger.LOG_MICRO, 'Auth.requestToken().requestToken', 'Sending GET; ' + tokenUri + '; Token params: ' + JSON.stringify(signedTokenParams));
Http.get(client, tokenUri, requestHeaders, signedTokenParams, tokenCb);
}
var keyName = signedTokenParams.keyName,
tokenUri = function(host) { return client.baseUri(host) + '/keys/' + keyName + '/requestToken'; };

var requestHeaders = Utils.defaultPostHeaders(format);
if(authOptions.requestHeaders) Utils.mixin(requestHeaders, authOptions.requestHeaders);
Logger.logAction(Logger.LOG_MICRO, 'Auth.requestToken().requestToken', 'Sending POST; ' + tokenUri + '; Token params: ' + JSON.stringify(signedTokenParams));
signedTokenParams = (format == 'msgpack') ? msgpack.encode(signedTokenParams, true) : JSON.stringify(signedTokenParams);
Http.post(client, tokenUri, requestHeaders, signedTokenParams, null, tokenCb);
};

var tokenRequestCallbackTimeoutExpired = false,
Expand Down Expand Up @@ -9280,11 +9279,7 @@ var XHRRequest = (function() {
pendingRequests[id].dispose();
}

var xhrSupported = Platform.xhrSupported;
var isIE = typeof window !== 'undefined' && window.XDomainRequest;
function isAvailable() {
return xhrSupported;
};

function ieVersion() {
var match = navigator.userAgent.toString().match(/MSIE\s([\d.]+)/);
Expand Down Expand Up @@ -9336,7 +9331,6 @@ var XHRRequest = (function() {
pendingRequests[this.id = String(++idCounter)] = this;
}
Utils.inherits(XHRRequest, EventEmitter);
XHRRequest.isAvailable = isAvailable;

var createRequest = XHRRequest.createRequest = function(uri, headers, params, body, requestMode, timeouts) {
/* XHR requests are used either with the context being a realtime
Expand Down Expand Up @@ -9382,7 +9376,7 @@ var XHRRequest = (function() {

if(body) {
var contentType = headers['content-type'] || (headers['content-type'] = 'application/json');
if(contentType == 'application/json' && typeof(body) != 'string')
if(contentType.indexOf('application/json') > -1 && typeof(body) != 'string')
body = JSON.stringify(body);
}

Expand Down Expand Up @@ -9439,7 +9433,7 @@ var XHRRequest = (function() {
var contentType = getHeader(xhr, 'content-type'),
headers,
server,
json = contentType ? (contentType == 'application/json') : (xhr.responseType == 'text');
json = contentType ? (contentType.indexOf('application/json') >= 0) : (xhr.responseType == 'text');

responseBody = json ? xhr.responseText : xhr.response;

Expand Down Expand Up @@ -9548,12 +9542,12 @@ var XHRRequest = (function() {
delete pendingRequests[this.id];
};

if(isAvailable()) {
if(Platform.xhrSupported) {
if(typeof DomEvent === 'object') {
DomEvent.addUnloadListener(clearPendingRequests);
}
if(typeof(Http) !== 'undefined') {
Http.supportsAuthHeaders = xhrSupported;
Http.supportsAuthHeaders = true;
Http.Request = function(rest, uri, headers, params, body, callback) {
var req = createRequest(uri, headers, params, body, REQ_SEND, rest && rest.options.timeouts);
req.once('complete', callback);
Expand Down Expand Up @@ -9586,7 +9580,9 @@ var XHRStreamingTransport = (function() {
}
Utils.inherits(XHRStreamingTransport, CometTransport);

XHRStreamingTransport.isAvailable = XHRRequest.isAvailable;
XHRStreamingTransport.isAvailable = function() {
return Platform.xhrSupported && Platform.streamingSupported;
};

XHRStreamingTransport.tryConnect = function(connectionManager, auth, params, callback) {
var transport = new XHRStreamingTransport(connectionManager, auth, params);
Expand Down Expand Up @@ -9623,7 +9619,9 @@ var XHRPollingTransport = (function() {
}
Utils.inherits(XHRPollingTransport, CometTransport);

XHRPollingTransport.isAvailable = XHRRequest.isAvailable;
XHRPollingTransport.isAvailable = function() {
return Platform.xhrSupported;
};

XHRPollingTransport.tryConnect = function(connectionManager, auth, params, callback) {
var transport = new XHRPollingTransport(connectionManager, auth, params);
Expand Down
Loading

0 comments on commit 4c6c8e1

Please sign in to comment.