SafeRPC.Atoms (safe_rpc v0.1.12)

Copy Markdown View Source

Bounded atom vocabulary preparation for SafeRPC clients.

SafeRPC decodes protocol frames with :safe, so replies can only contain atoms that already exist in the client VM. A service may expose a bounded vocabulary as strings; clients validate that vocabulary and intentionally intern accepted atoms before making calls that may return them.

Summary

Functions

Normalizes atoms and module names to unique strings.

Validates and interns an atom vocabulary.

Types

policy()

@type policy() :: [
  max_atoms: pos_integer(),
  max_atom_length: pos_integer(),
  allow: [Regex.t() | (String.t() -> as_boolean(term()))]
]

Functions

names(values)

@spec names([atom() | module() | String.t()]) :: [String.t()]

Normalizes atoms and module names to unique strings.

prepare(names, opts \\ [])

@spec prepare([String.t()], policy()) :: :ok | {:error, term()}

Validates and interns an atom vocabulary.