Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

event_sub_events

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event_sub_events

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

EventSubEvents

EventSub is a Ruby library for Twitch EventSub webhooks. It is built on the ActiveSupport::Notifications API.

This is forked from stripe_event and modified for use with Twitch EventSub.

Install

# Gemfile
gem "event_sub_events"
# config/routes.rb
mount EventSubEvents::Engine, at: "/my-chosen-path"

Usage

# config/initializers/event_sub_events.rb
EventSubEvents.signing_secret = ENV['TWITCH_SIGNING_SECRET']

EventSubEvents.configure do |events|
  events.subscribe "channel.ban" do |event|
    event.subscription
    event.event
  end

  events.all do |event|
    # Handle all event types - logging, etc.
  end
end

When a webhook_callback_verification_pending event is received, the event_sub_events engine will return the challenge response automatically.

Subscriber objects that respond to #call

class CustomerCreated
  def call(event)
    # Event handling
  end
end

class BillingEventLogger
  def initialize(logger)
    @logger = logger
  end

  def call(event)
    @logger.info "BILLING:#{event.type}:#{event.id}"
  end
end
EventSubEvents.configure do |events|
  events.all BillingEventLogger.new(Rails.logger)
  events.subscribe 'customer.created', CustomerCreated.new
end

Securing your webhook endpoint

Authenticating webhooks with signatures

Twitch will cryptographically sign webhook events with a signature which is included with a header sent with the request. Verifying this signature lets your application properly authenticate the request originated from Twitch.

Please set the signing_secret configuration value:

EventSubEvents.signing_secret = "abc123"

Please refer to Twitch's documentation for more details

Support for multiple signing secrets

You can also supply multiple secrets by sending an array to signing_secrets like so:

EventSubEvents.signing_secrets = [
  "abc123",
  "123abc"
]

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/deanpcmad/eventsub-events.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 27 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc