The Tripwire Ruby library provides convenient access to the Tripwire API from applications written in Ruby. It includes a client for Sessions, visitor fingerprints, Teams, Team API key management, and sealed token verification.
The library also provides:
- a fast configuration path using
TRIPWIRE_SECRET_KEY - lazy helpers for cursor-based pagination
- structured API errors and built-in sealed token verification
See the Tripwire docs and API reference.
You don't need this source code unless you want to modify the gem. If you just want to use the package, run:
bundle add tripwire-server- Ruby 2.6+
The library needs to be configured with your account's secret key. Set TRIPWIRE_SECRET_KEY in your environment or pass secret_key directly:
require "tripwire/server"
client = Tripwire::Server::Client.new(secret_key: "sk_live_...")
page = client.sessions.list(verdict: "bot", limit: 25)
session = client.sessions.get("sid_0123456789abcdefghjkmnpqrs")
puts "#{session[:decision][:automation_status]} #{session[:highlights].first&.fetch(:summary, nil)}"result = Tripwire::Server.safe_verify_tripwire_token(sealed_token, "sk_live_...")
if result[:ok]
puts "#{result[:data][:decision][:verdict]} #{result[:data][:decision][:risk_score]}"
else
warn result[:error].message
endclient.sessions.iter(search: "signup").each do |session|
puts "#{session[:id]} #{session[:latest_decision][:verdict]}"
endfingerprint = client.fingerprints.get("vid_0123456789abcdefghjkmnpqrs")
puts fingerprint[:id]team = client.teams.get("team_0123456789abcdefghjkmnpqrs")
updated = client.teams.update("team_0123456789abcdefghjkmnpqrs", name: "New Name")
puts updated[:name]created = client.teams.api_keys.create("team_0123456789abcdefghjkmnpqrs", name: "Production", environment: "live")
client.teams.api_keys.revoke("team_0123456789abcdefghjkmnpqrs", created[:id])begin
client.sessions.list(limit: 999)
rescue Tripwire::Server::ApiError => error
warn "#{error.status} #{error.code} #{error.message}"
endIf you need help integrating Tripwire, start with tripwirejs.com/docs.