Functions

Evervault Functions are secure serverless functions which allow you to process data encrypted by Evervault products. When you pass encrypted data to a Function, it is automatically decrypted. You can then process this data by running custom logic written in Node.js or Python as you usually would, but without ever handling it in plaintext on your infrastructure.

Deploying a Function


The quickest way to deploy your first Evervault Function is by signing into the Evervault Dashboard and creating a starter template Function by connecting your GitHub account.

  1. Sign in to the Evervault Dashboard
  2. Create or open an App and navigate to the Functions tab
  3. Click Create Function
  4. Select "Choose template"
  5. Authenticate with GitHub
  6. Select a starter template and deploy your Function

Using the CLI

You can also use the Evervault CLI to deploy a function directly from your machine.

Running a Function


Functions can be invoked using our SDKs, or using our REST API. Any encrypted data within the payload sent to the Function will be decrypted before being passed to the Function handler.

Client-side execution


API Keys are sensitive and should not be used client-side. When invoking Functions from frontend applications, we recommend using a Run Token. Run Tokens are single use, time bound tokens for invoking a Function with a given payload. Run Tokens will only last for 5 minutes and must be used with the same payload that was used to create the Run Token.

Run Tokens should be created in your backend using our API and handed off to your client.

Responses


The response from a Function run will contain a status field. The status field will be either success or failure, depending on whether the function completed successfully or not. Any payload returned from the Function will be inside of the result field of the response object.

Error handling


If there is a failure in the course of a Function run, the response will contain an error object with a message and stack field. The message field will contain a human readable error message, and the stack field will contain a stack trace of the error.

FunctionNotReady

Functions that have been idle for extended periods of time may return FunctionNotReady HTTP 409 errors. This can be resolved by retrying the request.

Encryption within a Function


An encrypt function is available within your Function and can be accessed through the context parameter. This allows you to encrypt data in your response using your App’s keys.

Configuration


Evervault Functions are configured using a function.toml configuration file which can be committed to source control. Simply provide a function.toml file in the root of your repository and Evervault will automatically include it at build time.

Dependencies


When you deploy a Function to Evervault, we will locate your package.json (for Node.js) and requirements.txt file (for Python) and install any non-development dependencies.

For Node.js Functions, if a node_modules folder is included then dependency installation will be skipped; this can be used to include private dependencies.

If there are any issues with your dependencies, for example if you have missed one in your package.json, an InitializationError will be thrown.

Environment Variables


Environment Variables for a Function can be configured using either the Evervault Dashboard or CLI. Secrets can be encrypted on creation and will be made available to your Function handler in plaintext on startup.

Secrets are available in plaintext in the Function handler, but will be in their encrypted form when accessed from anywhere else within the Function.

Networking


Limiting access to your Function


By default, Functions will respond to requests invoked from any client with a valid Evervault API key or Run Token. By adding an IP address to the Inbound Whitelist in the Dashboard, your Function will only be invoked when a request is made from a whitelisted IP address.

Limiting egress from your Function


By default, Functions can send requests to any third-party endpoint. By adding a domain name to the Outbound Whitelist in the Dashboard, your Function will only have network access to the hostnames you specify.

Resource Limits


Evervault Functions have a maximum memory consumption of 1024MB, 2 available CPU cores, and 512MB of ephemeral filesystem storage. However, using ephemeral storage is not recommended for sensitive data, as it cannot be guaranteed that data won't be available to a future invocation — increasing the risk of an accidental data leak.

Evervault Functions scale automatically to many thousands of requests per second without a noticeable drop in throughput or latency.

If you require more memory or CPU cores, check out Evervault Enclaves — the easiest way to build, deploy, and scale Secure Enclaves.

Execution Time


Evervault Functions have a default execution time of 30 seconds. This can be increased to a maximum of 55 seconds (for synchronous invocations) by setting the timeout in the function.toml.

Asynchronous Functions


Asynchronous Function runs up to 15 minutes are also permitted. To execute a Function in async mode, you must set the async argument on your request payload to true.

Observability


Logs for all function runs can be viewed inside of the Evervault Dashboard. You can learn more about observability in our observability guide.