Examples of various spatial categories in the gun database, such as public space, user space, and frozen space

It appears that the Gun functionality is quite impressive - both practical and user-friendly! However, I am having trouble grasping the distinction between a public space put, a user space put, and a frozen space put. I've tried to illustrate this with some straightforward examples:

Public Space

let gun = Gun() 
gun.put('hello') // Is this a public space put that anyone can edit? 

User Space

let user = gun.user() 
user.create('Bob','password123',console.log) 
user.auth('Bob' ,'password123',console.log) 
user.get('test').put("Bob's text") 


let user2 = gun.user() 
user2.create('Eve','password456',console.log) 
user2.auth('Eve' ,'password456',console.log) 
user2.get('test').put("Eve's text") 
gun.get('test').once(console.log)

// Would this result in separately indexed entries in the database?
// Is the verification integrated or left to the app developer?

Frozen Space

// Taken from the example:

var data = "hello world";
var hash = await SEA.work(data, null, null, {name: "SHA-256"});
gun.get('#').get(hash).put(data);

// Could another user potentially replace the value associated with this hash key? Is it the responsibility of the app developer to validate the returned result (and remove peers that provide incorrect information)? 

If a user could select any relay server (even ones that tamper with data randomly), how much of the authentication (user space) and content identification (frozen) is handled by the GUN protocol, and how much falls on the app developer(s)?

Can someone enhance the examples provided above?

EDIT

According to the documentation:

This is beneficial because it allows you to confirm that data has not been altered even if it is stored in a public space. Additionally, when using SEA with GUN, peers are prevented from modifying the data if a specific name/key combination of '#'+hash is utilized.

It appears that the content addressing, frozen space, is inherently integrated into the system.

Answer №1

Shared Workspace

Collaboration is key.

let workspace = Workspace() 
workspace.get('foo').put({hello: 'world'})

Documentation:


Individual Workspace (or Personal Workspace)

Only data authorized by the individual's key can be added. Utilizes SEA.

The ~ symbol signifies access to individual workspace. Workspace interprets this as "only permitting data signed by the specified key to be added here"

let Jane = await SEA.pair();
await workspace.user().auth(Jane) 
workspace.get('~'+Jane.pub).get('test').get('TestProperty').put("Greetings from Jane",console.log) 

let Alex = await SEA.pair() 
await workspace.user().auth(Alex) // commenting this code out will result in failure, as authorized user is Jane not Alex
workspace.get('~'+Alex.pub).get('test').get('TestProperty').put("Greetings from Alex",console.log) 

Documentation:


Secured Workspace (Hashed Workspace, Data Id Workspace)

The # operator denotes "Data can only be added here if its hash corresponds with the assigned hash object."

var info = "hello world";
var hashed = await SEA.work(info, null, null, {name: "SHA-256"});
workspace.get('#').get(hashed).put(info);

Referencing docs:


Additionally, I have observed that you can implement a secured workspace on top of an individual workspace but not the other way around:

//functioning (data hash id enforced)
workspace.get(pub).get('#').get('bR+eukWF7mYgxibHHRc6tJ+G6PIMEB91O1WVEbAYuWU=').put('NJViiTklbpVb2mmXmRel1cZ0F5lm6ZSTAjYg3RWhqkU.qbu9aOlUXGbrFwqZqeLdw2KiMlpj3QMbezmGRm4u7l0') 

//you cannot append data to a # object like this
workspace.get('#').get('bR+eukWF7mYgxibHHRc6tJ+G6PIMEB91O1WVEbAYuWU=').get('NJViiTklbpVb2mmXmRel1cZ0F5lm6ZSTAjYg3RWhqkU.qbu9aOlUXGbrFwqZqeLdw2KiMlpj3QMbezmGRm4u7l0').put({'different':'matter'}) 

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you explain how to utilize prop values for setting attributes in styled-components v4 with TypeScript?

Overview Situation: const Link = styled.a` border: solid 1px black; border-radius: 5px; padding: 5px; margin: 10px 5px; `; type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>; const LinkAsButton = styled(Link).attrs<ButtonP ...

I'm encountering some issues trying to install next-auth in my project built with Next.js and React

I recently set up my Next.js project with React using yarn create next-app. However, I am facing an issue as the next-auth package is not installed in my project. Currently, my node version is LTS 16.15.1, yarn version is 1.22.18, and npm version is 8.9. ...

Converting ed25519 private key into OpenSSH Format using JavaScript

After generating an ed25519 key pair using the javascript crypto library, I am now faced with the challenge of saving the private key in openssh format. Despite attempting to use the sshpk library for this task, I encountered an issue where the exported k ...

Tips for successfully retrieving a boolean value from an ASP.Net JavaScript AJAX request using a C# method

Query: Is there a way to call a C# function from JavaScript code on an .aspx webpage to get authentication results based on a username and password? Here is the JavaScript AJAX POST request I am currently using: $.ajax({ type: "POST", ...

Creating a React Native project without the use of TypeScript

Recently I dived into the world of React Native and decided to start a project using React Native CLI. However, I was surprised to find out that it uses TypeScript by default. Is there a way for me to create a project using React Native CLI without TypeS ...

What is the best way to create a backup copy of my project using git?

To ensure the safety of my project, I took the necessary steps to back it up. First, I initialized a repository using git init Following that, I committed all files by executing git add . git commit -am "first commit" Now, the next step involves pushin ...

Tips for accessing jQuery UI tab elements and adjusting visibility for specific panels

How can I retrieve the panel numbers of jQuery UI tabs and adjust their visibility using CSS? I am looking to identify the panel numbers of each tab and control the visibility of certain tabs. <div id="tabs"> <ul> <li><a href="#"> ...

Add a fresh text field with the click of a button and delete it with another button in Laravel 4

My form includes two fields: phone and email, as shown in the image below. By clicking on the plus button, I would like to add an additional text field to the form below the button. Similarly, by clicking on the minus button, I want to remove the text fie ...

Setting form values using Angular 9

I am currently facing a challenge that I could use some assistance with. My dilemma involves integrating a new payment system, and I seem to be encountering some obstacles. Here is a snippet of what I have: options: PaystackOptions= { amount: 5000, emai ...

Having difficulty updating the parent for all PortfolioItem/Feature that were copied for a specific PortfolioItem/MMF

I'm facing a challenge in setting the parent for multiple features that I've copied for a specific MMF. However, only the parent of the last feature is being set. Below is the code snippet responsible for setting the parent: Record represents th ...

Retrieve JSON data within a service and provide it to a component

I am currently facing an issue with loading data from a JSON file into my component using a service. The data is successfully loaded in the service, as confirmed by the console log; however, when trying to access the data in the component, it does not disp ...

Is it possible to utilize the function(e) multiple times within a single file?

Can the same function be used multiple times in a single file? document.getElementById('one').onlick = function test(e) { var key = e.which; if(key === 13) { document.getElementById('two').c ...

The error message "User is not a constructor in Express when using Passport"

I encountered an issue while trying to set up registration in Express using passport.js. After submitting the form, the server console displayed the following error: POST /user/register 500 62.273 ms - 2008 TypeError: User is not a constructor at /mea ...

Use React to increment a variable by a random value until it reaches a specific threshold

I am currently working on creating a simulated loading bar, similar to the one seen on YouTube videos. My goal is for it to last 1.5 seconds, which is the average time it takes for my page to load. However, I have encountered an issue with the following co ...

Why doesn't the Iframe onLoad event trigger when uploading a file?

I have a straightforward iframe <iframe class="ifr" src="about:blank"></iframe> It contains an onload handler. $(".ifr").on('load',function (){ alert("iframe loaded") }); There are also two buttons: Pressing the first button ...

Concealing items by placing them strategically between the camera and certain objects in Three.js

At the moment, my project involves utilizing three.js with several objects in the scene. One of the key features I am working on is the ability to select an object and have all other objects between the camera and the selected one hidden or removed. I am ...

Tips for formatting JSON using jQuery

Imagine my JSON data with 3 different sets of information: [ { "Pair":"", "Id":"8ca2df56-2523-4bc3-a648-61ec4debcaaf", "PubDate":"/Date(1463775846000)/", "Provider":null, "Market":"" }, { "Pair":"", ...

An object that appears to be empty at first glance, but contains values that are undefined

I am facing an issue with my object that I am populating with information. The logs show the object as empty, but when I inspect it in Chrome, it appears to have the correct details filled in. Here is a snapshot of what the logs display: closed: closed o ...

Is there a way to retrieve time data from a different server through AJAX?

I am in need of obtaining time information from an online source, whether it be an NTP server, JSON time server, or simply an HTTP Header. The precision is not important to me, but the requirement is that I must get the time from an online source. Unfortun ...

Submitting form data to PHP without refreshing the page

I've been attempting to send form data, specifically an array, to a PHP file without having the page refresh. I've implemented AJAX for this purpose but it doesn't appear to be working as intended. Below you'll find the syntax of the fo ...