Module: Insika::SecretMasking
- Defined in:
- lib/insika/secret_masking.rb
Overview
Secret masking on the UI<->Store round-trip. OpenClaw
convention: a secret NEVER comes back to the screen in plaintext — it becomes
the sentinel __OCULTO__. On save, the sentinel coming back means "keep what
was already there"; a new string replaces it; "" clears it. Shared by
llm_providers (api keys) and, in the future, MCP instances (credentials).
Constant Summary collapse
- SENTINEL =
"__OCULTO__"
Class Method Summary collapse
-
.mask(value) ⇒ Object
Value to DISPLAY: present -> sentinel (never the plaintext); absent -> nil.
- .present?(value) ⇒ Boolean
-
.reconcile(incoming, existing) ⇒ Object
Value to PERSIST given what the form sent (
incoming) and what already existed (existing): - not sent (nil) ............
Class Method Details
.mask(value) ⇒ Object
Value to DISPLAY: present -> sentinel (never the plaintext); absent -> nil.
15 16 17 |
# File 'lib/insika/secret_masking.rb', line 15 def mask(value) present?(value) ? SENTINEL : nil end |
.present?(value) ⇒ Boolean
32 |
# File 'lib/insika/secret_masking.rb', line 32 def present?(value) = Insika::Coercion.present?(value) |
.reconcile(incoming, existing) ⇒ Object
Value to PERSIST given what the form sent (incoming) and what already
existed (existing):
- not sent (nil) ............ preserves `existing`
- sentinel `__OCULTO__` ..... preserves `existing`
- "" (empty) ................ clears (nil)
- new string ................ replaces
25 26 27 28 29 30 |
# File 'lib/insika/secret_masking.rb', line 25 def reconcile(incoming, existing) return existing if incoming.nil? || incoming == SENTINEL s = incoming.to_s s.empty? ? nil : s end |