-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- new post works. - minimal debugging ui
- Loading branch information
Showing
26 changed files
with
1,317 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<html> | ||
<head> | ||
<title>Minimal Debugging UI</title> | ||
<link rel="stylesheet" href="https://the.missing.style/v1.0.6/missing.min.css"> | ||
|
||
<script src="https://unpkg.com/mithril/mithril.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
var root = document.body | ||
|
||
const server = "http://localhost:3000/jsonrpc" | ||
const token = "85b2ae37-0be4-4faa-b1f0-d02189a31cfa" | ||
|
||
async function callMethod(method, params) { | ||
const obj = { | ||
jsonrpc: "2.0", | ||
method: method, | ||
id: "1", | ||
params: [token, params], | ||
} | ||
|
||
const response = await fetch(server, { | ||
method: "POST", // *GET, POST, PUT, DELETE, etc. | ||
mode: "cors", // no-cors, *cors, same-origin | ||
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached | ||
credentials: "same-origin", // include, *same-origin, omit | ||
headers: { | ||
"Content-Type": "application/json", | ||
// 'Content-Type': 'application/x-www-form-urlencoded', | ||
}, | ||
redirect: "follow", // manual, *follow, error | ||
referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url | ||
body: JSON.stringify(obj), // body data type must match "Content-Type" header | ||
}) | ||
return response.json() // parses JSON response into native JavaScript objects | ||
} | ||
|
||
callMethod("examples.getStateName", [12]).then(data => { | ||
console.log(data) // JSON data parsed by `data.json()` call | ||
}) | ||
|
||
callMethod("ssb.post", { | ||
identity: "@fu9wRz7+UwjDcvW6TZrvbNDT0cEPgWBh/ZZq5dKGEyY=.ed25519", | ||
content: { | ||
text: `Now it will work`, | ||
root: "%sUJg+n7aIiDXPWQPrEMi4Tg82KhyF4gpI0TaQt0Z8Vc=.sha256" | ||
} | ||
}) | ||
.then(data => { | ||
console.log(data) | ||
}) | ||
.catch(err => { | ||
console.log("error", err) | ||
}) | ||
|
||
// callMethod("ssb.timeline.public", {identity: "@fu9wRz7+UwjDcvW6TZrvbNDT0cEPgWBh/ZZq5dKGEyY=.ed25519"}) | ||
// .then(data => { | ||
// console.log(data) | ||
// }) | ||
// .catch(err => { | ||
// console.log("error", err) | ||
// }) | ||
|
||
|
||
/* Live reload */ | ||
document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + | ||
':35729/livereload.js?snipver=1"></' + 'script>') | ||
</script> | ||
|
||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
|
||
File adapted from Perihelion by Nicolas Santini. | ||
|
||
Perihelion is an awesome SSB client, get its source from: | ||
|
||
https://github.com/nsantini/perihelion | ||
|
||
MIT License | ||
|
||
Copyright (c) 2022 Nicolas Santini | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
const lori = require("lori") | ||
|
||
function ping(_useless, callback) { | ||
callback(null, "pong") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const ssbRef = require("ssb-ref") | ||
const serverForIdentity = require("../../sbot.js") | ||
const api = require("../../common/ssb/api.js") | ||
|
||
async function post(params, callback) { | ||
console.log(params) | ||
const identity = params[0]?.identity | ||
const content = params[0]?.content | ||
let err = false | ||
let result = false | ||
|
||
if (!identity) { | ||
err = "Invalid identity." | ||
} | ||
|
||
if (!content || !content?.text) { | ||
err = "Invalid content." | ||
} | ||
|
||
if (!ssbRef.isFeed(identity)) { | ||
err = `Identity: ${identity} is not a valid identity` | ||
} | ||
|
||
if (!err) { | ||
try { | ||
result = await api.postMessage(identity, content) | ||
console.log(typeof result) | ||
console.log(JSON.stringify(result)) | ||
console.log(result) | ||
} catch(n) { | ||
console.log(n) | ||
err = `Error: ${n}` | ||
} | ||
} | ||
|
||
if (err) { | ||
callback(err, null) | ||
} else { | ||
callback(null, result) | ||
} | ||
} | ||
|
||
module.exports = post |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const ssbRef = require("ssb-ref") | ||
const serverForIdentity = require("../../../sbot.js") | ||
const api = require("../../../common/ssb/api.js") | ||
|
||
async function publicTimeline(params, callback) { | ||
console.log(params) | ||
const identity = params[0]?.identity | ||
let err = false | ||
let result = false | ||
|
||
if (!identity) { | ||
err = "Invalid identity." | ||
} | ||
|
||
if (!ssbRef.isFeed(identity)) { | ||
err = `Identity: ${identity} is not a valid identity` | ||
} | ||
|
||
if (!err) { | ||
try { | ||
result = await api.getThreads(identity, 1, 1) | ||
} catch(n) { | ||
console.log(n) | ||
err = `Error: ${n}` | ||
} | ||
} | ||
|
||
if (err) { | ||
callback(err, null) | ||
} else { | ||
callback(null, result) | ||
} | ||
} | ||
|
||
module.exports = publicTimeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.