-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
wot.go
316 lines (285 loc) · 9.29 KB
/
wot.go
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/wot.avdl
package keybase1
import (
"fmt"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
"time"
)
type UsernameVerificationType string
func (o UsernameVerificationType) DeepCopy() UsernameVerificationType {
return o
}
type WotProof struct {
ProofType ProofType `codec:"proofType" json:"proof_type"`
Name string `codec:"name" json:"name,omitempty"`
Username string `codec:"username" json:"username,omitempty"`
Protocol string `codec:"protocol" json:"protocol,omitempty"`
Hostname string `codec:"hostname" json:"hostname,omitempty"`
Domain string `codec:"domain" json:"domain,omitempty"`
}
func (o WotProof) DeepCopy() WotProof {
return WotProof{
ProofType: o.ProofType.DeepCopy(),
Name: o.Name,
Username: o.Username,
Protocol: o.Protocol,
Hostname: o.Hostname,
Domain: o.Domain,
}
}
type WotProofUI struct {
Type string `codec:"type" json:"type"`
Value string `codec:"value" json:"value"`
SiteIcon []SizedImage `codec:"siteIcon" json:"siteIcon"`
SiteIconDarkmode []SizedImage `codec:"siteIconDarkmode" json:"siteIconDarkmode"`
}
func (o WotProofUI) DeepCopy() WotProofUI {
return WotProofUI{
Type: o.Type,
Value: o.Value,
SiteIcon: (func(x []SizedImage) []SizedImage {
if x == nil {
return nil
}
ret := make([]SizedImage, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.SiteIcon),
SiteIconDarkmode: (func(x []SizedImage) []SizedImage {
if x == nil {
return nil
}
ret := make([]SizedImage, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.SiteIconDarkmode),
}
}
type Confidence struct {
UsernameVerifiedVia UsernameVerificationType `codec:"usernameVerifiedVia" json:"username_verified_via,omitempty"`
Proofs []WotProof `codec:"proofs" json:"proofs,omitempty"`
Other string `codec:"other" json:"other,omitempty"`
}
func (o Confidence) DeepCopy() Confidence {
return Confidence{
UsernameVerifiedVia: o.UsernameVerifiedVia.DeepCopy(),
Proofs: (func(x []WotProof) []WotProof {
if x == nil {
return nil
}
ret := make([]WotProof, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Proofs),
Other: o.Other,
}
}
type WotReactionType int
const (
WotReactionType_REJECT WotReactionType = 0
WotReactionType_ACCEPT WotReactionType = 1
)
func (o WotReactionType) DeepCopy() WotReactionType { return o }
var WotReactionTypeMap = map[string]WotReactionType{
"REJECT": 0,
"ACCEPT": 1,
}
var WotReactionTypeRevMap = map[WotReactionType]string{
0: "REJECT",
1: "ACCEPT",
}
func (e WotReactionType) String() string {
if v, ok := WotReactionTypeRevMap[e]; ok {
return v
}
return fmt.Sprintf("%v", int(e))
}
type WotVouch struct {
Status WotStatusType `codec:"status" json:"status"`
VouchProof SigID `codec:"vouchProof" json:"vouchProof"`
Vouchee UserVersion `codec:"vouchee" json:"vouchee"`
VoucheeUsername string `codec:"voucheeUsername" json:"voucheeUsername"`
Voucher UserVersion `codec:"voucher" json:"voucher"`
VoucherUsername string `codec:"voucherUsername" json:"voucherUsername"`
VouchText string `codec:"vouchText" json:"vouchText"`
VouchedAt Time `codec:"vouchedAt" json:"vouchedAt"`
Confidence Confidence `codec:"confidence" json:"confidence"`
Proofs []WotProofUI `codec:"proofs" json:"proofs"`
}
func (o WotVouch) DeepCopy() WotVouch {
return WotVouch{
Status: o.Status.DeepCopy(),
VouchProof: o.VouchProof.DeepCopy(),
Vouchee: o.Vouchee.DeepCopy(),
VoucheeUsername: o.VoucheeUsername,
Voucher: o.Voucher.DeepCopy(),
VoucherUsername: o.VoucherUsername,
VouchText: o.VouchText,
VouchedAt: o.VouchedAt.DeepCopy(),
Confidence: o.Confidence.DeepCopy(),
Proofs: (func(x []WotProofUI) []WotProofUI {
if x == nil {
return nil
}
ret := make([]WotProofUI, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Proofs),
}
}
type WotVouchArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Username string `codec:"username" json:"username"`
GuiID Identify3GUIID `codec:"guiID" json:"guiID"`
VouchText string `codec:"vouchText" json:"vouchText"`
Confidence Confidence `codec:"confidence" json:"confidence"`
}
type WotVouchCLIArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Assertion string `codec:"assertion" json:"assertion"`
VouchText string `codec:"vouchText" json:"vouchText"`
Confidence Confidence `codec:"confidence" json:"confidence"`
}
type WotReactArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Voucher string `codec:"voucher" json:"voucher"`
SigID SigID `codec:"sigID" json:"sigID"`
Reaction WotReactionType `codec:"reaction" json:"reaction"`
AllowEmptySigID bool `codec:"allowEmptySigID" json:"allowEmptySigID"`
}
type DismissWotNotificationsArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Voucher string `codec:"voucher" json:"voucher"`
Vouchee string `codec:"vouchee" json:"vouchee"`
}
type WotFetchVouchesArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Vouchee string `codec:"vouchee" json:"vouchee"`
Voucher string `codec:"voucher" json:"voucher"`
}
type WotInterface interface {
WotVouch(context.Context, WotVouchArg) error
WotVouchCLI(context.Context, WotVouchCLIArg) error
WotReact(context.Context, WotReactArg) error
DismissWotNotifications(context.Context, DismissWotNotificationsArg) error
WotFetchVouches(context.Context, WotFetchVouchesArg) ([]WotVouch, error)
}
func WotProtocol(i WotInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.wot",
Methods: map[string]rpc.ServeHandlerDescription{
"wotVouch": {
MakeArg: func() interface{} {
var ret [1]WotVouchArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]WotVouchArg)
if !ok {
err = rpc.NewTypeError((*[1]WotVouchArg)(nil), args)
return
}
err = i.WotVouch(ctx, typedArgs[0])
return
},
},
"wotVouchCLI": {
MakeArg: func() interface{} {
var ret [1]WotVouchCLIArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]WotVouchCLIArg)
if !ok {
err = rpc.NewTypeError((*[1]WotVouchCLIArg)(nil), args)
return
}
err = i.WotVouchCLI(ctx, typedArgs[0])
return
},
},
"wotReact": {
MakeArg: func() interface{} {
var ret [1]WotReactArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]WotReactArg)
if !ok {
err = rpc.NewTypeError((*[1]WotReactArg)(nil), args)
return
}
err = i.WotReact(ctx, typedArgs[0])
return
},
},
"dismissWotNotifications": {
MakeArg: func() interface{} {
var ret [1]DismissWotNotificationsArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]DismissWotNotificationsArg)
if !ok {
err = rpc.NewTypeError((*[1]DismissWotNotificationsArg)(nil), args)
return
}
err = i.DismissWotNotifications(ctx, typedArgs[0])
return
},
},
"wotFetchVouches": {
MakeArg: func() interface{} {
var ret [1]WotFetchVouchesArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]WotFetchVouchesArg)
if !ok {
err = rpc.NewTypeError((*[1]WotFetchVouchesArg)(nil), args)
return
}
ret, err = i.WotFetchVouches(ctx, typedArgs[0])
return
},
},
},
}
}
type WotClient struct {
Cli rpc.GenericClient
}
func (c WotClient) WotVouch(ctx context.Context, __arg WotVouchArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.wot.wotVouch", []interface{}{__arg}, nil, 0*time.Millisecond)
return
}
func (c WotClient) WotVouchCLI(ctx context.Context, __arg WotVouchCLIArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.wot.wotVouchCLI", []interface{}{__arg}, nil, 0*time.Millisecond)
return
}
func (c WotClient) WotReact(ctx context.Context, __arg WotReactArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.wot.wotReact", []interface{}{__arg}, nil, 0*time.Millisecond)
return
}
func (c WotClient) DismissWotNotifications(ctx context.Context, __arg DismissWotNotificationsArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.wot.dismissWotNotifications", []interface{}{__arg}, nil, 0*time.Millisecond)
return
}
func (c WotClient) WotFetchVouches(ctx context.Context, __arg WotFetchVouchesArg) (res []WotVouch, err error) {
err = c.Cli.Call(ctx, "keybase.1.wot.wotFetchVouches", []interface{}{__arg}, &res, 0*time.Millisecond)
return
}