mirror of
https://github.com/fumiama/tienyik.git
synced 2026-06-09 01:10:24 +08:00
30 lines
721 B
Go
30 lines
721 B
Go
package auth
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/fumiama/tienyik/internal/hcli"
|
|
"github.com/fumiama/tienyik/internal/hson"
|
|
"github.com/fumiama/tienyik/internal/textio"
|
|
)
|
|
|
|
type RequestNegotiationEncKey struct {
|
|
CertData string `json:"certData"`
|
|
CertType string `json:"certType"`
|
|
Etype string `json:"etype"`
|
|
}
|
|
|
|
type ResponseNegotiationEncKey struct {
|
|
EncData string `json:"encData"`
|
|
EncKey string `json:"encKey"`
|
|
}
|
|
|
|
func NegotiationEncKey(r *RequestNegotiationEncKey) (*ResponseNegotiationEncKey, error) {
|
|
resp, err := hcli.Post(textio.API(), bytes.NewReader(hson.Marshal(nil, r)))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer resp.Body.Close()
|
|
return hson.Unmarshal[*ResponseNegotiationEncKey](nil, resp.Body)
|
|
}
|