Tripwire Ruby Library
The Tripwire Ruby library provides convenient access to the Tripwire API from applications written in Ruby. It includes a client for Sessions, 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
Documentation
See the Tripwire docs and API reference.
Installation
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
Requirements
- Ruby 2.6+
Usage
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_123")
Sealed token verification
result = Tripwire::Server.safe_verify_tripwire_token(sealed_token, "sk_live_...")
if result[:ok]
puts "#{result[:data][:verdict]} #{result[:data][:score]}"
else
warn result[:error].
end
Pagination
client.sessions.iter(search: "signup").each do |session|
puts "#{session[:id]} #{session[:latestResult][:verdict]}"
end
Fingerprints
fingerprint = client.fingerprints.get("vis_123")
puts fingerprint[:id]
Teams
team = client.teams.get("team_123")
updated = client.teams.update("team_123", name: "New Name")
puts updated[:name]
Team API keys
created = client.teams.api_keys.create("team_123", name: "Production")
client.teams.api_keys.revoke("team_123", created[:id])
Error handling
begin
client.sessions.list(limit: 999)
rescue Tripwire::Server::ApiError => error
warn "#{error.status} #{error.code} #{error.}"
end
Support
If you need help integrating Tripwire, start with tripwirejs.com/docs.