Purpose: get together and design the next steps for a clear JS API
Attendees: Andrew, Mix, Nanomonkey, TyChi
Source: tinySSB/tiny-shed-design#5 Source 2: https://github.com/ssbc/tinySSB/tree/main/android/tinySSB/app/src/main/assets/web
this is where we send commands for the backend to "execute"
function backend (cmdStr) { // send this to Kotlin (or simulate in case of browser-only testing)
// >> BEGIN INSERT VIRTBACKEND
if (cmdStr == 'ready' && window.location.search == '?virtualBackend=true') { return }
if (virtBackEnd != null) {
virtBackEnd.postMessage(['f2b', cmdStr], '*')
// NOTE: cmd is posted to backend, which processes storing, broadcasting, and sometime other actions.
// This can also include reformatting + bouncing back a "new_event" message to the frontend (here)
return
}
// << END INSERT VIRTBACKENDhttps://github.com/ssbc/tinySSB/blob/main/android/tinySSB/app/src/main/assets/web/tremola.js
https://github.com/ssbc/tinySSB/blob/main/android/tinySSB/app/src/main/assets/web/tremola.js
cmdStr array:
-
[0]:
- ready
- publ:post
- priv:post
- kanban
- IAM
- add:contact
- invite:redeem
- dump:
- process.msg
- importSecret
- exportSecret
- conf_dlv
-
[1]:
-
[2]:
- prev
- array?
- format?
- prev
-
[3]:
- content?
- format?
- content?
-
[4]:
function backend('ready')
function backend('exportSecret')
function backend('wipe')
function backend('publ:post', _: unknown, draft: Array<unknown>)
function backend('kanban')
potential insight for message payloads from webview to native (kotlin): https://github.com/ssbc/tinySSB/blob/main/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/WebAppInterface.kt#L98
here we can listen to events that are emitted
from backend:
var e = {
header: {
tst: Date.now(),
ref: Math.floor(1000000 * Math.random()),
fid: IDs[myname],
seq: myseqno
},
confid: { type: 'post', text: draft, recps: cmd },
public: {}
}
frontEnd.postMessage(['b2f', 'new_event', e], '*')var e = {
header: {
tst: Date.now(),
ref: Math.floor(1000000 * Math.random()),
fid: IDs[myname],
seq: myseqno
},
confid: { type: 'post', text: draft, recps: cmd },
public: {}
}
frontEnd.postMessage(['b2f', 'new_event', e], '*')// cmd = ['KAN', ...??]
// kanban
var e = {
header: {
tst: Date.now(),
ref: Math.floor(1000000 * Math.random()),
fid: IDs[myname],
seq: myseqno
},
public: cmd
}
frontEnd.postMessage(['b2f', 'new_event', e], '*')event.source.postMessage(['b2f', 'exportSecret',
'secret_of_id_which_is@AAAA==.ed25519'], '*')- seems like this area needs a refactor for readability
- named arguments would help a lot
- object with parameters
- we could read Kotlin to see how backend
- Lets move away from 3-letter function names, variable
- all the formatting / encoding should happen in only one place
- no magic strings
- extract into a file and document
- different sorts
- backend commands
- message types
- for events emitted, need
- documentation on the different fields
- standardisation
- the b2f API has 2 parts
- top level:
[b2f, "new_event", e]- this could be an object with named params too
- the event:
e
- top level:
Docs driven API
- write the docs / README for the new API
- get feedback
- implement it