forked from cory/tildefriends
Compare commits
34 Commits
tasiaiso-n
...
tasiaiso-d
Author | SHA1 | Date | |
---|---|---|---|
9c8772c898
|
|||
f31ec0338b
|
|||
1b3b9e570e
|
|||
580688381e | |||
e63d69a440 | |||
be64fe04fb | |||
801ab20723 | |||
d974a5e044 | |||
1be94ae0be | |||
b883e6a485 | |||
a0210379ae | |||
912747bdac
|
|||
80c1463a5c
|
|||
f2a3c790dd
|
|||
43f6a3a482 | |||
e56dc207d1 | |||
523c9c9ad2 | |||
74bb2151c1 | |||
f79d7b35a4 | |||
d7eda01c16
|
|||
12599b5723
|
|||
5b7d0f1aa1
|
|||
ae3430bf56
|
|||
7d77e398d4
|
|||
9f3a3808f9
|
|||
fae2771645
|
|||
2bb6d68122
|
|||
5c8c6e8760
|
|||
85ac8080f4
|
|||
0751699bc8
|
|||
5551fd2dea
|
|||
69b2e2a955
|
|||
34c7fa8312
|
|||
396f37ee3b
|
@ -1,4 +1,5 @@
|
|||||||
.svn
|
.svn
|
||||||
db.sqlite
|
db.*
|
||||||
out/**/*.o
|
out/**/*.o
|
||||||
out/**/*.d
|
out/**/*.d
|
||||||
|
NOTES.md
|
||||||
|
3
.gitea/ISSUE_TEMPLATE/bug-report.md
Normal file
3
.gitea/ISSUE_TEMPLATE/bug-report.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
name: 'Bug Report'
|
||||||
|
---
|
5
.gitea/ISSUE_TEMPLATE/config.yaml
Normal file
5
.gitea/ISSUE_TEMPLATE/config.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: true
|
||||||
|
contact_links:
|
||||||
|
- name: Documentation
|
||||||
|
url: https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/index.md
|
||||||
|
about: Read the documentation
|
3
.gitea/ISSUE_TEMPLATE/feature-rquest.md
Normal file
3
.gitea/ISSUE_TEMPLATE/feature-rquest.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
name: 'Feature Request'
|
||||||
|
---
|
9
.gitea/PULL_REQUEST_TEMPLATE.md
Normal file
9
.gitea/PULL_REQUEST_TEMPLATE.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
To Do List
|
||||||
|
|
||||||
|
- [ ] My changes are documented in the [documentation](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/index.md)
|
||||||
|
- [ ] I have tested my changes
|
||||||
|
- [ ] I agree to the contribution guidelines
|
||||||
|
- [ ] [C](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/guidelines/c-guidelines.md)
|
||||||
|
- [ ] [JavaScript](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/guidelines/javascript-guidelines.md)
|
||||||
|
- [ ] [documentation](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/guidelines/documentation-guidelines.md)
|
||||||
|
<!-- - [ ] I agree to the [Code of Conduct]() -->
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ out
|
|||||||
*.swp
|
*.swp
|
||||||
.zsign_cache/
|
.zsign_cache/
|
||||||
result
|
result
|
||||||
|
NOTES.md
|
||||||
|
5
.markdownlint.yaml
Normal file
5
.markdownlint.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
default: true
|
||||||
|
MD010: false # Ignore tabs in code blocks
|
||||||
|
MD013: false # Don't wrap lines by default
|
||||||
|
MD046:
|
||||||
|
style: 'fenced' # Force fenced code blocks
|
@ -2,6 +2,7 @@ node_modules
|
|||||||
src
|
src
|
||||||
deps
|
deps
|
||||||
.clang-format
|
.clang-format
|
||||||
|
flake.lock
|
||||||
|
|
||||||
# Minified files
|
# Minified files
|
||||||
**/*.min.css
|
**/*.min.css
|
||||||
@ -12,3 +13,8 @@ deps
|
|||||||
apps/ssb/tribute.esm.js
|
apps/ssb/tribute.esm.js
|
||||||
apps/api/app.js
|
apps/api/app.js
|
||||||
**/emojis.json
|
**/emojis.json
|
||||||
|
|
||||||
|
# only markdownlint should deal with the documentation
|
||||||
|
docs/**/*.md
|
||||||
|
|
||||||
|
NOTES.md
|
||||||
|
@ -616,7 +616,7 @@ $(IOS_TARGETS) $(IOSSIM_TARGETS): LDFLAGS += \
|
|||||||
|
|
||||||
unix: debug release
|
unix: debug release
|
||||||
win: windebug winrelease
|
win: windebug winrelease
|
||||||
all: $(BUILD_TYPES)
|
all: $(BUILD_TYPES) default.nix
|
||||||
.PHONY: all win unix
|
.PHONY: all win unix
|
||||||
|
|
||||||
ALL_APP_OBJS := \
|
ALL_APP_OBJS := \
|
||||||
@ -673,6 +673,10 @@ src/android/AndroidManifest.xml : $(firstword $(MAKEFILE_LIST))
|
|||||||
-e 's/android:targetSdkVersion="[[:digit:]]*"/android:targetSdkVersion="$(ANDROID_TARGET_SDK_VERSION)"/' \
|
-e 's/android:targetSdkVersion="[[:digit:]]*"/android:targetSdkVersion="$(ANDROID_TARGET_SDK_VERSION)"/' \
|
||||||
$@
|
$@
|
||||||
|
|
||||||
|
default.nix : $(firstword $(MAKEFILE_LIST))
|
||||||
|
@echo "[version] $@"
|
||||||
|
@sed -i -e 's/version = ".*";/version = "$(VERSION_NUMBER)";/' $@
|
||||||
|
|
||||||
# Android support.
|
# Android support.
|
||||||
out/res/layout_activity_main.xml.flat: src/android/res/layout/activity_main.xml
|
out/res/layout_activity_main.xml.flat: src/android/res/layout/activity_main.xml
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@ -858,7 +862,7 @@ clean:
|
|||||||
rm -rf $(BUILD_DIR)
|
rm -rf $(BUILD_DIR)
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
dist: release-apk iosrelease-ipa $(if $(HAVE_WIN), out/winrelease/tildefriends.standalone.exe)
|
dist: release-apk iosrelease-ipa $(if $(HAVE_WIN), out/winrelease/tildefriends.standalone.exe) default.nix
|
||||||
@echo [archive] dist/tildefriends-$(VERSION_NUMBER).tar.xz
|
@echo [archive] dist/tildefriends-$(VERSION_NUMBER).tar.xz
|
||||||
@rm -rf out/tildefriends-$(VERSION_NUMBER)
|
@rm -rf out/tildefriends-$(VERSION_NUMBER)
|
||||||
@mkdir -p dist/ out/tildefriends-$(VERSION_NUMBER)
|
@mkdir -p dist/ out/tildefriends-$(VERSION_NUMBER)
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright 2014 Cory McWilliams
|
Copyright 2014-2024 Cory McWilliams
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
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
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
37
README.md
37
README.md
@ -4,46 +4,19 @@ Tilde Friends is a tool for making and sharing.
|
|||||||
|
|
||||||
A public instance lives at https://www.tildefriends.net/.
|
A public instance lives at https://www.tildefriends.net/.
|
||||||
|
|
||||||
It is both a peer-to-peer social network client, participating in Secure
|
It is both a peer-to-peer social network client, participating in Secure Scuttlebutt, as well as a platform for writing and running web applications.
|
||||||
Scuttlebutt, as well as a platform for writing and running web applications.
|
|
||||||
|
|
||||||
## Goals
|
## Goals
|
||||||
|
|
||||||
1. Make it easy and fun to run all sorts of web applications.
|
1. Make it easy and fun to run all sorts of web applications.
|
||||||
2. Provide security that is easy to understand and protects your data.
|
2. Provide security that is easy to understand and protects your data.
|
||||||
3. Make creating and sharing web applications accessible to anyone with a
|
3. Make creating and sharing web applications accessible to anyone with a browser.
|
||||||
browser.
|
|
||||||
|
|
||||||
## Building
|
|
||||||
|
|
||||||
Builds on Linux (x86_64 and aarch64), MacOS, OpenBSD, and Haiku. Builds for
|
|
||||||
all of those host platforms plus mingw64, iOS, and android.
|
|
||||||
|
|
||||||
1. Requires openssl (`libssl-dev`, in debian-speak). All other dependencies
|
|
||||||
are kept up to date in the tree.
|
|
||||||
2. To build, run `make debug` or `make release`. An executable will be
|
|
||||||
generated in a subdirectory of `out/`.
|
|
||||||
3. It's possible to build for Android, iOS, and Windows on Linux, if you have
|
|
||||||
the right dependencies in the right places. `make windebug winrelease
|
|
||||||
iosdebug-ipa iosrelease-ipa release-apk`.
|
|
||||||
4. To build in docker, `docker build .`.
|
|
||||||
5. `make format` will normalize formatting to the coding standard.
|
|
||||||
|
|
||||||
## Running
|
|
||||||
|
|
||||||
By default, running the built `tildefriends` executable will start a web server
|
|
||||||
at <http://localhost:12345/>. `tildefriends -h` lists further options.
|
|
||||||
|
|
||||||
The first user to create an account and log in will be granted administrative
|
|
||||||
privileges. Further administration can be done at
|
|
||||||
<http://localhost:12345/~core/admin/>.
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Docs are a work in progress:
|
Docs are a work in progress: [documentation](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/index.md), or alternatively in Tilde Friends: <https://www.tildefriends.net/~cory/wiki/#test-wiki/tf-app-quick-reference>.
|
||||||
<https://www.tildefriends.net/~cory/wiki/#test-wiki/tf-app-quick-reference>.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
All code unless otherwise noted in is provided under the
|
All code, documentation and assets unless otherwise noted in is provided under the
|
||||||
[MIT](https://opensource.org/licenses/MIT) license.
|
[MIT](https://opensource.org/licenses/MIT/) license.
|
||||||
|
@ -78,7 +78,7 @@ async function main() {
|
|||||||
alert('Successfully created: ' + id);
|
alert('Successfully created: ' + id);
|
||||||
await tfrpc.rpc.reload();
|
await tfrpc.rpc.reload();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert('Error creating identity: ' + e);
|
alert('Error creating identity: ' + e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handler.hide_id = function hide_id(event, element) {
|
handler.hide_id = function hide_id(event, element) {
|
||||||
|
@ -67,9 +67,6 @@ tfrpc.register(function getHash(id, message) {
|
|||||||
tfrpc.register(function setHash(hash) {
|
tfrpc.register(function setHash(hash) {
|
||||||
return app.setHash(hash);
|
return app.setHash(hash);
|
||||||
});
|
});
|
||||||
ssb.addEventListener('message', async function (id) {
|
|
||||||
await tfrpc.rpc.notifyNewMessage(id);
|
|
||||||
});
|
|
||||||
tfrpc.register(async function store_blob(blob) {
|
tfrpc.register(async function store_blob(blob) {
|
||||||
if (Array.isArray(blob)) {
|
if (Array.isArray(blob)) {
|
||||||
blob = Uint8Array.from(blob);
|
blob = Uint8Array.from(blob);
|
||||||
@ -91,10 +88,12 @@ tfrpc.register(function getActiveIdentity() {
|
|||||||
tfrpc.register(async function try_decrypt(id, content) {
|
tfrpc.register(async function try_decrypt(id, content) {
|
||||||
return await ssb.privateMessageDecrypt(id, content);
|
return await ssb.privateMessageDecrypt(id, content);
|
||||||
});
|
});
|
||||||
ssb.addEventListener('broadcasts', async function () {
|
core.register('onMessage', async function (id) {
|
||||||
|
await tfrpc.rpc.notifyNewMessage(id);
|
||||||
|
});
|
||||||
|
core.register('onBroadcastsChanged', async function () {
|
||||||
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());
|
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());
|
||||||
});
|
});
|
||||||
|
|
||||||
core.register('onConnectionsChanged', async function () {
|
core.register('onConnectionsChanged', async function () {
|
||||||
await tfrpc.rpc.set('connections', await ssb.connections());
|
await tfrpc.rpc.set('connections', await ssb.connections());
|
||||||
});
|
});
|
||||||
|
@ -55,7 +55,7 @@ function new_message() {
|
|||||||
return g_new_message_promise;
|
return g_new_message_promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssb.addEventListener('message', function (id) {
|
core.register('onMessage', function (id) {
|
||||||
let resolve = g_new_message_resolve;
|
let resolve = g_new_message_resolve;
|
||||||
g_new_message_promise = new Promise(function (resolve, reject) {
|
g_new_message_promise = new Promise(function (resolve, reject) {
|
||||||
g_new_message_resolve = resolve;
|
g_new_message_resolve = resolve;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🐌",
|
"emoji": "🐌",
|
||||||
"previous": "&wA6sLaDxtYeFdVCCu8jyhPsGYtGZEjbWQHeGOn0Yifg=.sha256"
|
"previous": "&h0sTvkhc3zEJw/sH612fy5i554Gr1AKzCBbLkm0KH28=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ tfrpc.register(function getHash(id, message) {
|
|||||||
tfrpc.register(function setHash(hash) {
|
tfrpc.register(function setHash(hash) {
|
||||||
return app.setHash(hash);
|
return app.setHash(hash);
|
||||||
});
|
});
|
||||||
ssb.addEventListener('message', async function (id) {
|
core.register('onMessage', async function (id) {
|
||||||
await tfrpc.rpc.notifyNewMessage(id);
|
await tfrpc.rpc.notifyNewMessage(id);
|
||||||
});
|
});
|
||||||
tfrpc.register(async function store_blob(blob) {
|
tfrpc.register(async function store_blob(blob) {
|
||||||
@ -103,7 +103,7 @@ tfrpc.register(async function encrypt(id, recipients, content) {
|
|||||||
tfrpc.register(async function getActiveIdentity() {
|
tfrpc.register(async function getActiveIdentity() {
|
||||||
return await ssb.getActiveIdentity();
|
return await ssb.getActiveIdentity();
|
||||||
});
|
});
|
||||||
ssb.addEventListener('broadcasts', async function () {
|
core.register('onBroadcastsChanged', async function () {
|
||||||
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());
|
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class TfTabNewsElement extends LitElement {
|
|||||||
${this.new_messages_text()}
|
${this.new_messages_text()}
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div class="w3-bar">
|
||||||
Welcome, <tf-user id=${this.whoami} .users=${this.users}></tf-user>!
|
Welcome, <tf-user id=${this.whoami} .users=${this.users}></tf-user>!
|
||||||
${edit_profile}
|
${edit_profile}
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,7 +22,8 @@ class TfUserElement extends LitElement {
|
|||||||
let image = html`<span
|
let image = html`<span
|
||||||
class="w3-theme-light w3-circle"
|
class="w3-theme-light w3-circle"
|
||||||
style="display: inline-block; width: 2em; height: 2em; text-align: center; line-height: 2em"
|
style="display: inline-block; width: 2em; height: 2em; text-align: center; line-height: 2em"
|
||||||
>?</span>`;
|
>?</span
|
||||||
|
>`;
|
||||||
let name = this.users?.[this.id]?.name;
|
let name = this.users?.[this.id]?.name;
|
||||||
name =
|
name =
|
||||||
name !== undefined
|
name !== undefined
|
||||||
@ -31,7 +32,8 @@ class TfUserElement extends LitElement {
|
|||||||
|
|
||||||
if (this.users[this.id]) {
|
if (this.users[this.id]) {
|
||||||
let image_link = this.users[this.id].image;
|
let image_link = this.users[this.id].image;
|
||||||
image_link = typeof image_link == 'string' ? image_link : image_link?.link;
|
image_link =
|
||||||
|
typeof image_link == 'string' ? image_link : image_link?.link;
|
||||||
if (image_link !== undefined) {
|
if (image_link !== undefined) {
|
||||||
image = html`<img
|
image = html`<img
|
||||||
class="w3-circle"
|
class="w3-circle"
|
||||||
@ -41,8 +43,7 @@ class TfUserElement extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return html` <div style="display: inline-block; font-weight: bold">
|
return html` <div style="display: inline-block; font-weight: bold">
|
||||||
${image}
|
${image} ${name}
|
||||||
${name}
|
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ function new_message() {
|
|||||||
return g_new_message_promise;
|
return g_new_message_promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssb.addEventListener('message', function (id) {
|
core.register('onMessage', function (id) {
|
||||||
let resolve = g_new_message_resolve;
|
let resolve = g_new_message_resolve;
|
||||||
g_new_message_promise = new Promise(function (resolve, reject) {
|
g_new_message_promise = new Promise(function (resolve, reject) {
|
||||||
g_new_message_resolve = resolve;
|
g_new_message_resolve = resolve;
|
||||||
|
@ -208,7 +208,10 @@ class TfNavigationElement extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else if (
|
||||||
|
this.credentials?.session?.name &&
|
||||||
|
this.credentials.session.name !== 'guest'
|
||||||
|
) {
|
||||||
return html`
|
return html`
|
||||||
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
|
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
|
||||||
<button
|
<button
|
||||||
|
152
core/core.js
152
core/core.js
@ -8,116 +8,6 @@ let gStatsTimer = false;
|
|||||||
const k_content_security_policy =
|
const k_content_security_policy =
|
||||||
'sandbox allow-downloads allow-top-navigation-by-user-activation';
|
'sandbox allow-downloads allow-top-navigation-by-user-activation';
|
||||||
|
|
||||||
const k_mime_types = {
|
|
||||||
css: 'text/css',
|
|
||||||
html: 'text/html',
|
|
||||||
js: 'text/javascript',
|
|
||||||
json: 'text/json',
|
|
||||||
map: 'application/json',
|
|
||||||
svg: 'image/svg+xml',
|
|
||||||
};
|
|
||||||
|
|
||||||
const k_magic_bytes = [
|
|
||||||
{bytes: [0xff, 0xd8, 0xff, 0xdb], type: 'image/jpeg'},
|
|
||||||
{
|
|
||||||
bytes: [
|
|
||||||
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
|
|
||||||
],
|
|
||||||
type: 'image/jpeg',
|
|
||||||
},
|
|
||||||
{bytes: [0xff, 0xd8, 0xff, 0xee], type: 'image/jpeg'},
|
|
||||||
{
|
|
||||||
bytes: [
|
|
||||||
0xff,
|
|
||||||
0xd8,
|
|
||||||
0xff,
|
|
||||||
0xe1,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0x45,
|
|
||||||
0x78,
|
|
||||||
0x69,
|
|
||||||
0x66,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
],
|
|
||||||
type: 'image/jpeg',
|
|
||||||
},
|
|
||||||
{bytes: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], type: 'image/png'},
|
|
||||||
{bytes: [0x47, 0x49, 0x46, 0x38, 0x37, 0x61], type: 'image/gif'},
|
|
||||||
{bytes: [0x47, 0x49, 0x46, 0x38, 0x39, 0x61], type: 'image/gif'},
|
|
||||||
{
|
|
||||||
bytes: [
|
|
||||||
0x52,
|
|
||||||
0x49,
|
|
||||||
0x46,
|
|
||||||
0x46,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0x57,
|
|
||||||
0x45,
|
|
||||||
0x42,
|
|
||||||
0x50,
|
|
||||||
],
|
|
||||||
type: 'image/webp',
|
|
||||||
},
|
|
||||||
{bytes: [0x3c, 0x73, 0x76, 0x67], type: 'image/svg+xml'},
|
|
||||||
{
|
|
||||||
bytes: [
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0x66,
|
|
||||||
0x74,
|
|
||||||
0x79,
|
|
||||||
0x70,
|
|
||||||
0x6d,
|
|
||||||
0x70,
|
|
||||||
0x34,
|
|
||||||
0x32,
|
|
||||||
],
|
|
||||||
type: 'audio/mpeg',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
bytes: [
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0x66,
|
|
||||||
0x74,
|
|
||||||
0x79,
|
|
||||||
0x70,
|
|
||||||
0x69,
|
|
||||||
0x73,
|
|
||||||
0x6f,
|
|
||||||
0x6d,
|
|
||||||
],
|
|
||||||
type: 'video/mp4',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
bytes: [
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
0x66,
|
|
||||||
0x74,
|
|
||||||
0x79,
|
|
||||||
0x70,
|
|
||||||
0x6d,
|
|
||||||
0x70,
|
|
||||||
0x34,
|
|
||||||
0x32,
|
|
||||||
],
|
|
||||||
type: 'video/mp4',
|
|
||||||
},
|
|
||||||
{bytes: [0x4d, 0x54, 0x68, 0x64], type: 'audio/midi'},
|
|
||||||
];
|
|
||||||
|
|
||||||
let k_static_files = [
|
let k_static_files = [
|
||||||
{uri: '/', path: 'index.html', type: 'text/html; charset=UTF-8'},
|
{uri: '/', path: 'index.html', type: 'text/html; charset=UTF-8'},
|
||||||
];
|
];
|
||||||
@ -577,7 +467,8 @@ async function getProcessBlob(blobId, key, options) {
|
|||||||
if (
|
if (
|
||||||
process.credentials &&
|
process.credentials &&
|
||||||
process.credentials.session &&
|
process.credentials.session &&
|
||||||
process.credentials.session.name
|
process.credentials.session.name &&
|
||||||
|
process.credentials.session.name !== 'guest'
|
||||||
) {
|
) {
|
||||||
let id = ssb.createIdentity(process.credentials.session.name);
|
let id = ssb.createIdentity(process.credentials.session.name);
|
||||||
await process.sendIdentities();
|
await process.sendIdentities();
|
||||||
@ -595,6 +486,8 @@ async function getProcessBlob(blobId, key, options) {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
return id;
|
return id;
|
||||||
|
} else {
|
||||||
|
throw new Error('Must be signed-in to create an account.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (process.credentials?.permissions?.administration) {
|
if (process.credentials?.permissions?.administration) {
|
||||||
@ -785,6 +678,8 @@ async function getProcessBlob(blobId, key, options) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
imports.ssb.addEventListener = undefined;
|
||||||
|
imports.ssb.removeEventListener = undefined;
|
||||||
imports.ssb.getIdentityInfo = undefined;
|
imports.ssb.getIdentityInfo = undefined;
|
||||||
imports.fetch = function (url, options) {
|
imports.fetch = function (url, options) {
|
||||||
return http.fetch(url, options, gGlobalSettings.fetch_hosts);
|
return http.fetch(url, options, gGlobalSettings.fetch_hosts);
|
||||||
@ -938,29 +833,6 @@ function startsWithBytes(data, bytes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODOC
|
|
||||||
* @param {*} path
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
function guessTypeFromName(path) {
|
|
||||||
let extension = path.split('.').pop();
|
|
||||||
return k_mime_types[extension];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODOC
|
|
||||||
* @param {*} data
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
function guessTypeFromMagicBytes(data) {
|
|
||||||
for (let magic of k_magic_bytes) {
|
|
||||||
if (startsWithBytes(data, magic.bytes)) {
|
|
||||||
return magic.type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODOC
|
* TODOC
|
||||||
* @param {*} response
|
* @param {*} response
|
||||||
@ -976,7 +848,9 @@ function sendData(response, data, type, headers, status_code) {
|
|||||||
Object.assign(
|
Object.assign(
|
||||||
{
|
{
|
||||||
'Content-Type':
|
'Content-Type':
|
||||||
type || guessTypeFromMagicBytes(data) || 'application/binary',
|
type ||
|
||||||
|
httpd.mime_type_from_magic_bytes(data) ||
|
||||||
|
'application/binary',
|
||||||
'Content-Length': data.byteLength,
|
'Content-Length': data.byteLength,
|
||||||
},
|
},
|
||||||
headers || {}
|
headers || {}
|
||||||
@ -1345,7 +1219,9 @@ async function blobHandler(request, response, blobId, uri) {
|
|||||||
'Content-Security-Policy': k_content_security_policy,
|
'Content-Security-Policy': k_content_security_policy,
|
||||||
};
|
};
|
||||||
data = await getBlobOrContent(id);
|
data = await getBlobOrContent(id);
|
||||||
let type = guessTypeFromName(uri) || guessTypeFromMagicBytes(data);
|
let type =
|
||||||
|
httpd.mime_type_from_extension(uri) ||
|
||||||
|
httpd.mime_type_from_magic_bytes(data);
|
||||||
sendData(response, data, type, headers);
|
sendData(response, data, type, headers);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1354,6 +1230,10 @@ async function blobHandler(request, response, blobId, uri) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssb.addEventListener('message', function () {
|
||||||
|
broadcastEvent('onMessage', [...arguments]);
|
||||||
|
});
|
||||||
|
|
||||||
ssb.addEventListener('broadcasts', function () {
|
ssb.addEventListener('broadcasts', function () {
|
||||||
broadcastEvent('onBroadcastsChanged', []);
|
broadcastEvent('onBroadcastsChanged', []);
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
}:
|
}:
|
||||||
pkgs.stdenv.mkDerivation rec {
|
pkgs.stdenv.mkDerivation rec {
|
||||||
pname = "tildefriends";
|
pname = "tildefriends";
|
||||||
version = "0.0.19";
|
version = "0.0.19-wip";
|
||||||
|
|
||||||
src = pkgs.fetchFromGitea {
|
src = pkgs.fetchFromGitea {
|
||||||
domain = "dev.tildefriends.net";
|
domain = "dev.tildefriends.net";
|
||||||
|
@ -1,36 +1,4 @@
|
|||||||
# Philosophy
|
<!--
|
||||||
|
|
||||||
Tilde Friends is a platform for making, running, and sharing web applications.
|
|
||||||
|
|
||||||
When you visit Tilde Friends in a web browser, you are presented with a
|
|
||||||
terminal interface, typically with a big text output box covering most of the
|
|
||||||
page and an input box at the bottom, into which text or commands can be
|
|
||||||
entered. A script runs to produce text output and consume user input.
|
|
||||||
|
|
||||||
The script is a Tilde Friends application, and it runs on the server, which
|
|
||||||
means that unlike client-side JavaScript, it can have the ability to read and
|
|
||||||
write files on the server or create network connections to other machines.
|
|
||||||
Unlike node.js or other server-side runtime environments, applications are
|
|
||||||
limited for security reasons to not interfere with each other or bring the
|
|
||||||
entire server down.
|
|
||||||
|
|
||||||
Above the terminal, an "Edit" link brings a visitor to the source code for the
|
|
||||||
current Tilde Friends application, which they can then edit, save as their own,
|
|
||||||
and run.
|
|
||||||
|
|
||||||
# Architecture
|
|
||||||
|
|
||||||
Tilde Friends is a C++ application with a JavaScript runtime that provides
|
|
||||||
restricted access to filesystem, network, and other system resources. The core
|
|
||||||
process runs a core set of scripts that implement a web server, typically
|
|
||||||
starting a new process for each visitor's session which runs scripts for the
|
|
||||||
active application and stopping it when the visitor leaves.
|
|
||||||
|
|
||||||
Only the core process has access to most system resources, but session
|
|
||||||
processes can be given accesss through the core process.
|
|
||||||
|
|
||||||
Service processes are identical to session processes, but they are not tied to
|
|
||||||
a user session.
|
|
||||||
|
|
||||||
## Communication
|
## Communication
|
||||||
|
|
||||||
@ -66,7 +34,7 @@ performance reasons to minimize the data size transferred between processes.
|
|||||||
|
|
||||||
// Receive the above message and call the function.
|
// Receive the above message and call the function.
|
||||||
core.register("onMessage", function(sender, message) {
|
core.register("onMessage", function(sender, message) {
|
||||||
message.add(3, 4).then(x => terminal.print(x.toString()));
|
message.add(3, 4).then(x => terminal.print(x.toString()));
|
||||||
});
|
});
|
||||||
|
|
||||||
Finally, there is a core web interface that runs on the client's browser that
|
Finally, there is a core web interface that runs on the client's browser that
|
||||||
@ -135,16 +103,18 @@ Sets the browser window/tab title.
|
|||||||
|
|
||||||
Reconfigures the terminal layout, potentially into multiple split panes.
|
Reconfigures the terminal layout, potentially into multiple split panes.
|
||||||
|
|
||||||
terminal.split([
|
```javascript
|
||||||
{
|
terminal.split(
|
||||||
type: "horizontal",
|
[{
|
||||||
children: [
|
type: "horizontal",
|
||||||
{name: "left", basis: "2in", grow: 0, shrink: 0},
|
children: [
|
||||||
{name: "middle", grow: 1},
|
{name: "left", basis: "2in", grow: 0, shrink: 0},
|
||||||
{name: "right", basis: "2in", grow: 0, shrink: 0},
|
{name: "middle", grow: 1},
|
||||||
],
|
{name: "right", basis: "2in", grow: 0, shrink: 0},
|
||||||
},
|
],
|
||||||
]);
|
}]
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
#### terminal.select(name)
|
#### terminal.select(name)
|
||||||
|
|
||||||
@ -207,3 +177,5 @@ Writes data to the connection.
|
|||||||
#### connection.close()
|
#### connection.close()
|
||||||
|
|
||||||
Closes the connection.
|
Closes the connection.
|
||||||
|
|
||||||
|
-->
|
53
docs/apps/quickstart.md
Normal file
53
docs/apps/quickstart.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Writing Tilde Friends applications7
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Creating your environment
|
||||||
|
|
||||||
|
1. Open an existing application (ie: `identity`);
|
||||||
|
2. Open the editing panel;
|
||||||
|
3. Save the app under a new name (ie `/~YOUR_USERNAME/my-app/`);
|
||||||
|
4. Go back to the main menu and open your new app;
|
||||||
|
5. You can now edit your app, save it and see changes in the real time.
|
||||||
|
|
||||||
|
## Project structure
|
||||||
|
|
||||||
|
An application has a `app.js` file that gets run when a user enters the app.
|
||||||
|
This file contains a function (typically called `main()`) that's considered the entry point.
|
||||||
|
|
||||||
|
Paste this in `app.js`:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
async function main() {
|
||||||
|
let ids = await ssb.getIdentities();
|
||||||
|
await app.setDocument(`
|
||||||
|
<body style="font-family: sans-serif; color: white">
|
||||||
|
<h1>Hello world!</h1>
|
||||||
|
</body>
|
||||||
|
</body>`);
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
```
|
||||||
|
|
||||||
|
Save the app, and you should now be seeing `Hello world!` on the screen.
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
Once your app grows to a certain size, you'll want to introduce components.
|
||||||
|
In Tilde Friends, the de facto standard is [Lit](TODO).
|
||||||
|
Althogh you an use any framework you want, you're encouraged to use Lit as you can reuse
|
||||||
|
|
||||||
|
First, add lit-all-min.js into your project.
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
<!-- mention shadow dom -->
|
||||||
|
|
||||||
|
TODO: tfrpc
|
||||||
|
|
||||||
|
Apps can interact with Tilde Friends using tfrpc.
|
||||||
|
|
||||||
|
Read [tfrpc.md](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/apps/tfrpc.md)
|
||||||
|
|
||||||
|
TODO: sharing apps
|
7
docs/apps/tfrpc.md
Normal file
7
docs/apps/tfrpc.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# RPC documentation
|
||||||
|
|
||||||
|
Quick start
|
||||||
|
|
||||||
|
Complete documentation
|
||||||
|
|
||||||
|
TODO
|
78
docs/building.md
Normal file
78
docs/building.md
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# How to build Tilde Friends
|
||||||
|
|
||||||
|
> Disclaimer: this documentation has been written by a Linux user and has not been reviewed by other people on other platforms. The procedure may vary slightly depending on your operating system.
|
||||||
|
|
||||||
|
Builds **on** Linux (`x86_64` and `aarch64`), MacOS, OpenBSD, and Haiku.
|
||||||
|
|
||||||
|
Builds **for** all of those host platforms plus `mingw64`, iOS, and android.
|
||||||
|
|
||||||
|
Dependencies:
|
||||||
|
|
||||||
|
- `openssl` (`libssl-dev`, in debian-speak)
|
||||||
|
|
||||||
|
Dependencies for Android:
|
||||||
|
|
||||||
|
- TODO
|
||||||
|
|
||||||
|
Dependencies for iOS:
|
||||||
|
|
||||||
|
- TODO
|
||||||
|
|
||||||
|
Dependencies for Windows:
|
||||||
|
|
||||||
|
- TODO
|
||||||
|
|
||||||
|
> All other dependencies are kept up to date as git submodules.
|
||||||
|
|
||||||
|
1. Clone the repository with the submodules: `git clone --recursive https://dev.tildefriends.net/cory/tildefriends.git`
|
||||||
|
|
||||||
|
2. Run `make -j $(nproc) debug` or `make -j $(nproc) release`
|
||||||
|
|
||||||
|
If you're unsure whether you should choose `debug` or `release`, stick to `release`.
|
||||||
|
|
||||||
|
> `-j $(nproc)` will start a compiler for every CPU thread, which will dramatically reduce the time needed to compile Tilde Friends.
|
||||||
|
|
||||||
|
An executable will be generated in a subdirectory of `out/`
|
||||||
|
|
||||||
|
It's possible to build for Android, iOS, and Windows on Linux, if you have the right dependencies in the right places. Run `make -j $(nproc) windebug winrelease iosdebug-ipa iosrelease-ipa release-apk`
|
||||||
|
|
||||||
|
To build in docker, `docker build .`
|
||||||
|
|
||||||
|
<!-- On NixOS: TODO -->
|
||||||
|
<!-- Add shell.nix and nix derivs first -->
|
||||||
|
|
||||||
|
Now that you have a binary, head over to [running.md](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/running.md).
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### The compiler throws a warning and I can't build the binary
|
||||||
|
|
||||||
|
You can choose to tell the compiler to ignore warnings.
|
||||||
|
Open `GNUMakefile` and edit the CFLAGS environment variable around line 50.
|
||||||
|
|
||||||
|
For example given this error:
|
||||||
|
|
||||||
|
```text
|
||||||
|
src/http.c: In function 'tf_http_get_cookie':
|
||||||
|
src/http.c:1089:128: error: check of 'name' for NULL after already dereferencing it [-Werror=analyzer-deref-before-check]
|
||||||
|
```
|
||||||
|
|
||||||
|
Add:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
CFLAGS += \
|
||||||
|
-std=gnu11 \
|
||||||
|
-Wall \
|
||||||
|
-Wextra \
|
||||||
|
-Wno-unused-parameter \
|
||||||
|
+ -Wno-analyzer-deref-before-check \
|
||||||
|
-MMD \
|
||||||
|
-MP \
|
||||||
|
-ffunction-sections \
|
||||||
|
-fdata-sections \
|
||||||
|
-fno-exceptions \
|
||||||
|
-g
|
||||||
|
```
|
||||||
|
|
||||||
|
Now the compiler will ignore this error and *should* continue building anyways.
|
||||||
|
Note this is a dirty hack to get Tilde Friends to compile and you should not propose to keep this flag on. Instead, open a bug report.
|
60
docs/contributing.md
Normal file
60
docs/contributing.md
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# How to contribute
|
||||||
|
|
||||||
|
## Philosophy
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Best practices
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## How to get your changes merged
|
||||||
|
|
||||||
|
- Fork this repository
|
||||||
|
|
||||||
|
- Clone your repository
|
||||||
|
|
||||||
|
1. Alternatively, you can add a remote called `fork`:
|
||||||
|
|
||||||
|
`$ git remote add fork https://dev.tildefriends.net/YOUR_USERNAME/tildefriends.git`
|
||||||
|
|
||||||
|
You'll need to set your branch's upstream to `fork`:
|
||||||
|
|
||||||
|
`$ git push --set-upstream fork my-branch`
|
||||||
|
|
||||||
|
2. or you can change the `origin` remote on your existing clone altogether:
|
||||||
|
|
||||||
|
`$ git remote set-url origin https://dev.tildefriends.net/YOUR_USERNAME/tildefriends.git`
|
||||||
|
|
||||||
|
- Make your changes
|
||||||
|
|
||||||
|
- I want to edit C code !
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
- I want to edit JavaScript code !
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
- I want to write documentation !
|
||||||
|
|
||||||
|
Great! Before you do, have a look at the [documentation guidelines](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/guidelines/documentation-guidelines.md) to learn how to write consistent documentation.
|
||||||
|
|
||||||
|
In all cases:
|
||||||
|
|
||||||
|
- Make sure that your commit messages are descriptive.
|
||||||
|
<!-- - hi -->
|
||||||
|
|
||||||
|
- Format your changes:
|
||||||
|
|
||||||
|
If you've edited C code: run `make format`
|
||||||
|
|
||||||
|
If you've edited JavaScript code or the documentation: run `npm run format`
|
||||||
|
|
||||||
|
- Open a pull request
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
- Get your changes reviewed and merged
|
||||||
|
|
||||||
|
TODO
|
13
docs/documentation.md
Normal file
13
docs/documentation.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Tilde Friends documentation
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
See [building.md](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/building.md).
|
||||||
|
|
||||||
|
## Contibuting
|
||||||
|
|
||||||
|
See [contributing.md](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/contributing.md).
|
||||||
|
|
||||||
|
## FAQ / Troubleshooting
|
||||||
|
|
||||||
|
See [faq.md](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/faq.md).
|
13
docs/faq.md
Normal file
13
docs/faq.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Troubleshooting
|
||||||
|
|
||||||
|
## I started tildefriends. Now what ?
|
||||||
|
|
||||||
|
See [running.md](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/running.md).
|
||||||
|
|
||||||
|
### The compiler throws an error and I can't build the binary
|
||||||
|
|
||||||
|
See [building.md](https://dev.tildefriends.net/cory/tildefriends/src/branch/main/docs/building.md).
|
||||||
|
|
||||||
|
### Where is my database located ?
|
||||||
|
|
||||||
|
TODO
|
1
docs/guidelines/c-guidelines.md
Normal file
1
docs/guidelines/c-guidelines.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# TODO
|
75
docs/guidelines/documentation-guidelines.md
Normal file
75
docs/guidelines/documentation-guidelines.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# Documentation guidelines
|
||||||
|
|
||||||
|
This document defines the rules used to write documentation in order to make it more consistent.
|
||||||
|
This documentation is a living document and so are it's rules; you are free to propose changes but in the meantime, please stick to them.
|
||||||
|
|
||||||
|
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119/).
|
||||||
|
|
||||||
|
## File naming
|
||||||
|
|
||||||
|
Files SHOULD be named using [kebab-case](https://www.freecodecamp.org/news/snake-case-vs-camel-case-vs-pascal-case-vs-kebab-case-whats-the-difference/#kebab-case).
|
||||||
|
Their names should be meaningful and SHOULD not conflict with other files in other directories:
|
||||||
|
|
||||||
|
> Example: this document is named `docs/guidelines/documentation-guidelines.md` instead of `docs/guidelines/documentation.md` because it could cause confusion with `docs/documentation.md`.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
When writing documentation, the author should have in mind it's target audience: people with varying technical skills and backgrounds, fluency in peer-to-peer-specific terms and mental ability.
|
||||||
|
The documentation should therefore be acessible and usefule to most people interested in building, using and contributing to Tilde Friends.
|
||||||
|
|
||||||
|
### Terminology
|
||||||
|
|
||||||
|
`Tilde Friends` refers to the projectas a whole. This can be abbreviated to `TF`.
|
||||||
|
|
||||||
|
`tildefriends` refers to the program.
|
||||||
|
|
||||||
|
### Style guide
|
||||||
|
|
||||||
|
1. Lines SHOULD NOT be wrapped, to allow clients to dynamically wrap them however they want:
|
||||||
|
|
||||||
|
```text
|
||||||
|
This is not very pleasant to read because
|
||||||
|
the text
|
||||||
|
is manually wrapped, but the size of the
|
||||||
|
screen is
|
||||||
|
smaller than the size the text is wrapped
|
||||||
|
at. I
|
||||||
|
need to write even more useless text here
|
||||||
|
so I get
|
||||||
|
my point across. Also hi! If you're here
|
||||||
|
that
|
||||||
|
means you're either going to contribute to
|
||||||
|
Tilde
|
||||||
|
Friends, or that you're reviewing my
|
||||||
|
stupid
|
||||||
|
changes. Either way, you're awesome!
|
||||||
|
```
|
||||||
|
|
||||||
|
You MAY use one line per sentence.
|
||||||
|
|
||||||
|
2. Lines ending with an `inline code block` or hyperlinks SHOULD NOT end with a period to make copy-pasting easier.
|
||||||
|
|
||||||
|
> Example: To build in docker, `$ docker build .`
|
||||||
|
|
||||||
|
NB: this does not apply to file names or other text that are not meant to be copy-pasted.
|
||||||
|
|
||||||
|
> Example: this document is named `docs/guidelines/documentation-guidelines.md` instead of `docs/guidelines/documentation.md` because it could cause confusion with `docs/documentation.md`.
|
||||||
|
|
||||||
|
3. Commands SHOULD start with a caret: (is that the tehnical term ?)
|
||||||
|
|
||||||
|
- `$` if the command should be run as the current user
|
||||||
|
- `#` if the command should be run as root
|
||||||
|
|
||||||
|
> Example: To build in docker, `$ docker build .`
|
||||||
|
|
||||||
|
More TODO
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
As per the rest of the code in this repository, the documentation is shared under the [MIT](https://opensource.org/licenses/MIT/) license.
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
### v1 (2024-05-12)
|
||||||
|
|
||||||
|
First version; 3 new guidelines.
|
1
docs/guidelines/javascript-guidelines.md
Normal file
1
docs/guidelines/javascript-guidelines.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# TODO
|
37
docs/in-depth.md
Normal file
37
docs/in-depth.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Tilde Friends in depth
|
||||||
|
|
||||||
|
## Philosophy
|
||||||
|
|
||||||
|
Tilde Friends is a platform for making, running, and sharing web applications.
|
||||||
|
|
||||||
|
<!-- When you visit Tilde Friends in a web browser, you are presented with a
|
||||||
|
terminal interface, typically with a big text output box covering most of the
|
||||||
|
page and an input box at the bottom, into which text or commands can be
|
||||||
|
entered. A script runs to produce text output and consume user input.
|
||||||
|
|
||||||
|
The script is a Tilde Friends application, and it runs on the server, which
|
||||||
|
means that unlike client-side JavaScript, it can have the ability to read and
|
||||||
|
write files on the server or create network connections to other machines.
|
||||||
|
Unlike node.js or other server-side runtime environments, applications are
|
||||||
|
limited for security reasons to not interfere with each other or bring the
|
||||||
|
entire server down.
|
||||||
|
|
||||||
|
Above the terminal, an "Edit" link brings a visitor to the source code for the
|
||||||
|
current Tilde Friends application, which they can then edit, save as their own,
|
||||||
|
and run. -->
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
Tilde Friends is a C++ application with a JavaScript runtime that provides restricted access to filesystem, network, and other system resources.
|
||||||
|
The core process runs a core set of scripts that implement a web server, typically starting a new process for each visitor's session which runs scripts for the active application and stopping it when the visitor leaves.
|
||||||
|
|
||||||
|
Only the core process has access to most system resources, but session processes can be given accesss through the core process.
|
||||||
|
|
||||||
|
Service processes are identical to session processes, but they are not tied to a user session.
|
||||||
|
|
||||||
|
```text
|
||||||
|
/-------\ /-------------\ /--------------\
|
||||||
|
| C app | <-----> | Server-side | <-----> | Client-side |
|
||||||
|
| | tfrpc | JS runtime | | JS (Browser) |
|
||||||
|
\-------/ \-------------/ \--------------/
|
||||||
|
```
|
50
docs/running.md
Normal file
50
docs/running.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Running Tilde Friends
|
||||||
|
|
||||||
|
> Disclaimer: this documentation has been written by a Linux user and has not been reviewed by other people on other platforms. The procedure may vary slightly depending on your operating system.
|
||||||
|
|
||||||
|
The binaries should appear at `out/debug/tildefriends` and `out/release/tildefriends`.
|
||||||
|
|
||||||
|
For Android, iOS and Windows: TODO
|
||||||
|
|
||||||
|
You can now start the server by running `$ ./out/debug/tildefriends` or `$ ./out/release/tildefriends`.
|
||||||
|
|
||||||
|
By default, running the built `tildefriends` executable will start a web server
|
||||||
|
at <http://localhost:12345/>. `$ tildefriends -h` lists further options.
|
||||||
|
|
||||||
|
## How to use TF
|
||||||
|
|
||||||
|
### Initial setup
|
||||||
|
|
||||||
|
Now you have a Tilde Friends instance running. The first thing you'll want to do is create your account. Click "login" in the top right corner, then "Register".
|
||||||
|
Enter your username and password.
|
||||||
|
|
||||||
|
> The first user to create an account and log in will be granted administrative privileges.
|
||||||
|
> Further administration can be done at <http://localhost:12345/~core/admin/>
|
||||||
|
|
||||||
|
Next, create a Scuttlebutt identity by pressing the "Create an identity" button.
|
||||||
|
This will create a pair of keys that are used to sign your messages with.
|
||||||
|
|
||||||
|
Because of the way Scuttlebutt is designed, you cannot log into your account without your keys.
|
||||||
|
Tilde Friends locks your keys behind a password, but if you were to destroy your database, the keys would be gone forever, and with it your possibility to send messages using this account. Click on the `identity` app and under "Identities", export your newly created identity.
|
||||||
|
|
||||||
|
You'll be prompted with a dialog box saying "This app is requesting the following permission:ssb_id_export".
|
||||||
|
This is because applications are not trusted to have access to your keys by default.
|
||||||
|
Click on "Allow" and you'll see a list of 12 words. You need to write those down in a password manager or on a piece of paperand keep it private and secure.
|
||||||
|
|
||||||
|
> Warning: Nobody needs to know these 12 words. Anybody that has access to those keys can post messages as you, see your private messages and documents and much more.
|
||||||
|
|
||||||
|
Now that your keys are safe, we can start connecting to the outside world.
|
||||||
|
|
||||||
|
### Replication
|
||||||
|
|
||||||
|
You've probably noticed asdtring of random characters by now. This is your public key, a unique identifier for your account you can share to anyone. If you go back to the home menu and into the `ssb` app, you can click on your public key. This will lead you to your profile, which is empty at the time. Edit it and enter your name.
|
||||||
|
|
||||||
|
TODO: joining a room
|
||||||
|
|
||||||
|
TODO: initial sync
|
||||||
|
|
||||||
|
TODO: send messages
|
||||||
|
|
||||||
|
TODO: how messages spread to friends
|
||||||
|
|
||||||
|
TODO: other apps
|
716
package-lock.json
generated
716
package-lock.json
generated
@ -6,13 +6,442 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "tildefriends",
|
"name": "tildefriends",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"markdownlint-cli": "0.40.0",
|
||||||
|
"prettier": "3.2.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@isaacs/cliui": {
|
||||||
|
"version": "8.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
|
||||||
|
"integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
|
||||||
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"prettier": "^3.2.5"
|
"string-width": "^5.1.2",
|
||||||
|
"string-width-cjs": "npm:string-width@^4.2.0",
|
||||||
|
"strip-ansi": "^7.0.1",
|
||||||
|
"strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
|
||||||
|
"wrap-ansi": "^8.1.0",
|
||||||
|
"wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@pkgjs/parseargs": {
|
||||||
|
"version": "0.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||||
|
"integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ansi-regex": {
|
||||||
|
"version": "6.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz",
|
||||||
|
"integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ansi-styles": {
|
||||||
|
"version": "6.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
|
||||||
|
"integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/argparse": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/balanced-match": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/brace-expansion": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/color-convert": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"color-name": "~1.1.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/color-name": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||||
|
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/commander": {
|
||||||
|
"version": "12.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz",
|
||||||
|
"integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/cross-spawn": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"path-key": "^3.1.0",
|
||||||
|
"shebang-command": "^2.0.0",
|
||||||
|
"which": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/deep-extend": {
|
||||||
|
"version": "0.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
|
||||||
|
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eastasianwidth": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/emoji-regex": {
|
||||||
|
"version": "9.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
|
||||||
|
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/entities": {
|
||||||
|
"version": "4.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||||
|
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/foreground-child": {
|
||||||
|
"version": "3.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz",
|
||||||
|
"integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"cross-spawn": "^7.0.0",
|
||||||
|
"signal-exit": "^4.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/get-stdin": {
|
||||||
|
"version": "9.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-9.0.0.tgz",
|
||||||
|
"integrity": "sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/glob": {
|
||||||
|
"version": "10.3.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-10.3.14.tgz",
|
||||||
|
"integrity": "sha512-4fkAqu93xe9Mk7le9v0y3VrPDqLKHarNi2s4Pv7f2yOvfhWfhc7hRPHC/JyqMqb8B/Dt/eGS4n7ykwf3fOsl8g==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"foreground-child": "^3.1.0",
|
||||||
|
"jackspeak": "^2.3.6",
|
||||||
|
"minimatch": "^9.0.1",
|
||||||
|
"minipass": "^7.0.4",
|
||||||
|
"path-scurry": "^1.11.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"glob": "dist/esm/bin.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16 || 14 >=14.17"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ignore": {
|
||||||
|
"version": "5.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz",
|
||||||
|
"integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ini": {
|
||||||
|
"version": "4.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/ini/-/ini-4.1.2.tgz",
|
||||||
|
"integrity": "sha512-AMB1mvwR1pyBFY/nSevUX6y8nJWS63/SzUKD3JyQn97s4xgIdgQPT75IRouIiBAN4yLQBUShNYVW0+UG25daCw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-fullwidth-code-point": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/isexe": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/jackspeak": {
|
||||||
|
"version": "2.3.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz",
|
||||||
|
"integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@isaacs/cliui": "^8.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@pkgjs/parseargs": "^0.11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/js-yaml": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"argparse": "^2.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"js-yaml": "bin/js-yaml.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/jsonc-parser": {
|
||||||
|
"version": "3.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz",
|
||||||
|
"integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/jsonpointer": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/linkify-it": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"uc.micro": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lru-cache": {
|
||||||
|
"version": "10.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz",
|
||||||
|
"integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": "14 || >=16.14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/markdown-it": {
|
||||||
|
"version": "14.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz",
|
||||||
|
"integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"argparse": "^2.0.1",
|
||||||
|
"entities": "^4.4.0",
|
||||||
|
"linkify-it": "^5.0.0",
|
||||||
|
"mdurl": "^2.0.0",
|
||||||
|
"punycode.js": "^2.3.1",
|
||||||
|
"uc.micro": "^2.1.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"markdown-it": "bin/markdown-it.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/markdownlint": {
|
||||||
|
"version": "0.34.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.34.0.tgz",
|
||||||
|
"integrity": "sha512-qwGyuyKwjkEMOJ10XN6OTKNOVYvOIi35RNvDLNxTof5s8UmyGHlCdpngRHoRGNvQVGuxO3BJ7uNSgdeX166WXw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"markdown-it": "14.1.0",
|
||||||
|
"markdownlint-micromark": "0.1.9"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/DavidAnson"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/markdownlint-cli": {
|
||||||
|
"version": "0.40.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.40.0.tgz",
|
||||||
|
"integrity": "sha512-JXhI3dRQcaqwiFYpPz6VJ7aKYheD53GmTz9y4D/d0F1MbZDGOp9pqKlbOfUX/pHP/iAoeiE4wYRmk8/kjLakxA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"commander": "~12.0.0",
|
||||||
|
"get-stdin": "~9.0.0",
|
||||||
|
"glob": "~10.3.12",
|
||||||
|
"ignore": "~5.3.1",
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
|
"jsonc-parser": "~3.2.1",
|
||||||
|
"jsonpointer": "5.0.1",
|
||||||
|
"markdownlint": "~0.34.0",
|
||||||
|
"minimatch": "~9.0.4",
|
||||||
|
"run-con": "~1.3.2",
|
||||||
|
"toml": "~3.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"markdownlint": "markdownlint.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/markdownlint-micromark": {
|
||||||
|
"version": "0.1.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/markdownlint-micromark/-/markdownlint-micromark-0.1.9.tgz",
|
||||||
|
"integrity": "sha512-5hVs/DzAFa8XqYosbEAEg6ok6MF2smDj89ztn9pKkCtdKHVdPQuGMH7frFfYL9mLkvfFe4pTyAMffLbjf3/EyA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/DavidAnson"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdurl": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/minimatch": {
|
||||||
|
"version": "9.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz",
|
||||||
|
"integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16 || 14 >=14.17"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/minimist": {
|
||||||
|
"version": "1.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||||
|
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/minipass": {
|
||||||
|
"version": "7.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.1.tgz",
|
||||||
|
"integrity": "sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16 || 14 >=14.17"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/path-key": {
|
||||||
|
"version": "3.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||||
|
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/path-scurry": {
|
||||||
|
"version": "1.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.0.tgz",
|
||||||
|
"integrity": "sha512-LNHTaVkzaYaLGlO+0u3rQTz7QrHTFOuKyba9JMTQutkmtNew8dw8wOD7mTU/5fCPZzCWpfW0XnQKzY61P0aTaw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": "^10.2.0",
|
||||||
|
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16 || 14 >=14.17"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "3.2.5",
|
"version": "3.2.5",
|
||||||
"license": "MIT",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",
|
||||||
|
"integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==",
|
||||||
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"prettier": "bin/prettier.cjs"
|
"prettier": "bin/prettier.cjs"
|
||||||
},
|
},
|
||||||
@ -22,6 +451,289 @@
|
|||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/punycode.js": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/run-con": {
|
||||||
|
"version": "1.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/run-con/-/run-con-1.3.2.tgz",
|
||||||
|
"integrity": "sha512-CcfE+mYiTcKEzg0IqS08+efdnH0oJ3zV0wSUFBNrMHMuxCtXvBCLzCJHatwuXDcu/RlhjTziTo/a1ruQik6/Yg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"deep-extend": "^0.6.0",
|
||||||
|
"ini": "~4.1.0",
|
||||||
|
"minimist": "^1.2.8",
|
||||||
|
"strip-json-comments": "~3.1.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"run-con": "cli.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/shebang-command": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"shebang-regex": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/shebang-regex": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/signal-exit": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/string-width": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"eastasianwidth": "^0.2.0",
|
||||||
|
"emoji-regex": "^9.2.2",
|
||||||
|
"strip-ansi": "^7.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/string-width-cjs": {
|
||||||
|
"name": "string-width",
|
||||||
|
"version": "4.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||||
|
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"emoji-regex": "^8.0.0",
|
||||||
|
"is-fullwidth-code-point": "^3.0.0",
|
||||||
|
"strip-ansi": "^6.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/string-width-cjs/node_modules/ansi-regex": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/string-width-cjs/node_modules/emoji-regex": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||||
|
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/string-width-cjs/node_modules/strip-ansi": {
|
||||||
|
"version": "6.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||||
|
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/strip-ansi": {
|
||||||
|
"version": "7.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
|
||||||
|
"integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": "^6.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/strip-ansi-cjs": {
|
||||||
|
"name": "strip-ansi",
|
||||||
|
"version": "6.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||||
|
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/strip-ansi-cjs/node_modules/ansi-regex": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/strip-json-comments": {
|
||||||
|
"version": "3.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
||||||
|
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/toml": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/uc.micro": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/which": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"isexe": "^2.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"node-which": "bin/node-which"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi": {
|
||||||
|
"version": "8.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
|
||||||
|
"integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-styles": "^6.1.0",
|
||||||
|
"string-width": "^5.0.1",
|
||||||
|
"strip-ansi": "^7.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi-cjs": {
|
||||||
|
"name": "wrap-ansi",
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-styles": "^4.0.0",
|
||||||
|
"string-width": "^4.1.0",
|
||||||
|
"strip-ansi": "^6.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi-cjs/node_modules/ansi-regex": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi-cjs/node_modules/ansi-styles": {
|
||||||
|
"version": "4.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||||
|
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"color-convert": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi-cjs/node_modules/emoji-regex": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||||
|
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi-cjs/node_modules/string-width": {
|
||||||
|
"version": "4.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||||
|
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"emoji-regex": "^8.0.0",
|
||||||
|
"is-fullwidth-code-point": "^3.0.0",
|
||||||
|
"strip-ansi": "^6.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi-cjs/node_modules/strip-ansi": {
|
||||||
|
"version": "6.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||||
|
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "tildefriends",
|
"name": "tildefriends",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prettier": "prettier . --check --cache --write"
|
"format": "npm run prettier && npm run markdown",
|
||||||
|
"prettier": "npx prettier --cache --write --check .",
|
||||||
|
"markdown": "npx markdownlint-cli --fix 'docs/**/*.md'"
|
||||||
},
|
},
|
||||||
"author": "Cory McWilliams",
|
"author": "Cory McWilliams",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^3.2.5"
|
"markdownlint-cli": "0.40.0",
|
||||||
|
"prettier": "3.2.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
175
src/httpd.js.c
175
src/httpd.js.c
@ -498,6 +498,151 @@ static JSValue _httpd_auth_query(JSContext* context, JSValueConst this_val, int
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct _magic_bytes_t
|
||||||
|
{
|
||||||
|
const char* type;
|
||||||
|
uint8_t bytes[12];
|
||||||
|
uint8_t ignore[12];
|
||||||
|
} magic_bytes_t;
|
||||||
|
|
||||||
|
static bool _magic_bytes_match(const magic_bytes_t* magic, const uint8_t* actual, size_t size)
|
||||||
|
{
|
||||||
|
if (size < sizeof(magic->bytes))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int length = (int)tf_min(sizeof(magic->bytes), size);
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
if ((magic->bytes[i] & ~magic->ignore[i]) != (actual[i] & ~magic->ignore[i]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static JSValue _httpd_mime_type_from_magic_bytes(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||||
|
{
|
||||||
|
JSValue result = JS_UNDEFINED;
|
||||||
|
size_t size = 0;
|
||||||
|
uint8_t* bytes = tf_util_try_get_array_buffer(context, &size, argv[0]);
|
||||||
|
if (bytes)
|
||||||
|
{
|
||||||
|
|
||||||
|
const magic_bytes_t k_magic_bytes[] = {
|
||||||
|
{
|
||||||
|
.type = "image/jpeg",
|
||||||
|
.bytes = { 0xff, 0xd8, 0xff, 0xdb },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "image/jpeg",
|
||||||
|
.bytes = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "image/jpeg",
|
||||||
|
.bytes = { 0xff, 0xd8, 0xff, 0xee },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "image/jpeg",
|
||||||
|
.bytes = { 0xff, 0xd8, 0xff, 0xe1, 0x00, 0x00, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 },
|
||||||
|
.ignore = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "image/png",
|
||||||
|
.bytes = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "image/gif",
|
||||||
|
.bytes = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "image/gif",
|
||||||
|
.bytes = { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "image/webp",
|
||||||
|
.bytes = { 0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50 },
|
||||||
|
.ignore = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "image/svg+xml",
|
||||||
|
.bytes = { 0x3c, 0x73, 0x76, 0x67 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "audio/mpeg",
|
||||||
|
.bytes = { 0x00, 0x00, 0x00, 0x00, 0x66, 0x74, 0x79, 0x70, 0x6d, 0x70, 0x34, 0x32 },
|
||||||
|
.ignore = { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "video/mp4",
|
||||||
|
.bytes = { 0x00, 0x00, 0x00, 0x00, 0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6f, 0x6d },
|
||||||
|
.ignore = { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "video/mp4",
|
||||||
|
.bytes = { 0x00, 0x00, 0x00, 0x00, 0x66, 0x74, 0x79, 0x70, 0x6d, 0x70, 0x34, 0x32 },
|
||||||
|
.ignore = { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.type = "audio/midi",
|
||||||
|
.bytes = { 0x4d, 0x54, 0x68, 0x64 },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < tf_countof(k_magic_bytes); i++)
|
||||||
|
{
|
||||||
|
if (_magic_bytes_match(&k_magic_bytes[i], bytes, size))
|
||||||
|
{
|
||||||
|
result = JS_NewString(context, k_magic_bytes[i].type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* _ext_to_content_type(const char* ext, bool use_fallback)
|
||||||
|
{
|
||||||
|
if (ext)
|
||||||
|
{
|
||||||
|
typedef struct _ext_type_t
|
||||||
|
{
|
||||||
|
const char* ext;
|
||||||
|
const char* type;
|
||||||
|
} ext_type_t;
|
||||||
|
|
||||||
|
const ext_type_t k_types[] = {
|
||||||
|
{ .ext = ".html", .type = "text/html; charset=UTF-8" },
|
||||||
|
{ .ext = ".js", .type = "text/javascript; charset=UTF-8" },
|
||||||
|
{ .ext = ".mjs", .type = "text/javascript; charset=UTF-8" },
|
||||||
|
{ .ext = ".css", .type = "text/css; charset=UTF-8" },
|
||||||
|
{ .ext = ".png", .type = "image/png" },
|
||||||
|
{ .ext = ".json", .type = "application/json" },
|
||||||
|
{ .ext = ".map", .type = "application/json" },
|
||||||
|
{ .ext = ".svg", .type = "image/svg+xml" },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < tf_countof(k_types); i++)
|
||||||
|
{
|
||||||
|
if (strcmp(ext, k_types[i].ext) == 0)
|
||||||
|
{
|
||||||
|
return k_types[i].type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return use_fallback ? "application/binary" : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static JSValue _httpd_mime_type_from_extension(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||||
|
{
|
||||||
|
const char* name = JS_ToCString(context, argv[0]);
|
||||||
|
const char* type = _ext_to_content_type(strrchr(name, '.'), false);
|
||||||
|
JS_FreeCString(context, name);
|
||||||
|
return type ? JS_NewString(context, type) : JS_UNDEFINED;
|
||||||
|
}
|
||||||
|
|
||||||
static void _httpd_finalizer(JSRuntime* runtime, JSValue value)
|
static void _httpd_finalizer(JSRuntime* runtime, JSValue value)
|
||||||
{
|
{
|
||||||
tf_http_t* http = JS_GetOpaque(value, _httpd_class_id);
|
tf_http_t* http = JS_GetOpaque(value, _httpd_class_id);
|
||||||
@ -627,30 +772,6 @@ typedef struct _http_file_t
|
|||||||
char etag[512];
|
char etag[512];
|
||||||
} http_file_t;
|
} http_file_t;
|
||||||
|
|
||||||
static const char* _ext_to_content_type(const char* ext)
|
|
||||||
{
|
|
||||||
if (ext)
|
|
||||||
{
|
|
||||||
if (strcmp(ext, ".html") == 0)
|
|
||||||
{
|
|
||||||
return "text/html; charset=UTF-8";
|
|
||||||
}
|
|
||||||
else if (strcmp(ext, ".js") == 0 || strcmp(ext, ".mjs") == 0)
|
|
||||||
{
|
|
||||||
return "text/javascript; charset=UTF-8";
|
|
||||||
}
|
|
||||||
else if (strcmp(ext, ".css") == 0)
|
|
||||||
{
|
|
||||||
return "text/css; charset=UTF-8";
|
|
||||||
}
|
|
||||||
else if (strcmp(ext, ".png") == 0)
|
|
||||||
{
|
|
||||||
return "image/png";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "application/binary";
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _httpd_endpoint_static_read(tf_task_t* task, const char* path, int result, const void* data, void* user_data)
|
static void _httpd_endpoint_static_read(tf_task_t* task, const char* path, int result, const void* data, void* user_data)
|
||||||
{
|
{
|
||||||
http_file_t* file = user_data;
|
http_file_t* file = user_data;
|
||||||
@ -659,7 +780,7 @@ static void _httpd_endpoint_static_read(tf_task_t* task, const char* path, int r
|
|||||||
{
|
{
|
||||||
if (strcmp(path, "core/tfrpc.js") == 0)
|
if (strcmp(path, "core/tfrpc.js") == 0)
|
||||||
{
|
{
|
||||||
const char* content_type = _ext_to_content_type(strrchr(path, '.'));
|
const char* content_type = _ext_to_content_type(strrchr(path, '.'), true);
|
||||||
const char* headers[] = {
|
const char* headers[] = {
|
||||||
"Content-Type",
|
"Content-Type",
|
||||||
content_type,
|
content_type,
|
||||||
@ -672,7 +793,7 @@ static void _httpd_endpoint_static_read(tf_task_t* task, const char* path, int r
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char* content_type = _ext_to_content_type(strrchr(path, '.'));
|
const char* content_type = _ext_to_content_type(strrchr(path, '.'), true);
|
||||||
const char* headers[] = {
|
const char* headers[] = {
|
||||||
"Content-Type",
|
"Content-Type",
|
||||||
content_type,
|
content_type,
|
||||||
@ -1519,6 +1640,8 @@ void tf_httpd_register(JSContext* context)
|
|||||||
JS_SetPropertyStr(context, httpd, "start", JS_NewCFunction(context, _httpd_endpoint_start, "start", 2));
|
JS_SetPropertyStr(context, httpd, "start", JS_NewCFunction(context, _httpd_endpoint_start, "start", 2));
|
||||||
JS_SetPropertyStr(context, httpd, "set_http_redirect", JS_NewCFunction(context, _httpd_set_http_redirect, "set_http_redirect", 1));
|
JS_SetPropertyStr(context, httpd, "set_http_redirect", JS_NewCFunction(context, _httpd_set_http_redirect, "set_http_redirect", 1));
|
||||||
JS_SetPropertyStr(context, httpd, "auth_query", JS_NewCFunction(context, _httpd_auth_query, "auth_query", 1));
|
JS_SetPropertyStr(context, httpd, "auth_query", JS_NewCFunction(context, _httpd_auth_query, "auth_query", 1));
|
||||||
|
JS_SetPropertyStr(context, httpd, "mime_type_from_magic_bytes", JS_NewCFunction(context, _httpd_mime_type_from_magic_bytes, "mime_type_from_magic_bytes", 1));
|
||||||
|
JS_SetPropertyStr(context, httpd, "mime_type_from_extension", JS_NewCFunction(context, _httpd_mime_type_from_extension, "mime_type_from_extension", 1));
|
||||||
JS_SetPropertyStr(context, global, "httpd", httpd);
|
JS_SetPropertyStr(context, global, "httpd", httpd);
|
||||||
JS_FreeValue(context, global);
|
JS_FreeValue(context, global);
|
||||||
}
|
}
|
||||||
|
93
src/ssb.c
93
src/ssb.c
@ -342,6 +342,8 @@ typedef struct _tf_ssb_connection_t
|
|||||||
|
|
||||||
tf_ssb_debug_message_t* debug_messages[k_debug_close_message_count];
|
tf_ssb_debug_message_t* debug_messages[k_debug_close_message_count];
|
||||||
int ref_count;
|
int ref_count;
|
||||||
|
|
||||||
|
int read_back_pressure;
|
||||||
} tf_ssb_connection_t;
|
} tf_ssb_connection_t;
|
||||||
|
|
||||||
static JSClassID _connection_class_id;
|
static JSClassID _connection_class_id;
|
||||||
@ -1618,6 +1620,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
|||||||
}
|
}
|
||||||
if (!found && !_tf_ssb_name_equals(context, val, (const char*[]) { "Error", NULL }))
|
if (!found && !_tf_ssb_name_equals(context, val, (const char*[]) { "Error", NULL }))
|
||||||
{
|
{
|
||||||
|
tf_ssb_connection_add_request(connection, -request_number, namebuf, NULL, NULL, NULL, NULL);
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
_tf_ssb_name_to_string(context, val, buffer, sizeof(buffer));
|
_tf_ssb_name_to_string(context, val, buffer, sizeof(buffer));
|
||||||
tf_ssb_connection_rpc_send_error_method_not_allowed(connection, flags, -request_number, buffer);
|
tf_ssb_connection_rpc_send_error_method_not_allowed(connection, flags, -request_number, buffer);
|
||||||
@ -2061,6 +2064,30 @@ static void _tf_ssb_connection_client_send_hello(tf_ssb_connection_t* connection
|
|||||||
connection->state = k_tf_ssb_state_sent_hello;
|
connection->state = k_tf_ssb_state_sent_hello;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _tf_ssb_connection_read_start(tf_ssb_connection_t* connection)
|
||||||
|
{
|
||||||
|
int result = uv_read_start((uv_stream_t*)&connection->tcp, _tf_ssb_connection_on_tcp_alloc, _tf_ssb_connection_on_tcp_recv);
|
||||||
|
if (result && result != UV_EALREADY)
|
||||||
|
{
|
||||||
|
tf_printf("uv_read_start => %s\n", uv_strerror(result));
|
||||||
|
_tf_ssb_connection_close(connection, "uv_read_start failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool _tf_ssb_connection_read_stop(tf_ssb_connection_t* connection)
|
||||||
|
{
|
||||||
|
int result = uv_read_stop((uv_stream_t*)&connection->tcp);
|
||||||
|
if (result && result != UV_EALREADY)
|
||||||
|
{
|
||||||
|
tf_printf("uv_read_stop => %s\n", uv_strerror(result));
|
||||||
|
_tf_ssb_connection_close(connection, "uv_read_stop failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void _tf_ssb_connection_on_connect(uv_connect_t* connect, int status)
|
static void _tf_ssb_connection_on_connect(uv_connect_t* connect, int status)
|
||||||
{
|
{
|
||||||
tf_ssb_connection_t* connection = connect->data;
|
tf_ssb_connection_t* connection = connect->data;
|
||||||
@ -2068,13 +2095,7 @@ static void _tf_ssb_connection_on_connect(uv_connect_t* connect, int status)
|
|||||||
if (status == 0)
|
if (status == 0)
|
||||||
{
|
{
|
||||||
connection->state = k_tf_ssb_state_connected;
|
connection->state = k_tf_ssb_state_connected;
|
||||||
int result = uv_read_start(connect->handle, _tf_ssb_connection_on_tcp_alloc, _tf_ssb_connection_on_tcp_recv);
|
if (_tf_ssb_connection_read_start(connection))
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
tf_printf("uv_read_start => %s\n", uv_strerror(status));
|
|
||||||
_tf_ssb_connection_close(connection, "uv_read_start failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
_tf_ssb_connection_client_send_hello(connection);
|
_tf_ssb_connection_client_send_hello(connection);
|
||||||
}
|
}
|
||||||
@ -2565,6 +2586,11 @@ void tf_ssb_destroy(tf_ssb_t* ssb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tf_ssb_is_shutting_down(tf_ssb_t* ssb)
|
||||||
|
{
|
||||||
|
return ssb->shutting_down;
|
||||||
|
}
|
||||||
|
|
||||||
void tf_ssb_run(tf_ssb_t* ssb)
|
void tf_ssb_run(tf_ssb_t* ssb)
|
||||||
{
|
{
|
||||||
uv_run(ssb->loop, UV_RUN_DEFAULT);
|
uv_run(ssb->loop, UV_RUN_DEFAULT);
|
||||||
@ -2722,22 +2748,30 @@ typedef struct _connect_t
|
|||||||
static void _tf_on_connect_getaddrinfo(uv_getaddrinfo_t* addrinfo, int result, struct addrinfo* info)
|
static void _tf_on_connect_getaddrinfo(uv_getaddrinfo_t* addrinfo, int result, struct addrinfo* info)
|
||||||
{
|
{
|
||||||
connect_t* connect = addrinfo->data;
|
connect_t* connect = addrinfo->data;
|
||||||
if (result == 0 && info)
|
if (!connect->ssb->shutting_down)
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr = *(struct sockaddr_in*)info->ai_addr;
|
if (result == 0 && info)
|
||||||
addr.sin_port = htons(connect->port);
|
{
|
||||||
tf_ssb_connection_create(connect->ssb, connect->host, &addr, connect->key);
|
struct sockaddr_in addr = *(struct sockaddr_in*)info->ai_addr;
|
||||||
|
addr.sin_port = htons(connect->port);
|
||||||
|
tf_ssb_connection_create(connect->ssb, connect->host, &addr, connect->key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tf_printf("getaddrinfo(%s) => %s\n", connect->host, uv_strerror(result));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
tf_printf("getaddrinfo(%s) => %s\n", connect->host, uv_strerror(result));
|
|
||||||
}
|
|
||||||
tf_free(connect);
|
|
||||||
uv_freeaddrinfo(info);
|
uv_freeaddrinfo(info);
|
||||||
|
tf_ssb_unref(connect->ssb);
|
||||||
|
tf_free(connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tf_ssb_connect(tf_ssb_t* ssb, const char* host, int port, const uint8_t* key)
|
void tf_ssb_connect(tf_ssb_t* ssb, const char* host, int port, const uint8_t* key)
|
||||||
{
|
{
|
||||||
|
if (ssb->shutting_down)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
connect_t* connect = tf_malloc(sizeof(connect_t));
|
connect_t* connect = tf_malloc(sizeof(connect_t));
|
||||||
*connect = (connect_t) {
|
*connect = (connect_t) {
|
||||||
.ssb = ssb,
|
.ssb = ssb,
|
||||||
@ -2749,11 +2783,13 @@ void tf_ssb_connect(tf_ssb_t* ssb, const char* host, int port, const uint8_t* ke
|
|||||||
tf_ssb_connections_store(ssb->connections_tracker, host, port, id);
|
tf_ssb_connections_store(ssb->connections_tracker, host, port, id);
|
||||||
snprintf(connect->host, sizeof(connect->host), "%s", host);
|
snprintf(connect->host, sizeof(connect->host), "%s", host);
|
||||||
memcpy(connect->key, key, k_id_bin_len);
|
memcpy(connect->key, key, k_id_bin_len);
|
||||||
|
tf_ssb_ref(ssb);
|
||||||
int r = uv_getaddrinfo(ssb->loop, &connect->req, _tf_on_connect_getaddrinfo, host, NULL, &(struct addrinfo) { .ai_family = AF_INET });
|
int r = uv_getaddrinfo(ssb->loop, &connect->req, _tf_on_connect_getaddrinfo, host, NULL, &(struct addrinfo) { .ai_family = AF_INET });
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
{
|
{
|
||||||
tf_printf("uv_getaddrinfo: %s\n", uv_strerror(r));
|
tf_printf("uv_getaddrinfo: %s\n", uv_strerror(r));
|
||||||
tf_free(connect);
|
tf_free(connect);
|
||||||
|
tf_ssb_unref(ssb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2810,7 +2846,7 @@ static void _tf_ssb_on_connection(uv_stream_t* stream, int status)
|
|||||||
_tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection);
|
_tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection);
|
||||||
|
|
||||||
connection->state = k_tf_ssb_state_server_wait_hello;
|
connection->state = k_tf_ssb_state_server_wait_hello;
|
||||||
uv_read_start((uv_stream_t*)&connection->tcp, _tf_ssb_connection_on_tcp_alloc, _tf_ssb_connection_on_tcp_recv);
|
_tf_ssb_connection_read_start(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address, struct sockaddr_in* netmask)
|
static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address, struct sockaddr_in* netmask)
|
||||||
@ -4049,3 +4085,26 @@ JSValue tf_ssb_connection_requests_to_object(tf_ssb_connection_t* connection)
|
|||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t* connection, int delta)
|
||||||
|
{
|
||||||
|
const int k_threshold = 256;
|
||||||
|
int old_pressure = connection->read_back_pressure;
|
||||||
|
connection->read_back_pressure += delta;
|
||||||
|
if (!connection->closing)
|
||||||
|
{
|
||||||
|
if (old_pressure < k_threshold && connection->read_back_pressure >= k_threshold)
|
||||||
|
{
|
||||||
|
_tf_ssb_connection_read_stop(connection);
|
||||||
|
}
|
||||||
|
else if (old_pressure >= k_threshold && connection->read_back_pressure < k_threshold)
|
||||||
|
{
|
||||||
|
_tf_ssb_connection_read_start(connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connection->ref_count += delta;
|
||||||
|
if (connection->ref_count == 0 && connection->closing)
|
||||||
|
{
|
||||||
|
_tf_ssb_connection_destroy(connection, "backpressure released");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -86,6 +86,10 @@ typedef struct _tf_ssb_connections_get_next_t
|
|||||||
static void _tf_ssb_connections_get_next_work(tf_ssb_t* ssb, void* user_data)
|
static void _tf_ssb_connections_get_next_work(tf_ssb_t* ssb, void* user_data)
|
||||||
{
|
{
|
||||||
tf_ssb_connections_get_next_t* next = user_data;
|
tf_ssb_connections_get_next_t* next = user_data;
|
||||||
|
if (tf_ssb_is_shutting_down(ssb))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
next->ready = _tf_ssb_connections_get_next_connection(next->connections, next->host, sizeof(next->host), &next->port, next->key, sizeof(next->key));
|
next->ready = _tf_ssb_connections_get_next_connection(next->connections, next->host, sizeof(next->host), &next->port, next->key, sizeof(next->key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +163,10 @@ typedef struct _tf_ssb_connections_update_t
|
|||||||
static void _tf_ssb_connections_update_work(tf_ssb_t* ssb, void* user_data)
|
static void _tf_ssb_connections_update_work(tf_ssb_t* ssb, void* user_data)
|
||||||
{
|
{
|
||||||
tf_ssb_connections_update_t* update = user_data;
|
tf_ssb_connections_update_t* update = user_data;
|
||||||
|
if (tf_ssb_is_shutting_down(ssb))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
sqlite3_stmt* statement;
|
sqlite3_stmt* statement;
|
||||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||||
if (update->attempted)
|
if (update->attempted)
|
||||||
|
16
src/ssb.h
16
src/ssb.h
@ -144,6 +144,13 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path
|
|||||||
*/
|
*/
|
||||||
void tf_ssb_destroy(tf_ssb_t* ssb);
|
void tf_ssb_destroy(tf_ssb_t* ssb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
** Checking if the SSB instance is in the process of shutting down.
|
||||||
|
** @param ssb The SSB instance.
|
||||||
|
** @return true If the SSB instance is shutting down.
|
||||||
|
*/
|
||||||
|
bool tf_ssb_is_shutting_down(tf_ssb_t* ssb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Start optional periodic work.
|
** Start optional periodic work.
|
||||||
** @param ssb The SSB instance.
|
** @param ssb The SSB instance.
|
||||||
@ -989,4 +996,13 @@ void tf_ssb_schedule_work(tf_ssb_t* ssb, int delay_ms, void (*callback)(tf_ssb_t
|
|||||||
*/
|
*/
|
||||||
bool tf_ssb_hmacsha256_verify(const char* public_key, const void* payload, size_t payload_length, const char* signature, bool signature_is_urlb64);
|
bool tf_ssb_hmacsha256_verify(const char* public_key, const void* payload, size_t payload_length, const char* signature, bool signature_is_urlb64);
|
||||||
|
|
||||||
|
/**
|
||||||
|
** Adjust read backpressure. If it gets too high, TCP receive will be paused
|
||||||
|
** until it lowers.
|
||||||
|
** @param connection The connection on which to affect backpressure.
|
||||||
|
** @param delta The change in backpressure. Higher will eventually pause
|
||||||
|
** receive. Lower will resume it.
|
||||||
|
*/
|
||||||
|
void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t* connection, int delta);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -1889,7 +1889,7 @@ void tf_ssb_register(JSContext* context, tf_ssb_t* ssb)
|
|||||||
JS_SetPropertyStr(context, object, "storeMessage", JS_NewCFunction(context, _tf_ssb_storeMessage, "storeMessage", 1));
|
JS_SetPropertyStr(context, object, "storeMessage", JS_NewCFunction(context, _tf_ssb_storeMessage, "storeMessage", 1));
|
||||||
JS_SetPropertyStr(context, object, "blobStore", JS_NewCFunction(context, _tf_ssb_blobStore, "blobStore", 1));
|
JS_SetPropertyStr(context, object, "blobStore", JS_NewCFunction(context, _tf_ssb_blobStore, "blobStore", 1));
|
||||||
|
|
||||||
/* Should be trusted only. */
|
/* Trusted only. */
|
||||||
JS_SetPropertyStr(context, object, "addEventListener", JS_NewCFunction(context, _tf_ssb_add_event_listener, "addEventListener", 2));
|
JS_SetPropertyStr(context, object, "addEventListener", JS_NewCFunction(context, _tf_ssb_add_event_listener, "addEventListener", 2));
|
||||||
JS_SetPropertyStr(context, object, "removeEventListener", JS_NewCFunction(context, _tf_ssb_remove_event_listener, "removeEventListener", 2));
|
JS_SetPropertyStr(context, object, "removeEventListener", JS_NewCFunction(context, _tf_ssb_remove_event_listener, "removeEventListener", 2));
|
||||||
|
|
||||||
|
@ -404,6 +404,7 @@ typedef struct _blobs_get_t
|
|||||||
bool done;
|
bool done;
|
||||||
bool storing;
|
bool storing;
|
||||||
tf_ssb_t* ssb;
|
tf_ssb_t* ssb;
|
||||||
|
tf_ssb_connection_t* connection;
|
||||||
uint8_t buffer[];
|
uint8_t buffer[];
|
||||||
} blobs_get_t;
|
} blobs_get_t;
|
||||||
|
|
||||||
@ -411,6 +412,7 @@ static void _tf_ssb_rpc_blob_store_callback(const char* id, bool is_new, void* u
|
|||||||
{
|
{
|
||||||
blobs_get_t* get = user_data;
|
blobs_get_t* get = user_data;
|
||||||
get->storing = false;
|
get->storing = false;
|
||||||
|
tf_ssb_connection_adjust_read_backpressure(get->connection, -1);
|
||||||
if (get->done)
|
if (get->done)
|
||||||
{
|
{
|
||||||
tf_free(get);
|
tf_free(get);
|
||||||
@ -433,6 +435,7 @@ static void _tf_ssb_rpc_connection_blobs_get_callback(
|
|||||||
if (JS_ToBool(context, args))
|
if (JS_ToBool(context, args))
|
||||||
{
|
{
|
||||||
get->storing = true;
|
get->storing = true;
|
||||||
|
tf_ssb_connection_adjust_read_backpressure(connection, 1);
|
||||||
tf_ssb_db_blob_store_async(ssb, get->buffer, get->received, _tf_ssb_rpc_blob_store_callback, get);
|
tf_ssb_db_blob_store_async(ssb, get->buffer, get->received, _tf_ssb_rpc_blob_store_callback, get);
|
||||||
}
|
}
|
||||||
/* TODO: Should we send the response in the callback? */
|
/* TODO: Should we send the response in the callback? */
|
||||||
@ -455,7 +458,7 @@ static void _tf_ssb_rpc_connection_blobs_get_cleanup(tf_ssb_t* ssb, void* user_d
|
|||||||
static void _tf_ssb_rpc_connection_blobs_get(tf_ssb_connection_t* connection, const char* blob_id, size_t size)
|
static void _tf_ssb_rpc_connection_blobs_get(tf_ssb_connection_t* connection, const char* blob_id, size_t size)
|
||||||
{
|
{
|
||||||
blobs_get_t* get = tf_malloc(sizeof(blobs_get_t) + size);
|
blobs_get_t* get = tf_malloc(sizeof(blobs_get_t) + size);
|
||||||
*get = (blobs_get_t) { .ssb = tf_ssb_connection_get_ssb(connection), .expected_size = size };
|
*get = (blobs_get_t) { .ssb = tf_ssb_connection_get_ssb(connection), .connection = connection, .expected_size = size };
|
||||||
snprintf(get->id, sizeof(get->id), "%s", blob_id);
|
snprintf(get->id, sizeof(get->id), "%s", blob_id);
|
||||||
memset(get->buffer, 0, size);
|
memset(get->buffer, 0, size);
|
||||||
|
|
||||||
@ -1000,6 +1003,12 @@ static void _tf_ssb_rpc_ebt_replicate_send_messages(tf_ssb_connection_t* connect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _tf_ssb_rpc_ebt_replicate_store_callback(const char* id, bool verified, bool is_new, void* user_data)
|
||||||
|
{
|
||||||
|
tf_ssb_connection_t* connection = user_data;
|
||||||
|
tf_ssb_connection_adjust_read_backpressure(connection, -1);
|
||||||
|
}
|
||||||
|
|
||||||
static void _tf_ssb_rpc_ebt_replicate(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data)
|
static void _tf_ssb_rpc_ebt_replicate(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data)
|
||||||
{
|
{
|
||||||
tf_ssb_t* ssb = tf_ssb_connection_get_ssb(connection);
|
tf_ssb_t* ssb = tf_ssb_connection_get_ssb(connection);
|
||||||
@ -1022,7 +1031,8 @@ static void _tf_ssb_rpc_ebt_replicate(tf_ssb_connection_t* connection, uint8_t f
|
|||||||
if (!JS_IsUndefined(author))
|
if (!JS_IsUndefined(author))
|
||||||
{
|
{
|
||||||
/* Looks like a message. */
|
/* Looks like a message. */
|
||||||
tf_ssb_verify_strip_and_store_message(ssb, args, NULL, NULL);
|
tf_ssb_connection_adjust_read_backpressure(connection, 1);
|
||||||
|
tf_ssb_verify_strip_and_store_message(ssb, args, _tf_ssb_rpc_ebt_replicate_store_callback, connection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user