Ranbval: load .ranbval* config, decrypt vault tokens, optional telemetry (BYO HTTP/vendor SDK)
Project description
Ranbval Python runtime
This package loads layered .ranbval* config into os.environ, decrypts ranbval.* vault tokens when your code calls safe_decrypt, and optionally sends telemetry to your Ranbval password-manager (Live Monitor). It does not bundle other vendors’ SDKs or HTTP stacks—only cryptography and certifi.
How it works (end-to-end)
- Config on disk — You keep
KEY=valuelines in.ranbvaland related files (see below). Values can be plain text orranbval.<salt>.<ciphertext>.<label>tokens produced by the vault. load_ranbval()— Merges those files intoos.environ. Encrypted tokens are stored as-is; nothing is decrypted during this step.- Your code — You read
os.environ, callsafe_decrypt(...)when a value is aranbval.*token and you need the real secret for an API call. emit_telemetry(...)(optional) — After an outbound call, you POST a small payload to the password-manager so usage is attributed to the right vault credential (via client salt inside the token, or an explicit salt).
Importing the package does not load files or touch the network. You choose where to call load_ranbval() (e.g. start of main, app factory, worker entrypoint).
Install
pip install ranbval-sdk
Runtime dependencies are cryptography and certifi (for HTTPS verification). Everything else is your app’s own stack.
load_ranbval() — layered config
Call it explicitly when your process should pick up .ranbval* settings:
from ranbval_sdk import load_ranbval
load_ranbval()
Where files are found
With no arguments, the SDK walks from the current working directory upward until it finds a directory that contains .ranbval or any .ranbval.* file. That directory is the config root.
Helpers (optional):
find_ranbval_directory(start=None)— config root path orNonefind_ranbval_file(start=None)— path to base.ranbvalor first layer fileresolve_ranbval_mode(mode=None)— which mode name is active (see below)
Which mode is used
Mode selects .ranbval.{mode} and .ranbval.{mode}.local in the merge. Resolution order:
load_ranbval(mode="...")if you passmode- Else
RANBVAL_ENV, thenENVIRONMENT, thenENV - Default
development
Merge order (later wins)
For the chosen mode, existing files are merged in this order:
.ranbval.ranbval.{mode}.ranbval.local.ranbval.{mode}.local
Duplicate keys: later file overrides earlier.
Applying values to os.environ
For each merged KEY=value:
override=False(default): set only if the key is missing or currently empty inos.environ.override=True: merged values always replace what was already inos.environ.
Return value: True if at least one file was read, else False.
Single file instead of layers
load_ranbval("/absolute/or/relative/path/to/file")
Only that file is parsed; layer discovery is skipped.
Optional start directory
load_ranbval(start="/path/to/project/root")
Search for the config root begins at start instead of os.getcwd().
Vault tokens vs plain env values
- Plain values in
.ranbval*are copied into the environment unchanged. ranbval.*tokens stay opaque strings in the environment until you callsafe_decrypt(encoded, RANBVAL_VAULT_SECRET)(or your app’s equivalent secret).
Token shape: ranbval.<client_salt>.<blob>.<label> — telemetry uses <client_salt> when you pass vault_token_env="..." pointing at that env var.
safe_decrypt
from ranbval_sdk import safe_decrypt
import os
load_ranbval()
raw = os.environ["MY_API_CREDENTIAL"]
secret = os.environ["RANBVAL_VAULT_SECRET"]
plain = safe_decrypt(raw, secret) if raw.startswith("ranbval.") else raw
# use `plain` in headers, clients, etc.
Use this only when you actually need the secret; avoid logging it.
emit_telemetry
Sends one row to {RANBVAL_HOST}/api/telemetry (password-manager origin only—no /api suffix in RANBVAL_HOST).
Typical pattern after your HTTP or SDK call:
from ranbval_sdk import load_ranbval, emit_telemetry
load_ranbval()
# ... your request using decrypted credential if needed ...
emit_telemetry(
vault_token_env="MY_API_CREDENTIAL", # env var holding a ranbval.* token → salt extracted
model_used="my-service.endpoint", # free-form label in the dashboard
prompt_tokens=0,
completion_tokens=0,
background=True,
)
If the credential is not a ranbval.* string, pass client_salt="..." instead of vault_token_env, or the call is a no-op (no salt → no POST).
| Variable | Purpose |
|---|---|
RANBVAL_HOST |
Password-manager base URL (default: hosted instance). |
RANBVAL_TELEMETRY |
0 / false / off / no — skip telemetry POSTs. |
RANBVAL_TELEMETRY_DEBUG |
1 / true — print telemetry failures to stderr. |
HTTPS uses certifi; upgrade certifi if certificate verification fails on your machine.
Optional: secure_client / build_secure_client
If you use a class-based third-party client that takes an API key in the constructor, you can wrap that class so it:
- reads a named env var,
- decrypts if it looks like
ranbval.*, - passes the plain key into the constructor under the keyword your client expects,
- optionally wraps one dotted method path to call
emit_telemetryon the way back.
from ranbval_sdk import load_ranbval, secure_client
import some_sdk # your dependency, not from this package
load_ranbval()
client = secure_client(
some_sdk.Client,
env_var="MY_API_CREDENTIAL",
key_kwarg="api_key",
method_path_to_patch="resources.create", # optional
)
build_secure_client(...) returns a subclass instead of an instance—same parameters at the class level.
Git remote allowlist (optional)
| Variable | Purpose |
|---|---|
RANBVAL_HOST |
Same host used for repo policy checks. |
RANBVAL_SKIP_REPO_CHECK |
1 / true — skip check (local dev only). |
Example layout
See .ranbval.example. Put machine-only secrets in .ranbval.local / .ranbval.{mode}.local and add those files to .gitignore.
Further reading
In this monorepo, ranbval-password-manager README describes ingest schema, dashboard behavior, and backend APIs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ranbval_sdk-0.4.2.tar.gz.
File metadata
- Download URL: ranbval_sdk-0.4.2.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.12.0 Darwin/25.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
178b4ea8b4ba022254618552f8324f1080ed4c34ae4994f4405fba4aa7906c06
|
|
| MD5 |
6ace1b0ae59e4664660623dc4aaaeb17
|
|
| BLAKE2b-256 |
15077a781555205a6c4507025fc25ac886a4e3803c846935e1d98894945decb9
|
File details
Details for the file ranbval_sdk-0.4.2-cp312-cp312-macosx_26_0_arm64.whl.
File metadata
- Download URL: ranbval_sdk-0.4.2-cp312-cp312-macosx_26_0_arm64.whl
- Upload date:
- Size: 14.9 kB
- Tags: CPython 3.12, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.12.0 Darwin/25.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
395d065207db08beb37f7e1d8d80a8e7f9738d8aa4f8436ee1680e688054afa4
|
|
| MD5 |
da1ac937bfbbc1ecbf6a1ed1afe6eb78
|
|
| BLAKE2b-256 |
5de73a54ca5398d922beeb3edcbc65718d65fcbdb8315f0b3c5cea76747cb350
|