Class: Chamber::Filters::DecryptionFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/chamber/filters/decryption_filter.rb

Constant Summary collapse

BASE64_STRING_PATTERN =
%r{\A[A-Za-z0-9+/]{342}==\z}.freeze
LARGE_DATA_STRING_PATTERN =
%r{
  \A                            # Beginning of String
  (
    [A-Za-z0-9+/#]*={0,2}       # Base64 Encoded Key
  )
  \#                            # Separator
  (
    [A-Za-z0-9+/#]*={0,2}       # Base64 Encoded IV
  )
  \#                            # Separator
  (
    [A-Za-z0-9+/#]*={0,2}       # Base64 Encoded Data
  )
  \z                            # End of String
}x.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, secure_key_prefix:, decryption_keys: {}, **_args) ⇒ DecryptionFilter

Returns a new instance of DecryptionFilter.



42
43
44
45
46
# File 'lib/chamber/filters/decryption_filter.rb', line 42

def initialize(data:, secure_key_prefix:, decryption_keys: {}, **_args)
  self.decryption_keys  = (decryption_keys || {}).transform_keys(&:to_s)
  self.data             = data.deep_dup
  self.secure_key_token = /\A#{Regexp.escape(secure_key_prefix)}/
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



34
35
36
# File 'lib/chamber/filters/decryption_filter.rb', line 34

def data
  @data
end

#decryption_keysObject

Returns the value of attribute decryption_keys.



36
37
38
# File 'lib/chamber/filters/decryption_filter.rb', line 36

def decryption_keys
  @decryption_keys
end

#secure_key_tokenObject

Returns the value of attribute secure_key_token.



34
35
36
# File 'lib/chamber/filters/decryption_filter.rb', line 34

def secure_key_token
  @secure_key_token
end

Class Method Details

.execute(**args) ⇒ Object



38
39
40
# File 'lib/chamber/filters/decryption_filter.rb', line 38

def self.execute(**args)
  new(**args).__send__(:execute)
end