BYOK Personal Data Server (PDS) written in Go
ipfs vow atproto pds go
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: simplify handling

+22 -19
+2 -1
docker-compose.yaml
··· 29 29 IPFS_PROFILE: server 30 30 ports: 31 31 # Expose the IPFS gateway to the reverse proxy only. 32 - - "127.0.0.1:8081:8080" 32 + - 8081:8080 33 33 # Keep the RPC API internal. 34 + - 5001:5001 34 35 restart: unless-stopped 35 36 healthcheck: 36 37 test: ["CMD", "ipfs", "id"]
+4 -10
server/blockstore_factory.go
··· 1 1 package server 2 2 3 3 import ( 4 - "net/http" 5 - 6 4 "github.com/ipfs/kubo/client/rpc" 7 5 vowblockstore "pkg.rbrt.fr/vow/blockstore" 8 6 ) 9 7 10 8 // newBlockstoreForRepo returns the blockstore for a DID. 11 - func newBlockstoreForRepo(did string, ipfsCfg *IPFSConfig) *vowblockstore.IPFSBlockstore { 12 - cli, err := rpc.NewURLApiWithClient(ipfsCfg.NodeURL, http.DefaultClient) 13 - if err != nil { 14 - panic(err) 15 - } 16 - return vowblockstore.NewIPFS(did, cli) 9 + func newBlockstoreForRepo(did string, ipfsAPI *rpc.HttpApi) *vowblockstore.IPFSBlockstore { 10 + return vowblockstore.NewIPFS(did, ipfsAPI) 17 11 } 18 12 19 13 // newRecordingBlockstoreForRepo adds read/write logging. 20 - func newRecordingBlockstoreForRepo(did string, ipfsCfg *IPFSConfig) (*vowblockstore.RecordingBlockstore, *vowblockstore.IPFSBlockstore) { 21 - base := newBlockstoreForRepo(did, ipfsCfg) 14 + func newRecordingBlockstoreForRepo(did string, ipfsAPI *rpc.HttpApi) (*vowblockstore.RecordingBlockstore, *vowblockstore.IPFSBlockstore) { 15 + base := newBlockstoreForRepo(did, ipfsAPI) 22 16 return vowblockstore.NewRecording(base), base 23 17 }
+1 -1
server/handle_account_signup.go
··· 184 184 return 185 185 } 186 186 187 - bs := newBlockstoreForRepo(did, s.ipfsConfig) 187 + bs := newBlockstoreForRepo(did, s.ipfsAPI) 188 188 189 189 clk := syntax.NewTIDClock(0) 190 190 repo := &atp.Repo{
+1 -1
server/handle_import_repo.go
··· 28 28 return 29 29 } 30 30 31 - bs := newBlockstoreForRepo(urepo.Repo.Did, s.ipfsConfig) 31 + bs := newBlockstoreForRepo(urepo.Repo.Did, s.ipfsAPI) 32 32 33 33 cs, err := car.NewCarReader(bytes.NewReader(b)) 34 34 if err != nil {
+1 -1
server/handle_server_create_account.go
··· 222 222 } 223 223 224 224 if request.Did == nil || *request.Did == "" { 225 - bs := newBlockstoreForRepo(signupDid, s.ipfsConfig) 225 + bs := newBlockstoreForRepo(signupDid, s.ipfsAPI) 226 226 227 227 clk := syntax.NewTIDClock(0) 228 228 r := &atp.Repo{
+1 -1
server/handle_sync_get_blocks.go
··· 71 71 return 72 72 } 73 73 74 - bs := newBlockstoreForRepo(urepo.Repo.Did, s.ipfsConfig) 74 + bs := newBlockstoreForRepo(urepo.Repo.Did, s.ipfsAPI) 75 75 76 76 for _, c := range cids { 77 77 b, err := bs.Get(ctx, c)
+1 -1
server/handle_sync_get_repo.go
··· 55 55 return 56 56 } 57 57 58 - bs := newBlockstoreForRepo(urepo.Repo.Did, s.ipfsConfig) 58 + bs := newBlockstoreForRepo(urepo.Repo.Did, s.ipfsAPI) 59 59 if err := writeRepoBlocksFromBlockstore(ctx, buf, bs, rc); err != nil { 60 60 logger.Error("error writing repo blocks to car", "error", err) 61 61 helpers.ServerError(w, nil)
+3 -3
server/repo.go
··· 352 352 return nil, err 353 353 } 354 354 355 - bs, baseBS := newRecordingBlockstoreForRepo(urepo.Did, rm.s.ipfsConfig) 355 + bs, baseBS := newRecordingBlockstoreForRepo(urepo.Did, rm.s.ipfsAPI) 356 356 // dbs is the unwrapped base blockstore used for direct reads when building 357 357 // the firehose CAR slice. 358 358 dbs := baseBS ··· 623 623 sigBytes []byte, 624 624 dbs blockstore.Blockstore, 625 625 ) ([]ApplyWriteResult, error) { 626 - bs, _ := newRecordingBlockstoreForRepo(urepo.Did, rm.s.ipfsConfig) 626 + bs, _ := newRecordingBlockstoreForRepo(urepo.Did, rm.s.ipfsAPI) 627 627 628 628 // Replay the write log blocks into the fresh blockstore so finaliseCommit 629 629 // can locate them when building the CAR. ··· 790 790 var proofBlocks []blocks.Block 791 791 var recordCid *cid.Cid 792 792 793 - dbs := newBlockstoreForRepo(urepo.Did, rm.s.ipfsConfig) 793 + dbs := newBlockstoreForRepo(urepo.Did, rm.s.ipfsAPI) 794 794 795 795 if err := rm.withRepo(ctx, urepo.Did, commitCid, dbs, func(r *atp.Repo) (cid.Cid, error) { 796 796 path := collection + "/" + rkey
+8
server/server.go
··· 30 30 "github.com/go-playground/validator" 31 31 "github.com/gorilla/sessions" 32 32 "github.com/ipfs/go-cid" 33 + "github.com/ipfs/kubo/client/rpc" 33 34 "github.com/prometheus/client_golang/prometheus/promhttp" 34 35 "pkg.rbrt.fr/vow/identity" 35 36 "pkg.rbrt.fr/vow/internal/db" ··· 93 94 94 95 dbName string 95 96 ipfsConfig *IPFSConfig 97 + ipfsAPI *rpc.HttpApi 96 98 } 97 99 98 100 type Args struct { ··· 392 394 return nil, fmt.Errorf("failed to create event persister: %w", err) 393 395 } 394 396 397 + ipfsAPI, err := rpc.NewURLApiWithClient(args.IPFSConfig.NodeURL, nil) 398 + if err != nil { 399 + return nil, fmt.Errorf("failed to create IPFS client: %w", err) 400 + } 401 + 395 402 cookieStore := sessions.NewCookieStore([]byte(args.SessionSecret)) 396 403 397 404 s := &Server{ ··· 425 432 426 433 dbName: args.DbName, 427 434 ipfsConfig: args.IPFSConfig, 435 + ipfsAPI: ipfsAPI, 428 436 429 437 oauthProvider: provider.NewProvider(provider.Args{ 430 438 Hostname: args.Hostname,