View Source Runbox.Runtime.Sandbox.UserActionSigner (runbox v21.2.0)
Module that signs user actions for Sandbox.
This uses a fixed key that is part of the source-code, so do not rely on it for security. The key is the same we used before, so it's backwards compatible - tests depending on Sandbox should keep working like before.
This module is set-up to be used in Sandbox automatically.
Summary
Functions
@spec sign(map()) :: {:ok, Joken.bearer_token()} | {:error, Joken.error_reason()}
Sign the provided user action claims.
Do not use this function directly for signing user actions. Instead use
Runbox.Scenario.UserAction.pack/4
.
@spec validate_and_unpack(token :: String.t()) :: {:ok, map()} | {:error, Joken.error_reason()}
Validate and unpack a user action token.
Checks if a token is a valid user action and if so unpacks the content.
Useful for testing or in Sandbox environment, for quickly checking a token possibly created by a scenario.