module Smaak
Constants
- DEFAULT_TOKEN_LIFE
- VERSION
Public Class Methods
adaptors()
click to toggle source
# File lib/smaak.rb, line 25 def self.adaptors @@adaptors end
add_request_adaptor(request_clazz, adaptor_clazz)
click to toggle source
# File lib/smaak.rb, line 29 def self.add_request_adaptor(request_clazz, adaptor_clazz) @@adaptors[request_clazz] = adaptor_clazz end
create_adaptor(request)
click to toggle source
# File lib/smaak.rb, line 33 def self.create_adaptor(request) @@adaptors.each do |r, a| return a.new(request) if request.is_a? r end raise ArgumentError.new("Unknown request class #{request.class}. Add an adaptor using Smaak.add_request_adaptor.") end
headers_to_be_signed()
click to toggle source
# File lib/smaak.rb, line 15 def self.headers_to_be_signed [ "x-smaak-recipient", "x-smaak-identifier", "x-smaak-route-info", "x-smaak-psk", "x-smaak-expires", "x-smaak-nonce", "x-smaak-encrypt" ] end
select_specification(adaptor, specification)
click to toggle source
# File lib/smaak.rb, line 40 def self.select_specification(adaptor, specification) raise ArgumentError.new("Adaptor must be provided") if adaptor.nil? return Cavage04.new(adaptor) if specification == Smaak::Cavage04::SPECIFICATION raise ArgumentError.new("Unknown specification") end
Private Class Methods
get_signature_data_from_request(adaptor, specification = Smaak::Cavage04::SPECIFICATION)
click to toggle source
# File lib/smaak.rb, line 74 def self.get_signature_data_from_request(adaptor, specification = Smaak::Cavage04::SPECIFICATION) specification = Smaak.select_specification(adaptor, specification) signature_headers = specification.extract_signature_headers signature = specification.extract_signature return signature_headers, Smaak::Crypto.decode64(signature) end