summaryrefslogtreecommitdiff
path: root/desk/sur/nostr.hoon
blob: ff5ad6bcc12ed5e52a946c7f7e08c7ba2f172125 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|%
+$  keys  [pub=@ priv=@]
+$  event
$:  id=@ux           :: 32bytes
    pubkey=@ux       ::  32bytes
    created-at=@ud   :: seconds
    kind=@ud
    tags=(list tag)
    content=@t
    sig=@ux          ::  64bytes
==
+$  raw-event
$:  pubkey=@ux       ::  32bytes
    created-at=@ud   :: seconds
    kind=@ud
    tags=(list tag)
    content=@t
==
+$  tag  (list @t)
:: $:  key=@t
::     value=@t
::     rest=(list @t)
:: ==
+$  user-meta  :: NIP-1
$:  name=@t
    about=@t
    picture=@t
    other=(map @t json)
==
+$  relay-stats
$:  connected=(unit @da)
    reqs=(map sub-id event-stats)
==
+$  event-stats
  [filters=(list filter) received=event-count]
+$  sub-id  @t
+$  event-count  @ud

+$  relay-req
$:  sub-id=@t
    filters=(list filter)
==
::  Relay comms
+$  filter
$:  ids=(unit (set @ux))
    authors=(unit (set @ux))
    kinds=(unit (set @ud))
    tags=(unit (map @t (set @t)))
    since=(unit @da)
    until=(unit @da)
    limit=(unit @ud)
==
:: messages from relay
++  relay-msg
$%  [%event sub-id=@t =event]
    [%ok id=@ux accepted=? msg=@t]
    [%eose sub-id=@t]
    [%closed sub-id=@t msg=@t]
    [%notice msg=@t]
    [%auth challenge=@t]
    :: from our shim
    [%error msg=@t]
==
++  shim
  |%
  ++  url  'http://localhost:8888/shim'
  +$  req
  $%  [%req relay-req]
      [%event =event]
      [%auth =event]
      [%close sub-id=@t]
  ==
  +$  bulk-req  [relays=(list @t) =req]
  +$  http-req  [relay=@t delay=@ud sub-id=@t filters=(list filter)]
  +$  res  $%([%http p=(list relay-msg)] [%ws relay=@t msg=relay-msg])
  --

:: https://github.com/sesseor/nostr-relays-list/blob/main/relays.txt
++  public-relays  ^-  (list @t)
  :~  'wss://nos.lol'
      :: 'wss://relay.damus.io'
      :: 'wss://nostr.wine'
      :: 'wss://offchain.pub'
  ==
      :: 'wss://knostr.neutrine.com'
--
:: event: {
::     content: "😂",
::     created_at: 1758049319,
::     id: "36c8a0bb6a9a1ff3ca3e6868fdf2c055a09aea39b1c078b75c38f5a7b580da87",
::     kind: 7,
::     pubkey: "26d6a946675e603f8de4bf6f9cef442037b70c7eee170ff06ed7673fc34c98f1",
::     sig: "7b5a9c799776935f959eccfd311af6152db6a1360296c9790b35544d0b83a8d75f8937ad1ad6f5da3e0d3e2bdb1bfb92686adbde42c3ef53ca06771080d08153",
::     tags: [
::       [ "e", "091d00811bb9a57088ab7c1d39697b0ed9bbbe05dae135b406f3560290fba311",
::         "wss://relay.nostr.band/", "root", "26d6a946675e603f8de4bf6f9cef442037b70c7eee170ff06ed7673fc34c98f1"
::       ], [ "e", "1cd926b58a1bac70adcedf38212d72ee1380e17dad1aef6bbc18782c5c540236",
::         "wss://relay.nostr.band/", "reply", "3252715543f6e43be086465129b030d47d76cf8cead4798e48864563c3375083"
::       ], [ "p", "26d6a946675e603f8de4bf6f9cef442037b70c7eee170ff06ed7673fc34c98f1",
::         "wss://nostr.bitcoiner.social/"
::       ], [ "p", "3252715543f6e43be086465129b030d47d76cf8cead4798e48864563c3375083",
::         "ws://relay.snort.social/"
::       ], [ "e", "b9a0c3b28a291d80bcb41ee730f2c48366fd2fefba0e68f9fb928bb9ca96f757" ], [ "p", "3252715543f6e43be086465129b030d47d76cf8cead4798e48864563c3375083" ]
::     ],
::   },