@onehazel/connect
v0.1.0
Published
Helpers for the OneHazel Operator Contract: verify X-OneHazel-Signature, launch games, typed errors.
Maintainers
Readme
@onehazel/connect
Helpers for the OneHazel Operator Contract. Zero runtime dependencies, Node 18+.
import { verifySignature, verifyWebhookSignature, signForTest, signWebhookForTest, launch, demoLaunch, ConnectError } from "@onehazel/connect";| Function | Purpose |
|---|---|
| verifySignature(rawBody, headerValue, secret, { toleranceSec: 300 }) | Verify a wallet or player call's X-OneHazel-Signature (t=<s>,v1=<hex>) over the RAW body, constant-time. secret may be [current, previous] during a rotation. Returns a boolean, never throws. |
| verifyWebhookSignature(rawBody, headerValue, secret) | Verify a webhook delivery's X-OneHazel-Signature: sha256=<hex> (HMAC-SHA256 of the RAW body, no timestamp, no bearer). Deduplicate on deliveryId: a replay verifies. |
| signForTest(body, secret, t?) | Build a valid wallet/player header for your own tests. |
| signWebhookForTest(body, secret) | Build a valid webhook header for your own tests. |
| launch(apiKey, params, options?) | POST /connect/v1/launch: real-money game URL. |
| demoLaunch(apiKey, params, options?) | POST /connect/v1/demo-launch: play-money game URL, moves no money. |
| ConnectError | Typed error with code, retryable, status; toEnvelope() gives the flat { code, message, retryable } body. |
launch and demoLaunch throw ConnectError on failure; a network failure is unavailable (retryable). Messages never contain your API key.
