statebus 7.0.6 → 7.0.7
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.
- package/client-library.js +3 -4
- package/package.json +1 -1
- package/server-library.js +22 -17
package/client-library.js
CHANGED
|
@@ -661,7 +661,7 @@
|
|
|
661
661
|
get: function (o, k) { return o[k] },
|
|
662
662
|
set: function (o, k, v) {
|
|
663
663
|
o[k] = v
|
|
664
|
-
make_component(k, v)
|
|
664
|
+
window[k] = make_component(k, v)
|
|
665
665
|
return true
|
|
666
666
|
}
|
|
667
667
|
})
|
|
@@ -713,7 +713,7 @@
|
|
|
713
713
|
|
|
714
714
|
// ... or at least most of them -- there are just a few missing from
|
|
715
715
|
// this list.
|
|
716
|
-
var all_tags = 'a,abbr,address,area,article,aside,audio,b,base,bdi,bdo,blockquote,
|
|
716
|
+
var all_tags = 'a,abbr,address,area,article,aside,audio,b,base,bdi,bdo,blockquote,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,dd,del,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,ins,kbd,label,legend,li,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,param,picture,pre,progress,q,s,samp,script,section,select,slot,small,source,span,strong,style,sub,summary,sup,svg,table,tbody,td,template,tfoot,th,thead,title,tr,u,ul,video,input,circle,ellipse,g,image,line,path,polygon,polyline,rect,switch,symbol,text,textPath,tspan,use'.split(',')
|
|
717
717
|
all_tags.forEach((tagname) => {
|
|
718
718
|
window[tagname.toUpperCase()] = function_for_tag(tagname)
|
|
719
719
|
})
|
|
@@ -823,8 +823,7 @@
|
|
|
823
823
|
var users_widgets = {}
|
|
824
824
|
function make_component(name, func) {
|
|
825
825
|
// Define the component
|
|
826
|
-
|
|
827
|
-
window[name] = users_widgets[name] = create_react_class({
|
|
826
|
+
return users_widgets[name] = create_react_class({
|
|
828
827
|
displayName: name,
|
|
829
828
|
render: function () {
|
|
830
829
|
var args = []
|
package/package.json
CHANGED
package/server-library.js
CHANGED
|
@@ -1691,6 +1691,11 @@ function import_server (bus, make_statebus, options)
|
|
|
1691
1691
|
},
|
|
1692
1692
|
|
|
1693
1693
|
serves_auth: function serves_auth (conn, master) {
|
|
1694
|
+
// Right now, we only support accounts at '@username', but in general
|
|
1695
|
+
// we could allow the prefix to be configurable. We just have to go
|
|
1696
|
+
// through this function and make all the regular expressions (like
|
|
1697
|
+
// /@*.../) parameterizable.
|
|
1698
|
+
var prefix = '@'
|
|
1694
1699
|
var client = this // to keep me straight while programming
|
|
1695
1700
|
function logout (user_key) {
|
|
1696
1701
|
var clients = master.get('logged_in_clients')
|
|
@@ -1747,7 +1752,7 @@ function import_server (bus, make_statebus, options)
|
|
|
1747
1752
|
master.auth_initialized = true
|
|
1748
1753
|
master.get('users/passwords')
|
|
1749
1754
|
|
|
1750
|
-
master('
|
|
1755
|
+
master(prefix + '*').deleter = (key, t) => {
|
|
1751
1756
|
master.log('Deleteinggg!!!', key)
|
|
1752
1757
|
// Remove from users.all
|
|
1753
1758
|
var users = master.get('users')
|
|
@@ -1820,11 +1825,11 @@ function import_server (bus, make_statebus, options)
|
|
|
1820
1825
|
// might create it, even though the account hasn't been created
|
|
1821
1826
|
// yet, and then this will rename it to some random ID.
|
|
1822
1827
|
//
|
|
1823
|
-
var key =
|
|
1828
|
+
var key = prefix + params.name
|
|
1824
1829
|
if (!params.name)
|
|
1825
|
-
key =
|
|
1830
|
+
key = prefix + Math.random().toString(36).substring(7,13)
|
|
1826
1831
|
while (master.cache.hasOwnProperty(key))
|
|
1827
|
-
key =
|
|
1832
|
+
key = prefix + Math.random().toString(36).substring(7,13)
|
|
1828
1833
|
|
|
1829
1834
|
// Make account object
|
|
1830
1835
|
var new_account = {
|
|
@@ -1964,15 +1969,15 @@ function import_server (bus, make_statebus, options)
|
|
|
1964
1969
|
}
|
|
1965
1970
|
client('current_user').deleter = function () {}
|
|
1966
1971
|
|
|
1967
|
-
// Users have closet space at
|
|
1968
|
-
var closet_space_key = /^(
|
|
1969
|
-
var private_closet_space_key =
|
|
1972
|
+
// Users have closet space at @<name>/*
|
|
1973
|
+
var closet_space_key = /^(@[^\/]+)\/.*/
|
|
1974
|
+
var private_closet_space_key = /^@[^\/]+\/private.*/
|
|
1970
1975
|
|
|
1971
1976
|
// User
|
|
1972
|
-
client('
|
|
1977
|
+
client(prefix + '*').setter = function (o, t) {
|
|
1973
1978
|
var c = client.get('current_user')
|
|
1974
|
-
var user_key = o.key.match(
|
|
1975
|
-
user_key = user_key && (
|
|
1979
|
+
var user_key = o.key.match(/^@([^\/]+)/)
|
|
1980
|
+
user_key = user_key && (prefix + user_key[1])
|
|
1976
1981
|
|
|
1977
1982
|
// Only the current user can touch himself.
|
|
1978
1983
|
if (!c.val.logged_in || c.val.user.link !== user_key) {
|
|
@@ -1985,7 +1990,7 @@ function import_server (bus, make_statebus, options)
|
|
|
1985
1990
|
return
|
|
1986
1991
|
}
|
|
1987
1992
|
|
|
1988
|
-
// Users have closet space at
|
|
1993
|
+
// Users have closet space at @<name>/*
|
|
1989
1994
|
if (o.key.match(closet_space_key)) {
|
|
1990
1995
|
client.log('saving closet data')
|
|
1991
1996
|
master.set(o, t)
|
|
@@ -1993,7 +1998,7 @@ function import_server (bus, make_statebus, options)
|
|
|
1993
1998
|
}
|
|
1994
1999
|
|
|
1995
2000
|
// Ok, then it must be a plain user
|
|
1996
|
-
console.assert(o.key.match(
|
|
2001
|
+
console.assert(o.key.match(/^@[^\/]+$/))
|
|
1997
2002
|
|
|
1998
2003
|
// Validate types
|
|
1999
2004
|
if (!client.validate(o, {key: 'string',
|
|
@@ -2072,11 +2077,11 @@ function import_server (bus, make_statebus, options)
|
|
|
2072
2077
|
|
|
2073
2078
|
master.set(u)
|
|
2074
2079
|
}
|
|
2075
|
-
client('
|
|
2080
|
+
client(prefix + '*').getter = function user_getter (k) {
|
|
2076
2081
|
var c = client.get('current_user')
|
|
2077
2082
|
client.log('* getting:', k, 'as', c.val.user)
|
|
2078
2083
|
|
|
2079
|
-
// Users have closet space at
|
|
2084
|
+
// Users have closet space at @<name>/*
|
|
2080
2085
|
if (k.match(closet_space_key)) {
|
|
2081
2086
|
var obj_user = k.match(closet_space_key)[1]
|
|
2082
2087
|
if (k.match(private_closet_space_key)
|
|
@@ -2091,10 +2096,10 @@ function import_server (bus, make_statebus, options)
|
|
|
2091
2096
|
// Otherwise return the actual user
|
|
2092
2097
|
return user_obj(k, c.val.logged_in && c.val.user.link === k)
|
|
2093
2098
|
}
|
|
2094
|
-
client('
|
|
2099
|
+
client(prefix + '*').deleter = function () {}
|
|
2095
2100
|
function user_obj (k, logged_in) {
|
|
2096
2101
|
var o = master.clone(master.get(k))
|
|
2097
|
-
if (k.match(
|
|
2102
|
+
if (k.match(/^@([^\/]+)\/private\/(.*)$/))
|
|
2098
2103
|
return logged_in ? o : {key: k}
|
|
2099
2104
|
|
|
2100
2105
|
o.val = o.val || {}
|
|
@@ -2434,7 +2439,7 @@ function import_server (bus, make_statebus, options)
|
|
|
2434
2439
|
path = path || 'client.js'
|
|
2435
2440
|
bus.http.get('/' + path, (req, res) => {
|
|
2436
2441
|
var files =
|
|
2437
|
-
['extras/coffee.js', 'extras/sockjs.js',
|
|
2442
|
+
['extras/coffee.js', 'extras/sockjs.js',
|
|
2438
2443
|
'statebus.js', 'client.js'].map((f) => fs.readFileSync('node_modules/statebus/' + f))
|
|
2439
2444
|
files.unshift(fs.readFileSync(
|
|
2440
2445
|
'node_modules/braidify/braidify-client.js'
|