MCPcopy
hub / github.com/wavetermdev/waveterm / setupRpcClientWithToken

Function setupRpcClientWithToken

cmd/wsh/cmd/wshcmd-root.go:127–150  ·  view source on GitHub ↗
(swapTokenStr string)

Source from the content-addressed store, hash-verified

125}
126
127func setupRpcClientWithToken(swapTokenStr string) (wshrpc.CommandAuthenticateRtnData, error) {
128 var rtn wshrpc.CommandAuthenticateRtnData
129 token, err := shellutil.UnpackSwapToken(swapTokenStr)
130 if err != nil {
131 return rtn, fmt.Errorf("error unpacking token: %w", err)
132 }
133 if token.RpcContext == nil {
134 return rtn, fmt.Errorf("no rpccontext in token")
135 }
136 if token.RpcContext.SockName == "" {
137 return rtn, fmt.Errorf("no sockname in token")
138 }
139 RpcContext = *token.RpcContext
140 RpcClient, err = wshutil.SetupDomainSocketRpcClient(token.RpcContext.SockName, nil, "wshcmd")
141 if err != nil {
142 return rtn, fmt.Errorf("error setting up domain socket rpc client: %w", err)
143 }
144 rtn, err = wshclient.AuthenticateTokenCommand(RpcClient, wshrpc.CommandAuthenticateTokenData{Token: token.Token}, &wshrpc.RpcOpts{Route: wshutil.ControlRoute})
145 if err != nil {
146 return rtn, err
147 }
148 RpcClientRouteId = rtn.RouteId
149 return rtn, nil
150}
151
152// returns the wrapped stdin and a new rpc client (that wraps the stdin input and stdout output)
153func setupRpcClient(serverImpl wshutil.ServerImpl, jwtToken string) error {

Callers 1

tokenCmdRunFunction · 0.85

Calls 3

UnpackSwapTokenFunction · 0.92
AuthenticateTokenCommandFunction · 0.92

Tested by

no test coverage detected