- [C](https://github.com/rescrv/libmacaroons)
- [Java](https://github.com/nitram509/jmacaroons)
- [Python](https://github.com/ecordell/pymacaroons)
+- [Node.js](https://github.com/nitram509/macaroons.js)
TODO
====
, Caveat
, Key
, Location
+ , Sig
-- * Accessing functions
-- ** Macaroons
, location
where
derivedKey = toBytes (hmac "macaroons-key-generator" secret :: HMAC SHA256)
+-- | Caveat target location
caveatLoc :: Caveat -> Location
caveatLoc = cl
+-- | Caveat identifier
caveatId :: Caveat -> Key
caveatId = cid
+-- | Caveat verification identifier
caveatVId :: Caveat -> Key
caveatVId = vid
+-- | Inspect a macaroon's contents. For debugging purposes.
inspect :: Macaroon -> String
inspect = show
+-- | Serialize a macaroon in an URL-safe Base64 encoding
serialize :: Macaroon -> BS.ByteString
serialize m = B8.filter (/= '=') . B64.encode $ packets
where
-- |Type alias for Macaroons and Caveat keys and identifiers
type Key = BS.ByteString
--- |Type alias For Macaroons and Caveat locations
+-- |Type alias for Macaroons and Caveat locations
type Location = BS.ByteString
+-- |Type alias for Macaroons signatures
type Sig = BS.ByteString
-- | Main structure of a macaroon
-- ^ Macaroon HMAC signature
} deriving (Eq)
+-- | show instance conforming to the @inspect@ "specification"
instance Show Macaroon where
-- We use intercalate because unlines would add a trailing newline
show (MkMacaroon l i c s) = intercalate "\n" [
, "signature " ++ B8.unpack (hex s)
]
+-- | NFData instance for use in the benchmark
instance NFData Macaroon where
rnf (MkMacaroon loc ident cavs sig) = rnf loc `seq` rnf ident `seq` rnf cavs `seq` rnf sig
} deriving (Eq)
+-- | show instance conforming to the @inspect@ "specification"
instance Show Caveat where
show (MkCaveat c v l) | v == BS.empty = "cid " ++ B8.unpack c
| otherwise = unlines [ "cid " ++ B8.unpack c
]
+-- | NFData instance for use in the benchmark
instance NFData Caveat where
rnf (MkCaveat cid vid cl) = rnf cid `seq` rnf vid `seq` rnf cl
-
+-- | Primitive to add a First or Third party caveat to a macaroon
+-- For internal use only
addCaveat :: Location
-> Key
-> Key