Lightning.SafetyString (Lightning v2.13.5)

View Source

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

decode(data)

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

encode(data)

@spec encode(data :: struct() | map() | binary() | [binary()]) :: binary()