AgregoreWeb / agregore-browser

A minimal browser for the distributed web (Desktop version)
https://www.youtube.com/watch?v=TnYKvOQB0ts&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=14
GNU Affero General Public License v3.0
748 stars 66 forks source link

Add GUN protocol #81

Closed RangerMauve closed 2 years ago

RangerMauve commented 3 years ago

It'd be cool to flush out a gun-fetch protocol handler.

Main stuff that we'd need to figure out:

cc @amark

RangerMauve commented 3 years ago

Nice. The query thing in particular is looking nice.

How do you feel about merging gun://_pubkey and gun://$something? I was thinking it could be something like gun://$pubkey/something would be gun.user(pubkey).get(something) and gun://$/something would be gun.user().auth().get(something). That way $ would represent "the current user" and $pubkey would represent "a specific user".

As well, would the concepts of aliases be combineable? Like, wold it be possible to detect when something is a pubkey and when something is an alias and automatically convert the string? e.g. $somebody is different from $46ee244685c57a89587264affa072c5adae86c19fef686084f3ad66203b86c5e and could be detected in code.

Would you be down for me submitting a PR with some of these changes?

resession commented 3 years ago

How do you feel about merging gun://_pubkey and gun://$something? I was thinking it could be something like gun://$pubkey/something would be gun.user(pubkey).get(something) and gun://$/something would be gun.user().auth().get(something). That way $ would represent "the current user" and $pubkey would represent "a specific user".

then we would only have 1 current user, which means losing the ability to have multiple logged in users. as of right now, we have the ability to log in multiple users because we can specify with the . character. if we merge pubkey and current user, then one will lose out.

As well, would the concepts of aliases be combineable? Like, wold it be possible to detect when something is a pubkey and when something is an alias and automatically convert the string? e.g. $somebody is different from $46ee244685c57a89587264affa072c5adae86c19fef686084f3ad66203b86c5e and could be detected in code.

that is what we are currently doing. _ is for both pubkey and alias(of other specific users)


updated the package again. so there are only 2 special characters now. - and _. - is for hex encoded hostname. such as gun://-someHexEncodedThingHere, 'someHexEncodedThingHere' can be 'someThing', gun-fetch will decode it, this is a way to get around browsers lowercasing the hostname `by itself such as gun://_/ means you want user creation/login/logout/destroy, body will contain username and password _with a pubkey, such as gun://_so-me.pub-key, gundb pubkey's have dashes and periods, so if the hostname has dashes and periods, we know its a pubkey _` with an alias, such as gun://_someAlias, here is where the main change is, so is someAlias is the current user, then it will return the logged in user for crud, if someAlias is not logged in as a user, then it will treat it like someone else(another specific user) so if _someAlias/something is not logged in -> gun.get('~@someAlias').get('something'), if _someAlias/something is logged in then -> gun.user().auth(someAlias).get('something')


yeah, do a pull request. though check out the changes that i made first. if there are changes you still want to make then yeah submit a pull request.

RangerMauve commented 2 years ago

Sweet, sounds good to me! Would you like to send in a PR with the protocol handler? I'm down to update the docs once that's in. 😁

resession commented 2 years ago

@RangerMauve pull request has been made

RangerMauve commented 2 years ago

Gonna close it now that it's been released as part of v1.0.0-44

Thanks again for your hard work @resession !