amark on master
Thanks @gabriellemon Gabriel fo… (compare)
@amark. Please implement this Forum as multiple threads initiated by each user, not a single thread currently. It is just a mess. Shift this Forum to reddit, and leave gitter?
@amark how can I change the username or alias for gun.user()?
@amark. I want to implement state management on the Clent-side using gundb. I want to expose only a subset of nodes e.g. gun.get("sessionid") on Client-side. I searched a lot, but still have doubts what if client-side hacking may access full gun graph network using XSS/code-injection. What security measures should I take? Is including SEA library enough security measure?
@amark. I am implementing gundb for a production grade app.
// Clear out localstorage to give Gun a fresh start on every load
localStorage.clear()
// Import Gun as a dependency
import Gun from 'gun'
/
var gun = Gun();
/
const server = require('http').createServer().listen(8080);
const gun = Gun({web: server});
var items = gun.get('items');
$('form').on('submit', function(e){
e.preventDefault();
items.set($('input').val());
$('input').val("");
})
items.map().on(function(item, id){
var li = $('#' + id).get(0) || $('<li>').attr('id', id).appendTo('ul');
if(item){
$(li).text(item);
} else {
$(li).hide();
}
})
Hi,
Sorry if this is a silly question, but I've been going over the docs today and I don't quite understand conceptually how the scopes work. So I think I get how user contexts work with storing data like in the following snippet:
$('#said').on('submit', function(e){
e.preventDefault();
if(!user.is){ return }
user.get('said').set($('#say').val());
$('#say').val("");
});
where the get/set/map methods apply to that users space, but if any endpoint can set data into the global space doesn't that mean that the global data set can be flooded? or is there some logic in the relay servers that I'm not understanding that prevents arbitrary data from being ingested and stored?
thoughts on how i would achieve key pair rotation for users created with user.create
? reading the docs, it seems that gun users are essentially key pairs generated with SEA.pair()
. does this mean i need to keep my own way of mapping usernames/alias to a pair, something like:
SEA.pair(({pair}) => {
gun.get('users').
('@some_username').get('activePublicKey').put(pair.pub)
// use `.activePublicKey` to encrypt, certify, etc.
})
or will (nope that would return a "user already exists" error.) gun.user().create(oldUsername, oldPaassphrase)
automatically update the keys?
gun.get('@newAliasYouWant').set(user)
(where user
is logged in)local = GUN(); gun = GUN(peers);
. Does this help?async
, this would be very mysterious if true. Can you replicate?
@amark , I found something. gun.get("some").get("test")
is not exactly the same as gun.get("some/test")
the first one, obey the reference
/ soul. the second one, it straight up doesn't give a shit about reference
.
meaning using the example on the docs
gun.get('user/ambernadal/husband/name') // will result undefined 😭
gun.get('user').get('ambernadal').get('husband').get('name') // will resut Mark Nadal 💑
I haven't tested with null
value, but my guess is, you can bypass the null value, by directly accessing the node using /
edit : just tested it. Yup, it straight up ignore the null value.
both of these command will result the same thing:
gun.get('user').get('nadal').once(console.log)
gun.get('user/nadal').once(console.log)
note that you can't do :
gun.get('user/nadal').put({
firstName : "Mark"
})
it will throw error. because you need at least 2 get
if you want to put something.
so, instead you can do :
gun.get('user').get('nadal/firstName').put("Mark")
and it exactly will result the same
gun.get('user').get('first/second/third').put({"four" : "five"})
will result