From ddd2787b731d71adaa51f37b895a72ec4322fc27 Mon Sep 17 00:00:00 2001 From: SITO Date: Wed, 19 Aug 2026 00:35:08 +0200 Subject: [PATCH] Oasis 0.9.5 con Karvan para escritorio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rama de desarrollo experimental sobre el Oasis de epsylon, sin afiliacion con el proyecto original. Base: 0.9.5. Trae el modulo Karvan —salas efimeras en memoria con autodestruccion por TTL, chat que funciona sin JavaScript y llamadas de audio y video sobre WebRTC— con el enlace en el menu lateral por el mismo patron que el resto de modulos: renderKarvanLink calcado de renderPollsLink, entrada en modules_view y en la lista de /modules. Los estilos del modulo van en su propia hoja, styles/karvan.css, siguiendo el patron de highlight.css: asi se ve igual con cualquier tema, sin depender del tema movil. Sin servidores ICE de terceros: no hay STUN de fabrica, porque un STUN aprende la IP publica y el momento de cada llamada. Solo candidatos host salvo que se configure un TURN propio en oasis-config.json, con credenciales efimeras por el mecanismo REST de coturn. El codigo propio vive separado —views/fork/, backend/fork_routes.js, models/karvan_model.js y translations/fork/— de modo que sobre los ficheros de upstream solo hay enganches de una linea y cada version nueva se integra sin arrastrar nada. Respecto al arbol de Android: fuera el wrapper y main.js, que es su arranque; el tema vuelve a Dark-SNH y se restauran los modulos que en movil se recortan por peso. Verificado arrancando sin OASIS_MOBILE: nueve rutas OK, menu lateral de upstream con 27 grupos y el enlace de Karvan, cero rastro de la interfaz movil (ni hexagonos, ni topbar, ni barra inferior), y una sala creada y servida. --- .gitignore | 15 + LICENSE | 661 + README.md | 78 + docs/AI/info.md | 17 + docs/FEDIVERSE/MASTODON/connect.md | 69 + docs/MANIFESTO | 17 + docs/PUB/deploy.md | 221 + docs/PUB/oasis-config.json.example | 78 + docs/PUB/oasis-pub.service | 26 + docs/PUB/server-config.json.example | 65 + docs/devs/architecture/00-README.md | 62 + docs/devs/architecture/01-red-ssb.md | 243 + .../architecture/02-arquitectura-software.md | 350 + docs/devs/architecture/03-modulos-y-juegos.md | 216 + .../04-tutorial-modulo-desde-cero.md | 361 + docs/devs/architecture/05-mapa-funciones.txt | 262 + docs/devs/code-of-conduct.md | 76 + docs/devs/contract.md | 125 + docs/devs/contributing.md | 68 + docs/devs/install.md | 86 + docs/devs/maintaining.md | 35 + docs/install/install.md | 34 + docs/security.md | 33 + install.sh | 128 + oasis.sh | 84 + package.json | 159 + scripts/build-deb.sh | 192 + scripts/generate_shs.js | 4 + scripts/oasis-pub.js | 91 + scripts/patch-node-modules.js | 79 + src/backend/backend.js | 9743 +++++++++ src/backend/blobHandler.js | 308 + src/backend/collab_content.js | 66 + src/backend/contentPdf.js | 280 + src/backend/content_favorites.js | 153 + src/backend/dedupe.js | 52 + src/backend/fileshare_crypto.js | 74 + src/backend/fork_routes.js | 208 + src/backend/logsPdf.js | 206 + src/backend/media-favorites.js | 126 + src/backend/nameCache.js | 20 + src/backend/opinion_categories.js | 50 + src/backend/pdfDocument.js | 199 + src/backend/pm_policy.js | 50 + src/backend/renderTextWithStyles.js | 139 + src/backend/renderUrl.js | 92 + src/backend/sanitizeHtml.js | 45 + src/backend/smartContractPdf.js | 228 + src/backend/turnCredentials.js | 50 + src/backend/updater.js | 121 + src/backend/vote_tally.js | 116 + src/backend/wallet_addresses.js | 17 + src/client/assets/images/anarchy.png | Bin 0 -> 33926 bytes src/client/assets/images/default-avatar.png | Bin 0 -> 354997 bytes src/client/assets/images/default-market.png | Bin 0 -> 167430 bytes src/client/assets/images/default-tribe.png | Bin 0 -> 244056 bytes src/client/assets/images/democracy.png | Bin 0 -> 29550 bytes src/client/assets/images/dictatorship.png | Bin 0 -> 30739 bytes src/client/assets/images/favicon.svg | 4 + src/client/assets/images/karmatocracy.png | Bin 0 -> 36717 bytes src/client/assets/images/majority.png | Bin 0 -> 33470 bytes src/client/assets/images/minority.png | Bin 0 -> 26411 bytes src/client/assets/images/snh-oasis.jpg | Bin 0 -> 53493 bytes src/client/assets/images/world-map.svg | 25 + src/client/assets/images/worldmap-z2.png | Bin 0 -> 135491 bytes src/client/assets/larp/houses.json | 92 + src/client/assets/larp/images/academia.jpg | Bin 0 -> 20452 bytes src/client/assets/larp/images/arrakis.jpg | Bin 0 -> 17030 bytes src/client/assets/larp/images/dogma.jpg | Bin 0 -> 14894 bytes src/client/assets/larp/images/helix.jpg | Bin 0 -> 16289 bytes src/client/assets/larp/images/hermandad.jpg | Bin 0 -> 17429 bytes src/client/assets/larp/images/quark.jpg | Bin 0 -> 15292 bytes src/client/assets/larp/images/solaris.jpg | Bin 0 -> 19047 bytes src/client/assets/larp/images/terraverde.jpg | Bin 0 -> 21767 bytes src/client/assets/larp/images/unsystem.jpg | Bin 0 -> 18395 bytes src/client/assets/styles/highlight.css | 67 + src/client/assets/styles/karvan.css | 88 + src/client/assets/styles/mobile.css | 944 + src/client/assets/styles/style.css | 7603 +++++++ src/client/assets/themes/Clear-SNH.css | 372 + src/client/assets/themes/Dark-SNH.css | 364 + src/client/assets/themes/Matrix-SNH.css | 382 + src/client/assets/themes/OasisMobile.css | 1115 + src/client/assets/themes/Purple-SNH.css | 398 + .../assets/translations/fork/i18n_fork.js | 524 + src/client/assets/translations/i18n.js | 20 + src/client/assets/translations/oasis_ar.js | 3649 ++++ src/client/assets/translations/oasis_de.js | 3645 ++++ src/client/assets/translations/oasis_en.js | 3650 ++++ src/client/assets/translations/oasis_es.js | 3650 ++++ src/client/assets/translations/oasis_eu.js | 3650 ++++ src/client/assets/translations/oasis_fr.js | 3649 ++++ src/client/assets/translations/oasis_hi.js | 3649 ++++ src/client/assets/translations/oasis_it.js | 3650 ++++ src/client/assets/translations/oasis_pt.js | 3650 ++++ src/client/assets/translations/oasis_ru.js | 3649 ++++ src/client/assets/translations/oasis_zh.js | 3650 ++++ src/client/cli-cmd-aliases.js | 10 + src/client/gui.js | 124 + src/client/middleware.js | 212 + src/client/oasis_client.js | 70 + src/client/public/docs/ecoin.md | 115 + src/client/public/js/karvan.js | 316 + src/client/public/js/pdf-viewer.js | 76 + src/client/public/js/pdf.min.mjs | 22 + src/client/public/js/pdf.worker.min.mjs | 22 + src/configs/config-manager.js | 126 + src/configs/content_favorites.json | 27 + src/configs/server-config.json | 61 + src/configs/shared-state.js | 44 + src/games/8ball/index.html | 285 + src/games/8ball/thumbnail.svg | 21 + src/games/arkanoid/index.html | 209 + src/games/arkanoid/thumbnail.svg | 36 + src/games/artillery/index.html | 272 + src/games/artillery/thumbnail.svg | 12 + src/games/asteroids/index.html | 250 + src/games/asteroids/thumbnail.svg | 25 + src/games/audiopendulum/index.html | 693 + src/games/audiopendulum/thumbnail.svg | 31 + src/games/cocoland/index.html | 236 + src/games/cocoland/thumbnail.svg | 26 + src/games/cocoman/index.html | 323 + src/games/cocoman/thumbnail.svg | 22 + src/games/ecoinflow/index.html | 793 + src/games/ecoinflow/thumbnail.svg | 113 + src/games/flipflop/index.html | 238 + src/games/flipflop/thumbnail.svg | 44 + src/games/labyrinth/index.html | 229 + src/games/labyrinth/thumbnail.svg | 16 + src/games/neoninfiltrator/index.html | 351 + src/games/neoninfiltrator/thumbnail.svg | 73 + src/games/pingpong/index.html | 192 + src/games/pingpong/thumbnail.svg | 11 + src/games/rockpaperscissors/index.html | 182 + src/games/rockpaperscissors/thumbnail.svg | 17 + src/games/spaceinvaders/index.html | 234 + src/games/spaceinvaders/thumbnail.svg | 26 + src/games/tetris/index.html | 242 + src/games/tetris/thumbnail.svg | 22 + src/games/tiktaktoe/index.html | 190 + src/games/tiktaktoe/thumbnail.svg | 18 + src/maps/map_renderer.js | 238 + src/models/activity_model.js | 815 + src/models/agenda_model.js | 360 + src/models/audios_model.js | 387 + src/models/banking_model.js | 1436 ++ src/models/blockchain_model.js | 397 + src/models/blog_model.js | 168 + src/models/bookmarking_model.js | 346 + src/models/calendars_model.js | 1105 + src/models/chats_model.js | 909 + src/models/cipher_model.js | 52 + src/models/courts_model.js | 964 + src/models/crypto.js | 552 + src/models/cv_model.js | 185 + src/models/data_model.js | 292 + src/models/dev_model.js | 340 + src/models/documents_model.js | 370 + src/models/events_model.js | 678 + src/models/exportmode_model.js | 52 + src/models/favorites_model.js | 217 + src/models/fediverse_model.js | 409 + src/models/feed_model.js | 435 + src/models/fileshare_model.js | 200 + src/models/forum_model.js | 533 + src/models/games_model.js | 67 + src/models/housing_model.js | 554 + src/models/images_model.js | 339 + src/models/industry_model.js | 993 + src/models/inhabitants_model.js | 533 + src/models/jobs_model.js | 560 + src/models/karvan_model.js | 198 + src/models/larp_model.js | 953 + src/models/legacy_model.js | 97 + src/models/logs_model.js | 380 + src/models/main_models.js | 2372 ++ src/models/maps_model.js | 914 + src/models/market_model.js | 642 + src/models/media_gallery.js | 42 + src/models/melody_model.js | 181 + src/models/mentions_model.js | 171 + src/models/onboarding_model.js | 182 + src/models/opinions_model.js | 284 + src/models/pads_model.js | 871 + src/models/panicmode_model.js | 15 + src/models/parliament_model.js | 1615 ++ src/models/pixelia_model.js | 144 + src/models/pm_model.js | 181 + src/models/polls_model.js | 443 + src/models/polls_model_limits.js | 5 + src/models/projects_model.js | 615 + src/models/recurrence.js | 40 + src/models/reports_model.js | 364 + src/models/search_model.js | 435 + src/models/shops_model.js | 954 + src/models/stats_model.js | 630 + src/models/tags_model.js | 234 + src/models/tasks_model.js | 376 + src/models/tombstone_validator.js | 39 + src/models/torrents_model.js | 378 + src/models/transfers_model.js | 430 + src/models/trending_model.js | 265 + src/models/tribe_crypto.js | 1 + src/models/tribes_content_model.js | 362 + src/models/tribes_model.js | 939 + src/models/videos_model.js | 332 + src/models/viewer_filters.js | 130 + src/models/votes_model.js | 392 + src/models/wallet_model.js | 61 + src/models/workflows_model.js | 104 + src/server/SSB_server.js | 191 + src/server/nodemon.json | 15 + src/server/package-lock.json | 17813 ++++++++++++++++ src/server/package.json | 159 + src/server/ssb_config.js | 31 + src/server/ssb_metadata.js | 141 + src/views/AI_view.js | 95 + src/views/activity_view.js | 2175 ++ src/views/agenda_view.js | 298 + src/views/audio_view.js | 459 + src/views/banking_views.js | 698 + src/views/blockchain_view.js | 554 + src/views/blog_view.js | 179 + src/views/bookmark_view.js | 390 + src/views/calendars_view.js | 442 + src/views/chats_view.js | 545 + src/views/cipher_view.js | 101 + src/views/clearnet_view.js | 310 + src/views/comments_view.js | 77 + src/views/courts_view.js | 1410 ++ src/views/cv_view.js | 232 + src/views/data_view.js | 172 + src/views/dev_view.js | 275 + src/views/document_view.js | 363 + src/views/event_view.js | 556 + src/views/favorites_view.js | 217 + src/views/fediverse_view.js | 229 + src/views/feed_view.js | 328 + src/views/fork/hive_nav.js | 244 + src/views/forum_view.js | 407 + src/views/gallery_view.js | 118 + src/views/games_view.js | 151 + src/views/graphos_view.js | 153 + src/views/housing_view.js | 496 + src/views/image_view.js | 404 + src/views/indexing_view.js | 39 + src/views/industry_view.js | 984 + src/views/inhabitants_view.js | 448 + src/views/invites_view.js | 326 + src/views/jobs_view.js | 758 + src/views/karvan_view.js | 121 + src/views/larp_view.js | 468 + src/views/legacy_view.js | 66 + src/views/logs_view.js | 238 + src/views/main_views.js | 3948 ++++ src/views/maps_view.js | 558 + src/views/markdown.js | 43 + src/views/market_view.js | 692 + src/views/melody_view.js | 144 + src/views/mentions_view.js | 81 + src/views/modules_view.js | 151 + src/views/opinions_view.js | 521 + src/views/pads_view.js | 379 + src/views/parliament_view.js | 987 + src/views/peers_view.js | 144 + src/views/pixelia_view.js | 92 + src/views/pm_view.js | 185 + src/views/polls_view.js | 323 + src/views/projects_view.js | 746 + src/views/report_view.js | 613 + src/views/search_view.js | 688 + src/views/settings_view.js | 391 + src/views/shops_view.js | 666 + src/views/stats_view.js | 520 + src/views/tags_view.js | 97 + src/views/task_view.js | 441 + src/views/torrents_view.js | 356 + src/views/transfer_view.js | 555 + src/views/trending_view.js | 371 + src/views/tribes_view.js | 1993 ++ src/views/video_view.js | 368 + src/views/vote_view.js | 338 + src/views/wallet_view.js | 168 + src/views/welcome_view.js | 196 + test/karvan_model.test.js | 183 + 286 files changed, 157145 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 docs/AI/info.md create mode 100644 docs/FEDIVERSE/MASTODON/connect.md create mode 100644 docs/MANIFESTO create mode 100644 docs/PUB/deploy.md create mode 100644 docs/PUB/oasis-config.json.example create mode 100644 docs/PUB/oasis-pub.service create mode 100644 docs/PUB/server-config.json.example create mode 100644 docs/devs/architecture/00-README.md create mode 100644 docs/devs/architecture/01-red-ssb.md create mode 100644 docs/devs/architecture/02-arquitectura-software.md create mode 100644 docs/devs/architecture/03-modulos-y-juegos.md create mode 100644 docs/devs/architecture/04-tutorial-modulo-desde-cero.md create mode 100644 docs/devs/architecture/05-mapa-funciones.txt create mode 100644 docs/devs/code-of-conduct.md create mode 100644 docs/devs/contract.md create mode 100644 docs/devs/contributing.md create mode 100644 docs/devs/install.md create mode 100644 docs/devs/maintaining.md create mode 100644 docs/install/install.md create mode 100644 docs/security.md create mode 100644 install.sh create mode 100644 oasis.sh create mode 100644 package.json create mode 100755 scripts/build-deb.sh create mode 100644 scripts/generate_shs.js create mode 100644 scripts/oasis-pub.js create mode 100644 scripts/patch-node-modules.js create mode 100644 src/backend/backend.js create mode 100644 src/backend/blobHandler.js create mode 100644 src/backend/collab_content.js create mode 100644 src/backend/contentPdf.js create mode 100644 src/backend/content_favorites.js create mode 100644 src/backend/dedupe.js create mode 100644 src/backend/fileshare_crypto.js create mode 100644 src/backend/fork_routes.js create mode 100644 src/backend/logsPdf.js create mode 100644 src/backend/media-favorites.js create mode 100644 src/backend/nameCache.js create mode 100644 src/backend/opinion_categories.js create mode 100644 src/backend/pdfDocument.js create mode 100644 src/backend/pm_policy.js create mode 100644 src/backend/renderTextWithStyles.js create mode 100644 src/backend/renderUrl.js create mode 100644 src/backend/sanitizeHtml.js create mode 100644 src/backend/smartContractPdf.js create mode 100644 src/backend/turnCredentials.js create mode 100644 src/backend/updater.js create mode 100644 src/backend/vote_tally.js create mode 100644 src/backend/wallet_addresses.js create mode 100644 src/client/assets/images/anarchy.png create mode 100644 src/client/assets/images/default-avatar.png create mode 100644 src/client/assets/images/default-market.png create mode 100644 src/client/assets/images/default-tribe.png create mode 100644 src/client/assets/images/democracy.png create mode 100644 src/client/assets/images/dictatorship.png create mode 100644 src/client/assets/images/favicon.svg create mode 100644 src/client/assets/images/karmatocracy.png create mode 100644 src/client/assets/images/majority.png create mode 100644 src/client/assets/images/minority.png create mode 100644 src/client/assets/images/snh-oasis.jpg create mode 100644 src/client/assets/images/world-map.svg create mode 100644 src/client/assets/images/worldmap-z2.png create mode 100644 src/client/assets/larp/houses.json create mode 100644 src/client/assets/larp/images/academia.jpg create mode 100644 src/client/assets/larp/images/arrakis.jpg create mode 100644 src/client/assets/larp/images/dogma.jpg create mode 100644 src/client/assets/larp/images/helix.jpg create mode 100644 src/client/assets/larp/images/hermandad.jpg create mode 100644 src/client/assets/larp/images/quark.jpg create mode 100644 src/client/assets/larp/images/solaris.jpg create mode 100644 src/client/assets/larp/images/terraverde.jpg create mode 100644 src/client/assets/larp/images/unsystem.jpg create mode 100644 src/client/assets/styles/highlight.css create mode 100644 src/client/assets/styles/karvan.css create mode 100644 src/client/assets/styles/mobile.css create mode 100644 src/client/assets/styles/style.css create mode 100644 src/client/assets/themes/Clear-SNH.css create mode 100644 src/client/assets/themes/Dark-SNH.css create mode 100644 src/client/assets/themes/Matrix-SNH.css create mode 100644 src/client/assets/themes/OasisMobile.css create mode 100644 src/client/assets/themes/Purple-SNH.css create mode 100644 src/client/assets/translations/fork/i18n_fork.js create mode 100644 src/client/assets/translations/i18n.js create mode 100644 src/client/assets/translations/oasis_ar.js create mode 100644 src/client/assets/translations/oasis_de.js create mode 100644 src/client/assets/translations/oasis_en.js create mode 100644 src/client/assets/translations/oasis_es.js create mode 100644 src/client/assets/translations/oasis_eu.js create mode 100644 src/client/assets/translations/oasis_fr.js create mode 100644 src/client/assets/translations/oasis_hi.js create mode 100644 src/client/assets/translations/oasis_it.js create mode 100644 src/client/assets/translations/oasis_pt.js create mode 100644 src/client/assets/translations/oasis_ru.js create mode 100644 src/client/assets/translations/oasis_zh.js create mode 100644 src/client/cli-cmd-aliases.js create mode 100644 src/client/gui.js create mode 100644 src/client/middleware.js create mode 100644 src/client/oasis_client.js create mode 100644 src/client/public/docs/ecoin.md create mode 100644 src/client/public/js/karvan.js create mode 100644 src/client/public/js/pdf-viewer.js create mode 100644 src/client/public/js/pdf.min.mjs create mode 100644 src/client/public/js/pdf.worker.min.mjs create mode 100644 src/configs/config-manager.js create mode 100644 src/configs/content_favorites.json create mode 100644 src/configs/server-config.json create mode 100644 src/configs/shared-state.js create mode 100644 src/games/8ball/index.html create mode 100644 src/games/8ball/thumbnail.svg create mode 100644 src/games/arkanoid/index.html create mode 100644 src/games/arkanoid/thumbnail.svg create mode 100644 src/games/artillery/index.html create mode 100644 src/games/artillery/thumbnail.svg create mode 100644 src/games/asteroids/index.html create mode 100644 src/games/asteroids/thumbnail.svg create mode 100644 src/games/audiopendulum/index.html create mode 100644 src/games/audiopendulum/thumbnail.svg create mode 100644 src/games/cocoland/index.html create mode 100644 src/games/cocoland/thumbnail.svg create mode 100644 src/games/cocoman/index.html create mode 100644 src/games/cocoman/thumbnail.svg create mode 100644 src/games/ecoinflow/index.html create mode 100644 src/games/ecoinflow/thumbnail.svg create mode 100644 src/games/flipflop/index.html create mode 100644 src/games/flipflop/thumbnail.svg create mode 100644 src/games/labyrinth/index.html create mode 100644 src/games/labyrinth/thumbnail.svg create mode 100644 src/games/neoninfiltrator/index.html create mode 100644 src/games/neoninfiltrator/thumbnail.svg create mode 100644 src/games/pingpong/index.html create mode 100644 src/games/pingpong/thumbnail.svg create mode 100644 src/games/rockpaperscissors/index.html create mode 100644 src/games/rockpaperscissors/thumbnail.svg create mode 100644 src/games/spaceinvaders/index.html create mode 100644 src/games/spaceinvaders/thumbnail.svg create mode 100644 src/games/tetris/index.html create mode 100644 src/games/tetris/thumbnail.svg create mode 100644 src/games/tiktaktoe/index.html create mode 100644 src/games/tiktaktoe/thumbnail.svg create mode 100644 src/maps/map_renderer.js create mode 100644 src/models/activity_model.js create mode 100644 src/models/agenda_model.js create mode 100644 src/models/audios_model.js create mode 100644 src/models/banking_model.js create mode 100644 src/models/blockchain_model.js create mode 100644 src/models/blog_model.js create mode 100644 src/models/bookmarking_model.js create mode 100644 src/models/calendars_model.js create mode 100644 src/models/chats_model.js create mode 100644 src/models/cipher_model.js create mode 100644 src/models/courts_model.js create mode 100644 src/models/crypto.js create mode 100644 src/models/cv_model.js create mode 100644 src/models/data_model.js create mode 100644 src/models/dev_model.js create mode 100644 src/models/documents_model.js create mode 100644 src/models/events_model.js create mode 100644 src/models/exportmode_model.js create mode 100644 src/models/favorites_model.js create mode 100644 src/models/fediverse_model.js create mode 100644 src/models/feed_model.js create mode 100644 src/models/fileshare_model.js create mode 100644 src/models/forum_model.js create mode 100644 src/models/games_model.js create mode 100644 src/models/housing_model.js create mode 100644 src/models/images_model.js create mode 100644 src/models/industry_model.js create mode 100644 src/models/inhabitants_model.js create mode 100644 src/models/jobs_model.js create mode 100644 src/models/karvan_model.js create mode 100644 src/models/larp_model.js create mode 100644 src/models/legacy_model.js create mode 100644 src/models/logs_model.js create mode 100644 src/models/main_models.js create mode 100644 src/models/maps_model.js create mode 100644 src/models/market_model.js create mode 100644 src/models/media_gallery.js create mode 100644 src/models/melody_model.js create mode 100644 src/models/mentions_model.js create mode 100644 src/models/onboarding_model.js create mode 100644 src/models/opinions_model.js create mode 100644 src/models/pads_model.js create mode 100644 src/models/panicmode_model.js create mode 100644 src/models/parliament_model.js create mode 100644 src/models/pixelia_model.js create mode 100644 src/models/pm_model.js create mode 100644 src/models/polls_model.js create mode 100644 src/models/polls_model_limits.js create mode 100644 src/models/projects_model.js create mode 100644 src/models/recurrence.js create mode 100644 src/models/reports_model.js create mode 100644 src/models/search_model.js create mode 100644 src/models/shops_model.js create mode 100644 src/models/stats_model.js create mode 100644 src/models/tags_model.js create mode 100644 src/models/tasks_model.js create mode 100644 src/models/tombstone_validator.js create mode 100644 src/models/torrents_model.js create mode 100644 src/models/transfers_model.js create mode 100644 src/models/trending_model.js create mode 100644 src/models/tribe_crypto.js create mode 100644 src/models/tribes_content_model.js create mode 100644 src/models/tribes_model.js create mode 100644 src/models/videos_model.js create mode 100644 src/models/viewer_filters.js create mode 100644 src/models/votes_model.js create mode 100644 src/models/wallet_model.js create mode 100644 src/models/workflows_model.js create mode 100644 src/server/SSB_server.js create mode 100644 src/server/nodemon.json create mode 100644 src/server/package-lock.json create mode 100644 src/server/package.json create mode 100644 src/server/ssb_config.js create mode 100644 src/server/ssb_metadata.js create mode 100644 src/views/AI_view.js create mode 100644 src/views/activity_view.js create mode 100644 src/views/agenda_view.js create mode 100644 src/views/audio_view.js create mode 100644 src/views/banking_views.js create mode 100644 src/views/blockchain_view.js create mode 100644 src/views/blog_view.js create mode 100644 src/views/bookmark_view.js create mode 100644 src/views/calendars_view.js create mode 100644 src/views/chats_view.js create mode 100644 src/views/cipher_view.js create mode 100644 src/views/clearnet_view.js create mode 100644 src/views/comments_view.js create mode 100644 src/views/courts_view.js create mode 100644 src/views/cv_view.js create mode 100644 src/views/data_view.js create mode 100644 src/views/dev_view.js create mode 100644 src/views/document_view.js create mode 100644 src/views/event_view.js create mode 100644 src/views/favorites_view.js create mode 100644 src/views/fediverse_view.js create mode 100644 src/views/feed_view.js create mode 100644 src/views/fork/hive_nav.js create mode 100644 src/views/forum_view.js create mode 100644 src/views/gallery_view.js create mode 100644 src/views/games_view.js create mode 100644 src/views/graphos_view.js create mode 100644 src/views/housing_view.js create mode 100644 src/views/image_view.js create mode 100644 src/views/indexing_view.js create mode 100644 src/views/industry_view.js create mode 100644 src/views/inhabitants_view.js create mode 100644 src/views/invites_view.js create mode 100644 src/views/jobs_view.js create mode 100644 src/views/karvan_view.js create mode 100644 src/views/larp_view.js create mode 100644 src/views/legacy_view.js create mode 100644 src/views/logs_view.js create mode 100644 src/views/main_views.js create mode 100644 src/views/maps_view.js create mode 100644 src/views/markdown.js create mode 100644 src/views/market_view.js create mode 100644 src/views/melody_view.js create mode 100644 src/views/mentions_view.js create mode 100644 src/views/modules_view.js create mode 100644 src/views/opinions_view.js create mode 100644 src/views/pads_view.js create mode 100644 src/views/parliament_view.js create mode 100644 src/views/peers_view.js create mode 100644 src/views/pixelia_view.js create mode 100644 src/views/pm_view.js create mode 100644 src/views/polls_view.js create mode 100644 src/views/projects_view.js create mode 100644 src/views/report_view.js create mode 100644 src/views/search_view.js create mode 100644 src/views/settings_view.js create mode 100644 src/views/shops_view.js create mode 100644 src/views/stats_view.js create mode 100644 src/views/tags_view.js create mode 100644 src/views/task_view.js create mode 100644 src/views/torrents_view.js create mode 100644 src/views/transfer_view.js create mode 100644 src/views/trending_view.js create mode 100644 src/views/tribes_view.js create mode 100644 src/views/video_view.js create mode 100644 src/views/vote_view.js create mode 100644 src/views/wallet_view.js create mode 100644 src/views/welcome_view.js create mode 100644 test/karvan_model.test.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..136b73d --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +node_modules/ +packages/ +*.gguf +*.onnx +*.tar.gz +src/AI/embeddings/ +src/AI/.cache/ +.update_required +cache/ +src/configs/* +!src/configs/config-manager.js +!src/configs/shared-state.js +!src/configs/server-config.json +!src/configs/content_favorites.json +test/results/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0ad25db --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9a8bbb5 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# OASIS_LINUX — rama de desarrollo experimental + +> ## ⚠ ESTO NO ES OASIS OFICIAL +> +> Esta es una **rama de desarrollo experimental** mantenida por el hacklab, no +> afiliada al proyecto original. +> +> **El repositorio oficial de Oasis es el de epsylon: https://github.com/epsylon/oasis** +> +> Si quieres **usar Oasis de verdad**, instala el oficial. Lo que hay aquí puede +> romperse, cambiar de forma incompatible o desaparecer sin aviso. No está auditado +> y no tiene garantía de ninguna clase. +> +> Los fallos de esta rama **se reportan aquí, nunca a epsylon**. + +Versión base: **Oasis 0.9.5**. + +## Qué añade esta rama + +### Karvan — salas efímeras + +Salas de chat que **viven solo en memoria** y se autodestruyen solas: + +- TTL de inactividad (30 min) y absoluto (2 h), configurables al crear la sala. +- Nada se escribe en disco ni en el log SSB: al vencer el plazo, la sala y sus + mensajes desaparecen. +- Anillo de 250 mensajes, 100 salas simultáneas, 50 miembros por sala. +- El identificador de sala son **72 bits** y es la única credencial: **quien tiene + el enlace, entra**. No hay lista de miembros que valga. +- Invitación a un contacto por mensaje privado SSB. +- **Funciona sin JavaScript**: enviar y recibir van por formulario y recarga. Con + JavaScript se añade un canal directo entre pares. + +### Llamadas de audio y vídeo + +Sobre el mismo WebRTC del chat. En escritorio el navegador pide los permisos de +cámara y micrófono directamente. + +**Sin servidores de terceros**: no hay ningún STUN de fábrica. Un servidor STUN +aprende la IP pública y el momento de cada llamada, así que no se pone ninguno. +Por defecto solo hay candidatos host, que funcionan en la misma red y con NAT +amable. Si tu nodo tiene TURN propio, se configura en `oasis-config.json`: + +```json +"rtc": { + "stun": ["stun:tu.pub:3478"], + "turn": { "urls": ["turn:tu.pub:3478"], "secret": "", "ttlSec": 3600 }, + "relayOnly": false +} +``` + +Con `secret` se emiten credenciales efímeras por el mecanismo REST de coturn. Con +`relayOnly` toda la media pasa por el TURN y ningún par ve la IP del otro. + +## Qué NO tiene respecto al oficial + +- **Módulo de IA**: fuera. El modelo son unos 4 GB. +- **housing**: portado pero apagado por defecto. + +## Instalación + +Igual que el oficial: + +```sh +cd src/server && npm install +cd ../.. && ./oasis.sh +``` + +## Relación con upstream + +Esta rama sigue las versiones de epsylon de cerca. El código propio vive separado +(`src/views/fork/`, `src/backend/fork_routes.js`, `src/models/karvan_model.js` y las +traducciones en `translations/fork/`) para que integrar cada versión nueva no arrastre +la interfaz de la rama. Sobre los ficheros de upstream solo hay enganches de una línea. + +## Licencia + +AGPL-3.0, la misma que el proyecto original. diff --git a/docs/AI/info.md b/docs/AI/info.md new file mode 100644 index 0000000..88fd9f8 --- /dev/null +++ b/docs/AI/info.md @@ -0,0 +1,17 @@ +# Oasis AI General Info + +Collective Artificial Intelligence (CAI) model called "42" is based into: llama-2-7b-chat.Q4_K_M. + +https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF + +This is a static model trained in English on an offline dataset with a size of: 3,8 GiB (4.081.004.224 bytes). + +--- + +The main idea behind this implementation of an GGUF/LLM in the OASIS network is to enable distributed learning generated through the collective action of many individuals, with the goal of redistributing the necessary processing load, as well as the ecological footprint and corporate bias. + +Our AI will be trained with content from the OASIS network and its purpose is to take action and obtain answers to individual, but also global, problems. + +Future versions of the tuned model will be released as we improve model safety with community feedback. + +--- diff --git a/docs/FEDIVERSE/MASTODON/connect.md b/docs/FEDIVERSE/MASTODON/connect.md new file mode 100644 index 0000000..b7b9515 --- /dev/null +++ b/docs/FEDIVERSE/MASTODON/connect.md @@ -0,0 +1,69 @@ +# Connect your Mastodon account + +The **Fediverse** module lets you use your Mastodon account from inside Oasis: read your timeline, publish posts (text, images or video), reply, boost and favourite — all in one place. + +This short guide shows you how to connect your account. + +--- + +## 1) Create an access token in Mastodon + +1. Log in to your Mastodon server (for example `mastodon.social`). +2. Go to **Preferences → Development → New application**. +3. Fill in: + - **Application name**: `Oasis` + - **Application website**: optional, leave blank if you want. + - **Redirect URI**: leave the value that's already there. +4. Under **Scopes**, tick these (and nothing else): + + ``` + read:accounts + read:statuses + write:statuses + write:media + write:favourites + ``` + +5. Click **Submit**. Open the new **Oasis** application and copy **"Your access token"**. + +> Keep this token private — it lets you post to your account. You can delete it any time from the same Development page. + +--- + +## 2) Connect it in Oasis + +1. In Oasis, open **Settings**. +2. Find the **Fediverse** section (the **Mastodon** box). +3. Enter: + - **Address**: your server, e.g. `mastodon.social`. + - **Access token**: the token you just copied. +4. Click **Connect it**. + +That's it. Oasis checks the token and opens your timeline. From now on you'll find **Fediverse** in the main menu. + +To stop using it, go back to **Settings → Fediverse** and click **Disconnect**. + +--- + +## 3) Using it + +Open **Fediverse → Timelines**: + +- **Read** your timeline, newest first. Use **Load more** to see older posts. +- **Post**: write in the box, optionally **Attach media** (images or video), **Preview**, then **Publish**. +- **Reply**: open a post's thread and answer from there. +- **Boost** and **Favourite** any post with its buttons. + +--- + +## Show "via Oasis" on your posts (optional) + +If you'd like your posts to show that they were sent from Oasis, go to **Preferences → Privacy** in Mastodon and enable **"Display from which app you sent a post"**. Since your application is named `Oasis`, your posts will then show *"via Oasis"*. + +--- + +## If something doesn't work + +- **Invalid or expired token** — create the token again and make sure the scopes above are ticked. +- **Invalid instance URL** — use your server's domain, e.g. `mastodon.social`. +- **Couldn't publish / upload** — your token is missing `write:statuses` or `write:media`; re-create it with the right scopes. diff --git a/docs/MANIFESTO b/docs/MANIFESTO new file mode 100644 index 0000000..10ca211 --- /dev/null +++ b/docs/MANIFESTO @@ -0,0 +1,17 @@ +""" + +I’m tired of watching injustice prevail while the echoes of despair roam the halls of a world that is burning out. Indifference is the cloak under which those who delight in the suffering of others hide. Reality, with all its weight, crushes us—but within us, there is a flame that refuses to go out, a hope that persists despite the shadows. + +Yes, we are tired. Tired of the systems that diminish us, of the lies that divide us, of the structures that tell us we cannot change. But haven’t we witnessed the transformative power of human connection? Haven’t we seen what happens when ideas flow without barriers, when a group of souls comes together in a shared purpose, when digital empathy turns into concrete action? + +Today, in the midst of this chaos, within the social network that connects the most willing minds and hearts, we have the power to give life to new worlds. Worlds where justice is non-negotiable, where collaboration replaces destructive competition, where knowledge is not a privilege but a universal right. + +Projects like OASIS are not just virtual spaces; they are seeds we plant today to harvest tomorrow: a place where voices rise together to build the future we dream of. A space where each piece of code, each line of thought, each project is born with the intention to heal, to learn, to change. We don’t have all the answers, but we are certain that the act of building begins here, in this community of dreamers and doers—creators who understand that the future is forged by hands that reach out to collaborate, not to destroy. + +So even if today the shadows are long and impunity still reigns, tomorrow the sun of hope will rise—and it will rise with the strength of an army of ideas and projects born in this Oasis of infinite possibilities. May our voices never go silent, may our hands never stop working, may our eyes never stop gazing toward the horizon—where new worlds await to be created by us. Because in the end, if we don’t dream the future, who will? + +The revolution is in our hands, and its strength lies in the connection between all of us. Together, I still believe—we can create something truly worthwhile ... + +.- by psy (03c8.net) + +""" diff --git a/docs/PUB/deploy.md b/docs/PUB/deploy.md new file mode 100644 index 0000000..9c0dfdf --- /dev/null +++ b/docs/PUB/deploy.md @@ -0,0 +1,221 @@ +# Oasis PUB Deployment Guide + +This guide walks you through deploying an **Oasis PUB** on a VPS using the Oasis launcher (`sh oasis.sh server`). A PUB needs a static, publicly-reachable IP address and an open TCP port (default `8008`). + +--- + +## 1) Prepare the server + +Install the basics: + +``` +sudo apt-get update +sudo apt-get install -y git curl build-essential +``` + +Install Node.js (Oasis is tested on Node 22; older LTS versions also work for server-only mode): + +``` +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash +source ~/.bashrc +nvm install 22 +nvm use 22 +nvm alias default 22 +``` + +## 2) Clone Oasis + +``` +cd ~ +git clone https://code.03c8.net/krakenslab/oasis oasis +cd oasis +``` + +## 3) Install dependencies + +The `install.sh` script installs Node deps and applies the bundled patches. **You can skip the AI model download** — a PUB does not need it. + +``` +bash install.sh +``` + +If the AI model download fails or you skipped it, that's fine. The PUB will run without it. + +## 4) Configure the PUB + +Two example config files live in `docs/PUB/`: + +- [`server-config.json.example`](./server-config.json.example) — the Oasis Sbot config (cap, friends graph, gossip, incoming/outgoing ports). Goes into `src/configs/server-config.json`. +- [`oasis-config.json.example`](./oasis-config.json.example) — the GUI/module config tuned for a PUB (AI/wallet/market/jobs/shops off; LAN broadcasting off). Goes into `src/configs/oasis-config.json` if you ever run the GUI on the same host. + +Copy them: + +```sh +cp docs/PUB/server-config.json.example src/configs/server-config.json +cp docs/PUB/oasis-config.json.example src/configs/oasis-config.json # only if you run the GUI here +``` + +The reference `server-config.json`: + +```json +{ + "logging": { "level": "notice" }, + "caps": { "shs": "H5EC+V5BU9s0lWxCkt4z8a095Sj8a6TgiLKPYi1JD7s=" }, + "pub": true, + "local": false, + "friends": { "dunbar": 300, "hops": 3 }, + "gossip": { + "connections": 50, + "local": false, + "friends": true, + "seed": true, + "global": true + }, + "replicationScheduler": { + "autostart": true, + "partialReplication": null + }, + "autofollow": { + "enabled": true, + "feeds": [ + "@0qSCyK3xyL71X4qKkmf84Cb2riP6OeUqxCvbP2Z6HWs=.ed25519" + ] + }, + "connections": { + "seeds": [], + "incoming": { + "net": [ + { + "scope": ["device", "local", "public"], + "transform": "shs", + "port": 8008, + "external": "pub.example.com" + } + ], + "unix": [ + { + "scope": ["device", "local", "private"], + "transform": "noauth" + } + ] + }, + "outgoing": { + "net": [{ "transform": "shs" }], + "tunnel": [], + "onion": [], + "ws": [] + } + } +} +``` + +**Three values to know:** + +- **`connections.incoming.net[].external`** — the externally-reachable hostname of this PUB (e.g. `pub.example.com`). This is what gets embedded into invite codes generated by `sh oasis.sh invite` and into pub announce messages for the `public` scope. If it's missing, multiserver falls back to the first non-loopback IPv4 address it finds, which means invites will hand out the raw VPS IP instead of your domain. Set it on the public listener before you generate any invites. Note: this is a per-listener field — the top-level `host` does **not** affect invite codes. + +- **`caps.shs`** — the network-level secret handshake cap. The Oasis network uses `H5EC+V5BU9s0lWxCkt4z8a095Sj8a6TgiLKPYi1JD7s=` (set in the example above). All PUBs and clients on this network must hold the **same** value — nodes with a different cap silently can't connect. If you're bootstrapping a separate isolated network instead, generate your own with: + + ```sh + node scripts/generate_shs.js + ``` + +- **`autofollow.feeds`** — the upstream PUB(s) this node will automatically follow on first boot. The example seeds from `solarnethub.com`'s PUB (`@0qSCyK3xyL71X4qKkmf84Cb2riP6OeUqxCvbP2Z6HWs=.ed25519`), the default seed of the Oasis network. Once your PUB connects to it, gossip propagates the rest of the network's pub list. Replace this id only if you're bootstrapping from a different network root. + +Everything else is the standard PUB shape: `pub: true`, no LAN discovery, dunbar 300, three friend hops, replication scheduler running on autostart, port `8008` open for SHS on every scope (device/local/public), and a `noauth` unix socket for the CLI. + +## 5) Launch the PUB (server-only) + +In server-only mode Oasis runs **only the Oasis Sbot**, not the web GUI or AI service. `aiMod` is forced off automatically when launched this way. + +The repo ships a ready-to-use systemd unit at `docs/PUB/oasis-pub.service`. Copy it, edit the `YOUR_USER` placeholder, then enable it: + +``` +sudo cp ~/oasis/docs/PUB/oasis-pub.service /etc/systemd/system/oasis-pub.service +sudo nano /etc/systemd/system/oasis-pub.service # replace YOUR_USER +sudo systemctl daemon-reload +sudo systemctl enable --now oasis-pub +sudo journalctl -u oasis-pub -f +``` + +Data is written to `~/.ssb/`. + +## 6) PUB admin: `sh oasis.sh ` + +All admin actions go through the launcher itself, which talks to the running Oasis Sbot via the local unix socket (`~/.ssb/socket`). No external CLI install is needed — just keep the systemd unit `oasis-pub` active. + +``` +sh oasis.sh whoami # print this PUB id +sh oasis.sh invite [N] # create invite code (N = uses, default 1) +sh oasis.sh name "" # set PUB display name +sh oasis.sh announce [port] # publish pub address (default port 8008) +sh oasis.sh follow # follow another PUB / feed +sh oasis.sh status # peer / replication overview +sh oasis.sh gossip # known gossip peers +``` + +## 7) Get your PUB ID + +``` +sh oasis.sh whoami +``` + +Example response: + +``` +{ "id": "@mGrevRCSX4E5dLgmflWBc50Qkn/1RXUAtDaGHOJ8xB4=.ed25519" } +``` + +## 8) Set the PUB profile name + +``` +sh oasis.sh name "My PUB Name" +``` + +## 9) Create invite codes + +``` +sh oasis.sh invite # uses=1 (default) +sh oasis.sh invite 500 # uses=500 (open PUB) +``` + +The output is a single-use (or N-use) invite code you can hand out. Clients redeem it in their `/invites` page. + +## 10) Announce the PUB + +So peers can discover the PUB by hostname: + +``` +sh oasis.sh announce mypub.example.com +sh oasis.sh announce mypub.example.com 8008 +``` + +## 11) Follow another PUB (federation) + +Federate so both replicate each other: + +``` +sh oasis.sh follow "@mGrevRCSX4E5dLgmflWBc50Qkn/1RXUAtDaGHOJ8xB4=.ed25519" +``` + +## 12) Health checks + +``` +sh oasis.sh status # peer / replication overview +sh oasis.sh gossip # known gossip peers with state +ls -la ~/.ssb/ # confirm flume/, blobs/, gossip.json, conn.json exist +sudo journalctl -u oasis-pub -f # tail service logs +``` + +## 13) Disabling the AI module (only relevant if also running the GUI) + +`sh oasis.sh server` does **not** load the GUI or AI service, so `oasis-config.json` is ignored in server-only mode. Only `server-config.json` matters. + +If you also run the GUI on the same VPS (`sh oasis.sh` without `server`), set `aiMod` to `off` in `src/configs/oasis-config.json` to skip the AI model: + +``` +sed -i 's/"aiMod": *"on"/"aiMod": "off"/' src/configs/oasis-config.json +``` + +## 14) Joining the Oasis network + +The default seed PUB at `solarnethub.com` is included in `autofollow.feeds` above. As soon as your PUB connects to it (or to any peer that knows about it), gossip propagates the rest of the network's pub list. diff --git a/docs/PUB/oasis-config.json.example b/docs/PUB/oasis-config.json.example new file mode 100644 index 0000000..6f7a8fb --- /dev/null +++ b/docs/PUB/oasis-config.json.example @@ -0,0 +1,78 @@ +{ + "themes": { + "current": "Dark-SNH" + }, + "ux": { + "current": "blocks" + }, + "modules": { + "popularMod": "on", + "topicsMod": "on", + "summariesMod": "on", + "latestMod": "on", + "threadsMod": "on", + "multiverseMod": "on", + "invitesMod": "on", + "walletMod": "off", + "legacyMod": "off", + "cipherMod": "off", + "bookmarksMod": "on", + "videosMod": "on", + "docsMod": "on", + "audiosMod": "on", + "tagsMod": "on", + "imagesMod": "on", + "trendingMod": "on", + "eventsMod": "on", + "tasksMod": "on", + "marketMod": "off", + "votesMod": "on", + "tribesMod": "on", + "reportsMod": "on", + "opinionsMod": "on", + "padsMod": "on", + "calendarsMod": "on", + "transfersMod": "off", + "feedMod": "on", + "pixeliaMod": "on", + "melodyMod": "on", + "agendaMod": "on", + "aiMod": "off", + "aiNavMod": "off", + "forumMod": "on", + "gamesMod": "on", + "jobsMod": "off", + "shopsMod": "off", + "projectsMod": "off", + "bankingMod": "off", + "parliamentMod": "on", + "courtsMod": "on", + "favoritesMod": "on", + "logsMod": "on", + "mapsMod": "on", + "chatsMod": "on", + "torrentsMod": "on", + "graphosMod": "on", + "larpMod": "on" + }, + "wallet": { + "url": "http://localhost:7474", + "user": "", + "pass": "", + "fee": "5" + }, + "walletPub": { + "pubId": "" + }, + "ai": { + "prompt": "Provide an informative and precise response." + }, + "ssbLogStream": { + "limit": 2000 + }, + "homePage": "activity", + "language": "en", + "wish": "whole", + "pmVisibility": "whole", + "lanBroadcasting": false +} diff --git a/docs/PUB/oasis-pub.service b/docs/PUB/oasis-pub.service new file mode 100644 index 0000000..8f58ddd --- /dev/null +++ b/docs/PUB/oasis-pub.service @@ -0,0 +1,26 @@ +[Unit] +Description=Oasis PUB +Documentation=https://wiki.solarnethub.com/socialnet/snh-pub +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +User=YOUR_USER +WorkingDirectory=/home/YOUR_USER/oasis +ExecStart=/bin/sh /home/YOUR_USER/oasis/oasis.sh server +Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +Restart=on-failure +RestartSec=5 +KillSignal=SIGTERM +TimeoutStopSec=30 +StandardOutput=journal +StandardError=journal +SyslogIdentifier=oasis-pub +NoNewPrivileges=yes +ProtectSystem=full +ProtectHome=read-only +ReadWritePaths=/home/YOUR_USER/.ssb /home/YOUR_USER/oasis + +[Install] +WantedBy=multi-user.target diff --git a/docs/PUB/server-config.json.example b/docs/PUB/server-config.json.example new file mode 100644 index 0000000..b771fdb --- /dev/null +++ b/docs/PUB/server-config.json.example @@ -0,0 +1,65 @@ +{ + "logging": { + "level": "notice" + }, + "caps": { + "shs": "H5EC+V5BU9s0lWxCkt4z8a095Sj8a6TgiLKPYi1JD7s=" + }, + "pub": true, + "local": false, + "friends": { + "dunbar": 300, + "hops": 3 + }, + "gossip": { + "connections": 50, + "local": false, + "friends": true, + "seed": true, + "global": true + }, + "replicationScheduler": { + "autostart": true, + "partialReplication": null + }, + "autofollow": { + "enabled": true, + "feeds": [ + "@0qSCyK3xyL71X4qKkmf84Cb2riP6OeUqxCvbP2Z6HWs=.ed25519" + ] + }, + "connections": { + "seeds": [ + ], + "incoming": { + "net": [ + { + "scope": ["device", "local", "public"], + "transform": "shs", + "port": 8008, + "external": "pub.example.com" + } + ], + "unix": [ + { + "scope": [ + "device", + "local", + "private" + ], + "transform": "noauth" + } + ] + }, + "outgoing": { + "net": [ + { + "transform": "shs" + } + ], + "tunnel": [], + "onion": [], + "ws": [] + } + } +} diff --git a/docs/devs/architecture/00-README.md b/docs/devs/architecture/00-README.md new file mode 100644 index 0000000..ad0d02b --- /dev/null +++ b/docs/devs/architecture/00-README.md @@ -0,0 +1,62 @@ +# Guía de desarrollo de Oasis + +Esta carpeta documenta cómo está construido Oasis por dentro, para que puedas +entenderlo y extenderlo (por ejemplo, creando un **módulo de juegos** nuevo). + +Está pensada para leerse en orden, pero cada archivo es autónomo. + +## Índice + +1. **[01-red-ssb.md](01-red-ssb.md)** — Cómo funciona Oasis **a nivel de red**: + Secure Scuttlebutt (SSB), secret-stack, multiserver, muxrpc, EBT, blobs, + federación P2P, puertos y cifrado. + +2. **[02-arquitectura-software.md](02-arquitectura-software.md)** — La + **arquitectura de software** del backend: el patrón MVC casero + (models / views / backend.js), el stack de dependencias, el "cooler", el + flujo de una petición y cómo se interrelacionan los archivos. + +3. **[03-modulos-y-juegos.md](03-modulos-y-juegos.md)** — Cómo está construido + el **módulo de juegos** actual y la anatomía de un módulo en general. + +4. **[04-tutorial-modulo-desde-cero.md](04-tutorial-modulo-desde-cero.md)** — + **Tutorial paso a paso** para crear un módulo nuevo desde cero (caso práctico: + un módulo de juegos propio), con todos los puntos de integración. + +5. **[05-mapa-funciones.txt](05-mapa-funciones.txt)** — **Gran mapa ASCII** de + cómo se relacionan las funciones lógicas entre archivos, la persistencia + (SSB) y la media (blobs). + +## Conceptos en 30 segundos + +Oasis es un **cliente web de Secure Scuttlebutt (SSB)**. SSB es un protocolo +social **P2P, distribuido y federado**: no hay servidor central; cada nodo tiene +una copia local de un *log append-only* firmado criptográficamente, y los nodos +se replican entre sí por *gossip*. + +Oasis se compone de **dos procesos**: + +``` + ┌─────────────────────────┐ ┌──────────────────────────┐ + │ SBOT (nodo de red SSB) │ <─────> │ FRONTEND WEB (Koa/HTML) │ + │ src/server/SSB_server │ unix │ src/backend/backend.js │ + │ habla con otros peers │ socket │ habla con tu navegador │ + └─────────────────────────┘ └──────────────────────────┘ + puerto 8008 (SSB) puerto 3000 (HTTP) +``` + +- El **sbot** (`src/server/SSB_server.js`) es el nodo SSB: se conecta a otros + peers, replica feeds, sirve y descarga blobs. → [01-red-ssb.md](01-red-ssb.md) +- El **frontend** (`src/backend/backend.js`) es un servidor HTTP en Koa que + renderiza HTML puro (sin JS de navegador) y se conecta al sbot como **cliente + muxrpc** por un socket Unix local. → [02-arquitectura-software.md](02-arquitectura-software.md) + +El patrón para **cada funcionalidad** ("módulo") es siempre el mismo: + +``` + navegador → backend.js (ruta) → *_model.js (lee/escribe SSB) → *_view.js (HTML) → navegador +``` + +> Las rutas, líneas y nombres citados en estos documentos corresponden a la +> versión 0.8.1 del código. Si editas el código, vuelve a comprobar los números +> de línea con `grep`. diff --git a/docs/devs/architecture/01-red-ssb.md b/docs/devs/architecture/01-red-ssb.md new file mode 100644 index 0000000..45dd9c0 --- /dev/null +++ b/docs/devs/architecture/01-red-ssb.md @@ -0,0 +1,243 @@ +# 1. Oasis a nivel de red (Secure Scuttlebutt) + +Oasis es un cliente/servidor de **Secure Scuttlebutt (SSB)**. Toda la "red" de +Oasis se construye sobre la pila clásica del ecosistema SSB: +`secret-stack` + `ssb-db` + un montón de plugins. + +Hay una separación clara en **dos procesos**: + +- **Backend SSB (sbot)** — `src/server/SSB_server.js`: el nodo de red propiamente + dicho. Es quien habla con otros peers. +- **Frontend web (GUI Koa)** — `src/backend/backend.js`: un servidor HTTP que + actúa como **cliente muxrpc** del sbot, conectándose por un socket Unix local. + +``` + RED SSB (otros peers Oasis, misma SHS cap) + │ + net:IP:8008~shs: · ssb-lan (UDP) · ssb-onion (Tor) + │ + ┌─────────────────────────────────────────────┐ + │ SBOT (src/server/SSB_server.js) │ + │ peer <-> MULTISERVER <-> SECRET-STACK (SHS) │ + │ <-> MUXRPC <-> PLUGINS │ + └─────────────────────────┬───────────────────┘ + │ unix socket ~noauth (muxrpc local, sin SHS) + ▼ + ┌─────────────────────────────────────────────┐ + │ FRONTEND (src/backend/backend.js, Koa) │ + │ cooler = src/client/gui.js → ssb-client │ + │ app.listen({host, port:3000}) │ + └─────────────────────────┬───────────────────┘ + ▼ + Navegador http://localhost:3000 +``` + +--- + +## 1.1 Arranque de red + +### Scripts de arranque + +- **`install.sh`**: instala Node 22 y hace `npm install` en `src/server` + (línea 23). Opcionalmente descarga modelos de IA. No toca la red. +- **`oasis.sh`** es el lanzador. Modos relevantes: + - `server` / `pub` (líneas 61-69): ejecuta `node SSB_server.js start` — **solo + el sbot headless**, sin interfaz web. + - `gui` o por defecto (líneas 73-81): ejecuta `node backend.js` — el frontend. + - comandos pub `whoami|invite|name|announce|follow|status|gossip` + (líneas 70-72) → delegan en `scripts/oasis-pub.js`. +- **`src/server/package.json`**, script `start`: + `npm run start:ssb && sleep 10 && npm run start:backend`. + Arranca el sbot en segundo plano, **espera 10 s** (para que el socket Unix + exista) y luego arranca el frontend. + +### Qué hace `SSB_server.js` paso a paso + +(`src/server/SSB_server.js`) + +1. **Líneas 7-11**: carga `secret-stack`, `ssb-caps` (la capability SHS), + `ssb-db`, la config (`./ssb_config`) y utilidades de metadatos. +2. **Líneas 13-52** (IIFE): *monkey-patch* de `console.error`/`console.warn` + para silenciar ruido de red — rechazos de handshake por SHS cap incorrecta, + excepciones EBT, etc. Un rechazo se convierte en un log limpio: + `[ts] REJECTED (wrong SHS cap)`. +3. **Líneas 56-81**: construye el servidor con + `SecretStack({ caps }).use(plugin).use(plugin)...` encadenando todos los + plugins (ver tabla abajo). +4. **Líneas 83-86**: si **no** es pub, carga `ssb-lan` (descubrimiento LAN por + UDP) y el router LAN local `./lanRouter`. +5. **Líneas 88-98**: lógica de `autofollow`; carga `ssb-autofollow` si hay feeds. +6. **Líneas 123-196** (`argv[0] === 'start'`): instancia el servidor, escribe + `manifest.json` (el catálogo de métodos muxrpc remotos), monta una barra de + progreso de replicación, imprime metadatos y **escucha eventos del hub de + conexiones** (`server.conn.hub().listen()`) para loguear `CONNECTED` / + `DISCONNECTED`. +7. **Líneas 198-202**: exporta `{ config, server, open() }` — esto permite a la + GUI reusar el servidor **in-process** si corre en el mismo proceso. + +### Plugins secret-stack cargados (líneas 56-98) + +| Plugin | Función de red | +|---|---| +| `ssb-db` | base de datos *append-only* de feeds | +| `ssb-master` | identidad maestra / auth local | +| `ssb-gossip` | gossip clásico (legacy) de peers | +| `ssb-ebt` | **Epidemic Broadcast Trees** — replicación gossip eficiente | +| `ssb-friends` | grafo social: hops, follows/blocks | +| `ssb-blobs` | transferencia de ficheros binarios | +| `ssb-meme` | blobs de imágenes/memes | +| `ssb-conn` | gestor de conexiones moderno (hub, db, staging) | +| `ssb-box` | cifrado de mensajes privados (box1) | +| `ssb-search`, `ssb-private`, `ssb-friend-pub` | búsqueda, PM, pub de amigos | +| `ssb-invite` / `ssb-invite-client` | invites (servidor si es pub, cliente si no) | +| `ssb-replication-scheduler`, `ssb-partial-replication` | planificación de replicación | +| `ssb-onion` | transporte Tor | +| `ssb-unix-socket` | **socket Unix local** para clientes (la GUI) | +| `ssb-no-auth` | conexiones locales sin handshake SHS | +| `ssb-about`, `ssb-backlinks`, `ssb-links`, `ssb-tangle`, `ssb-query` | índices de vistas | +| `ssb-lan` + `lanRouter` | descubrimiento LAN (solo si no es pub) | + +> Nota: la replicación NO usa `ssb-replicate` directamente; la orquestan +> `ssb-ebt` + `ssb-replication-scheduler` + `ssb-friends`. + +--- + +## 1.2 El protocolo SSB en términos del proyecto + +- **secret-stack + handshake SHS (capability).** `SecretStack({ caps })` crea el + nodo. La `caps.shs` está **fijada en `src/configs/server-config.json`** + (líneas 5-7): `"H5EC+V5BU9s0lWxCkt4z8a095Sj8a6TgiLKPYi1JD7s="`. Es la **clave + de capacidad de red** (Secret Handshake): dos peers solo completan el + handshake si comparten *exactamente* esta cap. Actúa como "contraseña de red": + **Oasis forma su propia red SSB privada**, distinta de la red SSB pública. + +- **multiserver (transportes).** Capa de transporte abstracta. La config + `connections` (`server-config.json`, líneas 29-60) define: + - **incoming.net**: `transform: "shs"`, `port: 8008` → TCP cifrado con SHS. + - **incoming.unix**: `transform: "noauth"` → socket Unix local sin handshake, + para que el frontend se conecte como cliente privilegiado. + - **outgoing.net**: `transform: "shs"`. + - Una dirección multiserver típica: `net:IP:8008~shs:`. + +- **muxrpc (RPC sobre el stream).** Una vez establecido el stream SHS, `muxrpc` + multiplexa llamadas RPC asíncronas y *pull-streams* sobre la misma conexión. + El `manifest.json` describe qué métodos remotos existen (`sync`/`async`/ + `source`). Es como el frontend invoca `ssb.publish(...)`, `ssb.blobs.get(...)`, + etc. + +- **EBT (`epidemic-broadcast-trees` + `ssb-ebt`).** El algoritmo de replicación + gossip. Cada peer anuncia el `seq` (reloj vectorial) de los feeds que tiene; + el otro envía solo los mensajes que faltan, formando árboles de difusión + epidémica que evitan duplicados. + +- **Identidad de los peers.** Cada peer es un **feed id ed25519**: + `@.ed25519`. En las direcciones multiserver, el sufijo + `~shs:` identifica criptográficamente al peer durante el handshake. + +--- + +## 1.3 Federación / P2P + +- **Descubrimiento LAN** (`src/server/lanRouter.js`): plugin local custom. + `startRouter` (líneas 55-64) arranca `ssb.lan.start()` (broadcast UDP) y + consume `ssb.lan.discoveredPeers()`. Cada peer descubierto pasa por + `handleDiscovery` → `stagePeer` (líneas 15-45): lo *stagea* en + `ssb.conn.stage(...)` (vía moderna) con fallback a `ssb.gossip.add(...)` + (legacy); si `eagerReplicate`, fuerza `ebt.request`. Respeta el flag + `lanBroadcasting` de `oasis-config.json`. + +- **Pubs / invites.** En modo pub se carga `ssb-invite` (servidor); en cliente, + `ssb-invite-client`. Los comandos `oasis.sh invite|announce|follow` + (→ `scripts/oasis-pub.js`) permiten a un pub publicar su dirección y generar + códigos de invitación. Un invite contiene `host:port:pubkey~seed`; al + canjearlo, el peer se conecta y el pub le sigue de vuelta (`ssb-friend-pub`). + +- **Replicación por hops.** `ssb-friends` define el grafo social. + `server-config.json` fija `friends.hops: 2` → el nodo replica los feeds de la + gente que sigues y de la gente que ellos siguen (amigos de amigos). El + `ssb-replication-scheduler` decide qué feeds pedir por EBT según ese grafo. + +- **"Distributed not decentralized".** No hay servidor central ni DHT global. + Cada nodo Oasis tiene su **propia copia local** de la base de datos + (logs *append-only* firmados con ed25519) y solo replica los feeds dentro de + su radio social (hops) más los descubiertos por LAN. La red se federa por + gossip entre peers que comparten la misma SHS cap. Es **distribuida** (datos + replicados en muchos nodos autónomos, funciona offline) pero **no + descentralizada** como una blockchain (no hay consenso global ni vista única; + cada quien ve solo su subgrafo). El flag `wish` de `oasis-config.json` + (`whole` / `mutuals` / `only-lan`) controla el alcance de replicación deseado. + +--- + +## 1.4 Puertos y endpoints + +| Qué | Dónde | Puerto / dirección | +|---|---|---| +| muxrpc SSB (sbot) — otros peers se conectan aquí | `server-config.json` incoming.net | **8008/TCP** transform `shs` | +| Socket Unix local — para el frontend | incoming.unix | `unix:/socket~noauth:` | +| Frontend web (Koa) — tu navegador | `oasis_client.js` / `middleware.js:180` | **3000** host `localhost` (configurable con `--host`/`--port`) | + +**Cómo se conecta el frontend al sbot** (el "cooler", `src/client/gui.js`): + +1. Intenta `require('../server/SSB_server')` y reusar el `server` **in-process** + si existe (sin socket, uso directo del objeto). +2. Si no, construye `remote = unix:/socket~noauth:` y se conecta + con **`ssb-client`** (muxrpc por el socket Unix `noauth`). +3. `attemptConnectionWithBackoff`: reintentos con backoff exponencial (de ahí el + `sleep 10` del arranque). +4. Expone `cooler.open()` / `cooler.close()`. **Todos los modelos** del backend + reciben este `cooler` y hacen `await cooler.open()` para obtener el cliente + muxrpc. + +> Para exponer la GUI en un VPS se usa `--host=0.0.0.0`. + +--- + +## 1.5 Blobs (ficheros / imágenes) + +- Plugin `ssb-blobs` (+ `ssb-meme`). Tamaño máximo en `ssb_config.js`: 50 MB. +- Un blob se referencia por hash: `&.sha256`. **Los mensajes del + log solo llevan el hash**, no el binario. +- Flujo en `src/backend/blobHandler.js`: + - **Subida**: `ssbClient.blobs.add(...)` recibe el contenido por pull-stream y + devuelve el ref `&...sha256`. + - **Descarga por red**: `blobs.has(id)` comprueba si ya está local; si no, + `blobs.want(id)` **lo pide a los peers conectados** (gossip de "want/has" + sobre muxrpc), y `blobs.get(id)` lo lee como stream. + +Los blobs viajan sobre la misma conexión SHS/muxrpc, fuera del log append-only. + +--- + +## 1.6 Caps / cifrado + +- **`ssb-caps`** define las capabilities de protocolo (shs, sign, invite). La + **shs cap real** está fijada en `server-config.json` → red privada de Oasis. +- **Handshake SHS**: autenticación mutua por ed25519 + confidencialidad del + stream de transporte. +- **`ssb-box`**: cifrado de **mensajes privados box1** (hasta ~7 destinatarios, + cifrado por clave pública de cada feed). `ssb-private` expone publish/read. +- **Grupos privados ("tribes").** No se usa `box2`/`ssb-tribes`. En su lugar + Oasis implementa cifrado **propio a nivel de aplicación** en + `src/models/crypto.js`, instanciado por dominio en `backend.js` + (`tribeCrypto`, `chatCrypto`, `padCrypto`, `mapCrypto`, `calendarCrypto`, + `eventCrypto`, `forumCrypto`). Los grupos se cifran con esas claves derivadas + y se almacenan/replican como mensajes normales del feed. + +--- + +## 1.7 Archivos clave de la capa de red + +| Archivo | Rol | +|---|---| +| `src/server/SSB_server.js` | Construye el sbot y carga los plugins (56-98) | +| `src/server/ssb_config.js` | Fusiona `server-config.json`; fija `blobs.max=50MB` | +| `src/server/ssb_metadata.js` | Deriva e imprime puerto SSB, hops, LAN, feed ID | +| `src/server/lanRouter.js` | Descubrimiento/staging de peers LAN | +| `src/configs/server-config.json` | `caps.shs`, `pub`, `friends.hops`, `connections` (puertos) | +| `src/configs/oasis-config.json` | `lanBroadcasting`, `wish`, `pmVisibility`, módulos | +| `src/client/gui.js` | El "cooler": cliente muxrpc por socket Unix noauth | +| `src/backend/blobHandler.js` | add/has/want/get de blobs | +| `scripts/oasis-pub.js` | Comandos pub (invite/announce/follow) | + +Siguiente: **[02-arquitectura-software.md](02-arquitectura-software.md)**. diff --git a/docs/devs/architecture/02-arquitectura-software.md b/docs/devs/architecture/02-arquitectura-software.md new file mode 100644 index 0000000..64057c4 --- /dev/null +++ b/docs/devs/architecture/02-arquitectura-software.md @@ -0,0 +1,350 @@ +# 2. Arquitectura de software del backend + +Oasis usa un patrón **MVC casero** (sin framework MVC): + +``` + src/backend/backend.js → el ROUTER monolítico (Koa, ~7250 líneas, ~472 rutas) + src/models/*_model.js → la lógica de DATOS (lee/escribe SSB) + src/views/*_view.js → el RENDER de HTML (con hyperaxe) +``` + +Flujo de una funcionalidad: + +``` + navegador → backend.js (ruta) → xModel.metodo() (SSB) → xView(data) (HTML) → ctx.body +``` + +--- + +## 2.1 Stack de software (dependencias clave) + +Todas las dependencias están en `src/server/package.json`. Importante: casi +todos los `require` usan **ruta relativa explícita** al node_modules del +servidor, p.ej. `require("../server/node_modules/@koa/router")`. + +**Capa web / HTTP** +- **`koa`** — servidor HTTP base. Se instancian varias apps Koa en + `src/client/middleware.js` (principal + sub-apps para estáticos). +- **`@koa/router`** — enrutado. `backend.js:442` instancia + `const router = new koaRouter()`. Toda la API es **una única cadena fluida** + `router.param(...).get(...).post(...)` (líneas ~1270-7124). +- **`koa-static` / `koa-mount`** — sirven assets estáticos (`/assets`, + `/maptiles`, `/game-assets`, `/js`...) montados en `middleware.js`. +- **`koa-body`** — parseo de `multipart/form-data` y POST. Se aplica por ruta: + `.post('/votes/create', koaBody(), ...)`. +- `express` y `cors` figuran como dependencias pero **el flujo principal es + Koa**; Express no se usa en el router. + +**Motor de plantillas (vistas)** +- **`hyperaxe`** — hyperscript → HTML. **No hay archivos `.html`**; el HTML se + construye programáticamente desde JS: `div(...)`, `nav(...)`, `form(...)`... + Cada elemento expone `.outerHTML`. +- **`ssb-markdown` + `ssb-msgs` + `ssb-ref`** — render de Markdown SSB con + resolución de menciones/enlaces internos (`src/views/markdown.js`). +- **`highlight.js`, `qrcode`, `moment`, `pretty-ms`** — sintaxis, QR, fechas. +- **`dompurify` + `jsdom` + `is-svg`** — saneado anti-XSS + (`src/backend/sanitizeHtml.js`). + +**Streams SSB** +- **`pull-stream`** — el paradigma de streams de SSB. Es el mecanismo central de + lectura: `pull(source, pull.filter(...), pull.collect(cb))`. +- Auxiliares: `pull-paramap` (map asíncrono), `pull-sort`, `pull-abortable` + (cancelar streams `live`), `pull-cat`, `pull-many`, `pull-pushable`. + +**Cliente / servidor SSB** +- **`ssb-client`** — cliente RPC muxrpc para conectar al sbot (en `gui.js`). +- **`ssb-config`, `ssb-keys`, `ssb-ref`** — config, claves ed25519, validación + de identificadores (`@feed`, `%msg`, `&blob`). +- **`secret-stack` + `ssb-caps` + `ssb-db`** y los plugins SSB → ver + [01-red-ssb.md](01-red-ssb.md). + +**Otros**: `module-alias`, `lodash`, `minimist`, `open`, `archiver`, +`file-type`, `pdfjs-dist`, `openpgp`, `axios`, `node-llama-cpp` + +`@xenova/transformers` (módulo IA local). + +--- + +## 2.2 Flujo de una petición + +**a) Construcción del servidor** — `src/client/middleware.js`: la función +exportada `({host, port, middleware, allowHost})` crea la app Koa, monta +estáticos, fija cabeceras de seguridad (CSP, `X-Frame-Options`...), valida el +host, aplica los middlewares recibidos y finalmente `app.listen({host, port})` +(línea 180). En `backend.js:7239`: +`const app = http({ host, port, middleware, allowHost: config.allowHost })`. + +**b) Cadena de middleware** — `backend.js:7126-7238`: incluye (1) bloqueo de +no-GET en modo público, (2) `setLanguage(...)` por cookie, (3) gate de +indexación (muestra `indexingView` si la base no está sincronizada), (4) refresco +de estado compartido cada 60 s, y por último `routes` (las rutas del router). + +**c) Ruta GET — ejemplo agenda** (`backend.js:1977-1982`): + +```js +.get('/agenda', async (ctx) => { + const filter = qf(ctx); + let data = await agendaModel.listAgenda(filter); // MODELO: lee SSB + if (Array.isArray(data)) data = await applyListFilters(data, ctx); + ctx.body = await agendaView(data, filter); // VISTA: genera HTML +}) +``` + +`agendaModel.listAgenda` abre el cliente (`cooler.open()`), lee el log +(`createLogStream`), agrega ítems y devuelve datos. `agendaView` los recibe y +construye HTML con hyperaxe, envuelto en `template(...)`. El HTML se asigna a +`ctx.body` y Koa lo sirve. + +**d) Ruta POST — ejemplo votos** (`backend.js:5572`): + +```js +.post('/votes/create', koaBody(), async ctx => { + const b = ctx.request.body; + const parsedOptions = b.options ? b.options.split(',')... : defaultOptions; + await votesModel.createVote(stripDangerousTags(b.question), b.deadline, parsedOptions, ...); + ctx.redirect(safeReturnTo(ctx, '/votes?filter=mine', ['/votes'])); +}) +``` + +El POST **sanea** la entrada (`stripDangerousTags`), llama al modelo que +**publica un mensaje SSB**, y **redirige** (patrón Post/Redirect/Get). El GET +posterior vuelve a leer del modelo y renderiza. + +--- + +## 2.3 Conexión al servidor SSB: el "cooler" + +El **cooler** es la abstracción que gestiona la conexión al sbot. Se define en +`src/client/gui.js` (importado en `backend.js:441` como +`const ssb = require("../client/gui")`) y se instancia en `backend.js:540`: + +```js +const cooler = ssb({ offline: config.offline, port: config.port, + host: config.host, isPublic: config.public }); +``` + +- Si existe un sbot **en el mismo proceso** (`internalSSB`), `cooler.open()` lo + devuelve directamente sin RPC. +- Si no, conecta por muxrpc vía socket Unix `noauth` con backoff exponencial. + +**Patrón de uso en todo el código**: +`const ssb = await cooler.open();` y luego se usan los métodos muxrpc: + +| Método | Para qué | +|---|---| +| `ssb.createUserStream({id, reverse, limit})` | feed de un usuario | +| `ssb.createLogStream({reverse, limit})` | log global (lo más usado) | +| `ssb.query.read({query:[{$filter:{...}}]})` | consultas ssb-query | +| `ssb.messagesByType({type, private})` | mensajes por tipo | +| `ssb.backlinks.read({query})` | referencias/backlinks | +| `ssb.get(id, cb)` | un mensaje por id | +| `ssb.publish(content, cb)` | **publicar un mensaje** | +| `ssb.blobs.want/get/add` | blobs | +| `ssb.friends.isFollowing/isBlocking/graph` | grafo social | +| `ssb.conn.peers / ssb.status() / ssb.progress()` | estado de red | + +--- + +## 2.4 Patrón de un MODELO + +Todos los modelos siguen la **factory pattern**: +`module.exports = ({ cooler, isPublic, ...deps }) => ({ ...métodos })`. Reciben +el `cooler` por inyección desde `backend.js` (líneas 553-602). Muchos cachean el +cliente: + +```js +let ssb; +const openSsb = async () => { if (!ssb) ssb = await cooler.open(); return ssb; }; +``` + +**Publicar (escribir)** — `ssb.publish(content, cb)` con un campo `type`. +Ejemplo `votes_model.js` (`createVote`): + +```js +const content = { + type: 'votes', question, options, deadline, createdBy: userId, + status: 'OPEN', votes: {...}, totalVotes: 0, createdAt: new Date().toISOString() +}; +return new Promise((res, rej) => + ssbClient.publish(content, (err, msg) => err ? rej(err) : res(msg))); +``` + +**Leer** — `pull-stream` + `collect`: + +```js +pull( + ssbClient.createLogStream({ limit: logLimit }), + pull.collect((err, results) => err ? reject(err) : resolve(results)) +); +``` + +Luego se procesa en memoria: se construye un índice, se filtra por `type`, se +ordena. + +**Borrar / editar — modelo de tombstone** (el log es *append-only*: nada se +borra físicamente): + +- **Borrado lógico**: se publica `{ type:'tombstone', target:, deletedAt, + author }`. +- **Validación** (`src/models/tombstone_validator.js`, + `buildValidatedTombstoneSet`): solo acepta el tombstone si **el autor del + tombstone coincide con el autor del mensaje objetivo** — evita borrados por + terceros. +- **Edición**: se publica una versión nueva con `replaces: ` y se + lapida la anterior, formando una cadena de versiones; al leer se sigue la + cadena hasta la "punta". +- Las comprobaciones de autoría (`if (c.createdBy !== userId) throw`) se hacen en + el modelo. + +**Tipos de mensaje SSB** (campo `content.type`): los nativos SSB `post`, `vote` +(likes), `contact` (follow/block), `about` (perfil), y los **propios de Oasis**: +`votes`, `tombstone`, `task`, `event`, `calendar`, `transfer`, `tribe`, +`market`, `report`, `job`, `project`, `gameScore`, etc. + +> **`main_models.js`** es el modelo núcleo: exporta `about`, `blob`, `friend`, +> `meta`, `post`, `vote`, `spreads`, `lifetime`. Su función `transform()` +> enriquece cada mensaje con metadatos (autor, avatar, votos, timestamps) antes +> de pasarlo a las vistas. + +--- + +## 2.5 Patrón de una VISTA + +Las vistas exportan funciones que reciben datos del modelo y devuelven HTML. +Patrón típico: + +```js +const { div, h2, p, section, button, form } = require("../server/node_modules/hyperaxe"); +const { template, i18n, userLink } = require('./main_views'); + +exports.agendaView = async (data, filter) => + template(i18n.agendaTitle, section( h2(i18n.agendaTitle), /* ... */ )); +``` + +**Layout común — `main_views.js`**: +- `template(titlePrefix, ...elements)` construye el documento completo: + `html → head (title, CSS, favicon) → body (header, sidebar de navegación, + main-content)`. Se exporta como `exports.template`. +- **Navegación**: helper `navLink({href, emoji, text, current})` genera cada + `
  • `. `navGroup({id, emoji, title})` agrupa enlaces en secciones + colapsables del menú lateral. Cada módulo tiene su `renderXxxLink()` que solo + emite el enlace si el módulo está activo en config. +- **i18n**: `i18n` es un objeto compartido importado por todas las vistas. + `setLanguage(lang)` lo muta in-place (11 idiomas: + `en, es, fr, eu, de, it, pt, zh, ar, hi, ru` en + `src/client/assets/translations/`). El middleware llama `setLanguage(...)` en + cada petición. Las cadenas se referencian como `i18n.agendaTitle`, con + fallback `i18n.x || 'Default'`. **Nunca texto literal en las vistas.** +- **Temas**: `const theme = currentConfig.themes.current || "Dark-SNH"` → + ``. +- **Helpers reutilizables** exportados por `main_views`: `userLink`, + `renderStateChip`, `renderVisibilityChip`, `renderSpreadButton`, `errorView`, + `formatCarbon`, `markdown(input, mentions)`. + +--- + +## 2.6 Configuración + +**`src/configs/config-manager.js`** — gestor central de `oasis-config.json`: +- Si el archivo no existe, escribe un `defaultConfig`. +- `getConfig()` lee y parsea el JSON **en cada llamada** (sin caché → cambios en + caliente). +- `saveConfig(newConfig)` reescribe el archivo. + +Qué controla **`oasis-config.json`**: +- `themes.current` — tema CSS activo. +- `ux.current` — modo de interfaz (`"blocks"` o `"ainav"`). +- **`modules`** — ~50 flags `Mod: "on"|"off"` que activan/desactivan cada + módulo. En backend se comprueba con `checkMod(ctx, mod)` (líneas 170-177): si + está `off`, redirige a `/modules`. +- `wallet`/`walletPub`, `ai.prompt`, `ssbLogStream.limit` (límite de mensajes + leídos del log), `homePage`, `language`, `wish`, `pmVisibility`, + `lanBroadcasting`. + +**`src/configs/shared-state.js`** — estado en memoria (no persistente): +contador de inbox, huella de carbono, nº de peers online, valor eco, etc. +Lo actualiza el middleware periódico y lo consume `template`. + +--- + +## 2.7 Tabla de módulos (modelo ↔ vista) + +| Modelo | Vista | Notas | +|---|---|---| +| `main_models.js` | `main_views.js` | Núcleo: layout, i18n, temas, about/blob/friend | +| `activity_model` | `activity_view` | Feed de actividad | +| `agenda_model` | `agenda_view` | Agrega tasks/events/transfers/market/... | +| `audios_model` | `audio_view` | | +| `banking_model` | `banking_views` | ECOin, epochs | +| `blockchain_model` | `blockchain_view` | | +| `bookmarking_model` | `bookmark_view` | | +| `calendars_model` | `calendars_view` | Cifrado | +| `chats_model` | `chats_view` | Cifrado | +| `cipher_model` | `cipher_view` | | +| `courts_model` | `courts_view` | | +| `cv_model` | `cv_view` | | +| `documents_model` | `document_view` | | +| `events_model` | `event_view` | | +| `favorites_model` | `favorites_view` | Agrega favoritos | +| `feed_model` | `feed_view` | | +| `forum_model` | `forum_view` | Cifrado | +| **`games_model`** | **`games_view`** | Hall of fame + shell de juegos | +| `images_model` | `image_view` | | +| `inhabitants_model` | `inhabitants_view` | Perfiles | +| `jobs_model` | `jobs_view` | | +| `larp_model` | `larp_view` | | +| `legacy_model` | `legacy_view` | | +| `logs_model` | `logs_view` | | +| `maps_model` | `maps_view` | Cifrado | +| `market_model` | `market_view` | | +| `melody_model` | `melody_view` | | +| `opinions_model` | `opinions_view` | | +| `pads_model` | `pads_view` | Cifrado | +| `parliament_model` | `parliament_view` | | +| `pixelia_model` | `pixelia_view` | | +| `pm_model` | `pm_view` | Mensajería privada | +| `projects_model` | `projects_view` | | +| `reports_model` | `report_view` | | +| `search_model` | `search_view` | | +| `shops_model` | `shops_view` | | +| `stats_model` | `stats_view` | | +| `tags_model` | `tags_view` | | +| `tasks_model` | `task_view` | | +| `torrents_model` | `torrents_view` | | +| `transfers_model` | `transfer_view` | | +| `trending_model` | `trending_view` | | +| `tribes_model` + `tribes_content_model` | `tribes_view` | Cifrado | +| `videos_model` | `video_view` | | +| `votes_model` | `vote_view` | | +| `wallet_model` | `wallet_view` | | +| (sin modelo) | `AI_view` | Lógica en `src/AI/*` | +| `crypto.js`/`tribe_crypto.js` | — | Cifrado simétrico por dominio | + +--- + +## 2.8 Mapa de dependencias entre archivos + +**`backend.js` → modelos** (líneas 541-602): importa `main_models` y **todos** +los `*_model.js` como factories invocadas con `{ cooler, isPublic, ...deps }`. +Hay **inyección de dependencias entre modelos**: p.ej. `agenda_model` recibe +`{calendarsModel, eventsModel, tasksModel, marketModel, jobsModel, +projectsModel}`; `favorites_model` recibe casi todos los modelos de contenido. + +**`backend.js` → vistas** (líneas ~1162-1216 + `require` inline): importa las +funciones de render de cada `*_view.js`. Algunas se cargan diferidas dentro de +los handlers (`require('../views/...')`). + +**Modelos → importan**: `pull-stream`, `moment`, `./tombstone_validator`, +`../configs/config-manager`, helpers, y reciben `cooler` por parámetro (no +importan `gui` directamente). `tombstone_validator.js` no tiene dependencias +(función pura). + +**Vistas → importan**: hyperaxe, `{template, i18n, userLink, ...}` de +`main_views`, `moment`, y a veces `../server/SSB_server` para obtener +`config.keys.id` (el feedId propio). + +**Estado compartido**: `config-manager.js` (lee/escribe `oasis-config.json`) y +`shared-state.js` (memoria) son importados por backend, modelos y vistas; son +los puntos de coordinación transversal. `nameCache.js` (un Map en memoria) lo +alimenta `main_models` y lo consume `main_views`. + +Siguiente: **[03-modulos-y-juegos.md](03-modulos-y-juegos.md)**. diff --git a/docs/devs/architecture/03-modulos-y-juegos.md b/docs/devs/architecture/03-modulos-y-juegos.md new file mode 100644 index 0000000..0909358 --- /dev/null +++ b/docs/devs/architecture/03-modulos-y-juegos.md @@ -0,0 +1,216 @@ +# 3. El módulo de juegos y la anatomía de un módulo + +> **Hallazgo clave que cambia las expectativas:** el módulo de juegos de Oasis +> **NO es un sistema multijugador asíncrono por SSB**. Es mucho más simple: +> +> - Cada juego es un **único `index.html` autocontenido** (HTML + CSS + JS +> inline), 100% client-side, servido como archivo estático y embebido en un +> `