Ruby SDK
emitwave — a server-side gem that HMAC-signs and publishes events to the gateway.
Server SDK· 3 min read
Install
bash
gem install emitwave
Requires Ruby 3.0+, an application ID, and an active server credential (public key + one-time secret). Keep the secret on the server — never in client code, public env vars, logs, or API responses.
The
key and secret are a server credential, not the browser public application key. For every request the SDK hashes the exact JSON body and signs the method, path, canonical query, and body hash with HMAC-SHA256.Publish an event
trigger(channel, event, data) serializes the event, signs the body, and sends it to /apps/{app_id}/events. gateway_url: is optional and defaults to the live gateway.
publish.rb
require "emitwave" client = Emitwave::Client.new( app_id: "app_...", key: "ew_pk_live_...", # server credential public key secret: "ew_sk_live_..." # server credential secret # gateway_url: defaults to https://api.emitwave.com ) client.trigger("orders", "order.created", { id: "ord_123", total: 4900 })
Error handling
Emitwave::Error represents a non-2xx gateway response and carries #status and #body; the body never includes your secret.
errors.rb
begin client.trigger("orders", "order.created", { id: "ord_123" }) rescue Emitwave::Error => e warn "Emitwave rejected the event #{e.status}: #{e.body}" end
This SDK publishes the provided JSON as-is. It does not build the ciphertext envelope for a private-encrypted channel — see Encryption.