refactor: move hashcash stamp from X-Hashcash header to JSON request body

Move the hashcash proof-of-work stamp from the X-Hashcash HTTP header
into the JSON request body as a 'hashcash' field on POST /api/v1/session.

Updated server handler, CLI client, SPA client, and documentation.
This commit is contained in:
clawbot
2026-03-10 10:00:20 -07:00
committed by user
parent db4cd9f055
commit 09a1dddbd0
5 changed files with 52 additions and 59 deletions

View File

@@ -52,7 +52,7 @@ func (client *Client) CreateSession(
// Fetch server info to check for hashcash requirement.
info, err := client.GetServerInfo()
var headers map[string]string
var hashcashStamp string
if err == nil && info.HashcashBits > 0 {
resource := info.Name
@@ -60,17 +60,13 @@ func (client *Client) CreateSession(
resource = "neoirc"
}
stamp := MintHashcash(info.HashcashBits, resource)
headers = map[string]string{
"X-Hashcash": stamp,
}
hashcashStamp = MintHashcash(info.HashcashBits, resource)
}
data, err := client.doWithHeaders(
data, err := client.do(
http.MethodPost,
"/api/v1/session",
&SessionRequest{Nick: nick},
headers,
&SessionRequest{Nick: nick, Hashcash: hashcashStamp},
)
if err != nil {
return nil, err