forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identify.go
373 lines (342 loc) · 12.8 KB
/
identify.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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
// Auto-generated by avdl-compiler v1.3.19 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/identify.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type IdentifyProofBreak struct {
RemoteProof RemoteProof `codec:"remoteProof" json:"remoteProof"`
Lcr LinkCheckResult `codec:"lcr" json:"lcr"`
}
func (o IdentifyProofBreak) DeepCopy() IdentifyProofBreak {
return IdentifyProofBreak{
RemoteProof: o.RemoteProof.DeepCopy(),
Lcr: o.Lcr.DeepCopy(),
}
}
type IdentifyTrackBreaks struct {
Keys []IdentifyKey `codec:"keys" json:"keys"`
Proofs []IdentifyProofBreak `codec:"proofs" json:"proofs"`
}
func (o IdentifyTrackBreaks) DeepCopy() IdentifyTrackBreaks {
return IdentifyTrackBreaks{
Keys: (func(x []IdentifyKey) []IdentifyKey {
var ret []IdentifyKey
for _, v := range x {
vCopy := v.DeepCopy()
ret = append(ret, vCopy)
}
return ret
})(o.Keys),
Proofs: (func(x []IdentifyProofBreak) []IdentifyProofBreak {
var ret []IdentifyProofBreak
for _, v := range x {
vCopy := v.DeepCopy()
ret = append(ret, vCopy)
}
return ret
})(o.Proofs),
}
}
type Identify2Res struct {
Upk UserPlusKeys `codec:"upk" json:"upk"`
IdentifiedAt Time `codec:"identifiedAt" json:"identifiedAt"`
TrackBreaks *IdentifyTrackBreaks `codec:"trackBreaks,omitempty" json:"trackBreaks,omitempty"`
}
func (o Identify2Res) DeepCopy() Identify2Res {
return Identify2Res{
Upk: o.Upk.DeepCopy(),
IdentifiedAt: o.IdentifiedAt.DeepCopy(),
TrackBreaks: (func(x *IdentifyTrackBreaks) *IdentifyTrackBreaks {
if x == nil {
return nil
}
tmp := (*x).DeepCopy()
return &tmp
})(o.TrackBreaks),
}
}
type IdentifyLiteRes struct {
Ul UserOrTeamLite `codec:"ul" json:"ul"`
TrackBreaks *IdentifyTrackBreaks `codec:"trackBreaks,omitempty" json:"trackBreaks,omitempty"`
}
func (o IdentifyLiteRes) DeepCopy() IdentifyLiteRes {
return IdentifyLiteRes{
Ul: o.Ul.DeepCopy(),
TrackBreaks: (func(x *IdentifyTrackBreaks) *IdentifyTrackBreaks {
if x == nil {
return nil
}
tmp := (*x).DeepCopy()
return &tmp
})(o.TrackBreaks),
}
}
type ResolveArg struct {
Assertion string `codec:"assertion" json:"assertion"`
}
func (o ResolveArg) DeepCopy() ResolveArg {
return ResolveArg{
Assertion: o.Assertion,
}
}
type Resolve2Arg struct {
Assertion string `codec:"assertion" json:"assertion"`
}
func (o Resolve2Arg) DeepCopy() Resolve2Arg {
return Resolve2Arg{
Assertion: o.Assertion,
}
}
type Resolve3Arg struct {
Assertion string `codec:"assertion" json:"assertion"`
}
func (o Resolve3Arg) DeepCopy() Resolve3Arg {
return Resolve3Arg{
Assertion: o.Assertion,
}
}
type IdentifyArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
UserAssertion string `codec:"userAssertion" json:"userAssertion"`
ForceRemoteCheck bool `codec:"forceRemoteCheck" json:"forceRemoteCheck"`
UseDelegateUI bool `codec:"useDelegateUI" json:"useDelegateUI"`
Reason IdentifyReason `codec:"reason" json:"reason"`
Source ClientType `codec:"source" json:"source"`
}
func (o IdentifyArg) DeepCopy() IdentifyArg {
return IdentifyArg{
SessionID: o.SessionID,
UserAssertion: o.UserAssertion,
ForceRemoteCheck: o.ForceRemoteCheck,
UseDelegateUI: o.UseDelegateUI,
Reason: o.Reason.DeepCopy(),
Source: o.Source.DeepCopy(),
}
}
type Identify2Arg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Uid UID `codec:"uid" json:"uid"`
UserAssertion string `codec:"userAssertion" json:"userAssertion"`
Reason IdentifyReason `codec:"reason" json:"reason"`
UseDelegateUI bool `codec:"useDelegateUI" json:"useDelegateUI"`
AlwaysBlock bool `codec:"alwaysBlock" json:"alwaysBlock"`
NoErrorOnTrackFailure bool `codec:"noErrorOnTrackFailure" json:"noErrorOnTrackFailure"`
ForceRemoteCheck bool `codec:"forceRemoteCheck" json:"forceRemoteCheck"`
NeedProofSet bool `codec:"needProofSet" json:"needProofSet"`
AllowEmptySelfID bool `codec:"allowEmptySelfID" json:"allowEmptySelfID"`
NoSkipSelf bool `codec:"noSkipSelf" json:"noSkipSelf"`
CanSuppressUI bool `codec:"canSuppressUI" json:"canSuppressUI"`
IdentifyBehavior TLFIdentifyBehavior `codec:"identifyBehavior" json:"identifyBehavior"`
ForceDisplay bool `codec:"forceDisplay" json:"forceDisplay"`
}
func (o Identify2Arg) DeepCopy() Identify2Arg {
return Identify2Arg{
SessionID: o.SessionID,
Uid: o.Uid.DeepCopy(),
UserAssertion: o.UserAssertion,
Reason: o.Reason.DeepCopy(),
UseDelegateUI: o.UseDelegateUI,
AlwaysBlock: o.AlwaysBlock,
NoErrorOnTrackFailure: o.NoErrorOnTrackFailure,
ForceRemoteCheck: o.ForceRemoteCheck,
NeedProofSet: o.NeedProofSet,
AllowEmptySelfID: o.AllowEmptySelfID,
NoSkipSelf: o.NoSkipSelf,
CanSuppressUI: o.CanSuppressUI,
IdentifyBehavior: o.IdentifyBehavior.DeepCopy(),
ForceDisplay: o.ForceDisplay,
}
}
type IdentifyLiteArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Id UserOrTeamID `codec:"id" json:"id"`
Assertion string `codec:"assertion" json:"assertion"`
Reason IdentifyReason `codec:"reason" json:"reason"`
UseDelegateUI bool `codec:"useDelegateUI" json:"useDelegateUI"`
AlwaysBlock bool `codec:"alwaysBlock" json:"alwaysBlock"`
NoErrorOnTrackFailure bool `codec:"noErrorOnTrackFailure" json:"noErrorOnTrackFailure"`
ForceRemoteCheck bool `codec:"forceRemoteCheck" json:"forceRemoteCheck"`
NeedProofSet bool `codec:"needProofSet" json:"needProofSet"`
AllowEmptySelfID bool `codec:"allowEmptySelfID" json:"allowEmptySelfID"`
NoSkipSelf bool `codec:"noSkipSelf" json:"noSkipSelf"`
CanSuppressUI bool `codec:"canSuppressUI" json:"canSuppressUI"`
IdentifyBehavior TLFIdentifyBehavior `codec:"identifyBehavior" json:"identifyBehavior"`
ForceDisplay bool `codec:"forceDisplay" json:"forceDisplay"`
}
func (o IdentifyLiteArg) DeepCopy() IdentifyLiteArg {
return IdentifyLiteArg{
SessionID: o.SessionID,
Id: o.Id.DeepCopy(),
Assertion: o.Assertion,
Reason: o.Reason.DeepCopy(),
UseDelegateUI: o.UseDelegateUI,
AlwaysBlock: o.AlwaysBlock,
NoErrorOnTrackFailure: o.NoErrorOnTrackFailure,
ForceRemoteCheck: o.ForceRemoteCheck,
NeedProofSet: o.NeedProofSet,
AllowEmptySelfID: o.AllowEmptySelfID,
NoSkipSelf: o.NoSkipSelf,
CanSuppressUI: o.CanSuppressUI,
IdentifyBehavior: o.IdentifyBehavior.DeepCopy(),
ForceDisplay: o.ForceDisplay,
}
}
type IdentifyInterface interface {
// Resolve an assertion to a UID. On failure, resolves to an empty UID and returns
// an error.
Resolve(context.Context, string) (UID, error)
// Resolve an assertion to a (UID,username). On failure, returns an error. Doesn't work for teams.
Resolve2(context.Context, string) (User, error)
// Resolve an assertion to a (UID,username) or (TeamID,teamname). On failure, returns an error.
Resolve3(context.Context, string) (UserOrTeamLite, error)
// DEPRECATED: use identify2
//
// Identify a user from a username or assertion (e.g. kbuser, twuser@twitter).
// If forceRemoteCheck is true, we force all remote proofs to be checked (otherwise a cache is used).
Identify(context.Context, IdentifyArg) (IdentifyRes, error)
Identify2(context.Context, Identify2Arg) (Identify2Res, error)
IdentifyLite(context.Context, IdentifyLiteArg) (IdentifyLiteRes, error)
}
func IdentifyProtocol(i IdentifyInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.identify",
Methods: map[string]rpc.ServeHandlerDescription{
"Resolve": {
MakeArg: func() interface{} {
ret := make([]ResolveArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]ResolveArg)
if !ok {
err = rpc.NewTypeError((*[]ResolveArg)(nil), args)
return
}
ret, err = i.Resolve(ctx, (*typedArgs)[0].Assertion)
return
},
MethodType: rpc.MethodCall,
},
"Resolve2": {
MakeArg: func() interface{} {
ret := make([]Resolve2Arg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]Resolve2Arg)
if !ok {
err = rpc.NewTypeError((*[]Resolve2Arg)(nil), args)
return
}
ret, err = i.Resolve2(ctx, (*typedArgs)[0].Assertion)
return
},
MethodType: rpc.MethodCall,
},
"Resolve3": {
MakeArg: func() interface{} {
ret := make([]Resolve3Arg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]Resolve3Arg)
if !ok {
err = rpc.NewTypeError((*[]Resolve3Arg)(nil), args)
return
}
ret, err = i.Resolve3(ctx, (*typedArgs)[0].Assertion)
return
},
MethodType: rpc.MethodCall,
},
"identify": {
MakeArg: func() interface{} {
ret := make([]IdentifyArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]IdentifyArg)
if !ok {
err = rpc.NewTypeError((*[]IdentifyArg)(nil), args)
return
}
ret, err = i.Identify(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"identify2": {
MakeArg: func() interface{} {
ret := make([]Identify2Arg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]Identify2Arg)
if !ok {
err = rpc.NewTypeError((*[]Identify2Arg)(nil), args)
return
}
ret, err = i.Identify2(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"identifyLite": {
MakeArg: func() interface{} {
ret := make([]IdentifyLiteArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]IdentifyLiteArg)
if !ok {
err = rpc.NewTypeError((*[]IdentifyLiteArg)(nil), args)
return
}
ret, err = i.IdentifyLite(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type IdentifyClient struct {
Cli rpc.GenericClient
}
// Resolve an assertion to a UID. On failure, resolves to an empty UID and returns
// an error.
func (c IdentifyClient) Resolve(ctx context.Context, assertion string) (res UID, err error) {
__arg := ResolveArg{Assertion: assertion}
err = c.Cli.Call(ctx, "keybase.1.identify.Resolve", []interface{}{__arg}, &res)
return
}
// Resolve an assertion to a (UID,username). On failure, returns an error. Doesn't work for teams.
func (c IdentifyClient) Resolve2(ctx context.Context, assertion string) (res User, err error) {
__arg := Resolve2Arg{Assertion: assertion}
err = c.Cli.Call(ctx, "keybase.1.identify.Resolve2", []interface{}{__arg}, &res)
return
}
// Resolve an assertion to a (UID,username) or (TeamID,teamname). On failure, returns an error.
func (c IdentifyClient) Resolve3(ctx context.Context, assertion string) (res UserOrTeamLite, err error) {
__arg := Resolve3Arg{Assertion: assertion}
err = c.Cli.Call(ctx, "keybase.1.identify.Resolve3", []interface{}{__arg}, &res)
return
}
// DEPRECATED: use identify2
//
// Identify a user from a username or assertion (e.g. kbuser, twuser@twitter).
// If forceRemoteCheck is true, we force all remote proofs to be checked (otherwise a cache is used).
func (c IdentifyClient) Identify(ctx context.Context, __arg IdentifyArg) (res IdentifyRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.identify.identify", []interface{}{__arg}, &res)
return
}
func (c IdentifyClient) Identify2(ctx context.Context, __arg Identify2Arg) (res Identify2Res, err error) {
err = c.Cli.Call(ctx, "keybase.1.identify.identify2", []interface{}{__arg}, &res)
return
}
func (c IdentifyClient) IdentifyLite(ctx context.Context, __arg IdentifyLiteArg) (res IdentifyLiteRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.identify.identifyLite", []interface{}{__arg}, &res)
return
}