twilio_ip_messaging_rails 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 740d483f4f6580f8cd1b020da395786a68622d44
4
- data.tar.gz: 87a9178bfe4c63031b9517d2a566c6a6ff2fe00c
3
+ metadata.gz: 13788832cada6ff937afd3c276c2e6d9bd986506
4
+ data.tar.gz: 1251dfdb23e260d82336d5f4f9790407704eafc0
5
5
  SHA512:
6
- metadata.gz: 6b7eb84c8926eedfa0690e063d676ec2e77d6dc27220004628ccd1b8039c460ebe50667c60bc73e114305fe043dd13c1a9522252c29e1e336743cce45d56a0d9
7
- data.tar.gz: 1158ea231ed747f1344837c098a99d52a36de0a8e9a9d2540d1451e011adbbe67c19033622e46efc4af08465c6f4379c44b8c128ea52ea47ca874e5e26e600b3
6
+ metadata.gz: 939ae414251b699b7d98a1e85b198fd39ad7f41337b1b6f0fc023f8f81497299cacd475e6147371c4aa368f46d563b02540c6003822b9b9e63a577caa3835c32
7
+ data.tar.gz: 5d152b179792a704b8c24c6f7861b76e21775c7a935a6b333c9c4ce07dc67c43ed0409a99691d947ebedf88313b3d67a636c834b3919650029489a58802abbd8
@@ -1,4 +1,4 @@
1
- /* twilio-ip-messaging.js 0.10.3
1
+ /* twilio-ip-messaging.js 0.10.4
2
2
  The following license applies to all parts of this software except as
3
3
  documented below.
4
4
 
@@ -3243,9 +3243,10 @@ Client.prototype._updateToken = function _updateToken(token) {
3243
3243
  this._token = token;
3244
3244
  log.info('IPMSG I: authTokenUpdated');
3245
3245
 
3246
- return _promise2.default.all([this._twilsock.setAuthToken(token), this._notification.setAuthToken(token), this._datasync.setAuthToken(token), this._sessionPromise.then(function () {
3246
+ this._datasync.setAuthToken(token);
3247
+ return this._sessionPromise.then(function () {
3247
3248
  return _this4._session.updateToken(token);
3248
- })]).then(function () {
3249
+ }).then(function () {
3249
3250
  return _this4;
3250
3251
  });
3251
3252
  };
@@ -6161,11 +6162,11 @@ module.exports = { "default": _dereq_("core-js/library/fn/symbol/iterator"), __e
6161
6162
 
6162
6163
  exports.__esModule = true;
6163
6164
 
6164
- var _iterator = _dereq_("babel-runtime/core-js/symbol/iterator");
6165
+ var _iterator = _dereq_("../core-js/symbol/iterator");
6165
6166
 
6166
6167
  var _iterator2 = _interopRequireDefault(_iterator);
6167
6168
 
6168
- var _symbol = _dereq_("babel-runtime/core-js/symbol");
6169
+ var _symbol = _dereq_("../core-js/symbol");
6169
6170
 
6170
6171
  var _symbol2 = _interopRequireDefault(_symbol);
6171
6172
 
@@ -6178,7 +6179,7 @@ exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.d
6178
6179
  } : function (obj) {
6179
6180
  return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
6180
6181
  };
6181
- },{"babel-runtime/core-js/symbol":38,"babel-runtime/core-js/symbol/iterator":39}],41:[function(_dereq_,module,exports){
6182
+ },{"../core-js/symbol":38,"../core-js/symbol/iterator":39}],41:[function(_dereq_,module,exports){
6182
6183
  _dereq_('../modules/web.dom.iterable');
6183
6184
  _dereq_('../modules/es6.string.iterator');
6184
6185
  module.exports = _dereq_('../modules/core.get-iterator');
@@ -6594,7 +6595,7 @@ module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
6594
6595
  return C;
6595
6596
  };
6596
6597
  },{"./_an-instance":53,"./_array-methods":57,"./_descriptors":68,"./_export":72,"./_fails":73,"./_for-of":74,"./_global":75,"./_hide":77,"./_is-object":84,"./_meta":93,"./_object-dp":96,"./_redefine-all":108,"./_set-to-string-tag":112}],65:[function(_dereq_,module,exports){
6597
- var core = module.exports = {version: '2.3.0'};
6598
+ var core = module.exports = {version: '2.4.0'};
6598
6599
  if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
6599
6600
  },{}],66:[function(_dereq_,module,exports){
6600
6601
  // optional / simple context binding
@@ -6733,20 +6734,26 @@ var ctx = _dereq_('./_ctx')
6733
6734
  , isArrayIter = _dereq_('./_is-array-iter')
6734
6735
  , anObject = _dereq_('./_an-object')
6735
6736
  , toLength = _dereq_('./_to-length')
6736
- , getIterFn = _dereq_('./core.get-iterator-method');
6737
- module.exports = function(iterable, entries, fn, that, ITERATOR){
6737
+ , getIterFn = _dereq_('./core.get-iterator-method')
6738
+ , BREAK = {}
6739
+ , RETURN = {};
6740
+ var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){
6738
6741
  var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable)
6739
6742
  , f = ctx(fn, that, entries ? 2 : 1)
6740
6743
  , index = 0
6741
- , length, step, iterator;
6744
+ , length, step, iterator, result;
6742
6745
  if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
6743
6746
  // fast case for arrays with default iterator
6744
6747
  if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
6745
- entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
6748
+ result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
6749
+ if(result === BREAK || result === RETURN)return result;
6746
6750
  } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
6747
- call(iterator, f, step.value, entries);
6751
+ result = call(iterator, f, step.value, entries);
6752
+ if(result === BREAK || result === RETURN)return result;
6748
6753
  }
6749
6754
  };
6755
+ exports.BREAK = BREAK;
6756
+ exports.RETURN = RETURN;
6750
6757
  },{"./_an-object":54,"./_ctx":66,"./_is-array-iter":82,"./_iter-call":85,"./_to-length":121,"./core.get-iterator-method":128}],75:[function(_dereq_,module,exports){
6751
6758
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
6752
6759
  var global = module.exports = typeof window != 'undefined' && window.Math == Math
@@ -7980,6 +7987,7 @@ var global = _dereq_('./_global')
7980
7987
  , isEnum = {}.propertyIsEnumerable
7981
7988
  , SymbolRegistry = shared('symbol-registry')
7982
7989
  , AllSymbols = shared('symbols')
7990
+ , OPSymbols = shared('op-symbols')
7983
7991
  , ObjectProto = Object[PROTOTYPE]
7984
7992
  , USE_NATIVE = typeof $Symbol == 'function'
7985
7993
  , QObject = global.QObject;
@@ -8011,6 +8019,7 @@ var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){
8011
8019
  };
8012
8020
 
8013
8021
  var $defineProperty = function defineProperty(it, key, D){
8022
+ if(it === ObjectProto)$defineProperty(OPSymbols, key, D);
8014
8023
  anObject(it);
8015
8024
  key = toPrimitive(key, true);
8016
8025
  anObject(D);
@@ -8038,10 +8047,14 @@ var $create = function create(it, P){
8038
8047
  };
8039
8048
  var $propertyIsEnumerable = function propertyIsEnumerable(key){
8040
8049
  var E = isEnum.call(this, key = toPrimitive(key, true));
8050
+ if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false;
8041
8051
  return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
8042
8052
  };
8043
8053
  var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
8044
- var D = gOPD(it = toIObject(it), key = toPrimitive(key, true));
8054
+ it = toIObject(it);
8055
+ key = toPrimitive(key, true);
8056
+ if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return;
8057
+ var D = gOPD(it, key);
8045
8058
  if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
8046
8059
  return D;
8047
8060
  };
@@ -8050,16 +8063,19 @@ var $getOwnPropertyNames = function getOwnPropertyNames(it){
8050
8063
  , result = []
8051
8064
  , i = 0
8052
8065
  , key;
8053
- while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
8054
- return result;
8066
+ while(names.length > i){
8067
+ if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
8068
+ } return result;
8055
8069
  };
8056
8070
  var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
8057
- var names = gOPN(toIObject(it))
8071
+ var IS_OP = it === ObjectProto
8072
+ , names = gOPN(IS_OP ? OPSymbols : toIObject(it))
8058
8073
  , result = []
8059
8074
  , i = 0
8060
8075
  , key;
8061
- while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]);
8062
- return result;
8076
+ while(names.length > i){
8077
+ if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]);
8078
+ } return result;
8063
8079
  };
8064
8080
 
8065
8081
  // 19.4.1.1 Symbol([description])
@@ -8067,13 +8083,12 @@ if(!USE_NATIVE){
8067
8083
  $Symbol = function Symbol(){
8068
8084
  if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!');
8069
8085
  var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
8070
- DESCRIPTORS && setter && setSymbolDesc(ObjectProto, tag, {
8071
- configurable: true,
8072
- set: function(value){
8073
- if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
8074
- setSymbolDesc(this, tag, createDesc(1, value));
8075
- }
8076
- });
8086
+ var $set = function(value){
8087
+ if(this === ObjectProto)$set.call(OPSymbols, value);
8088
+ if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
8089
+ setSymbolDesc(this, tag, createDesc(1, value));
8090
+ };
8091
+ if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set});
8077
8092
  return wrap(tag);
8078
8093
  };
8079
8094
  redefine($Symbol[PROTOTYPE], 'toString', function toString(){
@@ -16494,7 +16509,7 @@ RegistrarConnector.prototype.has = function (messageType) {
16494
16509
 
16495
16510
  RegistrarConnector.prototype.subscribe = function (messageType) {
16496
16511
  if (this._messageTypes.has(messageType)) {
16497
- log.warn('Message type already registered ', messageType);
16512
+ log.debug('Message type already registered ', messageType);
16498
16513
  return false;
16499
16514
  }
16500
16515
 
@@ -16830,11 +16845,14 @@ function TwilsockConnector(context, twilsock, config) {
16830
16845
  context: { value: context }
16831
16846
  });
16832
16847
 
16833
- twilsock.on('disconnected', function () {
16834
- return _this.emit('transportReady', false);
16848
+ twilsock.on('stateChanged', function (state) {
16849
+ if (state !== 'connected') {
16850
+ _this.emit('transportReady', false);
16851
+ }
16835
16852
  });
16853
+
16836
16854
  twilsock.on('registered', function (id) {
16837
- if (context && id === context.id) {
16855
+ if (context && id === context.id && twilsock.state === 'connected') {
16838
16856
  _this.emit('transportReady', true);
16839
16857
  }
16840
16858
  });
@@ -16859,7 +16877,7 @@ TwilsockConnector.prototype.has = function (messageType) {
16859
16877
 
16860
16878
  TwilsockConnector.prototype.subscribe = function (messageType) {
16861
16879
  if (this._messageTypes.has(messageType)) {
16862
- log.warn('Message type already registered ', messageType);
16880
+ log.debug('Message type already registered ', messageType);
16863
16881
  return false;
16864
16882
  }
16865
16883
 
@@ -17283,6 +17301,9 @@ function TwilsockClient(accessManager, options) {
17283
17301
  } },
17284
17302
  connected: { get: function get() {
17285
17303
  return _this._socket.isConnected;
17304
+ } },
17305
+ state: { get: function get() {
17306
+ return _this._socket.state;
17286
17307
  } }
17287
17308
  });
17288
17309
 
@@ -17309,6 +17330,9 @@ function TwilsockClient(accessManager, options) {
17309
17330
  this._socket.on('disconnected', function () {
17310
17331
  return _this.emit('disconnected');
17311
17332
  });
17333
+ this._socket.on('stateChanged', function (state) {
17334
+ return _this.emit('stateChanged', state);
17335
+ });
17312
17336
  }
17313
17337
 
17314
17338
  inherits(TwilsockClient, EventEmitter);
@@ -17648,7 +17672,7 @@ var WebSocket = _dereq_('ws');
17648
17672
  var StateMachine = _dereq_('javascript-state-machine');
17649
17673
 
17650
17674
  var ACTIVITY_CHECK_INTERVAL = 5000;
17651
- var ACTIVITY_TIMEOUT = 43000;
17675
+ var ACTIVITY_TIMEOUT = 45000;
17652
17676
 
17653
17677
  /**
17654
17678
  * @class TwilsockChannel
@@ -17664,7 +17688,7 @@ function TwilsockChannel(config) {
17664
17688
 
17665
17689
  var fsm = StateMachine.create({
17666
17690
  initial: 'disconnected',
17667
- events: [{ name: 'userConnect', from: ['disconnected'], to: 'connecting' }, { name: 'userDisconnect', from: ['connecting', 'connected', 'retrying'], to: 'disconnecting' }, { name: 'userRetry', from: ['retrying'], to: 'connecting' }, { name: 'socketConnected', from: ['connecting'], to: 'connected' }, { name: 'socketClosed', from: ['connecting', 'connected'], to: 'retrying' }, { name: 'socketClosed', from: ['disconnecting'], to: 'disconnected' }, { name: 'socketRejected', from: ['connecting', 'connected'], to: 'disconnecting' }],
17691
+ events: [{ name: 'userConnect', from: ['disconnected'], to: 'connecting' }, { name: 'userDisconnect', from: ['connecting', 'connected', 'retrying'], to: 'disconnecting' }, { name: 'userRetry', from: ['retrying'], to: 'connecting' }, { name: 'socketConnected', from: ['connecting'], to: 'connected' }, { name: 'socketClosed', from: ['connecting', 'connected', 'error'], to: 'retrying' }, { name: 'socketError', from: ['connected'], to: 'retrying' }, { name: 'socketClosed', from: ['disconnecting'], to: 'disconnected' }, { name: 'socketRejected', from: ['connecting', 'connected'], to: 'disconnecting' }, { name: 'protocolError', from: ['connected'], to: 'error' }],
17668
17692
  callbacks: {
17669
17693
  onconnecting: function onconnecting() {
17670
17694
  _this._startWatchdogTimer();
@@ -17689,6 +17713,12 @@ function TwilsockChannel(config) {
17689
17713
  onsocketRejected: function onsocketRejected() {
17690
17714
  var args = Array.prototype.slice.call(_arguments, 3, _arguments.length);
17691
17715
  _this._onSocketRejected(args);
17716
+ },
17717
+ onerror: function onerror() {
17718
+ _this._closeSocket();
17719
+ },
17720
+ onenterstate: function onenterstate() {
17721
+ _this.emit('stateChanged', _this.state);
17692
17722
  }
17693
17723
  },
17694
17724
  error: function error() {
@@ -17765,6 +17795,7 @@ TwilsockChannel.prototype._getState = function () {
17765
17795
  case 'disconnecting':
17766
17796
  return TwilsockChannel.state.DISCONNECTING;
17767
17797
  case 'disconnected':
17798
+ case 'error':
17768
17799
  default:
17769
17800
  return TwilsockChannel.state.DISCONNECTED;
17770
17801
  }
@@ -17776,7 +17807,7 @@ TwilsockChannel.prototype._initRetry = function () {
17776
17807
 
17777
17808
  TwilsockChannel.prototype._retry = function () {
17778
17809
  this._socket = null;
17779
- this._token = null;
17810
+ this._activeToken = null;
17780
17811
  this._fsm.userRetry();
17781
17812
  };
17782
17813
 
@@ -17789,7 +17820,7 @@ TwilsockChannel.prototype._onDisconnected = function () {
17789
17820
  this._backoff.reset();
17790
17821
  this._wschannelUrl = null;
17791
17822
  this._socket = null;
17792
- this._token = null;
17823
+ this._activeToken = null;
17793
17824
  this.emit('disconnected');
17794
17825
  };
17795
17826
 
@@ -17846,11 +17877,10 @@ TwilsockChannel.prototype._setupSocket = function () {
17846
17877
  };
17847
17878
 
17848
17879
  socket.onerror = function (error) {
17849
- log.debug('Twilsock E: ', error);
17880
+ log.error('Twilsock: ', error);
17850
17881
  // self._fsm.socketError();
17851
17882
  };
17852
17883
 
17853
- // Log messages from the server
17854
17884
  socket.onmessage = function (message) {
17855
17885
  log.trace('Twilsock: ', message.data);
17856
17886
 
@@ -17859,19 +17889,35 @@ TwilsockChannel.prototype._setupSocket = function () {
17859
17889
  var dataView = new Uint8Array(message.data);
17860
17890
  var magic = getMagic(dataView);
17861
17891
  if (magic.protocol !== 'TWILSOCK' || magic.version !== 'V1.0') {
17862
- throw new Error('Unsupported protocol: ' + magic.protocol + ' ver ' + magic.version);
17892
+ log.error('Twilsock E: unsupported protocol: ' + magic.protocol + ' ver ' + magic.version);
17893
+ self._fsm.socketRejected('Unsupported protocol');
17894
+ return;
17863
17895
  }
17864
17896
 
17865
- var header = getJsonObject(dataView.subarray(magic.size, magic.size + magic.headerSize));
17897
+ var header = null;
17898
+ try {
17899
+ header = getJsonObject(dataView.subarray(magic.size, magic.size + magic.headerSize));
17900
+ } catch (e) {
17901
+ log.error('Twilsock: failed to parse message header', e, message);
17902
+ self._fsm.protocolError();
17903
+ return;
17904
+ }
17866
17905
  log.trace('Twilsock: message received: ', header);
17867
17906
 
17868
17907
  var payload = null;
17869
17908
  if (header.payload_size > 0) {
17870
17909
  var payloadOffset = fieldMargin + magic.size + magic.headerSize;
17910
+ var payloadSize = header.payload_size;
17871
17911
  if (!header.hasOwnProperty('payload_type') || header.payload_type.indexOf('application/json') === 0) {
17872
- payload = getJsonObject(dataView.subarray(payloadOffset));
17912
+ try {
17913
+ payload = getJsonObject(dataView.subarray(payloadOffset, payloadOffset + payloadSize));
17914
+ } catch (e) {
17915
+ log.error('Twilsock: failed to parse message body', e, message);
17916
+ self._fsm.protocolError();
17917
+ return;
17918
+ }
17873
17919
  } else if (header.payload_type.indexOf('text/plain') === 0) {
17874
- payload = new Buffer(dataView.subarray(payloadOffset)).toString();
17920
+ payload = new Buffer(dataView.subarray(payloadOffset, payloadOffset + payloadSize)).toString();
17875
17921
  }
17876
17922
  }
17877
17923
 
@@ -18051,7 +18097,6 @@ TwilsockChannel.prototype.send = function (header, body) {
18051
18097
  */
18052
18098
  TwilsockChannel.prototype._onSocketRejected = function socketRejected(reason) {
18053
18099
  log.error('Twilsock connection closed by server', reason);
18054
- this.emit('remoteClose', reason);
18055
18100
  this._closeSocket();
18056
18101
  };
18057
18102
 
@@ -18065,6 +18110,9 @@ TwilsockChannel.prototype._startWatchdogTimer = function () {
18065
18110
  this._watchTimer = setInterval(function () {
18066
18111
  if (Date.now() - _this3._timestamp > ACTIVITY_TIMEOUT && _this3._socket) {
18067
18112
  _this3._socket.close();
18113
+ _this3._socket.onmessage = null;
18114
+ _this3._socket = null;
18115
+ _this3._fsm.socketClosed();
18068
18116
  }
18069
18117
  }, ACTIVITY_CHECK_INTERVAL);
18070
18118
  };
@@ -20421,7 +20469,7 @@ function extend() {
20421
20469
  },{}],211:[function(_dereq_,module,exports){
20422
20470
  module.exports={
20423
20471
  "name": "twilio-ip-messaging",
20424
- "version": "0.10.3",
20472
+ "version": "0.10.4",
20425
20473
  "description": "A library for Twilio IP messaging",
20426
20474
  "main": "lib/index.js",
20427
20475
  "author": "Twilio",
@@ -1,3 +1,3 @@
1
1
  module TwilioIpMessagingRails
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio_ip_messaging_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Aliabadi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler