diff --git a/.gitignore b/.gitignore index 0b41c5aba60..602482b0761 100644 --- a/.gitignore +++ b/.gitignore @@ -73,9 +73,6 @@ deploy/dockerephemeral/build/airdock_rvm/ deploy/dockerephemeral/build/dynamodb_local/ deploy/dockerephemeral/build/smtp/ -# Ignore cabal files; use package.yaml instead -*.cabal - # Avoid storing generated keys /deploy/services-demo/resources/turn/secret.txt @@ -85,3 +82,5 @@ deploy/dockerephemeral/build/smtp/ /libs/libzauth/bzauth-c/deb/usr +# Generated hie.yaml +hie.yaml \ No newline at end of file diff --git a/.licensure.yml b/.licensure.yml new file mode 100644 index 00000000000..9692e627b13 --- /dev/null +++ b/.licensure.yml @@ -0,0 +1,65 @@ +# See https://github.com/chasinglogic/licensure +# (As of 2020-02-17, version 0.2.0 (96d7fad9201e19e5193bf7435ab5fdf4a6ad4685) is used) + +change_in_place: true +# Regexes which if matched by a file path will always be excluded from +# getting a license header +excludes: + - \.gitignore + - .*lock + - \.git/.* + - \.licensure\.yml + - README.* + - LICENSE.* + - .*\.(md|rst|txt|yml|yaml) + - Cargo.toml +# Definition of the licenses used on this project and to what files +# they should apply. +licenses: + # Either a regex or the string "any" to determine to what files this + # license should apply. It is common for projects to have files + # under multiple licenses or with multiple copyright holders. This + # provides the ability to automatically license files correctly + # based on their file paths. + # + # If "any" is provided all files will match this license. + - files: .*\.(hs|hsc|rs) + ident: AGPL-3.0 + authors: + - name: Wire Swiss GmbH + email: opensource@wire.com + year: 2020 + year: 2020 + name of author: Wire + + auto_template: false + template: | + This file is part of the Wire Server implementation. + + Copyright (C) [year] Wire Swiss GmbH + + 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 . + +# Define type of comment characters to apply based on file extensions. +comments: + # The extensions (or singular extension) field defines which file + # extensions to apply the commenter to. + - columns: 80 + extensions: + - hs + - hsc + commenter: + type: line + comment_char: "--" + trailing_lines: 1 + - columns: 80 + extensions: + - rs + commenter: + type: line + comment_char: "//" + trailing_lines: 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 803b4bcbdba..5d65d209a16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,43 @@ +# 2020-04-15 + +## Upgrade steps (IMPORTANT) + +1. Update mapping in ElasticSearch (see [./docs/reference/elastic-search.md](./docs/reference/elastic-search.md)) +2. Upgrade brig and the other services as usual +3. Migrate data in ElasticSearch (see [./docs/reference/elastic-search.md](./docs/reference/elastic-search.md)) + +## New features + +* Allow `brig-index create` to set ES index settings (#1023) +* Extended team invitations to have name and phone number (#1032) +* Allow team members to be searched by teammates. (#964) +* Better defaults for maxKeyLen and maxValueLen (#1034) + +## Bug Fixes + +* Fix swagger (#1012, #1031) +* Custom backend lookup by domain is now case-insensitive (#1013) + +## Internal Changes + +* Federation: resolve opaque IDs at the edges of galley (#1008) +* Qualify all API imports in Galley (#1006) +* types-common: write unit tests for Data.Qualified (#1011) +* Remove subv4 (#1003) +* Add federation feature flag to brig and galley (#1014) +* Add hie.yaml (#1024) +* Improve reproducibility of builds (#1027) +* Update types of some brig endpoints to be federation-aware (#1013) +* Bump to lts-14.27 (#1030) +* Add comments about which endpoints send which events to clients (#1025) +* Minimize dependencies of all brig binaries (#1035) +* Federation: Use status 403 for 'not implemented' (#1036) +* Add endpoint to count team members using ES (#1022) +* Rename brig's userName to userDisplayName to avoid confusion (#1039) +* Upgrade to restund 0.4.14 (#1043) +* Add license headers to all files (#980, #1045) +* Federation: Link related issue IDs (#1041) + # 2020-03-10 ## New features diff --git a/Makefile b/Makefile index 3b2cafcf0e0..f9650343e06 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,17 @@ formatf: formatc: ./tools/ormolu.sh -c +# For any Haskell or Rust file that doesn't mention AGPL yet, add a license header. +# It's your own reponsibility to keep ormolu happy. +.PHONY: add-license +add-license: + for file in $$(git grep -L "GNU Affero General Public License" | grep '\.hs$$\|\.hsc$$\|\.rs$$'); do \ + echo "Adding license to $${file}."; \ + licensure -i $${file}; \ + done; + @echo "" + @echo "you most probably want to run 'make formatf' now to keep ormolu happy" + # Clean .PHONY: clean clean: @@ -181,3 +192,7 @@ db-reset: libzauth: $(MAKE) -C libs/libzauth install + +.PHONY: hie.yaml +hie.yaml: + ./tools/gen-hie-yaml.sh > hie.yaml diff --git a/docs/developer/dependencies.md b/docs/developer/dependencies.md index 5d6fb454000..41ecada6607 100644 --- a/docs/developer/dependencies.md +++ b/docs/developer/dependencies.md @@ -95,6 +95,24 @@ sudo apt install rustc cargo -y curl https://sh.rustup.rs -sSf | sh source $HOME/.cargo/env ``` + +## Formatting Haskell files + +You need `ormolu` on your PATH, get it with `stack install ormolu` + +## Generating license headers + +We use [`licensure`](https://github.com/chasinglogic/licensure). + +To get it: + +``` +git clone https://github.com/chasinglogic/licensure +cd licensure +git checkout 96d7fad9201e19e5193bf7435ab5fdf4a6ad4685 # master as of 2020-02-18 +cargo install --path . +``` + ## makedeb This is a tool to create debian-style binary packages. It is optional, and is only used if you want to install debian-style packages on your debian or ubuntu system. diff --git a/docs/reference/elastic-search.md b/docs/reference/elastic-search.md new file mode 100644 index 00000000000..b2fe874c86e --- /dev/null +++ b/docs/reference/elastic-search.md @@ -0,0 +1,69 @@ +# Maintaining ElasticSearch + +## Update mapping + +```bash +ES_HOST= +ES_PORT= # default is 9200 +ES_INDEX= # default is directory +WIRE_VERSION= + +docker run "quay.io/wire/brig-index:$WIRE_VERSION" update-mapping \ + --elasticsearch-server "http://$ES_HOST:$ES_PORT" \ + --elasticsearch-index "$ES_INDEX" +``` + +Instead of running this in docker, this can also be done by building the `brig-index` binary from `services/brig` and executing it like this: + +```bash +brig-index update-mapping \ + --elasticsearch-server "http://$ES_HOST:$ES_PORT" \ + --elasticsearch-index "$ES_INDEX" +``` + +## Migrate Data + +```bash +ES_HOST= +ES_PORT= # default is 9200 +ES_INDEX= # default is directory +BRIG_CASSANDRA_HOST= +BRIG_CASSANDRA_PORT= +BRIG_CASSANDRA_KEYSPACE= +WIRE_VERSION= + +docker run "quay.io/wire/brig-index:$WIRE_VERSION" migrate-data \ + --elasticsearch-server "http://$ES_HOST:$ES_PORT" \ + --elasticsearch-index "$ES_INDEX" \ + --cassandra-host "$BRIG_CASSANDRA_HOST" \ + --cassandra-port "$BRIG_CASSANDRA_PORT" \ + --cassandra-keyspace "$BRIG_CASSANDRA_KEYSPACE" +``` + +(Or, as above, you can also do the same thing without docker.) + +## Refill ES documents from Cassandra + +This is needed if the information we keep in elastic search increases. +Also update the indices. + +```bash +ES_HOST= +ES_PORT= # default is 9200 +ES_INDEX= # default is directory +BRIG_CASSANDRA_HOST= +BRIG_CASSANDRA_PORT= +BRIG_CASSANDRA_KEYSPACE= +WIRE_VERSION= + +docker run "quay.io/wire/brig-index:$WIRE_VERSION" reindex \ + --elasticsearch-server "http://$ES_HOST:$ES_PORT" \ + --elasticsearch-index "$ES_INDEX" \ + --cassandra-host "$BRIG_CASSANDRA_HOST" \ + --cassandra-port "$BRIG_CASSANDRA_PORT" \ + --cassandra-keyspace "$BRIG_CASSANDRA_KEYSPACE" +``` + +Subcommand `reindex-if-same-or-newer` can be used instead of `reindex`, if you want to recreate the documents in elasticsearch regardless of their version. + +(Or, as above, you can also do the same thing without docker.) diff --git a/libs/api-bot/api-bot.cabal b/libs/api-bot/api-bot.cabal new file mode 100644 index 00000000000..49dbec8003e --- /dev/null +++ b/libs/api-bot/api-bot.cabal @@ -0,0 +1,89 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: ff48dbfe677cdd01dafb24662f6ef4d5e0dd7f04251cf92a8c7ed61a4787e1c0 + +name: api-bot +version: 0.4.2 +synopsis: (Internal) API automation around wire-client +description: (Internal) API automation around the wire-client. +category: Network +stability: experimental +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Network.Wire.Bot + Network.Wire.Bot.Assert + Network.Wire.Bot.Cache + Network.Wire.Bot.Clients + Network.Wire.Bot.Crypto + Network.Wire.Bot.Crypto.Glue + Network.Wire.Bot.Email + Network.Wire.Bot.Metrics + Network.Wire.Bot.Monad + Network.Wire.Bot.Report + Network.Wire.Bot.Report.Text + Network.Wire.Bot.Settings + other-modules: + Paths_api_bot + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + HaskellNet >=0.5 + , HaskellNet-SSL >=0.3 + , aeson >=0.11 + , ansi-terminal >=0.6 + , api-client + , async >=2.0 + , attoparsec >=0.13 + , base >=4.6 && <5 + , base64-bytestring >=1.0 + , bilge >=0.21 + , bytestring >=0.10 + , bytestring-conversion >=0.2 + , cereal >=0.5 + , containers >=0.5 + , cryptobox-haskell >=0.1.1 + , cryptonite >=0.17 + , directory >=1.2 + , errors >=2.0 + , exceptions >=0.8 + , filepath >=1.3 + , http-client >=0.4 + , http-types >=0.8 + , imports + , iso639 >=0.1 + , lens >=4.1 + , memory >=0.12 + , metrics-core >=0.1.17 + , mime >=0.4 + , monad-control >=1.0 + , mtl >=2.1 + , mwc-random >=0.13 + , optparse-applicative >=0.11 + , resource-pool >=0.2 + , scientific >=0.3 + , semigroups >=0.10 + , singletons >=0.10 + , stm >=2.4 + , text >=0.11 + , time >=1.5 + , tinylog >=0.14 + , transformers >=0.3 + , transformers-base >=0.4 + , types-common >=0.11 + , unliftio-core >=0.1 + , unordered-containers >=0.2 + , uuid >=1.3 + , vector >=0.10 + default-language: Haskell2010 diff --git a/libs/api-bot/src/Network/Wire/Bot.hs b/libs/api-bot/src/Network/Wire/Bot.hs index 258985b5c87..10b137bc0d2 100644 --- a/libs/api-bot/src/Network/Wire/Bot.hs +++ b/libs/api-bot/src/Network/Wire/Bot.hs @@ -1,4 +1,24 @@ -module Network.Wire.Bot (module M) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Network.Wire.Bot + ( module M, + ) +where import Network.Wire.Bot.Email as M import Network.Wire.Bot.Monad as M diff --git a/libs/api-bot/src/Network/Wire/Bot/Assert.hs b/libs/api-bot/src/Network/Wire/Bot/Assert.hs index d1e3b0faf5a..30fd27b6033 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Assert.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Assert.hs @@ -1,6 +1,23 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Assert where import Data.Id (ConvId, UserId) diff --git a/libs/api-bot/src/Network/Wire/Bot/Cache.hs b/libs/api-bot/src/Network/Wire/Bot/Cache.hs index ffc1a21ded0..ff532c5befc 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Cache.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Cache.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Cache ( CachedUser (..), Cache, @@ -68,7 +85,7 @@ toUser _ acc [i, e, p] = do pw User { userId = ui, - userName = Name $ "Fakebot-" <> Text.toStrict (Text.strip i), + userDisplayName = Name $ "Fakebot-" <> Text.toStrict (Text.strip i), userPict = Pict [], userAssets = [], userIdentity = Just (EmailIdentity em), diff --git a/libs/api-bot/src/Network/Wire/Bot/Clients.hs b/libs/api-bot/src/Network/Wire/Bot/Clients.hs index 5a32493798c..306621ef8e4 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Clients.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Clients.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Clients ( Clients, Network.Wire.Bot.Clients.empty, diff --git a/libs/api-bot/src/Network/Wire/Bot/Crypto.hs b/libs/api-bot/src/Network/Wire/Bot/Crypto.hs index d659003e2a0..f54f327b9d7 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Crypto.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Crypto.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Crypto ( Plaintext, Ciphertext, diff --git a/libs/api-bot/src/Network/Wire/Bot/Crypto/Glue.hs b/libs/api-bot/src/Network/Wire/Bot/Crypto/Glue.hs index 216c003b407..6da93041c3d 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Crypto/Glue.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Crypto/Glue.hs @@ -1,5 +1,22 @@ {-# LANGUAGE LambdaCase #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Crypto.Glue ( openBox, deleteBox, diff --git a/libs/api-bot/src/Network/Wire/Bot/Email.hs b/libs/api-bot/src/Network/Wire/Bot/Email.hs index 81b3312e3dc..f224abc32c4 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Email.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Email.hs @@ -1,6 +1,23 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Email ( Mailbox (mailboxSettings), MailboxSettings (..), diff --git a/libs/api-bot/src/Network/Wire/Bot/Metrics.hs b/libs/api-bot/src/Network/Wire/Bot/Metrics.hs index 5a31b19ab6c..5784e8468b7 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Metrics.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Metrics.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Metrics where import Data.Metrics diff --git a/libs/api-bot/src/Network/Wire/Bot/Monad.hs b/libs/api-bot/src/Network/Wire/Bot/Monad.hs index 1c76e9341d7..953ee92dcb5 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Monad.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Monad.hs @@ -6,6 +6,23 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Monad ( -- * Environment BotNetEnv, @@ -354,7 +371,7 @@ botId :: Bot -> UserId botId = userId . botUser botName :: Bot -> Text -botName = fromName . userName . botUser +botName = fromName . userDisplayName . botUser botEmail :: Bot -> Maybe Text botEmail = fmap fromEmail . userEmail . botUser @@ -949,7 +966,7 @@ randUser (Email loc dom) (BotTag tag) = do let passw = PlainTextPassword (pack (toString pwdUuid)) return ( NewUser - { newUserName = Name (tag <> "-Wirebot-" <> pack (toString uuid)), + { newUserDisplayName = Name (tag <> "-Wirebot-" <> pack (toString uuid)), newUserUUID = Nothing, newUserIdentity = Just (EmailIdentity email), newUserPassword = Just passw, @@ -974,4 +991,4 @@ randMailbox = do return $ botNetMailboxes e !! i tagged :: BotTag -> User -> User -tagged t u = u {userName = Name $ unTag t <> "-" <> fromName (userName u)} +tagged t u = u {userDisplayName = Name $ unTag t <> "-" <> fromName (userDisplayName u)} diff --git a/libs/api-bot/src/Network/Wire/Bot/Report.hs b/libs/api-bot/src/Network/Wire/Bot/Report.hs index 6563068d19b..9d8f53c8b24 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Report.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Report.hs @@ -1,6 +1,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Report ( -- * Create Reports Report (reportTitle, reportDate, reportSections), diff --git a/libs/api-bot/src/Network/Wire/Bot/Report/Text.hs b/libs/api-bot/src/Network/Wire/Bot/Report/Text.hs index 0b177fe250b..66f4f2e58cb 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Report/Text.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Report/Text.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Report.Text ( formatReport, printReport, diff --git a/libs/api-bot/src/Network/Wire/Bot/Settings.hs b/libs/api-bot/src/Network/Wire/Bot/Settings.hs index d64f1244fe7..a6ac3349592 100644 --- a/libs/api-bot/src/Network/Wire/Bot/Settings.hs +++ b/libs/api-bot/src/Network/Wire/Bot/Settings.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Bot.Settings ( BotNetSettings (..), botNetSettingsParser, diff --git a/libs/api-client/api-client.cabal b/libs/api-client/api-client.cabal new file mode 100644 index 00000000000..7eabd117489 --- /dev/null +++ b/libs/api-client/api-client.cabal @@ -0,0 +1,77 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 247f19b4a4ffffe1eea1492b7c28f299df43c7203d768cda26b1f87f64142f80 + +name: api-client +version: 0.4.2 +synopsis: (Internal) Wire HTTP API Client +description: An (internal) client library for the Wire HTTP API. +category: Network +stability: experimental +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Network.Wire.Client + Network.Wire.Client.API.Asset + Network.Wire.Client.API.Auth + Network.Wire.Client.API.Client + Network.Wire.Client.API.Conversation + Network.Wire.Client.API.Push + Network.Wire.Client.API.Search + Network.Wire.Client.API.User + Network.Wire.Client.HTTP + Network.Wire.Client.Monad + Network.Wire.Client.Session + other-modules: + Paths_api_client + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson >=0.11 + , async >=2.0 + , base >=4.6 && <5 + , base64-bytestring >=1.0 + , bilge >=0.21 + , brig-types >=0.84 + , bytestring >=0.10 + , bytestring-conversion >=0.2 + , cargohold-types >=0.25.6 + , connection >=0.2 + , cookie >=0.4 + , cryptobox-haskell >=0.1.1 + , cryptonite >=0.17 + , data-default-class >=0.0 + , errors >=2.1 + , exceptions >=0.8 + , galley-types >=0.66 + , gundeck-types >=1.24 + , http-client >=0.4 + , http-types >=0.8 + , imports + , memory >=0.12 + , mime >=0.4 + , mtl >=2.1 + , network >=2.4 + , retry >=0.7 + , semigroups >=0.10 + , text >=1.2 + , time >=1.5 + , tinylog >=0.14 + , transformers >=0.3 + , types-common >=0.16 + , unliftio + , unordered-containers >=0.2 + , uuid >=1.3 + , websockets >=0.9 + default-language: Haskell2010 diff --git a/libs/api-client/src/Network/Wire/Client.hs b/libs/api-client/src/Network/Wire/Client.hs index 2f6dfa3c4a3..9cb68faa46d 100644 --- a/libs/api-client/src/Network/Wire/Client.hs +++ b/libs/api-client/src/Network/Wire/Client.hs @@ -1,4 +1,24 @@ -module Network.Wire.Client (module M) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Network.Wire.Client + ( module M, + ) +where import Network.Wire.Client.Monad as M import Network.Wire.Client.Session as M diff --git a/libs/api-client/src/Network/Wire/Client/API/Asset.hs b/libs/api-client/src/Network/Wire/Client/API/Asset.hs index d919445d078..689281b6722 100644 --- a/libs/api-client/src/Network/Wire/Client/API/Asset.hs +++ b/libs/api-client/src/Network/Wire/Client/API/Asset.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.API.Asset ( AssetData, AssetKey, diff --git a/libs/api-client/src/Network/Wire/Client/API/Auth.hs b/libs/api-client/src/Network/Wire/Client/API/Auth.hs index 7668d862900..14c06919438 100644 --- a/libs/api-client/src/Network/Wire/Client/API/Auth.hs +++ b/libs/api-client/src/Network/Wire/Client/API/Auth.hs @@ -1,6 +1,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.API.Auth ( login, refreshAuth, diff --git a/libs/api-client/src/Network/Wire/Client/API/Client.hs b/libs/api-client/src/Network/Wire/Client/API/Client.hs index 180cb09a2b9..abdd525a791 100644 --- a/libs/api-client/src/Network/Wire/Client/API/Client.hs +++ b/libs/api-client/src/Network/Wire/Client/API/Client.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.API.Client ( registerClient, removeClient, diff --git a/libs/api-client/src/Network/Wire/Client/API/Conversation.hs b/libs/api-client/src/Network/Wire/Client/API/Conversation.hs index 057bfa98d3c..16a8a17beda 100644 --- a/libs/api-client/src/Network/Wire/Client/API/Conversation.hs +++ b/libs/api-client/src/Network/Wire/Client/API/Conversation.hs @@ -1,6 +1,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.API.Conversation ( postOtrMessage, createConv, diff --git a/libs/api-client/src/Network/Wire/Client/API/Push.hs b/libs/api-client/src/Network/Wire/Client/API/Push.hs index 047ef19c2dd..32adcf5d03c 100644 --- a/libs/api-client/src/Network/Wire/Client/API/Push.hs +++ b/libs/api-client/src/Network/Wire/Client/API/Push.hs @@ -2,6 +2,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.API.Push ( Notification (..), awaitNotifications, diff --git a/libs/api-client/src/Network/Wire/Client/API/Search.hs b/libs/api-client/src/Network/Wire/Client/API/Search.hs index 8b4af589e80..5f6fced2d82 100644 --- a/libs/api-client/src/Network/Wire/Client/API/Search.hs +++ b/libs/api-client/src/Network/Wire/Client/API/Search.hs @@ -1,6 +1,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.API.Search ( Contact (..), SearchParams (..), diff --git a/libs/api-client/src/Network/Wire/Client/API/User.hs b/libs/api-client/src/Network/Wire/Client/API/User.hs index e32cf2da217..864fcaacd7f 100644 --- a/libs/api-client/src/Network/Wire/Client/API/User.hs +++ b/libs/api-client/src/Network/Wire/Client/API/User.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.API.User ( registerUser, activateKey, diff --git a/libs/api-client/src/Network/Wire/Client/HTTP.hs b/libs/api-client/src/Network/Wire/Client/HTTP.hs index 1fd54db5706..e96234d7c86 100644 --- a/libs/api-client/src/Network/Wire/Client/HTTP.hs +++ b/libs/api-client/src/Network/Wire/Client/HTTP.hs @@ -1,6 +1,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.HTTP ( clientRequest, readBody, diff --git a/libs/api-client/src/Network/Wire/Client/Monad.hs b/libs/api-client/src/Network/Wire/Client/Monad.hs index fa34074fe1a..af7b76e0a67 100644 --- a/libs/api-client/src/Network/Wire/Client/Monad.hs +++ b/libs/api-client/src/Network/Wire/Client/Monad.hs @@ -2,6 +2,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.Monad ( Server (..), setServer, diff --git a/libs/api-client/src/Network/Wire/Client/Session.hs b/libs/api-client/src/Network/Wire/Client/Session.hs index f2d9cfffc26..25f40f58425 100644 --- a/libs/api-client/src/Network/Wire/Client/Session.hs +++ b/libs/api-client/src/Network/Wire/Client/Session.hs @@ -1,5 +1,22 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Wire.Client.Session ( Session, MonadSession (..), diff --git a/libs/bilge/bilge.cabal b/libs/bilge/bilge.cabal new file mode 100644 index 00000000000..0fa33418395 --- /dev/null +++ b/libs/bilge/bilge.cabal @@ -0,0 +1,66 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 3935614b306254149b1649f7970804c8b164d0edfee1b42192edd81220011379 + +name: bilge +version: 0.22.0 +synopsis: Library for composing HTTP requests. +description: Library for constructing HTTP requests and asserting on their responses. +category: Network +stability: experimental +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple +extra-source-files: + README.md + +library + exposed-modules: + Bilge + Bilge.Assert + Bilge.IO + Bilge.Request + Bilge.Response + Bilge.Retry + Bilge.RPC + other-modules: + Paths_bilge + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson >=0.6 + , ansi-terminal >=0.6 + , base >=4.7 && <5 + , bytestring >=0.9 + , case-insensitive >=1.1 + , containers >=0.5 + , cookie + , data-default >=0.5 + , errors >=1.4 + , exceptions >=0.6 + , http-client >=0.5 + , http-types >=0.8 + , imports + , lens + , monad-control >=1.0 + , mtl >=2.2 + , text >=0.11 + , time >=1.4 + , tinylog >=0.9 + , transformers >=0.4 + , transformers-base >=0.4 + , types-common >=0.7 + , unliftio + , uri-bytestring + , wai + , wai-extra + default-language: Haskell2010 diff --git a/libs/bilge/examples/google.hs b/libs/bilge/examples/google.hs index 9a9066c82d2..3e6d3e6d906 100644 --- a/libs/bilge/examples/google.hs +++ b/libs/bilge/examples/google.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Main where import Bilge diff --git a/libs/bilge/src/Bilge.hs b/libs/bilge/src/Bilge.hs index a487cc950fd..be4605dd6b9 100644 --- a/libs/bilge/src/Bilge.hs +++ b/libs/bilge/src/Bilge.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | Bilge provides declarative ways to compose requests and assert on responses. module Bilge ( module B, diff --git a/libs/bilge/src/Bilge/Assert.hs b/libs/bilge/src/Bilge/Assert.hs index ea7c9f453f9..253ff6c6292 100644 --- a/libs/bilge/src/Bilge/Assert.hs +++ b/libs/bilge/src/Bilge/Assert.hs @@ -1,5 +1,22 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | 'Assert' provides ways to maintain claims over 'Response's. module Bilge.Assert ( Assertions, diff --git a/libs/bilge/src/Bilge/IO.hs b/libs/bilge/src/Bilge/IO.hs index 6e383fef081..0c134290e94 100644 --- a/libs/bilge/src/Bilge/IO.hs +++ b/libs/bilge/src/Bilge/IO.hs @@ -6,6 +6,23 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Bilge.IO ( -- * Convenience API HttpT (..), diff --git a/libs/bilge/src/Bilge/RPC.hs b/libs/bilge/src/Bilge/RPC.hs index 1f1c12f79f6..0428cef43a4 100644 --- a/libs/bilge/src/Bilge/RPC.hs +++ b/libs/bilge/src/Bilge/RPC.hs @@ -1,6 +1,23 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Bilge.RPC ( HasRequestId (..), RPCException (..), diff --git a/libs/bilge/src/Bilge/Request.hs b/libs/bilge/src/Bilge/Request.hs index 7f695990062..9ef79201c70 100644 --- a/libs/bilge/src/Bilge/Request.hs +++ b/libs/bilge/src/Bilge/Request.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Bilge.Request ( RequestId (..), diff --git a/libs/bilge/src/Bilge/Response.hs b/libs/bilge/src/Bilge/Response.hs index 4dcf3d0399a..9aba3b8446d 100644 --- a/libs/bilge/src/Bilge/Response.hs +++ b/libs/bilge/src/Bilge/Response.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Bilge.Response ( -- * Helpers statusCode, diff --git a/libs/bilge/src/Bilge/Retry.hs b/libs/bilge/src/Bilge/Retry.hs index 79163599b18..2386effe304 100644 --- a/libs/bilge/src/Bilge/Retry.hs +++ b/libs/bilge/src/Bilge/Retry.hs @@ -1,5 +1,22 @@ {-# LANGUAGE ScopedTypeVariables #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Bilge.Retry where import Bilge.RPC (RPCException (..)) diff --git a/libs/brig-types/brig-types.cabal b/libs/brig-types/brig-types.cabal new file mode 100644 index 00000000000..9b77972d701 --- /dev/null +++ b/libs/brig-types/brig-types.cabal @@ -0,0 +1,134 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 67eab80b4b772b485785e77f0ba45811541ed4ac1eac935cf47bfaee4837ec55 + +name: brig-types +version: 1.35.0 +synopsis: User Service +category: Network +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Brig.Types + Brig.Types.Activation + Brig.Types.Client + Brig.Types.Client.Prekey + Brig.Types.Code + Brig.Types.Common + Brig.Types.Connection + Brig.Types.Instances + Brig.Types.Intra + Brig.Types.Properties + Brig.Types.Provider + Brig.Types.Provider.External + Brig.Types.Provider.Tag + Brig.Types.Search + Brig.Types.Swagger + Brig.Types.Team + Brig.Types.Team.Invitation + Brig.Types.Team.LegalHold + Brig.Types.Test.Arbitrary + Brig.Types.TURN + Brig.Types.TURN.Internal + Brig.Types.User + Brig.Types.User.Auth + other-modules: + Paths_brig_types + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path -funbox-strict-fields + build-depends: + QuickCheck >=2.9 + , aeson >=0.11 + , attoparsec >=0.10 + , base ==4.* + , base64-bytestring >=1.0 + , bytestring >=0.9 + , bytestring-conversion >=0.2 + , case-insensitive + , cassandra-util + , containers >=0.5 + , currency-codes >=2.0 + , errors >=1.4 + , extra + , galley-types >=0.45.7 + , hashable + , hostname-validate + , imports + , iproute >=1.5 + , iso3166-country-codes >=0.2 + , iso639 >=0.1 + , lens + , lens-aeson + , network-uri >=2.6 + , pem >=0.2 + , quickcheck-instances >=0.3.16 + , random + , safe >=0.3 + , scientific >=0.3.4 + , singletons >=2.0 + , swagger >=0.1 + , text >=0.11 + , time >=1.1 + , types-common >=0.16 + , unordered-containers >=0.2 + , uri-bytestring + , uuid >=1.3 + default-language: Haskell2010 + +test-suite brig-types-tests + type: exitcode-stdio-1.0 + main-is: Main.hs + other-modules: + Test.Brig.Roundtrip + Test.Brig.Types.Common + Test.Brig.Types.Team + Test.Brig.Types.TURN + Test.Brig.Types.User + Paths_brig_types + hs-source-dirs: + test/unit + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path -threaded -with-rtsopts=-N + build-depends: + QuickCheck + , aeson + , aeson-qq + , attoparsec + , base + , brig-types + , bytestring + , containers + , currency-codes + , extra + , galley-types + , hostname-validate + , imports + , iproute + , iso639 + , lens + , pem + , quickcheck-instances + , random + , tasty + , tasty-hunit + , tasty-quickcheck + , text + , time + , types-common + , unordered-containers + , uri-bytestring + , uuid + , vector + default-language: Haskell2010 diff --git a/libs/brig-types/src/Brig/Types.hs b/libs/brig-types/src/Brig/Types.hs index f02e5d5213e..b4f3307ba91 100644 --- a/libs/brig-types/src/Brig/Types.hs +++ b/libs/brig-types/src/Brig/Types.hs @@ -1,4 +1,24 @@ -module Brig.Types (module M) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Brig.Types + ( module M, + ) +where import Brig.Types.Activation as M import Brig.Types.Client as M @@ -6,4 +26,5 @@ import Brig.Types.Connection as M import Brig.Types.Properties as M import Brig.Types.Search as M import Brig.Types.TURN as M +import Brig.Types.Team as M import Brig.Types.User as M diff --git a/libs/brig-types/src/Brig/Types/Activation.hs b/libs/brig-types/src/Brig/Types/Activation.hs index 6e50a776f68..e0cd1b61580 100644 --- a/libs/brig-types/src/Brig/Types/Activation.hs +++ b/libs/brig-types/src/Brig/Types/Activation.hs @@ -1,6 +1,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Activation ( module Brig.Types.Activation, module C, diff --git a/libs/brig-types/src/Brig/Types/Client.hs b/libs/brig-types/src/Brig/Types/Client.hs index e8072b3b4fb..0a36264b7ec 100644 --- a/libs/brig-types/src/Brig/Types/Client.hs +++ b/libs/brig-types/src/Brig/Types/Client.hs @@ -1,6 +1,23 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- TODO: Move to Brig.Types.User.Client module Brig.Types.Client ( module Brig.Types.Client, diff --git a/libs/brig-types/src/Brig/Types/Client/Prekey.hs b/libs/brig-types/src/Brig/Types/Client/Prekey.hs index 3716843d6b8..3e7f9cbad55 100644 --- a/libs/brig-types/src/Brig/Types/Client/Prekey.hs +++ b/libs/brig-types/src/Brig/Types/Client/Prekey.hs @@ -1,6 +1,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Client.Prekey ( PrekeyId (..), Prekey (..), @@ -31,7 +48,7 @@ data Prekey data PrekeyBundle = PrekeyBundle - { prekeyUser :: !UserId, + { prekeyUser :: !OpaqueUserId, prekeyClients :: ![ClientPrekey] } deriving (Eq, Show, Generic) diff --git a/libs/brig-types/src/Brig/Types/Code.hs b/libs/brig-types/src/Brig/Types/Code.hs index 794317245fa..9ff96df056c 100644 --- a/libs/brig-types/src/Brig/Types/Code.hs +++ b/libs/brig-types/src/Brig/Types/Code.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | Types for verification codes. module Brig.Types.Code ( -- * re-exports diff --git a/libs/brig-types/src/Brig/Types/Common.hs b/libs/brig-types/src/Brig/Types/Common.hs index d2a03f9275a..e8d8864d5dd 100644 --- a/libs/brig-types/src/Brig/Types/Common.hs +++ b/libs/brig-types/src/Brig/Types/Common.hs @@ -5,6 +5,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- Brig.Types.Account? module Brig.Types.Common where diff --git a/libs/brig-types/src/Brig/Types/Connection.hs b/libs/brig-types/src/Brig/Types/Connection.hs index 5b320e4c0b9..f16b824b502 100644 --- a/libs/brig-types/src/Brig/Types/Connection.hs +++ b/libs/brig-types/src/Brig/Types/Connection.hs @@ -4,6 +4,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | > docs/reference/user/connection.md {#RefConnection} -- -- Types for connections between users. @@ -64,7 +81,7 @@ data UserConnection data ConnectionRequest = ConnectionRequest { -- | Connection recipient - crUser :: !UserId, + crUser :: !OpaqueUserId, -- | Name of the conversation to be created crName :: !Text, -- | Initial message diff --git a/libs/brig-types/src/Brig/Types/Instances.hs b/libs/brig-types/src/Brig/Types/Instances.hs index fe261900104..f0e8ea73ec5 100644 --- a/libs/brig-types/src/Brig/Types/Instances.hs +++ b/libs/brig-types/src/Brig/Types/Instances.hs @@ -2,6 +2,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# OPTIONS_GHC -fno-warn-orphans #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Instances ( ) diff --git a/libs/brig-types/src/Brig/Types/Intra.hs b/libs/brig-types/src/Brig/Types/Intra.hs index 116d5ae3d9b..c2e1be5f277 100644 --- a/libs/brig-types/src/Brig/Types/Intra.hs +++ b/libs/brig-types/src/Brig/Types/Intra.hs @@ -2,6 +2,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | API data types used only for intra-environment communication. -- TODO: Move to Brig.Types.User.Intra / Internal module Brig.Types.Intra where diff --git a/libs/brig-types/src/Brig/Types/Properties.hs b/libs/brig-types/src/Brig/Types/Properties.hs index f9faa6bb9a8..b4b6706c513 100644 --- a/libs/brig-types/src/Brig/Types/Properties.hs +++ b/libs/brig-types/src/Brig/Types/Properties.hs @@ -2,6 +2,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Properties where import Data.Aeson diff --git a/libs/brig-types/src/Brig/Types/Provider.hs b/libs/brig-types/src/Brig/Types/Provider.hs index 007812c845c..81d34a3e426 100644 --- a/libs/brig-types/src/Brig/Types/Provider.hs +++ b/libs/brig-types/src/Brig/Types/Provider.hs @@ -4,6 +4,23 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | Types for the (internal) provider API. -- -- TODO: Lenses & proper export list diff --git a/libs/brig-types/src/Brig/Types/Provider/External.hs b/libs/brig-types/src/Brig/Types/Provider/External.hs index b49288f43cc..f2c4678e429 100644 --- a/libs/brig-types/src/Brig/Types/Provider/External.hs +++ b/libs/brig-types/src/Brig/Types/Provider/External.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Provider.External ( module Brig.Types.Provider.External, BotUserView (..), diff --git a/libs/brig-types/src/Brig/Types/Provider/Tag.hs b/libs/brig-types/src/Brig/Types/Provider/Tag.hs index 9e33dd25f6d..a5a67e05ebf 100644 --- a/libs/brig-types/src/Brig/Types/Provider/Tag.hs +++ b/libs/brig-types/src/Brig/Types/Provider/Tag.hs @@ -3,6 +3,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Provider.Tag where import Cassandra.CQL (Cql) diff --git a/libs/brig-types/src/Brig/Types/Search.hs b/libs/brig-types/src/Brig/Types/Search.hs index 151c9d124f0..afd019baf90 100644 --- a/libs/brig-types/src/Brig/Types/Search.hs +++ b/libs/brig-types/src/Brig/Types/Search.hs @@ -1,11 +1,27 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE StrictData #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Search where import Data.Aeson -import Data.Id (UserId) -import Data.Json.Util +import Data.Id (TeamId, UserId) import Imports data SearchResult a @@ -17,18 +33,24 @@ data SearchResult a } deriving (Show) +-- | This is a subset of 'User' and json instances should reflect that. data Contact = Contact { contactUserId :: UserId, contactName :: Text, contactColorId :: Maybe Int, - contactHandle :: Maybe Text + contactHandle :: Maybe Text, + contactTeam :: Maybe TeamId } deriving (Show) --- | Encodes whether the (current) user has opted in/out of search -newtype SearchableStatus = SearchableStatus {isSearchable :: Bool} - deriving (Show) +data TeamSearchInfo + = -- | When searching user is not part of a team. + NoTeam + | -- | When searching user is part of a team and 'Brig.Options.setSearchSameTeamOnly' is True + TeamOnly TeamId + | -- | When searching user is part of a team and 'Brig.Options.setSearchSameTeamOnly' is False + TeamAndNonMembers TeamId instance ToJSON a => ToJSON (SearchResult a) where toJSON r = @@ -48,24 +70,20 @@ instance FromJSON a => FromJSON (SearchResult a) where instance ToJSON Contact where toJSON c = - object $ - "id" .= contactUserId c - # "name" .= contactName c - # "accent_id" .= contactColorId c - # "handle" .= contactHandle c - # [] + object + [ "id" .= contactUserId c, + "name" .= contactName c, + "accent_id" .= contactColorId c, + "handle" .= contactHandle c, + "team" .= contactTeam c + ] instance FromJSON Contact where - parseJSON = withObject "Contact" $ \o -> - Contact <$> o .: "id" - <*> o .: "name" - <*> o .:? "accent_id" - <*> o .:? "handle" - -instance ToJSON SearchableStatus where - toJSON (SearchableStatus onoff) = object ["searchable" .= onoff] - -instance FromJSON SearchableStatus where parseJSON = - withObject "SearchableStatus" $ - fmap SearchableStatus . (.: "searchable") + withObject "Contact" $ \o -> + Contact + <$> o .: "id" + <*> o .: "name" + <*> o .:? "accent_id" + <*> o .:? "handle" + <*> o .:? "team" diff --git a/libs/brig-types/src/Brig/Types/Swagger.hs b/libs/brig-types/src/Brig/Types/Swagger.hs index 116ed323396..395d3315388 100644 --- a/libs/brig-types/src/Brig/Types/Swagger.hs +++ b/libs/brig-types/src/Brig/Types/Swagger.hs @@ -1,21 +1,38 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Swagger where -import Data.Swagger import Data.Swagger.Build.Api import qualified Data.Swagger.Model.Api as Model import qualified Galley.Types.Swagger as Galley import Galley.Types.Teams (defaultRole) import qualified Galley.Types.Teams.Swagger as Galley import Imports +import Wire.Swagger brigModels :: [Model] brigModels = [ -- User self, user, - userName, + userDisplayName, newUser, userUpdate, emailUpdate, @@ -73,7 +90,6 @@ brigModels = -- Search searchResult, searchContact, - searchableStatus, -- Team invitations teamInvitation, teamInvitationList, @@ -145,6 +161,9 @@ user = defineModel "User" $ do property "handle" string' $ do description "Unique user handle." optional + property "team" string' $ do + description "Team ID" + optional managedBy :: DataType managedBy = @@ -195,8 +214,8 @@ richInfo = defineModel "RichInfo" $ do property "version" int32' $ description "Format version (the current version is 0)" -userName :: Model -userName = defineModel "UserName" $ do +userDisplayName :: Model +userDisplayName = defineModel "UserDisplayName" $ do description "User name" property "name" string' $ description "User name" @@ -417,6 +436,12 @@ teamInvitationRequest = defineModel "TeamInvitationRequest" $ do property "role" role $ do description "Role of the invited user" optional + property "name" string' $ do + description "Name of the invitee (1 - 128 characters)" + optional + property "phone" string' $ do + description "Phone number of the invitee, in the E.164 format" + optional -- | This is *not* the swagger model for the 'TeamInvitation' type (which does not exist), but -- for the use of 'Invitation' under @/teams/{tid}/invitations@. @@ -440,8 +465,12 @@ teamInvitation = defineModel "TeamInvitation" $ do property "created_by" bytes' $ do description "ID of the inviting user" optional - property "name" string' $ - description "Name of the invitee" + property "name" string' $ do + description "Name of the invitee (1 - 128 characters)" + optional + property "phone" string' $ do + description "Phone number of the invitee, in the E.164 format" + optional teamInvitationList :: Model teamInvitationList = defineModel "TeamInvitationList" $ do @@ -725,7 +754,7 @@ client = defineModel "Client" $ do property "time" dateTime' $ description "The date and time when this client was registered." property "class" clientClass $ - description "The device class this client belongs to. Either 'phone', 'tablet', or 'desktop'." + description "The device class this client belongs to." property "cookie" string' $ description "The cookie label of this client." property "address" string' $ do @@ -860,12 +889,9 @@ searchContact = defineModel "Contact" $ do property "accent_id" int32' $ do description "Accent color" optional - -searchableStatus :: Model -searchableStatus = defineModel "SearchableStatus" $ do - description "Whether the user is discoverable via search" - property "searchable" bool' $ - description "'true' if discoverable, 'false' otherwise" + property "team" string' $ do + description "Team ID" + optional -------------------------------------------------------------------------------- -- TURN diff --git a/libs/brig-types/src/Brig/Types/TURN.hs b/libs/brig-types/src/Brig/Types/TURN.hs index e191be95f0f..827e7fb3fee 100644 --- a/libs/brig-types/src/Brig/Types/TURN.hs +++ b/libs/brig-types/src/Brig/Types/TURN.hs @@ -2,6 +2,23 @@ {-# LANGUAGE StrictData #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.TURN ( RTCConfiguration, rtcConfiguration, diff --git a/libs/brig-types/src/Brig/Types/TURN/Internal.hs b/libs/brig-types/src/Brig/Types/TURN/Internal.hs index 42bfddbf8f5..a77eaf44ca6 100644 --- a/libs/brig-types/src/Brig/Types/TURN/Internal.hs +++ b/libs/brig-types/src/Brig/Types/TURN/Internal.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.TURN.Internal where import Data.Aeson diff --git a/libs/brig-types/src/Brig/Types/Team.hs b/libs/brig-types/src/Brig/Types/Team.hs new file mode 100644 index 00000000000..bc62e3c840a --- /dev/null +++ b/libs/brig-types/src/Brig/Types/Team.hs @@ -0,0 +1,32 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Brig.Types.Team where + +import Data.Aeson +import Imports +import Numeric.Natural + +newtype TeamSize = TeamSize Natural + deriving (Show, Eq) + +instance ToJSON TeamSize where + toJSON (TeamSize s) = object ["teamSize" .= s] + +instance FromJSON TeamSize where + parseJSON = + withObject "TeamSize" $ \o -> TeamSize <$> o .: "teamSize" diff --git a/libs/brig-types/src/Brig/Types/Team/Invitation.hs b/libs/brig-types/src/Brig/Types/Team/Invitation.hs index d2fb2b7c9de..755236db26b 100644 --- a/libs/brig-types/src/Brig/Types/Team/Invitation.hs +++ b/libs/brig-types/src/Brig/Types/Team/Invitation.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Team.Invitation where import Brig.Types.Common @@ -14,7 +31,9 @@ data InvitationRequest { irEmail :: !Email, irName :: !Name, irLocale :: !(Maybe Locale), - irRole :: !(Maybe Role) + irRole :: !(Maybe Role), + irInviteeName :: !(Maybe Name), + irPhone :: !(Maybe Phone) } deriving (Eq, Show) @@ -27,7 +46,9 @@ data Invitation inCreatedAt :: !UTCTimeMillis, -- | this is always 'Just' for new invitations, but for -- migration it is allowed to be 'Nothing'. - inCreatedBy :: !(Maybe UserId) + inCreatedBy :: !(Maybe UserId), + inInviteeName :: !(Maybe Name), + inPhone :: !(Maybe Phone) } deriving (Eq, Show) @@ -44,6 +65,8 @@ instance FromJSON InvitationRequest where <*> o .: "inviter_name" <*> o .:? "locale" <*> o .:? "role" + <*> o .:? "name" + <*> o .:? "phone" instance ToJSON InvitationRequest where toJSON i = @@ -51,7 +74,9 @@ instance ToJSON InvitationRequest where [ "email" .= irEmail i, "inviter_name" .= irName i, "locale" .= irLocale i, - "role" .= irRole i + "role" .= irRole i, + "name" .= irInviteeName i, + "phone" .= irPhone i ] instance FromJSON Invitation where @@ -63,6 +88,8 @@ instance FromJSON Invitation where <*> o .: "email" <*> o .: "created_at" <*> o .:? "created_by" + <*> o .:? "name" + <*> o .:? "phone" instance ToJSON Invitation where toJSON i = @@ -72,7 +99,9 @@ instance ToJSON Invitation where "id" .= inInvitation i, "email" .= inIdentity i, "created_at" .= inCreatedAt i, - "created_by" .= inCreatedBy i + "created_by" .= inCreatedBy i, + "name" .= inInviteeName i, + "phone" .= inPhone i ] instance ToJSON InvitationList where diff --git a/libs/brig-types/src/Brig/Types/Team/LegalHold.hs b/libs/brig-types/src/Brig/Types/Team/LegalHold.hs index 28b3c71bfe3..4e10d9be751 100644 --- a/libs/brig-types/src/Brig/Types/Team/LegalHold.hs +++ b/libs/brig-types/src/Brig/Types/Team/LegalHold.hs @@ -1,6 +1,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Team.LegalHold where import Brig.Types.Client.Prekey diff --git a/libs/brig-types/src/Brig/Types/Test/Arbitrary.hs b/libs/brig-types/src/Brig/Types/Test/Arbitrary.hs index 748286b7ed0..2d672f9e77c 100644 --- a/libs/brig-types/src/Brig/Types/Test/Arbitrary.hs +++ b/libs/brig-types/src/Brig/Types/Test/Arbitrary.hs @@ -12,6 +12,23 @@ {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-orphans #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.Test.Arbitrary where import Brig.Types.Activation @@ -226,7 +243,7 @@ instance Arbitrary NewUser where let isTeamUser = case newUserOrigin of Just (NewUserOriginTeamUser _) -> True _ -> False - newUserName <- arbitrary + newUserDisplayName <- arbitrary newUserUUID <- elements [Just nil, Nothing] newUserPict <- arbitrary newUserAssets <- arbitrary @@ -381,7 +398,7 @@ instance Arbitrary InvitationList where arbitrary = InvitationList <$> listOf arbitrary <*> arbitrary instance Arbitrary Invitation where - arbitrary = Invitation <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary + arbitrary = Invitation <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary instance Arbitrary Permissions where arbitrary = maybe (error "instance Arbitrary Permissions") pure =<< do @@ -393,7 +410,7 @@ instance Arbitrary Perm where arbitrary = elements [minBound ..] instance Arbitrary InvitationRequest where - arbitrary = InvitationRequest <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary + arbitrary = InvitationRequest <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary instance Arbitrary Role where arbitrary = elements [minBound ..] diff --git a/libs/brig-types/src/Brig/Types/User.hs b/libs/brig-types/src/Brig/Types/User.hs index f98cfccc0e6..1c3c445d62e 100644 --- a/libs/brig-types/src/Brig/Types/User.hs +++ b/libs/brig-types/src/Brig/Types/User.hs @@ -7,6 +7,23 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.User ( module Brig.Types.User, module C, @@ -107,7 +124,7 @@ connectedProfile u = UserProfile { profileId = userId u, profileHandle = userHandle u, - profileName = userName u, + profileName = userDisplayName u, profilePict = userPict u, profileAssets = userAssets u, profileAccentId = userAccentId u, @@ -162,7 +179,7 @@ data User -- verified. {#RefActivation} userIdentity :: !(Maybe UserIdentity), -- | required; non-unique - userName :: !Name, + userDisplayName :: !Name, -- | DEPRECATED userPict :: !Pict, userAssets :: [Asset], @@ -221,7 +238,7 @@ instance ToJSON User where toJSON u = object $ "id" .= userId u - # "name" .= userName u + # "name" .= userDisplayName u # "picture" .= userPict u # "assets" .= userAssets u # "email" .= userEmail u @@ -454,7 +471,7 @@ emptyRichInfoAssocList = RichInfoAssocList [] data NewUser = NewUser - { newUserName :: !Name, + { newUserDisplayName :: !Name, -- | use this as 'UserId' (if 'Nothing', call 'Data.UUID.nextRandom'). newUserUUID :: !(Maybe UUID), newUserIdentity :: !(Maybe UserIdentity), @@ -536,7 +553,7 @@ newUserSSOId = ssoIdentity <=< newUserIdentity instance FromJSON NewUser where parseJSON = withObject "new-user" $ \o -> do ssoid <- o .:? "sso_id" - newUserName <- o .: "name" + newUserDisplayName <- o .: "name" newUserUUID <- o .:? "uuid" newUserIdentity <- parseIdentity ssoid o newUserPict <- o .:? "picture" @@ -558,7 +575,7 @@ instance FromJSON NewUser where instance ToJSON NewUser where toJSON u = object $ - "name" .= newUserName u + "name" .= newUserDisplayName u # "uuid" .= newUserUUID u # "email" .= newUserEmail u # "email_code" .= newUserEmailCode u diff --git a/libs/brig-types/src/Brig/Types/User/Auth.hs b/libs/brig-types/src/Brig/Types/User/Auth.hs index b02c506f1f9..682848c0398 100644 --- a/libs/brig-types/src/Brig/Types/User/Auth.hs +++ b/libs/brig-types/src/Brig/Types/User/Auth.hs @@ -3,6 +3,23 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Brig.Types.User.Auth where import Brig.Types.Code diff --git a/libs/brig-types/test/unit/Main.hs b/libs/brig-types/test/unit/Main.hs index 5e7a3e5be85..3513fe5ca13 100644 --- a/libs/brig-types/test/unit/Main.hs +++ b/libs/brig-types/test/unit/Main.hs @@ -1,8 +1,29 @@ -module Main (main) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Main + ( main, + ) +where import Imports import qualified Test.Brig.Types.Common import qualified Test.Brig.Types.TURN +import qualified Test.Brig.Types.Team import qualified Test.Brig.Types.User import Test.Tasty @@ -12,6 +33,7 @@ main = testGroup "Tests" [ Test.Brig.Types.Common.tests, + Test.Brig.Types.Team.tests, Test.Brig.Types.TURN.tests, Test.Brig.Types.User.tests ] diff --git a/libs/brig-types/test/unit/Test/Brig/Roundtrip.hs b/libs/brig-types/test/unit/Test/Brig/Roundtrip.hs new file mode 100644 index 00000000000..c54a90929ae --- /dev/null +++ b/libs/brig-types/test/unit/Test/Brig/Roundtrip.hs @@ -0,0 +1,36 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Test.Brig.Roundtrip where + +import Data.Aeson (FromJSON, ToJSON, parseJSON, toJSON) +import Data.Aeson.Types (parseEither) +import Data.Typeable (typeOf) +import Imports +import Test.Tasty (TestTree) +import Test.Tasty.QuickCheck ((===), Arbitrary, counterexample, testProperty) + +testRoundTrip :: + forall a. + (Arbitrary a, Typeable a, ToJSON a, FromJSON a, Eq a, Show a) => + TestTree +testRoundTrip = testProperty msg trip + where + msg = show $ typeOf (undefined :: a) + trip (v :: a) = + counterexample (show $ toJSON v) $ + Right v === (parseEither parseJSON . toJSON) v diff --git a/libs/brig-types/test/unit/Test/Brig/Types/Common.hs b/libs/brig-types/test/unit/Test/Brig/Types/Common.hs index b0be05ba42e..a36a1fb60bf 100644 --- a/libs/brig-types/test/unit/Test/Brig/Types/Common.hs +++ b/libs/brig-types/test/unit/Test/Brig/Types/Common.hs @@ -3,6 +3,23 @@ {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-orphans #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | This is where currently all the json roundtrip tests happen for brig-types and -- galley-types. module Test.Brig.Types.Common where @@ -12,12 +29,11 @@ import Brig.Types.Team.LegalHold import Brig.Types.Test.Arbitrary () import Control.Lens import Data.Aeson -import Data.Aeson.Types -import Data.Typeable (typeOf) import Galley.Types (CustomBackend) import Galley.Types.Teams import Galley.Types.Teams.SSO import Imports +import Test.Brig.Roundtrip (testRoundTrip) import Test.Tasty import Test.Tasty.HUnit import Test.Tasty.QuickCheck @@ -28,48 +44,38 @@ tests :: TestTree tests = testGroup "Common (types vs. aeson)" - [ run @Name, - run @ColourId, - run @Email, - run @Phone, - run @UserIdentity, - run @UserSSOId, - run @AssetSize, - run @Asset, - run @ExcludedPrefix, - run @ManagedBy, - run @TeamMemberDeleteData, - run @LegalHoldStatus, - run @LegalHoldTeamConfig, - run @NewLegalHoldService, - run @LegalHoldService, - run @ViewLegalHoldService, - run @NewLegalHoldClient, - run @RequestNewLegalHoldClient, - run @UserLegalHoldStatusResponse, - run @LegalHoldServiceConfirm, - run @LegalHoldClientRequest, - run @RemoveLegalHoldSettingsRequest, - run @DisableLegalHoldForUserRequest, - run @ApproveLegalHoldForUserRequest, - run @SSOStatus, - run @SSOTeamConfig, - run @CustomBackend, - run @FeatureFlags, + [ testRoundTrip @Name, + testRoundTrip @ColourId, + testRoundTrip @Email, + testRoundTrip @Phone, + testRoundTrip @UserIdentity, + testRoundTrip @UserSSOId, + testRoundTrip @AssetSize, + testRoundTrip @Asset, + testRoundTrip @ExcludedPrefix, + testRoundTrip @ManagedBy, + testRoundTrip @TeamMemberDeleteData, + testRoundTrip @LegalHoldStatus, + testRoundTrip @LegalHoldTeamConfig, + testRoundTrip @NewLegalHoldService, + testRoundTrip @LegalHoldService, + testRoundTrip @ViewLegalHoldService, + testRoundTrip @NewLegalHoldClient, + testRoundTrip @RequestNewLegalHoldClient, + testRoundTrip @UserLegalHoldStatusResponse, + testRoundTrip @LegalHoldServiceConfirm, + testRoundTrip @LegalHoldClientRequest, + testRoundTrip @RemoveLegalHoldSettingsRequest, + testRoundTrip @DisableLegalHoldForUserRequest, + testRoundTrip @ApproveLegalHoldForUserRequest, + testRoundTrip @SSOStatus, + testRoundTrip @SSOTeamConfig, + testRoundTrip @CustomBackend, + testRoundTrip @FeatureFlags, + testRoundTrip @TruncatedTeamSize, testCase "{} is a valid TeamMemberDeleteData" $ do assertEqual "{}" (Right $ newTeamMemberDeleteData Nothing) (eitherDecode "{}") ] - where - run :: - forall a. - (Arbitrary a, Typeable a, ToJSON a, FromJSON a, Eq a, Show a) => - TestTree - run = testProperty msg trip - where - msg = show $ typeOf (undefined :: a) - trip (v :: a) = - counterexample (show $ toJSON v) $ - Right v === (parseEither parseJSON . toJSON) v instance Arbitrary TeamMemberDeleteData where arbitrary = newTeamMemberDeleteData <$> arbitrary @@ -91,3 +97,9 @@ instance Arbitrary FeatureFlags where FeatureFlags <$> Test.Tasty.QuickCheck.elements [minBound ..] <*> Test.Tasty.QuickCheck.elements [minBound ..] + +instance Arbitrary TruncatedTeamSize where + arbitrary = + mkTruncatedTeamSize + <$> arbitrary + <*> arbitrary diff --git a/libs/brig-types/test/unit/Test/Brig/Types/TURN.hs b/libs/brig-types/test/unit/Test/Brig/Types/TURN.hs index 6663314fe4e..9d6305a40c0 100644 --- a/libs/brig-types/test/unit/Test/Brig/Types/TURN.hs +++ b/libs/brig-types/test/unit/Test/Brig/Types/TURN.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Test.Brig.Types.TURN where import Brig.Types.TURN hiding (turnURI) diff --git a/libs/brig-types/test/unit/Test/Brig/Types/Team.hs b/libs/brig-types/test/unit/Test/Brig/Types/Team.hs new file mode 100644 index 00000000000..9a7c2969b7b --- /dev/null +++ b/libs/brig-types/test/unit/Test/Brig/Types/Team.hs @@ -0,0 +1,32 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Test.Brig.Types.Team where + +import Brig.Types.Team +import Imports +import Test.Brig.Roundtrip (testRoundTrip) +import Test.Tasty +import Test.Tasty.QuickCheck (Arbitrary, arbitrary, arbitrarySizedNatural) + +tests :: TestTree +tests = testGroup "Team" $ [testRoundTrip @TeamSize] + +instance Arbitrary TeamSize where + arbitrary = TeamSize <$> arbitrarySizedNatural diff --git a/libs/brig-types/test/unit/Test/Brig/Types/User.hs b/libs/brig-types/test/unit/Test/Brig/Types/User.hs index dc9c9ddac50..e17b3a4c542 100644 --- a/libs/brig-types/test/unit/Test/Brig/Types/User.hs +++ b/libs/brig-types/test/unit/Test/Brig/Types/User.hs @@ -7,6 +7,23 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Test.Brig.Types.User where import Brig.Types.Activation @@ -19,13 +36,11 @@ import Data.Aeson import Data.Aeson.QQ import Data.Aeson.Types as Aeson import qualified Data.Map as Map -import Data.Typeable (typeOf) import Galley.Types.Teams import Imports -import Test.QuickCheck +import Test.Brig.Roundtrip import Test.Tasty import Test.Tasty.HUnit -import Test.Tasty.QuickCheck tests :: TestTree tests = testGroup "User (types vs. aeson)" $ unitTests <> roundtripTests @@ -176,45 +191,34 @@ unitTests = roundtripTests :: [TestTree] roundtripTests = - [ run @BindingNewTeamUser, - run @CheckHandles, - run @CompletePasswordReset, - run @DeleteUser, - run @DeletionCodeTimeout, - run @EmailRemove, - run @EmailUpdate, - run @HandleUpdate, - run @InvitationList, - run @Invitation, - run @InvitationRequest, - run @LocaleUpdate, - run @NewPasswordReset, - run @NewUser, - run @PasswordChange, - run @PhoneRemove, - run @PhoneUpdate, - run @ManagedByUpdate, - run @ReAuthUser, - run @SelfProfile, - run @TeamMember, - run @UpdateServiceWhitelist, - run @UserHandleInfo, - run @UserIdentity, - run @UserProfile, - run @User, - run @RichInfo, - run @UserUpdate, - run @RichInfoUpdate, - run @VerifyDeleteUser + [ testRoundTrip @BindingNewTeamUser, + testRoundTrip @CheckHandles, + testRoundTrip @CompletePasswordReset, + testRoundTrip @DeleteUser, + testRoundTrip @DeletionCodeTimeout, + testRoundTrip @EmailRemove, + testRoundTrip @EmailUpdate, + testRoundTrip @HandleUpdate, + testRoundTrip @InvitationList, + testRoundTrip @Invitation, + testRoundTrip @InvitationRequest, + testRoundTrip @LocaleUpdate, + testRoundTrip @NewPasswordReset, + testRoundTrip @NewUser, + testRoundTrip @PasswordChange, + testRoundTrip @PhoneRemove, + testRoundTrip @PhoneUpdate, + testRoundTrip @ManagedByUpdate, + testRoundTrip @ReAuthUser, + testRoundTrip @SelfProfile, + testRoundTrip @TeamMember, + testRoundTrip @UpdateServiceWhitelist, + testRoundTrip @UserHandleInfo, + testRoundTrip @UserIdentity, + testRoundTrip @UserProfile, + testRoundTrip @User, + testRoundTrip @RichInfo, + testRoundTrip @UserUpdate, + testRoundTrip @RichInfoUpdate, + testRoundTrip @VerifyDeleteUser ] - where - run :: - forall a. - (Arbitrary a, Typeable a, ToJSON a, FromJSON a, Eq a, Show a) => - TestTree - run = testProperty msg trip - where - msg = show $ typeOf (undefined :: a) - trip (v :: a) = - counterexample (show $ toJSON v) $ - Right v === (parseEither parseJSON . toJSON) v diff --git a/libs/cargohold-types/cargohold-types.cabal b/libs/cargohold-types/cargohold-types.cabal new file mode 100644 index 00000000000..ab45a8f6929 --- /dev/null +++ b/libs/cargohold-types/cargohold-types.cabal @@ -0,0 +1,52 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 7edcd36d24f5398798920a6ee316d3174d152a77fb531b3d3f8561286506d295 + +name: cargohold-types +version: 1.5.0 +synopsis: Asset Storage API Types +description: API Types for the CargoHold service. +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + CargoHold.Types + CargoHold.Types.V3 + CargoHold.Types.V3.Resumable + other-modules: + Paths_cargohold_types + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson >=0.6 + , attoparsec >=0.10 + , base ==4.* + , base16-bytestring >=0.1 + , base64-bytestring >=1.0 + , byteable >=0.1 + , bytestring >=0.9 + , bytestring-conversion >=0.2 + , containers >=0.5 + , cryptonite >=0.11 + , data-default >=0.5 + , imports + , lens >=4.13 + , memory >=0.11 + , mime >=0.4 + , text >=0.11 + , time >=1.5 + , types-common >=0.16 + , unordered-containers >=0.2 + , uuid >=1.2 + default-language: Haskell2010 diff --git a/libs/cargohold-types/src/CargoHold/Types.hs b/libs/cargohold-types/src/CargoHold/Types.hs index b50ad524f77..c63d4e8829b 100644 --- a/libs/cargohold-types/src/CargoHold/Types.hs +++ b/libs/cargohold-types/src/CargoHold/Types.hs @@ -1,3 +1,23 @@ -module CargoHold.Types (module V3) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module CargoHold.Types + ( module V3, + ) +where import CargoHold.Types.V3 as V3 diff --git a/libs/cargohold-types/src/CargoHold/Types/V3.hs b/libs/cargohold-types/src/CargoHold/Types/V3.hs index 025bdb4c263..c7f6d1aa8d7 100644 --- a/libs/cargohold-types/src/CargoHold/Types/V3.hs +++ b/libs/cargohold-types/src/CargoHold/Types/V3.hs @@ -3,6 +3,23 @@ {-# LANGUAGE StrictData #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module CargoHold.Types.V3 ( -- * Body Construction buildMultipartBody, diff --git a/libs/cargohold-types/src/CargoHold/Types/V3/Resumable.hs b/libs/cargohold-types/src/CargoHold/Types/V3/Resumable.hs index 0b839719a21..6c8256aadb2 100644 --- a/libs/cargohold-types/src/CargoHold/Types/V3/Resumable.hs +++ b/libs/cargohold-types/src/CargoHold/Types/V3/Resumable.hs @@ -3,6 +3,23 @@ {-# LANGUAGE StrictData #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module CargoHold.Types.V3.Resumable ( ResumableSettings, mkResumableSettings, diff --git a/libs/cassandra-util/cassandra-util.cabal b/libs/cassandra-util/cassandra-util.cabal new file mode 100644 index 00000000000..6130782efeb --- /dev/null +++ b/libs/cassandra-util/cassandra-util.cabal @@ -0,0 +1,59 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 4b6e1302b2f3f0c59820223b656b21aeb8634a3697b272f2546dc957818a3310 + +name: cassandra-util +version: 0.16.5 +synopsis: Cassandra Utilities +category: Database +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Cassandra + Cassandra.CQL + Cassandra.Exec + Cassandra.Schema + Cassandra.Settings + Cassandra.Util + other-modules: + Paths_cassandra_util + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson >=0.7 + , base >=4.6 && <5.0 + , conduit + , cql >=3.0.0 + , cql-io >=0.14 + , cql-io-tinylog + , dns >=3.0 + , errors >=1.4 + , exceptions >=0.6 + , imports + , lens >=4.4 + , lens-aeson >=1.0 + , mtl ==2.* + , optparse-applicative >=0.10 + , retry + , semigroups >=0.15 + , split >=0.2 + , text >=0.11 + , time >=1.4 + , tinylog >=0.7 + , transformers >=0.3 + , unliftio-core >=0.1 + , uuid + , wreq >=0.2 + default-language: Haskell2010 diff --git a/libs/cassandra-util/src/Cassandra.hs b/libs/cassandra-util/src/Cassandra.hs index 93863d7ce23..31b9c4ed856 100644 --- a/libs/cassandra-util/src/Cassandra.hs +++ b/libs/cassandra-util/src/Cassandra.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | The top import of our Cassandra utility library. Essentially, a "everyone who needs cassandra needs this" import. module Cassandra ( module C, @@ -40,7 +57,7 @@ import Cassandra.Exec as C Client, ClientState, MonadClient, - Page, + Page (..), PrepQuery, Row, addPrepQuery, diff --git a/libs/cassandra-util/src/Cassandra/CQL.hs b/libs/cassandra-util/src/Cassandra/CQL.hs index 04ea5da7414..995c9a9a653 100644 --- a/libs/cassandra-util/src/Cassandra/CQL.hs +++ b/libs/cassandra-util/src/Cassandra/CQL.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | This module just exports components from cassandra's Database.CQL.Protocol. module Cassandra.CQL ( module C, diff --git a/libs/cassandra-util/src/Cassandra/Exec.hs b/libs/cassandra-util/src/Cassandra/Exec.hs index cc2af0527c8..711b2beda91 100644 --- a/libs/cassandra-util/src/Cassandra/Exec.hs +++ b/libs/cassandra-util/src/Cassandra/Exec.hs @@ -1,6 +1,23 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | This module exports components from Cassandra's Database.CQL.IO, adding a few functions we find useful, that are built on top of it. module Cassandra.Exec ( params, @@ -17,7 +34,7 @@ import Cassandra.CQL (Consistency, R) import Control.Monad.Catch import Data.Conduit -- Things we just import and re-export. -import Database.CQL.IO as C (BatchM, Client, ClientState, MonadClient, Page (hasMore, nextPage, result), PrepQuery, Row, addPrepQuery, addQuery, adjustConsistency, adjustResponseTimeout, adjustSendTimeout, batch, emptyPage, init, liftClient, localState, paginate, prepared, query, query1, queryString, retry, runClient, schema, setConsistency, setSerialConsistency, setType, shutdown, trans, write) +import Database.CQL.IO as C (BatchM, Client, ClientState, MonadClient, Page (..), PrepQuery, Row, addPrepQuery, addQuery, adjustConsistency, adjustResponseTimeout, adjustSendTimeout, batch, emptyPage, init, liftClient, localState, paginate, prepared, query, query1, queryString, retry, runClient, schema, setConsistency, setSerialConsistency, setType, shutdown, trans, write) -- We only use these locally. import Database.CQL.IO (RetrySettings, RunQ, defRetrySettings, eagerRetrySettings) import Database.CQL.Protocol (Error, QueryParams (QueryParams), Tuple) diff --git a/libs/cassandra-util/src/Cassandra/Schema.hs b/libs/cassandra-util/src/Cassandra/Schema.hs index 72d26f54bbf..6dd310655d9 100644 --- a/libs/cassandra-util/src/Cassandra/Schema.hs +++ b/libs/cassandra-util/src/Cassandra/Schema.hs @@ -3,6 +3,23 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- Additional functionality on top of our cassandra library. Used by brig, brig's schema definitions, Spar, Spar's schema definitions, Galley, Galley's schema definitions, Gundeck, and Gundeck's schema definitions. module Cassandra.Schema diff --git a/libs/cassandra-util/src/Cassandra/Settings.hs b/libs/cassandra-util/src/Cassandra/Settings.hs index f089701e7cc..eab36353dc1 100644 --- a/libs/cassandra-util/src/Cassandra/Settings.hs +++ b/libs/cassandra-util/src/Cassandra/Settings.hs @@ -1,6 +1,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | This module exports types and functions from Database.CQL.IO, while adding a few wire specific functions. module Cassandra.Settings ( module C, diff --git a/libs/cassandra-util/src/Cassandra/Util.hs b/libs/cassandra-util/src/Cassandra/Util.hs index 16ed3af97dd..828c02e5706 100644 --- a/libs/cassandra-util/src/Cassandra/Util.hs +++ b/libs/cassandra-util/src/Cassandra/Util.hs @@ -1,4 +1,26 @@ -module Cassandra.Util (writeTimeToUTC, defInitCassandra, Writetime) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Cassandra.Util + ( writeTimeToUTC, + defInitCassandra, + Writetime, + ) +where import Cassandra (ClientState, Keyspace (Keyspace), init) import Cassandra.Settings (defSettings, setContacts, setKeyspace, setLogger, setPortNumber) diff --git a/libs/extended/extended.cabal b/libs/extended/extended.cabal new file mode 100644 index 00000000000..a332a2fe4f6 --- /dev/null +++ b/libs/extended/extended.cabal @@ -0,0 +1,57 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 6d1c11d003f9c50397c8bc6ff6b07138dc00200844cb86411aa895fa49ca81f6 + +name: extended +version: 0.1.0 +synopsis: Extended versions of common modules +description: .Extended versions of various libraries from Hackage. See + https://jaspervdj.be/posts/2015-01-20-haskell-design-patterns-extended-modules.html + for a description of this design pattern. +category: Utilities +stability: experimental +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2018 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Options.Applicative.Extended + Servant.API.Extended + System.Logger.Extended + other-modules: + Paths_extended + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson + , base + , bytestring + , cql-io + , errors + , exceptions + , extra + , http-types + , imports + , mtl + , optparse-applicative + , servant + , servant-client + , servant-server + , servant-swagger + , string-conversions + , text + , tinylog + , transformers + , unliftio + , wai + default-language: Haskell2010 diff --git a/libs/extended/src/Options/Applicative/Extended.hs b/libs/extended/src/Options/Applicative/Extended.hs index 90784f4341a..d5050caf498 100644 --- a/libs/extended/src/Options/Applicative/Extended.hs +++ b/libs/extended/src/Options/Applicative/Extended.hs @@ -1,5 +1,22 @@ {-# LANGUAGE NoImplicitPrelude #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | A version of "Options.Applicative" with extra utilities. module Options.Applicative.Extended ( module Options.Applicative, diff --git a/libs/extended/src/Servant/API/Extended.hs b/libs/extended/src/Servant/API/Extended.hs index 8ce596d14da..9b8a7c1c70c 100644 --- a/libs/extended/src/Servant/API/Extended.hs +++ b/libs/extended/src/Servant/API/Extended.hs @@ -1,5 +1,22 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | Code from "Servant.Server.Internal", modified very slightly to allow for returning json -- errors instead of plaintext. module Servant.API.Extended where diff --git a/libs/extended/src/System/Logger/Extended.hs b/libs/extended/src/System/Logger/Extended.hs index 40a0b820264..352e344cfc3 100644 --- a/libs/extended/src/System/Logger/Extended.hs +++ b/libs/extended/src/System/Logger/Extended.hs @@ -2,6 +2,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# OPTIONS_GHC -Wno-orphans #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | Tinylog convenience things. module System.Logger.Extended ( module Log, diff --git a/libs/federation-util/federation-util.cabal b/libs/federation-util/federation-util.cabal new file mode 100644 index 00000000000..8f8a57aef2f --- /dev/null +++ b/libs/federation-util/federation-util.cabal @@ -0,0 +1,85 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 312f8e843a350a0a87c70b3b868a3e29f0ec6d30aaa8913ec0a40e33ba30e6bd + +name: federation-util +version: 0.1.0 +synopsis: Various helpers for federation +description: Small helper functions useful when federating. +category: Web +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2020 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Network.Federation.Util + Network.Federation.Util.DNS + Network.Federation.Util.Internal + other-modules: + Paths_federation_util + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + async >=2.0 + , base >=4.6 && <5.0 + , bytestring >=0.10 + , bytestring-conversion >=0.3 + , containers >=0.5 + , dns + , errors >=2.0 + , exceptions >=0.6 + , http-types >=0.8 + , imports + , random + , stm + , streaming-commons >=0.1 + , string-conversions + , text >=0.11 + , tinylog >=0.8 + , transformers >=0.3 + default-language: Haskell2010 + +test-suite spec + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Test.DNSSpec + Paths_federation_util + hs-source-dirs: + test + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path -threaded -rtsopts -with-rtsopts=-N + build-depends: + QuickCheck + , async >=2.0 + , base >=4.6 && <5.0 + , bytestring >=0.10 + , bytestring-conversion >=0.3 + , containers >=0.5 + , dns + , errors >=2.0 + , exceptions >=0.6 + , federation-util + , hspec + , hspec-discover + , http-types >=0.8 + , imports + , random + , stm + , streaming-commons >=0.1 + , string-conversions + , text >=0.11 + , tinylog >=0.8 + , transformers >=0.3 + , uri-bytestring + default-language: Haskell2010 diff --git a/libs/federation-util/src/Network/Federation/Util.hs b/libs/federation-util/src/Network/Federation/Util.hs index 748bd3faffb..bd9a191b618 100644 --- a/libs/federation-util/src/Network/Federation/Util.hs +++ b/libs/federation-util/src/Network/Federation/Util.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Federation.Util ( module Network.Federation.Util.DNS, ) diff --git a/libs/federation-util/src/Network/Federation/Util/DNS.hs b/libs/federation-util/src/Network/Federation/Util/DNS.hs index bc3bc207d9c..dbbc34481f7 100644 --- a/libs/federation-util/src/Network/Federation/Util/DNS.hs +++ b/libs/federation-util/src/Network/Federation/Util/DNS.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Network.Federation.Util.DNS ( srvLookup, ) diff --git a/libs/federation-util/src/Network/Federation/Util/Internal.hs b/libs/federation-util/src/Network/Federation/Util/Internal.hs index 6f3c16e4d15..a45db92e7f0 100644 --- a/libs/federation-util/src/Network/Federation/Util/Internal.hs +++ b/libs/federation-util/src/Network/Federation/Util/Internal.hs @@ -1,3 +1,60 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . +-- +-- Parts of this code, namely functions srvLookup'' and orderSrvResult, +-- which were taken from http://hackage.haskell.org/package/pontarius-xmpp +-- are also licensed under the three-clause BSD license: +-- +-- Copyright © 2005-2011 Dmitry Astapov +-- Copyright © 2005-2011 Pierre Kovalev +-- Copyright © 2010-2011 Mahdi Abdinejadi +-- Copyright © 2010-2013 Jon Kristensen +-- Copyright © 2011 IETF Trust +-- Copyright © 2012-2013 Philipp Balzarek +-- +-- All rights reserved. +-- +-- Pontarius XMPP is licensed under the three-clause BSD license. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are met: +-- +-- - Redistributions of source code must retain the above copyright notice, this +-- list of conditions and the following disclaimer. +-- +-- - Redistributions in binary form must reproduce the above copyright notice, +-- this list of conditions and the following disclaimer in the documentation +-- and/or other materials provided with the distribution. +-- +-- - Neither the name of the Pontarius project nor the names of its contributors +-- may be used to endorse or promote products derived from this software without +-- specific prior written permission. +-- +-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR THE PONTARIUS PROJECT BE +-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + module Network.Federation.Util.Internal where import Data.Text.Encoding (encodeUtf8) diff --git a/libs/federation-util/test/Spec.hs b/libs/federation-util/test/Spec.hs index a824f8c30c8..7b57431c0d0 100644 --- a/libs/federation-util/test/Spec.hs +++ b/libs/federation-util/test/Spec.hs @@ -1 +1,18 @@ {-# OPTIONS_GHC -F -pgmF hspec-discover #-} + +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . diff --git a/libs/federation-util/test/Test/DNSSpec.hs b/libs/federation-util/test/Test/DNSSpec.hs index a1e943a1e78..de2532e7243 100644 --- a/libs/federation-util/test/Test/DNSSpec.hs +++ b/libs/federation-util/test/Test/DNSSpec.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Test.DNSSpec where import Imports diff --git a/libs/galley-types/galley-types.cabal b/libs/galley-types/galley-types.cabal new file mode 100644 index 00000000000..ddb42a0706b --- /dev/null +++ b/libs/galley-types/galley-types.cabal @@ -0,0 +1,88 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 17c531781908d029505fd232502717c457cd69cdc75158a30937b07dd9f95b87 + +name: galley-types +version: 0.81.0 +description: API types of Galley. +category: Network +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Galley.Types + Galley.Types.Bot + Galley.Types.Bot.Service + Galley.Types.Bot.Service.Internal + Galley.Types.Conversations.Roles + Galley.Types.Proto + Galley.Types.Swagger + Galley.Types.Teams + Galley.Types.Teams.Internal + Galley.Types.Teams.Intra + Galley.Types.Teams.SSO + Galley.Types.Teams.Swagger + other-modules: + Paths_galley_types + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson >=0.6 + , attoparsec >=0.10 + , base >=4 && <5 + , base64-bytestring >=1.0 + , bytestring >=0.9 + , bytestring-conversion >=0.2 + , cassandra-util + , containers >=0.5 + , currency-codes >=2.0 + , data-default >=0.5 + , errors + , exceptions >=0.10.0 + , gundeck-types >=1.15.13 + , hashable + , imports + , lens >=4.12 + , protobuf >=0.2 + , string-conversions + , swagger >=0.1 + , text >=0.11 + , time >=1.4 + , transformers >=0.3 + , types-common >=0.16 + , unordered-containers >=0.2 + , uri-bytestring >=0.2 + , uuid >=1.3 + default-language: Haskell2010 + +test-suite galley-types-tests + type: exitcode-stdio-1.0 + main-is: Main.hs + other-modules: + Test.Galley.Types + Paths_galley_types + hs-source-dirs: + test/unit + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path -threaded -with-rtsopts=-N + build-depends: + base + , containers + , galley-types + , imports + , lens + , tasty + , tasty-hunit + , types-common + default-language: Haskell2010 diff --git a/libs/galley-types/src/Galley/Types.hs b/libs/galley-types/src/Galley/Types.hs index 59440f0b874..7a6d1b33941 100644 --- a/libs/galley-types/src/Galley/Types.hs +++ b/libs/galley-types/src/Galley/Types.hs @@ -5,6 +5,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE StandaloneDeriving #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types ( -- * Galley conversation types Conversation (..), @@ -131,7 +148,7 @@ data Access LinkAccess | -- | User can join knowing [changeable/revokable] code CodeAccess - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Bounded, Enum, Show) -- | AccessRoles define who can join conversations. The roles are -- "supersets", i.e. Activated includes Team and NonActivated includes @@ -443,6 +460,9 @@ deriving instance Show Invite -- Events ------------------------------------------------------------------- +-- FUTUREWORK(federation, #1213): +-- Conversation and user ID can be remote IDs, but the receiver might be on +-- another backend, so mapped IDs don't work for them. data Event = Event { evtType :: !EventType, @@ -470,7 +490,7 @@ data EventType | Typing deriving (Eq, Show, Generic) --- FUTUREWORK(federation): +-- FUTUREWORK(federation, #1213): -- A lot of information in the events can contain remote IDs, but the -- receiver might be on another backend, so mapped IDs don't work for them. data EventData diff --git a/libs/galley-types/src/Galley/Types/Bot.hs b/libs/galley-types/src/Galley/Types/Bot.hs index 29a878de1ed..bf6acb54186 100644 --- a/libs/galley-types/src/Galley/Types/Bot.hs +++ b/libs/galley-types/src/Galley/Types/Bot.hs @@ -2,6 +2,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Bot ( AddBot, addBot, diff --git a/libs/galley-types/src/Galley/Types/Bot/Service.hs b/libs/galley-types/src/Galley/Types/Bot/Service.hs index d0b807fcffc..169a63bd73a 100644 --- a/libs/galley-types/src/Galley/Types/Bot/Service.hs +++ b/libs/galley-types/src/Galley/Types/Bot/Service.hs @@ -2,6 +2,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Bot.Service ( ServiceToken (..), ServiceRef, diff --git a/libs/galley-types/src/Galley/Types/Bot/Service/Internal.hs b/libs/galley-types/src/Galley/Types/Bot/Service/Internal.hs index eda0d49c65f..f28bf53c2f9 100644 --- a/libs/galley-types/src/Galley/Types/Bot/Service/Internal.hs +++ b/libs/galley-types/src/Galley/Types/Bot/Service/Internal.hs @@ -2,6 +2,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Bot.Service.Internal where import Cassandra.CQL diff --git a/libs/galley-types/src/Galley/Types/Conversations/Roles.hs b/libs/galley-types/src/Galley/Types/Conversations/Roles.hs index 83889b9e8fa..00b028b143c 100644 --- a/libs/galley-types/src/Galley/Types/Conversations/Roles.hs +++ b/libs/galley-types/src/Galley/Types/Conversations/Roles.hs @@ -3,6 +3,23 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | This module contains the analog of some of the team-level roles & permissions types in -- "Galley.Types.Teams". module Galley.Types.Conversations.Roles diff --git a/libs/galley-types/src/Galley/Types/Proto.hs b/libs/galley-types/src/Galley/Types/Proto.hs index 4f82be464eb..39991ba9a7d 100644 --- a/libs/galley-types/src/Galley/Types/Proto.hs +++ b/libs/galley-types/src/Galley/Types/Proto.hs @@ -2,6 +2,23 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- FUTUREWORK: generate this file module Galley.Types.Proto ( UserId, diff --git a/libs/galley-types/src/Galley/Types/Swagger.hs b/libs/galley-types/src/Galley/Types/Swagger.hs index 9efa9973dcb..a9e1798f02e 100644 --- a/libs/galley-types/src/Galley/Types/Swagger.hs +++ b/libs/galley-types/src/Galley/Types/Swagger.hs @@ -1,10 +1,30 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Swagger where -import qualified "types-common" Data.Swagger as Swagger +import Data.Aeson (encode) +import Data.String.Conversions (cs) import Data.Swagger.Build.Api as Swagger +import Galley.Types (Access) import Imports +import qualified Wire.Swagger as Swagger galleyModels :: [Model] galleyModels = @@ -293,8 +313,13 @@ conversationUpdateName = defineModel "ConversationUpdateName" $ do conversationAccessUpdate :: Model conversationAccessUpdate = defineModel "ConversationAccessUpdate" $ do description "Contains conversation properties to update" - property "access" (unique $ array bytes') $ - description "List of conversation access modes: []|[invite]|[invite,code]" + property "access" (unique $ array access) $ + description "List of conversation access modes." + property "access_role" (bytes') $ + description "Conversation access role: private|team|activated|non_activated" + +access :: DataType +access = string . enum $ cs . encode <$> [(minBound :: Access) ..] conversationReceiptModeUpdate :: Model conversationReceiptModeUpdate = defineModel "conversationReceiptModeUpdate" $ do diff --git a/libs/galley-types/src/Galley/Types/Teams.hs b/libs/galley-types/src/Galley/Types/Teams.hs index 111c3051531..60cb7080cf9 100644 --- a/libs/galley-types/src/Galley/Types/Teams.hs +++ b/libs/galley-types/src/Galley/Types/Teams.hs @@ -7,6 +7,23 @@ {-# LANGUAGE StrictData #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Teams ( Team, TeamBinding (..), @@ -43,6 +60,7 @@ module Galley.Types.Teams isTeamMember, newTeamMemberList, teamMembers, + teamMemberListHasMore, teamMemberListJson, TeamConversation, newTeamConversation, @@ -101,16 +119,24 @@ module Galley.Types.Teams TeamDeleteData, tdAuthPassword, newTeamDeleteData, + HardTruncationLimit, + hardTruncationLimit, + TruncatedTeamSize, + mkTruncatedTeamSize, + mkLargeTeamSize, + ttsLimit, + ttsSize, + isBiggerThanLimit, ) where import qualified Cassandra as Cql import qualified Control.Error.Util as Err import Control.Exception (ErrorCall (ErrorCall)) -import Control.Lens ((^.), makeLenses, to, view) +import Control.Lens ((.~), (^.), generateUpdateableOptics, lensRules, makeLenses, makeLensesWith, to, view) import Control.Monad.Catch import Data.Aeson -import Data.Aeson.Types (Pair, Parser) +import Data.Aeson.Types (Pair, Parser, typeMismatch) import Data.Bits ((.|.), testBit) import qualified Data.HashMap.Strict as HashMap import Data.Id (ConvId, TeamId, UserId) @@ -118,12 +144,15 @@ import Data.Json.Util import Data.LegalHold (UserLegalHoldStatus (..)) import qualified Data.Maybe as Maybe import Data.Misc (PlainTextPassword (..)) +import Data.Proxy import Data.Range import qualified Data.Set as Set import Data.String.Conversions (cs) import Data.Time (UTCTime) +import GHC.TypeLits import Galley.Types.Teams.Internal import Imports +import Numeric.Natural (Natural) data Event = Event @@ -213,11 +242,36 @@ data TeamMember } deriving (Eq, Ord, Show, Generic) -newtype TeamMemberList +data TeamMemberList = TeamMemberList - { _teamMembers :: [TeamMember] + { _teamMembers :: [TeamMember], + _teamMemberListHasMore :: Bool } - deriving (Semigroup, Monoid, Generic) + deriving (Generic) + +type HardTruncationLimit = (2000 :: Nat) + +hardTruncationLimit :: Integral a => a +hardTruncationLimit = fromIntegral $ natVal (Proxy @HardTruncationLimit) + +data TruncatedTeamSize + = TruncatedTeamSize + { _ttsLimit :: Natural, + _ttsSize :: Maybe Natural + } + deriving (Eq, Show) + +mkTruncatedTeamSize :: Natural -> Natural -> TruncatedTeamSize +mkTruncatedTeamSize limit n = + if n > limit + then TruncatedTeamSize limit Nothing + else TruncatedTeamSize limit (Just n) + +mkLargeTeamSize :: Natural -> TruncatedTeamSize +mkLargeTeamSize limit = TruncatedTeamSize limit Nothing + +isBiggerThanLimit :: TruncatedTeamSize -> Bool +isBiggerThanLimit = isNothing . _ttsSize data TeamConversation = TeamConversation @@ -406,7 +460,7 @@ newTeamMemberRaw uid perms Nothing Nothing lhStatus = pure $ TeamMember uid perms Nothing lhStatus newTeamMemberRaw _ _ _ _ _ = throwM $ ErrorCall "TeamMember with incomplete metadata." -newTeamMemberList :: [TeamMember] -> TeamMemberList +newTeamMemberList :: [TeamMember] -> Bool -> TeamMemberList newTeamMemberList = TeamMemberList newTeamConversation :: ConvId -> Bool -> TeamConversation @@ -463,6 +517,8 @@ makeLenses ''TeamCreationTime makeLenses ''FeatureFlags +makeLensesWith (lensRules & generateUpdateableOptics .~ False) ''TruncatedTeamSize + -- Note [hidden team roles] -- -- The problem: the mapping between 'Role' and 'Permissions' is fixed by external contracts: @@ -716,14 +772,17 @@ instance ToJSON TeamMemberList where -- | Show a list of team members using 'teamMemberJson'. teamMemberListJson :: (TeamMember -> Bool) -> TeamMemberList -> Value teamMemberListJson withPerms l = - object ["members" .= map (teamMemberJson withPerms) (_teamMembers l)] + object + [ "members" .= map (teamMemberJson withPerms) (_teamMembers l), + "hasMore" .= _teamMemberListHasMore l + ] instance FromJSON TeamMember where parseJSON = parseTeamMember instance FromJSON TeamMemberList where parseJSON = withObject "team member list" $ \o -> - TeamMemberList <$> o .: "members" + TeamMemberList <$> o .: "members" <*> o .: "hasMore" instance ToJSON TeamConversation where toJSON t = @@ -925,6 +984,26 @@ instance ToJSON TeamDeleteData where [ "password" .= _tdAuthPassword tdd ] +instance ToJSON TruncatedTeamSize where + toJSON limitedSize = + let sizePairs = + case _ttsSize limitedSize of + Nothing -> ["within-limit" .= False] + Just n -> ["within-limit" .= True, "size" .= n] + in object (["limit" .= _ttsLimit limitedSize] ++ sizePairs) + +instance FromJSON TruncatedTeamSize where + parseJSON = withObject "TruncatedTeamSize" $ \o -> do + withinLimit <- o .: "within-limit" + limit <- o .: "limit" + case withinLimit of + (Bool True) -> (o .: "size") >>= \s -> + if s <= limit + then pure $ TruncatedTeamSize limit (Just s) + else fail $ "expected size to be less than " ++ show limit ++ ", encountered " ++ show s + (Bool False) -> pure $ TruncatedTeamSize limit Nothing + v -> typeMismatch "Boolean" v + instance Cql.Cql Role where ctype = Cql.Tagged Cql.IntColumn diff --git a/libs/galley-types/src/Galley/Types/Teams/Internal.hs b/libs/galley-types/src/Galley/Types/Teams/Internal.hs index 9837e92ca1f..c06c2f21cd6 100644 --- a/libs/galley-types/src/Galley/Types/Teams/Internal.hs +++ b/libs/galley-types/src/Galley/Types/Teams/Internal.hs @@ -6,6 +6,23 @@ {-# LANGUAGE StrictData #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Teams.Internal where import Data.Aeson diff --git a/libs/galley-types/src/Galley/Types/Teams/Intra.hs b/libs/galley-types/src/Galley/Types/Teams/Intra.hs index 70d875683dc..1e0f9f09356 100644 --- a/libs/galley-types/src/Galley/Types/Teams/Intra.hs +++ b/libs/galley-types/src/Galley/Types/Teams/Intra.hs @@ -1,6 +1,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Teams.Intra where import Data.Aeson diff --git a/libs/galley-types/src/Galley/Types/Teams/SSO.hs b/libs/galley-types/src/Galley/Types/Teams/SSO.hs index f1bcb9adcf9..2c1da2697bf 100644 --- a/libs/galley-types/src/Galley/Types/Teams/SSO.hs +++ b/libs/galley-types/src/Galley/Types/Teams/SSO.hs @@ -1,6 +1,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Teams.SSO where import Data.Aeson diff --git a/libs/galley-types/src/Galley/Types/Teams/Swagger.hs b/libs/galley-types/src/Galley/Types/Teams/Swagger.hs index 87e931c06a9..b59113aedec 100644 --- a/libs/galley-types/src/Galley/Types/Teams/Swagger.hs +++ b/libs/galley-types/src/Galley/Types/Teams/Swagger.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Galley.Types.Teams.Swagger where import Data.Swagger.Build.Api @@ -132,6 +149,8 @@ teamMemberList = defineModel "TeamMemberList" $ do description "list of team member" property "members" (unique $ array (ref teamMember)) $ description "the array of team members" + property "hasMore" bool' $ + description "true if 'members' doesn't contain all team members" teamConversation :: Model teamConversation = defineModel "TeamConversation" $ do diff --git a/libs/galley-types/test/unit/Main.hs b/libs/galley-types/test/unit/Main.hs index e282de900d1..98db9cb0285 100644 --- a/libs/galley-types/test/unit/Main.hs +++ b/libs/galley-types/test/unit/Main.hs @@ -1,4 +1,24 @@ -module Main (main) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Main + ( main, + ) +where import Imports import qualified Test.Galley.Types diff --git a/libs/galley-types/test/unit/Test/Galley/Types.hs b/libs/galley-types/test/unit/Test/Galley/Types.hs index 5726c493803..ab9d39d402f 100644 --- a/libs/galley-types/test/unit/Test/Galley/Types.hs +++ b/libs/galley-types/test/unit/Test/Galley/Types.hs @@ -2,6 +2,23 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Test.Galley.Types where import Control.Lens diff --git a/libs/gundeck-types/gundeck-types.cabal b/libs/gundeck-types/gundeck-types.cabal new file mode 100644 index 00000000000..53aefc61687 --- /dev/null +++ b/libs/gundeck-types/gundeck-types.cabal @@ -0,0 +1,53 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: cd6d96d914d3ccd3f3fd20c1e49ad4233088e531421fa53faff209525b523702 + +name: gundeck-types +version: 1.45.0 +description: API types of Gundeck. +category: Network +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Gundeck.Types + Gundeck.Types.BulkPush + Gundeck.Types.Common + Gundeck.Types.Event + Gundeck.Types.Notification + Gundeck.Types.Presence + Gundeck.Types.Push + Gundeck.Types.Push.V2 + Gundeck.Types.Swagger + other-modules: + Paths_gundeck_types + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson >=0.6 + , attoparsec >=0.10 + , base >=4 && <5 + , base64-bytestring >=1.0 + , bytestring >=0.10 + , bytestring-conversion >=0.2 + , containers >=0.5 + , imports + , lens >=4.11 + , network-uri >=2.6 + , swagger >=0.1 + , text >=0.11 + , time >=1.5 + , types-common >=0.16 + , unordered-containers >=0.2 + default-language: Haskell2010 diff --git a/libs/gundeck-types/src/Gundeck/Types.hs b/libs/gundeck-types/src/Gundeck/Types.hs index 50207c97e6b..1213ab6244c 100644 --- a/libs/gundeck-types/src/Gundeck/Types.hs +++ b/libs/gundeck-types/src/Gundeck/Types.hs @@ -1,4 +1,24 @@ -module Gundeck.Types (module G) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Gundeck.Types + ( module G, + ) +where import Gundeck.Types.Event as G import Gundeck.Types.Notification as G diff --git a/libs/gundeck-types/src/Gundeck/Types/BulkPush.hs b/libs/gundeck-types/src/Gundeck/Types/BulkPush.hs index d86b44b3fb7..40585a42f8b 100644 --- a/libs/gundeck-types/src/Gundeck/Types/BulkPush.hs +++ b/libs/gundeck-types/src/Gundeck/Types/BulkPush.hs @@ -3,6 +3,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | This module defines the types used by the Cannon API. It is contained in package gundeck-types -- for the pragmatic reason that it allows us to re-use types from the gundeck API. (This move can -- be justified by picturing Cannon as a local service that makes only sense in the context of a diff --git a/libs/gundeck-types/src/Gundeck/Types/Common.hs b/libs/gundeck-types/src/Gundeck/Types/Common.hs index 977448cbc00..13627bef82f 100644 --- a/libs/gundeck-types/src/Gundeck/Types/Common.hs +++ b/libs/gundeck-types/src/Gundeck/Types/Common.hs @@ -1,5 +1,22 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Gundeck.Types.Common where import Data.Aeson diff --git a/libs/gundeck-types/src/Gundeck/Types/Event.hs b/libs/gundeck-types/src/Gundeck/Types/Event.hs index 10f14063653..34341031d43 100644 --- a/libs/gundeck-types/src/Gundeck/Types/Event.hs +++ b/libs/gundeck-types/src/Gundeck/Types/Event.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Gundeck.Types.Event where import Data.Aeson diff --git a/libs/gundeck-types/src/Gundeck/Types/Notification.hs b/libs/gundeck-types/src/Gundeck/Types/Notification.hs index 89621b19787..5e909f035f8 100644 --- a/libs/gundeck-types/src/Gundeck/Types/Notification.hs +++ b/libs/gundeck-types/src/Gundeck/Types/Notification.hs @@ -1,6 +1,23 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Gundeck.Types.Notification ( -- * Notification Notification (..), diff --git a/libs/gundeck-types/src/Gundeck/Types/Presence.hs b/libs/gundeck-types/src/Gundeck/Types/Presence.hs index 9c66df212b5..23e76a064ca 100644 --- a/libs/gundeck-types/src/Gundeck/Types/Presence.hs +++ b/libs/gundeck-types/src/Gundeck/Types/Presence.hs @@ -1,6 +1,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Gundeck.Types.Presence ( module Gundeck.Types.Presence, module Common, diff --git a/libs/gundeck-types/src/Gundeck/Types/Push.hs b/libs/gundeck-types/src/Gundeck/Types/Push.hs index 6f5b534755c..4213e4c2060 100644 --- a/libs/gundeck-types/src/Gundeck/Types/Push.hs +++ b/libs/gundeck-types/src/Gundeck/Types/Push.hs @@ -1,3 +1,23 @@ -module Gundeck.Types.Push (module V2) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Gundeck.Types.Push + ( module V2, + ) +where import Gundeck.Types.Push.V2 as V2 diff --git a/libs/gundeck-types/src/Gundeck/Types/Push/V2.hs b/libs/gundeck-types/src/Gundeck/Types/Push/V2.hs index fbdcff5578c..384286a9165 100644 --- a/libs/gundeck-types/src/Gundeck/Types/Push/V2.hs +++ b/libs/gundeck-types/src/Gundeck/Types/Push/V2.hs @@ -5,6 +5,23 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Gundeck.Types.Push.V2 ( Push (..), newPush, diff --git a/libs/gundeck-types/src/Gundeck/Types/Swagger.hs b/libs/gundeck-types/src/Gundeck/Types/Swagger.hs index cee32999213..ff1a30bf31c 100644 --- a/libs/gundeck-types/src/Gundeck/Types/Swagger.hs +++ b/libs/gundeck-types/src/Gundeck/Types/Swagger.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Gundeck.Types.Swagger where import Data.Swagger.Build.Api diff --git a/libs/imports/imports.cabal b/libs/imports/imports.cabal new file mode 100644 index 00000000000..fd671b53a90 --- /dev/null +++ b/libs/imports/imports.cabal @@ -0,0 +1,47 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 46140b9b362cced4d847a47014015a2517bfaaa4203a1d359d61963e7be044cd + +name: imports +version: 0.1.0 +synopsis: Very common imports +description: A single module combining some common imports. Designed to be + usable as a drop-in Prelude replacement. + . + Also exports common orphan instances. +category: Utilities +stability: experimental +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2018 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Imports + other-modules: + Paths_imports + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + base + , bytestring + , containers + , deepseq + , extra + , mtl + , text + , tinylog + , transformers + , unliftio + , unliftio-core + , unordered-containers + default-language: Haskell2010 diff --git a/libs/imports/src/Imports.hs b/libs/imports/src/Imports.hs index 21a14a665a2..a27af8c0cef 100644 --- a/libs/imports/src/Imports.hs +++ b/libs/imports/src/Imports.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | Imports that are supposed to be used in all wire-server code. module Imports ( -- * Base diff --git a/libs/libzauth/libzauth-c/src/lib.rs b/libs/libzauth/libzauth-c/src/lib.rs index 1b87759fefb..be8bb949fac 100644 --- a/libs/libzauth/libzauth-c/src/lib.rs +++ b/libs/libzauth/libzauth-c/src/lib.rs @@ -1,3 +1,20 @@ +// This file is part of the Wire Server implementation. +// +// Copyright (C) 2020 Wire Swiss GmbH +// +// 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 . + extern crate libc; extern crate zauth; diff --git a/libs/libzauth/libzauth/examples/verify.rs b/libs/libzauth/libzauth/examples/verify.rs index 8b35c2e91b9..19d256bb0b4 100644 --- a/libs/libzauth/libzauth/examples/verify.rs +++ b/libs/libzauth/libzauth/examples/verify.rs @@ -1,3 +1,20 @@ +// This file is part of the Wire Server implementation. +// +// Copyright (C) 2020 Wire Swiss GmbH +// +// 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 . + extern crate clap; extern crate zauth; diff --git a/libs/libzauth/libzauth/src/acl.rs b/libs/libzauth/libzauth/src/acl.rs index d83d6558069..65f6910ad5c 100644 --- a/libs/libzauth/libzauth/src/acl.rs +++ b/libs/libzauth/libzauth/src/acl.rs @@ -1,3 +1,20 @@ +// This file is part of the Wire Server implementation. +// +// Copyright (C) 2020 Wire Swiss GmbH +// +// 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 . + use std::collections::HashMap; use asexp::Sexp; use tree::Tree; diff --git a/libs/libzauth/libzauth/src/error.rs b/libs/libzauth/libzauth/src/error.rs index 81fc9f0eb23..45ee5ad0b30 100644 --- a/libs/libzauth/libzauth/src/error.rs +++ b/libs/libzauth/libzauth/src/error.rs @@ -1,3 +1,20 @@ +// This file is part of the Wire Server implementation. +// +// Copyright (C) 2020 Wire Swiss GmbH +// +// 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 . + use rustc_serialize::base64::FromBase64Error; use std::error; use std::fmt; diff --git a/libs/libzauth/libzauth/src/lib.rs b/libs/libzauth/libzauth/src/lib.rs index f939dfff42b..e7243089edc 100644 --- a/libs/libzauth/libzauth/src/lib.rs +++ b/libs/libzauth/libzauth/src/lib.rs @@ -1,3 +1,20 @@ +// This file is part of the Wire Server implementation. +// +// Copyright (C) 2020 Wire Swiss GmbH +// +// 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 . + extern crate asexp; extern crate rustc_serialize; extern crate sodiumoxide; diff --git a/libs/libzauth/libzauth/src/tree.rs b/libs/libzauth/libzauth/src/tree.rs index 9d048cfa517..98c82bd517f 100644 --- a/libs/libzauth/libzauth/src/tree.rs +++ b/libs/libzauth/libzauth/src/tree.rs @@ -1,3 +1,20 @@ +// This file is part of the Wire Server implementation. +// +// Copyright (C) 2020 Wire Swiss GmbH +// +// 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 . + //! Internal module to provide efficient lookup trees for paths. //! Actually a port of wai-zauth's Network.Wai.Zauth.Tree with //! the addtional support for "deep wildcards" (specified with "**"). diff --git a/libs/libzauth/libzauth/src/zauth.rs b/libs/libzauth/libzauth/src/zauth.rs index 42eec64f147..af0bf5c5397 100644 --- a/libs/libzauth/libzauth/src/zauth.rs +++ b/libs/libzauth/libzauth/src/zauth.rs @@ -1,3 +1,20 @@ +// This file is part of the Wire Server implementation. +// +// Copyright (C) 2020 Wire Swiss GmbH +// +// 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 . + use rustc_serialize::base64::FromBase64; use sodiumoxide::crypto::sign::ed25519::{PublicKey, Signature, verify_detached}; use std::collections::HashMap; diff --git a/libs/metrics-core/metrics-core.cabal b/libs/metrics-core/metrics-core.cabal new file mode 100644 index 00000000000..88911bd50b0 --- /dev/null +++ b/libs/metrics-core/metrics-core.cabal @@ -0,0 +1,42 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 41d05423bb5ecff238b37dda906f942b8e5688f1627637853be687ada4e61693 + +name: metrics-core +version: 0.3.2 +synopsis: Metrics core +category: Data +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Data.Metrics + Data.Metrics.GC + other-modules: + Paths_metrics_core + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + atomic-primops >=0.8 + , base >=4.9 + , containers + , hashable >=1.2 + , immortal + , imports + , prometheus-client + , text >=0.11 + , transformers >=0.3 + , unordered-containers >=0.2 + , vector >=0.10 + default-language: Haskell2010 diff --git a/libs/metrics-core/src/Data/Metrics.hs b/libs/metrics-core/src/Data/Metrics.hs index 00f2c6f46d7..739d956f0fe 100644 --- a/libs/metrics-core/src/Data/Metrics.hs +++ b/libs/metrics-core/src/Data/Metrics.hs @@ -1,6 +1,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Data.Metrics ( -- * Types Path, diff --git a/libs/metrics-core/src/Data/Metrics/GC.hs b/libs/metrics-core/src/Data/Metrics/GC.hs index f991b2349d4..adc3b37703c 100644 --- a/libs/metrics-core/src/Data/Metrics/GC.hs +++ b/libs/metrics-core/src/Data/Metrics/GC.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Data.Metrics.GC ( spawnGCMetricsCollector, ) diff --git a/libs/metrics-wai/metrics-wai.cabal b/libs/metrics-wai/metrics-wai.cabal new file mode 100644 index 00000000000..e8eaca8d80c --- /dev/null +++ b/libs/metrics-wai/metrics-wai.cabal @@ -0,0 +1,53 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 5ae11aea0f562def1900e89b7cec0809fbd3e10edc7eef00cfbfe752b06a147f + +name: metrics-wai +version: 0.5.7 +synopsis: Metrics WAI integration +category: Data +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Data.Metrics.Middleware + Data.Metrics.Middleware.Prometheus + Data.Metrics.Servant + Data.Metrics.Test + Data.Metrics.Types + Data.Metrics.WaiRoute + other-modules: + Paths_metrics_wai + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + ghc-prof-options: -fprof-auto + build-depends: + base ==4.* + , bytestring >=0.10 + , clock >=0.6 + , containers + , exceptions >=0.6 + , http-types >=0.8 + , imports + , metrics-core >=0.3 + , prometheus-client + , servant + , string-conversions + , text >=0.11 + , transformers >=0.3 + , wai >=3 + , wai-middleware-prometheus + , wai-route >=0.3 + , wai-routing + default-language: Haskell2010 diff --git a/libs/metrics-wai/src/Data/Metrics/Middleware.hs b/libs/metrics-wai/src/Data/Metrics/Middleware.hs index ce878f13179..88dd3a81d20 100644 --- a/libs/metrics-wai/src/Data/Metrics/Middleware.hs +++ b/libs/metrics-wai/src/Data/Metrics/Middleware.hs @@ -1,5 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | FUTUREWORK: use package wai-middleware-prometheus instead and deprecate collectd? module Data.Metrics.Middleware ( PathTemplate, diff --git a/libs/metrics-wai/src/Data/Metrics/Middleware/Prometheus.hs b/libs/metrics-wai/src/Data/Metrics/Middleware/Prometheus.hs index b47a57c6fff..e6e19b80465 100644 --- a/libs/metrics-wai/src/Data/Metrics/Middleware/Prometheus.hs +++ b/libs/metrics-wai/src/Data/Metrics/Middleware/Prometheus.hs @@ -1,4 +1,24 @@ -module Data.Metrics.Middleware.Prometheus (waiPrometheusMiddleware) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Data.Metrics.Middleware.Prometheus + ( waiPrometheusMiddleware, + ) +where import Data.Maybe (fromMaybe) import Data.Metrics.Types (Paths) diff --git a/libs/metrics-wai/src/Data/Metrics/Servant.hs b/libs/metrics-wai/src/Data/Metrics/Servant.hs index aebf2a51a51..33607341b5c 100644 --- a/libs/metrics-wai/src/Data/Metrics/Servant.hs +++ b/libs/metrics-wai/src/Data/Metrics/Servant.hs @@ -6,6 +6,23 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | Given a servant API type, this module gives you a 'Paths' for 'withPathTemplate'. module Data.Metrics.Servant where diff --git a/libs/metrics-wai/src/Data/Metrics/Test.hs b/libs/metrics-wai/src/Data/Metrics/Test.hs index 1a5d2fb0168..c5065ffbe36 100644 --- a/libs/metrics-wai/src/Data/Metrics/Test.hs +++ b/libs/metrics-wai/src/Data/Metrics/Test.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Data.Metrics.Test where import Data.Metrics.Types diff --git a/libs/metrics-wai/src/Data/Metrics/Types.hs b/libs/metrics-wai/src/Data/Metrics/Types.hs index 09f759a1fd3..1d9d75f5d9d 100644 --- a/libs/metrics-wai/src/Data/Metrics/Types.hs +++ b/libs/metrics-wai/src/Data/Metrics/Types.hs @@ -4,6 +4,23 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Data.Metrics.Types ( PathTemplate (..), Paths (..), diff --git a/libs/metrics-wai/src/Data/Metrics/WaiRoute.hs b/libs/metrics-wai/src/Data/Metrics/WaiRoute.hs index b0443afe28c..a6803bf94cf 100644 --- a/libs/metrics-wai/src/Data/Metrics/WaiRoute.hs +++ b/libs/metrics-wai/src/Data/Metrics/WaiRoute.hs @@ -2,6 +2,23 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | wai-route-0.4.0 uses a 'Tree' type for route construction. This module lets you -- construct the simpler metrics routing tree from that. module Data.Metrics.WaiRoute where diff --git a/libs/ropes/ropes.cabal b/libs/ropes/ropes.cabal new file mode 100644 index 00000000000..28ecb8e1596 --- /dev/null +++ b/libs/ropes/ropes.cabal @@ -0,0 +1,103 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 3f789e5caaf99371aeab04b920b5b7a1a3ea71687eeb7b49cbaeec83c6b8ed3d + +name: ropes +version: 0.4.20 +synopsis: Various ropes to tie together with external web services. +category: Network +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Ropes.Aws + Ropes.Aws.Ses + Ropes.Nexmo + Ropes.Twilio + other-modules: + Paths_ropes + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson >=0.6 + , aws >=0.10.2 + , base ==4.* + , bytestring >=0.9 + , errors >=2.0 + , exceptions >=0.6 + , http-client >=0.5 + , http-types >=0.7 + , imports + , iso3166-country-codes >=0.20140203.7 + , mime-mail >=0.4 + , resourcet >=1.1 + , retry >=0.7 + , semigroups >=0.11 + , text >=0.11 + , time >=1.1 + , tinylog >=0.10.2 + , transformers >=0.3 + , yaml >=0.8.22 + default-language: Haskell2010 + +executable ropes-aws-auth-test + main-is: Main.hs + other-modules: + Paths_ropes + hs-source-dirs: + test/integration-aws-auth + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path -threaded + build-depends: + aws + , base >=4 && <5 + , bytestring >=0.9 + , errors >=2.0 + , http-client + , imports + , mime-mail >=0.4 + , ropes + , semigroups >=0.11 + , time + , tinylog + default-language: Haskell2010 + +executable ropes-aws-test + main-is: Main.hs + other-modules: + Tests.Ropes.Aws.Ses + Paths_ropes + hs-source-dirs: + test/integration-aws + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path -threaded + build-depends: + aws + , base >=4 && <5 + , bytestring >=0.9 + , errors >=2.0 + , exceptions + , http-client + , http-client-tls + , imports + , mime-mail >=0.4 + , resourcet + , ropes + , semigroups >=0.11 + , tasty >=0.2 + , tasty-hunit >=0.2 + , text >=0.11.3 + , tinylog + , transformers + default-language: Haskell2010 diff --git a/libs/ropes/src/Ropes/Aws.hs b/libs/ropes/src/Ropes/Aws.hs index 60e7cedfb1b..c2441ed8b1a 100644 --- a/libs/ropes/src/Ropes/Aws.hs +++ b/libs/ropes/src/Ropes/Aws.hs @@ -1,6 +1,23 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Ropes.Aws ( -- * Env AccessKeyId (..), diff --git a/libs/ropes/src/Ropes/Aws/Ses.hs b/libs/ropes/src/Ropes/Aws/Ses.hs index e8ad736791e..0345dab1c7e 100644 --- a/libs/ropes/src/Ropes/Aws/Ses.hs +++ b/libs/ropes/src/Ropes/Aws/Ses.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Ropes.Aws.Ses where import Aws.Ses diff --git a/libs/ropes/src/Ropes/Nexmo.hs b/libs/ropes/src/Ropes/Nexmo.hs index eb7824e2595..3bf97801cd9 100644 --- a/libs/ropes/src/Ropes/Nexmo.hs +++ b/libs/ropes/src/Ropes/Nexmo.hs @@ -4,6 +4,23 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Ropes.Nexmo ( -- * Types ApiKey (..), diff --git a/libs/ropes/src/Ropes/Twilio.hs b/libs/ropes/src/Ropes/Twilio.hs index e25f1943839..50eb5a41224 100644 --- a/libs/ropes/src/Ropes/Twilio.hs +++ b/libs/ropes/src/Ropes/Twilio.hs @@ -1,6 +1,23 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Ropes.Twilio ( -- * Types SID (..), diff --git a/libs/ropes/test/integration-aws-auth/Main.hs b/libs/ropes/test/integration-aws-auth/Main.hs index 07643928f1c..c5a369a7617 100644 --- a/libs/ropes/test/integration-aws-auth/Main.hs +++ b/libs/ropes/test/integration-aws-auth/Main.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Main where import Data.Time.Clock diff --git a/libs/ropes/test/integration-aws/Main.hs b/libs/ropes/test/integration-aws/Main.hs index f125cd20481..9e868269199 100644 --- a/libs/ropes/test/integration-aws/Main.hs +++ b/libs/ropes/test/integration-aws/Main.hs @@ -1,4 +1,24 @@ -module Main (main) where +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + +module Main + ( main, + ) +where import Data.ByteString.Char8 (pack) import Imports diff --git a/libs/ropes/test/integration-aws/Tests/Ropes/Aws/Ses.hs b/libs/ropes/test/integration-aws/Tests/Ropes/Aws/Ses.hs index 06cab7ca704..a66e79d8f52 100644 --- a/libs/ropes/test/integration-aws/Tests/Ropes/Aws/Ses.hs +++ b/libs/ropes/test/integration-aws/Tests/Ropes/Aws/Ses.hs @@ -1,6 +1,23 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Tests.Ropes.Aws.Ses ( tests, ) diff --git a/libs/sodium-crypto-sign/sodium-crypto-sign.cabal b/libs/sodium-crypto-sign/sodium-crypto-sign.cabal new file mode 100644 index 00000000000..54a74ae8964 --- /dev/null +++ b/libs/sodium-crypto-sign/sodium-crypto-sign.cabal @@ -0,0 +1,37 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: e269c6982089a3f0f5b7e20f9c88218fed99a2344c98c4c5c75ba382789d9a90 + +name: sodium-crypto-sign +version: 0.1.2 +synopsis: FFI to some of the libsodium crypto_sign_* functions. +description: FFI bindings to some of the libsodium cryptographic signature functions which are based on Ed25519. +category: Cryptography +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Sodium.Crypto.Sign + other-modules: + Paths_sodium_crypto_sign + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + pkgconfig-depends: + libsodium >= 0.4.5 + build-depends: + base >=4.6 && <5 + , base64-bytestring >=1.0 + , bytestring >=0.10 + , imports + default-language: Haskell2010 diff --git a/libs/sodium-crypto-sign/src/Sodium/Crypto/Sign.hsc b/libs/sodium-crypto-sign/src/Sodium/Crypto/Sign.hsc index 249a327f0cb..7b8b7198395 100644 --- a/libs/sodium-crypto-sign/src/Sodium/Crypto/Sign.hsc +++ b/libs/sodium-crypto-sign/src/Sodium/Crypto/Sign.hsc @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + {-# LANGUAGE CPP #-} module Sodium.Crypto.Sign diff --git a/libs/ssl-util/src/Ssl/Util.hs b/libs/ssl-util/src/Ssl/Util.hs index 4c8608a7f56..ef4285e070d 100644 --- a/libs/ssl-util/src/Ssl/Util.hs +++ b/libs/ssl-util/src/Ssl/Util.hs @@ -1,5 +1,22 @@ {-# LANGUAGE TypeApplications #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Ssl.Util ( -- * Public Key Pinning verifyFingerprint, diff --git a/libs/ssl-util/ssl-util.cabal b/libs/ssl-util/ssl-util.cabal new file mode 100644 index 00000000000..69cabe82e44 --- /dev/null +++ b/libs/ssl-util/ssl-util.cabal @@ -0,0 +1,39 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: c47b5a68a5c4c6497c1fdf7420e4c787f72d884eda70231731a57a0d7b02bc52 + +name: ssl-util +version: 0.1.0 +synopsis: SSL-related utilities +category: Network +stability: experimental +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2018 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Ssl.Util + other-modules: + Paths_ssl_util + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + HsOpenSSL >=0.11 + , base >=4.7 && <5 + , byteable >=0.1 + , bytestring >=0.10 + , http-client >=0.4 + , imports + , network >=2.6 + , time >=1.5 + default-language: Haskell2010 diff --git a/libs/tasty-cannon/src/Test/Tasty/Cannon.hs b/libs/tasty-cannon/src/Test/Tasty/Cannon.hs index fa69abdcc3c..8b156d31c95 100644 --- a/libs/tasty-cannon/src/Test/Tasty/Cannon.hs +++ b/libs/tasty-cannon/src/Test/Tasty/Cannon.hs @@ -3,6 +3,23 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Test.Tasty.Cannon ( Cannon, diff --git a/libs/tasty-cannon/tasty-cannon.cabal b/libs/tasty-cannon/tasty-cannon.cabal new file mode 100644 index 00000000000..c2c8ae2cd51 --- /dev/null +++ b/libs/tasty-cannon/tasty-cannon.cabal @@ -0,0 +1,48 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 245a691959757e03022c98c946bc4fe2c2bb6b1882a481d8cf576c0fdfd80064 + +name: tasty-cannon +version: 0.4.0 +synopsis: Cannon Integration Testing Utilities +category: Testing +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Test.Tasty.Cannon + other-modules: + Paths_tasty_cannon + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + build-depends: + aeson + , async + , base >=4.6 && <5 + , bytestring + , bytestring-conversion + , data-default-class + , data-timeout + , exceptions + , gundeck-types + , http-client >=0.5 + , http-types + , imports + , random + , stm + , tasty-hunit >=0.9 + , transformers + , types-common >=0.16 + , websockets >=0.8 + default-language: Haskell2010 diff --git a/libs/types-common-aws/src/Util/Test/SQS.hs b/libs/types-common-aws/src/Util/Test/SQS.hs index 3839d297fbc..4ffa22f3a81 100644 --- a/libs/types-common-aws/src/Util/Test/SQS.hs +++ b/libs/types-common-aws/src/Util/Test/SQS.hs @@ -6,6 +6,23 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Util.Test.SQS where import Control.Exception (SomeAsyncException, asyncExceptionFromException) diff --git a/libs/types-common-aws/types-common-aws.cabal b/libs/types-common-aws/types-common-aws.cabal new file mode 100644 index 00000000000..499090de2f4 --- /dev/null +++ b/libs/types-common-aws/types-common-aws.cabal @@ -0,0 +1,75 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 1d709501a762db52880e7e0ab3c268832b6bee36371162d6caf4bd91536fba3b + +name: types-common-aws +version: 0.16.0 +synopsis: Shared AWS type definitions. +description: AWS Types shared with many other projects. +category: System +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Simple + +flag arbitrary + description: Enable quickcheck's arbitrary instances + manual: True + default: False + +flag protobuf + description: Enable protocol buffers instances + manual: True + default: False + +library + exposed-modules: + Util.Test.SQS + other-modules: + Paths_types_common_aws + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path + ghc-prof-options: -fprof-auto-exported + build-depends: + amazonka + , amazonka-core + , amazonka-sqs + , base ==4.* + , base64-bytestring >=1.0 + , errors >=2.0 + , exceptions + , imports + , lens >=4.10 + , monad-control + , mtl + , proto-lens + , resourcet + , safe >=0.3 + , tasty + , tasty-hunit + , text >=0.11 + , transformers >=0.3 + , transformers-base + , types-common + , unordered-containers >=0.2 + , uri-bytestring >=0.2 + , uuid >=1.3.11 + if impl(ghc >=8) + ghc-options: -fno-warn-redundant-constraints + if flag(protobuf) + cpp-options: -DWITH_PROTOBUF + build-depends: + protobuf >=0.2 + if flag(arbitrary) + cpp-options: -DWITH_ARBITRARY + build-depends: + QuickCheck >=2.9 + default-language: Haskell2010 diff --git a/libs/types-common-journal/Setup.hs b/libs/types-common-journal/Setup.hs index 6532980091a..46b099dae61 100644 --- a/libs/types-common-journal/Setup.hs +++ b/libs/types-common-journal/Setup.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + import Data.ProtoLens.Setup main :: IO () diff --git a/libs/types-common-journal/src/Data/Proto.hs b/libs/types-common-journal/src/Data/Proto.hs index f27b38929c0..2bcebc6ed4b 100644 --- a/libs/types-common-journal/src/Data/Proto.hs +++ b/libs/types-common-journal/src/Data/Proto.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Data.Proto where import Data.Time.Clock (getCurrentTime) diff --git a/libs/types-common-journal/src/Data/Proto/Id.hs b/libs/types-common-journal/src/Data/Proto/Id.hs index 0cc72b7401f..4b11182e9bc 100644 --- a/libs/types-common-journal/src/Data/Proto/Id.hs +++ b/libs/types-common-journal/src/Data/Proto/Id.hs @@ -1,3 +1,20 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Data.Proto.Id where import Data.ByteString.Lazy (fromStrict, toStrict) diff --git a/libs/types-common-journal/types-common-journal.cabal b/libs/types-common-journal/types-common-journal.cabal new file mode 100644 index 00000000000..48c6acc1840 --- /dev/null +++ b/libs/types-common-journal/types-common-journal.cabal @@ -0,0 +1,53 @@ +cabal-version: 1.24 + +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: c0fe3ead4cd149cf0424226e6d130441dc44ea8538517927150a017c1a983cd6 + +name: types-common-journal +version: 0.1.0 +synopsis: Shared protobuf type definitions. +description: Shared protobuf type definitions for journaling. +category: System +author: Wire Swiss GmbH +maintainer: Wire Swiss GmbH +copyright: (c) 2017 Wire Swiss GmbH +license: AGPL-3 +license-file: LICENSE +build-type: Custom +extra-source-files: + proto/TeamEvents.proto + proto/UserEvents.proto + +custom-setup + setup-depends: + Cabal + , base + , proto-lens-setup + +library + exposed-modules: + Data.Proto + Data.Proto.Id + Proto.TeamEvents + Proto.TeamEvents_Fields + Proto.UserEvents + Proto.UserEvents_Fields + other-modules: + Paths_types_common_journal + hs-source-dirs: + src + default-extensions: AllowAmbiguousTypes BangPatterns ConstraintKinds DataKinds DefaultSignatures DerivingStrategies DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PackageImports PatternSynonyms PolyKinds QuasiQuotes RankNTypes ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UndecidableInstances ViewPatterns + ghc-options: -O2 -Wall -fwarn-tabs -optP-Wno-nonportable-include-path -fno-warn-redundant-constraints + ghc-prof-options: -fprof-auto-exported + build-depends: + base ==4.* + , bytestring + , imports + , proto-lens-runtime + , time + , types-common + , uuid + default-language: Haskell2010 diff --git a/libs/types-common/package.yaml b/libs/types-common/package.yaml index e216d1511dd..dd162cad73a 100644 --- a/libs/types-common/package.yaml +++ b/libs/types-common/package.yaml @@ -29,7 +29,6 @@ library: - data-default >=0.5 - deepseq >=1.4 - directory >=1.2 - - email-validate >=2.3 - errors >=2.0 - ghc-prim - hashable >=1.2 @@ -77,6 +76,7 @@ tests: - bytestring-conversion - protobuf - QuickCheck + - string-conversions - tasty - tasty-hunit - tasty-quickcheck diff --git a/libs/types-common/src/Data/Code.hs b/libs/types-common/src/Data/Code.hs index c6f2e84dc10..9513abf3053 100644 --- a/libs/types-common/src/Data/Code.hs +++ b/libs/types-common/src/Data/Code.hs @@ -5,6 +5,23 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-} +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + -- | Types for verification codes. module Data.Code where diff --git a/libs/types-common/src/Data/Domain.hs b/libs/types-common/src/Data/Domain.hs index 213c90e0923..095bc0cbe49 100644 --- a/libs/types-common/src/Data/Domain.hs +++ b/libs/types-common/src/Data/Domain.hs @@ -1,17 +1,56 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2020 Wire Swiss GmbH +-- +-- 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 . + module Data.Domain where import Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON)) import qualified Data.Aeson as Aeson -import qualified Data.Attoparsec.ByteString as Atto -import Data.Bifunctor (bimap, first) +import Data.Attoparsec.ByteString (()) +import qualified Data.Attoparsec.ByteString.Char8 as Atto +import qualified Data.ByteString as BS +import qualified Data.ByteString.Char8 as BS.Char8 import Data.ByteString.Conversion +import qualified Data.Text as Text import qualified Data.Text.Encoding as Text.E -import Imports -import Test.QuickCheck (Arbitrary (arbitrary), elements) -import qualified Text.Email.Validate as Email +import Imports hiding (isAlphaNum) +import Test.QuickCheck (Arbitrary (arbitrary)) +import qualified Test.QuickCheck as QC +import Util.Attoparsec (takeUpToWhile) --- | FUTUREWORK: move this type upstream into the email-validate package? --- or become independent of email validation. +-- | A Fully Qualified Domain Name (FQDN). +-- +-- Following [RFC-1035](https://www.ietf.org/rfc/rfc1035.txt), Section 2.3.1, +-- except for: +-- * not allowing a space @" "@ +-- * accepting digits as first letter of labels (except for the last label, not allowing IPs) +-- * requiring at least two labels +-- * not only must labels be 63 chars or less, the whole domain must be 253 chars or less +-- +-- ::=