-
Notifications
You must be signed in to change notification settings - Fork 329
/
Copy pathBrig.hs
1911 lines (1856 loc) · 70.5 KB
/
Brig.hs
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <[email protected]>
--
-- 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.Brig where
import Control.Lens ((?~))
import Data.Aeson qualified as A (FromJSON, ToJSON, Value)
import Data.ByteString.Conversion
import Data.Code (Timeout)
import Data.CommaSeparatedList (CommaSeparatedList)
import Data.Domain
import Data.Handle
import Data.Id as Id
import Data.Misc
import Data.Nonce (Nonce)
import Data.OpenApi hiding (Contact, Header, Schema, ToSchema)
import Data.OpenApi qualified as S
import Data.Qualified (Qualified (..))
import Data.Range
import Data.SOP
import Data.Schema as Schema
import Generics.SOP qualified as GSOP
import Imports hiding (head)
import Network.Wai.Utilities
import Servant (JSON)
import Servant hiding (Handler, JSON, addHeader, respond)
import Servant.OpenApi.Internal.Orphans ()
import Wire.API.Call.Config (RTCConfiguration)
import Wire.API.Connection hiding (MissingLegalholdConsent)
import Wire.API.Deprecated
import Wire.API.Error
import Wire.API.Error.Brig
import Wire.API.Error.Empty
import Wire.API.MLS.CipherSuite
import Wire.API.MLS.KeyPackage
import Wire.API.MLS.Servant
import Wire.API.OAuth
import Wire.API.Properties (PropertyKey, PropertyKeysAndValues, RawPropertyValue)
import Wire.API.Routes.API
import Wire.API.Routes.Bearer
import Wire.API.Routes.Cookies
import Wire.API.Routes.MultiVerb
import Wire.API.Routes.Named
import Wire.API.Routes.Public
import Wire.API.Routes.Public.Brig.Bot (BotAPI)
import Wire.API.Routes.Public.Brig.DomainVerification
import Wire.API.Routes.Public.Brig.OAuth (OAuthAPI)
import Wire.API.Routes.Public.Brig.Provider (ProviderAPI)
import Wire.API.Routes.Public.Brig.Services (ServicesAPI)
import Wire.API.Routes.Public.Util
import Wire.API.Routes.QualifiedCapture
import Wire.API.Routes.Version
import Wire.API.Routes.Versioned
import Wire.API.SystemSettings
import Wire.API.Team.Invitation
import Wire.API.Team.Size
import Wire.API.User hiding (NoIdentity)
import Wire.API.User.Activation
import Wire.API.User.Auth
import Wire.API.User.Client
import Wire.API.User.Client.DPoPAccessToken
import Wire.API.User.Client.Prekey
import Wire.API.User.Handle
import Wire.API.User.Password (CompletePasswordReset, NewPasswordReset, PasswordReset, PasswordResetKey)
import Wire.API.User.RichInfo (RichInfoAssocList)
import Wire.API.User.Search (Contact, PagingState, RoleFilter, SearchResult, TeamContact, TeamUserSearchSortBy, TeamUserSearchSortOrder)
import Wire.API.UserMap
type BrigAPI =
UserAPI
:<|> SelfAPI
:<|> AccountAPI
:<|> ClientAPI
:<|> PrekeyAPI
:<|> UserClientAPI
:<|> ConnectionAPI
:<|> PropertiesAPI
:<|> MLSAPI
:<|> UserHandleAPI
:<|> SearchAPI
:<|> AuthAPI
:<|> CallingAPI
:<|> TeamsAPI
:<|> SystemSettingsAPI
:<|> OAuthAPI
:<|> BotAPI
:<|> ServicesAPI
:<|> ProviderAPI
:<|> DomainVerificationAPI
:<|> DomainVerificationTeamAPI
:<|> DomainVerificationChallengeAPI
data BrigAPITag
instance ServiceAPI BrigAPITag v where
type ServiceAPIRoutes BrigAPITag = BrigAPI
-------------------------------------------------------------------------------
-- User API
type MaxUsersForListClientsBulk = 500
type GetUserVerb =
MultiVerb
'GET
'[JSON]
'[ ErrorResponse 'UserNotFound,
Respond 200 "User found" UserProfile
]
(Maybe UserProfile)
type CaptureUserId name = Capture' '[Description "User Id"] name UserId
type QualifiedCaptureUserId name = QualifiedCapture' '[Description "User Id"] name UserId
type CaptureClientId name = Capture' '[Description "ClientId"] name ClientId
type DeleteSelfResponses =
'[ RespondEmpty 200 "Deletion is initiated.",
RespondWithDeletionCodeTimeout
]
newtype RespondWithDeletionCodeTimeout
= RespondWithDeletionCodeTimeout
(Respond 202 "Deletion is pending verification with a code." DeletionCodeTimeout)
deriving (IsResponse '[JSON], IsSwaggerResponse)
type instance ResponseType RespondWithDeletionCodeTimeout = DeletionCodeTimeout
instance AsUnion DeleteSelfResponses (Maybe Timeout) where
toUnion (Just t) = S (Z (I (DeletionCodeTimeout t)))
toUnion Nothing = Z (I ())
fromUnion (Z (I ())) = Nothing
fromUnion (S (Z (I (DeletionCodeTimeout t)))) = Just t
fromUnion (S (S x)) = case x of {}
type ConnectionUpdateResponses = UpdateResponses "Connection unchanged" "Connection updated" UserConnection
type UserAPI =
-- See Note [ephemeral user sideeffect]
Named
"get-user-unqualified"
( Summary "Get a user by UserId"
:> Until 'V2
:> ZLocalUser
:> "users"
:> CaptureUserId "uid"
:> GetUserVerb
)
:<|>
-- See Note [ephemeral user sideeffect]
Named
"get-user-qualified"
( Summary "Get a user by Domain and UserId"
:> ZLocalUser
:> "users"
:> QualifiedCaptureUserId "uid"
:> GetUserVerb
)
:<|> Named
"update-user-email"
( Summary "Resend email address validation email."
:> Description "If the user has a pending email validation, the validation email will be resent."
:> ZUser
:> "users"
:> CaptureUserId "uid"
:> "email"
:> ReqBody '[JSON] EmailUpdate
:> Put '[JSON] ()
)
:<|> Named
"get-handle-info-unqualified"
( Summary "(deprecated, use /search/contacts) Get information on a user handle"
:> Until 'V2
:> ZUser
:> "users"
:> "handles"
:> Capture' '[Description "The user handle"] "handle" Handle
:> MultiVerb
'GET
'[JSON]
'[ ErrorResponse 'HandleNotFound,
Respond 200 "User found" UserHandleInfo
]
(Maybe UserHandleInfo)
)
:<|> Named
"get-user-by-handle-qualified"
( Summary "(deprecated, use /search/contacts) Get information on a user handle"
:> Until 'V2
:> ZUser
:> "users"
:> "by-handle"
:> QualifiedCapture' '[Description "The user handle"] "handle" Handle
:> MultiVerb
'GET
'[JSON]
'[ ErrorResponse 'HandleNotFound,
Respond 200 "User found" UserProfile
]
(Maybe UserProfile)
)
:<|>
-- See Note [ephemeral user sideeffect]
Named
"list-users-by-unqualified-ids-or-handles"
( Summary "List users (deprecated)"
:> Until 'V2
:> Description "The 'ids' and 'handles' parameters are mutually exclusive."
:> ZUser
:> "users"
:> QueryParam' [Optional, Strict, Description "User IDs of users to fetch"] "ids" (CommaSeparatedList UserId)
:> QueryParam' [Optional, Strict, Description "Handles of users to fetch, min 1 and max 4 (the check for handles is rather expensive)"] "handles" (Range 1 4 (CommaSeparatedList Handle))
:> Get '[JSON] [UserProfile]
)
:<|> Named
"list-users-by-ids-or-handles"
( Summary "List users"
:> Description "The 'qualified_ids' and 'qualified_handles' parameters are mutually exclusive."
:> ZUser
:> From 'V4
:> "list-users"
:> ReqBody '[JSON] ListUsersQuery
:> Post '[JSON] ListUsersById
)
:<|>
-- See Note [ephemeral user sideeffect]
Named
"list-users-by-ids-or-handles@V3"
( Summary "List users"
:> Description "The 'qualified_ids' and 'qualified_handles' parameters are mutually exclusive."
:> ZUser
:> Until 'V4
:> "list-users"
:> ReqBody '[JSON] ListUsersQuery
:> Post '[JSON] [UserProfile]
)
:<|> Named
"send-verification-code"
( Summary "Send a verification code to a given email address."
:> "verification-code"
:> "send"
:> ReqBody '[JSON] SendVerificationCode
:> MultiVerb 'POST '[JSON] '[RespondEmpty 200 "Verification code sent."] ()
)
:<|> Named
"get-rich-info"
( Summary "Get a user's rich info"
:> CanThrow 'InsufficientTeamPermissions
:> ZLocalUser
:> "users"
:> CaptureUserId "uid"
:> "rich-info"
:> MultiVerb
'GET
'[JSON]
'[Respond 200 "Rich info about the user" RichInfoAssocList]
RichInfoAssocList
)
:<|> Named
"get-supported-protocols"
( Summary "Get a user's supported protocols"
:> From 'V5
:> ZLocalUser
:> "users"
:> QualifiedCaptureUserId "uid"
:> "supported-protocols"
:> MultiVerb1
'GET
'[JSON]
(Respond 200 "Protocols supported by the user" (Set BaseProtocolTag))
)
type SelfAPI =
Named
"get-self"
( Summary "Get your own profile"
:> DescriptionOAuthScope 'ReadSelf
:> ZLocalUser
:> "self"
:> Get '[JSON] SelfProfile
)
:<|>
-- This endpoint can lead to the following events being sent:
-- - UserDeleted event to contacts of self
-- - MemberLeave event to members for all conversations the user was in (via galley)
Named
"delete-self"
( Summary "Initiate account deletion."
:> Description
"if the account has a verified identity, a verification \
\code is sent and needs to be confirmed to authorise the \
\deletion. if the account has no verified identity but a \
\password, it must be provided. if password is correct, or if neither \
\a verified identity nor a password exists, account deletion \
\is scheduled immediately."
:> CanThrow 'InvalidUser
:> CanThrow 'InvalidCode
:> CanThrow 'BadCredentials
:> CanThrow 'MissingAuth
:> CanThrow 'DeleteCodePending
:> CanThrow 'OwnerDeletingSelf
:> ZLocalUser
:> "self"
:> ReqBody '[JSON] DeleteUser
:> MultiVerb 'DELETE '[JSON] DeleteSelfResponses (Maybe Timeout)
)
:<|>
-- This endpoint can lead to the following events being sent:
-- - UserUpdated event to contacts of self
Named
"put-self"
( Summary "Update your profile."
:> ZLocalUser
:> ZConn
:> "self"
:> ReqBody '[JSON] UserUpdate
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "User updated")
)
:<|> Named
"change-phone"
( Summary "Change your phone number."
:> Until 'V6
:> ZUser
:> ZConn
:> "self"
:> "phone"
:> ReqBody '[JSON] PhoneUpdate
:> MultiVerb 'PUT '[JSON] ChangePhoneResponses (Maybe ChangePhoneError)
)
:<|>
-- This endpoint can lead to the following events being sent:
-- - UserIdentityRemoved event to self
Named
"remove-phone"
( Summary "Remove your phone number."
:> Until 'V6
:> Description
"Your phone number can only be removed if you also have an \
\email address and a password."
:> ZUser
:> "self"
:> "phone"
:> MultiVerb 'DELETE '[JSON] RemoveIdentityResponses (Maybe RemoveIdentityError)
)
:<|>
-- This endpoint can lead to the following events being sent:
-- - UserIdentityRemoved event to self
Named
"remove-email"
( Summary "Remove your email address."
:> Description
"Your email address can only be removed if you also have a \
\phone number."
:> ZLocalUser
:> "self"
:> "email"
:> MultiVerb 'DELETE '[JSON] RemoveIdentityResponses (Maybe RemoveIdentityError)
)
:<|> Named
"check-password-exists"
( Summary "Check that your password is set."
:> ZUser
:> "self"
:> "password"
:> MultiVerb
'HEAD
'()
'[ RespondEmpty 404 "Password is not set",
RespondEmpty 200 "Password is set"
]
Bool
)
:<|> Named
"change-password"
( Summary "Change your password."
:> ZUser
:> "self"
:> "password"
:> ReqBody '[JSON] PasswordChange
:> MultiVerb 'PUT '[JSON] ChangePasswordResponses (Maybe ChangePasswordError)
)
:<|> Named
"change-locale"
( Summary "Change your locale."
:> ZLocalUser
:> ZConn
:> "self"
:> "locale"
:> ReqBody '[JSON] LocaleUpdate
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "Local Changed")
)
:<|> Named
"change-handle"
( Summary "Change your handle."
:> ZLocalUser
:> ZConn
:> "self"
:> "handle"
:> ReqBody '[JSON] HandleUpdate
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "Handle Changed")
)
:<|> Named
"change-supported-protocols"
( Summary "Change your supported protocols"
:> From 'V5
:> CanThrow 'MlsRemovalNotAllowed
:> ZLocalUser
:> ZConn
:> "self"
:> "supported-protocols"
:> ReqBody '[JSON] SupportedProtocolUpdate
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "Supported protocols changed")
)
type UserHandleAPI =
Named
"check-user-handles@v6"
( Summary "Check availability of user handles"
:> Until V7
:> ZUser
:> "users"
:> "handles"
:> ReqBody '[JSON] CheckHandles
:> MultiVerb
'POST
'[JSON]
'[Respond 200 "List of free handles" [Handle]]
[Handle]
)
:<|> Named
"check-user-handles"
( Summary "Check availability of user handles"
:> From V7
:> ZUser
:> "handles"
:> ReqBody '[JSON] CheckHandles
:> MultiVerb
'POST
'[JSON]
'[Respond 200 "List of free handles" [Handle]]
[Handle]
)
:<|> Named
"check-user-handle@v6"
( Summary "Check whether a user handle can be taken"
:> Until V7
:> CanThrow 'InvalidHandle
:> CanThrow 'HandleNotFound
:> ZUser
:> "users"
:> "handles"
:> Capture "handle" Text
:> MultiVerb
'HEAD
'[JSON]
'[Respond 200 "Handle is taken" ()]
()
)
:<|> Named
"check-user-handle"
( Summary "Check whether a user handle can be taken"
:> From V7
:> CanThrow 'InvalidHandle
:> CanThrow 'HandleNotFound
:> ZUser
:> "handles"
:> Capture "handle" Text
:> MultiVerb
'HEAD
'[JSON]
'[Respond 200 "Handle is taken" ()]
()
)
type AccountAPI =
Named
"upgrade-personal-to-team"
( Summary "Upgrade personal user to team owner"
:> "upgrade-personal-to-team"
:> ZLocalUser
:> ReqBody '[JSON] BindingNewTeamUser
:> MultiVerb
'POST
'[JSON]
UpgradePersonalToTeamResponses
(Either UpgradePersonalToTeamError CreateUserTeam)
)
:<|>
-- docs/reference/user/registration.md {#RefRegistration}
--
-- This endpoint can lead to the following events being sent:
-- - UserActivated event to created user, if it is a team invitation or user has an SSO ID
-- - UserIdentityUpdated event to created user, if email code or phone code is provided
Named
"register"
( Summary "Register a new user."
:> Description
"If the environment where the registration takes \
\place is private and a registered email address \
\is not whitelisted, a 403 error is returned."
:> "register"
:> Header' '[Required, Strict] "X-Forwarded-For" IpAddr
:> ReqBody '[JSON] NewUserPublic
:> MultiVerb 'POST '[JSON] RegisterResponses (Either RegisterError RegisterSuccess)
)
-- This endpoint can lead to the following events being sent:
-- UserDeleted event to contacts of deleted user
-- MemberLeave event to members for all conversations the user was in (via galley)
:<|> Named
"verify-delete"
( Summary "Verify account deletion with a code."
:> CanThrow 'InvalidCode
:> "delete"
:> ReqBody '[JSON] VerifyDeleteUser
:> MultiVerb 'POST '[JSON] '[RespondEmpty 200 "Deletion is initiated."] ()
)
-- This endpoint can lead to the following events being sent:
-- - UserActivated event to the user, if account gets activated
-- - UserIdentityUpdated event to the user, if email or phone get activated
:<|> Named
"get-activate"
( Summary "Activate (i.e. confirm) an email address."
:> Description "See also 'POST /activate' which has a larger feature set."
:> CanThrow 'UserKeyExists
:> CanThrow 'InvalidActivationCodeWrongUser
:> CanThrow 'InvalidActivationCodeWrongCode
:> CanThrow 'InvalidEmail
:> CanThrow 'InvalidPhone
:> "activate"
:> QueryParam' '[Required, Strict, Description "Activation key"] "key" ActivationKey
:> QueryParam' '[Required, Strict, Description "Activation code"] "code" ActivationCode
:> MultiVerb
'GET
'[JSON]
GetActivateResponse
ActivationRespWithStatus
)
-- docs/reference/user/activation.md {#RefActivationSubmit}
--
-- This endpoint can lead to the following events being sent:
-- - UserActivated event to the user, if account gets activated
-- - UserIdentityUpdated event to the user, if email or phone get activated
:<|> Named
"post-activate"
( Summary "Activate (i.e. confirm) an email address."
:> Description
"Activation only succeeds once and the number of \
\failed attempts for a valid key is limited."
:> CanThrow 'UserKeyExists
:> CanThrow 'InvalidActivationCodeWrongUser
:> CanThrow 'InvalidActivationCodeWrongCode
:> CanThrow 'InvalidEmail
:> CanThrow 'InvalidPhone
:> "activate"
:> ReqBody '[JSON] Activate
:> MultiVerb
'POST
'[JSON]
GetActivateResponse
ActivationRespWithStatus
)
-- docs/reference/user/activation.md {#RefActivationRequest}
:<|> Named
"post-activate-send"
( Summary "Send (or resend) an email activation code."
:> CanThrow 'UserKeyExists
:> CanThrow 'InvalidEmail
:> CanThrow 'BlacklistedEmail
:> CanThrow 'CustomerExtensionBlockedDomain
:> "activate"
:> "send"
:> ReqBody '[JSON] SendActivationCode
:> MultiVerb 'POST '[JSON] '[RespondEmpty 200 "Activation code sent."] ()
)
:<|> Named
"post-password-reset"
( Summary "Initiate a password reset."
:> "password-reset"
:> ReqBody '[JSON] NewPasswordReset
:> MultiVerb 'POST '[JSON] '[RespondEmpty 201 "Password reset code created and sent by email."] ()
)
:<|> Named
"post-password-reset-complete"
( Summary "Complete a password reset."
:> CanThrow 'InvalidPasswordResetCode
:> "password-reset"
:> "complete"
:> ReqBody '[JSON] CompletePasswordReset
:> MultiVerb 'POST '[JSON] '[RespondEmpty 200 "Password reset successful."] ()
)
:<|> Named
"post-password-reset-key-deprecated"
( Summary "Complete a password reset."
:> Deprecated
:> Until 'V8
:> CanThrow 'PasswordResetInProgress
:> CanThrow 'InvalidPasswordResetKey
:> CanThrow 'InvalidPasswordResetCode
:> CanThrow 'ResetPasswordMustDiffer
:> Description "DEPRECATED: Use 'POST /password-reset/complete'."
:> "password-reset"
:> Capture' '[Description "An opaque key for a pending password reset."] "key" PasswordResetKey
:> ReqBody '[JSON] PasswordReset
:> MultiVerb 'POST '[JSON] '[RespondEmpty 200 "Password reset successful."] ()
)
:<|> Named
"onboarding"
( Summary "Upload contacts and invoke matching."
:> Deprecated
:> Until 'V8
:> Description
"DEPRECATED: the feature has been turned off, the end-point does \
\nothing and always returns '{\"results\":[],\"auto-connects\":[]}'."
:> ZUser
:> "onboarding"
:> "v3"
:> ReqBody '[JSON] JsonValue
:> Post '[JSON] DeprecatedMatchingResult
)
newtype JsonValue = JsonValue {fromJsonValue :: A.Value}
deriving (A.ToJSON, A.FromJSON, S.ToSchema) via (Schema JsonValue)
instance ToSchema JsonValue where
schema = fromJsonValue .= (JsonValue <$> named "Body" jsonValue)
data DeprecatedMatchingResult = DeprecatedMatchingResult
deriving (A.ToJSON, A.FromJSON, S.ToSchema) via (Schema DeprecatedMatchingResult)
instance ToSchema DeprecatedMatchingResult where
schema =
objectWithDocModifier
"DeprecatedMatchingResult"
(S.deprecated ?~ True)
$ DeprecatedMatchingResult
<$ const []
.= field "results" (array (null_ @SwaggerDoc))
<* const []
.= field "auto-connects" (array (null_ @SwaggerDoc))
data ActivationRespWithStatus
= ActivationResp ActivationResponse
| ActivationRespDryRun
| ActivationRespPass
| ActivationRespSuccessNoIdent
deriving (Generic)
deriving (AsUnion GetActivateResponse) via GenericAsUnion GetActivateResponse ActivationRespWithStatus
instance GSOP.Generic ActivationRespWithStatus
type GetActivateResponse =
'[ Respond 200 "Activation successful." ActivationResponse,
RespondEmpty 200 "Activation successful. (Dry run)",
RespondEmpty 204 "A recent activation was already successful.",
RespondEmpty 200 "Activation successful."
]
type PrekeyAPI =
Named
"get-users-prekeys-client-unqualified"
( Summary "(deprecated) Get a prekey for a specific client of a user."
:> Until 'V2
:> ZUser
:> "users"
:> CaptureUserId "uid"
:> "prekeys"
:> CaptureClientId "client"
:> Get '[JSON] ClientPrekey
)
:<|> Named
"get-users-prekeys-client-qualified"
( Summary "Get a prekey for a specific client of a user."
:> ZUser
:> "users"
:> QualifiedCaptureUserId "uid"
:> "prekeys"
:> CaptureClientId "client"
:> Get '[JSON] ClientPrekey
)
:<|> Named
"get-users-prekey-bundle-unqualified"
( Summary "(deprecated) Get a prekey for each client of a user."
:> Until 'V2
:> ZUser
:> "users"
:> CaptureUserId "uid"
:> "prekeys"
:> Get '[JSON] PrekeyBundle
)
:<|> Named
"get-users-prekey-bundle-qualified"
( Summary "Get a prekey for each client of a user."
:> ZUser
:> "users"
:> QualifiedCaptureUserId "uid"
:> "prekeys"
:> Get '[JSON] PrekeyBundle
)
:<|> Named
"get-multi-user-prekey-bundle-unqualified"
( Summary
"(deprecated) Given a map of user IDs to client IDs return a prekey for each one."
:> Description "You can't request information for more users than maximum conversation size."
:> Until 'V2
:> ZUser
:> "users"
:> "prekeys"
:> ReqBody '[JSON] UserClients
:> Post '[JSON] UserClientPrekeyMap
)
:<|> Named
"get-multi-user-prekey-bundle-qualified@v3"
( Summary
"(deprecated) Given a map of user IDs to client IDs return a prekey for each one."
:> Description "You can't request information for more users than maximum conversation size."
:> ZUser
:> Until 'V4
:> "users"
:> "list-prekeys"
:> ReqBody '[JSON] QualifiedUserClients
:> Post '[JSON] QualifiedUserClientPrekeyMap
)
:<|> Named
"get-multi-user-prekey-bundle-qualified"
( Summary
"(deprecated) Given a map of user IDs to client IDs return a prekey for each one."
:> Description "You can't request information for more users than maximum conversation size."
:> ZUser
:> From 'V4
:> "users"
:> "list-prekeys"
:> ReqBody '[JSON] QualifiedUserClients
:> Post '[JSON] QualifiedUserClientPrekeyMapV4
)
-- User Client API ----------------------------------------------------
type ClientHeaders = '[DescHeader "Location" "Client ID" ClientId]
type UserClientAPI =
-- This endpoint can lead to the following events being sent:
-- - ClientAdded event to self
-- - ClientRemoved event to self, if removing old clients due to max number
Named
"add-client@v6"
( Summary "Register a new client"
:> Until 'V7
:> CanThrow 'TooManyClients
:> CanThrow 'MissingAuth
:> CanThrow 'MalformedPrekeys
:> CanThrow 'CodeAuthenticationFailed
:> CanThrow 'CodeAuthenticationRequired
:> ZLocalUser
:> ZConn
:> "clients"
:> VersionedReqBody 'V6 '[JSON] NewClient
:> MultiVerb1
'POST
'[JSON]
( WithHeaders
ClientHeaders
Client
(VersionedRespond 'V6 201 "Client registered" Client)
)
)
:<|> Named
"add-client@v7"
( Summary "Register a new client"
:> From 'V7
:> Until 'V8
:> CanThrow 'TooManyClients
:> CanThrow 'MissingAuth
:> CanThrow 'MalformedPrekeys
:> CanThrow 'CodeAuthenticationFailed
:> CanThrow 'CodeAuthenticationRequired
:> ZLocalUser
:> ZConn
:> "clients"
:> VersionedReqBody 'V7 '[JSON] NewClient
:> MultiVerb1
'POST
'[JSON]
( WithHeaders
ClientHeaders
Client
(VersionedRespond 'V7 201 "Client registered" Client)
)
)
:<|> Named
"add-client"
( Summary "Register a new client"
:> From 'V8
:> CanThrow 'TooManyClients
:> CanThrow 'MissingAuth
:> CanThrow 'MalformedPrekeys
:> CanThrow 'CodeAuthenticationFailed
:> CanThrow 'CodeAuthenticationRequired
:> ZLocalUser
:> ZConn
:> "clients"
:> ReqBody '[JSON] NewClient
:> MultiVerb1
'POST
'[JSON]
( WithHeaders
ClientHeaders
Client
(Respond 201 "Client registered" Client)
)
)
:<|> Named
"update-client@v6"
( Summary "Update a registered client"
:> Until 'V7
:> CanThrow 'MalformedPrekeys
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> VersionedReqBody 'V6 '[JSON] UpdateClient
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "Client updated")
)
:<|> Named
"update-client@v7"
( Summary "Update a registered client"
:> From 'V7
:> Until 'V8
:> CanThrow 'MalformedPrekeys
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> VersionedReqBody 'V7 '[JSON] UpdateClient
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "Client updated")
)
:<|> Named
"update-client"
( Summary "Update a registered client"
:> From 'V8
:> CanThrow 'MalformedPrekeys
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> ReqBody '[JSON] UpdateClient
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "Client updated")
)
:<|>
-- This endpoint can lead to the following events being sent:
-- - ClientRemoved event to self
Named
"delete-client"
( Summary "Delete an existing client"
:> ZUser
:> ZConn
:> "clients"
:> CaptureClientId "client"
:> ReqBody '[JSON] RmClient
:> MultiVerb 'DELETE '[JSON] '[RespondEmpty 200 "Client deleted"] ()
)
:<|> Named
"list-clients@v6"
( Summary "List the registered clients"
:> Until 'V7
:> ZUser
:> "clients"
:> MultiVerb1
'GET
'[JSON]
( VersionedRespond 'V6 200 "List of clients" [Client]
)
)
:<|> Named
"list-clients@v7"
( Summary "List the registered clients"
:> From 'V7
:> Until 'V8
:> ZUser
:> "clients"
:> MultiVerb1
'GET
'[JSON]
( VersionedRespond 'V7 200 "List of clients" [Client]
)
)
:<|> Named
"list-clients"
( Summary "List the registered clients"
:> From 'V8
:> ZUser
:> "clients"
:> MultiVerb1
'GET
'[JSON]
( Respond 200 "List of clients" [Client]
)
)
:<|> Named
"get-client@v6"
( Summary "Get a registered client by ID"
:> Until 'V7
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> MultiVerb
'GET
'[JSON]
'[ EmptyErrorForLegacyReasons 404 "Client not found",
VersionedRespond 'V6 200 "Client found" Client
]
(Maybe Client)
)
:<|> Named
"get-client@v7"
( Summary "Get a registered client by ID"
:> From 'V7
:> Until 'V8
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> MultiVerb
'GET
'[JSON]
'[ EmptyErrorForLegacyReasons 404 "Client not found",
VersionedRespond 'V7 200 "Client found" Client
]
(Maybe Client)
)
:<|> Named
"get-client"
( Summary "Get a registered client by ID"
:> From 'V8
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> MultiVerb
'GET
'[JSON]
'[ EmptyErrorForLegacyReasons 404 "Client not found",
Respond 200 "Client found" Client
]
(Maybe Client)
)
:<|> Named
"get-client-capabilities@v6"
( Summary "Read back what the client has been posting about itself"
:> Until 'V7
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> "capabilities"
:> MultiVerb1
'GET
'[JSON]
(VersionedRespond 'V6 200 "capabilities" ClientCapabilityList)
)
:<|> Named
"get-client-capabilities@v7"
( Summary "Read back what the client has been posting about itself"
:> From 'V7
:> Until 'V8
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> "capabilities"
:> MultiVerb1
'GET
'[JSON]
(VersionedRespond 'V7 200 "capabilities" ClientCapabilityList)
)
:<|> Named
"get-client-capabilities"
( Summary "Read back what the client has been posting about itself"
:> From 'V8
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> "capabilities"
:> Get '[JSON] ClientCapabilityList
)
:<|> Named
"get-client-prekeys"
( Summary "List the remaining prekey IDs of a client"
:> ZUser
:> "clients"
:> CaptureClientId "client"