View Source Lightning.SafetyString (Lightning v2.10.4)

Utilities for securely encoding serializable structs, lists and strings into URL-safe strings.

In order to pass the state around in a URL, in a manner that protects secrets from leaking - and allows us to avoid persistance we take a set of parameters and:

  • Encode into a URI query string
  • gzip it to save characters
  • encrypt the string
  • base64 encode it for URI encoding safety

Summary

Functions

@spec decode(data :: binary()) ::
  {:error, String.t()} | %{optional(binary()) => binary()} | [binary()]
@spec encode(data :: struct() | map() | binary() | [binary()]) :: binary()