← all modules
Std.Auth
Std.Auth
Std.Auth — authentication helpers (Layer 3 Sky source).
Types
type AccessState = Active | Revoked | Disabled
Values
disableUser : Db -> String -> Task Error ()
`disableUser db userId` — BAN the user: sets `users.disabled_at`. The
enableUser : Db -> String -> Task Error ()
`enableUser db userId` — clear a `disableUser` ban. (Independent of
hashPassword : String -> Result Error String
Bcrypt hash with default cost (12).
hashPasswordCost : String -> Int -> Result Error String
Bcrypt hash with explicit cost — `hashPasswordCost password
isDisabled : Db -> String -> Task Error Bool
`isDisabled db userId` — True iff the user is banned (`disableUser`).
isRevoked : Db -> String -> Int -> Task Error Bool
`isRevoked db userId issuedAt` — True iff a token/session issued at
login : Db -> String -> String -> Task Error Int
`login db email password` — authenticate. Returns the user
passwordStrength : String -> Result Error String
Categorical password strength: "weak" / "fair" / "strong".
register : Db -> String -> String -> Task Error Int
`register db email password` — create a new user. Returns
revokeUser : Db -> String -> Task Error ()
`revokeUser db userId` — invalidate the user's EXISTING sessions/tokens
setRole : Db -> Int -> String -> Task Error ()
`setRole db userId role` — assign a role to the user.
setSlidingCookie : Request -> String -> Response -> Response
`setSlidingCookie req token resp` — set the sliding auth cookie on a
signSlidingToken : String -> a -> { windowSeconds : Int , maxLifetimeSeconds : Int } -> Result Error String
`signSlidingToken secret claims { windowSeconds, maxLifetimeSeconds }` —
signToken : String -> a -> Int -> Result Error String
`signToken secret claims expirySeconds` — produce a signed
signTokenWithClaims : Jwt.Algorithm -> Jwt.Claims -> Result Error String
`signTokenWithClaims alg claims` — typed-builder alternative
userAccessState : Db -> String -> Int -> Task Error AccessState
`userAccessState db userId issuedAt` — the combined verdict, with
verifyPassword : String -> String -> Result Error Bool
`verifyPassword password hash` — constant-time bcrypt verify.
verifyToken : String -> String -> Result Error a
`verifyToken secret token` — verify + decode a JWT.
verifyTokenWithAlgorithm : Jwt.Algorithm -> Int -> String -> Result Error String
`verifyTokenWithAlgorithm alg now token` — typed-builder