{"modulePath":"github.com/GoCodeAlone/workflow-plugin-ws-auth","version":"v0.1.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package internal\n\n## Variables\n\n```go\nvar Version = \"0.0.0\"\n```\nVersion is set at build time via -ldflags \"-X github.com/GoCodeAlone/workflow-plugin-ws-auth/internal.Version=X.Y.Z\". Default is a bare semver so plugin loaders that validate semver accept unreleased dev builds; goreleaser overrides with the real release tag.\n\n## Functions\n\n```go\nfunc NewWSAuthPlugin() sdk.PluginProvider\n```\nNewWSAuthPlugin returns the ws-auth SDK plugin provider.\n\n```go\nfunc SetGlobalEnforcer(pe *ProtocolEnforcer)\n```\nSetGlobalEnforcer sets the global protocol enforcer.\n\n## Types\n\n```go\ntype AuthenticatedConnection struct {\n\tConnID     string\n\tPlayerID   string\n\tPlayerType string\n\tSessionID  string\n\tHMACKey    []byte\n\tLastSeq    uint64\n}\n```\nAuthenticatedConnection holds per-connection state after a completed handshake.\n\n```go\ntype ConnectionChallenge struct {\n\tNonce     string `json:\"nonce\"`\n\tTimestamp int64  `json:\"timestamp\"`\n\tServerID  string `json:\"server_id\"`\n}\n```\nConnectionChallenge is sent to the client to initiate handshake.\n\n```go\ntype HandshakeResponse struct {\n\tSignature  string `json:\"signature\"`\n\tPlayerType string `json:\"player_type\"`\n\tSessionID  string `json:\"session_id\"`\n\tAuthToken  string `json:\"auth_token\"`\n\tSDKVersion string `json:\"sdk_version\"`\n}\n```\nHandshakeResponse is the client's reply to a challenge.\n\n```go\ntype ProtocolEnforcer struct {\n\n\t// OnAuthenticated is called after successful handshake, before the\n\t// handshake_ok message is sent. Useful for joining rooms synchronously.\n\tOnAuthenticated func(connID, playerType, sessionID, playerID string)\n\n\t// OnDisconnect is called when a connection is removed.\n\tOnDisconnect func(connID, playerID string)\n\n\t// SendFunc delivers a message to a connection. Must be set by the host.\n\tSendFunc func(connID string, msg []byte) bool\n\t// contains filtered or unexported fields\n}\n```\nProtocolEnforcer manages HMAC handshakes and validates signed messages.\n\n```go\nfunc GetGlobalEnforcer() *ProtocolEnforcer\n```\nGetGlobalEnforcer returns the global protocol enforcer.\n\n```go\nfunc NewProtocolEnforcer(sdkSecret []byte, serverID string) *ProtocolEnforcer\n```\nNewProtocolEnforcer creates a ProtocolEnforcer with the given shared SDK secret.\n\n```go\nfunc (pe *ProtocolEnforcer) GetConnID(playerID string) string\n```\nGetConnID returns the connID for a playerID, if any.\n\n```go\nfunc (pe *ProtocolEnforcer) GetConnection(connID string) (AuthenticatedConnection, bool)\n```\nGetConnection returns a copy of the authenticated connection for inspection.\n\n```go\nfunc (pe *ProtocolEnforcer) GetPlayerID(connID string) string\n```\nGetPlayerID returns the playerID associated with a connection, if any.\n\n```go\nfunc (pe *ProtocolEnforcer) HandleConnect(connID string)\n```\nHandleConnect generates a challenge for a new connection and sends it.\n\n```go\nfunc (pe *ProtocolEnforcer) HandleDisconnect(connID string)\n```\nHandleDisconnect cleans up per-connection state.\n\n```go\nfunc (pe *ProtocolEnforcer) HandleMessage(connID string, raw []byte) ([]byte, bool)\n```\nHandleMessage processes an inbound message. Returns (payload, true) when the message should be forwarded to pipeline routing. Returns (nil, false) when consumed internally (handshake) or rejected.\n\n```go\ntype SignedMessage struct {\n\tSeq       uint64 `json:\"seq\"`\n\tPayload   []byte `json:\"payload\"`\n\tSignature string `json:\"signature\"`\n}\n```\nSignedMessage wraps a payload with sequence and HMAC signature.\n\n","path":"github.com/GoCodeAlone/workflow-plugin-ws-auth/internal","name":"internal","synopsis":"","isRedistributable":true}
