forked from keybase/client
/
identify.go
159 lines (145 loc) · 5.57 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
// Auto-generated by avdl-compiler v1.3.1 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/identify.avdl
package keybase1
import (
rpc "github.com/keybase/go-framed-msgpack-rpc"
context "golang.org/x/net/context"
)
type Identify2Res struct {
Upk UserPlusKeys `codec:"upk" json:"upk"`
}
type ResolveArg struct {
Assertion string `codec:"assertion" json:"assertion"`
}
type Resolve2Arg struct {
Assertion string `codec:"assertion" json:"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"`
}
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"`
}
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.
Resolve2(context.Context, string) (User, error)
// 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)
}
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,
},
"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,
},
},
}
}
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.
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
}
// 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
}