Differences From
Artifact [ed1d490f12]:
7 7 };
8 8 notiftype = lib.enum {
9 9 'mention', 'like', 'rt', 'react'
10 10 };
11 11 relation = lib.enum {
12 12 'follow', 'mute', 'block'
13 13 };
14 + credset = lib.set {
15 + 'pw', 'otp', 'challenge', 'trust'
16 + };
14 17 }
15 18
16 -local str = lib.mem.ptr(int8)
17 -str:complete()
19 +local str = rawstring --lib.mem.ptr(int8)
18 20
19 21 struct m.source
20 22
21 23 struct m.rights {
22 24 rank: uint16 -- lower = more powerful except 0 = regular user
23 25 -- creating staff automatically assigns rank immediately below you
24 26 quota: uint32 -- # of allowed tweets per day; 0 = no limit
................................................................................
54 56 struct m.actor {
55 57 id: uint64
56 58 nym: str
57 59 handle: str
58 60 origin: uint64
59 61 bio: str
60 62 rights: m.rights
61 - key: str
63 + key: lib.mem.ptr(uint8)
64 +
65 + xid: str
62 66
63 67 source: &m.source
64 68 }
65 -terra m.actor:free()
66 - self.nym:free()
67 - self.handle:free()
68 - self.bio:free()
69 - self.key:free()
70 -end
71 69
72 70 struct m.range {
73 71 time: bool
74 72 union {
75 73 from_time: m.timepoint
76 74 from_idx: uint64
77 75 }
................................................................................
111 109 kind: m.notiftype.t
112 110 when: uint64
113 111 union {
114 112 post: uint64
115 113 reaction: int8[8]
116 114 }
117 115 }
116 +
117 +struct m.inet {
118 + pv: uint8 -- 0 = null, 4 = ipv4, 6 = ipv6
119 + union {
120 + v4: uint8[4]
121 + v6: uint8[16]
122 + }
123 + union {
124 + fixbits: uint8 -- for cidr
125 + port: uint16 -- for origin
126 + }
127 +}
128 +
129 +terra m.inet:cidr_str()
130 + if self.pv == 4 then
131 + var maxsz = 3*4 + 3 + 1
132 + elseif self.pv == 6 then
133 + var bits = 128
134 + var bytes = bits / 8
135 + var hexchs = bytes * 2
136 + var segs = hexchs / 4
137 + var seps = segs - 1
138 + var maxsz = hexchs + seps + 1
139 + else return nil end
140 +end
141 +
142 +struct m.auth {
143 + aid: uint64
144 + uid: uint64
145 + aname: str
146 + netmask: m.inet
147 + restrict: lib.mem.ptr(rawstring)
148 + blacklist: bool
149 +}
150 +
118 151
119 152 -- backends only handle content on the local server
120 153 struct m.backend { id: rawstring
121 154 open: &m.source -> &opaque
122 155 close: &m.source -> {}
123 156
124 157 conf_get: {&m.source, rawstring} -> lib.mem.ptr(int8)
125 158 conf_set: {&m.source, rawstring, rawstring} -> {}
126 159 conf_reset: {&m.source, rawstring} -> {}
127 160
128 161 actor_save: {&m.source, m.actor} -> bool
129 162 actor_create: {&m.source, m.actor} -> bool
130 - actor_fetch_xid: {&m.source, rawstring} -> lib.stat(m.actor)
131 - actor_fetch_uid: {&m.source, uint64} -> lib.stat(m.actor)
163 + actor_fetch_xid: {&m.source, rawstring} -> lib.mem.ptr(m.actor)
164 + actor_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.actor)
132 165 actor_notif_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.notif)
133 - actor_auth: {&m.source, rawstring, rawstring} -> lib.stat(m.actor)
134 - actor_enum: {&m.source} -> lib.mem.ptr(m.actor)
135 - actor_enum_local: {&m.source} -> lib.mem.ptr(m.actor)
166 + actor_enum: {&m.source} -> lib.mem.ptr(&m.actor)
167 + actor_enum_local: {&m.source} -> lib.mem.ptr(&m.actor)
168 +
169 + actor_auth_how: {&m.source, m.inet, rawstring} -> m.credset
170 + -- returns a set of auth method categories that are available for a
171 + -- given user from a certain origin
172 + -- origin: inet
173 + -- handle: rawstring
174 + actor_auth_otp: {&m.source, m.inet, rawstring, rawstring} -> uint64
175 + actor_auth_pw: {&m.source, m.inet, rawstring, rawstring} -> uint64
176 + -- handles password-based logins against hashed passwords
177 + -- origin: inet
178 + -- handle: rawstring
179 + -- token: rawstring
180 + actor_auth_tls: {&m.source, m.inet, rawstring} -> uint64
181 + -- handles implicit authentication performed as part of an TLS connection
182 + -- origin: inet
183 + -- fingerprint: rawstring
184 + actor_auth_api: {&m.source, m.inet, rawstring, rawstring} -> uint64
185 + -- handles API authentication
186 + -- origin: inet
187 + -- handle: rawstring
188 + -- key: rawstring (X-API-Key)
189 + actor_auth_record_fetch: {&m.source, uint64} -> lib.mem.ptr(m.auth)
136 190
137 191 actor_conf_str: cnf(rawstring, lib.mem.ptr(int8))
138 192 actor_conf_int: cnf(intptr, lib.stat(intptr))
139 193
140 194 post_save: {&m.source, &m.post} -> bool
141 195 post_create: {&m.source, &m.post} -> bool
142 196 actor_post_fetch_uid: {&m.source, uint64, m.range} -> lib.mem.ptr(m.post)