Skip to content

Commit b8aea83

Browse files
committed
Adding additional interface documentation
1 parent fe29b0e commit b8aea83

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

credentials/src/Credentials/Types.hs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ newtype Cipher = Cipher ByteString deriving (ToByteString)
8686
-- | An encrypted secret.
8787
data Encrypted = Encrypted !Nonce !Key !Cipher !HMAC256
8888

89+
-- | Whether the setup action resulting in any setup actions being performed.
8990
data Setup
9091
= Created
9192
| Exists
@@ -109,18 +110,38 @@ class Monad m => Storage m where
109110
-- | A reference to the storage engine, such as a table or bucket name.
110111
data Ref m :: *
111112

113+
-- | The input (inserted) type.
112114
type In m :: *
115+
116+
-- | The output (selected) type.
113117
type Out m :: *
114118

115-
layer :: m a -> Layer m a
119+
-- | Unwrap the storage to its inner monad.
120+
layer :: m a -> Layer m a
121+
122+
-- | Setup a new storage layer.
123+
-- Calling 'setup' with a non-unique 'Ref' _must_ result in a noop.
124+
setup :: Ref m -> m Setup
125+
126+
-- | Teardown and destroy an existing storage layer.
127+
-- Calling 'setup' with a non-existing 'Ref' _must_ result in a noop.
128+
teardown :: Ref m -> m ()
116129

117-
setup :: Ref m -> m Setup
118-
teardown :: Ref m -> m ()
130+
-- | Returning a paginated 'Source' of stored credentials and their
131+
-- respective list of 'Revision's.
119132
revisions :: Ref m -> Source m (Name, NonEmpty Revision)
120133

121-
delete :: Name -> Maybe Revision -> Ref m -> m ()
122-
insert :: KeyId -> Context -> Name -> In m -> Ref m -> m Revision
123-
select :: Context -> Name -> Maybe Revision -> Ref m -> m (Out m, Revision)
134+
-- | Delete a specific credential 'Name'. If no 'Revision' is specified,
135+
-- the storage layer _must_ delete all revisions.
136+
delete :: Name -> Maybe Revision -> Ref m -> m ()
137+
138+
-- | Insert a new credential, using the given 'KeyId' and 'Context'
139+
-- for encryption.
140+
insert :: KeyId -> Context -> Name -> In m -> Ref m -> m Revision
141+
142+
-- | Select an existing credential, supplying the 'Context' used during encryption.
143+
-- If no 'Revision' is specified, the storage layer should return the latest revision.
144+
select :: Context -> Name -> Maybe Revision -> Ref m -> m (Out m, Revision)
124145

125146
data CredentialError
126147
= MasterKeyMissing KeyId (Maybe Text)

0 commit comments

Comments
 (0)