-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathMLS.hs
More file actions
171 lines (165 loc) · 6.41 KB
/
Copy pathMLS.hs
File metadata and controls
171 lines (165 loc) · 6.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.
module Wire.API.Routes.Public.Galley.MLS where
import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.OpenApi qualified as S
import Data.Schema
import Imports
import Servant
import Servant.OpenApi.Internal.Orphans ()
import Wire.API.Conversation.Role
import Wire.API.Error
import Wire.API.Error.Galley
import Wire.API.MLS.CommitBundle
import Wire.API.MLS.Epoch
import Wire.API.MLS.Group
import Wire.API.MLS.Keys
import Wire.API.MLS.Message
import Wire.API.MLS.Serialisation
import Wire.API.MLS.Servant
import Wire.API.Routes.MultiVerb
import Wire.API.Routes.Named
import Wire.API.Routes.Public
import Wire.API.Routes.Version
import Wire.Arbitrary
data MLSReset = MLSReset
{ groupId :: GroupId,
epoch :: Epoch
}
deriving (Eq, Show, Generic)
deriving (FromJSON, ToJSON, S.ToSchema) via Schema MLSReset
deriving (Arbitrary) via (GenericUniform MLSReset)
instance ToSchema MLSReset where
schema =
object "MLSReset" $
MLSReset
<$> (.groupId) .= field "group_id" schema
<*> (.epoch) .= field "epoch" schema
type MLSMessagingAPI =
Named
"mls-message"
( Summary "Post an MLS message"
:> From 'V5
:> CanThrow 'ConvAccessDenied
:> CanThrow 'ConvMemberNotFound
:> CanThrow 'ConvNotFound
:> CanThrow 'LegalHoldNotEnabled
:> CanThrow 'MissingLegalholdConsent
:> CanThrow 'MLSClientMismatch
:> CanThrow 'MLSClientSenderUserMismatch
:> CanThrow 'MLSCommitMissingReferences
:> CanThrow 'MLSGroupConversationMismatch
:> CanThrow 'MLSInvalidLeafNodeIndex
:> CanThrow 'MLSNotEnabled
:> CanThrow 'MLSProposalNotFound
:> CanThrow 'MLSProtocolErrorTag
:> CanThrow 'MLSSelfRemovalNotAllowed
:> CanThrow 'MLSStaleMessage
:> CanThrow 'MLSSubConvClientNotInParent
:> CanThrow 'MLSUnsupportedMessage
:> CanThrow 'MLSUnsupportedProposal
:> CanThrow MLSProposalFailure
:> CanThrow NonFederatingBackends
:> CanThrow UnreachableBackends
:> CanThrow 'MLSInvalidLeafNodeSignature
:> "messages"
:> ZLocalUser
:> ZClient
:> ZConn
:> ReqBody '[MLS] (RawMLS Message)
:> MultiVerb1 'POST '[JSON] (Respond 201 "Message sent" MLSMessageSendingStatus)
)
:<|> Named
"mls-commit-bundle"
( Summary "Post a MLS CommitBundle"
:> From V5
:> CanThrow ConvAccessDenied
:> CanThrow ConvMemberNotFound
:> CanThrow ConvNotFound
:> CanThrow LegalHoldNotEnabled
:> CanThrow MissingLegalholdConsent
:> CanThrow MLSClientMismatch
:> CanThrow MLSClientSenderUserMismatch
:> CanThrow MLSCommitMissingReferences
:> CanThrow MLSGroupConversationMismatch
:> CanThrow MLSInvalidLeafNodeIndex
:> CanThrow MLSNotEnabled
:> CanThrow MLSProposalNotFound
:> CanThrow MLSProtocolErrorTag
:> CanThrow MLSSelfRemovalNotAllowed
:> CanThrow MLSStaleMessage
:> CanThrow MLSSubConvClientNotInParent
:> CanThrow MLSUnsupportedMessage
:> CanThrow MLSUnsupportedProposal
:> CanThrow MLSWelcomeMismatch
:> CanThrow MLSLegalholdIncompatible
:> CanThrow MLSProposalFailure
:> CanThrow MLSIdentityMismatch
:> CanThrow MLSGroupInfoMismatch
:> CanThrow NonFederatingBackends
:> CanThrow UnreachableBackends
:> CanThrow GroupIdVersionNotSupported
:> CanThrow MLSInvalidLeafNodeSignature
:> "commit-bundles"
:> ZLocalUser
:> ZClient
:> ZConn
:> ReqBody '[MLS] (RawMLS CommitBundle)
:> MultiVerb1 POST '[JSON] (Respond 201 "Commit accepted and forwarded" MLSMessageSendingStatus)
)
:<|> Named
"mls-public-keys"
( Summary "Get public keys used by the backend to sign external proposals"
:> Description
"The format of the returned key is determined by the `format` query parameter:\n\
\ - raw (default): base64-encoded raw public keys\n\
\ - jwk: keys are nested objects in JWK format."
:> From 'V5
:> CanThrow 'MLSNotEnabled
:> "public-keys"
:> ZLocalUser
:> QueryParam "format" MLSPublicKeyFormat
:> MultiVerb1
'GET
'[JSON]
( Respond
200
"Public keys"
(MLSKeysByPurpose (MLSKeys SomeKey))
)
)
:<|> Named
"mls-reset-conversation"
( Summary "Reset an MLS conversation to epoch 0"
:> "reset-conversation"
:> ZLocalUser
:> ReqBody '[JSON] MLSReset
:> CanThrow 'MLSNotEnabled
:> CanThrow 'MLSStaleMessage
:> CanThrow 'ConvAccessDenied
:> CanThrow 'ConvNotFound
:> CanThrow 'InvalidOperation
:> CanThrow ('ActionDenied LeaveConversation)
:> CanThrow 'MLSFederatedResetNotSupported
:> CanThrow 'GroupIdVersionNotSupported
:> CanThrow MLSProtocolErrorTag
:> MultiVerb1
'POST
'[JSON]
(RespondEmpty 200 "Conversation reset")
)
type MLSAPI = LiftNamed ("mls" :> MLSMessagingAPI)