Class: Rack::DiscordInteractions::Verifier

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/discord-interactions/verifier.rb

Overview

Middleware to handle verification of interaction signatures

Instance Method Summary collapse

Constructor Details

#initialize(app, public_key, path: nil, handle_pings: true) ⇒ Verifier

Returns a new instance of Verifier.

Parameters:

  • app (#call)

    The rack app, or an object that responds to ‘#call`.

  • public_key (String)

    The public key of the application.

  • path (String) (defaults to: nil)

    Path to verify, will verify all requests if ‘nil`.

  • handle_pings (true, false) (defaults to: true)

    Whether the middleware should automatically handle responding to pings.



24
25
26
27
28
29
# File 'lib/rack/discord-interactions/verifier.rb', line 24

def initialize(app, public_key, path: nil, handle_pings: true)
  @app = app
  @verify_key = Ed25519::VerifyKey.new([public_key].pack('H*'))
  @path = path
  @handle_pings = handle_pings
end