From b3479cf2c98d81f69f156b3d8a1568f887ddaf61 Mon Sep 17 00:00:00 2001 From: Bram Date: Mon, 18 Dec 2023 05:51:24 +0100 Subject: [PATCH] Add leaking values --- elm.json | 1 + src/Internal/Config/Leaks.elm | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/Internal/Config/Leaks.elm diff --git a/elm.json b/elm.json index befcf14..168fd69 100644 --- a/elm.json +++ b/elm.json @@ -8,6 +8,7 @@ "Matrix", "Matrix.Settings", "Internal.Config.Default", + "Internal.Config.Leaks", "Internal.Config.Text", "Internal.Tools.Decode", "Internal.Tools.Encode", diff --git a/src/Internal/Config/Leaks.elm b/src/Internal/Config/Leaks.elm new file mode 100644 index 0000000..c71b81c --- /dev/null +++ b/src/Internal/Config/Leaks.elm @@ -0,0 +1,39 @@ +module Internal.Config.Leaks exposing (accessToken) + +{-| + + +# Leaks module + +The Elm compiler is quite picky when it comes to handling edge cases, which may +occasionally result in requiring us to insert values in impossible states. + +This module offers placeholders for those times. The placeholder values are +intentionally called "leaks", because they should be used carefully: a wrongful +implementation might cause unexpected behaviour, vulnerabilities or even +security risks! + +You should not use this module unless you know what you're doing. That is: + + - By exclusively using leaking values in opaque types so a user cannot + accidentally reach an impossible state + - By exclusively using leaking values in cases where the compiler is the only + reason that the leaking value needs to be used + - By exclusively using leaking values if there is no way to circumvent the + compiler with a reasonable method. + +One such example would be to turn an `Maybe Int` into an `Int` if you already +know 100% sure that the value isn't `Nothing`. + + Just 5 |> Maybe.withDefault Leaks.number + +@docs accessToken + +-} + + +{-| Placeholder access token. +-} +accessToken : String +accessToken = + "elm-sdk-placeholder-access-token-leaks"