Skip to content

Commit 70fb04b

Browse files
committed
I'm crushing your head!
1 parent 924a3f0 commit 70fb04b

3 files changed

Lines changed: 179 additions & 62 deletions

File tree

coms/net/fs.js

Lines changed: 177 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -22,89 +22,124 @@
2222
}
2323
2424
»*/
25-
/*DB SCHEMA«
25+
/*CURRENT DB SCHEMA«
2626
2727
Just like with our local file system, we should have a separate blob storage on the backend.
2828
29-
The outer "namespaces" (like LOTWFS) are meant to encapsulate the data of the various applications
29+
The outer "namespaces" (like LOTW_FS) are meant to encapsulate the data of the various (siloed) applications
3030
that the backend might possibly be used for.
3131
32-
root: {
32+
// Generic read/write rules ($ghid is our numerical github id, and is used as the name of an outer object)
33+
// ".read": "auth != null",
34+
// ".write": "auth != null && // Yes we are authorized...
35+
// auth.provider === 'github' && // by github...
36+
// auth.token.firebase.identities['github.com'][0] === $ghid && // with the correct id...
37+
// newData.child('sid').val() == root.child('cur_session_id').val() // identified by the current session
3338
34-
".read": false,
35-
".write": false,
36-
37-
LOTW_FS: {
39+
MOST RECENT:
3840
39-
"$ghid": {
40-
session_ids: { // Register a unique session id here upon local initialization
41-
".validate": "!root.child($ghid).child('session_ids')[newData.val()]"
42-
},
43-
cur_session_id: {
44-
'.validate": "newData.isString() && newData.val().length >= 4"
45-
},
46-
next_node_id: {
47-
},
48-
nodes: {
49-
".indexOn" = ["parId", "path"],
50-
"$nodeId": {
51-
".read": "auth != null",
52-
".write": "auth.ghid = $ghid",
53-
".validate": "data.exists() || newData.hasChildren(['parId', 'type', 'path'])",
54-
"parId": { // Mutable
55-
".validate": "newData.isNumber()"
41+
{
42+
"rules": {
43+
".read": false,
44+
".write": false,
45+
"LOTW_FS": {
46+
"$ghid": {
47+
"session_ids": {
48+
"$sid":{
49+
".read": "auth != null && auth.provider === 'github' && auth.token.firebase.identities['github.com'][0] === $ghid",
50+
".write": "auth != null && auth.provider === 'github' && auth.token.firebase.identities['github.com'][0] === $ghid",
51+
".validate": "newData.isBoolean() && newData.val() === true && !root.child('LOTW_FS').child($ghid).child('session_ids').child($sid).exists()"
52+
}
5653
},
57-
"path": { // Mutable: parId/name
58-
".validate": "newData.isString() && newData.val().length < $PATH_MAX"
54+
"cur_session_id": {
55+
".read": "auth != null && auth.provider === 'github' && auth.token.firebase.identities['github.com'][0] === $ghid",
56+
".write": "auth != null && auth.provider === 'github' && auth.token.firebase.identities['github.com'][0] === $ghid && newData.child('sid').val() === root.child('cur_session_id').val()",
57+
".validate": "newData.isString() && newData.val().length == 4"
5958
},
60-
"type": {
61-
".validate": "!data.exists() && newData.isString() && newData.val().length < $TYPE_MAX"
59+
"next_node_id": {
60+
".read": "auth != null && auth.provider === 'github' && auth.token.firebase.identities['github.com'][0] === $ghid",
61+
".write": "auth != null && auth.provider === 'github' && auth.token.firebase.identities['github.com'][0] === $ghid && newData.child('sid').val() === root.child('cur_session_id').val()",
62+
".validate": true
6263
},
63-
"blobId": {
64-
".validate": "!data.exists() && newData.isString() && newData.val().length < $ID_MAX"
65-
}
66-
"$other": {
67-
".validate": false
68-
}
69-
}
70-
},
71-
blobs: {
72-
"$blobId": {
73-
"meta": { // Example
74-
"field1": {
75-
".validate": "newData.isString() && newData.val().length < $FIELD1_MAX"
76-
},
77-
"field2": {
78-
".validate": "newData.isNumber()"
79-
},
80-
"field3": {
81-
".validate": "newData.isBoolean()"
82-
},
83-
".other": {
84-
".validate": false
64+
"nodes": {
65+
".indexOn": ["parId", "path"],
66+
"$nodeId": {
67+
".read": "auth != null && auth.provider === 'github'",
68+
".write": "auth != null && auth.provider === 'github' && auth.token.firebase.identities['github.com'][0] === $ghid && newData.child('sid').val() === root.child('cur_session_id').val()",
69+
".validate": "data.exists() || newData.hasChildren(['parId', 'type', 'path'])",
70+
"parId": {
71+
".validate": "newData.isNumber()"
72+
},
73+
"path": {
74+
".validate": "newData.isString() && newData.val().length < 100"
75+
},
76+
"type": {
77+
".validate": "!data.exists() && newData.isString() && newData.val().length < 5"
78+
},
79+
"blobId": {
80+
".validate": "!data.exists() && newData.isNumber()"
81+
},
82+
"$other": {
83+
".validate": false
84+
}
8585
}
8686
},
87-
"contents": {
88-
".validate": "newData.isString() && newData.val().length < $CONTENTS_MAX"
89-
},
90-
"$other": {
91-
".validate": false
87+
"blobs": {
88+
"$blobId": {
89+
".read": "auth != null && auth.provider === 'github'",
90+
".write": "auth != null && auth.provider === 'github' && auth.token.firebase.identities['github.com'][0] === $ghid && newData.child('sid').val() === root.child('cur_session_id').val()",
91+
"meta": {
92+
".validate": true
93+
},
94+
"contents": {
95+
".validate": "newData.isString() && newData.val().length < 100000"
96+
},
97+
"$other": {
98+
".validate": false
99+
}
100+
}
92101
}
93102
}
94103
}
95104
}
96-
},
105+
}
97106
98-
OTHER_NS: {
107+
Also: Let's await on update.
108+
»*/
99109

100-
}
110+
/*10/11/25: The urgency is arising. First, we'll delete everything from the firebase datastore,«
111+
and replace the security rules, whole cloth, with our new ones (the DB SCHEMA). Then we'll put
112+
this file in another location, and start it over again. We are going to need to clean up the
113+
logic that we've recently added to sys/fs.js. The plan is to do a 1:1 mapping of the
114+
(indexedDB) database logic used in sys/fs.js.
101115
116+
Way more than that stupid crap (below) about hardware APIs there is a need of a central location for,
117+
and common interface into all of the various ways of interacting, computationally-speaking,
118+
with the wider world.
102119
103-
}
120+
»*/
121+
/*10/9/25: The fundamental idea I am having is to do only what is necessary to support an«
122+
"ecosystem" that is centered around web-client-centric scripting languages.
104123
105-
Also: Let's await on update.
124+
One of the more telling outcomes will/should be the increasing usage of (web-based) hardware
125+
APIs, as opposed to DOM APIs.
106126
»*/
127+
/*10/7/25: Overall workflow«
128+
129+
1. Load the net.fs library
130+
2. Get the current user object
131+
- If not found, the user can only proceed by logging in
132+
3. Once logged in, check that a remote user directory has been set up.
133+
- If none exists, the user must create one.
134+
4. Check for the session id ($sid) in local storage.
135+
- If not found, call create_session_id() until an unused one is found, and set it in local storage.
136+
5. Call set_session_id() with the value of $sid.
137+
6. Perform remote fs operations.
138+
- If these fail with permission denied (on one's own directory), this most likely means that
139+
another session has called set_session_id. Report this (likely) error condition, and inform
140+
the user that they must manually reset the session id to continue.
107141
142+
»*/
108143
/*10/6/25: Persistent session ids, create_new_file() example«
109144
110145
Let's do persistent 24 bit session ids (4 chars, ~16M possible). This is instead of
@@ -1885,6 +1920,87 @@ export {coms, onkill};
18851920
cwarn("Firebase config");
18861921
log(firebaseConfig);
18871922

1923+
1924+
1925+
1926+
1927+
/*«
1928+
1929+
PAST:
1930+
1931+
root: {
1932+
1933+
".read": false,
1934+
".write": false,
1935+
1936+
LOTW_FS: {
1937+
1938+
"$ghid": {
1939+
session_ids: { // Register a unique session id here upon local initialization, stored locally
1940+
".validate": "!root.child($ghid).child('session_ids')[newData.val()]"
1941+
},
1942+
cur_session_id: {
1943+
'.validate": "newData.isString() && newData.val().length == 4"
1944+
},
1945+
next_node_id: {
1946+
},
1947+
nodes: {
1948+
".indexOn" = ["parId", "path"],
1949+
"$nodeId": {
1950+
".read": "auth != null",
1951+
".write": "auth.ghid = $ghid",
1952+
".validate": "data.exists() || newData.hasChildren(['parId', 'type', 'path'])",
1953+
"parId": { // Mutable
1954+
".validate": "newData.isNumber()"
1955+
},
1956+
"path": { // Mutable: parId/name
1957+
".validate": "newData.isString() && newData.val().length < $PATH_MAX"
1958+
},
1959+
"type": {
1960+
".validate": "!data.exists() && newData.isString() && newData.val().length < $TYPE_MAX"
1961+
},
1962+
"blobId": {
1963+
".validate": "!data.exists() && newData.isString() && newData.val().length < $ID_MAX"
1964+
}
1965+
"$other": {
1966+
".validate": false
1967+
}
1968+
}
1969+
},
1970+
blobs: {
1971+
"$blobId": {
1972+
"meta": { // Example
1973+
"field1": {
1974+
".validate": "newData.isString() && newData.val().length < $FIELD1_MAX"
1975+
},
1976+
"field2": {
1977+
".validate": "newData.isNumber()"
1978+
},
1979+
"field3": {
1980+
".validate": "newData.isBoolean()"
1981+
},
1982+
".other": {
1983+
".validate": false
1984+
}
1985+
},
1986+
"contents": {
1987+
".validate": "newData.isString() && newData.val().length < $CONTENTS_MAX"
1988+
},
1989+
"$other": {
1990+
".validate": false
1991+
}
1992+
}
1993+
}
1994+
}
1995+
},
1996+
1997+
OTHER_NS: {
1998+
1999+
}
2000+
2001+
}
2002+
2003+
»*/
18882004
/*«
18892005
goog_but.onclick=async()=>{//«
18902006
is_active = true;
@@ -1929,3 +2045,4 @@ const firebaseConfig = {
19292045
appId: "1:668423415088:web:979b40c704cab2322ed4f5"
19302046
};
19312047
»*/
2048+

list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11255","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/100824","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12602"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/61912"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/11295","fs.js/28722","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44068","net",["fs.js/45698"],"shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2026","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1436"],"index.html/486","login",["index.html/11711"],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9655","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/185316"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162926"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7969","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/1211"],"sys",["config.js/9931","desk.js/219678","fs.js/72746","terminal.js/4307","three.js/3443","util.js/33015"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]
1+
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11255","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/100824","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12602"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/61912"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/11295","fs.js/28722","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44068","net",["fs.js/50574"],"shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2026","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1436"],"index.html/486","login",["index.html/11711"],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9655","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/185316"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162926"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7969","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/1211"],"sys",["config.js/9931","desk.js/219761","fs.js/72746","terminal.js/4307","three.js/3443","util.js/33015"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]

sys/desk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ controls the interface, but modifying those areas should be done by experts only
1616
and press "*" in order to jump to the relevant point in the code.)
1717
1818
»*/
19-
19+
//10/10/25: Something like: '$ cat --binary /path/to/sloom.jpg > /style/desk/bgimg'
2020
/*util.GetPoint: New generic keyboard-driven graphical point/pixel selector«
2121
With the return value (a point: {x,y}), we can do document.elementsFromPoint(x,y)
2222
and pinpoint the element we want without resorting to needing (wanting) the mouse.

0 commit comments

Comments
 (0)