Current section
Files
Jump to
Current section
Files
src/cowl@unsafe.erl
-module(cowl@unsafe).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/cowl/unsafe.gleam").
-export([reveal/1, tap_raw/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/cowl/unsafe.gleam", 23).
?DOC(
" Extract the raw value from a secret.\n"
"\n"
" Once the value is in a plain variable the compiler can no longer protect\n"
" it. Keep the scope as small as possible and never assign it to a field\n"
" that outlives the current function.\n"
"\n"
" Prefer `cowl.with_secret` for all production use.\n"
).
-spec reveal(cowl:secret(DXP)) -> DXP.
reveal(Secret) ->
cowl:with_secret(Secret, fun(V) -> V end).
-file("src/cowl/unsafe.gleam", 34).
?DOC(
" Run `f` on the raw value for its side effects; return the original secret.\n"
"\n"
" ⚠️ Passing a logging or print function here will expose the secret in\n"
" plain text. This function exists for low-level debugging and test\n"
" instrumentation only.\n"
"\n"
" For safe side effects use `cowl.tap_masked` instead.\n"
).
-spec tap_raw(cowl:secret(DXR), fun((DXR) -> any())) -> cowl:secret(DXR).
tap_raw(Secret, F) ->
cowl:with_secret(
Secret,
fun(V) ->
_ = F(V),
Secret
end
).