Class: Yes::Core::DataDecryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/yes/core/data_decryptor.rb

Overview

Decrypts event data attributes using a key from the key repository.

Examples:

decryptor = DataDecryptor.new(data: event.data, schema: event.['encryption'], repository: repo)
decrypted_data = decryptor.call

Instance Method Summary collapse

Instance Method Details

#callHash

Decrypts the data attributes specified in the encryption metadata.

Returns:

  • (Hash)

    the decrypted data



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/yes/core/data_decryptor.rb', line 14

def call
  return encrypted_data if .empty?

  result = find_key(['key'])
  return encrypted_data unless result.success?

  decrypt_attributes(
    key: result.value!,
    data: encrypted_data,
    attributes: ['attributes']
  )
end