Documentation
¶
Index ¶
- func BuildHandshakeRequest(clientPriv *ec.PrivateKey, serverPub *ec.PublicKey, salt string, nonce string) (body string, headers map[string]string, err error)
- func CreateToken(payload map[string]any, priv *ec.PrivateKey, expSec int64) (string, error)
- func VerifyHandshakeRequest(body, method, uriPath string, headers map[string]string, ...) (*ec.PublicKey, string, string, error)
- func VerifyToken(token string, pub *ec.PublicKey) (map[string]any, error)
- type BitSealWSConn
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildHandshakeRequest ¶
func BuildHandshakeRequest(clientPriv *ec.PrivateKey, serverPub *ec.PublicKey, salt string, nonce string) (body string, headers map[string]string, err error)
BuildHandshakeRequest constructs body+headers like TS side.
func CreateToken ¶
CreateToken builds payload JSON, adds iat/exp, signs SHA256(payload) with secp256k1 ECDSA. Returns base64url(payload) + "." + base64url(signatureDER)
Types ¶
type BitSealWSConn ¶
BitSealWSConn 封装了 x/net/websocket.Conn,并在读写时自动进行 BST2 编解码。 发送方需先 EncodeRecord,接收方需 DecodeRecord,本结构体内部自动处理。
func ConnectBitSealWS ¶
func ConnectBitSealWS(clientPriv *ec.PrivateKey, serverPub *ec.PublicKey, wsURL string) (*BitSealWSConn, error)
ConnectBitSealWS 完成客户端两步握手并建立 BST2 会话,返回包装后的连接。
- HTTP POST /ws/handshake – BitSeal-WEB 签名请求
- WebSocket Upgrade /ws/socket – 子协议携带 SimpleToken
wsURL 形如 wss://host/ws/socket
Click to show internal directories.
Click to hide internal directories.