@subiz/wsclient 3.1.6 → 3.1.8

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.
Files changed (2) hide show
  1. package/package.json +4 -3
  2. package/realtime.js +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/wsclient",
3
- "version": "3.1.6",
3
+ "version": "3.1.8",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "node realtime.test.js"
@@ -14,9 +14,10 @@
14
14
  "homepage": "https://github.com/subiz/wsclient#readme",
15
15
  "description": "",
16
16
  "devDependencies": {
17
- "tape": "^5.3.1"
17
+ "tape": "^5.6.1"
18
18
  },
19
19
  "dependencies": {
20
- "@subiz/flow": "^1.0.9"
20
+ "@subiz/flow": "^1.0.9",
21
+ "request": "^2.88.2"
21
22
  }
22
23
  }
package/realtime.js CHANGED
@@ -65,7 +65,8 @@ function Conn(apiUrl, credential, onDead, onEvents, callAPI) {
65
65
  return new Promise(function(rs) {
66
66
  var query = '?token=' + lastToken
67
67
  credential.getAccessToken().then(function(access_token) {
68
- if (credential.user_mask) query += '&user-mask=' + encodeURIComponent(credential.user_mask)
68
+ if (credential.user_ref) query += '&user-ref=' + encodeURIComponent(credential.user_ref)
69
+ else if (credential.user_mask) query += '&user-mask=' + encodeURIComponent(credential.user_mask)
69
70
  else if (access_token) query += '&access-token=' + access_token
70
71
 
71
72
  callAPI('post', apiUrl + 'subs' + query, JSON.stringify({events: events}), function(body, code) {
@@ -219,7 +220,7 @@ var dofetch = function(method, url, body, cb) {
219
220
  }
220
221
  // xhrsend sends an HTTP request
221
222
  var xhrsend = function(method, url, body, cb) {
222
- if (!XMLHttpRequest) return dofetch(method, url, body, cb)
223
+ if (typeof XMLHttpRequest === 'undefined') return dofetch(method, url, body, cb)
223
224
  var request = new XMLHttpRequest()
224
225
  request.onreadystatechange = function(e) {
225
226
  if (request.readyState !== 4) return