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 @@ - - +