(swapTokenStr string)
| 125 | } |
| 126 | |
| 127 | func 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) |
| 153 | func setupRpcClient(serverImpl wshutil.ServerImpl, jwtToken string) error { |
no test coverage detected