diff --git a/src/Internal/Config/Log.elm b/src/Internal/Config/Log.elm new file mode 100644 index 0000000..c591ec0 --- /dev/null +++ b/src/Internal/Config/Log.elm @@ -0,0 +1,54 @@ +module Internal.Config.Log exposing (caughtError, debug, error, info, securityWarn, warn) +{-| # Logs + +The logs module exposes various log types that can be used to indicate logs. +This helps users filter for the logs that they care about. + +The logs are encoded as strings as to allow the addition of new log types +without triggering a major update. + +@docs caughtError, debug, error, info, securityWarn, warn +-} + +{-| A caught error is an error that has been caught elsewhere in the code, hence +functioning as a secondary debug channel. +-} +caughtError : String +caughtError = "caught-error" + +{-| Debug logs are logs that can be used to debug API interactions. +-} +debug : String +debug = "debug" + +{-| Error strings indicate that something unexpected has happened. As a result, +something has stopped working. +-} +error : String +error = "error" + +{-| Info contains relevant info for the user +-} +info : String +info = "info" + +{-| Security warnings are warnings that contain red flags. + +Of course, the Elm SDK is not aware of any security vulnerabilities that it +contains, but it can raise a user's attention to suspicious situations. + +For example, if the homeserver returns room ids that do not look like usernames +at all, the homeserver can raise a security warning, which indicates that: + +1. The homeserver might be bugged +2. The Elm SDK might be severaly outdated +3. The homeserver might be compromised and/or trying to attack the Elm SDK +-} +securityWarn : String +securityWarn = "security-warn" + +{-| Warning logs are logs that are unusual, but that can be dealt with. Warnings +are debug logs that are out of the ordinary. +-} +warn : String +warn = "warn" diff --git a/src/Internal/Tools/Decode.elm b/src/Internal/Tools/Decode.elm new file mode 100644 index 0000000..7948e91 --- /dev/null +++ b/src/Internal/Tools/Decode.elm @@ -0,0 +1,19 @@ +module Internal.Tools.Decode exposing (Decoder) +{-| # Advanced security Json.Decode + +This module extends the standard JSON encode / decode library for security +measures. Most Elm libraries do not access an API this often without insight +for the user, and hence this module aims to offer the user more insight into +what is going on. + +Additionally, the decoder will warn for suspicious values, and provide helpful +errors when the JSON fails to decode. + +## Primitives + +@docs Decoder +-} + +import Json.Decode as D + +type Decoder a = D.Decoder { value : a, messages : List String } \ No newline at end of file