statebus 6.2.0 → 6.2.2

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 (3) hide show
  1. package/client.js +12 -6
  2. package/package.json +2 -2
  3. package/server.js +10 -6
package/client.js CHANGED
@@ -14,7 +14,8 @@
14
14
  // ****************
15
15
  // Connecting over the Network
16
16
  function set_cookie (key, val) {
17
- document.cookie = key + '=' + val + '; Expires=21 Oct 2025 00:0:00 GMT;'
17
+ // max-age is 400 days, the max allowed in chrome now
18
+ document.cookie = key + '=' + val + '; max-age=34560000;'
18
19
  }
19
20
  function get_cookie (key) {
20
21
  var c = document.cookie.match('(^|;)\\s*' + key + '\\s*=\\s*([^;]+)');
@@ -59,6 +60,8 @@
59
60
  }
60
61
 
61
62
  function braid_http_mount (prefix, url) {
63
+ throw "Sorry, braid_http_mount is disabled! Tell mike you're using it, and he'll re-enable it."
64
+
62
65
  var preprefix = prefix.slice(0,-1)
63
66
  var has_prefix = new RegExp('^' + preprefix)
64
67
  var is_absolute = /^https?:\/\//
@@ -553,12 +556,15 @@
553
556
  improve_react()
554
557
  window.ignore_flashbacks = false
555
558
  if (statebus_server !== 'none') {
556
- if (clientjs_option('braid_mode')) {
557
- console.log('Using Braid-HTTP!')
558
- braid_http_mount ('/*', statebus_server)
559
- } else {
559
+ // Disable "braid_mode" for now
560
+ if (clientjs_option('braid_mode'))
561
+ console.log('braid_mode is disabled for now. Tell mike that you\'re using it, and he\'ll re-enable it!')
562
+ // if (clientjs_option('braid_mode')) {
563
+ // console.log('Using Braid-HTTP!')
564
+ // braid_http_mount ('/*', statebus_server)
565
+ // } else {
560
566
  bus.net_mount ('/*', statebus_server)
561
- }
567
+ // }
562
568
  }
563
569
 
564
570
  if (window.statebus_backdoor) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "statebus",
3
- "version": "6.2.0",
3
+ "version": "6.2.2",
4
4
  "description": "Synchronize state.",
5
5
  "main": "statebus.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "repository": "invisible-college/statebus",
18
18
  "dependencies": {
19
19
  "bcrypt-nodejs": "0.0.3",
20
- "braidify": "^0.1.18",
20
+ "braid-http": "^1.3.82",
21
21
  "chokidar": "^4.0.3",
22
22
  "coffeescript": "^2.3.1",
23
23
  "cookie": "^0.3.1",
package/server.js CHANGED
@@ -3,8 +3,8 @@ var fs = require('fs'),
3
3
 
4
4
  // Import braidify if it's available
5
5
  try {
6
- var braidify = require('braidify').http_server
7
- console.log('Found braidify library. Braid-HTTP enabled!')
6
+ var braidify = require('braid-http').http_server
7
+ console.log('Found braid-http library. Braid-HTTP enabled!')
8
8
  } catch (e) {
9
9
  var braidify = undefined
10
10
  }
@@ -106,8 +106,9 @@ function import_server (bus, options)
106
106
  + Math.random().toString(36).substring(2)
107
107
  + Math.random().toString(36).substring(2))
108
108
 
109
+ // max-age is 400 days, the max allowed in chrome now
109
110
  res.setHeader('Set-Cookie', 'client=' + req.client
110
- + '; Expires=21 Oct 2025 00:0:00 GMT;')
111
+ + '; max-age=34560000;')
111
112
  }
112
113
  next()
113
114
  })
@@ -219,7 +220,10 @@ function import_server (bus, options)
219
220
  res.end()
220
221
  }
221
222
 
222
- braidify && braidify(req, res)
223
+ // Braidify the request
224
+ braidify && braidify(req, res); if (req.is_multiplexer) return
225
+
226
+ // Handle subscription
223
227
  if (req.subscribe) {
224
228
  res.startSubscription({ onClose: end_it_all })
225
229
  console.log('yay subscription!')
@@ -237,7 +241,7 @@ function import_server (bus, options)
237
241
  // Note: if body === undefined, we need to send the
238
242
  // equivalent of a 404. This is missing in braid spec:
239
243
  // https://github.com/braid-org/braid-spec/issues/110
240
- res.sendVersion({body: body || 'null'})
244
+ res.sendUpdate({body: body || 'null'})
241
245
 
242
246
  // Or just return the current version
243
247
  else {
@@ -2416,7 +2420,7 @@ function import_server (bus, options)
2416
2420
  'statebus.js', 'client.js'].map((f) => fs.readFileSync('node_modules/statebus/' + f))
2417
2421
  if (bus.options.braid_mode)
2418
2422
  files.unshift(fs.readFileSync(
2419
- 'node_modules/braidify/braidify-client.js'
2423
+ 'node_modules/braid-http/braid-http-client.js'
2420
2424
  ))
2421
2425
  res.send(files.join(';\n'))
2422
2426
  })