From b1b408971d0e5b29e50e5427965b6b64e09a9bdd Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Sat, 23 Nov 2024 17:52:28 -0800 Subject: [PATCH] Master into Deploys (#1391) * Thank you Murage Martin @murageyun for donating!!! * Fix opt.s3.fakes3 parsing issue (#1318) * Fix opt.s3.fakes3 parsing issue * Fix second typo within if block * Support variable number of auth retry attempts through opt.retries (#1325) Maintain default to 9 to ensure backwards compatibility * Thanks Jason Stallings @octalmage !!! * Remove unused imports (#1337) * Update README.md * yay format change * encode objects * WS ws.path fix (#1343) * Update wire.js * Update wire.js * Update wire.js * add one click deploy to readme (#1342) * update src/index (#1254) * update src/index * update * src/index fix * added src/core * is ??? this a MVP of book & rad ???? thanks to @rogowski * book & rad APIs stabilizing * RAD & Book promoted! + buggy example: test/rad/book.html * bump path * cleaned up Book results & sorting & caching * sea blobs! (#1353) * sea blobs! * and null origins * null fix * null check is last * add a way to select stats file from url (#1351) * react-native detection, and load needed shims (#1349) * react-native detection * added lib mobile * changed back to gun. for another solution * have unbuild function wrap to prevent scope leaks & allow RETURN hehehe so I can reject @bmatusiak 's lS change O:) O:) I love you you're a hero! later with @bmatusiak check sea.then for '../gun.js' vs '../' vs ... note: src/index -> core.js TODO: something about WebRTC candidates hitting ack decrement limits? * quick-fix (#1355) * Fix SEA certificate verification, allow multiple pubs (#1358) * Create SECURITY.md (#1364) * ... works (#1357) * Loading fix (#1356) * does this load better * check window.Gun too in rfs * update SECURITY.md file and change the versions to 0.2020.x (#1365) * webrtc accept getUserMedia streams as peer * Check atom exists in graph when deciding to read from disk (#1371) * fix: ERROR: Radisk needs `store.put` interface (#1374) * Update STUN servers (#1381) Commented out sipgate.net STUN server. Added Cloudflare STUN server. * universal notification system --------- Co-authored-by: ritchia1 Co-authored-by: Anton Co-authored-by: Bradley Matusiak Co-authored-by: Jay Byoun Co-authored-by: mimiza Co-authored-by: Simardeep Singh <1003simar@gmail.com> Co-authored-by: Malcolm Blaney Co-authored-by: Andreas Heissenberger Co-authored-by: carlin978 <120719190+carlin978@users.noreply.github.com> --- README.md | 12 +- SECURITY.md | 47 ++++++++ browser.js | 5 +- examples/basic/meet.html | 38 ++++++ examples/stats.html | 1 + gun.js | 253 +++++++++++++++++++++++++++++++++++++-- lib/axe.js | 31 ++++- lib/book.js | 188 +---------------------------- lib/radisk.js | 18 ++- lib/radisk3.js | 233 ----------------------------------- lib/radix.js | 11 +- lib/rfs.js | 4 +- lib/rs3.js | 6 +- lib/store.js | 2 +- lib/unbuild.js | 1 + lib/webrtc.js | 84 ++++++++----- lib/wire.js | 44 ++++--- package-lock.json | 14 +-- rad.js | 199 ++++++++++++++++++++++++++++++ sea.js | 13 +- sea/aeskey.js | 4 +- sea/array.js | 4 +- sea/auth.js | 13 +- sea/base64.js | 4 +- sea/buffer.js | 4 +- sea/certify.js | 4 +- sea/create.js | 6 +- sea/decrypt.js | 4 +- sea/encrypt.js | 4 +- sea/https.js | 8 +- sea/index.js | 6 +- sea/pair.js | 4 +- sea/recall.js | 6 +- sea/root.js | 5 +- sea/sea.js | 8 +- sea/secret.js | 4 +- sea/settings.js | 4 +- sea/sha1.js | 4 +- sea/sha256.js | 4 +- sea/share.js | 4 +- sea/shim.js | 10 +- sea/sign.js | 4 +- sea/then.js | 6 +- sea/user.js | 4 +- sea/verify.js | 4 +- sea/work.js | 4 +- src/ask.js | 4 +- src/back.js | 4 +- src/book.js | 215 +++++++++++++++++++++++++++++++++ src/chain.js | 5 +- src/core.js | 10 ++ src/dup.js | 5 +- src/get.js | 5 +- src/index.js | 22 +++- src/localStorage.js | 4 +- src/map.js | 6 +- src/mesh.js | 20 +++- src/on.js | 10 +- src/onto.js | 4 +- src/put.js | 4 +- src/root.js | 15 ++- src/set.js | 6 +- src/shim.js | 4 +- src/state.js | 4 +- src/valid.js | 6 +- src/websocket.js | 6 +- test/rad/book.html | 21 ++++ test/rad/book.js | 142 +++++++++++++++++++--- test/rad/mocha.html | 3 +- 69 files changed, 1259 insertions(+), 606 deletions(-) create mode 100644 SECURITY.md create mode 100644 examples/basic/meet.html delete mode 100644 lib/radisk3.js create mode 100644 rad.js create mode 100644 src/book.js create mode 100644 src/core.js create mode 100644 test/rad/book.html diff --git a/README.md b/README.md index 3eb99b6f..2b7290fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

-[![](https://data.jsdelivr.com/v1/package/gh/amark/gun/badge?style=rounded)](https://data.jsdelivr.com/v1/package/gh/amark/gun/stats) +[![](https://data.jsdelivr.com/v1/package/npm/gun/badge)](https://www.jsdelivr.com/package/npm/gun) ![Build](https://github.com/amark/gun/actions/workflows/ci.yml/badge.svg) [![Gitter](https://img.shields.io/gitter/room/amark/gun.js.svg)](http://chat.gun.eco) @@ -42,7 +42,7 @@ GUN is *super easy* to get started with: > **Note:** If you don't have [node](http://nodejs.org/) or [npm](https://www.npmjs.com/), read [this](https://github.com/amark/gun/blob/master/examples/install.sh) first. > If the `npm` command line didn't work, you may need to `mkdir node_modules` first or use `sudo`. -- An online demo of the examples are available here: http://gunjs.herokuapp.com/ +- An online demo of the examples are available here: http://try.axe.eco/ - Or write a quick app: ([try now in a playground](https://jsbin.com/kadobamevo/edit?js,console)) ```html @@ -156,7 +156,8 @@ Thanks to: Jacob Millner, Gerrit Balindt, Gabriel Lemon, -Murage Martin +Murage Martin, +Jason Stallings

- Join others in sponsoring code: https://www.patreon.com/gunDB ! @@ -260,6 +261,11 @@ You can now safely `CTRL+A+D` to escape without stopping the peer. To stop every Environment variables may need to be set like `export HTTPS_CERT=~/cert.pem HTTPS_KEY=~/key.pem PORT=443`. You can also look at a sample [nginx](https://gun.eco/docs/nginx) config. For production deployments, you probably will want to use something like `pm2` or better to keep the peer alive after machine reboots. +### [Dome](https://www.trydome.io/) +[Deploy GUN in one-click](https://app.trydome.io/signup?package=gun) with [Dome](https://trydome.io) and receive a free trial: + +[![Deploy to Dome](https://trydome.io/button.svg)](https://app.trydome.io/signup?package=gun) + ### [Heroku](https://www.heroku.com/) [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/amark/gun) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..7a0afd6d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,47 @@ +# Security Policy + +## Introduction + +Security is our top priority. We are committed to ensuring that our project is as secure as possible for everyone who uses it. This document outlines our security policy and procedures for dealing with security issues. + +## Supported Versions + +We provide security updates for the following versions of our project: + +| Version | Supported | +| ------- | ------------------ | +| 0.2020.x| :white_check_mark: | +| < 0.2020| :x: | + +## Reporting a Vulnerability + +If you discover a vulnerability, we would like to know about it so we can take steps to address it as quickly as possible. + +### Report Format + +When reporting vulnerabilities, please include the following details: + +- Description of the vulnerability +- Steps to reproduce the issue +- Potential impact if left unaddressed +- Suggested mitigation or resolution if any + +### Response Time + +We aim to confirm the receipt of your vulnerability report within 48 hours. Depending on the severity and complexity of the issue, we strive to investigate the issue and provide an initial response within a week. + +### Disclosure Policy + +If the vulnerability is confirmed, we will work on a fix and plan a release. We ask that you do not publicly disclose the issue until it has been addressed by us. + +## Security Practices + +We follow industry-standard security practices, including regular audits of the services and features we provide, to maintain the trust of our users. + +## Security Updates + +We will communicate any security updates through our standard communication channels, including our project's release notes and official website. + +## Conclusion + +We greatly value the work of security researchers and believe that responsible disclosure of vulnerabilities is a valuable contribution to the security of the Internet. We encourage users to contribute to the security of our project by reporting any security-related issues to us. \ No newline at end of file diff --git a/browser.js b/browser.js index 2459a30c..d4418a63 100644 --- a/browser.js +++ b/browser.js @@ -1 +1,4 @@ -module.exports = require('./gun.js') \ No newline at end of file +// if(!(typeof navigator == "undefined") && navigator.product == "ReactNative"){ +// require("./lib/mobile.js"); +// } +module.exports = require('./gun.js'); diff --git a/examples/basic/meet.html b/examples/basic/meet.html new file mode 100644 index 00000000..e91f8f27 --- /dev/null +++ b/examples/basic/meet.html @@ -0,0 +1,38 @@ + + +
must press play or unmute on new videos to accept meeting
+
+ +
+
Stream
+ + + + + + + \ No newline at end of file diff --git a/examples/stats.html b/examples/stats.html index 8223b3c8..171478fe 100644 --- a/examples/stats.html +++ b/examples/stats.html @@ -44,6 +44,7 @@ + \ No newline at end of file diff --git a/test/rad/book.js b/test/rad/book.js index 3dada386..3205b7a4 100644 --- a/test/rad/book.js +++ b/test/rad/book.js @@ -86,9 +86,18 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam expect(B.decode(B.encode("bo\\|\|row"))).to.be("bo\\|\|row"); expect(B.decode(B.encode("||\áãbbçcddéẽffǵghhíĩj́jḱkĺlḿmńñóõṕpqqŕrśsttẃwúǘũxxýỹźzàbcdèfghìjklm̀ǹòpqrstùǜẁxỳz|"))).to.be("||\áãbbçcddéẽffǵghhíĩj́jḱkĺlḿmńñóõṕpqqŕrśsttẃwúǘũxxýỹźzàbcdèfghìjklm̀ǹòpqrstùǜẁxỳz|"); }); + it('heal', function(){ + //var obj = {a: null, b: false, c: true, d: 0, e: 42, f: Infinity, h: "hello"}; + var page = '| |-|+|'+B.encode('he||o!')+'|+0|+42.69|'+B.encode('he|p')+'|+Infinity|'; + expect(B.slot(page)).to.be.eql([' ', '-', '+', '|2"he||o!', '+0', '+42.69', '|1"he|p', '+Infinity']); + }); + it.skip('encode decode object', function(){ + expect(B.decode(B.encode({foo: 'bar', a: 1}))).to.be.eql({foo: 'bar', a: 1}) + }); }); describe('BASIC API', function(done){ + // TODO: Mark return here, slot("") slot("ab") causes infinite loop with heal, so need to detect not corrupted yet. it('write', function(done){ rad('hello', 'world', function(err, ok){ @@ -98,7 +107,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam }); it('read', function(done){ - rad('hello', function(err, page){ + rad('hello', function(page, err){ var val = page.get('hello'); expect(val).to.be('world'); done(); @@ -135,7 +144,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam it('save '+type, done => { setTimeout(function(){ rad('type-'+type, type, function(err, ok){ expect(err).to.not.be.ok(); - rad('type-'+type, function(err, page){ + rad('type-'+type, function(page, err){ var val = page.get('type-'+type); expect(val).to.be(type); done(); @@ -145,7 +154,8 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam });}); describe('error on invalid primitives', function(){ - it('test invalid', done => { + console.log("TODO: TESTS! Add invalid data type tests, error checking. HINT: Maybe also add invisible ASCII character tests here too."); + it.skip('test invalid', done => { rad('type-NaN', NaN, function(err, ok){ expect(err).to.be.ok(); done(); @@ -160,8 +170,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam var prev = RAD(opt); prev('helloz', 'world', function(err, ok){ - - prev('helloz', function(err, page){ + prev('helloz', function(page, err){ prev('zalice', 'yay', function(err){ expect(page.text.split('helloz').length).to.be(2); done(); @@ -175,6 +184,25 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam */ }); + it('make sure word does not get duplicated when data is re-saved after read <', done => { + var opt = {file: 'azadata'} + var prev = RAD(opt); + + prev('helloz', 'world', function(err, ok){ + prev('helloz', function(page, err){ + prev('azalice', 'yay', function(err){ + expect(page.text.split('helloz').length).to.be(2); + done(); + }); + }); + }); + /* + (A) READ ONLY: we receive a message, we READ only - parseless is important. + (B) READ & WRITE: we write a page, and it already exists on disk. + (C) WRITE ONLY: we write a page, and it is new to disk. + */ + }); + it('test if adding an in-memory word merges with previously written disk data', done => { var prev = RAD(opt); @@ -183,14 +211,60 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam setTimeout(function(){ var rad = RAD(opt); - rad('pa-bob', 'banana', function(err, ok){ expect(err).to.not.be.ok(); var text = rad.book.list[0].text; var i = text.indexOf('pa-alice'); expect(i).to.not.be(-1); var ii = text.indexOf('hello'); - expect((ii - i) < 10).to.be.ok(); + expect((ii - i) < ('pa-alice'.length + 3)).to.be.ok(); + done(); + }) + },99); + }); + }); + + it('test if adding an in-memory word merges with previously written disk data <', done => { + var opt = {file: 'azadatab'} + var prev = RAD(opt); + + prev('pa-alice', 'hello', function(err, ok){ + expect(err).to.not.be.ok(); + + setTimeout(function(){ + var rad = RAD(opt); + rad('pa-alex', 'banana', function(err, ok){ + expect(err).to.not.be.ok(); + var text = rad.book.list[0].text; + var i = text.indexOf('pa-alice'); + expect(i).to.not.be(-1); + var ii = text.indexOf('hello'); + expect((ii - i) < ('pa-alice'.length + 3)).to.be.ok(); + done(); + }) + },99); + }); + }); + + it('test if adding an in-memory escaped word merges with previously written disk data', done => { + var opt = {file:'badata'}; + var prev = RAD(opt); + + prev('ba-bob', 'hello', function(err, ok){ + expect(err).to.not.be.ok(); + + setTimeout(function(){ + var rad = RAD(opt); + rad('ba-a|ice', 'banana', function(err, ok){ + expect(err).to.not.be.ok(); + var text = rad.book.list[0].text; + var i = text.indexOf('ba-a|ice'); + expect(i).to.not.be(-1); + var ii = text.indexOf('banana'); + expect((ii - i) < ('ba-a|ice'.length + 3)).to.be.ok(); + var iii = text.indexOf('ba-bob'); + if(iii < i){ console.log("ERROR! Escaped word not sorted correctly!!!") } + expect(iii > i).to.be.ok(); done(); }) },99); @@ -198,17 +272,18 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam }); it('test if updating an in-memory word merges with previously written disk data', done => { + var opt = {file:'pu-data'}; var prev = RAD(opt); + prev('pu-zach', 'zap'); + prev('pu-alex', 'yay'); prev('pu-alice', 'hello', function(err, ok){ expect(err).to.not.be.ok(); var rad = RAD(opt); - rad('pu-alice', 'cool', function(err, ok){ expect(err).to.not.be.ok(); - var next = RAD(opt); - next('pu-alice', function(err, page){ + next('pu-alice', function(page, err){ expect('cool').to.be(page.get('pu-alice')); done(); }) @@ -222,8 +297,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam function gen(val){ return val + String.random(99,'a') } var opt = {file: 'gen'} - //var rad = window.names = Book(); - var rad = window.names = RAD(opt); + var rad = RAD(opt); it('Generate more than 1 page', done => { var i = 0; @@ -238,13 +312,12 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam }); it('Make sure parseless lookup works with incrementally parsed values', done => { - rad = RAD(opt); - rad('adora', function(err, page){ + rad('adora', function(page, err){ var n = page.get('adora'); expect(gen('adora')).to.be(n); - rad('aia', function(err, page){ + rad('aia', function(page, err){ var n = page.get('aia'); expect(gen('aia')).to.be(n); done(); @@ -258,7 +331,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam rad = RAD(opt); names.forEach(function(name){ name = name.toLowerCase(); - rad(name, function(err, page){ + rad(name+'a', function(page, err){ var n = page.get(name); expect(gen(name)).to.be(n); @@ -282,9 +355,46 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam rad('c', r); });*/ + + it.skip('index metadata', done => { + localStorage.clear(); + var B = setTimeout.Book; + var r = setTimeout.RAD(); + //r('hello', 'world'); + //return; + var i = 200; while(--i){ r('store'+i, Math.random()+'r'+Math.random()) } + console.log('switch test to a test of replication, maybe with panic'); + r('store150', function(page, err){ + console.log("<<<<<<<<<"); + page.meta = 'https://localhost:9876,https://localhost:9877'; + var i = 200; while(--i){ r('store'+i+'b', Math.random()+'r'+Math.random()) } + console.log(">>>>>>>>>"); + }) + }); }); + describe('API usage checks', function(){ + var opt = {file: 'search'} + var search = RAD(opt); + var b = Book(); + it('read results from in-memory data', async done => { + b('hello', '1data'); + var r = b.page('wat').read(); + expect(r).to.be.eql(['1data']); + b('hello', '1dataZ'); + r = b.page('wat').read(); + expect(r).to.be.eql(['1dataZ']); + b('new', '2data'); + r = b.page('wat').read(); + expect(r).to.be.eql(['1dataZ','2data']); + done(); + }); + + }); + + console.log("Performance Tests: 2023 Nov 12, 60M put/sec, 120M get/sec, 1M get/sec with splits."); + }); var ntmp = names; diff --git a/test/rad/mocha.html b/test/rad/mocha.html index 22c7eace..08983087 100644 --- a/test/rad/mocha.html +++ b/test/rad/mocha.html @@ -17,8 +17,7 @@ - - +