diff options
| author | LLLL Colonq <llll@colonq> | 2024-08-08 21:52:29 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2024-08-08 21:52:29 -0400 |
| commit | 31d0954b9e51a0ca9071a92637e3a2e86660fe3e (patch) | |
| tree | b8cfa0aecb709991c9ca8a9fca572814b74dac74 /fig-frontend-client/src/Auth.purs | |
| parent | 2482292d033013ff37bbd4cdac00632b3dc70323 (diff) | |
Auth for frontend
Diffstat (limited to 'fig-frontend-client/src/Auth.purs')
| -rw-r--r-- | fig-frontend-client/src/Auth.purs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fig-frontend-client/src/Auth.purs b/fig-frontend-client/src/Auth.purs new file mode 100644 index 0000000..2a53629 --- /dev/null +++ b/fig-frontend-client/src/Auth.purs @@ -0,0 +1,29 @@ +module Auth where + +import Prelude + +import Config (authRedirectURL, clientID) +import Data.Array (fold) +import Data.Maybe (Maybe(..)) +import Data.Tuple (Tuple(..)) +import Effect (Effect) +import Effect.Class (class MonadEffect, liftEffect) + +foreign import _startTwitchAuth :: String -> String -> Effect Unit +startTwitchAuth :: forall m. MonadEffect m => m Unit +startTwitchAuth = liftEffect $ _startTwitchAuth clientID authRedirectURL + +type AuthInfo = Tuple String String +foreign import _getToken :: forall a. (a -> Maybe a) -> Maybe a -> (a -> a -> Tuple a a) -> Effect (Maybe (Tuple String String)) +getToken :: forall m. MonadEffect m => m (Maybe AuthInfo) +getToken = liftEffect $ _getToken Just Nothing Tuple + +authHeader :: AuthInfo -> String +authHeader (Tuple t n) = + fold + [ "FIG-TWITCH token=\"" + , t + , "\", nonce=\"" + , n + , "\"" + ] |
