forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prove.go
126 lines (111 loc) · 3.38 KB
/
prove.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
// Auto-generated by avdl-compiler v1.3.19 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/prove.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type CheckProofStatus struct {
Found bool `codec:"found" json:"found"`
Status ProofStatus `codec:"status" json:"status"`
ProofText string `codec:"proofText" json:"proofText"`
State ProofState `codec:"state" json:"state"`
}
func (o CheckProofStatus) DeepCopy() CheckProofStatus {
return CheckProofStatus{
Found: o.Found,
Status: o.Status.DeepCopy(),
ProofText: o.ProofText,
State: o.State.DeepCopy(),
}
}
type StartProofResult struct {
SigID SigID `codec:"sigID" json:"sigID"`
}
func (o StartProofResult) DeepCopy() StartProofResult {
return StartProofResult{
SigID: o.SigID.DeepCopy(),
}
}
type StartProofArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Service string `codec:"service" json:"service"`
Username string `codec:"username" json:"username"`
Force bool `codec:"force" json:"force"`
PromptPosted bool `codec:"promptPosted" json:"promptPosted"`
Auto bool `codec:"auto" json:"auto"`
}
func (o StartProofArg) DeepCopy() StartProofArg {
return StartProofArg{
SessionID: o.SessionID,
Service: o.Service,
Username: o.Username,
Force: o.Force,
PromptPosted: o.PromptPosted,
Auto: o.Auto,
}
}
type CheckProofArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
SigID SigID `codec:"sigID" json:"sigID"`
}
func (o CheckProofArg) DeepCopy() CheckProofArg {
return CheckProofArg{
SessionID: o.SessionID,
SigID: o.SigID.DeepCopy(),
}
}
type ProveInterface interface {
StartProof(context.Context, StartProofArg) (StartProofResult, error)
CheckProof(context.Context, CheckProofArg) (CheckProofStatus, error)
}
func ProveProtocol(i ProveInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.prove",
Methods: map[string]rpc.ServeHandlerDescription{
"startProof": {
MakeArg: func() interface{} {
ret := make([]StartProofArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]StartProofArg)
if !ok {
err = rpc.NewTypeError((*[]StartProofArg)(nil), args)
return
}
ret, err = i.StartProof(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"checkProof": {
MakeArg: func() interface{} {
ret := make([]CheckProofArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]CheckProofArg)
if !ok {
err = rpc.NewTypeError((*[]CheckProofArg)(nil), args)
return
}
ret, err = i.CheckProof(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type ProveClient struct {
Cli rpc.GenericClient
}
func (c ProveClient) StartProof(ctx context.Context, __arg StartProofArg) (res StartProofResult, err error) {
err = c.Cli.Call(ctx, "keybase.1.prove.startProof", []interface{}{__arg}, &res)
return
}
func (c ProveClient) CheckProof(ctx context.Context, __arg CheckProofArg) (res CheckProofStatus, err error) {
err = c.Cli.Call(ctx, "keybase.1.prove.checkProof", []interface{}{__arg}, &res)
return
}