diff --git a/README.md b/README.md index 2a68319..dc77b55 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,12 @@ SPDX-License-Identifier: CC0-1.0 --> # Go-SSB Room -[![REUSE status](https://api.reuse.software/badge/github.com/ssb-ngi-pointer/go-ssb-room)](https://api.reuse.software/info/github.com/ssb-ngi-pointer/go-ssb-room) +[![REUSE status](https://api.reuse.software/badge/github.com/ssbc/go-ssb-room)](https://api.reuse.software/info/github.com/ssbc/go-ssb-room) This repository implements the [Room (v1+v2) server spec](https://github.com/ssbc/rooms2), in Go. It includes: -* secret-handshake+boxstream network transport, sometimes referred to as SHS, using [secretstream](https://github.com/cryptoscope/secretstream) +* secret-handshake+boxstream network transport, sometimes referred to as SHS, using [secretstream](https://github.com/ssbc/go-secretstream) * muxrpc handlers for tunneling connections * a fully embedded HTTP server & HTML frontend, for administering the room @@ -45,4 +45,3 @@ For an in-depth codebase walkthrough, see the [development.md](./docs/developmen ## License MIT - diff --git a/cmd/insert-user/main.go b/cmd/insert-user/main.go index 6d70322..ce97ea5 100644 --- a/cmd/insert-user/main.go +++ b/cmd/insert-user/main.go @@ -19,10 +19,10 @@ import ( _ "github.com/mattn/go-sqlite3" "golang.org/x/crypto/ssh/terminal" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite" ) func main() { @@ -90,7 +90,7 @@ func main() { } ctx := context.Background() - mid, err := db.Members.Add(ctx, *pubKey, role) + mid, err := db.Members.Add(ctx, pubKey, role) check(err) err = db.AuthFallback.SetPassword(ctx, mid, string(bytePassword)) diff --git a/cmd/server/main.go b/cmd/server/main.go index d5463c0..f976e8b 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -26,21 +26,21 @@ import ( _ "net/http/pprof" _ "github.com/mattn/go-sqlite3" + "github.com/ssbc/go-muxrpc/v2/debug" "github.com/throttled/throttled/v2" "github.com/throttled/throttled/v2/store/memstore" "github.com/unrolled/secure" - "go.cryptoscope.co/muxrpc/v2/debug" kitlog "go.mindeco.de/log" "go.mindeco.de/log/level" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" - mksrv "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/handlers" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite" + "github.com/ssbc/go-ssb-room/v2/roomsrv" + mksrv "github.com/ssbc/go-ssb-room/v2/roomsrv" + "github.com/ssbc/go-ssb-room/v2/web/handlers" ) // Version and Build are set by ldflags @@ -375,7 +375,7 @@ func runroomsrv() error { // all init was successfull level.Info(log).Log( "event", "serving", - "ID", roomsrv.Whoami().Ref(), + "ID", roomsrv.Whoami().String(), "shsmuxaddr", listenAddrShsMux, "httpaddr", listenAddrHTTP, "version", version, "commit", commit, diff --git a/docs/architecture.md b/docs/architecture.md index 289fa40..20dadc2 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -9,9 +9,9 @@ SPDX-License-Identifier: CC0-1.0 ## Invite flow This implementation of Rooms 2.0 is compliant with the [Rooms 2.0 -specification](https://github.com/ssb-ngi-pointer/rooms2), but we add a few additional features +specification](https://github.com/ssbc/rooms2), but we add a few additional features and pages in order to improve user experience when their SSB app does not support [SSB -URIs](https://github.com/ssb-ngi-pointer/ssb-uri-spec). +URIs](https://github.com/ssbc/ssb-uri-spec). A summary can be seen in the following chart: @@ -25,7 +25,7 @@ in a form. ## Sign-in flow This implementation is compliant with [SSB HTTP -Authentication](https://github.com/ssb-ngi-pointer/ssb-http-auth-spec), but we add a few +Authentication](https://github.com/ssbc/ssb-http-auth-spec), but we add a few additional features and pages in order to improve user experience. For instance, besides conventional SSB HTTP Auth, we also render a QR code to sign-in with a remote SSB app (an SSB identity not on the device that has the browser open). We also support sign-in with @@ -33,4 +33,4 @@ username/password, what we call "fallback authentication". A summary can be seen in the following chart: -![Chart](./images/login-chart.png) \ No newline at end of file +![Chart](./images/login-chart.png) diff --git a/docs/deployment.md b/docs/deployment.md index 18328cf..774c117 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -5,15 +5,16 @@ SPDX-License-Identifier: CC0-1.0 --> # Getting Started + There are two paths to starting your own room: creating a build from source, or downloading one of the premade releases. ## Premade builds -See the [releases page](https://github.com/ssb-ngi-pointer/go-ssb-room/releases) for packaged linux releases. +See the [releases page](https://github.com/ssbc/go-ssb-room/releases) for packaged linux releases. We currently only distributed pre-packaged releases for Debian-compatible distributions. -See [Issue #79](https://github.com/ssb-ngi-pointer/go-ssb-room/issues/79) for the details. +See [Issue #79](https://github.com/ssbc/go-ssb-room/issues/79) for the details. If this doesn't work for you, read the "Creating a build" section below. After running `sudo dpkg -i go-ssb-room_v1.2.3_Linux_x86_64.deb` pay special attention to the @@ -22,7 +23,7 @@ After running `sudo dpkg -i go-ssb-room_v1.2.3_Linux_x86_64.deb` pay special att ## Creating a build * [Download Go](https://golang.org/doc/install) & [set up your Go environment](https://golang.org/doc/install#install). You will need at least Go v1.16. -* Download the repository `git clone git@github.com:ssb-ngi-pointer/go-ssb-room.git && cd go-ssb-room` +* Download the repository `git clone git@github.com:ssbc/go-ssb-room.git && cd go-ssb-room` * [Follow the development instructions](./development.md) * You should now have a working go-ssb-room binary! Read the HTTP Hosting section below and admin user sections below, for more instructions on the last mile. @@ -32,7 +33,7 @@ After running `sudo dpkg -i go-ssb-room_v1.2.3_Linux_x86_64.deb` pay special att This project includes a docker-compose.yml file as well as a Docker file. Using it should be fairly straight forward. -Start off by making a copy of `.env_example` called `.env` and insert your +Start off by making a copy of `.env_example` called `.env` and insert your website domain there. With that done execute ``` @@ -78,7 +79,7 @@ Two bits of rationale: 1. People usually want to have more than one site on their server. Put differently, we could have [LetsEncrypt](https://letsencrypt.org/) inside the go-ssb-room server but it would have to -listen on port :443—blocking the use of other domains on the same IP. +listen on port :443—blocking the use of other domains on the same IP. 2. Listening on :443 can be pretty annoying (you might need root privileges or similar capabilities). go-ssb-room needs three headers to function properly, which need to be forwarded by the @@ -111,7 +112,7 @@ is often added automatically by your provider. When the process is complete with `certbot`, pay attention to where the certificate has been placed in the filesystem. If it's at `/etc/letsencrypt/live/hermies.club`, it's correct, otherwise you may -need to rename it e.g. `hermies.club-0001` to `hermies.club`. +need to rename it e.g. `hermies.club-0001` to `hermies.club`. The example nginx configuration uses prebuilt Diffie-Hellman parameters. You can generate these with the following command: @@ -184,5 +185,4 @@ Or if you installed go-ssb-room using the Debian package: sudo ./insert-user -repo "/var/lib/go-ssb-room" "@Bp5Z5TQKv6E/Y+QZn/3LiDWMPi63EP8MHsXZ4tiIb2w=.ed25519" ``` -It will ask you to create a password to access the web-front-end. You can now login in the web-front-end using these credentials - +It will ask you to create a password to access the web-front-end. You can now login in the web-front-end using these credentials. diff --git a/docs/development.md b/docs/development.md index cac0afe..3792f6d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -69,8 +69,8 @@ go generate ./... cd cmd/server && go build && ./server -htts-domain=my.room.example ``` - ## Tooling + ### Mocks [`counterfeiter`](https://github.com/maxbrunsfeld/counterfeiter) enables generating mocks for defined interfaces. To update the mocks, run `go generate` in package roomdb. @@ -126,7 +126,7 @@ See the [testing.md](./testing.md) for a thorough walkthorugh of the different t ## Release packaging -Because of [issue #79](https://github.com/ssb-ngi-pointer/go-ssb-room/issues/79) we can't simply create binaries for all platforms independantly. Therefore binaries for re-distributions need to be created on the relevant distributions themselvs. We currently do this for debian. The process is as follows: +Because of [issue #79](https://github.com/ssbc/go-ssb-room/issues/79) we can't simply create binaries for all platforms independantly. Therefore binaries for re-distributions need to be created on the relevant distributions themselvs. We currently do this for debian. The process is as follows: 1) Install a recent debian stable version onto a dedicated machine or VM for instance (docker might also be possible). 2) Install [Go](https://golang.org/doc/install). diff --git a/docs/files/debian-postinstall.sh b/docs/files/debian-postinstall.sh index 88d18b9..c8a6358 100644 --- a/docs/files/debian-postinstall.sh +++ b/docs/files/debian-postinstall.sh @@ -16,12 +16,12 @@ It will store it's files (roomdb and cookie secrets) under /var/lib/go-ssb-room. This is also where you would put custom translations. For more configuration background see /usr/share/go-ssb-room/README.md -or visit the code repo at https://github.com/ssb-ngi-pointer/go-ssb-room/tree/master/docs +or visit the code repo at https://github.com/ssbc/go-ssb-room/tree/master/docs Like outlined in that document, we highly encourage using nginx with certbot for TLS termination. We also supply an example config for this. You can find it under /usr/share/go-ssb-room/nginx-example.conf -> Important +> Important Before you start using room server via the systemd service, you need to at least change the https domain in the systemd service. diff --git a/docs/testing.md b/docs/testing.md index 43f6fac..5a758c5 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -37,21 +37,25 @@ The frontend tests—tests that check for the presence of various elements on se the module [`goquery`](https://github.com/PuerkitoBio/goquery) for querying the returned HTML. ## Snippets + #### Print the raw html of the corresponding page + ``` - html, _ := ts.Client.GetHTML(url) - fmt.Println(html.Html()) +html, _ := ts.Client.GetHTML(url) +fmt.Println(html.Html()) ``` #### Find and print the `title` element of a page + ``` - html, _ := ts.Client.GetHTML(url) - title := html.Find("title") - // print the title string - fmt.Println(title.Text()) +html, _ := ts.Client.GetHTML(url) +title := html.Find("title") +// print the title string +fmt.Println(title.Text()) ``` ## Filling the mockdb + `go-ssb-room` uses database mocks for performing tests against the backend database logic. This means prefilling a route with the data you expect to be returned when the route is queried. This type of testing is an alternative to using an entire pre-filled sqlite database of test @@ -59,7 +63,7 @@ data. As such, there is no command you run first to generate your fake database, but functions you have to call in a kind of pre-test setup, inside each testing -block you are authoring. +block you are authoring. > [counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) generates a bunch of methods for each function, so you have > XXXXReturns, XXXCallCount XXXArgsForCall(i) etc @@ -72,6 +76,7 @@ That is, for a function `GetUID` there is a corresponding mock-filling function The following examples show more concretely what mocking the data looks like. **Having the List() function return a static list of three items:** + ```go // go-ssb-room/web/handlers/admin/allow_list_test.go:113 lst := roomdb.ListEntries{ @@ -80,10 +85,10 @@ lst := roomdb.ListEntries{ {ID: 3, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: "true"}}, } ts.MembersDB.ListReturns(lst, nil) - ``` **Checking how often RemoveID was called and with what arguments:** + ```go // go-ssb-room/web/handlers/admin/allow_list_test.go:210 a.Equal(1, ts.MembersDB.RemoveIDCallCount()) @@ -91,8 +96,8 @@ ts.MembersDB.ListReturns(lst, nil) a.EqualValues(666, theID) ``` - ## Example test + ```go package handlers @@ -144,4 +149,3 @@ cd muxrpc/test/nodejs npm ci go test ``` - diff --git a/go.mod b/go.mod index 46f7b3d..c10cd95 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Unlicense -module github.com/ssb-ngi-pointer/go-ssb-room/v2 +module github.com/ssbc/go-ssb-room/v2 go 1.16 @@ -20,30 +20,29 @@ require ( github.com/mattevans/pwned-passwords v0.3.0 github.com/mattn/go-sqlite3 v2.0.3+incompatible github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0 - github.com/mileusna/useragent v1.0.2 // indirect + github.com/mileusna/useragent v1.0.2 github.com/nicksnyder/go-i18n/v2 v2.1.2 github.com/pkg/errors v0.9.1 github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351 github.com/russross/blackfriday/v2 v2.1.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e - github.com/stretchr/testify v1.7.0 + github.com/ssbc/go-muxrpc/v2 v2.0.14-0.20221020091224-b09bdf60812f + github.com/ssbc/go-netwrap v0.1.5-0.20221019160355-cd323bb2e29d + github.com/ssbc/go-secretstream v1.2.11-0.20221019175226-fa042d4912fe + github.com/ssbc/go-ssb-refs v0.5.2-0.20221019090322-8b558c2f31de + github.com/stretchr/testify v1.8.0 github.com/throttled/throttled/v2 v2.7.1 github.com/unrolled/secure v1.0.8 github.com/vcraescu/go-paginator/v2 v2.0.0 github.com/volatiletech/sqlboiler/v4 v4.5.0 github.com/volatiletech/strmangle v0.0.1 - go.cryptoscope.co/muxrpc/v2 v2.0.6 - go.cryptoscope.co/netwrap v0.1.1 go.cryptoscope.co/nocomment v0.0.0-20210520094614-fb744e81f810 - go.cryptoscope.co/secretstream v1.2.8 go.mindeco.de v1.12.0 - go.mindeco.de/ssb-refs v0.2.0 - golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a + golang.org/x/crypto v0.0.0-20221012134737-56aed061732a golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/text v0.3.5 golang.org/x/tools v0.1.1 gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) exclude go.cryptoscope.co/ssb v0.0.0-20201207161753-31d0f24b7a79 diff --git a/go.sum b/go.sum index 4c7308a..89da54e 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= +filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= @@ -223,14 +225,26 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= +github.com/ssbc/go-luigi v0.3.7-0.20221019204020-324065b9a7c6 h1:4Mhg4qHaiX56eXNND9gGJAf0xzoRQQtfFFhv6wcIOIU= +github.com/ssbc/go-luigi v0.3.7-0.20221019204020-324065b9a7c6/go.mod h1:tBPMBysJeh1u3vStvrWe5w3YBC4fnbnGsLk5ML4D6do= +github.com/ssbc/go-muxrpc/v2 v2.0.14-0.20221020091224-b09bdf60812f h1:eIzrej3VH9sYd13X8zVVzlsDRh0uCjYCbdsLcsZqrnc= +github.com/ssbc/go-muxrpc/v2 v2.0.14-0.20221020091224-b09bdf60812f/go.mod h1:CFvV9kCI3SmJM38pf1NCXWrS7UVgTYXJdKs+Q9hkJIw= +github.com/ssbc/go-netwrap v0.1.5-0.20221019160355-cd323bb2e29d h1:UnYPPekKU0mHzMMOSuI6117Djq9xni60c/IzzUYxgCI= +github.com/ssbc/go-netwrap v0.1.5-0.20221019160355-cd323bb2e29d/go.mod h1:tsE1qeqkc8kvf1psPNdJ5s8O+/jE1WlKwsEETb2VZqs= +github.com/ssbc/go-secretstream v1.2.11-0.20221019175226-fa042d4912fe h1:naU+qPze58a1vOf4J0Glglc1GoTvRkuCv3+sWziocf4= +github.com/ssbc/go-secretstream v1.2.11-0.20221019175226-fa042d4912fe/go.mod h1:imXhXNa5OfEL+qrGtOs6NZ9zJe6L3P+ZwFVC2mIgH0E= +github.com/ssbc/go-ssb-refs v0.5.2-0.20221019090322-8b558c2f31de h1:av0v73MeB+HASXfbtr3+r1dWD1DrYlGEIMCdVKV09Ag= +github.com/ssbc/go-ssb-refs v0.5.2-0.20221019090322-8b558c2f31de/go.mod h1:TRIqkOhZERfVzB+NoO3eUoru0ceQAsDnfZricPd1sUM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/throttled/throttled/v2 v2.7.1 h1:FnBysDX4Sok55bvfDMI0l2Y71V1vM2wi7O79OW7fNtw= github.com/throttled/throttled/v2 v2.7.1/go.mod h1:fuOeyK9fmnA+LQnsBbfT/mmPHjmkdogRBQxaD8YsgZ8= @@ -258,22 +272,11 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= -go.cryptoscope.co/luigi v0.3.5 h1:6rrNciUqbuwphT7hIjFd8eVRP3IatDX6HxdHs/Qo+Zw= -go.cryptoscope.co/luigi v0.3.5/go.mod h1:vJZOaxKWLWTC5oRWBOGVVW9X+o6nikLZSYUF9bvPd2w= -go.cryptoscope.co/muxrpc/v2 v2.0.6 h1:AzzrPQnx9sqUlqczJMOes9sQqYKvINz7Ie1ZJIdgy/Y= -go.cryptoscope.co/muxrpc/v2 v2.0.6/go.mod h1:og3Wr0CWnJBVp3aiRa9MmmTUQh901wWNjI96+o3NZag= -go.cryptoscope.co/netwrap v0.1.0/go.mod h1:7zcYswCa4CT+ct54e9uH9+IIbYYETEMHKDNpzl8Ukew= -go.cryptoscope.co/netwrap v0.1.1 h1:JLzzGKEvrUrkKzu3iM0DhpHmt+L/gYqmpcf1lJMUyFs= -go.cryptoscope.co/netwrap v0.1.1/go.mod h1:7zcYswCa4CT+ct54e9uH9+IIbYYETEMHKDNpzl8Ukew= go.cryptoscope.co/nocomment v0.0.0-20210520094614-fb744e81f810 h1:Sa7Q5X/La6bVTNT8Vcnt9GIGuOFOEFmjY3UNiwPErQk= go.cryptoscope.co/nocomment v0.0.0-20210520094614-fb744e81f810/go.mod h1:SJ9qQwHw1S7F2RsE9Ez9RmBhGpIdAphG1xGnI0rdKUI= -go.cryptoscope.co/secretstream v1.2.8 h1:M/2EYQfj2A97oe44jGWFDMxgu9NsRnjRSTnz1WPWTnA= -go.cryptoscope.co/secretstream v1.2.8/go.mod h1:OjHU/Io8LYyBxv1ehWohsFyyz4fVcKGozAzLoj6il50= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.mindeco.de v1.12.0 h1:K5FHILjJlD/U1HJMs8Y9ZLwdfG4dPEsxw+e+eqg1wKc= go.mindeco.de v1.12.0/go.mod h1:dZty08izAk/rSX8wSLen4gMR4WDPYmA6vUTE0QtepHA= -go.mindeco.de/ssb-refs v0.2.0 h1:KL+W2gq8ZeUzoFsPlKL0G/oThYeJKscqq8V3D0AgMoc= -go.mindeco.de/ssb-refs v0.2.0/go.mod h1:Ysyvb0aGeR721Nvu5V7mCJtkQP1fwf0qEBLA4FXHXXk= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= @@ -376,8 +379,8 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/sqlite v1.1.3 h1:BYfdVuZB5He/u9dt4qDpZqiqDJ6KhPqs5QUqsr/Eeuc= gorm.io/driver/sqlite v1.1.3/go.mod h1:AKDgRWk8lcSQSw+9kxCJnX/yySj8G3rdwYlU57cB45c= gorm.io/gorm v1.20.1/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= diff --git a/internal/aliases/confirm.go b/internal/aliases/confirm.go index 44736b6..38ef032 100644 --- a/internal/aliases/confirm.go +++ b/internal/aliases/confirm.go @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT -// Package aliases implements the validation and signing features of https://ssb-ngi-pointer.github.io/rooms2/#alias +// Package aliases implements the validation and signing features of https://ssbc.github.io/rooms2/#alias package aliases import ( @@ -10,7 +10,7 @@ import ( "golang.org/x/crypto/ed25519" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" ) // Registration ties an alias to the ID of the user and the RoomID it should be registered on @@ -33,9 +33,9 @@ func (r Registration) Sign(privKey ed25519.PrivateKey) Confirmation { func (r Registration) createRegistrationMessage() []byte { var message bytes.Buffer message.WriteString("=room-alias-registration:") - message.WriteString(r.RoomID.Ref()) + message.WriteString(r.RoomID.String()) message.WriteString(":") - message.WriteString(r.UserID.Ref()) + message.WriteString(r.UserID.String()) message.WriteString(":") message.WriteString(r.Alias) return message.Bytes() diff --git a/internal/aliases/confirm_test.go b/internal/aliases/confirm_test.go index 607bb0f..fbf29d4 100644 --- a/internal/aliases/confirm_test.go +++ b/internal/aliases/confirm_test.go @@ -8,18 +8,18 @@ import ( "bytes" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" "github.com/stretchr/testify/require" - refs "go.mindeco.de/ssb-refs" ) func TestConfirmation(t *testing.T) { r := require.New(t) // this is our room, it's not a valid feed but thats fine for this test - roomID := refs.FeedRef{ - ID: bytes.Repeat([]byte("test"), 8), - Algo: "test", + roomID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("test"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) } // to make the test deterministic, decided by fair dice roll. @@ -36,7 +36,7 @@ func TestConfirmation(t *testing.T) { // internal function to create the registration string msg := valid.createRegistrationMessage() - want := "=room-alias-registration:@dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3Q=.test:@Rt2aJrtOqWXhBZ5/vlfzeWQ9Bj/z6iT8CMhlr2WWlG4=.ed25519:TestConfirmation" + want := "=room-alias-registration:@dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3Q=.ed25519:@Rt2aJrtOqWXhBZ5/vlfzeWQ9Bj/z6iT8CMhlr2WWlG4=.ed25519:TestConfirmation" r.Equal(want, string(msg)) // create the signed confirmation @@ -46,9 +46,9 @@ func TestConfirmation(t *testing.T) { r.True(yes, "should be valid for this room and feed") // make up another id for the invalid test(s) - otherID := refs.FeedRef{ - ID: bytes.Repeat([]byte("nope"), 8), - Algo: "test", + otherID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("nope"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) } confirmation.RoomID = otherID diff --git a/internal/aliases/names.go b/internal/aliases/names.go index 56a064f..0764ec8 100644 --- a/internal/aliases/names.go +++ b/internal/aliases/names.go @@ -5,7 +5,7 @@ package aliases // IsValid decides whether an alias is okay for use or not. -// The room spec defines it as _labels valid under RFC 1035_ ( https://ssb-ngi-pointer.github.io/rooms2/#alias-string ) +// The room spec defines it as _labels valid under RFC 1035_ ( https://ssbc.github.io/rooms2/#alias-string ) // but that can be mostly any string since DNS is a 8bit binary protocol, // as long as it's shorter then 63 charachters. // diff --git a/internal/broadcasts/attendants.go b/internal/broadcasts/attendants.go index a4f2bda..cb05eee 100644 --- a/internal/broadcasts/attendants.go +++ b/internal/broadcasts/attendants.go @@ -8,8 +8,8 @@ import ( "io" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror" ) type AttendantsEmitter interface { diff --git a/internal/broadcasts/doc.go b/internal/broadcasts/doc.go index 601776d..92794b6 100644 --- a/internal/broadcasts/doc.go +++ b/internal/broadcasts/doc.go @@ -4,4 +4,4 @@ // Package broadcasts implements custom typed one-to-n facilities for broadcasting messages/calls to multiple subscribers. // They loosely follow from luigi.Broadcasts but using concrete types instead of empty interfaces. -package broadcasts \ No newline at end of file +package broadcasts diff --git a/internal/broadcasts/endpoints.go b/internal/broadcasts/endpoints.go index d50605a..1a04b2c 100644 --- a/internal/broadcasts/endpoints.go +++ b/internal/broadcasts/endpoints.go @@ -8,7 +8,7 @@ import ( "io" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror" ) type EndpointsEmitter interface { diff --git a/internal/devtools/counterfeiter.go b/internal/devtools/counterfeiter.go index 19a2d27..c0ba986 100644 --- a/internal/devtools/counterfeiter.go +++ b/internal/devtools/counterfeiter.go @@ -2,6 +2,7 @@ // // SPDX-License-Identifier: MIT +//go:build tools // +build tools package devtools diff --git a/internal/devtools/stringer.go b/internal/devtools/stringer.go index 265ca4a..0f2c704 100644 --- a/internal/devtools/stringer.go +++ b/internal/devtools/stringer.go @@ -2,6 +2,7 @@ // // SPDX-License-Identifier: MIT +//go:build tools // +build tools package devtools diff --git a/internal/maybemod/keys/keys.go b/internal/maybemod/keys/keys.go index 9f3857c..143f1ea 100644 --- a/internal/maybemod/keys/keys.go +++ b/internal/maybemod/keys/keys.go @@ -14,9 +14,9 @@ import ( "path/filepath" "strings" + "github.com/ssbc/go-secretstream/secrethandshake" + refs "github.com/ssbc/go-ssb-refs" "go.cryptoscope.co/nocomment" - "go.cryptoscope.co/secretstream/secrethandshake" - refs "go.mindeco.de/ssb-refs" ) var SecretPerms = os.FileMode(0600) @@ -38,8 +38,8 @@ type ssbSecret struct { // IsValidFeedFormat checks if the passed FeedRef is for one of the two supported formats, // legacy/crapp or GabbyGrove. func IsValidFeedFormat(r refs.FeedRef) error { - if r.Algo != refs.RefAlgoFeedSSB1 && r.Algo != refs.RefAlgoFeedGabby { - return fmt.Errorf("ssb: unsupported feed format:%s", r.Algo) + if r.Algo() != refs.RefAlgoFeedSSB1 && r.Algo() != refs.RefAlgoFeedGabby { + return fmt.Errorf("ssb: unsupported feed format:%s", r.Algo()) } return nil } @@ -53,11 +53,13 @@ func NewKeyPair(r io.Reader) (*KeyPair, error) { return nil, fmt.Errorf("ssb: error building key pair: %w", err) } + feed, err := refs.NewFeedRefFromBytes(kp.Public[:], refs.RefAlgoFeedSSB1) + if err != nil { + return nil, fmt.Errorf("ssb: error building key pair: %w", err) + } + keyPair := KeyPair{ - Feed: refs.FeedRef{ - ID: kp.Public[:], - Algo: refs.RefAlgoFeedSSB1, - }, + Feed: feed, Pair: *kp, } diff --git a/internal/maybemod/multicloser/multicloser.go b/internal/maybemod/multicloser/multicloser.go index 8dddfaa..56ea83e 100644 --- a/internal/maybemod/multicloser/multicloser.go +++ b/internal/maybemod/multicloser/multicloser.go @@ -9,7 +9,7 @@ import ( "io" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror" ) type Closer struct { diff --git a/internal/maybemuxrpc/plugin.go b/internal/maybemuxrpc/plugin.go index b34fbf0..63d3383 100644 --- a/internal/maybemuxrpc/plugin.go +++ b/internal/maybemuxrpc/plugin.go @@ -8,7 +8,7 @@ import ( "net" "sync" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" ) type Authorizer interface { diff --git a/internal/network/conntracker.go b/internal/network/conntracker.go index 5e6dd58..035415a 100644 --- a/internal/network/conntracker.go +++ b/internal/network/conntracker.go @@ -11,8 +11,8 @@ import ( "sync" "time" - "go.cryptoscope.co/netwrap" - "go.cryptoscope.co/secretstream" + "github.com/ssbc/go-netwrap" + "github.com/ssbc/go-secretstream" ) type connEntry struct { diff --git a/internal/network/interface.go b/internal/network/interface.go index f15f403..06236e4 100644 --- a/internal/network/interface.go +++ b/internal/network/interface.go @@ -15,10 +15,10 @@ import ( "net/url" "time" - "go.cryptoscope.co/muxrpc/v2" - "go.cryptoscope.co/netwrap" - "go.cryptoscope.co/secretstream" - refs "go.mindeco.de/ssb-refs" + "github.com/ssbc/go-muxrpc/v2" + "github.com/ssbc/go-netwrap" + "github.com/ssbc/go-secretstream" + refs "github.com/ssbc/go-ssb-refs" ) // ServerEndpointDetails encapsulates the endpoint information. @@ -131,10 +131,10 @@ type ConnTracker interface { } // GetFeedRefFromAddr uses netwrap to get the secretstream address and then uses ParseFeedRef -func GetFeedRefFromAddr(addr net.Addr) (*refs.FeedRef, error) { +func GetFeedRefFromAddr(addr net.Addr) (refs.FeedRef, error) { addr = netwrap.GetAddr(addr, secretstream.NetworkString) if addr == nil { - return nil, errors.New("no shs-bs address found") + return refs.FeedRef{}, errors.New("no shs-bs address found") } ssAddr := addr.(secretstream.Addr) return refs.ParseFeedRef(ssAddr.String()) diff --git a/internal/network/isserver_test.go b/internal/network/isserver_test.go index 721433a..56d6487 100644 --- a/internal/network/isserver_test.go +++ b/internal/network/isserver_test.go @@ -11,11 +11,11 @@ import ( "os" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/internal/network" "go.mindeco.de/log" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" "github.com/stretchr/testify/require" ) diff --git a/internal/network/mocked/endpoints.go b/internal/network/mocked/endpoints.go index a26dcf2..540bb77 100644 --- a/internal/network/mocked/endpoints.go +++ b/internal/network/mocked/endpoints.go @@ -8,9 +8,9 @@ package mocked import ( "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - muxrpc "go.cryptoscope.co/muxrpc/v2" - refs "go.mindeco.de/ssb-refs" + muxrpc "github.com/ssbc/go-muxrpc/v2" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" ) type FakeEndpoints struct { diff --git a/internal/network/msaddr_test.go b/internal/network/msaddr_test.go index f56c73f..09c4ca8 100644 --- a/internal/network/msaddr_test.go +++ b/internal/network/msaddr_test.go @@ -10,8 +10,8 @@ import ( "strings" "testing" + refs "github.com/ssbc/go-ssb-refs" "github.com/stretchr/testify/assert" - refs "go.mindeco.de/ssb-refs" ) func TestMultiserverAddress(t *testing.T) { @@ -21,10 +21,11 @@ func TestMultiserverAddress(t *testing.T) { sed.Domain = "the.ho.st" sed.ListenAddressMUXRPC = ":8008" - sed.RoomID = refs.FeedRef{ - ID: bytes.Repeat([]byte("ohai"), 8), - Algo: "doesnt-matter", // not part of msaddr v1 + roomID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("ohai"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) } + sed.RoomID = roomID gotMultiAddr := sed.MultiserverAddress() diff --git a/internal/network/new.go b/internal/network/new.go index 9d6b3cb..13e0d22 100644 --- a/internal/network/new.go +++ b/internal/network/new.go @@ -14,14 +14,14 @@ import ( "strings" "sync" - "go.cryptoscope.co/muxrpc/v2" - "go.cryptoscope.co/netwrap" - "go.cryptoscope.co/secretstream" + "github.com/ssbc/go-muxrpc/v2" + "github.com/ssbc/go-netwrap" + "github.com/ssbc/go-secretstream" "go.mindeco.de/log" "go.mindeco.de/log/level" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" ) // DefaultPort is the default listening port for ScuttleButt. @@ -128,7 +128,7 @@ func (n *node) GetEndpointFor(ref refs.FeedRef) (muxrpc.Endpoint, bool) { n.remotesLock.Lock() defer n.remotesLock.Unlock() - edp, has := n.remotes[ref.Ref()] + edp, has := n.remotes[ref.String()] return edp, has } @@ -147,7 +147,7 @@ func (n *node) GetAllEndpoints() []EndpointStat { continue } stats = append(stats, EndpointStat{ - ID: id, + ID: &id, Addr: remote, Since: durr, Endpoint: edp, @@ -164,7 +164,7 @@ func (n *node) addRemote(edp muxrpc.Endpoint) { if err != nil { panic(err) } - // ref := r.Ref() + // ref := r.String() // if oldEdp, has := n.remotes[ref]; has { // n.log.Log("remotes", "previous active", "ref", ref) // c := client.FromEndpoint(oldEdp) @@ -175,7 +175,7 @@ func (n *node) addRemote(edp muxrpc.Endpoint) { // } // } // replace with new - n.remotes[r.Ref()] = edp + n.remotes[r.String()] = edp } // TODO: merge with conntracker @@ -186,7 +186,7 @@ func (n *node) removeRemote(edp muxrpc.Endpoint) { if err != nil { panic(err) } - delete(n.remotes, r.Ref()) + delete(n.remotes, r.String()) } func (n *node) handleConnection(ctx context.Context, origConn net.Conn, isServer bool, hws ...muxrpc.HandlerWrapper) { @@ -205,7 +205,7 @@ func (n *node) handleConnection(ctx context.Context, origConn net.Conn, isServer level.Error(n.log).Log("conn", "not shs authorized", "err", err) return } - rLogger := log.With(n.log, "peer", remoteRef.ShortRef()) + rLogger := log.With(n.log, "peer", remoteRef.ShortSigil()) ok, ctx := n.connTracker.OnAccept(ctx, conn) if !ok { diff --git a/internal/network/websocket.go b/internal/network/websocket.go index 5f6f0e8..9bedcee 100644 --- a/internal/network/websocket.go +++ b/internal/network/websocket.go @@ -13,7 +13,7 @@ import ( "time" "github.com/gorilla/websocket" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" kitlog "go.mindeco.de/log" "go.mindeco.de/log/level" ) diff --git a/internal/netwraputil/spoof.go b/internal/netwraputil/spoof.go index b8b77a6..b5c102a 100644 --- a/internal/netwraputil/spoof.go +++ b/internal/netwraputil/spoof.go @@ -8,8 +8,8 @@ import ( "errors" "net" - "go.cryptoscope.co/netwrap" - "go.cryptoscope.co/secretstream" + "github.com/ssbc/go-netwrap" + "github.com/ssbc/go-secretstream" ) // SpoofRemoteAddress wraps the connection with the passed reference diff --git a/internal/netwraputil/spoof_test.go b/internal/netwraputil/spoof_test.go index 90549c2..97ab47c 100644 --- a/internal/netwraputil/spoof_test.go +++ b/internal/netwraputil/spoof_test.go @@ -8,8 +8,8 @@ import ( "net" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/internal/network" "github.com/stretchr/testify/require" ) @@ -28,7 +28,7 @@ func TestSpoof(t *testing.T) { ref, err := network.GetFeedRefFromAddr(wrapped.RemoteAddr()) r.NoError(err) - r.True(ref.Equal(&kp.Feed)) + r.True(ref.Equal(kp.Feed)) wc.Close() rc.Close() diff --git a/internal/repo/secret.go b/internal/repo/secret.go index aca4bb7..03679e2 100644 --- a/internal/repo/secret.go +++ b/internal/repo/secret.go @@ -11,8 +11,8 @@ import ( "os" "path/filepath" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" ) func DefaultKeyPair(r Interface) (*keys.KeyPair, error) { @@ -29,7 +29,7 @@ func DefaultKeyPair(r Interface) (*keys.KeyPair, error) { if err := keys.SaveKeyPair(*keyPair, secPath); err != nil { return nil, fmt.Errorf("repo: error saving new identity file: %w", err) } - log.Printf("saved identity %s to %s", keyPair.Feed.Ref(), secPath) + log.Printf("saved identity %s to %s", keyPair.Feed.String(), secPath) } return keyPair, nil } @@ -53,7 +53,7 @@ func newKeyPair(r Interface, name, algo string, seed io.Reader) (*keys.KeyPair, return nil, err } } - if algo != refs.RefAlgoFeedSSB1 && algo != refs.RefAlgoFeedGabby { // enums would be nice + if algo != string(refs.RefAlgoFeedSSB1) && algo != string(refs.RefAlgoFeedGabby) { // enums would be nice return nil, fmt.Errorf("invalid feed refrence algo") } if _, err := keys.LoadKeyPair(secPath); err == nil { @@ -63,11 +63,10 @@ func newKeyPair(r Interface, name, algo string, seed io.Reader) (*keys.KeyPair, if err != nil { return nil, fmt.Errorf("repo: no keypair but couldn't create one either: %w", err) } - keyPair.Feed.Algo = algo if err := keys.SaveKeyPair(*keyPair, secPath); err != nil { return nil, fmt.Errorf("repo: error saving new identity file: %w", err) } - log.Printf("saved identity %s to %s", keyPair.Feed.Ref(), secPath) + log.Printf("saved identity %s to %s", keyPair.Feed.String(), secPath) return keyPair, nil } diff --git a/internal/signinwithssb/challenges.go b/internal/signinwithssb/challenges.go index 642ad57..4019d42 100644 --- a/internal/signinwithssb/challenges.go +++ b/internal/signinwithssb/challenges.go @@ -12,7 +12,7 @@ import ( "golang.org/x/crypto/ed25519" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" ) // sign-in with ssb uses 256-bit nonces @@ -54,9 +54,9 @@ type ClientPayload struct { func (cr ClientPayload) createMessage() []byte { var msg bytes.Buffer msg.WriteString("=http-auth-sign-in:") - msg.WriteString(cr.ServerID.Ref()) + msg.WriteString(cr.ServerID.String()) msg.WriteString(":") - msg.WriteString(cr.ClientID.Ref()) + msg.WriteString(cr.ClientID.String()) msg.WriteString(":") msg.WriteString(cr.ServerChallenge) msg.WriteString(":") diff --git a/internal/signinwithssb/simple_test.go b/internal/signinwithssb/simple_test.go index 7407210..e124943 100644 --- a/internal/signinwithssb/simple_test.go +++ b/internal/signinwithssb/simple_test.go @@ -11,13 +11,20 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" ) func TestPayloadString(t *testing.T) { - server := refs.FeedRef{ID: bytes.Repeat([]byte{1}, 32), Algo: "test"} - client := refs.FeedRef{ID: bytes.Repeat([]byte{2}, 32), Algo: "test"} + server, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + + client, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{2}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } var req ClientPayload @@ -27,7 +34,7 @@ func TestPayloadString(t *testing.T) { req.ServerChallenge = "fooo" req.ClientChallenge = "barr" - want := "=http-auth-sign-in:@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.test:@AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=.test:fooo:barr" + want := "=http-auth-sign-in:@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.ed25519:@AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=.ed25519:fooo:barr" got := req.createMessage() assert.Equal(t, want, string(got)) diff --git a/muxrpc/handlers/alias/handler.go b/muxrpc/handlers/alias/handler.go index 11901c0..337f009 100644 --- a/muxrpc/handlers/alias/handler.go +++ b/muxrpc/handlers/alias/handler.go @@ -13,14 +13,14 @@ import ( "fmt" "strings" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" kitlog "go.mindeco.de/log" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/aliases" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" ) // Handler implements the muxrpc methods for alias registration and recvocation @@ -93,7 +93,7 @@ func (h Handler) Register(ctx context.Context, req *muxrpc.Request) (interface{} return nil, err } - confirmation.UserID = *userID + confirmation.UserID = userID // check the signature if !confirmation.Verify() { diff --git a/muxrpc/handlers/doc.go b/muxrpc/handlers/doc.go index 0e08191..8f0af1e 100644 --- a/muxrpc/handlers/doc.go +++ b/muxrpc/handlers/doc.go @@ -4,5 +4,5 @@ // Package handlers contains the muxrpc handler packages for the room server. // -// The implementation the actual multiplexing implementation is go.cryptoscope.co/muxrpc. +// The implementation the actual multiplexing implementation is github.com/ssbc/go-muxrpc. package handlers diff --git a/muxrpc/handlers/gossip/ping.go b/muxrpc/handlers/gossip/ping.go index 4b0fbfc..48e56c4 100644 --- a/muxrpc/handlers/gossip/ping.go +++ b/muxrpc/handlers/gossip/ping.go @@ -10,7 +10,7 @@ import ( "io" "time" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" "go.mindeco.de/encodedTime" ) diff --git a/muxrpc/handlers/signinwithssb/withssb.go b/muxrpc/handlers/signinwithssb/withssb.go index 6d12427..15fc99e 100644 --- a/muxrpc/handlers/signinwithssb/withssb.go +++ b/muxrpc/handlers/signinwithssb/withssb.go @@ -11,14 +11,14 @@ import ( "fmt" "strings" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" kitlog "go.mindeco.de/log" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - validate "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + validate "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) // Handler implements the muxrpc methods for the "Sign-in with SSB" calls. SendSolution and InvalidateAllSolutions. @@ -64,7 +64,7 @@ func (h Handler) SendSolution(ctx context.Context, req *muxrpc.Request) (interfa return nil, err } - member, err := h.members.GetByFeed(ctx, *clientID) + member, err := h.members.GetByFeed(ctx, clientID) if err != nil { return nil, fmt.Errorf("client is not a room member") } @@ -81,7 +81,7 @@ func (h Handler) SendSolution(ctx context.Context, req *muxrpc.Request) (interfa var payload validate.ClientPayload payload.ServerID = h.self payload.ServerChallenge = params[0] - payload.ClientID = *clientID + payload.ClientID = clientID payload.ClientChallenge = params[1] sig, err := base64.StdEncoding.DecodeString(strings.TrimSuffix(params[2], ".sig.ed25519")) @@ -120,7 +120,7 @@ func (h Handler) InvalidateAllSolutions(ctx context.Context, req *muxrpc.Request } // lookup the member - member, err := h.members.GetByFeed(ctx, *clientID) + member, err := h.members.GetByFeed(ctx, clientID) if err != nil { return nil, err } diff --git a/muxrpc/handlers/tunnel/server/attendants.go b/muxrpc/handlers/tunnel/server/attendants.go index cd5026b..bc8af8b 100644 --- a/muxrpc/handlers/tunnel/server/attendants.go +++ b/muxrpc/handlers/tunnel/server/attendants.go @@ -10,10 +10,10 @@ import ( "fmt" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "go.cryptoscope.co/muxrpc/v2" - refs "go.mindeco.de/ssb-refs" + "github.com/ssbc/go-muxrpc/v2" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) // AttendantsUpdate is emitted if a single member joins or leaves. @@ -43,14 +43,14 @@ func (h *Handler) attendants(ctx context.Context, req *muxrpc.Request, snk *muxr } if pm == roomdb.ModeCommunity || pm == roomdb.ModeRestricted { - _, err := h.membersdb.GetByFeed(ctx, *peer) + _, err := h.membersdb.GetByFeed(ctx, peer) if err != nil { return fmt.Errorf("external user are not allowed to enumerate members") } } // add peer to the state - h.state.AddEndpoint(*peer, req.Endpoint()) + h.state.AddEndpoint(peer, req.Endpoint()) // send the current state snk.SetEncoding(muxrpc.TypeJSON) diff --git a/muxrpc/handlers/tunnel/server/connect.go b/muxrpc/handlers/tunnel/server/connect.go index da0993d..1f42edd 100644 --- a/muxrpc/handlers/tunnel/server/connect.go +++ b/muxrpc/handlers/tunnel/server/connect.go @@ -10,13 +10,13 @@ import ( "fmt" "io" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" kitlog "go.mindeco.de/log" "go.mindeco.de/log/level" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomstate" ) type ConnectArg struct { @@ -46,7 +46,7 @@ func (h connectHandler) HandleConnect(ctx context.Context, edp muxrpc.Endpoint) return } - h.state.Remove(*peer) + h.state.Remove(peer) } // HandleDuplex here implements the tunnel.connect behavior of the server-side. It receives incoming events @@ -63,7 +63,7 @@ func (h connectHandler) HandleDuplex(ctx context.Context, req *muxrpc.Request, p } arg := args[0] - if !arg.Portal.Equal(&h.self) { + if !arg.Portal.Equal(h.self) { return fmt.Errorf("talking to the wrong room") } @@ -74,29 +74,29 @@ func (h connectHandler) HandleDuplex(ctx context.Context, req *muxrpc.Request, p } // make sure they dont want to connect to themselves - if caller.Equal(&arg.Target) { + if caller.Equal(arg.Target) { return fmt.Errorf("can't connect to self") } // see if we have and endpoint for the target edp, has := h.state.Has(arg.Target) if !has { - return fmt.Errorf("could not connect to:%s", arg.Target.Ref()) + return fmt.Errorf("could not connect to:%s", arg.Target.String()) } // call connect on them var argWorigin connectWithOriginArg argWorigin.ConnectArg = arg - argWorigin.Origin = *caller + argWorigin.Origin = caller targetSrc, targetSnk, err := edp.Duplex(ctx, muxrpc.TypeBinary, muxrpc.Method{"tunnel", "connect"}, argWorigin) if err != nil { - return fmt.Errorf("could not connect to:%s", arg.Target.Ref()) + return fmt.Errorf("could not connect to:%s", arg.Target.String()) } // pipe data between caller and target var cpy muxrpcDuplexCopy - cpy.logger = kitlog.With(h.logger, "caller", caller.ShortRef(), "target", arg.Target.ShortRef()) + cpy.logger = kitlog.With(h.logger, "caller", caller.ShortSigil(), "target", arg.Target.ShortSigil()) cpy.ctx, cpy.cancel = context.WithCancel(ctx) go cpy.do(targetSnk, peerSrc) diff --git a/muxrpc/handlers/tunnel/server/members.go b/muxrpc/handlers/tunnel/server/members.go index e32a378..d4f12a9 100644 --- a/muxrpc/handlers/tunnel/server/members.go +++ b/muxrpc/handlers/tunnel/server/members.go @@ -8,10 +8,11 @@ import ( "context" "encoding/json" "fmt" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "go.cryptoscope.co/muxrpc/v2" - refs "go.mindeco.de/ssb-refs" + + "github.com/ssbc/go-muxrpc/v2" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type Member struct { @@ -30,7 +31,7 @@ func (h *Handler) members(ctx context.Context, req *muxrpc.Request, snk *muxrpc. } if pm == roomdb.ModeCommunity || pm == roomdb.ModeRestricted { - _, err := h.membersdb.GetByFeed(ctx, *peer) + _, err := h.membersdb.GetByFeed(ctx, peer) if err != nil { return fmt.Errorf("external users are not allowed to list members: %w", err) } diff --git a/muxrpc/handlers/tunnel/server/plugin.go b/muxrpc/handlers/tunnel/server/plugin.go index 6144b5d..289bb44 100644 --- a/muxrpc/handlers/tunnel/server/plugin.go +++ b/muxrpc/handlers/tunnel/server/plugin.go @@ -5,13 +5,13 @@ package server import ( - "go.cryptoscope.co/muxrpc/v2" - "go.cryptoscope.co/muxrpc/v2/typemux" + "github.com/ssbc/go-muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2/typemux" kitlog "go.mindeco.de/log" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomstate" ) /* manifest: diff --git a/muxrpc/handlers/tunnel/server/state.go b/muxrpc/handlers/tunnel/server/state.go index 59a01f5..dfde7e8 100644 --- a/muxrpc/handlers/tunnel/server/state.go +++ b/muxrpc/handlers/tunnel/server/state.go @@ -12,11 +12,11 @@ import ( "sync" "time" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomstate" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" kitlog "go.mindeco.de/log" ) @@ -50,7 +50,7 @@ func (h *Handler) metadata(ctx context.Context, req *muxrpc.Request) (interface{ reply.Name = h.netInfo.Domain // check if caller is a member - if _, err := h.membersdb.GetByFeed(ctx, *ref); err != nil { + if _, err := h.membersdb.GetByFeed(ctx, ref); err != nil { if !errors.Is(err, roomdb.ErrNotFound) { return nil, err } @@ -90,7 +90,7 @@ func (h *Handler) announce(_ context.Context, req *muxrpc.Request) (interface{}, return nil, err } - h.state.AddEndpoint(*ref, req.Endpoint()) + h.state.AddEndpoint(ref, req.Endpoint()) return true, nil } @@ -101,7 +101,7 @@ func (h *Handler) leave(_ context.Context, req *muxrpc.Request) (interface{}, er return nil, err } - h.state.Remove(*ref) + h.state.Remove(ref) return true, nil } @@ -123,7 +123,7 @@ func (h *Handler) endpoints(ctx context.Context, req *muxrpc.Request, snk *muxrp case roomdb.ModeCommunity: fallthrough case roomdb.ModeRestricted: - _, err := h.membersdb.GetByFeed(ctx, *peer) + _, err := h.membersdb.GetByFeed(ctx, peer) if err != nil { return fmt.Errorf("external user are not allowed to enumerate members") } @@ -134,7 +134,7 @@ func (h *Handler) endpoints(ctx context.Context, req *muxrpc.Request, snk *muxrp h.state.RegisterLegacyEndpoints(toPeer) // add the peer to the room state if they arent already - h.state.AlreadyAdded(*peer, req.Endpoint()) + h.state.AlreadyAdded(peer, req.Endpoint()) // update the peer with toPeer.Update(h.state.List()) diff --git a/muxrpc/handlers/whoami/whoami.go b/muxrpc/handlers/whoami/whoami.go index eeeb1a7..a367233 100644 --- a/muxrpc/handlers/whoami/whoami.go +++ b/muxrpc/handlers/whoami/whoami.go @@ -7,13 +7,13 @@ package whoami import ( "context" - "go.cryptoscope.co/muxrpc/v2/typemux" + "github.com/ssbc/go-muxrpc/v2/typemux" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" kitlog "go.mindeco.de/log" "go.mindeco.de/log/level" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" ) var ( @@ -39,5 +39,5 @@ func (h handler) HandleAsync(ctx context.Context, req *muxrpc.Request) (interfac ID string `json:"id"` } - return ret{h.id.Ref()}, nil + return ret{h.id.String()}, nil } diff --git a/muxrpc/test/go/alias_test.go b/muxrpc/test/go/alias_test.go index b088b40..d9aa915 100644 --- a/muxrpc/test/go/alias_test.go +++ b/muxrpc/test/go/alias_test.go @@ -13,14 +13,14 @@ import ( "testing" "time" + "github.com/ssbc/go-muxrpc/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" + "github.com/ssbc/go-ssb-room/v2/internal/aliases" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomsrv" ) // technically we are usign two servers here @@ -104,7 +104,7 @@ func TestAliasRegister(t *testing.T) { a.Equal(confirmation.Alias, alias.Name) a.Equal(confirmation.Signature, alias.Signature) - a.True(confirmation.UserID.Equal(&bobsKey.Feed)) + a.True(confirmation.UserID.Equal(bobsKey.Feed)) t.Log("alias stored") @@ -183,7 +183,7 @@ func TestListAliases(t *testing.T) { var response string - err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.Ref()) + err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.String()) r.NoError(err) a.Equal("[]", response, "initially the list of aliases should be empty") @@ -191,7 +191,7 @@ func TestListAliases(t *testing.T) { r.NoError(err) a.NotEqual("", response, "response isn't empty") - err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.Ref()) + err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.String()) r.NoError(err) a.Equal("[\"bob\"]", response, "new alias should be in the list") } diff --git a/muxrpc/test/go/attendants_test.go b/muxrpc/test/go/attendants_test.go index 78615ec..9427db1 100644 --- a/muxrpc/test/go/attendants_test.go +++ b/muxrpc/test/go/attendants_test.go @@ -13,11 +13,11 @@ import ( "testing" "time" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" + "github.com/ssbc/go-muxrpc/v2" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" - refs "go.mindeco.de/ssb-refs" ) // this tests the new room.attendants call @@ -55,7 +55,7 @@ func TestRoomAttendants(t *testing.T) { decodeJSONsrc(t, carlsSource, &initState) a.Equal("state", initState.Type) a.Len(initState.IDs, 1) - a.True(initState.IDs[0].Equal(&carl.feed)) + a.True(initState.IDs[0].Equal(carl.feed)) announcementsForCarl := make(announcements) go logAttendantsStream(ts, carlsSource, "carl", announcementsForCarl) @@ -85,7 +85,7 @@ func TestRoomAttendants(t *testing.T) { a.Len(announcementsForAlf, 0, "none yet") // assert what carl saw - _, seen = announcementsForCarl[alf.feed.Ref()] + _, seen = announcementsForCarl[alf.feed.String()] a.True(seen, "carl saw alf") // let bre join the room @@ -109,10 +109,10 @@ func TestRoomAttendants(t *testing.T) { a.Len(announcementsForBre, 0, "none yet") // the two present people saw her - _, seen = announcementsForAlf[bre.feed.Ref()] + _, seen = announcementsForAlf[bre.feed.String()] a.True(seen, "alf saw bre") - _, seen = announcementsForCarl[bre.feed.Ref()] + _, seen = announcementsForCarl[bre.feed.String()] a.True(seen, "carl saw alf") // shutdown alf first @@ -122,10 +122,10 @@ func TestRoomAttendants(t *testing.T) { // bre and arl should have removed him - _, seen = announcementsForBre[alf.feed.Ref()] + _, seen = announcementsForBre[alf.feed.String()] a.False(seen, "alf should be gone for bre") - _, seen = announcementsForCarl[alf.feed.Ref()] + _, seen = announcementsForCarl[alf.feed.String()] a.False(seen, "alf should be gone for carl") // terminate server and the clients @@ -143,12 +143,12 @@ func TestRoomAttendants(t *testing.T) { func assertListContains(t *testing.T, lst []refs.FeedRef, who refs.FeedRef) { var found = false for _, feed := range lst { - if feed.Equal(&who) { + if feed.Equal(who) { found = true } } if !found { - t.Errorf("did not find %s in list of %d", who.ShortRef(), len(lst)) + t.Errorf("did not find %s in list of %d", who.ShortSigil(), len(lst)) } } @@ -176,13 +176,13 @@ func logAttendantsStream(ts *testSession, src *muxrpc.ByteSource, who string, a if err != nil { panic(err) } - ts.t.Log(who, "got an update:", update.Type, update.ID.ShortRef()) + ts.t.Log(who, "got an update:", update.Type, update.ID.ShortSigil()) switch update.Type { case "joined": - a[update.ID.Ref()] = struct{}{} + a[update.ID.String()] = struct{}{} case "left": - delete(a, update.ID.Ref()) + delete(a, update.ID.String()) default: ts.t.Fatalf("%s: unexpected update type: %v", who, update.Type) } diff --git a/muxrpc/test/go/deny_test.go b/muxrpc/test/go/deny_test.go index 16a6c60..f829830 100644 --- a/muxrpc/test/go/deny_test.go +++ b/muxrpc/test/go/deny_test.go @@ -9,12 +9,12 @@ import ( "testing" "time" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-muxrpc/v2" + refs "github.com/ssbc/go-ssb-refs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" - refs "go.mindeco.de/ssb-refs" ) // This test denies connections for keys that have been added to the deny list database, DeniedKeys. @@ -72,7 +72,7 @@ func TestConnEstablishmentDeniedKey(t *testing.T) { a.Nil(endpointB, "should not have an endpoint on B") err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.Error(err) - t.Log(srvWho.ID.Ref()) + t.Log(srvWho.ID.String()) } endpointA, has := botA.Network.GetEndpointFor(serv.Whoami()) @@ -81,8 +81,8 @@ func TestConnEstablishmentDeniedKey(t *testing.T) { err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.NoError(err) - t.Log("server whoami:", srvWho.ID.Ref()) - a.True(serv.Whoami().Equal(&srvWho.ID)) + t.Log("server whoami:", srvWho.ID.String()) + a.True(serv.Whoami().Equal(srvWho.ID)) cancel() } @@ -141,7 +141,7 @@ func TestConnEstablishmentDenyNonMembersRestrictedRoom(t *testing.T) { a.Nil(endpointB, "should not have an endpoint on B (B is not a member, and the server is restricted)") err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.Error(err) - t.Log(srvWho.ID.Ref()) + t.Log(srvWho.ID.String()) } endpointA, has := botA.Network.GetEndpointFor(serv.Whoami()) @@ -150,8 +150,8 @@ func TestConnEstablishmentDenyNonMembersRestrictedRoom(t *testing.T) { err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.NoError(err) - t.Log("server whoami:", srvWho.ID.Ref()) - a.True(serv.Whoami().Equal(&srvWho.ID)) + t.Log("server whoami:", srvWho.ID.String()) + a.True(serv.Whoami().Equal(srvWho.ID)) cancel() } @@ -211,7 +211,7 @@ func TestConnEstablishmentAllowNonMembersCommunityRoom(t *testing.T) { r.True(has, "botB has no endpoint for the server") err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.NoError(err) - t.Log(srvWho.ID.Ref()) + t.Log(srvWho.ID.String()) endpointA, has := botA.Network.GetEndpointFor(serv.Whoami()) r.True(has, "botA has no endpoint for the server") @@ -219,8 +219,8 @@ func TestConnEstablishmentAllowNonMembersCommunityRoom(t *testing.T) { err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.NoError(err) - t.Log("server whoami:", srvWho.ID.Ref()) - a.True(serv.Whoami().Equal(&srvWho.ID)) + t.Log("server whoami:", srvWho.ID.String()) + a.True(serv.Whoami().Equal(srvWho.ID)) cancel() } diff --git a/muxrpc/test/go/endpoints_test.go b/muxrpc/test/go/endpoints_test.go index 9acc316..6da2990 100644 --- a/muxrpc/test/go/endpoints_test.go +++ b/muxrpc/test/go/endpoints_test.go @@ -12,11 +12,11 @@ import ( "testing" "time" + "github.com/ssbc/go-muxrpc/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" ) type announcements map[string]struct{} @@ -54,7 +54,7 @@ func TestEndpointClients(t *testing.T) { go logEndpointsStream(ts, carlEndpointsSrc, "carl", announcementsForCarl) time.Sleep(1 * time.Second) // give some time to process new events - _, seen := announcementsForCarl[carl.feed.Ref()] + _, seen := announcementsForCarl[carl.feed.String()] a.True(seen, "carl saw himself") // let alf join the room @@ -66,13 +66,13 @@ func TestEndpointClients(t *testing.T) { time.Sleep(1 * time.Second) // give some time to process new events // assert what alf saw - _, seen = announcementsForAlf[carl.feed.Ref()] + _, seen = announcementsForAlf[carl.feed.String()] a.True(seen, "alf saw carl") - _, seen = announcementsForAlf[alf.feed.Ref()] + _, seen = announcementsForAlf[alf.feed.String()] a.True(seen, "alf saw himself") // assert what carl saw - _, seen = announcementsForCarl[alf.feed.Ref()] + _, seen = announcementsForCarl[alf.feed.String()] a.True(seen, "carl saw alf") // let bre join the room @@ -85,17 +85,17 @@ func TestEndpointClients(t *testing.T) { time.Sleep(1 * time.Second) // give some time to process new events // assert bre saw the other two and herself - _, seen = announcementsForBre[carl.feed.Ref()] + _, seen = announcementsForBre[carl.feed.String()] a.True(seen, "bre saw carl") - _, seen = announcementsForBre[alf.feed.Ref()] + _, seen = announcementsForBre[alf.feed.String()] a.True(seen, "bre saw alf") - _, seen = announcementsForBre[bre.feed.Ref()] + _, seen = announcementsForBre[bre.feed.String()] a.True(seen, "bre saw herself") // assert the others saw bre - _, seen = announcementsForAlf[bre.feed.Ref()] + _, seen = announcementsForAlf[bre.feed.String()] a.True(seen, "alf saw bre") - _, seen = announcementsForCarl[bre.feed.Ref()] + _, seen = announcementsForCarl[bre.feed.String()] a.True(seen, "carl saw bre") // terminate server and the clients @@ -127,10 +127,10 @@ func logEndpointsStream(ts *testSession, src *muxrpc.ByteSource, who string, a a } ts.t.Log(who, "got endpoints:", len(edps)) for i, f := range edps { - ts.t.Log(who, ":", i, f.ShortRef()) + ts.t.Log(who, ":", i, f.ShortSigil()) // mark as f is present - a[f.Ref()] = struct{}{} + a[f.String()] = struct{}{} } } diff --git a/muxrpc/test/go/members_test.go b/muxrpc/test/go/members_test.go index 5b79abd..2af429c 100644 --- a/muxrpc/test/go/members_test.go +++ b/muxrpc/test/go/members_test.go @@ -7,16 +7,16 @@ package go_test import ( "context" "encoding/json" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomsrv" "math/rand" "testing" "time" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" ) // this tests the new room.members call diff --git a/muxrpc/test/go/roomstate_test.go b/muxrpc/test/go/roomstate_test.go index c9548ca..9381206 100644 --- a/muxrpc/test/go/roomstate_test.go +++ b/muxrpc/test/go/roomstate_test.go @@ -13,10 +13,10 @@ import ( "testing" "time" + "github.com/ssbc/go-muxrpc/v2" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server" ) // peers not on the members list can't connect @@ -73,7 +73,7 @@ func TestStaleMembers(t *testing.T) { // restart srh oldSrh := srh.feed srh = ts.makeTestClient("srh") - r.True(oldSrh.Equal(&srh.feed)) + r.True(oldSrh.Equal(srh.feed)) t.Log("restarted srh") time.Sleep(1 * time.Second) // let server respond diff --git a/muxrpc/test/go/simple_test.go b/muxrpc/test/go/simple_test.go index c20db37..b96720b 100644 --- a/muxrpc/test/go/simple_test.go +++ b/muxrpc/test/go/simple_test.go @@ -9,13 +9,13 @@ import ( "testing" "time" + "github.com/ssbc/go-muxrpc/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" - tunserv "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + tunserv "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) func TestTunnelServerSimple(t *testing.T) { @@ -68,7 +68,7 @@ func TestTunnelServerSimple(t *testing.T) { a.Nil(endpointB, "should not have an endpoint on B") err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.Error(err) - t.Log(srvWho.ID.Ref()) + t.Log(srvWho.ID.String()) } endpointA, has := botA.Network.GetEndpointFor(serv.Whoami()) @@ -77,8 +77,8 @@ func TestTunnelServerSimple(t *testing.T) { err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.NoError(err) - t.Log("server whoami:", srvWho.ID.Ref()) - a.True(serv.Whoami().Equal(&srvWho.ID)) + t.Log("server whoami:", srvWho.ID.String()) + a.True(serv.Whoami().Equal(srvWho.ID)) // start testing basic room stuff var meta tunserv.MetadataReply @@ -145,11 +145,11 @@ func TestRoomAnnounce(t *testing.T) { err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.NoError(err) - a.True(serv.Whoami().Equal(&srvWho.ID)) + a.True(serv.Whoami().Equal(srvWho.ID)) err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) r.NoError(err) - a.True(serv.Whoami().Equal(&srvWho.ID)) + a.True(serv.Whoami().Equal(srvWho.ID)) // let B listen for changes newRoomMember, err := endpointB.Source(ctx, muxrpc.TypeJSON, muxrpc.Method{"tunnel", "endpoints"}) diff --git a/muxrpc/test/go/utils_test.go b/muxrpc/test/go/utils_test.go index 116ede0..5c412d4 100644 --- a/muxrpc/test/go/utils_test.go +++ b/muxrpc/test/go/utils_test.go @@ -19,25 +19,25 @@ import ( "time" _ "github.com/mattn/go-sqlite3" + "github.com/ssbc/go-muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2/debug" + "github.com/ssbc/go-netwrap" + "github.com/ssbc/go-secretstream" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" - "go.cryptoscope.co/muxrpc/v2/debug" - "go.cryptoscope.co/netwrap" - "go.cryptoscope.co/secretstream" "go.mindeco.de/log" "go.mindeco.de/log/level" "golang.org/x/sync/errgroup" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/testutils" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/testutils" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite" + "github.com/ssbc/go-ssb-room/v2/roomsrv" ) var ( @@ -167,7 +167,7 @@ func (ts *testSession) makeTestClient(name string) testClient { ts.clientKeys[name] = client } - ts.t.Log(name, "is", client.Feed.ShortRef()) + ts.t.Log(name, "is", client.Feed.ShortSigil()) // add it as a memeber, if it isnt already _, err := ts.srv.Members.GetByFeed(ts.ctx, client.Feed) diff --git a/muxrpc/test/go/websocket_test.go b/muxrpc/test/go/websocket_test.go index 48a3b61..a13f8f2 100644 --- a/muxrpc/test/go/websocket_test.go +++ b/muxrpc/test/go/websocket_test.go @@ -17,16 +17,16 @@ import ( "time" "github.com/gorilla/websocket" + "github.com/ssbc/go-muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2/debug" + "github.com/ssbc/go-secretstream" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" - "go.cryptoscope.co/muxrpc/v2/debug" - "go.cryptoscope.co/secretstream" "go.mindeco.de/encodedTime" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - tunserv "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/internal/network" + tunserv "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) func TestWebsocketDialing(t *testing.T) { diff --git a/muxrpc/test/nodejs/aliases_test.go b/muxrpc/test/nodejs/aliases_test.go index 94d11b7..3ab6b72 100644 --- a/muxrpc/test/nodejs/aliases_test.go +++ b/muxrpc/test/nodejs/aliases_test.go @@ -11,9 +11,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" + "github.com/ssbc/go-ssb-room/v2/internal/aliases" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb" ) func TestGoServerJSClientAliases(t *testing.T) { @@ -51,7 +51,7 @@ func TestGoServerJSClientAliases(t *testing.T) { r.Equal(1, aliasesDB.RegisterCallCount(), "register call count") _, name, ref, signature := aliasesDB.RegisterArgsForCall(0) a.Equal("alice", name, "wrong alias registered") - a.Equal(alice.Ref(), ref.Ref()) + a.Equal(alice.String(), ref.String()) var aliasReq aliases.Confirmation aliasReq.Alias = name diff --git a/muxrpc/test/nodejs/setup_test.go b/muxrpc/test/nodejs/setup_test.go index bde0cc9..668d13a 100644 --- a/muxrpc/test/nodejs/setup_test.go +++ b/muxrpc/test/nodejs/setup_test.go @@ -21,20 +21,20 @@ import ( "testing" "time" + "github.com/ssbc/go-muxrpc/v2/debug" + "github.com/ssbc/go-netwrap" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2/debug" - "go.cryptoscope.co/netwrap" "go.mindeco.de/log" "golang.org/x/sync/errgroup" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/testutils" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/testutils" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb" + "github.com/ssbc/go-ssb-room/v2/roomsrv" ) func init() { @@ -121,7 +121,7 @@ func (ts *testSession) startGoServer( if err != nil { return nil, err } - fname := filepath.Join("testrun", ts.t.Name(), "muxdump", ref.ShortRef()) + fname := filepath.Join("testrun", ts.t.Name(), "muxdump", ref.ShortSigil()) return debug.WrapDump(fname, conn) }), ) @@ -135,7 +135,7 @@ func (ts *testSession) startGoServer( srv, err := roomsrv.New(membersDB, deniedKeysDB, aliasDB, authSessionsDB, sb, fakeConfig, netInfo, opts...) r.NoError(err, "failed to init tees a server") - ts.t.Logf("go server: %s", srv.Whoami().Ref()) + ts.t.Logf("go server: %s", srv.Whoami().String()) ts.t.Cleanup(func() { ts.t.Log("bot close:", srv.Close()) }) @@ -143,7 +143,7 @@ func (ts *testSession) startGoServer( ts.done.Go(func() error { err := srv.Network.Serve(ts.ctx) // if the muxrpc protocol fucks up by e.g. unpacking body data into a header, this type of error will be surfaced here and look scary in the test output - // example: https://github.com/ssb-ngi-pointer/go-ssb-room/pull/85#issuecomment-801106687 + // example: https://github.com/ssbc/go-ssb-room/pull/85#issuecomment-801106687 if err != nil && !errors.Is(err, context.Canceled) { err = fmt.Errorf("go server exited: %w", err) ts.t.Log(err) @@ -187,7 +187,7 @@ func (ts *testSession) startJSClient( "TEST_NAME=" + name, "TEST_REPO=" + cmd.Dir, "TEST_PEERADDR=" + netwrap.GetAddr(peerAddr, "tcp").String(), - "TEST_PEERREF=" + peerRef.Ref(), + "TEST_PEERREF=" + peerRef.String(), "TEST_SESSIONSCRIPT=" + testScript, // "DEBUG=ssb:room:tunnel:*", } @@ -221,8 +221,8 @@ func (ts *testSession) startJSClient( jsBotRef, err := refs.ParseFeedRef(pubScanner.Text()) r.NoError(err, "failed to get %s key from JS process") - ts.t.Logf("JS %s:%d %s", name, jsBotCnt, jsBotRef.Ref()) - return *jsBotRef + ts.t.Logf("JS %s:%d %s", name, jsBotCnt, jsBotRef.String()) + return jsBotRef } // startJSBotAsServer returns the servers public key and it's TCP port on localhost. @@ -277,8 +277,8 @@ func (ts *testSession) startJSBotAsServer(name, testScriptFileName string) (*ref srvRef, err := refs.ParseFeedRef(pubScanner.Text()) r.NoError(err, "failed to get srvRef key from JS process") - ts.t.Logf("JS %s: %s port: %d", name, srvRef.Ref(), port) - return srvRef, port + ts.t.Logf("JS %s: %s port: %d", name, srvRef.String(), port) + return &srvRef, port } func (ts *testSession) wait() { diff --git a/muxrpc/test/nodejs/tunnel_connect_test.go b/muxrpc/test/nodejs/tunnel_connect_test.go index eb9c463..50cf3d4 100644 --- a/muxrpc/test/nodejs/tunnel_connect_test.go +++ b/muxrpc/test/nodejs/tunnel_connect_test.go @@ -16,9 +16,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb" ) // legacy js end-to-end test as a sanity check @@ -136,7 +136,7 @@ func TestModernJSClient(t *testing.T) { } // found a nasty `throw err` in the JS stack around pull.drain. lets make sure it stays gone -// https://github.com/ssb-ngi-pointer/go-ssb-room/issues/190 +// https://github.com/ssbc/go-ssb-room/issues/190 func TestClientSurvivesShutdown(t *testing.T) { r := require.New(t) @@ -177,11 +177,11 @@ func TestClientSurvivesShutdown(t *testing.T) { func writeRoomHandleFile(srv, target refs.FeedRef, filePath string) error { var roomHandle bytes.Buffer roomHandle.WriteString("tunnel:") - roomHandle.WriteString(srv.Ref()) + roomHandle.WriteString(srv.String()) roomHandle.WriteString(":") - roomHandle.WriteString(target.Ref()) + roomHandle.WriteString(target.String()) roomHandle.WriteString("~shs:") - roomHandle.WriteString(base64.StdEncoding.EncodeToString(target.ID)) + roomHandle.WriteString(base64.StdEncoding.EncodeToString(target.PubKey())) os.MkdirAll(filepath.Dir(filePath), 0700) return ioutil.WriteFile(filePath, roomHandle.Bytes(), 0700) diff --git a/roomdb/interface.go b/roomdb/interface.go index b0409fc..6567077 100644 --- a/roomdb/interface.go +++ b/roomdb/interface.go @@ -15,8 +15,8 @@ package roomdb import ( "context" + refs "github.com/ssbc/go-ssb-refs" "go.mindeco.de/http/auth" - refs "go.mindeco.de/ssb-refs" ) type RoomConfig interface { @@ -143,7 +143,7 @@ type AliasesService interface { type InvitesService interface { // Create creates a new invite for a new member. It returns the token or an error. // createdBy is user ID of the admin or moderator who created it. MemberID -1 is allowed if Privacy Mode is set to Open. - // aliasSuggestion is optional (empty string is fine) but can be used to disambiguate open invites. (See https://github.com/ssb-ngi-pointer/rooms2/issues/21) + // aliasSuggestion is optional (empty string is fine) but can be used to disambiguate open invites. (See https://github.com/ssbc/rooms2/issues/21) Create(ctx context.Context, createdBy int64) (string, error) // Consume checks if the passed token is still valid. diff --git a/roomdb/mockdb/aliases.go b/roomdb/mockdb/aliases.go index ec60485..eb3e9ef 100644 --- a/roomdb/mockdb/aliases.go +++ b/roomdb/mockdb/aliases.go @@ -9,8 +9,8 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakeAliasesService struct { diff --git a/roomdb/mockdb/auth.go b/roomdb/mockdb/auth.go index 06631d1..4f7453c 100644 --- a/roomdb/mockdb/auth.go +++ b/roomdb/mockdb/auth.go @@ -9,7 +9,7 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakeAuthWithSSBService struct { diff --git a/roomdb/mockdb/auth_fallback.go b/roomdb/mockdb/auth_fallback.go index 1043323..919fca9 100644 --- a/roomdb/mockdb/auth_fallback.go +++ b/roomdb/mockdb/auth_fallback.go @@ -9,7 +9,7 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakeAuthFallbackService struct { diff --git a/roomdb/mockdb/denied.go b/roomdb/mockdb/denied.go index 010ddc2..14e2ec0 100644 --- a/roomdb/mockdb/denied.go +++ b/roomdb/mockdb/denied.go @@ -9,8 +9,8 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakeDeniedKeysService struct { diff --git a/roomdb/mockdb/fixed_pages.go b/roomdb/mockdb/fixed_pages.go index fde0eab..5c3bb08 100644 --- a/roomdb/mockdb/fixed_pages.go +++ b/roomdb/mockdb/fixed_pages.go @@ -9,7 +9,7 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakePinnedNoticesService struct { diff --git a/roomdb/mockdb/invites.go b/roomdb/mockdb/invites.go index 6dde2ba..17dd7e0 100644 --- a/roomdb/mockdb/invites.go +++ b/roomdb/mockdb/invites.go @@ -9,8 +9,8 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakeInvitesService struct { diff --git a/roomdb/mockdb/members.go b/roomdb/mockdb/members.go index 957c547..620ea7d 100644 --- a/roomdb/mockdb/members.go +++ b/roomdb/mockdb/members.go @@ -9,8 +9,8 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakeMembersService struct { diff --git a/roomdb/mockdb/pages.go b/roomdb/mockdb/pages.go index 73a753a..7a32cb9 100644 --- a/roomdb/mockdb/pages.go +++ b/roomdb/mockdb/pages.go @@ -9,7 +9,7 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakeNoticesService struct { diff --git a/roomdb/mockdb/roomconfig.go b/roomdb/mockdb/roomconfig.go index d2332e0..21dbf6e 100644 --- a/roomdb/mockdb/roomconfig.go +++ b/roomdb/mockdb/roomconfig.go @@ -9,7 +9,7 @@ import ( "context" "sync" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) type FakeRoomConfig struct { diff --git a/roomdb/sqlite/aliases.go b/roomdb/sqlite/aliases.go index 748bacf..a03d847 100644 --- a/roomdb/sqlite/aliases.go +++ b/roomdb/sqlite/aliases.go @@ -13,9 +13,9 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" ) // compiler assertion to ensure the struct fullfills the interface @@ -82,7 +82,7 @@ func (a Aliases) List(ctx context.Context) ([]roomdb.Alias, error) { func (a Aliases) Register(ctx context.Context, alias string, userFeed refs.FeedRef, signature []byte) error { return transact(a.db, func(tx *sql.Tx) error { // check we have a members entry for the feed and load it to get its ID - memberEntry, err := models.Members(qm.Where("pub_key = ?", userFeed.Ref())).One(ctx, tx) + memberEntry, err := models.Members(qm.Where("pub_key = ?", userFeed.String())).One(ctx, tx) if err != nil { if errors.Is(err, sql.ErrNoRows) { return roomdb.ErrNotFound diff --git a/roomdb/sqlite/aliases_test.go b/roomdb/sqlite/aliases_test.go index 5b65f84..2866ab5 100644 --- a/roomdb/sqlite/aliases_test.go +++ b/roomdb/sqlite/aliases_test.go @@ -15,9 +15,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) func TestAliases(t *testing.T) { @@ -28,7 +28,10 @@ func TestAliases(t *testing.T) { tr := repo.New(testRepo) // fake feed for testing, looks ok at least - newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} + newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } // 64 bytes of random for testing (validation is handled by the handlers) testSig := make([]byte, 64) @@ -112,7 +115,10 @@ func TestAliasesUniqueError(t *testing.T) { r.NoError(err) // fake feed for testing, looks ok at least - newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} + newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } // 64 bytes of random for testing (validation is handled by the handlers) testSig := make([]byte, 64) diff --git a/roomdb/sqlite/auth_fallback.go b/roomdb/sqlite/auth_fallback.go index f2bf85f..3760ce0 100644 --- a/roomdb/sqlite/auth_fallback.go +++ b/roomdb/sqlite/auth_fallback.go @@ -19,9 +19,9 @@ import ( "go.mindeco.de/http/auth" "golang.org/x/crypto/bcrypt" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" ) // compiler assertion to ensure the struct fullfills the interface diff --git a/roomdb/sqlite/auth_fallback_test.go b/roomdb/sqlite/auth_fallback_test.go index ea1a0ad..0220e8a 100644 --- a/roomdb/sqlite/auth_fallback_test.go +++ b/roomdb/sqlite/auth_fallback_test.go @@ -12,10 +12,10 @@ import ( "path/filepath" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb" "github.com/stretchr/testify/require" - refs "go.mindeco.de/ssb-refs" ) func TestFallbackAuth(t *testing.T) { @@ -27,7 +27,10 @@ func TestFallbackAuth(t *testing.T) { tr := repo.New(testRepo) // fake feed for testing, looks ok at least - newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} + newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } db, err := Open(tr) r.NoError(err, "failed to open database") @@ -40,7 +43,7 @@ func TestFallbackAuth(t *testing.T) { err = db.AuthFallback.SetPassword(ctx, memberID, testPassword) r.NoError(err, "failed to create password") - cookieVal, err := db.AuthFallback.Check(newMember.Ref(), string(testPassword)) + cookieVal, err := db.AuthFallback.Check(newMember.String(), string(testPassword)) r.NoError(err, "failed to check password") gotID, ok := cookieVal.(int64) r.True(ok, "unexpected cookie value: %T", cookieVal) @@ -74,7 +77,10 @@ func TestFallbackAuthSetPassword(t *testing.T) { tr := repo.New(testRepo) // fake feed for testing, looks ok at least - newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} + newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } db, err := Open(tr) r.NoError(err, "failed to open database") @@ -88,14 +94,14 @@ func TestFallbackAuthSetPassword(t *testing.T) { r.NoError(err, "failed to set password") // use the password - cookieVal, err := db.AuthFallback.Check(newMember.Ref(), string(testPassword)) + cookieVal, err := db.AuthFallback.Check(newMember.String(), string(testPassword)) r.NoError(err, "failed to check password") gotID, ok := cookieVal.(int64) r.True(ok, "unexpected cookie value: %T", cookieVal) r.Equal(memberID, gotID, "unexpected member ID value") // use a wrong password - cookieVal, err = db.AuthFallback.Check(newMember.Ref(), string(testPassword)+"nope-nope-nope") + cookieVal, err = db.AuthFallback.Check(newMember.String(), string(testPassword)+"nope-nope-nope") r.Error(err, "wrong password actually worked?!") r.Nil(cookieVal) @@ -105,11 +111,11 @@ func TestFallbackAuthSetPassword(t *testing.T) { r.NoError(err, "failed to update password") // now try to use old and new - cookieVal, err = db.AuthFallback.Check(newMember.Ref(), string(testPassword)) + cookieVal, err = db.AuthFallback.Check(newMember.String(), string(testPassword)) r.Error(err, "old password actually worked?!") r.Nil(cookieVal) - cookieVal, err = db.AuthFallback.Check(newMember.Ref(), string(changedTestPassword)) + cookieVal, err = db.AuthFallback.Check(newMember.String(), string(changedTestPassword)) r.NoError(err, "new password didnt work") gotID, ok = cookieVal.(int64) r.True(ok, "unexpected cookie value: %T", cookieVal) @@ -125,8 +131,15 @@ func TestFallbackAuthSetPasswordWithToken(t *testing.T) { tr := repo.New(testRepo) // two fake feeds for testing, looks ok at least - alf := refs.FeedRef{ID: bytes.Repeat([]byte("whyy"), 8), Algo: refs.RefAlgoFeedSSB1} - carl := refs.FeedRef{ID: bytes.Repeat([]byte("carl"), 8), Algo: refs.RefAlgoFeedSSB1} + alf, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("whyy"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } + + carl, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("carl"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } db, err := Open(tr) r.NoError(err, "failed to open database") @@ -155,7 +168,7 @@ func TestFallbackAuthSetPasswordWithToken(t *testing.T) { r.NoError(err, "setPassword with token failed") // now use the new password - cookieVal, err := db.AuthFallback.Check(carl.Ref(), newPassword) + cookieVal, err := db.AuthFallback.Check(carl.String(), newPassword) r.NoError(err, "new password didnt work") gotID, ok := cookieVal.(int64) r.True(ok, "unexpected cookie value: %T", cookieVal) diff --git a/roomdb/sqlite/auth_withssb.go b/roomdb/sqlite/auth_withssb.go index 1d07457..9af2eab 100644 --- a/roomdb/sqlite/auth_withssb.go +++ b/roomdb/sqlite/auth_withssb.go @@ -14,9 +14,9 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/randutil" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" + "github.com/ssbc/go-ssb-room/v2/internal/randutil" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" ) // compiler assertion to ensure the struct fullfills the interface diff --git a/roomdb/sqlite/denied.go b/roomdb/sqlite/denied.go index e9975e3..eb5ea06 100644 --- a/roomdb/sqlite/denied.go +++ b/roomdb/sqlite/denied.go @@ -14,9 +14,9 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" ) // compiler assertion to ensure the struct fullfills the interface @@ -30,7 +30,7 @@ type DeniedKeys struct { // Add adds the feed to the list. func (dk DeniedKeys) Add(ctx context.Context, a refs.FeedRef, comment string) error { // TODO: better valid - if _, err := refs.ParseFeedRef(a.Ref()); err != nil { + if _, err := refs.ParseFeedRef(a.String()); err != nil { return err } @@ -53,7 +53,7 @@ func (dk DeniedKeys) Add(ctx context.Context, a refs.FeedRef, comment string) er // HasFeed returns true if a feed is on the list. func (dk DeniedKeys) HasFeed(ctx context.Context, h refs.FeedRef) bool { - _, err := models.DeniedKeys(qm.Where("pub_key = ?", h.Ref())).One(ctx, dk.db) + _, err := models.DeniedKeys(qm.Where("pub_key = ?", h.String())).One(ctx, dk.db) if err != nil { return false } @@ -116,7 +116,7 @@ func (dk DeniedKeys) Count(ctx context.Context) (uint, error) { // RemoveFeed removes the feed from the list. func (dk DeniedKeys) RemoveFeed(ctx context.Context, r refs.FeedRef) error { - entry, err := models.DeniedKeys(qm.Where("pub_key = ?", r.Ref())).One(ctx, dk.db) + entry, err := models.DeniedKeys(qm.Where("pub_key = ?", r.String())).One(ctx, dk.db) if err != nil { if errors.Is(err, sql.ErrNoRows) { return roomdb.ErrNotFound diff --git a/roomdb/sqlite/denied_test.go b/roomdb/sqlite/denied_test.go index ca29131..e25e149 100644 --- a/roomdb/sqlite/denied_test.go +++ b/roomdb/sqlite/denied_test.go @@ -12,12 +12,12 @@ import ( "testing" "time" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" "github.com/stretchr/testify/require" - refs "go.mindeco.de/ssb-refs" ) func TestDeniedKeys(t *testing.T) { @@ -32,14 +32,20 @@ func TestDeniedKeys(t *testing.T) { db, err := Open(tr) require.NoError(t, err) - tf := refs.FeedRef{ID: bytes.Repeat([]byte("fooo"), 8), Algo: "nope"} + tf, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("fooo"), 8), "nope") + if err != nil { + r.Error(err) + } err = db.DeniedKeys.Add(ctx, tf, "wont work anyhow") r.Error(err) // looks ok at least created := time.Now() time.Sleep(time.Second) - okFeed := refs.FeedRef{ID: bytes.Repeat([]byte("b44d"), 8), Algo: refs.RefAlgoFeedSSB1} + okFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("b44d"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } err = db.DeniedKeys.Add(ctx, okFeed, "be gone") r.NoError(err) @@ -53,7 +59,7 @@ func TestDeniedKeys(t *testing.T) { lst, err := db.DeniedKeys.List(ctx) r.NoError(err) r.Len(lst, 1) - r.Equal(okFeed.Ref(), lst[0].PubKey.Ref()) + r.Equal(okFeed.String(), lst[0].PubKey.String()) r.Equal("be gone", lst[0].Comment) r.True(lst[0].CreatedAt.After(created), "not created after the sleep?") @@ -92,7 +98,10 @@ func TestDeniedKeysUnique(t *testing.T) { db, err := Open(tr) require.NoError(t, err) - feedA := refs.FeedRef{ID: bytes.Repeat([]byte("b33f"), 8), Algo: refs.RefAlgoFeedSSB1} + feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("b33f"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } err = db.DeniedKeys.Add(ctx, feedA, "test comment") r.NoError(err) @@ -118,7 +127,10 @@ func TestDeniedKeysByID(t *testing.T) { db, err := Open(tr) require.NoError(t, err) - feedA := refs.FeedRef{ID: bytes.Repeat([]byte("b33f"), 8), Algo: refs.RefAlgoFeedSSB1} + feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("b33f"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } err = db.DeniedKeys.Add(ctx, feedA, "nope") r.NoError(err) diff --git a/roomdb/sqlite/invites.go b/roomdb/sqlite/invites.go index 91f380d..ffa2f25 100644 --- a/roomdb/sqlite/invites.go +++ b/roomdb/sqlite/invites.go @@ -17,9 +17,9 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" ) // compiler assertion to ensure the struct fullfills the interface @@ -35,7 +35,7 @@ type Invites struct { // Create creates a new invite for a new member. It returns the token or an error. // createdBy is user ID of the admin or moderator who created it. -// aliasSuggestion is optional (empty string is fine) but can be used to disambiguate open invites. (See https://github.com/ssb-ngi-pointer/rooms2/issues/21) +// aliasSuggestion is optional (empty string is fine) but can be used to disambiguate open invites. (See https://github.com/ssbc/rooms2/issues/21) // The returned token is base64 URL encoded and has inviteTokenLength when decoded. func (i Invites) Create(ctx context.Context, createdBy int64) (string, error) { var newInvite = models.Invite{ @@ -132,7 +132,7 @@ func (i Invites) Consume(ctx context.Context, token string, newMember refs.FeedR _, err = i.members.add(ctx, tx, newMember, roomdb.RoleMember) var alreadyAdded roomdb.ErrAlreadyAdded if err != nil { - if errors.As(err, &alreadyAdded) && alreadyAdded.Ref.Equal(&newMember) { + if errors.As(err, &alreadyAdded) && alreadyAdded.Ref.Equal(newMember) { // it is fine to use an invite twice } else { return err diff --git a/roomdb/sqlite/invites_test.go b/roomdb/sqlite/invites_test.go index 8b9b797..88d4948 100644 --- a/roomdb/sqlite/invites_test.go +++ b/roomdb/sqlite/invites_test.go @@ -16,9 +16,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) func TestInvites(t *testing.T) { @@ -29,7 +29,10 @@ func TestInvites(t *testing.T) { tr := repo.New(testRepo) // fake feed for testing, looks ok at least - newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} + newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } db, err := Open(tr) require.NoError(t, err) @@ -55,7 +58,10 @@ func TestInvites(t *testing.T) { r.Error(err, "can't create invite for invalid user") }) - invitingMember := refs.FeedRef{ID: bytes.Repeat([]byte("ohai"), 8), Algo: refs.RefAlgoFeedSSB1} + invitingMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("ohai"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } mid, err := db.Members.Add(ctx, invitingMember, roomdb.RoleModerator) require.NoError(t, err, "failed to create test user") diff --git a/roomdb/sqlite/members.go b/roomdb/sqlite/members.go index af33557..e4629ec 100644 --- a/roomdb/sqlite/members.go +++ b/roomdb/sqlite/members.go @@ -11,11 +11,11 @@ import ( "github.com/friendsofgo/errors" "github.com/mattn/go-sqlite3" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - refs "go.mindeco.de/ssb-refs" ) // compiler assertion to ensure the struct fullfills the interface @@ -59,7 +59,7 @@ func (Members) add(ctx context.Context, tx *sql.Tx, pubKey refs.FeedRef, role ro return -1, err } - if _, err := refs.ParseFeedRef(pubKey.Ref()); err != nil { + if _, err := refs.ParseFeedRef(pubKey.String()); err != nil { return -1, err } @@ -105,7 +105,7 @@ func (m Members) GetByID(ctx context.Context, mid int64) (roomdb.Member, error) // GetByFeed returns the member if it exists func (m Members) GetByFeed(ctx context.Context, h refs.FeedRef) (roomdb.Member, error) { - entry, err := models.Members(qm.Where("pub_key = ?", h.Ref())).One(ctx, m.db) + entry, err := models.Members(qm.Where("pub_key = ?", h.String())).One(ctx, m.db) if err != nil { if errors.Is(err, sql.ErrNoRows) { return roomdb.Member{}, roomdb.ErrNotFound @@ -156,7 +156,7 @@ func (m Members) Count(ctx context.Context) (uint, error) { // RemoveFeed removes the feed from the list. func (m Members) RemoveFeed(ctx context.Context, r refs.FeedRef) error { - entry, err := models.Members(qm.Where("pub_key = ?", r.Ref())).One(ctx, m.db) + entry, err := models.Members(qm.Where("pub_key = ?", r.String())).One(ctx, m.db) if err != nil { if errors.Is(err, sql.ErrNoRows) { return roomdb.ErrNotFound diff --git a/roomdb/sqlite/members_test.go b/roomdb/sqlite/members_test.go index 0110f31..847247a 100644 --- a/roomdb/sqlite/members_test.go +++ b/roomdb/sqlite/members_test.go @@ -11,12 +11,12 @@ import ( "path/filepath" "testing" + refs "github.com/ssbc/go-ssb-refs" "github.com/stretchr/testify/require" - refs "go.mindeco.de/ssb-refs" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" ) func TestMembers(t *testing.T) { @@ -32,12 +32,18 @@ func TestMembers(t *testing.T) { require.NoError(t, err) // broken feed (unknown algo) - tf := refs.FeedRef{ID: bytes.Repeat([]byte("fooo"), 8), Algo: "nope"} + tf, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("fooo"), 8), "nope") + if err != nil { + r.Error(err) + } _, err = db.Members.Add(ctx, tf, roomdb.RoleMember) r.Error(err) // looks ok at least - okFeed := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} + okFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } mid, err := db.Members.Add(ctx, okFeed, roomdb.RoleMember) r.NoError(err) @@ -57,7 +63,7 @@ func TestMembers(t *testing.T) { r.NoError(err) r.Equal(okMember.ID, mid) r.Equal(okMember.Role, roomdb.RoleMember) - r.True(okMember.PubKey.Equal(&okFeed)) + r.True(okMember.PubKey.Equal(okFeed)) _, yes = db.Members.GetByFeed(ctx, tf) r.Error(yes) @@ -91,7 +97,10 @@ func TestMembersUnique(t *testing.T) { db, err := Open(tr) require.NoError(t, err) - feedA := refs.FeedRef{ID: bytes.Repeat([]byte("1312"), 8), Algo: refs.RefAlgoFeedSSB1} + feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1312"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } _, err = db.Members.Add(ctx, feedA, roomdb.RoleMember) r.NoError(err) @@ -117,7 +126,10 @@ func TestMembersByID(t *testing.T) { db, err := Open(tr) require.NoError(t, err) - feedA := refs.FeedRef{ID: bytes.Repeat([]byte("1312"), 8), Algo: refs.RefAlgoFeedSSB1} + feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1312"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } _, err = db.Members.Add(ctx, feedA, roomdb.RoleMember) r.NoError(err) @@ -157,12 +169,18 @@ func TestMembersSetRole(t *testing.T) { require.NoError(t, err) // create two users - feedA := refs.FeedRef{ID: bytes.Repeat([]byte("1"), 32), Algo: refs.RefAlgoFeedSSB1} + feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1"), 32), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } idA, err := db.Members.Add(ctx, feedA, roomdb.RoleAdmin) r.NoError(err) t.Log("member A:", idA) - feedB := refs.FeedRef{ID: bytes.Repeat([]byte("2"), 32), Algo: refs.RefAlgoFeedSSB1} + feedB, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("2"), 32), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } idB, err := db.Members.Add(ctx, feedB, roomdb.RoleModerator) r.NoError(err) t.Log("member B:", idB) @@ -238,7 +256,10 @@ func TestMembersAliases(t *testing.T) { db, err := Open(tr) require.NoError(t, err) - feedA := refs.FeedRef{ID: bytes.Repeat([]byte("1312"), 8), Algo: refs.RefAlgoFeedSSB1} + feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1312"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + r.Error(err) + } mid, err := db.Members.Add(ctx, feedA, roomdb.RoleMember) r.NoError(err) diff --git a/roomdb/sqlite/models/config.go b/roomdb/sqlite/models/config.go index 09047cc..da7cf47 100644 --- a/roomdb/sqlite/models/config.go +++ b/roomdb/sqlite/models/config.go @@ -17,7 +17,7 @@ import ( "time" "github.com/friendsofgo/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries" "github.com/volatiletech/sqlboiler/v4/queries/qm" diff --git a/roomdb/sqlite/models/denied_keys.go b/roomdb/sqlite/models/denied_keys.go index 17bac00..a67c620 100644 --- a/roomdb/sqlite/models/denied_keys.go +++ b/roomdb/sqlite/models/denied_keys.go @@ -17,7 +17,7 @@ import ( "time" "github.com/friendsofgo/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries" "github.com/volatiletech/sqlboiler/v4/queries/qm" diff --git a/roomdb/sqlite/models/members.go b/roomdb/sqlite/models/members.go index 770ec1e..bc51cbb 100644 --- a/roomdb/sqlite/models/members.go +++ b/roomdb/sqlite/models/members.go @@ -17,7 +17,7 @@ import ( "time" "github.com/friendsofgo/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries" "github.com/volatiletech/sqlboiler/v4/queries/qm" diff --git a/roomdb/sqlite/new.go b/roomdb/sqlite/new.go index 9f794c5..1f29414 100644 --- a/roomdb/sqlite/new.go +++ b/roomdb/sqlite/new.go @@ -28,7 +28,7 @@ import ( migrate "github.com/rubenv/sql-migrate" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/repo" ) type Database struct { diff --git a/roomdb/sqlite/new_test.go b/roomdb/sqlite/new_test.go index 6175b9a..090f559 100644 --- a/roomdb/sqlite/new_test.go +++ b/roomdb/sqlite/new_test.go @@ -12,7 +12,7 @@ import ( _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/repo" ) // verify the database opens and migrates successfully from zero state diff --git a/roomdb/sqlite/notices.go b/roomdb/sqlite/notices.go index 97cb940..ecea9ad 100644 --- a/roomdb/sqlite/notices.go +++ b/roomdb/sqlite/notices.go @@ -13,8 +13,8 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" ) // compiler assertion to ensure the struct fullfills the interface diff --git a/roomdb/sqlite/notices_test.go b/roomdb/sqlite/notices_test.go index c7f8359..2d694ab 100644 --- a/roomdb/sqlite/notices_test.go +++ b/roomdb/sqlite/notices_test.go @@ -12,8 +12,8 @@ import ( "path/filepath" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb" "github.com/stretchr/testify/require" ) diff --git a/roomdb/sqlite/roomconfig.go b/roomdb/sqlite/roomconfig.go index c5b7142..6076902 100644 --- a/roomdb/sqlite/roomconfig.go +++ b/roomdb/sqlite/roomconfig.go @@ -9,8 +9,8 @@ import ( "database/sql" "fmt" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models" "github.com/volatiletech/sqlboiler/v4/boil" ) diff --git a/roomdb/sqlite/roomconfig_test.go b/roomdb/sqlite/roomconfig_test.go index 2ccc747..725eda7 100644 --- a/roomdb/sqlite/roomconfig_test.go +++ b/roomdb/sqlite/roomconfig_test.go @@ -10,9 +10,9 @@ import ( "path/filepath" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/repo" "github.com/stretchr/testify/require" ) diff --git a/roomdb/types.go b/roomdb/types.go index 31c349f..af684cd 100644 --- a/roomdb/types.go +++ b/roomdb/types.go @@ -11,7 +11,7 @@ import ( "sort" "time" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" ) // ErrNotFound is returned by the admin db if an object couldn't be found. @@ -169,7 +169,7 @@ type ErrAlreadyAdded struct { } func (aa ErrAlreadyAdded) Error() string { - return fmt.Sprintf("roomdb: the item (%s) is already on the list", aa.Ref.Ref()) + return fmt.Sprintf("roomdb: the item (%s) is already on the list", aa.Ref.PubKey()) } // Invite is a combination of an invite id, who created it and when. @@ -205,14 +205,14 @@ func (r *DBFeedRef) Scan(src interface{}) error { return err } - r.FeedRef = *fr + r.FeedRef = fr return nil } // Value returns feed references as strings to the database. // https://pkg.go.dev/database/sql/driver#Valuer func (r DBFeedRef) Value() (driver.Value, error) { - return driver.Value(r.Ref()), nil + return driver.Value(r.String()), nil } // PinnedNoticeName holds a name of a well known part of the page with a fixed location. diff --git a/roomsrv/init_handlers.go b/roomsrv/init_handlers.go index ea93045..d80ce34 100644 --- a/roomsrv/init_handlers.go +++ b/roomsrv/init_handlers.go @@ -5,15 +5,15 @@ package roomsrv import ( - muxrpc "go.cryptoscope.co/muxrpc/v2" - "go.cryptoscope.co/muxrpc/v2/typemux" + muxrpc "github.com/ssbc/go-muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2/typemux" kitlog "go.mindeco.de/log" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/alias" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/gossip" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/whoami" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/alias" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/gossip" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server" + "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/whoami" ) // instantiate and register the muxrpc handlers diff --git a/roomsrv/init_network.go b/roomsrv/init_network.go index e736c49..0141265 100644 --- a/roomsrv/init_network.go +++ b/roomsrv/init_network.go @@ -8,10 +8,10 @@ import ( "fmt" "net" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) // opens the shs listener for TCP connections @@ -37,13 +37,13 @@ func (s *Server) initNetwork() error { // if privacy mode is restricted, deny connections from non-members if pm == roomdb.ModeRestricted { - if _, err := s.Members.GetByFeed(s.rootCtx, *remote); err != nil { + if _, err := s.Members.GetByFeed(s.rootCtx, remote); err != nil { return nil, fmt.Errorf("access restricted to members") } } // if feed is in the deny list, deny their connection - if s.DeniedKeys.HasFeed(s.rootCtx, *remote) { + if s.DeniedKeys.HasFeed(s.rootCtx, remote) { return nil, fmt.Errorf("this key has been banned") } diff --git a/roomsrv/init_unixsock.go b/roomsrv/init_unixsock.go index cfdb62c..1201d78 100644 --- a/roomsrv/init_unixsock.go +++ b/roomsrv/init_unixsock.go @@ -10,12 +10,12 @@ import ( "os" "path/filepath" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" kitlog "go.mindeco.de/log" "go.mindeco.de/log/level" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/netwraputil" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/netwraputil" + "github.com/ssbc/go-ssb-room/v2/internal/repo" ) // WithUNIXSocket enables listening for muxrpc connections on a unix socket files ($repo/socket). @@ -34,7 +34,7 @@ func (s *Server) initUnixSock() error { if s.keyPair == nil { return fmt.Errorf("roomsrv/unixsock: keypair is nil. please use unixSocket with LateOption") } - spoofWrapper := netwraputil.SpoofRemoteAddress(s.keyPair.Feed.ID) + spoofWrapper := netwraputil.SpoofRemoteAddress(s.keyPair.Feed.PubKey()) r := repo.New(s.repoPath) sockPath := r.GetPath("socket") diff --git a/roomsrv/manifest.go b/roomsrv/manifest.go index 61760c3..9a99d9d 100644 --- a/roomsrv/manifest.go +++ b/roomsrv/manifest.go @@ -9,7 +9,7 @@ import ( "encoding/json" "fmt" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" ) type manifestHandler string diff --git a/roomsrv/options.go b/roomsrv/options.go index 0ce336c..ae820aa 100644 --- a/roomsrv/options.go +++ b/roomsrv/options.go @@ -9,10 +9,10 @@ import ( "fmt" "strings" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "go.cryptoscope.co/netwrap" + "github.com/ssbc/go-netwrap" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/repo" kitlog "go.mindeco.de/log" ) diff --git a/roomsrv/server.go b/roomsrv/server.go index e50019c..248d9b6 100644 --- a/roomsrv/server.go +++ b/roomsrv/server.go @@ -16,19 +16,19 @@ import ( "path/filepath" "sync" - "go.cryptoscope.co/muxrpc/v2/typemux" - "go.cryptoscope.co/netwrap" + "github.com/ssbc/go-muxrpc/v2/typemux" + "github.com/ssbc/go-netwrap" kitlog "go.mindeco.de/log" "go.mindeco.de/log/level" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multicloser" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/multicloser" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomstate" ) type Server struct { diff --git a/roomstate/roomstate.go b/roomstate/roomstate.go index 6034609..c70bbc4 100644 --- a/roomstate/roomstate.go +++ b/roomstate/roomstate.go @@ -9,11 +9,11 @@ import ( "sort" "sync" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" kitlog "go.mindeco.de/log" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/broadcasts" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/broadcasts" ) type Manager struct { @@ -79,7 +79,7 @@ func (m *Manager) ListAsRefs() []refs.FeedRef { if err != nil { panic(fmt.Errorf("invalid feed ref in room state: %d: %s", i, err)) } - rlst[i] = *fr + rlst[i] = fr } return rlst } @@ -88,7 +88,7 @@ func (m *Manager) ListAsRefs() []refs.FeedRef { func (m *Manager) AddEndpoint(who refs.FeedRef, edp muxrpc.Endpoint) { m.roomMu.Lock() // add ref to to the room map - m.room[who.Ref()] = edp + m.room[who.String()] = edp currentMembers := m.room.AsList() m.roomMu.Unlock() // update all the connected tunnel.endpoints calls @@ -101,7 +101,7 @@ func (m *Manager) AddEndpoint(who refs.FeedRef, edp muxrpc.Endpoint) { func (m *Manager) Remove(who refs.FeedRef) { m.roomMu.Lock() // remove ref from lobby - delete(m.room, who.Ref()) + delete(m.room, who.String()) currentMembers := m.room.AsList() m.roomMu.Unlock() // update all the connected tunnel.endpoints calls @@ -117,10 +117,10 @@ func (m *Manager) AlreadyAdded(who refs.FeedRef, edp muxrpc.Endpoint) bool { var currentMembers []string // if the peer didn't call tunnel.announce() - _, has := m.room[who.Ref()] + _, has := m.room[who.String()] if !has { // register them as if they didnt - m.room[who.Ref()] = edp + m.room[who.String()] = edp currentMembers = m.room.AsList() } m.roomMu.Unlock() @@ -138,7 +138,7 @@ func (m *Manager) AlreadyAdded(who refs.FeedRef, edp muxrpc.Endpoint) bool { func (m *Manager) Has(who refs.FeedRef) (muxrpc.Endpoint, bool) { m.roomMu.Lock() // add ref to to the room map - edp, has := m.room[who.Ref()] + edp, has := m.room[who.String()] m.roomMu.Unlock() return edp, has } diff --git a/web/embedded_dev.go b/web/embedded_dev.go index e23b155..7f4b5dc 100644 --- a/web/embedded_dev.go +++ b/web/embedded_dev.go @@ -16,7 +16,7 @@ import ( const Production = false // absolute path of where this package is located -var pkgDir = goutils.MustLocatePackage("github.com/ssb-ngi-pointer/go-ssb-room/v2/web") +var pkgDir = goutils.MustLocatePackage("github.com/ssbc/go-ssb-room/v2/web") var Templates = http.Dir(filepath.Join(pkgDir, "templates")) diff --git a/web/errors/errhandler.go b/web/errors/errhandler.go index ef6dc58..36eb048 100644 --- a/web/errors/errhandler.go +++ b/web/errors/errhandler.go @@ -14,8 +14,8 @@ import ( "go.mindeco.de/log/level" "go.mindeco.de/logging" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/i18n" ) type ErrorHandler struct { @@ -120,7 +120,7 @@ func localizeError(ih *i18n.Localizer, err error) (int, template.HTML) { msg = ih.LocalizeSimple("ErrorNotFound") case errors.As(err, &aa): - msg = ih.LocalizeWithData("ErrorAlreadyAdded", "Feed", aa.Ref.Ref()) + msg = ih.LocalizeWithData("ErrorAlreadyAdded", "Feed", aa.Ref.String()) case errors.As(err, &pnf): code = http.StatusNotFound diff --git a/web/errors/flashes.go b/web/errors/flashes.go index 58a0b55..203bb89 100644 --- a/web/errors/flashes.go +++ b/web/errors/flashes.go @@ -11,7 +11,7 @@ import ( "net/http" "github.com/gorilla/sessions" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/web/i18n" ) type FlashHelper struct { diff --git a/web/handlers/admin/aliases.go b/web/handlers/admin/aliases.go index 86c9771..499a1ad 100644 --- a/web/handlers/admin/aliases.go +++ b/web/handlers/admin/aliases.go @@ -12,9 +12,9 @@ import ( "github.com/gorilla/csrf" "go.mindeco.de/http/render" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" + "github.com/ssbc/go-ssb-room/v2/roomdb" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/members" ) // aliasesHandler implements the managment endpoints for aliases (list and revoke), @@ -90,7 +90,7 @@ func (h aliasesHandler) revoke(rw http.ResponseWriter, req *http.Request) { } // ensure own alias or admin - if !aliasEntry.Feed.Equal(¤tMember.PubKey) && currentMember.Role != roomdb.RoleAdmin { + if !aliasEntry.Feed.Equal(currentMember.PubKey) && currentMember.Role != roomdb.RoleAdmin { err := weberrors.ErrForbidden{Details: fmt.Errorf("not your alias or not an admin")} h.flashes.AddError(rw, req, err) return diff --git a/web/handlers/admin/aliases_test.go b/web/handlers/admin/aliases_test.go index 9de0b44..2a646cc 100644 --- a/web/handlers/admin/aliases_test.go +++ b/web/handlers/admin/aliases_test.go @@ -11,10 +11,10 @@ import ( "github.com/stretchr/testify/assert" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" ) func TestAliasesRevokeConfirmation(t *testing.T) { @@ -23,7 +23,7 @@ func TestAliasesRevokeConfirmation(t *testing.T) { testKey, err := refs.ParseFeedRef("@x7iOLUcq3o+sjGeAnipvWeGzfuYgrXl8L4LYlxIhwDc=.ed25519") a.NoError(err) - testEntry := roomdb.Alias{ID: 666, Name: "the-test-name", Feed: *testKey} + testEntry := roomdb.Alias{ID: 666, Name: "the-test-name", Feed: testKey} ts.AliasesDB.GetByIDReturns(testEntry, nil) urlRevokeConfirm := ts.URLTo(router.AdminAliasesRevokeConfirm, "id", 3) @@ -31,7 +31,7 @@ func TestAliasesRevokeConfirmation(t *testing.T) { html, resp := ts.Client.GetHTML(urlRevokeConfirm) a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code") - a.Equal(testKey.Ref(), html.Find("pre#verify").Text(), "has the key for verification") + a.Equal(testKey.String(), html.Find("pre#verify").Text(), "has the key for verification") form := html.Find("form#confirm") diff --git a/web/handlers/admin/dashboard.go b/web/handlers/admin/dashboard.go index 8de0909..1e4fa28 100644 --- a/web/handlers/admin/dashboard.go +++ b/web/handlers/admin/dashboard.go @@ -10,15 +10,15 @@ import ( "net/http" "time" + refs "github.com/ssbc/go-ssb-refs" "go.mindeco.de/http/render" "go.mindeco.de/log/level" "go.mindeco.de/logging" - refs "go.mindeco.de/ssb-refs" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomstate" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" ) type dashboardHandler struct { @@ -34,7 +34,7 @@ func (h dashboardHandler) overview(w http.ResponseWriter, req *http.Request) (in var ( err error ctx = req.Context() - roomRef = h.netInfo.RoomID.Ref() + roomRef = h.netInfo.RoomID.String() onlineRefs []refs.FeedRef refsUpdateCh = make(chan []refs.FeedRef) @@ -116,5 +116,5 @@ func (dm connectedUser) String() string { if len(dm.Aliases) > 0 { return dm.Aliases[0].Name } - return dm.PubKey.Ref() + return dm.PubKey.String() } diff --git a/web/handlers/admin/dashboard_test.go b/web/handlers/admin/dashboard_test.go index 2d4ab4d..f288a49 100644 --- a/web/handlers/admin/dashboard_test.go +++ b/web/handlers/admin/dashboard_test.go @@ -10,18 +10,21 @@ import ( "net/http" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" "github.com/stretchr/testify/assert" - refs "go.mindeco.de/ssb-refs" ) func TestDashboardSimple(t *testing.T) { ts := newSession(t) a := assert.New(t) - testRef := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{0}, 32)} + testRef, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{0}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } ts.RoomState.AddEndpoint(testRef, nil) // 1 online ts.MembersDB.CountReturns(4, nil) // 4 members ts.InvitesDB.CountReturns(3, nil) // 3 invites @@ -47,15 +50,21 @@ func TestDashboardWithVisitors(t *testing.T) { ts := newSession(t) a := assert.New(t) - visitorRef := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{0}, 32)} - memberRef := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{1}, 32)} + visitorRef, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{0}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + memberRef, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } ts.RoomState.AddEndpoint(visitorRef, nil) ts.RoomState.AddEndpoint(memberRef, nil) ts.MembersDB.CountReturns(1, nil) // return a member for the member but not for the visitor ts.MembersDB.GetByFeedStub = func(ctx context.Context, r refs.FeedRef) (roomdb.Member, error) { - if r.Equal(&memberRef) { + if r.Equal(memberRef) { return roomdb.Member{ID: 23, Role: roomdb.RoleMember, PubKey: r}, nil } return roomdb.Member{}, roomdb.ErrNotFound @@ -73,12 +82,12 @@ func TestDashboardWithVisitors(t *testing.T) { a.Equal(2, memberList.Length()) htmlVisitor := memberList.Eq(0) - a.Equal(visitorRef.Ref(), htmlVisitor.Text()) + a.Equal(visitorRef.String(), htmlVisitor.Text()) gotLink, has := htmlVisitor.Attr("href") a.False(has, "visitor should not have a link to a details page: %v", gotLink) htmlMember := memberList.Eq(1) - a.Equal(memberRef.Ref(), htmlMember.Text()) + a.Equal(memberRef.String(), htmlMember.Text()) gotLink, has = htmlMember.Attr("href") a.True(has, "member should have a link to a details page") wantLink := ts.URLTo(router.AdminMemberDetails, "id", 23) diff --git a/web/handlers/admin/denied_keys.go b/web/handlers/admin/denied_keys.go index 9d89cd6..5fb8aac 100644 --- a/web/handlers/admin/denied_keys.go +++ b/web/handlers/admin/denied_keys.go @@ -12,10 +12,10 @@ import ( "github.com/gorilla/csrf" "go.mindeco.de/http/render" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/members" ) type deniedKeysHandler struct { @@ -65,7 +65,7 @@ func (h deniedKeysHandler) add(w http.ResponseWriter, req *http.Request) { // can be empty comment := req.Form.Get("comment") - err = h.db.Add(req.Context(), *newEntryParsed, comment) + err = h.db.Add(req.Context(), newEntryParsed, comment) if err != nil { h.flashes.AddError(w, req, err) } else { diff --git a/web/handlers/admin/denied_keys_test.go b/web/handlers/admin/denied_keys_test.go index 3adf1f3..c7cd994 100644 --- a/web/handlers/admin/denied_keys_test.go +++ b/web/handlers/admin/denied_keys_test.go @@ -14,10 +14,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" ) func TestDeniedKeysEmpty(t *testing.T) { @@ -91,7 +91,7 @@ func TestDeniedKeysAddDisabledInterface(t *testing.T) { // require call count to not panic r.Equal(totalAddCallCount, ts.DeniedKeysDB.AddCallCount()) _, addedKey, addedComment := ts.DeniedKeysDB.AddArgsForCall(totalAddCallCount - 1) - a.Equal(newKey, addedKey.Ref()) + a.Equal(newKey, addedKey.String()) a.Equal("some comment", addedComment) } else { r.Equal(totalAddCallCount, ts.DeniedKeysDB.AddCallCount()) @@ -191,7 +191,7 @@ func TestDeniedKeysAdd(t *testing.T) { a.Equal(1, ts.DeniedKeysDB.AddCallCount()) _, addedKey, addedComment := ts.DeniedKeysDB.AddArgsForCall(0) - a.Equal(newKey, addedKey.Ref()) + a.Equal(newKey, addedKey.String()) a.Equal("some comment", addedComment) } @@ -223,10 +223,25 @@ func TestDeniedKeys(t *testing.T) { ts := newSession(t) a := assert.New(t) + fakeFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{0}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + + oneThreeOneTwoFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1312"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + + acabFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + lst := []roomdb.ListEntry{ - {ID: 1, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte{0}, 32), Algo: "fake"}}, - {ID: 2, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("1312"), 8), Algo: "test"}}, - {ID: 3, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: "true"}}, + {ID: 1, PubKey: fakeFeed}, + {ID: 2, PubKey: oneThreeOneTwoFeed}, + {ID: 3, PubKey: acabFeed}, } ts.DeniedKeysDB.ListReturns(lst, nil) @@ -243,8 +258,12 @@ func TestDeniedKeys(t *testing.T) { a.EqualValues(html.Find("#theList li").Length(), 3) + feed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } lst = []roomdb.ListEntry{ - {ID: 666, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte{1}, 32), Algo: "one"}}, + {ID: 666, PubKey: feed}, } ts.DeniedKeysDB.ListReturns(lst, nil) @@ -273,7 +292,7 @@ func TestDeniedKeysRemoveConfirmation(t *testing.T) { testKey, err := refs.ParseFeedRef("@x7iOLUcq3o+sjGeAnipvWeGzfuYgrXl8L4LYlxIhwDc=.ed25519") a.NoError(err) - testEntry := roomdb.ListEntry{ID: 666, PubKey: *testKey} + testEntry := roomdb.ListEntry{ID: 666, PubKey: testKey} ts.DeniedKeysDB.GetByIDReturns(testEntry, nil) urlRemoveConfirm := ts.URLTo(router.AdminDeniedKeysRemoveConfirm, "id", 3) @@ -281,7 +300,7 @@ func TestDeniedKeysRemoveConfirmation(t *testing.T) { html, resp := ts.Client.GetHTML(urlRemoveConfirm) a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code") - a.Equal(testKey.Ref(), html.Find("pre#verify").Text(), "has the key for verification") + a.Equal(testKey.String(), html.Find("pre#verify").Text(), "has the key for verification") form := html.Find("form#confirm") @@ -333,8 +352,12 @@ func TestDeniedKeysRemovalRights(t *testing.T) { ts := newSession(t) // check disabled remove button on list page + pubKey, err := generatePubKey() + if err != nil { + t.Error(err) + } ts.DeniedKeysDB.ListReturns([]roomdb.ListEntry{ - {ID: 666, PubKey: generatePubKey(), Comment: "test-entry"}, + {ID: 666, PubKey: pubKey, Comment: "test-entry"}, }, nil) urlRemoveConfirm := ts.URLTo(router.AdminDeniedKeysRemoveConfirm, "id", "666").String() @@ -382,21 +405,36 @@ func TestDeniedKeysRemovalRights(t *testing.T) { } } + memKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + modKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + adminKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + // the users who will execute the action memberUser := roomdb.Member{ ID: 7331, Role: roomdb.RoleMember, - PubKey: generatePubKey(), + PubKey: memKey, } modUser := roomdb.Member{ ID: 9001, Role: roomdb.RoleModerator, - PubKey: generatePubKey(), + PubKey: modKey, } adminUser := roomdb.Member{ ID: 1337, Role: roomdb.RoleAdmin, - PubKey: generatePubKey(), + PubKey: adminKey, } /* test various restricted mode with the roles member, mod, admin */ diff --git a/web/handlers/admin/handler.go b/web/handlers/admin/handler.go index 5fe5308..fd64246 100644 --- a/web/handlers/admin/handler.go +++ b/web/handlers/admin/handler.go @@ -18,13 +18,13 @@ import ( "github.com/vcraescu/go-paginator/v2/view" "go.mindeco.de/http/render" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomstate" + "github.com/ssbc/go-ssb-room/v2/web" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/web/router" ) // HTMLTemplates define the list of files the template system should load. diff --git a/web/handlers/admin/invites.go b/web/handlers/admin/invites.go index 4ce3c31..9d722f9 100644 --- a/web/handlers/admin/invites.go +++ b/web/handlers/admin/invites.go @@ -13,11 +13,11 @@ import ( "github.com/gorilla/csrf" "go.mindeco.de/http/render" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/members" + "github.com/ssbc/go-ssb-room/v2/web/router" ) type invitesHandler struct { diff --git a/web/handlers/admin/invites_test.go b/web/handlers/admin/invites_test.go index 6d7735a..b1a2f23 100644 --- a/web/handlers/admin/invites_test.go +++ b/web/handlers/admin/invites_test.go @@ -14,9 +14,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" ) func TestInvitesOverview(t *testing.T) { @@ -218,20 +218,35 @@ func TestInvitesCreateAndRevoke(t *testing.T) { shownLink := doc.Find("#invite-facade-link").Text() a.Equal(wantURL.String(), shownLink) + memKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + modKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + adminKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + memberUser := roomdb.Member{ ID: 7331, Role: roomdb.RoleMember, - PubKey: generatePubKey(), + PubKey: memKey, } modUser := roomdb.Member{ ID: 9001, Role: roomdb.RoleModerator, - PubKey: generatePubKey(), + PubKey: modKey, } adminUser := roomdb.Member{ ID: 1337, Role: roomdb.RoleAdmin, - PubKey: generatePubKey(), + PubKey: adminKey, } /* test invite creation under various restricted mode with the roles member, mod, admin */ diff --git a/web/handlers/admin/members.go b/web/handlers/admin/members.go index 7a39e0f..9966b0a 100644 --- a/web/handlers/admin/members.go +++ b/web/handlers/admin/members.go @@ -14,13 +14,13 @@ import ( "github.com/gorilla/csrf" "go.mindeco.de/http/render" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/members" + "github.com/ssbc/go-ssb-room/v2/web/router" ) type membersHandler struct { @@ -59,7 +59,7 @@ func (h membersHandler) add(w http.ResponseWriter, req *http.Request) { return } - _, err = h.db.Add(req.Context(), *newEntryParsed, roomdb.RoleMember) + _, err = h.db.Add(req.Context(), newEntryParsed, roomdb.RoleMember) if err != nil { h.flashes.AddError(w, req, err) return diff --git a/web/handlers/admin/members_test.go b/web/handlers/admin/members_test.go index 3c55e96..6cc3757 100644 --- a/web/handlers/admin/members_test.go +++ b/web/handlers/admin/members_test.go @@ -15,10 +15,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" ) func TestMembersEmpty(t *testing.T) { @@ -78,7 +78,7 @@ func TestMembersAdd(t *testing.T) { a.Equal(1, ts.MembersDB.AddCallCount()) _, addedPubKey, addedRole := ts.MembersDB.AddArgsForCall(0) - a.Equal(newKey, addedPubKey.Ref()) + a.Equal(newKey, addedPubKey.String()) a.Equal(roomdb.RoleMember, addedRole) /* Verify that the inputs are visible/hidden depending on user roles */ @@ -149,10 +149,25 @@ func TestMembers(t *testing.T) { ts := newSession(t) a := assert.New(t) + fakeFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{0}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + + oneThreeOneTwoFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1312"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + + acabFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + lst := []roomdb.Member{ - {ID: 1, Role: roomdb.RoleMember, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte{0}, 32), Algo: "fake"}}, - {ID: 2, Role: roomdb.RoleModerator, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("1312"), 8), Algo: "test"}}, - {ID: 3, Role: roomdb.RoleAdmin, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: "true"}}, + {ID: 1, Role: roomdb.RoleMember, PubKey: fakeFeed}, + {ID: 2, Role: roomdb.RoleModerator, PubKey: oneThreeOneTwoFeed}, + {ID: 3, Role: roomdb.RoleAdmin, PubKey: acabFeed}, } ts.MembersDB.ListReturns(lst, nil) @@ -175,8 +190,13 @@ func TestMembers(t *testing.T) { a.EqualValues(elems.Find("span[data-role='admin']").Length(), 1) a.EqualValues(elems.Find("span[data-role='moderator']").Length(), 1) + oneFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + lst = []roomdb.Member{ - {ID: 666, Role: roomdb.RoleAdmin, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte{1}, 32), Algo: "one"}}, + {ID: 666, Role: roomdb.RoleAdmin, PubKey: oneFeed}, } ts.MembersDB.ListReturns(lst, nil) @@ -208,7 +228,11 @@ func TestMemberDetails(t *testing.T) { ts := newSession(t) a := assert.New(t) - feedRef := refs.FeedRef{ID: bytes.Repeat([]byte{0}, 32), Algo: "fake"} + feedRef, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{0}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + aliases := []roomdb.Alias{ {ID: 11, Name: "robert", Feed: feedRef, Signature: bytes.Repeat([]byte{0}, 4)}, {ID: 21, Name: "bob", Feed: feedRef, Signature: bytes.Repeat([]byte{0}, 4)}, @@ -271,7 +295,7 @@ func TestMemberDetails(t *testing.T) { // check for SSB ID ssbID := html.Find("#ssb-id") - a.Equal(feedRef.Ref(), ssbID.Text()) + a.Equal(feedRef.String(), ssbID.Text()) // check for change-role dropdown roleDropdown := html.Find("#change-role") @@ -312,20 +336,35 @@ func TestMemberDetails(t *testing.T) { webassert.HasFlashMessages(t, ts.Client, overviewURL, wantLabel) } + memKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + modKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + adminKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + memberUser := roomdb.Member{ ID: 7331, Role: roomdb.RoleMember, - PubKey: generatePubKey(), + PubKey: memKey, } modUser := roomdb.Member{ ID: 9001, Role: roomdb.RoleModerator, - PubKey: generatePubKey(), + PubKey: modKey, } adminUser := roomdb.Member{ ID: 1337, Role: roomdb.RoleAdmin, - PubKey: generatePubKey(), + PubKey: adminKey, } for _, mode := range roomdb.AllPrivacyModes { @@ -370,7 +409,7 @@ func TestMembersRemoveConfirmation(t *testing.T) { testKey, err := refs.ParseFeedRef("@x7iOLUcq3o+sjGeAnipvWeGzfuYgrXl8L4LYlxIhwDc=.ed25519") a.NoError(err) - testEntry := roomdb.Member{ID: 666, PubKey: *testKey} + testEntry := roomdb.Member{ID: 666, PubKey: testKey} ts.MembersDB.GetByIDReturns(testEntry, nil) urlRemoveConfirm := ts.URLTo(router.AdminMembersRemoveConfirm, "id", 3) @@ -378,7 +417,7 @@ func TestMembersRemoveConfirmation(t *testing.T) { html, resp := ts.Client.GetHTML(urlRemoveConfirm) a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code") - a.Equal(testKey.Ref(), html.Find("pre#verify").Text(), "has the key for verification") + a.Equal(testKey.String(), html.Find("pre#verify").Text(), "has the key for verification") form := html.Find("form#confirm") @@ -441,10 +480,15 @@ func TestMembersCreateResetToken(t *testing.T) { // setup mock + testRef, err := refs.NewFeedRefFromBytes(make([]byte, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + ts.MembersDB.GetByIDReturns(roomdb.Member{ ID: 2342, Role: roomdb.RoleMember, - PubKey: refs.FeedRef{ID: make([]byte, 32), Algo: refs.RefAlgoFeedSSB1}, + PubKey: testRef, }, nil) urlViewDetails := ts.URLTo(router.AdminMemberDetails, "id", "2342") @@ -482,7 +526,7 @@ func TestMembersCreateResetToken(t *testing.T) { }) a.Equal(http.StatusOK, resp.Code) - doc, err := goquery.NewDocumentFromReader(resp.Body) + doc, err = goquery.NewDocumentFromReader(resp.Body) require.NoError(t, err) gotResetURL, has := doc.Find("#password-reset-link").Attr("href") diff --git a/web/handlers/admin/notices.go b/web/handlers/admin/notices.go index ce66f9d..7601910 100644 --- a/web/handlers/admin/notices.go +++ b/web/handlers/admin/notices.go @@ -11,14 +11,14 @@ import ( "strconv" "strings" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web" + "github.com/ssbc/go-ssb-room/v2/web/members" + "github.com/ssbc/go-ssb-room/v2/web/router" "github.com/gorilla/csrf" "github.com/russross/blackfriday/v2" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/roomdb" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" "go.mindeco.de/http/render" ) diff --git a/web/handlers/admin/notices_test.go b/web/handlers/admin/notices_test.go index d8af74c..5f5d386 100644 --- a/web/handlers/admin/notices_test.go +++ b/web/handlers/admin/notices_test.go @@ -10,9 +10,9 @@ import ( "net/url" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" "github.com/stretchr/testify/assert" ) @@ -214,20 +214,35 @@ func TestNoticesRoleRightsEditing(t *testing.T) { a.Equal(totalSaveCallCount, ts.NoticeDB.SaveCallCount(), "call count missmatch") } + memKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + modKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + adminKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + memberUser := roomdb.Member{ ID: 7331, Role: roomdb.RoleMember, - PubKey: generatePubKey(), + PubKey: memKey, } modUser := roomdb.Member{ ID: 9001, Role: roomdb.RoleModerator, - PubKey: generatePubKey(), + PubKey: modKey, } adminUser := roomdb.Member{ ID: 1337, Role: roomdb.RoleAdmin, - PubKey: generatePubKey(), + PubKey: adminKey, } /* test invite creation under various restricted mode with the roles member, mod, admin */ @@ -310,20 +325,35 @@ func TestNoticesRoleRightsAddingTranslation(t *testing.T) { a.Equal(totalAddCallCount, ts.PinnedDB.SetCallCount(), "call count missmatch") } + memKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + modKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + + adminKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + memberUser := roomdb.Member{ ID: 7331, Role: roomdb.RoleMember, - PubKey: generatePubKey(), + PubKey: memKey, } modUser := roomdb.Member{ ID: 9001, Role: roomdb.RoleModerator, - PubKey: generatePubKey(), + PubKey: modKey, } adminUser := roomdb.Member{ ID: 1337, Role: roomdb.RoleAdmin, - PubKey: generatePubKey(), + PubKey: adminKey, } /* test invite creation under various restricted mode with the roles member, mod, admin */ diff --git a/web/handlers/admin/set_language_test.go b/web/handlers/admin/set_language_test.go index d7491a2..d34aa1a 100644 --- a/web/handlers/admin/set_language_test.go +++ b/web/handlers/admin/set_language_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" "github.com/stretchr/testify/assert" ) diff --git a/web/handlers/admin/settings.go b/web/handlers/admin/settings.go index 1e57593..10dee02 100644 --- a/web/handlers/admin/settings.go +++ b/web/handlers/admin/settings.go @@ -12,12 +12,12 @@ import ( "go.mindeco.de/http/render" "github.com/gorilla/csrf" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/web/members" + "github.com/ssbc/go-ssb-room/v2/web/router" ) type settingsHandler struct { diff --git a/web/handlers/admin/settings_test.go b/web/handlers/admin/settings_test.go index 3d6a1e0..d075391 100644 --- a/web/handlers/admin/settings_test.go +++ b/web/handlers/admin/settings_test.go @@ -12,8 +12,8 @@ import ( "github.com/PuerkitoBio/goquery" "github.com/stretchr/testify/assert" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" ) func TestSettingsOverview(t *testing.T) { diff --git a/web/handlers/admin/setup_test.go b/web/handlers/admin/setup_test.go index f49f310..fe6580d 100644 --- a/web/handlers/admin/setup_test.go +++ b/web/handlers/admin/setup_test.go @@ -19,23 +19,23 @@ import ( "github.com/dustin/go-humanize" "github.com/gorilla/sessions" "github.com/pkg/errors" + refs "github.com/ssbc/go-ssb-refs" "go.mindeco.de/http/render" "go.mindeco.de/http/tester" "go.mindeco.de/logging/logtest" - refs "go.mindeco.de/ssb-refs" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/randutil" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrs "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n/i18ntesting" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/randutil" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb" + "github.com/ssbc/go-ssb-room/v2/roomstate" + "github.com/ssbc/go-ssb-room/v2/web" + weberrs "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/web/i18n/i18ntesting" + "github.com/ssbc/go-ssb-room/v2/web/members" + "github.com/ssbc/go-ssb-room/v2/web/router" ) type testSession struct { @@ -62,10 +62,13 @@ type testSession struct { var pubKeyCount byte -func generatePubKey() refs.FeedRef { - pk := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{pubKeyCount}, 32)} +func generatePubKey() (refs.FeedRef, error) { + pk, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{pubKeyCount}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + return refs.FeedRef{}, err + } pubKeyCount++ - return pk + return pk, nil } func newSession(t *testing.T) *testSession { @@ -87,10 +90,14 @@ func newSession(t *testing.T) *testSession { log, _ := logtest.KitLogger("admin", t) ts.RoomState = roomstate.NewManager(log) - ts.netInfo = network.ServerEndpointDetails{ - Domain: randutil.String(10), - RoomID: generatePubKey(), + pubKey, err := generatePubKey() + if err != nil { + t.Error(err) + } + ts.netInfo = network.ServerEndpointDetails{ + Domain: randutil.String(10), + RoomID: pubKey, UseSubdomainForAliases: true, } @@ -108,11 +115,16 @@ func newSession(t *testing.T) *testSession { return testURL } + pubKey, err = generatePubKey() + if err != nil { + t.Error(err) + } + // fake user ts.User = roomdb.Member{ ID: 1234, Role: roomdb.RoleModerator, - PubKey: generatePubKey(), + PubKey: pubKey, } testPath := filepath.Join("testrun", t.Name()) diff --git a/web/handlers/aliases.go b/web/handlers/aliases.go index a25e21c..7a8929d 100644 --- a/web/handlers/aliases.go +++ b/web/handlers/aliases.go @@ -16,10 +16,10 @@ import ( "github.com/gorilla/mux" "go.mindeco.de/http/render" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" + "github.com/ssbc/go-ssb-room/v2/internal/aliases" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web" ) // aliasHandler implements the public resolve endpoint for HTML and JSON requests. @@ -110,10 +110,10 @@ func (json *aliasJSONResponder) UpdateRoomInfo(netInfo network.ServerEndpointDet func (json aliasJSONResponder) SendConfirmation(alias roomdb.Alias) { var resp = aliasJSONResponse{ Status: "successful", - RoomID: json.netInfo.RoomID.Ref(), + RoomID: json.netInfo.RoomID.String(), MultiserverAddress: json.netInfo.MultiserverAddress(), Alias: alias.Name, - UserID: alias.Feed.Ref(), + UserID: alias.Feed.String(), Signature: base64.StdEncoding.EncodeToString(alias.Signature), } json.enc.Encode(resp) @@ -152,9 +152,9 @@ func (html aliasHTMLResponder) SendConfirmation(alias roomdb.Alias) { // construct the ssb:experimental?action=consume-alias&... uri for linking into apps queryParams := url.Values{} queryParams.Set("action", "consume-alias") - queryParams.Set("roomId", html.netInfo.RoomID.Ref()) + queryParams.Set("roomId", html.netInfo.RoomID.String()) queryParams.Set("alias", alias.Name) - queryParams.Set("userId", alias.Feed.Ref()) + queryParams.Set("userId", alias.Feed.String()) queryParams.Set("signature", base64.URLEncoding.EncodeToString(alias.Signature)) queryParams.Set("multiserverAddress", html.netInfo.MultiserverAddress()) diff --git a/web/handlers/aliases_test.go b/web/handlers/aliases_test.go index b44ef7f..2c1ad71 100644 --- a/web/handlers/aliases_test.go +++ b/web/handlers/aliases_test.go @@ -16,11 +16,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/randutil" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/randutil" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" ) func TestAliasResolve(t *testing.T) { @@ -29,13 +29,14 @@ func TestAliasResolve(t *testing.T) { a := assert.New(t) r := require.New(t) + feed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{'F'}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } var testAlias = roomdb.Alias{ - ID: 54321, - Name: "test-name", - Feed: refs.FeedRef{ - ID: bytes.Repeat([]byte{'F'}, 32), - Algo: "test", - }, + ID: 54321, + Name: "test-name", + Feed: feed, Signature: bytes.Repeat([]byte{'S'}, 32), } ts.AliasesDB.ResolveReturns(testAlias, nil) @@ -67,11 +68,11 @@ func TestAliasResolve(t *testing.T) { params := aliasURI.Query() a.Equal("consume-alias", params.Get("action")) a.Equal(testAlias.Name, params.Get("alias")) - a.Equal(testAlias.Feed.Ref(), params.Get("userId")) + a.Equal(testAlias.Feed.String(), params.Get("userId")) sigData, err := base64.StdEncoding.DecodeString(params.Get("signature")) r.NoError(err) a.Equal(testAlias.Signature, sigData) - a.Equal(ts.NetworkInfo.RoomID.Ref(), params.Get("roomId")) + a.Equal(ts.NetworkInfo.RoomID.String(), params.Get("roomId")) a.Equal(ts.NetworkInfo.MultiserverAddress(), params.Get("multiserverAddress")) // now as JSON @@ -92,8 +93,8 @@ func TestAliasResolve(t *testing.T) { sigData2, err := base64.StdEncoding.DecodeString(ar.Signature) r.NoError(err) a.Equal(testAlias.Signature, sigData2) - a.Equal(testAlias.Feed.Ref(), ar.UserID, "wrong user feed on response") - a.Equal(ts.NetworkInfo.RoomID.Ref(), ar.RoomID, "wrong room feed on response") + a.Equal(testAlias.Feed.String(), ar.UserID, "wrong user feed on response") + a.Equal(ts.NetworkInfo.RoomID.String(), ar.RoomID, "wrong room feed on response") a.Equal(ts.NetworkInfo.MultiserverAddress(), ar.MultiserverAddress) /* alias resolving should not work for restricted rooms */ @@ -110,13 +111,14 @@ func TestAliasResolveOnAndroidChrome(t *testing.T) { a := assert.New(t) r := require.New(t) + feed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{'F'}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } var testAlias = roomdb.Alias{ - ID: 54321, - Name: "test-name", - Feed: refs.FeedRef{ - ID: bytes.Repeat([]byte{'F'}, 32), - Algo: "test", - }, + ID: 54321, + Name: "test-name", + Feed: feed, Signature: bytes.Repeat([]byte{'S'}, 32), } ts.AliasesDB.ResolveReturns(testAlias, nil) @@ -153,11 +155,11 @@ func TestAliasResolveOnAndroidChrome(t *testing.T) { params := aliasURI.Query() a.Equal("consume-alias", params.Get("action")) a.Equal(testAlias.Name, params.Get("alias")) - a.Equal(testAlias.Feed.Ref(), params.Get("userId")) + a.Equal(testAlias.Feed.String(), params.Get("userId")) sigData, err := base64.StdEncoding.DecodeString(params.Get("signature")) r.NoError(err) a.Equal(testAlias.Signature, sigData) - a.Equal(ts.NetworkInfo.RoomID.Ref(), params.Get("roomId")) + a.Equal(ts.NetworkInfo.RoomID.String(), params.Get("roomId")) a.Equal(ts.NetworkInfo.MultiserverAddress(), params.Get("multiserverAddress")) frag := aliasURI.Fragment diff --git a/web/handlers/auth/withssb.go b/web/handlers/auth/withssb.go index f55da84..5dbe54d 100644 --- a/web/handlers/auth/withssb.go +++ b/web/handlers/auth/withssb.go @@ -21,19 +21,19 @@ import ( "github.com/gorilla/mux" "github.com/gorilla/sessions" "github.com/skip2/go-qrcode" - "go.cryptoscope.co/muxrpc/v2" + "github.com/ssbc/go-muxrpc/v2" "go.mindeco.de/http/render" kitlog "go.mindeco.de/log" "go.mindeco.de/log/level" "go.mindeco.de/logging" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/router" ) var HTMLTemplates = []string{ @@ -61,7 +61,7 @@ const ( const sessionLifetime = time.Hour * 24 // WithSSBHandler implements the oauth-like challenge/response dance described in -// https://ssb-ngi-pointer.github.io/ssb-http-auth-spec +// https://ssbc.github.io/ssb-http-auth-spec type WithSSBHandler struct { render *render.Renderer @@ -225,7 +225,7 @@ func (h WithSSBHandler) DecideMethod(w http.ResponseWriter, req *http.Request) { if cidString := queryVals.Get("cid"); cidString != "" { parsedCID, err := refs.ParseFeedRef(cidString) if err == nil { - cid = parsedCID + cid = &parsedCID _, err := h.membersdb.GetByFeed(req.Context(), *cid) if err != nil { @@ -356,10 +356,10 @@ func (h WithSSBHandler) serverInitiated(sc string, userAgent string) (templateDa } // prepare the ssb-uri - // https://ssb-ngi-pointer.github.io/ssb-http-auth-spec/#list-of-new-ssb-uris + // https://ssbc.github.io/ssb-http-auth-spec/#list-of-new-ssb-uris var queryParams = make(url.Values) queryParams.Set("action", "start-http-auth") - queryParams.Set("sid", h.netInfo.RoomID.Ref()) + queryParams.Set("sid", h.netInfo.RoomID.String()) queryParams.Set("sc", sc) queryParams.Set("multiserverAddress", h.netInfo.MultiserverAddress()) diff --git a/web/handlers/auth_test.go b/web/handlers/auth_test.go index 92f531c..7997f97 100644 --- a/web/handlers/auth_test.go +++ b/web/handlers/auth_test.go @@ -15,18 +15,18 @@ import ( "testing" "time" + "github.com/ssbc/go-muxrpc/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.cryptoscope.co/muxrpc/v2" "go.mindeco.de/http/auth" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/roomdb" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" ) func TestRestricted(t *testing.T) { @@ -180,7 +180,10 @@ func TestFallbackAuthWorks(t *testing.T) { {"title", "AdminDashboardTitle"}, }) - testRef := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{0}, 32)} + testRef, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{0}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } ts.RoomState.AddEndpoint(testRef, nil) html, resp = ts.Client.GetHTML(dashboardURL) @@ -191,7 +194,10 @@ func TestFallbackAuthWorks(t *testing.T) { {"title", "AdminDashboardTitle"}, }) - testRef2 := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{1}, 32)} + testRef2, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } ts.RoomState.AddEndpoint(testRef2, nil) html, resp = ts.Client.GetHTML(dashboardURL) @@ -216,7 +222,7 @@ func TestAuthWithSSBClientInitNotConnected(t *testing.T) { cc := signinwithssb.GenerateChallenge() signInStartURL := ts.URLTo(router.AuthWithSSBLogin, - "cid", client.Feed.Ref(), + "cid", client.Feed.String(), "cc", cc, ) r.NotNil(signInStartURL) @@ -243,7 +249,7 @@ func TestAuthWithSSBClientInitNotAllowed(t *testing.T) { cc := signinwithssb.GenerateChallenge() signInStartURL := ts.URLTo(router.AuthWithSSBLogin, - "cid", client.Feed.Ref(), + "cid", client.Feed.String(), "cc", cc, ) r.NotNil(signInStartURL) @@ -273,7 +279,7 @@ func TestAuthWithSSBClientAlternativeRoute(t *testing.T) { loginURL := ts.URLTo(router.AuthLogin, "ssb-http-auth", 1, - "cid", client.Feed.Ref(), + "cid", client.Feed.String(), "cc", cc, ) r.NotNil(loginURL) @@ -352,7 +358,7 @@ func TestAuthWithSSBClientInitHasClient(t *testing.T) { // prepare the url signInStartURL := ts.URLTo(router.AuthWithSSBLogin, - "cid", client.Feed.Ref(), + "cid", client.Feed.String(), "cc", cc, ) signInStartURL.Host = "localhost" @@ -375,7 +381,7 @@ func TestAuthWithSSBClientInitHasClient(t *testing.T) { // analyse the endpoints call a.Equal(1, ts.MockedEndpoints.GetEndpointForCallCount()) edpRef := ts.MockedEndpoints.GetEndpointForArgsForCall(0) - a.Equal(client.Feed.Ref(), edpRef.Ref()) + a.Equal(client.Feed.String(), edpRef.String()) // check the mock was called a.Equal(1, edp.AsyncCallCount()) @@ -410,7 +416,7 @@ func TestAuthWithSSBServerInitHappyPath(t *testing.T) { // prepare the url signInStartURL := ts.URLTo(router.AuthWithSSBLogin, - "cid", client.Feed.Ref(), + "cid", client.Feed.String(), ) r.NotNil(signInStartURL) @@ -444,7 +450,7 @@ func TestAuthWithSSBServerInitHappyPath(t *testing.T) { qry := parsedURI.Query() a.Equal("start-http-auth", qry.Get("action")) a.Equal(serverChallenge, qry.Get("sc")) - a.Equal(ts.NetworkInfo.RoomID.Ref(), qry.Get("sid")) + a.Equal(ts.NetworkInfo.RoomID.String(), qry.Get("sid")) a.Equal(ts.NetworkInfo.MultiserverAddress(), qry.Get("multiserverAddress")) qrCode, has := html.Find("#start-auth-qrcode").Attr("src") @@ -511,7 +517,7 @@ func TestAuthWithSSBServerInitWrongSolution(t *testing.T) { // prepare the url signInStartURL := ts.URLTo(router.AuthWithSSBLogin, - "cid", client.Feed.Ref(), + "cid", client.Feed.String(), ) r.NotNil(signInStartURL) @@ -572,7 +578,7 @@ func TestAuthWithSSBServerOnAndroidChrome(t *testing.T) { // prepare the url signInStartURL := ts.URLTo(router.AuthWithSSBLogin, - "cid", client.Feed.Ref(), + "cid", client.Feed.String(), ) r.NotNil(signInStartURL) diff --git a/web/handlers/basic_test.go b/web/handlers/basic_test.go index 71b601e..11431cd 100644 --- a/web/handlers/basic_test.go +++ b/web/handlers/basic_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" ) func TestIndex(t *testing.T) { diff --git a/web/handlers/http.go b/web/handlers/http.go index 1109af0..ab93ce7 100644 --- a/web/handlers/http.go +++ b/web/handlers/http.go @@ -20,18 +20,18 @@ import ( "go.mindeco.de/log/level" "go.mindeco.de/logging" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrs "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/handlers/admin" - roomsAuth "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/handlers/auth" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomstate" + "github.com/ssbc/go-ssb-room/v2/web" + weberrs "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/handlers/admin" + roomsAuth "github.com/ssbc/go-ssb-room/v2/web/handlers/auth" + "github.com/ssbc/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/web/members" + "github.com/ssbc/go-ssb-room/v2/web/router" ) var HTMLTemplates = []string{ diff --git a/web/handlers/invites.go b/web/handlers/invites.go index 6e43724..edc34ca 100644 --- a/web/handlers/invites.go +++ b/web/handlers/invites.go @@ -20,12 +20,12 @@ import ( "go.mindeco.de/log/level" "go.mindeco.de/logging" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/router" ) type inviteHandler struct { @@ -237,7 +237,7 @@ func (h inviteHandler) consume(rw http.ResponseWriter, req *http.Request) { resp.SendError(err) return } - newMember = *parsedID + newMember = parsedID default: http.Error(rw, fmt.Sprintf("unhandled Content-Type (%q)", ct), http.StatusBadRequest) return @@ -261,7 +261,7 @@ func (h inviteHandler) consume(rw http.ResponseWriter, req *http.Request) { return } log := logging.FromContext(req.Context()) - level.Info(log).Log("event", "invite consumed", "id", inv.ID, "ref", newMember.ShortRef()) + level.Info(log).Log("event", "invite consumed", "id", inv.ID, "ref", newMember.ShortSigil()) resp.SendSuccess() } diff --git a/web/handlers/invites_test.go b/web/handlers/invites_test.go index 0c02a90..71d03e5 100644 --- a/web/handlers/invites_test.go +++ b/web/handlers/invites_test.go @@ -16,11 +16,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/roomdb" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" ) func TestInviteShowAcceptForm(t *testing.T) { @@ -38,7 +38,7 @@ func TestInviteShowAcceptForm(t *testing.T) { // request the form doc, resp := ts.Client.GetHTML(acceptURL404) - // 500 until https://github.com/ssb-ngi-pointer/go-ssb-room/issues/66 is fixed + // 500 until https://github.com/ssbc/go-ssb-room/issues/66 is fixed a.Equal(http.StatusInternalServerError, resp.Code) // check database calls @@ -197,13 +197,13 @@ func TestInviteConsumeInviteHTTP(t *testing.T) { a.True(has, "should have value attribute") // create the consume request - testNewMember := refs.FeedRef{ - ID: bytes.Repeat([]byte{1}, 32), - Algo: refs.RefAlgoFeedSSB1, + testNewMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) } consumeVals := url.Values{ "invite": []string{testToken}, - "id": []string{testNewMember.Ref()}, + "id": []string{testNewMember.String()}, csrfName: []string{csrfValue}, } @@ -227,7 +227,7 @@ func TestInviteConsumeInviteHTTP(t *testing.T) { r.EqualValues(1, ts.InvitesDB.ConsumeCallCount()) _, tokenFromArg, newMemberRef := ts.InvitesDB.ConsumeArgsForCall(0) a.Equal(testToken, tokenFromArg) - a.True(newMemberRef.Equal(&testNewMember)) + a.True(newMemberRef.Equal(testNewMember)) } func TestInviteConsumeInviteJSON(t *testing.T) { @@ -266,9 +266,9 @@ func TestInviteConsumeInviteJSON(t *testing.T) { a.Equal(testToken, reply.Invite, "wrong invite token") // create the consume request - testNewMember := refs.FeedRef{ - ID: bytes.Repeat([]byte{1}, 32), - Algo: refs.RefAlgoFeedSSB1, + testNewMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) } var consume inviteConsumePayload consume.Invite = testToken @@ -285,7 +285,7 @@ func TestInviteConsumeInviteJSON(t *testing.T) { r.EqualValues(1, ts.InvitesDB.ConsumeCallCount()) _, tokenFromArg, newMemberRef := ts.InvitesDB.ConsumeArgsForCall(0) a.Equal(testToken, tokenFromArg) - a.True(newMemberRef.Equal(&testNewMember)) + a.True(newMemberRef.Equal(testNewMember)) var jsonConsumeResp inviteConsumeJSONResponse err = json.NewDecoder(resp.Body).Decode(&jsonConsumeResp) @@ -312,9 +312,9 @@ func TestInviteConsumptionDenied(t *testing.T) { ts.DeniedKeysDB.HasFeedReturns(true) // create the consume request - testNewMember := refs.FeedRef{ - ID: bytes.Repeat([]byte{1}, 32), - Algo: refs.RefAlgoFeedSSB1, + testNewMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) } var consume inviteConsumePayload @@ -333,7 +333,7 @@ func TestInviteConsumptionDenied(t *testing.T) { // decode the json response var jsonConsumeResp inviteConsumeJSONResponse - err := json.NewDecoder(resp.Body).Decode(&jsonConsumeResp) + err = json.NewDecoder(resp.Body).Decode(&jsonConsumeResp) r.NoError(err) // json response should indicate an error for the denied key diff --git a/web/handlers/members_password.go b/web/handlers/members_password.go index ed26132..b121249 100644 --- a/web/handlers/members_password.go +++ b/web/handlers/members_password.go @@ -13,11 +13,11 @@ import ( hibp "github.com/mattevans/pwned-passwords" "go.mindeco.de/http/render" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - weberrs "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web" + weberrs "github.com/ssbc/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/web/members" + "github.com/ssbc/go-ssb-room/v2/web/router" ) type membersHandler struct { diff --git a/web/handlers/members_password_test.go b/web/handlers/members_password_test.go index af2f798..c63eff0 100644 --- a/web/handlers/members_password_test.go +++ b/web/handlers/members_password_test.go @@ -11,9 +11,9 @@ import ( "github.com/stretchr/testify/assert" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" ) func TestLoginAndChangePassword(t *testing.T) { diff --git a/web/handlers/notices.go b/web/handlers/notices.go index a56d491..ac22925 100644 --- a/web/handlers/notices.go +++ b/web/handlers/notices.go @@ -11,8 +11,8 @@ import ( "github.com/russross/blackfriday/v2" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/errors" ) type noticeHandler struct { diff --git a/web/handlers/notices_test.go b/web/handlers/notices_test.go index 3521533..0db8c04 100644 --- a/web/handlers/notices_test.go +++ b/web/handlers/notices_test.go @@ -9,9 +9,9 @@ import ( "net/url" "testing" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/webassert" "github.com/stretchr/testify/assert" ) diff --git a/web/handlers/set_language_test.go b/web/handlers/set_language_test.go index 3480a26..87d6897 100644 --- a/web/handlers/set_language_test.go +++ b/web/handlers/set_language_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" + "github.com/ssbc/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/web/router" ) func TestLanguageDefaultNoCookie(t *testing.T) { diff --git a/web/handlers/setup_test.go b/web/handlers/setup_test.go index cd323ff..6563e9c 100644 --- a/web/handlers/setup_test.go +++ b/web/handlers/setup_test.go @@ -15,17 +15,17 @@ import ( "go.mindeco.de/http/tester" "go.mindeco.de/logging/logtest" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network/mocked" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n/i18ntesting" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/network/mocked" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb" + "github.com/ssbc/go-ssb-room/v2/roomstate" + "github.com/ssbc/go-ssb-room/v2/web" + "github.com/ssbc/go-ssb-room/v2/web/i18n/i18ntesting" + "github.com/ssbc/go-ssb-room/v2/web/router" ) type testSession struct { @@ -86,16 +86,16 @@ func setup(t *testing.T) *testSession { ts.MockedEndpoints = new(mocked.FakeEndpoints) + roomID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("test"), 8), refs.RefAlgoFeedSSB1) + if err != nil { + t.Error(err) + } + ts.NetworkInfo = network.ServerEndpointDetails{ - Domain: "localhost", - PortHTTPS: 443, - + Domain: "localhost", + PortHTTPS: 443, ListenAddressMUXRPC: ":8008", - - RoomID: refs.FeedRef{ - ID: bytes.Repeat([]byte("test"), 8), - Algo: refs.RefAlgoFeedSSB1, - }, + RoomID: roomID, } log, _ := logtest.KitLogger("complete", t) diff --git a/web/i18n/dev.go b/web/i18n/dev.go index 1c55e6a..d7cfdb1 100644 --- a/web/i18n/dev.go +++ b/web/i18n/dev.go @@ -17,6 +17,6 @@ import ( var Defaults fs.FS = os.DirFS(defaultsPath) var ( - pkgDir = goutils.MustLocatePackage("github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n") + pkgDir = goutils.MustLocatePackage("github.com/ssbc/go-ssb-room/v2/web/i18n") defaultsPath = filepath.Join(pkgDir, "defaults") ) diff --git a/web/i18n/helper.go b/web/i18n/helper.go index eceae65..ebf1607 100644 --- a/web/i18n/helper.go +++ b/web/i18n/helper.go @@ -20,12 +20,12 @@ import ( "github.com/BurntSushi/toml" "github.com/gorilla/sessions" "github.com/nicksnyder/go-i18n/v2/i18n" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web" + "github.com/ssbc/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/web" "go.mindeco.de/http/render" "golang.org/x/text/language" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/internal/repo" ) const LanguageCookieName = "gossbroom-language" diff --git a/web/i18n/i18ntesting/i18n_helper_test.go b/web/i18n/i18ntesting/i18n_helper_test.go index 5ea6b94..d0e4a5b 100644 --- a/web/i18n/i18ntesting/i18n_helper_test.go +++ b/web/i18n/i18ntesting/i18n_helper_test.go @@ -10,9 +10,9 @@ import ( "github.com/stretchr/testify/assert" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb" + "github.com/ssbc/go-ssb-room/v2/web/i18n" ) func TestListLanguages(t *testing.T) { diff --git a/web/i18n/i18ntesting/testing.go b/web/i18n/i18ntesting/testing.go index e0f7975..1cc09d1 100644 --- a/web/i18n/i18ntesting/testing.go +++ b/web/i18n/i18ntesting/testing.go @@ -14,8 +14,8 @@ import ( "github.com/BurntSushi/toml" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/web/i18n" ) // justTheKeys auto generates from the defaults a list of Label = "Label" diff --git a/web/members/helper.go b/web/members/helper.go index 8b6e6bb..a376d42 100644 --- a/web/members/helper.go +++ b/web/members/helper.go @@ -13,9 +13,9 @@ import ( "go.mindeco.de/http/auth" "go.mindeco.de/http/render" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" - authWithSSB "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/handlers/auth" + "github.com/ssbc/go-ssb-room/v2/roomdb" + weberrors "github.com/ssbc/go-ssb-room/v2/web/errors" + authWithSSB "github.com/ssbc/go-ssb-room/v2/web/handlers/auth" ) type roomMemberContextKeyType string diff --git a/web/members/testing.go b/web/members/testing.go index 074a413..e326966 100644 --- a/web/members/testing.go +++ b/web/members/testing.go @@ -8,7 +8,7 @@ import ( "context" "net/http" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) // MiddlewareForTests gives us a way to inject _test members_. It should not be used in production. diff --git a/web/templates/admin/aliases-revoke-confirm.tmpl b/web/templates/admin/aliases-revoke-confirm.tmpl index 934c48a..de6501b 100644 --- a/web/templates/admin/aliases-revoke-confirm.tmpl +++ b/web/templates/admin/aliases-revoke-confirm.tmpl @@ -16,7 +16,7 @@ SPDX-License-Identifier: CC-BY-4.0
{{.Entry.Feed.Ref}}
+ >{{.Entry.Feed.String}}
{{ .csrfField }} @@ -34,4 +34,4 @@ SPDX-License-Identifier: CC-BY-4.0
-{{end}} \ No newline at end of file +{{end}} diff --git a/web/templates/admin/denied-keys-remove-confirm.tmpl b/web/templates/admin/denied-keys-remove-confirm.tmpl index 530fbf5..0811187 100644 --- a/web/templates/admin/denied-keys-remove-confirm.tmpl +++ b/web/templates/admin/denied-keys-remove-confirm.tmpl @@ -16,7 +16,7 @@ SPDX-License-Identifier: CC-BY-4.0
{{.Entry.PubKey.Ref}}
+ >{{.Entry.PubKey.String}}
{{human_time .Entry.CreatedAt}} @@ -45,4 +45,4 @@ SPDX-License-Identifier: CC-BY-4.0
-{{end}} \ No newline at end of file +{{end}} diff --git a/web/templates/admin/denied-keys.tmpl b/web/templates/admin/denied-keys.tmpl index 5c0126d..be9d990 100644 --- a/web/templates/admin/denied-keys.tmpl +++ b/web/templates/admin/denied-keys.tmpl @@ -61,7 +61,7 @@ SPDX-License-Identifier: CC-BY-4.0
  • {{.PubKey.Ref}} + >{{.PubKey.String}} {{range .Entries}} {{ $user := is_logged_in }} - {{$hasCreatedInvite := eq $user.PubKey.Ref .CreatedBy.PubKey.Ref }} - {{$creator := .CreatedBy.PubKey.Ref}} + {{$hasCreatedInvite := eq $user.PubKey.String .CreatedBy.PubKey.String }} + {{$creator := .CreatedBy.PubKey.String }} {{$creatorIsAlias := false}} {{range $index, $alias := .CreatedBy.Aliases}} {{if eq $index 0}} diff --git a/web/templates/admin/invite-revoke-confirm.tmpl b/web/templates/admin/invite-revoke-confirm.tmpl index dbbf43d..4b116e6 100644 --- a/web/templates/admin/invite-revoke-confirm.tmpl +++ b/web/templates/admin/invite-revoke-confirm.tmpl @@ -13,7 +13,7 @@ SPDX-License-Identifier: CC-BY-4.0 class="text-center" >{{i18n "AdminInviteRevokeConfirmWelcome"}} - {{$creator := .Invite.CreatedBy.PubKey.Ref}} + {{$creator := .Invite.CreatedBy.PubKey.String}} {{range $index, $alias := .Invite.CreatedBy.Aliases}} {{if eq $index 0}} {{$creator = $alias.Name}} @@ -39,4 +39,4 @@ SPDX-License-Identifier: CC-BY-4.0 -{{end}} \ No newline at end of file +{{end}} diff --git a/web/templates/admin/member-list.tmpl b/web/templates/admin/member-list.tmpl index 757a30b..91bfe5e 100644 --- a/web/templates/admin/member-list.tmpl +++ b/web/templates/admin/member-list.tmpl @@ -49,7 +49,7 @@ SPDX-License-Identifier: CC-BY-4.0
  • - {{$member.PubKey.Ref}} + {{$member.PubKey.String}}
    {{if eq .ID $self.ID}} diff --git a/web/templates/admin/member.tmpl b/web/templates/admin/member.tmpl index a9fe464..330533f 100644 --- a/web/templates/admin/member.tmpl +++ b/web/templates/admin/member.tmpl @@ -11,11 +11,11 @@ SPDX-License-Identifier: CC-BY-4.0 >{{i18n "AdminMemberDetailsTitle"}} -

    {{.Member.PubKey.Ref}}

    +

    {{.Member.PubKey.String}}

    {{ $user := is_logged_in }} - {{ $viewerIsSameAsMember := eq $user.PubKey.Ref .Member.PubKey.Ref }} + {{ $viewerIsSameAsMember := eq $user.PubKey.String .Member.PubKey.String }} {{ if member_is_elevated }}
    diff --git a/web/templates/admin/members-remove-confirm.tmpl b/web/templates/admin/members-remove-confirm.tmpl index af8896f..4bf76bd 100644 --- a/web/templates/admin/members-remove-confirm.tmpl +++ b/web/templates/admin/members-remove-confirm.tmpl @@ -16,7 +16,7 @@ SPDX-License-Identifier: CC-BY-4.0
    {{.Entry.PubKey.Ref}}
    + >{{.Entry.PubKey.String}}
    {{ .csrfField }} @@ -34,4 +34,4 @@ SPDX-License-Identifier: CC-BY-4.0
    -{{end}} \ No newline at end of file +{{end}} diff --git a/web/templates/base.tmpl b/web/templates/base.tmpl index a91f49d..ae91246 100644 --- a/web/templates/base.tmpl +++ b/web/templates/base.tmpl @@ -42,7 +42,7 @@ SPDX-License-Identifier: CC-BY-4.0
    -
    {{$user.PubKey.Ref}}
    +
    {{$user.PubKey.String}}
    diff --git a/web/utils.go b/web/utils.go index c778aad..3375016 100644 --- a/web/utils.go +++ b/web/utils.go @@ -22,10 +22,10 @@ import ( "go.mindeco.de/log/level" "go.mindeco.de/logging" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" - "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" - refs "go.mindeco.de/ssb-refs" + refs "github.com/ssbc/go-ssb-refs" + "github.com/ssbc/go-ssb-room/v2/internal/network" + "github.com/ssbc/go-ssb-room/v2/internal/repo" + "github.com/ssbc/go-ssb-room/v2/roomdb" ) // TemplateFuncs returns a map of template functions @@ -51,8 +51,8 @@ func NewURLTo(appRouter *mux.Router, netInfo network.ServerEndpointDetails) URLM return func(routeName string, ps ...interface{}) *url.URL { route := appRouter.Get(routeName) if route == nil { - // TODO: https://github.com/ssb-ngi-pointer/go-ssb-room/issues/35 for a - // for reference, see https://github.com/ssb-ngi-pointer/go-ssb-room/pull/64 + // TODO: https://github.com/ssbc/go-ssb-room/issues/35 for a + // for reference, see https://github.com/ssbc/go-ssb-room/pull/64 // level.Warn(l).Log("msg", "no such route", "route", routeName, "params", fmt.Sprintf("%v", ps)) return &url.URL{} } @@ -72,7 +72,7 @@ func NewURLTo(appRouter *mux.Router, netInfo network.ServerEndpointDetails) URLM case int64: params = append(params, strconv.FormatInt(v, 10)) case refs.FeedRef: - params = append(params, v.Ref()) + params = append(params, v.String()) case roomdb.PinnedNoticeName: params = append(params, string(v)) default: @@ -202,7 +202,7 @@ func StringifySSBURI(uri *url.URL, userAgent string) string { browser := ua.Parse(userAgent) // Special treatment for Android Chrome for issue #135 - // https://github.com/ssb-ngi-pointer/go-ssb-room/issues/135 + // https://github.com/ssbc/go-ssb-room/issues/135 if browser.IsAndroid() && browser.IsChrome() { href := url.URL{ Scheme: "intent",