'Understanding and updating the gun user alias system
On the gun alias
system:
Is it like a phone book (public key book) where every user could have a different name for each key?
Is it stored in a user's user space, or is there some kind of local dict, or is it more of a global/universe thing?
There seems to be two ways to initialise a user:
1: via an alias and password, e.g.
let eve = gun.user().auth('Eve' ,'password123')
How do you recover the public key for eve
?
Here's what I have but is seems like there'd be a better way:
let userObj
let eve= gun.user().auth('Eve' ,'password456',(u)=>{userObj = u})
let evePub = userObj.put.pub // or eve._.put.pub
2: via SEA pair, e.g.
let bob = await SEA.pair();
await gun.user().auth(bob)
How do you set an alias for bob
?
Perhaps I have to set SEA.name
or something to do with ~@
in the user space, but I'm not sure..
Solution 1:[1]
- To get the public key for user
eve
use the call back function:
let pub = await new Promise (res => user.auth('Eve' ,'password123',ack =>
{
if (!ack.err) {
res(ack.put.pub)
}
else {
res(ack.err)
}
}))
- The alias is set in the
~@<alias>
property of the~publicKeyOfUser
node, like this:
let link = {};
let alias = 'bob'
link['~'+bob.pub] = {'#': '~'+bob.pub};
gun.get('~'+bob.pub).get('~@'+alias).put(link)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | atomh33ls |