dev vouch dev on at. thats about it atvouch.dev
8
fork

Configure Feed

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

invalidate self-vouches

look i know its funny but its not useful im sorry to be the fun cop

Luna 8a36f6a3 804e03f9

+54 -1
+10 -1
appview/lib/atvouch/tap_handler.ex
··· 93 93 94 94 defp validate_record(event) do 95 95 with :ok <- validate_lexicon(event.record), 96 - :ok <- validate_rkey_matches_subject(event.rkey, event.record["subject"]) do 96 + :ok <- validate_rkey_matches_subject(event.rkey, event.record["subject"]), 97 + :ok <- validate_not_self_vouch(event.did, event.record["subject"]) do 97 98 :ok 98 99 end 99 100 end ··· 102 103 case Atvouch.Lexicons.Vouch.main(record) do 103 104 {:ok, _} -> :ok 104 105 {:error, errors} -> {:error, "lexicon validation failed: #{inspect(errors)}"} 106 + end 107 + end 108 + 109 + defp validate_not_self_vouch(creator_did, subject) do 110 + if creator_did != subject do 111 + :ok 112 + else 113 + {:error, "subject must not be the same as creator did '#{creator_did}'"} 105 114 end 106 115 end 107 116
+44
appview/test/atvouch/tap_handler_test.exs
··· 254 254 # Also no vouch with the subject as rkey 255 255 at_uri2 = "at://#{creator_did}/dev.atvouch.graph.vouch/#{target_did}" 256 256 assert Atvouch.Vouch.one(at_uri2) == nil 257 + 258 + # No identities should have been created either 259 + assert Atvouch.Identity.one(creator_did) == nil 260 + assert Atvouch.Identity.one(target_did) == nil 257 261 end 258 262 259 263 test "rejects record with invalid DID in subject", %{port: port} do ··· 374 378 375 379 # No vouch created 376 380 at_uri = "at://#{creator_did}/dev.atvouch.graph.vouch/some-rkey" 381 + assert Atvouch.Vouch.one(at_uri) == nil 382 + end 383 + 384 + test "rejects record where subject equals creator did (self-vouch)", %{port: port} do 385 + {:ok, _pid} = 386 + Atvouch.Tap.Socket.start_link( 387 + uri: "ws://localhost:#{port}/channel", 388 + handler: Atvouch.TapHandler, 389 + password: "123", 390 + name: :"tap_handler_self_vouch_test_#{port}" 391 + ) 392 + 393 + assert_receive {:ws_connected, ws_pid}, 5_000 394 + 395 + self_did = "did:plc:cpzv5kdrtinsnj5rsblsttz6" 396 + 397 + Atvouch.Test.FakeTapServer.send_event(ws_pid, %{ 398 + "id" => 504, 399 + "type" => "record", 400 + "record" => %{ 401 + "action" => "create", 402 + "did" => self_did, 403 + "rev" => "3mgmqjki6sz2n", 404 + "collection" => "dev.atvouch.graph.vouch", 405 + "rkey" => self_did, 406 + "record" => %{ 407 + "$type" => "dev.atvouch.graph.vouch", 408 + "createdAt" => "2026-03-09T10:53:26.922Z", 409 + "subject" => self_did 410 + }, 411 + "cid" => "bafyreig2uvo5annaomcmrjfrwyshnjannfrr2xje5txnsyuk7l4o2tdmju", 412 + "live" => false 413 + } 414 + }) 415 + 416 + # Should still be ACKed 417 + assert_receive {:ws_message, %{"type" => "ack", "id" => 504}}, 5_000 418 + 419 + # No vouch created 420 + at_uri = "at://#{self_did}/dev.atvouch.graph.vouch/#{self_did}" 377 421 assert Atvouch.Vouch.one(at_uri) == nil 378 422 end 379 423