toc

Ruby SDK

A full reference of our Ruby SDK.

You can use our Ruby SDK to:

  1. Encrypt data at your server
  2. Run your Cages
  3. Encrypt/decrypt data with Relay

You can use our Ruby SDK to encrypt data — rather than with Relay — and still send it to a third-party via Outbound Relay. Encrypting with our backend SDKs is best for developers who want to avoid the network latency of Relay and/or want to avoid sending plaintext data to Relay to be encrypted.

Encrypting data with our backend SDKs instead of Relay may expose you to greater compliance burden because plaintext data touches your server before it is encrypted.

You don’t need to change your database configuration. You can store Evervault-encrypted data in your database as you would the plaintext version.

Installation

There are two ways to install the Ruby SDK.

1. With Gemfile

Add this line to your application's Gemfile:

ruby
gem 'evervault'

Then, run:

sh
bundle install

2. By yourself

Just run:

sh
gem install evervault

Initialization

ruby
require "evervault"
# Initialize the client with your team's API key
Evervault.api_key = <YOUR-API-KEY>
# Encrypt your data and run a cage
encrypted_data = Evervault.encrypt({ hello: 'World!' })
# Process the encrypted data in a Cage
result = Evervault.run(<CAGE-NAME>, encrypted_data)

Reference

The Evervault Ruby SDK exposes nine methods.

Evervault.encrypt

Evervault.encrypt encrypts data for use in your Evervault Cages. To encrypt data on your server, simply pass a supported value into the Evervault.encrypt method. Store the encrypted data in your database as normal.

ruby
Evervault.encrypt(data = String | Number | Boolean | Hash | Array)
ParameterTypeDescription
dataString, Number, Boolean, Hash, ArrayData to be encrypted

Evervault.relay

Evervault.relay specifies which domains should be proxied through outbound relay. See Outbound Relay to learn more.

ruby
Evervault.relay(decryption_domains = Array)
ParameterTypeDescription
decryption_domainsArrayRequests sent to any of the domains listed will be proxied through outbound relay

Evervault.run

Evervault.run invokes a Cage with a given payload.

ruby
Evervault.run(cage_name = String, data = Hash[, options = Hash])
ParameterTypeDescription
cageNameStringName of the Cage to be run
dataHashPayload for the Cage
optionsHashOptions for the Cage run

Cage Run Options

OptionTypeDefaultDescription
asyncBooleanfalseRun your Cage in async mode. Async Cage runs will be queued for processing.
versionIntegernilSpecify the version of your Cage to run. By default, the latest version will be run.

Evervault.encrypt_and_run

Encrypt your data and use it as the payload to invoke the Cage.

ruby
Evervault.encrypt_and_run(cage_name = String, data = Hash)
ParameterTypeDescription
cageNameStringName of the Cage to be run
datadictData to be encrypted

Evervault.create_run_token

Evervault.create_run_token creates a single use, time bound token for invoking a cage.

ruby
Evervault.create_run_token(cage_name = String, data = Hash)
ParameterTypeDescription
cage_nameStringName of the Cage the run token should be created for.
dataHashPayload that the token can be used with.

Evervault.cages

Return a hash of your team's Cage objects in hash format, with cage-name as keys

ruby
Evervault.cages
=> {"hello-cage-chilly-plum"=>
#<Evervault::Models::Cage:0x00007f8b900b4438
@name="hello-cage-chilly-plum",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="c8a7ed58-4858-4510-a542-43125ccd1183">,
"hello-cage-filthy-fuchsia"=>
#<Evervault::Models::Cage:0x00007f8b900b43e8
@name="hello-cage-filthy-fuchsia",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="9af32d2b-53fa-406a-9abf-6a240648b45b">,
"hello-cage-extra-amaranth"=>
#<Evervault::Models::Cage:0x00007f8b900b4398
@name="hello-cage-extra-amaranth",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="5b99011e-a64d-4af7-bf81-619c8cb8c67f">,
"twilio-cage-explicit-salmon"=>
#<Evervault::Models::Cage:0x00007f8b900b4348
@name="twilio-cage-explicit-salmon",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="55986772-4db7-4695-ba44-1b807290ddea">}

Evervault.cage_list

Return a CageList object, containing a list of your team's Cages

ruby
Evervault.cage_list
=> #<Evervault::Models::CageList:0x00007f8b900b44b0
@cages=
[#<Evervault::Models::Cage:0x00007f8b900b4438
@name="hello-cage-chilly-plum",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="c8a7ed58-4858-4510-a542-43125ccd1183">,
#<Evervault::Models::Cage:0x00007f8b900b43e8
@name="hello-cage-filthy-fuchsia",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="9af32d2b-53fa-406a-9abf-6a240648b45b">,
#<Evervault::Models::Cage:0x00007f8b900b4398
@name="hello-cage-extra-amaranth",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="5b99011e-a64d-4af7-bf81-619c8cb8c67f">,
#<Evervault::Models::Cage:0x00007f8b900b4348
@name="twilio-cage-explicit-salmon",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="55986772-4db7-4695-ba44-1b807290ddea">,
#<Evervault::Models::Cage:0x00007f8b900b42f8
@name="hello-cage-collective-aquamarine",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="01691e76-691b-473e-aad5-44bf813ef146">,
#<Evervault::Models::Cage:0x00007f8b900b42a8
@name="twilio-cage-bored-scarlet",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="dc056e8b-faf3-445b-9c95-0885b983c302">,
#<Evervault::Models::Cage:0x00007f8b900b4258
@name="hello-cage-front-emerald",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="a30295e6-91fc-4d1d-837c-ac4c9b87d02d">]>

CageList.to_hash

Converts a list of Cages to a hash with keys of CageName => Cage Model

ruby
Evervault.cage_list.to_hash
=> {"hello-cage-chilly-plum"=>
#<Evervault::Models::Cage:0x00007f8b900b4438
@name="hello-cage-chilly-plum",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="c8a7ed58-4858-4510-a542-43125ccd1183">,
"hello-cage-filthy-fuchsia"=>
#<Evervault::Models::Cage:0x00007f8b900b43e8
@name="hello-cage-filthy-fuchsia",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="9af32d2b-53fa-406a-9abf-6a240648b45b">,
"hello-cage-extra-amaranth"=>
#<Evervault::Models::Cage:0x00007f8b900b4398
@name="hello-cage-extra-amaranth",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="5b99011e-a64d-4af7-bf81-619c8cb8c67f">,
"twilio-cage-explicit-salmon"=>
#<Evervault::Models::Cage:0x00007f8b900b4348
@name="twilio-cage-explicit-salmon",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="55986772-4db7-4695-ba44-1b807290ddea">,
"hello-cage-collective-aquamarine"=>
#<Evervault::Models::Cage:0x00007f8b900b42f8
@name="hello-cage-collective-aquamarine",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="01691e76-691b-473e-aad5-44bf813ef146">,
"twilio-cage-bored-scarlet"=>
#<Evervault::Models::Cage:0x00007f8b900b42a8
@name="twilio-cage-bored-scarlet",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="dc056e8b-faf3-445b-9c95-0885b983c302">,
"hello-cage-front-emerald"=>
#<Evervault::Models::Cage:0x00007f8b900b4258
@name="hello-cage-front-emerald",
@request=#<Evervault::Http::Request:0x00007f8b900b7d40 @api_key="API-KEY", @base_url="https://api.evervault.com/", @cage_run_url="https://cage.run/", @timeout=30>,
@uuid="a30295e6-91fc-4d1d-837c-ac4c9b87d02d">}

Was this page useful?