commit 22c372e246db77884331f2ee7ec5bf299791219c Author: Jonas L Date: Mon Feb 25 00:00:00 2019 +0000 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..68a7dd4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +node_modules +test.db diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..ae09573 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,20 @@ +image: docker:stable + +services: + - docker:dind + +variables: + CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH + DOCKER_HOST: tcp://docker:2375 + DOCKER_DRIVER: overlay2 + +before_script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com + +build: + stage: build + script: + - docker pull $CONTAINER_IMAGE:$CI_COMMIT_REF_NAME || true + - docker build --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_REF_NAME . + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker push $CONTAINER_IMAGE:$CI_COMMIT_REF_NAME diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0b851e2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:11-alpine + +# Create app directories +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +# Install app dependencies +COPY . /usr/src/app/ +RUN npm install --no-optional && npm run build && npm prune --production && rm -rf ./src + +# Start the App +EXPOSE 8080 +CMD [ "npm", "start" ] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b0c8b36 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..f82359d --- /dev/null +++ b/Readme.md @@ -0,0 +1,62 @@ +# TimeLimit-Server + +This is the server for the connected mode in TimeLimit. + +## Clustering + +This application only supports running a single instance of it. +When clustering, push messages do not work anymore between devices +connected to different devices and the rate limiting is per instance. + +## Running + +Option 1: Use a prebuilt docker image +Option 2: Install Node.JS (see below for detailed usage) + +## Commands + +### npm start + +This runs all pending migrations and starts the server. + +### npm run build + +This "compiles" the application. + +### npm run lint:fix + +This fixes the causes of lint warnings (where possible). + +## Configuration (environment variables) + +- DATABASE_URL + - this specifies the database to use + - default value: ``sqlite://test.db`` (sqlite database in the source code directory) + - supports mysql, postgresql and sqlite (sqlite in development builds only because it's declared as dev dependency) + - looks like ``postgres://user:pass@example.com:5432/dbname`` + - no extra setup needed + - when starting the application, the database tables are created/ migrated + - this only works for upgrading; if you intend to eventually downgrade, make a backup first (you should make backups in all cases before an upgrade) +- PORT + - the port at which the server should listen +- NODE_ENV + - should be set to ``production`` in production + - when using ``development``, then mails are not sent; instead they are written to a html file which is opened +- GOOGLE_PLAY_PUBLIC_KEY + - key for validating purchases + - purchases using google play don't work without it +- GOOGLE_SIGN_IN_CLIENT_ID + - token for validating sign in with google requests + - sign in with Google does not work without it +- MAIL_SENDER + - sender (for the from-field) for sent mails +- MAIL_TRANSPORT + - a JSON encoded configuration for nodemailer (object with service and auth) + - see for examples + - default value is ``null`` +- MAIL_IMPRINT + - a string which is added to the footer of the sent mails + - default value: ``not defined`` +- STATUS_MESSAGE + - a message which is shown to all users in the overview screen + - default: null/ no shown message diff --git a/other/mail/login/html.ejs b/other/mail/login/html.ejs new file mode 100644 index 0000000..5c93e3f --- /dev/null +++ b/other/mail/login/html.ejs @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + +
+
TimeLimit
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+
+

+ <%= introtext %> +

+

<%= code %>

+

+ <%= outrotext %> +

+
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+

+ +
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+
+

You got this mail because your mail address was entered at the TimeLimit App for signing in. If you did not request this mail, then you can ignore it. If you have got any questions, then you can reply to this messagge.

+

+ Sie erhalten diese Nachricht, da Ihre E-Mail-Adresse in der TimeLimit-App zum Anmelden eingegeben wurde. Wenn Sie diese E-Mail nicht angefordert haben, können Sie diese ignorieren. Falls Sie Fragen haben können Sie einfach auf + diese E-Mail antworten.

+

© + <%= mailimprint %> +

+
+
+
+ +
+
+ +
+ + + diff --git a/other/mail/login/htmltemplate-src.txt b/other/mail/login/htmltemplate-src.txt new file mode 100644 index 0000000..03e2f33 --- /dev/null +++ b/other/mail/login/htmltemplate-src.txt @@ -0,0 +1,40 @@ + + + + + TimeLimit + + + + + +

+ <%= introtext %> +

+

<%= code %>

+

<%= outrotext %>

+
+
+
+ + + + + + + + +

+ You got this mail because your mail address was entered at the TimeLimit App for signing in. If you did not request this mail, then you can ignore it. If you have got any questions, then you can reply to this messagge. +

+

+ Sie erhalten diese Nachricht, da Ihre E-Mail-Adresse in der TimeLimit-App zum Anmelden eingegeben wurde. Wenn Sie diese E-Mail nicht angefordert haben, können Sie diese ignorieren. Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten. +

+

+ © <%= mailimprint %> +

+
+
+
+
+
diff --git a/other/mail/login/subject.ejs b/other/mail/login/subject.ejs new file mode 100644 index 0000000..f023d60 --- /dev/null +++ b/other/mail/login/subject.ejs @@ -0,0 +1 @@ +<%= subject %> diff --git a/other/mail/login/text.ejs b/other/mail/login/text.ejs new file mode 100644 index 0000000..ffe4f81 --- /dev/null +++ b/other/mail/login/text.ejs @@ -0,0 +1,17 @@ +<%= introtext %> + +<%= code %> + +<%= outrotext %> + +---------------------- + +You got this mail because your mail address was entered at the TimeLimit App for signing in. +If you did not request this mail, then you can ignore it. +If you have got any questions, then you can reply to this messagge. + +Sie erhalten diese Nachricht, da Ihre E-Mail-Adresse in der TimeLimit-App zum Anmelden eingegeben wurde. +Wenn Sie diese E-Mail nicht angefordert haben, können Sie diese ignorieren. +Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten. + + <%= mailimprint %> diff --git a/other/mail/manipulation/html.ejs b/other/mail/manipulation/html.ejs new file mode 100644 index 0000000..e39fa48 --- /dev/null +++ b/other/mail/manipulation/html.ejs @@ -0,0 +1,308 @@ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + +
+
TimeLimit
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+
+

Die TimeLimit-Installation von dem Gerät + <%= deviceName %> hat eine Manipulation gemeldet. Sie können die Details dazu in der TimeLimit-App einsehen.
Solange Sie nicht die Warnung in TimeLimit bestätigen (ignorieren und/ oder beheben) erhalten Sie keine weitere Manipulationsbenachrichtigungen + für dieses Gerät.

+

TimeLimit at + <%= deviceName %> reported a manipulation. You can see the details in the TimeLimit App.
You will not get any further warnings for this device until you confirm (ignore and/ or fix) the manipulation in the TimeLimit App.

+
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+

+ +
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+
+

Sie erhalten diese Nachricht, weil Sie E-Mail-Benachrichtigungen in TimeLimit aktiviert haben. Sie können die Nachrichten in der TimeLimit-App abbestellen, oder indem Sie auf diese Nachricht antworten, dass Sie diese Benachrichtigungen + nicht mehr erhalten möchten. Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten.

+

You got this mail because you enable mail notifications for this in TimeLimit. You can disable getting these messages in the TimeLimit App or by replying to this message that you don't want to get these notifications anymore. If + you have got any questions, then you can reply to this messagge.

+

© + <%= mailimprint %> +

+
+
+
+ +
+
+ +
+ + + diff --git a/other/mail/manipulation/htmltemplate-src.txt b/other/mail/manipulation/htmltemplate-src.txt new file mode 100644 index 0000000..586c586 --- /dev/null +++ b/other/mail/manipulation/htmltemplate-src.txt @@ -0,0 +1,56 @@ + + + + + TimeLimit + + + + + +

+ Die TimeLimit-Installation von dem Gerät <%= deviceName %> hat eine Manipulation gemeldet. + Sie können die Details dazu in der TimeLimit-App einsehen. +
+ Solange Sie nicht die Warnung in TimeLimit bestätigen (ignorieren und/ oder beheben) + erhalten Sie keine weitere Manipulationsbenachrichtigungen für dieses Gerät. +

+ +

+ TimeLimit at <%= deviceName %> reported a manipulation. + You can see the details in the TimeLimit App. +
+ You will not get any further warnings for this device + until you confirm (ignore and/ or fix) the manipulation in the TimeLimit App. +

+
+
+
+ + + + + + + + +

+ Sie erhalten diese Nachricht, weil Sie E-Mail-Benachrichtigungen in TimeLimit aktiviert haben. + Sie können die Nachrichten in der TimeLimit-App abbestellen, oder indem + Sie auf diese Nachricht antworten, dass Sie diese Benachrichtigungen nicht mehr erhalten möchten. + Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten. +

+

+ You got this mail because you enable mail notifications for this in TimeLimit. + You can disable getting these messages in the TimeLimit App or by + replying to this message that you don't want to get these notifications anymore. + If you have got any questions, then you can reply to this messagge. +

+

+ © <%= mailimprint %> +

+
+
+
+
+
diff --git a/other/mail/manipulation/subject.ejs b/other/mail/manipulation/subject.ejs new file mode 100644 index 0000000..f023d60 --- /dev/null +++ b/other/mail/manipulation/subject.ejs @@ -0,0 +1 @@ +<%= subject %> diff --git a/other/mail/manipulation/text.ejs b/other/mail/manipulation/text.ejs new file mode 100644 index 0000000..9500074 --- /dev/null +++ b/other/mail/manipulation/text.ejs @@ -0,0 +1,26 @@ +Die TimeLimit-Installation von dem Gerät <%= deviceName %> hat eine Manipulation gemeldet. +Sie können die Details dazu in der TimeLimit-App einsehen. + +Solange Sie nicht die Warnung in TimeLimit bestätigen (ignorieren und/ oder beheben) +erhalten Sie keine weitere Manipulationsbenachrichtigungen für dieses Gerät. + + +TimeLimit at <%= deviceName %> reported a manipulation. +You can see the details in the TimeLimit App. + +You will not get any further warnings for this device +until you confirm (ignore and/ or fix) the manipulation in the TimeLimit App. + +---------------------- + +Sie erhalten diese Nachricht, weil Sie E-Mail-Benachrichtigungen in TimeLimit aktiviert haben. +Sie können die Nachrichten in der TimeLimit-App abbestellen, oder indem +Sie auf diese Nachricht antworten, dass Sie diese Benachrichtigungen nicht mehr erhalten möchten. +Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten. + +You got this mail because you enable mail notifications for this in TimeLimit. +You can disable getting these messages in the TimeLimit App or by +replying to this message that you don't want to get these notifications anymore. +If you have got any questions, then you can reply to this messagge. + + <%= mailimprint %> diff --git a/other/mail/uninstall/html.ejs b/other/mail/uninstall/html.ejs new file mode 100644 index 0000000..8041916 --- /dev/null +++ b/other/mail/uninstall/html.ejs @@ -0,0 +1,307 @@ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + +
+
TimeLimit
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+
+

TimeLimit wurde von dem Gerät + <%= deviceName %> entfernt.

+

TimeLimit was removed from + <%= deviceName %>.

+
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+

+ +
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+
+

Sie erhalten diese Nachricht, weil Sie E-Mail-Benachrichtigungen in TimeLimit aktiviert haben. Sie können die Nachrichten in der TimeLimit-App abbestellen, oder indem Sie auf diese Nachricht antworten, dass Sie diese Benachrichtigungen + nicht mehr erhalten möchten. Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten.

+

You got this mail because you enable mail notifications for this in TimeLimit. You can disable getting these messages in the TimeLimit App or by replying to this message that you don't want to get these notifications anymore. If + you have got any questions, then you can reply to this messagge.

+

© + <%= mailimprint %> +

+
+
+
+ +
+
+ +
+ + + diff --git a/other/mail/uninstall/htmltemplate-src.txt b/other/mail/uninstall/htmltemplate-src.txt new file mode 100644 index 0000000..747af67 --- /dev/null +++ b/other/mail/uninstall/htmltemplate-src.txt @@ -0,0 +1,48 @@ + + + + + TimeLimit + + + + + +

+ TimeLimit wurde von dem Gerät <%= deviceName %> entfernt. +

+ +

+ TimeLimit was removed from <%= deviceName %>. +

+
+
+
+ + + + + + + + +

+ Sie erhalten diese Nachricht, weil Sie E-Mail-Benachrichtigungen in TimeLimit aktiviert haben. + Sie können die Nachrichten in der TimeLimit-App abbestellen, oder indem + Sie auf diese Nachricht antworten, dass Sie diese Benachrichtigungen nicht mehr erhalten möchten. + Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten. +

+

+ You got this mail because you enable mail notifications for this in TimeLimit. + You can disable getting these messages in the TimeLimit App or by + replying to this message that you don't want to get these notifications anymore. + If you have got any questions, then you can reply to this messagge. +

+

+ © <%= mailimprint %> +

+
+
+
+
+
diff --git a/other/mail/uninstall/subject.ejs b/other/mail/uninstall/subject.ejs new file mode 100644 index 0000000..f023d60 --- /dev/null +++ b/other/mail/uninstall/subject.ejs @@ -0,0 +1 @@ +<%= subject %> diff --git a/other/mail/uninstall/text.ejs b/other/mail/uninstall/text.ejs new file mode 100644 index 0000000..f62b136 --- /dev/null +++ b/other/mail/uninstall/text.ejs @@ -0,0 +1,17 @@ +TimeLimit wurde von dem Gerät <%= deviceName %> entfernt. + +TimeLimit was removed from <%= deviceName %>. + +---------------------- + +Sie erhalten diese Nachricht, weil Sie E-Mail-Benachrichtigungen in TimeLimit aktiviert haben. +Sie können die Nachrichten in der TimeLimit-App abbestellen, oder indem +Sie auf diese Nachricht antworten, dass Sie diese Benachrichtigungen nicht mehr erhalten möchten. +Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten. + +You got this mail because you enable mail notifications for this in TimeLimit. +You can disable getting these messages in the TimeLimit App or by +replying to this message that you don't want to get these notifications anymore. +If you have got any questions, then you can reply to this messagge. + + <%= mailimprint %> diff --git a/other/wordlist/de.txt b/other/wordlist/de.txt new file mode 100644 index 0000000..23b7d31 --- /dev/null +++ b/other/wordlist/de.txt @@ -0,0 +1,5634 @@ +abdecken +abdichten +abdrehen +Abdruck +Abend +abends +aber +Abfahrt +Abfall +Abfluss +Abfuhr +Abgang +Abgas +Abgrund +abgucken +abhaken +abhalten +Abhang +abhauen +Abhilfe +Abitur +Abkehr +Abklatsch +Ablage +ablagern +ablassen +ablegen +ableiten +abnutzen +abreisen +Absage +Absatz +Abschied +abseits +Absender +absetzen +absolut +Abstoß +absurd +Abteil +abtrocknen +abtupfen +Abwasser +abwechseln +abwenden +abwinken +abzahlen +Abzeichen +abziehen +abzocken +Achse +Achsel +acht +achtel +achtfach +Achtung +achtzig +Adel +Adler +Adresse +Advent +Affe +Agent +ahnen +Ahnung +ahoi +Ahorn +Akazie +Akte +aktiv +Akzent +Alarm +albern +Album +Alge +Alibi +allein +allenfalls +allerdings +alles +allgemein +Alltag +Almosen +Alpen +Alptraum +alsdann +also +Altar +Alter +Ameise +Amerika +Ampel +Amsel +analog +Analyse +Ananas +Andenken +andere +Anfang +Angel +angenehm +Angst +Anhang +Anker +anklagen +Anlass +Anlauf +anpassen +anpeilen +anregen +Anruf +Ansage +Ansammlung +Ansatz +Ansporn +Anstalt +Anstand +anstatt +anstiften +Anteil +antik +Antrag +Antwort +anvertraut +Anwalt +Anzahl +Anzeige +anzeigen +anzetteln +anzweifeln +Apfel +April +Araber +Arbeit +Arbeiter +Archiv +Arena +Arktis +Armband +Arme +Aroma +artig +Arzt +Asche +Aspekt +Asphalt +Atem +Athlet +Atlantik +Atlas +Atom +auch +Aufgabe +Aufgaben +aufrichtig +Aufsatz +aufschauen +Aufschub +aufwendig +aufziehen +Aufzug +Auge +Augen +Augenzeuge +August +Aula +Ausflug +ausgelaugt +Ausrede +austrinken +ausweichen +Augen +Auto +Automat +Autor +Bach +Backe +baden +Badezimmer +Bahn +bald +Balkon +Ball +Ballade +Ballon +Band +Bank +Bann +Basis +Bass +Bauch +bauen +Bauer +Baum +Beamte +Becher +Becken +bedeckt +bedeuten +beeilen +beenden +befangen +befassen +behandeln +beharren +Beifall +beim +Bein +bemerkbar +bemerken +bemerkte +Benehmen +Benzin +beobachten +bequem +beraten +bereden +bereit +bereits +Berg +bergen +Berlin +Beruf +beschattet +besser +Bestand +bestatten +beste +bester +Besuch +Beton +Betrag +Betragen +betreuen +Betrieb +betteln +Beule +beurlauben +Beute +Beutel +bevor +bewachen +bewegen +Beweis +beweist +bewerten +bezahlen +bezeichnen +bezeugen +Bezirk +bezwingen +Biber +Biene +bieten +bietet +Bilanz +Bild +bilden +billig +binden +Bingo +Bioladen +Birke +Bitte +bitten +bitter +bizarr +blass +Blatt +blau +Blech +bleich +blicken +blickte +blind +blinken +Blitz +Block +braun +brav +braver +Briefwaage +bringen +bringt +bsher +Buchverlag +Buchzeile +dagegen +daher +daneben +dankbar +Danke +danken +dann +daran +darauf +daraus +darbieten +Darm +darstellen +darum +darunter +Dattel +Datum +Dauer +dauern +Daumen +Daune +Daunenbett +davon +dazu +dazukommen +dazulernen +dazusetzen +dazwischen +Decke +Deckel +Defekt +Deich +dein +deiner +Delfin +Delle +Delta +denkbar +denken +denkfaul +Denkfehler +Denkmal +Denkzettel +dennoch +deponieren +derartig +dermaßen +derselbe +deshalb +Design +Dessert +Detail +deutbar +deuten +deutet +deutlich +deutsch +Deutung +Dezember +Dezimeter +diagonal +Diagonale +Diagramm +Dialekt +Dialog +Diamant +dich +Dichte +dichten +Dichter +Dichtkunst +Dichtung +dick +Dickdarm +Dienst +Dienstag +Dienstbote +dienstlich +Dietrich +digital +Diktat +diktieren +Diplom +Diplomat +direkt +Direktor +Distel +Disziplin +Doktor +Dokument +Donner +Donnerstag +doof +Dorf +Dorn +Dorsch +dort +Dose +Dosis +Drachen +Draht +Drama +draußen +Dreck +drehen +drei +drinnen +Drohne +Druck +drucken +Dschungel +Duft +Dukaten +dulden +dumm +dunkel +Dunst +Duplikat +durch +Durchblick +Durchfall +Durchlass +durchlesen +Durchsage +Durst +duschen +dusselig +dutzend +Dynamo +Ebbe +Ebenholz +ebenso +Eber +Eberesche +Echo +Echse +echt +echtes +Ecke +edel +Efeu +Effekt +egal +Eibe +Eiche +Eifer +eigentlich +Eimer +Einband +einbilden +einblenden +eindeutig +Eindruck +einfach +einfahren +einfallen +einfrieren +Eingang +Einheit +einholen +einkaufen +Einkommen +einladen +einmal +einmischen +Einnahme +einordnen +einpacken +einrasten +einreisen +einrichten +einsam +Einsatz +einschulen +einseitig +einsenden +einsetzen +Einsiedler +Einspruch +einstellen +einstellig +Eintopf +Eintracht +eintreten +Eintritt +einweisen +einwenden +Einwohner +Einzahl +einzeilig +Eisen +Eiter +Eiweiß +Ekel +elastisch +Elefant +Elektron +Element +elend +Elfe +Elfenbein +Elster +empfangen +empfehlen +empfinden +empirisch +Ende +Energie +Engel +England +enorm +entbehren +Ente +enteisen +entfernen +enthalten +Entschluss +entsetzen +entsinnen +entsorgen +entspannen +entstehen +entwenden +entwerfen +entwerten +entwickeln +Entwurf +erbarmen +erbauen +erben +erbeuten +erbost +Erbse +Erde +erdenklich +erfinden +Erfolg +erforschen +erfreuen +erfrischen +ergeben +erhalten +erhitzen +erholen +erinnern +erkennen +erkunden +erlauben +erleben +erledigen +ermitteln +ermuntern +ermutigen +Ernte +erreichen +errichten +Ersatz +erscheinen +ersparen +erstatten +erstaunt +Ertrag +erwachsen +erwarten +erweitern +erwerben +erzeugen +erziehen +Esche +Esel +Espe +essen +Essig +Eule +Euro +Europa +Evolution +ewig +exakt +Expedition +Experiment +extrem +exzellent +Fabel +Fabrik +Fach +Fackel +Faden +Fahne +fahren +fair +Faktor +Falke +fallen +falsch +falten +Falter +Familie +Farbe +Farm +Fasching +Faser +Fassade +fauchen +faul +Faust +Favorit +fehlen +Feier +feige +Feile +fein +Feind +Felder +Fell +Felsen +Fenster +Ferien +Ferkel +fern +Ferse +fertig +fest +Fett +Feuer +Fibel +Fichte +Fieber +Figur +Film +Filter +finden +Finger +finster +Firma +Fisch +flach +flackern +Flamme +Flasche +flattern +Fleck +Flecken +Fledermaus +flehen +Fleiß +Fliege +fliehen +Fliese +fließen +flimmern +Flocke +flog +Floß +Flosse +fluchen +Flug +Flur +Fluss +Flut +Folie +fordern +Forelle +formuliert +forschen +fortfahren +fortlaufen +fortsetzen +Fracht +Frage +fragen +Frankreich +frech +frei +Freitag +fremd +fressen +Freude +freuen +Freund +Frieden +frisch +froh +Frosch +Frost +Frucht +Fuchs +Fuhre +Fundament +Funk +Funktion +Furt +Futter +Galaxie +Galerie +Gang +Garage +Garderobe +Gardine +Garnele +Garten +Gasse +Gast +Gaumen +geben +gebildet +Gebirge +Gebiss +Gebot +Gedanke +gedenken +Gedicht +Geduld +geeignet +Gefahr +gefahren +Gefolge +gefrieren +gegen +Gegend +Gegenstand +Gegenwart +gegessen +Gegner +Gehalt +geheim +gehen +Gehilfe +Gehirn +geholfen +Geige +Geist +gekauft +gekleidet +gekommen +gelassen +gelb +Geld +Gelee +gelehrt +geleiten +Gelenk +gelingen +Gemeinde +Gemisch +genannt +genau +genehmigen +Genie +Geometrie +geradeaus +geradezu +gerannt +geraten +gerecht +Gericht +gering +Gerippe +Gerste +Geruch +gesamt +Gesang +Geschenk +Geschichte +Geschick +Geschirr +Geschmack +Geschoss +gesessen +Gesetz +Gesicht +Gespenst +Gestalt +Geste +Gestein +Gestell +gestern +gestorben +gestreift +gesund +gesungen +gesunken +getan +Getreide +getrost +getrunken +Gewebe +Geweih +Gewerbe +Gewicht +gewinnen +Gewissen +Gewitter +geworfen +gewusst +gezogen +gezwungen +Gier +Gift +Gigant +Gipfel +Gips +Giraffe +Gitarre +Gitter +Glanz +Glas +glatt +Gleis +Gletscher +Glocke +Glorie +Glut +Gnade +Gold +Golf +Gondel +Gong +Grafik +Gramm +Grammatik +Gras +gratis +grau +greifen +Grenze +Grieche +Griff +Grill +Grille +Grippe +Grips +groß +Großstadt +Grotte +Grube +Gruft +Grund +grunzen +Gulasch +Hafen +Hafer +Hagebutte +Hagel +Hahn +Haken +halb +Halle +hallo +Halm +Hals +halt +halten +Halunke +Hamburg +Hamburger +Hammer +Hand +Handel +handlich +Handlung +Handy +Hang +Hantel +hantieren +Hardware +Harfe +Harke +Harlekin +harmlos +Harmonie +Harmonika +Harn +hart +Harz +Hase +Haselnuss +hassen +hatte +Haube +hauen +Hauer +Haufen +Haupt +Haus +Haut +Hebel +heben +hecheln +Hecht +Hecke +Heer +Hefe +Heft +heften +heftig +hegen +Hehl +Heide +heikel +Heil +heilig +Heimat +heiser +heiß +heißen +heiter +heizen +Hektar +Hektik +Held +Helden +helfen +Helikopter +Helium +hell +Heller +Helm +Hemd +Henkel +Henne +herab +herauf +Herberge +Herbst +Herd +Herde +Hering +Herkunft +Herr +herunter +Herz +Herzog +Hessen +hetzen +heulen +heute +heutzutage +Hexe +Hieb +hielt +hier +Hierarchie +hierauf +Hilfe +Himbeere +Himmel +hinab +hinauf +hindern +hindurch +hinfort +hingegen +hinken +Hinsicht +hinten +hinter +Hintern +hinweg +Hirn +Hirsch +Hirse +Hirte +historisch +Hitze +Hobby +Hobel +hoch +hoffen +Hoffnung +Hoheit +hohl +Hohn +Hokuspokus +hold +holen +Holland +holpern +Holunder +Holz +Honig +Hopfen +hoppeln +horchen +Horizont +Hormon +Horn +Hornisse +Horoskop +Horror +Horst +Hort +Hotel +Huhn +Hummer +Humor +Humus +Hund +hundert +Hunger +Hupe +Hurrikan +huschen +husten +Idioten +Innenleben +Jacht +Jacke +Jagd +Jaguar +Jahr +jahrelang +Jammer +Januar +Japan +Jazz +Jeans +jeden +jeder +jemand +Jesus +jetzt +jeweils +Joghurt +Joker +Jongleur +Joule +Journalist +Joystick +jubeln +jucken +Judo +Jugend +Juli +Jumbo +jung +Junge +Juni +Junior +Jupiter +Jura +Jury +Justiz +Juwel +Kabarett +Kabel +Kabeljau +Kabine +Kabinett +Kabriolett +Kachel +Kadaver +Kaff +Kaffee +kahl +Kahn +Kaiser +Kajak +Kakao +kakeln +Kaki +Kaktus +Kalauer +Kalb +Kalender +Kaliber +Kalif +Kalk +Kalorien +kalt +Kamel +Kamelle +Kamera +Kamerad +Kamille +Kamin +Kamm +Kammer +Kampagne +Kampf +Kanadier +Kanal +Kandidat +Kandis +Kaninchen +Kanister +kann +Kanne +Kannibale +kannte +Kanon +Kanone +Kantate +Kante +Kantine +Kanu +Kanzel +Kanzler +kapern +kapieren +Kapillare +Kapital +Kapitel +Kaplan +Kappe +kappen +Kapriole +Kapsel +kaputt +Kapuze +Karabiner +Karaffe +Karamell +Karat +Karate +Karawane +Kardinal +Karenz +Karfreitag +karg +kariert +Karies +Karikatur +Karneval +Karnickel +Karo +Karosserie +Karotte +Karpfen +Karre +Karriere +Karst +Karte +Kartell +Kartoffel +Karton +Karussell +Karwoche +Kasack +kaschen +Kaserne +Kasino +Kasko +Kasper +Kasse +Kassette +Kastanie +kasteien +Kastell +Kasten +Kasus +Katakombe +Katalog +Katapult +Kategorie +Kater +Kathedrale +Katze +kauen +kauern +Kauf +kaufen +Kaulquappe +kaum +kausal +Kaution +Kauz +Kavalier +Kaviar +Kebab +keck +Kegel +Kehle +Kehre +kehren +keifen +Keiferei +Keil +keilen +Keilerei +Keilkissen +Keim +keine +Keks +Kelch +Keller +Kellner +kennen +kentern +Keramik +Kerbe +kerierte +Kerker +Kerl +Kern +Kerosin +Kerze +kess +Kessel +Kette +Ketzer +keuchen +Keule +keusch +kichern +kicken +Kiebitz +Kiefer +Kiel +Kieme +Kies +kiffen +killen +Kilogramm +Kilohertz +Kilometer +Kilowatt +Kimme +Kimono +Kind +Kinn +Kino +Kiosk +kippen +Kirche +Kirchturm +Kirmes +Kirsche +Kissen +Kiste +Kitsch +Kitt +Kittel +Kitz +kitzeln +Kladde +klaffen +klagen +Klamm +Klamotte +Klappe +klappern +Klaps +klar +Klarinette +Klasse +Klassik +klatschen +Klaue +Klause +Klausel +Klausur +Klavier +kleben +Klecks +Klee +Kleid +kleidet +Kleidung +Kleie +klein +kleinen +kleines +Kleister +Klemme +klemmen +Klempner +Klerus +Klette +klettern +Klient +Kliff +Klima +klimmen +klimpern +Klinge +klingen +Klinik +Klinke +Klinker +Klipp +Klippe +klirren +Klischee +Klistier +Klitoris +klngeln +Kloake +klobig +klopfen +Kloß +Klotz +Klub +Kluft +klug +Klumpen +knabbern +Knabe +knallen +knapp +Knarre +knarren +Knast +knauserig +knautschen +Knebel +Knecht +kneifen +Kneipe +Kneippkur +kneten +knicken +knickerig +Knie +Kniff +knipsen +Knirps +knirschen +knistern +knittern +knobeln +Knoblauch +Knochen +Knolle +Knopf +knorrig +Knospe +Knoten +knurren +knuspern +Knute +knutschen +Koalition +Kobel +Kobold +Kobra +kochen +kochend +Kode +Koffein +Koffer +Kogel +Kogge +Kohl +Kohle +Koje +Kokain +kokeln +kokett +Kokon +Kokos +Koks +Kolben +Kolik +Kollaps +Kollege +Kollekte +Kollektiv +Koller +kollern +Kolonie +Kolonnade +Kolonne +Koloratur +kolorieren +Koloss +Kolumne +Koma +Komet +Komfort +komisch +Komitee +Komma +Kommandant +komme +kommen +Kommentar +Kommissar +Kommission +Kommode +Kommune +Kommunion +Kommunist +kompakt +Komparativ +Kompass +kompatibel +kompetent +komplett +Komplex +Kompliment +Komplize +Komplott +Komponente +Kompost +Kompromiss +Kondition +Konditor +Kondom +Konfekt +Konfektion +Konferenz +Konfession +Konfetti +Konflikt +konform +konfus +Kongress +kongruent +Konjunktiv +konkav +Konkordat +konkret +Konkurrenz +Konkurs +Konrektor +Konsens +konsequent +Konserve +Konsonant +konstant +Konsul +Konsum +Kontakt +kontern +Kontext +Kontinent +Konto +kontra +Kontrast +Kontrolle +kontrovers +Kontur +Konus +Konvention +konvex +Konvoi +Konzert +Konzil +Kopf +Kopfes +Kopie +Kopilot +koppeln +Koralle +Koran +Korb +Kord +Kordel +Korinthe +Korken +Kormoran +Korn +korpulent +korrekt +Korridor +Korrosion +korrupt +Korsett +Kosak +kosen +Kosmetik +Kosmos +Kost +Kosten +Kotelett +kotzen +Krabbe +krabbeln +Krach +Kraft +Kragen +krakeelen +Kralle +Kram +Krampe +Krampf +Kran +krank +Kranz +Krapfen +krass +Krater +kratzen +kraulen +kraus +Kraut +Krawall +Krawatte +kraxeln +kreativ +Krebs +Kredit +Kreide +Kreis +kreischen +Kreißsaal +Kreml +Krempe +Krempel +krempeln +krepieren +Krepp +Kresse +Kreuz +kribbeln +kriechen +Krieg +kriegen +Krill +Krimskrams +Kringel +Krippe +Krise +Kristall +Kriterium +kritisch +kritzeln +Kroatien +Krokodil +Krone +Kropf +kross +Krug +Krume +krumm +Kruste +Krypta +Kubik +Kuchen +Kuckuck +Kufe +Kugel +Kuhle +Kuli +Kulisse +kullern +Kult +Kultur +Kummer +Kumpan +Kunde +Kunst +kunterbunt +Kupfer +Kuppe +Kuppel +kuppeln +Kurbel +Kurier +kurios +Kurs +kursiv +Kurve +kurz +kuscheln +Kusine +Kuss +Kutsche +Kutte +Kutter +Kuvert +Label +laben +labern +labil +Labyrinth +Lache +lachen +Lachs +Lack +laden +Lady +Lage +Lager +Lagune +lahm +Laib +Laich +Laie +Lakai +Laken +lakonisch +Lakritze +lallen +Lama +Lamelle +Lametta +Lamm +Lampe +Lampion +Land +landen +Landrover +lang +lange +langen +langsam +Lanze +lapidar +Lappalie +Lappen +Lappland +Laptop +Larve +lasch +Lasche +Laser +lassen +Lasso +Last +Laster +Lasur +lateinisch +latent +Laterne +Latrine +latschen +Latte +Latz +Laub +Laube +Lauch +lauern +laufen +Lauge +laugen +Laune +Laus +lauschen +laut +Laute +lauter +Lava +Lavendel +lavieren +Lawine +Lazarett +Leben +Leber +Lebkuchen +lechzen +Leck +lecken +lecker +Leder +ledig +leer +legal +legen +Legende +leger +Leggins +Legierung +Legion +legitim +legte +Lehen +Lehm +lehnen +Lehnwort +lehren +Leib +Leiche +leicht +Leid +leiden +Leier +leihen +Leim +Leine +Leinen +Leinsamen +leise +Leiste +leisten +leiten +Leiter +Lektion +Lemming +Lende +lenken +Lenz +Leopard +Leporello +Lepra +Lerche +lernen +lesbisch +lesen +Lesezirkel +Letter +letzter +leuchten +leugnen +Leumund +Leute +Leutnant +Level +Lexikon +Liane +Libelle +liberal +Libido +Licht +lichten +Liebe +Lied +liederlich +lief +liefern +liegen +ließ +Lift +Liga +Liguster +lila +Lilie +Liliput +Limerick +Limes +Limit +limitieren +Limonade +Limousine +lindern +Lineal +Linie +links +Linoleum +Linse +Lippe +Lippen +lispeln +List +Liste +Litanei +Liter +Literatur +Liturgie +Litze +Lizenz +Lobby +loben +Loch +Locke +locken +locker +Loden +lodern +Logbuch +Loge +Loggia +logisch +Lohe +Lohn +Loipe +Lokal +Lokomotive +Lokus +Lolli +Longe +Look +Looping +Lorbeer +Lord +Lore +lose +Losung +Lotion +Lotse +Lotterie +Lotto +Lovestory +loyal +Luchs +Luder +Luft +luftdicht +Luke +lukrativ +lullen +Lump +Lumpen +Lunge +lungern +Lunte +Lupe +Lurch +Lust +Luther +lutschen +Luxus +Luzerne +Luzifer +Lymphe +lynchen +Lyrik +Lyzeum +Maar +Maat +machen +Macho +Macht +machten +Macke +Made +Madonna +Mafia +Magazin +Magd +Magen +mager +Magie +Magister +Magma +Magnet +Mahagoni +Mahl +mahlen +mahnen +Maid +Main +Mais +Majoran +makaber +Makel +Makkaroni +Makler +Makrele +Makrone +Makulatur +Malaria +malen +Malheur +Malve +Malz +Mama +Mammon +Mammut +Manager +manch +manchmal +Mandant +Mandarine +Mandat +Mandel +Mandoline +Manege +Mangel +mangelt +Mango +Mangold +Mangrove +Manie +Manier +Manifest +Manko +mann +Mannequin +Manometer +Mansarde +manschen +Manschette +Mantel +manuell +Manuskript +Mappe +Marder +Margarine +Margerite +Marinade +Marine +Marionette +Mark +Marke +Marketing +Markise +Markt +Marmelade +Marmor +marode +Marone +Marotte +Mars +Marsch +martern +Marzipan +Masche +Maschine +Masern +Maserung +Maske +maskulin +Massage +Massaker +Masse +Massel +Masseur +massiv +Mast +Match +Material +Materie +Mathe +Mathematik +Matratze +Matrose +Matsch +matt +Matte +Mauer +Maul +Maulesel +Maus +mausen +Mauser +Mausoleum +Maut +maxi +Maximum +Mayonnaise +Mechanik +meckern +Medaille +Medium +Medizin +Meer +Meeting +mega +Megalith +Mehl +mehr +meiden +Meile +mein +Meineid +meinen +Meise +Meißel +meist +Meister +melden +meliert +melken +Melodie +Melone +Membrane +Memme +Memoire +Menge +mengen +Meniskus +Mensa +Mensch +Menschen +Menschheit +Menuett +Meridian +merken +Merkur +meschugge +Mesner +Messe +messen +Messer +Messias +Messing +Metall +Metapher +Meteor +Meter +Methode +Metro +Metropole +Mette +metzeln +Metzger +meutern +mich +mickrig +Mief +Miene +mies +Miete +Mieze +mikro +Mikrophon +Mikroskop +Milan +Milbe +mild +Milieu +Milliarde +Millimeter +Million +Milz +Mimik +Minarett +minder +mindeste +Mine +Mineral +mini +Minimum +Minister +Minne +minus +Minute +Minze +Mirabelle +mischen +miserabel +Miss +missen +Missetat +Mission +Mist +Mistel +Mitgift +Mitglied +Mitglieder +mithilfe +mitkriegen +mitlaufen +Mitlaut +Mitleid +mitleiden +mitnehmen +mitreißen +Mittag +Mitte +mitteilen +Mitteilung +Mittel +mittels +mitten +Mittwoch +mitwirken +Mitwisser +mitzittern +mixen +mobil +Mobiliar +Mode +Model +Modell +Modem +Moder +moderieren +modern +modisch +Mofa +mogeln +Mohair +Mohn +Mokassin +mokieren +Mokka +Molch +Mole +Molke +Moll +mollig +Moment +Monarch +Monat +Mond +Moneten +monieren +Monitor +Monogramm +Monolog +Monopol +monoton +Monster +Monstranz +Monsun +Montag +Montage +Montur +Monument +Moor +Moos +Moped +Mopp +Moral +Morast +Mord +morgen +Moritat +morsch +Mosaik +Moschee +mosern +Moskito +Moslem +Most +Mostrich +Motel +Motiv +Motor +Motte +Motto +motzen +mucksen +Muff +Mufflon +Mulatte +Mulde +Mull +mulmig +Mumm +Mumps +Mund +Munition +munkeln +munter +murksen +murmeln +Murmeltier +murren +Muschel +Muse +Museum +Musical +Musik +Musikszene +Muskat +Muskel +muss +Muße +Muster +Mutation +Mutter +Myrrhe +Mythos +Nabe +Nabel +nach +nachahmen +Nachbar +nachdem +nachdenken +Nachdruck +nachfolgen +nachfragen +nachgeben +nachgerade +nachher +Nachhilfe +nachhinein +nachholen +Nachkomme +nachlassen +Nachmittag +Nachnahme +Nachrede +Nachricht +Nachruf +nachsehen +nachsenden +nachsinnen +Nachspeise +Nachspiel +nachsuchen +Nacht +Nachteil +Nachtigall +Nachtisch +Nachtrag +nachweisen +Nachwelt +nachwirken +Nachwort +Nachwuchs +nachzahlen +Nacken +nackt +Nadel +Nagel +nagelneu +nagen +nahe +nahm +Naht +naiv +Name +Napf +Narbe +Narkose +Narr +Narziss +Narzisse +nasal +naschen +Nase +nass +Nation +NATO +Natron +Natter +Natur +Nautik +Nautilus +Navigation +Nebel +neben +necken +Neffe +nehmen +Neid +neigen +neigte +nein +Nektar +Nelke +nennen +Neon +Nepp +Neptun +Nerv +Nerz +Nessel +Nest +nesteln +nett +netto +Netz +neue +neuen +neues +neun +neutral +Neutrum +Newton +nicht +Nichte +nichts +Nickel +nicken +nieder +niedlich +niedrig +niemand +Niere +niesen +Niet +Niete +Nikolaus +Nikotin +Nilpferd +nimm +nimmer +Nippel +nippen +nirgends +Nische +nisten +nisteten +Niveau +Nixe +nobel +noch +Nomade +Nomen +Nominativ +Nonne +Nonsens +nonstop +Noppe +Nord +Norm +Norwegen +Nostalgie +Note +Noten +notieren +notorisch +Nougat +Novelle +November +nuckeln +Nudel +Nugat +Nugget +nuklear +null +Nummer +nunmehr +nuscheln +Nuss +Nutria +Nylon +Nymphe +Oase +Obacht +Obdach +Obelisk +oben +ober +obgleich +Obhut +Objekt +Oblate +Obmann +Oboe +Obst +obwohl +Ochse +Ocker +oder +Odyssee +Ofen +offen +Offensive +offiziell +Offizier +ohne +Ohnmacht +Ohren +okay +Oktave +Oktober +Oldie +Oldtimer +Olive +Olymp +Omelett +Omnibus +Onkel +Online +Oper +Operation +Opfer +Opposition +Optik +Optimismus +Orakel +Orange +Orbit +Orchester +Orchidee +Orden +ordentlich +Order +ordnen +Ordnung +Organ +Orgel +Original +Orkan +Orkus +Ornament +Ornat +Osten +Ostern +Otter +oval +Ovation +Overall +Oxid +Ozean +Ozon +paar +pachten +Pack +packen +packte +packten +paddeln +paffen +Page +Pagode +Paket +Pakt +Palais +Palast +Palaver +Palette +paletti +Palisade +Palisander +Palme +Pampe +Pampelmuse +panieren +Panik +Panne +Panorama +panschen +Panther +Pantine +Pantoffel +Pantomime +Panzer +Papa +Papagei +Paperback +Papier +Pappe +Pappel +Paprika +Papst +Papyrus +Parabel +Parade +Paradies +paradox +Paraffin +Paragraph +parallel +Parasit +parat +Pardon +parieren +Park +Parka +parken +Parkett +Parlament +Parodie +Parole +Partei +parterre +Partie +Partisan +Partitur +Partizip +Partner +Party +Pass +Passage +Passagier +Passat +passen +passieren +Passion +passiv +Pasta +Pastell +Pastete +Pastille +Pastor +Patchwork +Patent +Pater +Patient +Patriot +Patrone +Patsche +patzen +Pauke +pauschal +Pause +pausen +Pavillon +Pazifik +Pech +Pedal +Pedant +Pegel +peilen +Pein +Peitsche +Pelikan +Pelle +pellen +Pelz +Pendel +Pension +Pensum +perfekt +Pergament +Periode +Perle +perplex +Perser +Person +pervers +Pest +Petersilie +Petroleum +petzen +Pfad +Pfaffe +Pfahl +Pfalz +Pfand +Pfanne +Pfarrer +Pfau +Pfeffer +pfeifen +Pfeil +Pfeiler +Pfennig +Pferd +Pfiff +Pfingsten +Pfirsich +Pflanze +Pflaster +Pflaume +Pflege +Pflicht +Pflock +Pflug +Pforte +Pfosten +Pfote +Pfropfen +Pfuhl +pfui +Pfund +pfuschen +Phantasie +Phantom +Pharao +Pharmazeut +Pharmazie +Phase +Philosoph +Phlegma +Phosphor +Phrase +Physik +Piano +Pickel +picken +Piefke +pieken +piepsen +Pier +piesacken +Pigment +pikant +pikiert +piksen +Piktogramm +Pilger +Pille +Pilot +Pilz +pingelig +Pinguin +pink +Pinnwand +Pinscher +Pinsel +Pinzette +Pionier +Pipeline +Piranha +Pirat +Pirsch +Piste +Pistole +Pizza +Plage +Plakat +Plakette +Plan +Plane +Planet +planieren +Planke +Plankton +planschen +Plantage +plappern +Plasma +Plastik +Plastilin +Platane +Plateau +Platin +platt +Platte +Platz +platzen +platzieren +plaudern +plausibel +pleite +Plexiglas +Plombe +plump +plumpen +Plunder +Plural +plustern +pochen +Pocken +Podest +Podium +Poesie +Pointe +Pokal +pokern +polieren +Politesse +Politik +Polizei +Polizist +Pollen +Polster +Poltern +Polyester +Polyp +Pomade +Pommes +Pomp +Poncho +Pony +Popcorn +Pore +Porree +Portal +Portion +Porto +Portugal +Porzellan +Posaune +Pose +Position +positiv +Positur +Posse +Post +Posten +Poster +potent +Power +Pracht +prahlen +praktisch +Praline +prall +prangen +Pranger +Pranke +prasseln +prassen +Praxis +predigen +Preis +preisen +Preisgabe +prellen +Premiere +preschen +Presse +pressen +presste +Prestige +Preußen +prickeln +Priester +prima +primitiv +Prinz +Prinzip +Prise +Prisma +Pritsche +privat +Privileg +Probe +probieren +Problem +Produkt +profan +Professor +Profi +Profil +Profit +profund +Prognose +Programm +progressiv +Projekt +Prolog +Promenade +promille +prominent +prompt +Pronomen +Propaganda +Propan +Propeller +proper +Prophet +Proportion +Prosa +Prospekt +prost +Protest +Protestant +Prothese +Protokoll +protzen +Proviant +Provinz +Prozent +Prozess +Prozession +Prunk +prusten +Psyche +publik +Puck +Pudel +Puder +Puffer +Pulk +Pullover +Puls +Pult +Pulver +Puma +Pummel +Pumpe +Punk +Pupille +Puppe +Purpur +purzeln +pushen +Pustel +pusten +Pute +Putsch +Putte +putzen +putzig +Puzzle +Pyjama +Python +Quaddel +Quader +Quadrat +quaken +Qual +Qualle +Qualm +qualmend +Quantum +Quark +Quartal +Quartett +Quartier +Quarz +quasi +quasseln +Quatsch +Quelle +quengeln +quer +Querulant +quetschen +quick +quieken +quietschen +Quintett +Quirl +quitt +Quitte +Quittung +Quiz +Quote +Quotient +Rabatt +Rabatz +Rabbiner +Rabe +rabiat +Rache +Rachen +Radar +Radau +radieren +Radieschen +radikal +Radio +radioaktiv +Radium +Radius +raffen +Raffinade +raffiniert +Rage +Ragout +Rahm +Rahmen +Rain +Rakete +Rallye +rammen +Rampe +Ramsch +Ranch +Rang +rangeln +rangieren +Ranke +Ranzen +ranzig +rapide +Rappe +Raps +rasant +rasch +rascheln +Rasen +rasieren +Raspel +Rasse +Rassel +rassig +Rast +Raster +Rate +rational +rationell +Ratte +rattern +Raub +Rauch +Rauchware +Rauchwaren +rauf +raufen +Raum +raunen +Raupe +raus +Rausch +rauschen +Rauschgift +Raute +Razzia +Reader +reagieren +Reaktor +real +Rebe +Rebell +Rebhuhn +Rechen +rechnen +Recht +rechts +Reck +recken +Recorder +Redaktion +reden +redlich +reduzieren +Reede +reell +Referat +Referendar +Reform +Refrain +Regal +Regatta +rege +Regel +Regen +Regent +Reggae +Regie +regieren +Regime +Regiment +Region +Register +reiben +Reich +reichen +reiches +reif +Reifen +Reigen +Reihe +Reiher +Reim +rein +Reis +Reise +Reisig +reißen +Reißzwecke +reiten +Reiz +rekeln +Reklame +Rekord +Rektor +renommiert +renovieren +rentabel +Rente +reparieren +Repertoire +Report +Reptil +Republik +Reputation +Requisit +Residenz +resistent +resolut +Resonanz +Respekt +Ressort +Ressource +Rest +Restaurant +Resultat +Retorte +retten +Rettich +Reue +Reuse +Revanche +Revier +Revision +Revolte +Revolution +Revolver +Revue +Rezension +Rezept +Rezession +Rhabarber +Rhetorik +Rhomboid +rhythmisch +Rhythmus +richten +richtig +Richtung +Richtungen +riechen +Ried +riefen +Riege +Riegel +Riemen +Riese +rieseln +Riff +rigoros +Rille +Rind +Rinde +Ring +ringen +rings +rinnen +Rippe +Risiko +Risotto +Rispe +Riss +Ritt +Ritual +Ritz +Rivale +Robbe +Roboter +robust +Rochen +Rock +Rocker +Rodel +roden +Rogen +Roggen +Rohr +Rokoko +Rolle +rollen +Rolltreppe +Roman +Romanik +Romantik +Rommee +rosa +Rose +Rosette +Rosine +Ross +Rost +rosten +rotieren +Rotte +Rotz +Rouge +Roulade +Rouleau +Roulette +Routine +Rowdy +rubbeln +Rubin +Rubrik +Ruck +Rucksack +Rudel +Ruder +Rudiment +rufen +Rugby +Ruhe +ruhen +Ruhm +Ruhr +Ruin +ruiniert +Rummel +rumoren +rumpeln +Rumpf +Rumpsteak +rund +Rune +runter +Runzel +rupfen +ruppig +Russland +rustikal +Rute +rutschen +Saal +Saale +Saarland +Saat +Sabbat +Sabotage +Sache +Sachsen +sachte +Sack +Sadismus +Safari +Safe +Safran +Saft +sagen +Sahara +Sahne +Saison +Saite +Saiten +Sakko +Sakrament +Salami +Salat +Salbe +Saldo +Saline +Salmiak +Salon +salopp +Salpeter +Salto +Salut +Salz +Samariter +Samen +sammeln +sammelte +sammelten +Sammlung +Samstag +samt +Sanatorium +Sand +Sandale +Sandwich +sanft +sang +sanieren +sank +Sankt +Sanktion +Saphir +Sardelle +Sardine +Sarg +Satan +Satellit +Satin +Satire +satt +Sattel +Satz +Satzung +sauber +Sauce +sauer +saufen +saugen +Saum +Sauna +Saurier +sausen +Savanne +Saxophon +Scanner +schaben +Schablone +Schach +schachern +Schacht +Schachtel +Schachteln +schade +Schaden +Schaf +schaffen +Schaffner +Schafott +Schaft +schal +Schale +Schalk +Schall +schalten +Scham +Schamotte +Schampus +Schande +Schanze +Schar +scharf +Scharlach +Scharlatan +Scharm +Scharnier +scharren +Scharte +Schaschlik +Schatten +schattig +Schatulle +Schatz +Schau +Schauder +Schauer +Schaufel +Schaukel +Schaum +Scheck +scheckig +scheel +Scheffel +Scheibe +Scheich +scheiden +scheinen +Scheiße +Scheit +Scheitel +scheitern +Schelf +Schelle +Schelm +Schelte +Schema +Schemel +Schemen +Schenke +Schenkel +schenken +Scherbe +Schere +scheren +Scherz +Scheu +scheuchen +Scheuer +scheuern +Scheune +Scheusal +scheußlich +schick +schicken +Schicksal +Schickt +schieben +Schied +schief +Schiefer +schielen +schien +Schiene +schier +schießen +Schiff +Schikane +Schild +schildern +Schilf +schillern +Schimmel +schimmern +Schimpanse +schimpfen +Schindel +schinden +Schinken +schippe +Schirm +Schlacht +Schlacke +schlackern +schlaff +Schlag +schlagen +Schlager +Schlamm +schlampig +schlang +Schlange +schlank +schlapp +schlau +Schlauch +Schlaufe +Schlawiner +schlecht +schlecken +Schlehe +Schlei +schleichen +Schleie +Schleier +Schleife +schleifen +Schleim +schlemmen +schlendern +schlenzen +schleppen +Schleuder +schleunig +Schleuse +schlich +schlicht +Schlick +schlief +schließen +schliff +schlimm +Schlingel +schlingen +schlingern +Schlips +Schlitten +schlitz +schloss +Schlot +schlottern +Schlucht +schluchzen +Schluck +schludern +schlug +Schlummer +Schlumpf +Schlund +schlurfen +Schluss +Schmach +schmal +Schmalz +Schmand +schmatzen +Schmaus +schmecken +schmeißen +schmelzen +Schmerz +schmettern +schmiegen +schmieren +schminken +schmirgeln +schmiss +schmollen +schmoren +Schmuck +Schmuggel +schmunzeln +Schmus +Schmutz +Schnabel +Schnake +Schnalle +schnalzen +schnappen +Schnaps +schnarchen +schnaufen +Schnauze +Schnecke +Schnee +Schneid +schneiden +Schneise +Schnepfe +schnetzeln +schniefen +schnippeln +schnippen +Schnipsel +schnitt +Schnitzel +schnitzen +Schnorchel +schnorren +Schnucke +Schnuller +Schnulze +schnupfen +schnuppern +Schnur +schnurren +Schnute +schob +Schock +schofelig +Schokolade +Scholle +schon +schonen +Schoner +Schonung +Schopf +Schoppen +Schorf +Schorle +Schoß +Schote +Schott +Schotter +Schramme +Schrank +Schranke +Schraube +Schreck +Schredder +schreiben +schreichen +schreien +Schrein +schreiten +schrie +Schrift +schrill +Schritt +schroff +Schrot +Schrothkur +Schrott +Schrubber +Schrulle +Schrumpel +schrumpfen +Schub +Schubs +schuf +Schuft +schuften +Schuh +Schuld +Schule +Schulter +schummeln +schummerig +schund +schunkeln +Schuppe +Schuppen +Schur +Schurke +Schurz +Schuss +Schussel +Schuster +Schute +Schutt +Schutz +schwabbeln +Schwabe +schwach +schwafeln +Schwager +Schwalbe +Schwall +Schwamm +Schwan +schwanger +Schwank +schwanken +Schwanz +schwappen +Schwarm +Schwarte +schwarz +schwarzen +schwatzen +schweben +Schweden +Schwefel +Schweif +schweigen +Schwein +Schweiß +schweißen +Schweiz +schwelgen +Schwelle +schwellen +schwemmen +schwenken +schwer +schwerlich +Schwert +Schwester +Schwiele +schwimmen +Schwindel +schwinden +schwingen +Schwips +schwirren +schwitzen +Schwof +Schwule +Schwulst +Schwund +Schwung +Schwur +sechs +Seele +seelisch +seelischen +Segel +Segen +Segment +segnen +sehen +Sehne +sehr +seicht +seid +Seide +Seife +Seil +sein +seine +seiner +seit +Seite +Sekret +Sekt +Sekte +Sektion +Sektor +Sekunde +selber +selbst +selig +Sellerie +selten +Selters +seltsam +Semantik +Semester +Semikolon +Seminar +Semmel +Senat +senden +Senf +sengen +senil +senior +Senkel +senken +senkt +Senn +Sensation +Sense +sensibel +separat +September +serbisch +Serenade +Serie +Serpentine +Serum +Servelat +Service +Sessel +sesshaft +setzen +Seuche +seufzen +sezieren +Shampoo +Sheriff +Shirt +Shop +Shorts +Show +sich +Sichel +sicher +Sicht +Sichtweite +sickern +Sieb +sieben +siech +siedeln +sieden +Sieg +Siegel +siehe +siezen +Signal +Signatur +Silbe +Silber +Silhouette +Silikon +Silo +Silvester +simpel +Sims +simulieren +simultan +sind +Sinfonie +singen +Single +Singular +sinken +sinnen +Sintflut +Sinto +Sinus +Sippe +Sirene +Sirup +Sisal +Sitte +Sittich +Situation +Sitz +Skala +Skalp +Skalpell +Skandal +Skat +Skateboard +Skelett +Skepsis +Sketch +Skinhead +Skizze +Sklave +Sklerose +Skonto +Skooter +Skorpion +Skrupel +Skulptur +Skyline +Slalom +Slang +Slawe +Slip +Slipper +Slogan +Slowakei +Slowenien +Slum +Smalltalk +Smaragd +smart +Smog +Snob +Socke +Sockel +Soda +Sofa +Softeis +Software +sogar +sogleich +Sohle +Sohn +Soja +solar +solch +solcher +Sold +Soldat +Sole +solide +sollen +sollten +Solo +Solvenz +Sommer +Sonate +Sonde +sonderbar +sondern +Song +Sonnabend +Sonne +Sonntag +sonst +Sopran +Sorbe +Sorge +Sorte +Soße +Souffleur +Soul +Sound +Souterrain +Souvenir +soviel +sozial +Sozius +Spachtel +Spagat +Spaghetti +Spalier +spaltbreit +spalten +Span +Spange +Spaniel +spanisch +spannen +sparen +Spargel +Sparte +Spaß +Spastiker +Spaten +Spatz +spazieren +Specht +Speck +Spedition +Spedituren +Speed +Speer +Speiche +Speichel +Speicher +speien +Spektakel +Spektrum +Spelunke +spenden +Sperling +sperren +Spesen +spezial +spicken +Spiegel +Spiel +Spieler +Spieß +Spike +Spinat +Spind +Spindel +Spinett +spinnen +Spion +Spirale +Spiritual +Spiritus +Spital +spitz +Spleen +Splitt +Splitter +Sponsor +spontan +sporadisch +Spore +Sporn +Sport +Spot +spotten +Sprache +Spray +sprechen +spreizen +sprengen +Spreu +Sprichwort +sprießen +springen +Sprint +Sprit +spritzen +Spross +Sprotte +Spruch +Sprudel +Sprung +spucken +spuken +Spule +Spund +Spur +Spurt +sputen +Sputnik +Staat +Stab +stabil +Stabreim +Stachel +Stadel +Stadion +Stadium +Stadt +Stafette +Staffel +Staffelei +stagnieren +Stahl +staksen +Stalagnit +Stall +Stamm +stammeln +stampfen +stand +Standard +standen +Standpunkt +Stange +stanzen +Stapel +stapfen +Star +stark +starr +Start +Station +Statist +Statistik +Stativ +statt +Statue +Statur +Status +Stau +Staub +stauchen +Staude +staunen +staute +Steak +Stearin +stechen +stecken +Steg +Stegreif +stehen +stehlen +steif +Steifel +steigen +steigern +steil +Stein +Steiß +stellen +Stelze +stemmen +Stempel +Stepp +Steppe +steppen +sterben +Stereo +steril +Stern +stetig +Steuer +Stich +Stichel +sticken +Sticker +stickig +Stickstoff +Stiefel +Stiege +Stiel +Stier +Stiesel +Stift +Stil +Stilett +still +Stimme +stinken +Stipendium +stippen +Stirn +stochern +Stock +stocken +Stoff +Stola +Stollen +stolpern +Stolz +stopfen +Stoppel +Storch +Store +stornieren +Story +stoßen +stottern +Strafe +straff +Strahl +stramm +strampeln +Strand +Strang +Strapaze +Straps +Straße +Strategie +Strauch +straucheln +Strauß +streben +Strecke +streichen +streifen +Streik +streiken +streiten +streng +Stress +streuen +streunen +Strich +stricken +striegeln +Strieme +striezen +strikt +Strippe +Stroh +Strolch +Strom +stromern +Strophe +strotzen +strubbelig +Strudel +Struktur +Strumpf +Strunk +struppig +Stube +Stuck +Student +Studie +studieren +Studio +Stufe +Stuhl +Stulle +stumm +Stummel +stumpf +Stunde +Stuntfrau +Stuntgirl +Stuntman +Stups +stupsen +Stupsnase +stur +Sturheit +Sturm +Sturmflut +Sturz +Sturzbach +Sturzflug +Sturzhelm +stutzen +stutzig +stylen +Styropor +Subjekt +subjektiv +Substantiv +Substanz +subtil +Subvention +Suchaktion +Suchdienst +Suche +suchen +Sucher +Sucherei +Suchhund +Sucht +Suff +Suffix +Sulfonamid +Sultan +Summand +summarisch +Summe +Summton +Sumpf +sumpfig +Sumpfvogel +super +superfein +superklug +Superlativ +Supermann +Supermarkt +Superstar +Suppe +Suppenhuhn +Surfbrett +surfen +Surfer +Surfing +surren +suspekt +Sweatshirt +Swing +swingen +Symbol +symbolhaft +Symbolik +symbolisch +Symmetrie +Sympathie +Symptom +Synagoge +Syndrom +Synonym +Syntax +Synthese +System +Szene +Szenerie +szenisch +Tabak +Tabakwaren +Tabelle +Tablett +Tablette +Tabu +Tabuierung +Tachometer +Tadel +tadellos +tadeln +Tafel +Tafelberg +tafeln +Taft +tagaus +Tagebau +Tagebuch +tagein +tagelang +tagen +Tages +Tagung +Taifun +Taille +tailliert +Takt +taktieren +Taktik +Taktiker +taktisch +taktlos +Taktstrich +taktvoll +Talent +talentiert +Taler +Talg +talgig +Talisman +Talkmaster +Talkshow +Tampon +Tandem +Tango +Tank +tanken +Tanker +Tankstelle +Tankwart +Tanne +Tannenbaum +Tante +Tanz +Tanzbar +tanzen +Tanzschule +Tapete +tapezieren +tapfer +Tapferkeit +tappen +tapsen +Tarif +Tariflohn +tarnen +Tarnfarbe +Tarnkappe +Tarnung +Tartan +Tartanbahn +Tarzan +Tasche +Tasse +Tastatur +Taste +tasten +Tastsinn +Tatort +Tatsache +tatschen +Tatze +taub +Taube +Taubheit +Taubnessel +taubstumm +tauchen +Taucher +Tauende +Taufe +taufen +Taufpate +taufrisch +Taufschein +taugen +tauglich +Taumel +taumelig +taumeln +taumlig +Tausch +tauschen +tausend +Tautropfen +Tauwetter +Tauziehen +Taverne +Taxe +Teak +Team +Tearoom +Technik +Teddy +Teenager +Teer +Teich +Teig +Teil +Teilchen +Teilzeit +Teint +Telefax +Telefon +Telegraf +Telegramm +Telepathie +Teleskop +Television +Teller +Tempel +Tempo +Tempus +Tendenz +Tender +Tenne +Tennis +Tenor +Teppich +Termin +Terminal +Terminus +Termite +Terpentin +Terrain +Terrarium +Terrasse +Terrier +Terrine +Terror +Tesafilm +Test +Testament +Tetanus +teuer +Teufel +teures +Text +Textilien +Theater +Theke +Thema +Theologie +Theorie +These +Thriller +Thron +Thunfisch +Tick +ticken +Ticket +Tide +tief +Tiegel +Tier +Tiger +tilgen +timen +tingeln +Tinktur +Tinte +Tipp +tippeln +tippen +Tipptopp +Tirade +Tiramisu +Tisch +Titel +Toast +toben +Tochter +Tofu +Toilette +Toleranz +toll +Tollpatsch +Tomahawk +Tomate +Tombola +Tonfall +Tonic +Tonne +Topas +Topf +Torf +torkeln +Tornado +Tornister +Torpedo +Torpedos +Torso +Torte +Tortellini +tosen +total +Totem +Toto +Toupet +Tour +Tower +traben +Trabent +Tracht +Tradition +Trafo +tragen +tragisch +trainieren +Trakt +traktieren +Traktor +Tram +Tramp +trampeln +Trampolin +Tran +Transistor +Transit +transitiv +Transport +Trapez +trappeln +trapsen +Trasse +trat +Tratsch +tratschen +Traube +trauen +Trauer +Trauerfall +Trauerkloß +trauern +Traufe +traulich +Traum +Traumberuf +traumhaft +traurig +Trauung +Trauzeuge +Trecker +treffen +treffend +Treffer +Treffpunkt +Treibeis +treiben +Treiber +Treibjagd +Treibsand +Treibstoff +Trend +Trendwende +trennbar +trennen +Trennung +Trennwand +treppab +treppauf +Treppchen +Treppe +Tresen +Tresor +Tretboot +treten +Treter +Tretmine +treu +Treue +treuherzig +treulos +Triangel +Triathlet +Triathlon +Tribunal +Tribut +Trichter +Trick +Trickfilm +trickreich +Trieb +triebhaft +Triebkraft +Triebwerk +triefen +triefnass +triezen +triftig +Trikot +Triller +trillern +Trilliarde +trimmen +trinkbar +trinken +Trinker +Trinkgeld +Trio +Trip +trippeln +trist +tritt +trittfest +Triumph +trivial +trocken +trocknen +Trog +trollen +Trommel +trommeln +Trommler +trompete +Trompeter +Tropen +Tropf +Tropfen +tropisch +Trost +trostlos +Trott +Trottel +trottelig +trotteln +trotten +trotz +trotzdem +trotzen +trotzig +Trotzkopf +Trubel +Truck +Trucker +trudeln +trug +Truhe +Trumpf +Trumpfass +trumpfen +Trunk +Trunksucht +Truppe +Truthahn +Truthenne +Tscheche +Tschechien +Tschechin +T-Shirt +Tuba +Tube +Tuch +Tuchfabrik +Tugend +Tugendbold +tugendhaft +Tulpe +Tulpenbeet +Tumor +Tumult +Tundra +tunen +Tunfisch +Tunichtgut +Tuning +tunken +tunlichst +Tunnel +tupfen +Tupfer +Turban +Turbine +Turbomotor +turbulent +Turbulenz +Turm +Turmbau +turmhoch +turnen +Turner +Turnerin +Turnhalle +Turnhose +Turnier +Turnus +turteln +Tusch +Tusche +tuscheln +tuten +Tweed +Tweedhosen +Twen +Twinset +Twist +Typhus +Tyrann +Ufer +Ukraine +Ulme +Ultimatum +ultra +umarmen +Umbau +umblicken +umbringen +umdrehen +umeinander +umfahren +umfallen +Umfang +umfassend +Umfeld +Umfrage +Umgang +Umgebung +umgehen +Umhang +umher +umkehren +umkleiden +umkommen +Umkreis +umlagern +umlaufen +Umlaut +umlegen +umleiten +umliegend +umpflanzen +Umrandung +umreißen +umringen +Umriss +umsatteln +Umsatz +umschalten +Umschau +Umschlag +umschulen +Umschwung +Umsicht +umso +umsonst +umspannen +Umstand +umsteigen +umstellen +umstimmen +umstritten +Umsturz +umtauschen +umwandeln +Umweg +Umwelt +umwerfen +umziehen +umzusehen +unachtsam +unangenehm +Unart +unbedingt +unbefugt +unbegrenzt +Unbehagen +unbeholfen +unbeirrt +unbekannt +unbesonnen +unbesorgt +unbeugsam +unbewusst +uneben +unehelich +uneins +unendlich +unentwegt +unerwartet +Unfall +Unfug +Ungarn +ungeachtet +Ungeduld +ungeeignet +ungeheuer +ungehorsam +ungelernt +ungeniert +ungerade +ungerecht +ungewiss +Ungeziefer +ungezogen +Ungunst +Unheil +unheimlich +Unhold +Uniform +Unikum +Union +universal +Universum +unken +Unkosten +Unkraut +unlauter +Unmenge +unnahbar +Unrat +Unrecht +Unschuld +Unsinn +unten +unter +Untergang +Untergrund +unterhalb +Unterhalt +Unterholz +Unterhose +Unterhosen +Unterkunft +unterlegen +Untermiete +Unterricht +untersagen +Untersatz +Unterseite +unterst +Untertan +Untertasse +Unterteil +unterwegs +Unterwelt +Untiefe +Untier +unverhofft +unverwandt +unwahr +Unwesen +Unwetter +unwichtig +unwissend +Unzucht +Uradel +Urahn +Urahne +uralt +Uran +Uranerz +uranhaltig +urban +urbar +Urheber +Urin +urinieren +urkomisch +Urkunde +urkundlich +Urlaub +Urlauber +Urlauberin +Urmensch +Urne +Urnengang +Urnengrab +Ursache +Ursprung +Urteil +Urwald +Urzeit +urzeitlich +Utensilien +utopisch +Vagabund +vage +vakant +Vakanz +Vakuum +Valuta +Vampir +Vandale +Vanille +Vanilleeis +variabel +Variable +Variante +variieren +Vase +Vaselin +Vaseline +Vater +Vaterland +Vaterunser +Vati +Vatikan +vebohrt +Vegetarier +Vegetation +vegetieren +Vehikel +Veilchen +veilleicht +Vektor +Vene +Ventil +Ventilator +Venus +Venussonde +verabreden +verachten +Verachtund +Verachtung +veralten +veraltet +Veranda +Verb +Verband +verbergen +verbessern +verbieten +verbinden +Verbindung +Verbiss +verbissen +Verbleib +verbleiben +verblichen +verborgen +Verborgene +Verbot +Verbrauch +verbrechen +Verbrecher +verbreiten +Verbund +Verdacht +verdammen +Verdammnis +verdattert +verdauen +Verdauung +Verdeck +verdecken +verderben +verdienen +Verdienst +verdrießen +Verdruss +verdutzen +verdutzt +Verein +vereinbar +vereinen +vereinigen +vereinzeln +vereinzelt +vereiteln +vererbbar +vererben +vererblich +Vererbung +verfahren +Verfall +verfallen +verfassen +Verfasser +Verfassung +verfilmen +Verfilmung +verflixt +verfluchen +verflucht +verfolgen +Verfolger +Verfolgung +Vergaser +vergaß +vergeben +vergebens +vergeblich +Vergebung +vergehen +vergelten +vergessen +vergeuden +vergilben +Vergleich +vergriffen +verhaften +Verhaftete +Verhaftung +verhalten +verhandeln +verhangen +verhasst +verheeren +verheerend +verheißen +verheult +verhindern +verhungern +verirren +verjagen +verkabeln +Verkauf +verkaufen +Verkehr +verkehrt +verkleiden +verkneifen +verkniffen +verkommen +verkraften +verladen +Verladung +Verlag +verlagerte +verlangen +verlassen +Verlauf +verlaufen +verlegen +Verleger +Verleih +verleihen +Verleiher +verleiten +verletzen +verletzt +Verletzung +verlieben +Verliebte +verlieren +Verlierer +Verlies +verloben +Verlobung +verloren +Verlust +vermachen +vermeidbar +vermeiden +Vermeidung +Vermerk +vermiesen +vermieten +Vermieter +vermissen +Vermisste +vermitteln +Vermittler +vermuten +vermutlich +Vermutung +vernehmbar +vernehmen +Vernehmung +vernichten +Vernunft +verordnen +Verordnung +verpacken +Verpackung +verpassen +verpetzen +verpflegen +Verrat +verraten +verrechnen +verreise +verrenken +Verrenkung +verrotten +Verrottung +Vers +Versagen +Versager +Versagerin +Versagung +Versand +Verschleiß +Verschluss +verschonen +Versehen +versehrt +versenden +versetzen +Versetzung +versichern +versiegen +versinken +Versmaß +versorgen +Versorgung +Verstand +Versteck +verstecken +verstehen +verstellen +verstimmt +verstockt +verstopft +Verstoß +verstoßen +Versuch +versuchen +Versucher +Versuchung +versumpfen +verteilen +Verteiler +Verteilung +vertikal +Vertikale +Vertikalen +vertonen +Vertonung +Vertrag +vertrauen +Vertraute +vertreiben +verwackeln +verwahren +verwaisen +verwalten +Verwalter +Verwaltung +verwandeln +verwandt +Verwandte +Verwandten +verwarnen +Verwarnung +verweigern +Verweis +verweisen +verwelken +verwendbar +verwenden +Verwendung +verwesen +verwest +Verwesung +verwinden +verwirren +Verwirrung +verworren +verwundbar +Verwundete +Verwundung +verzehren +verzeihen +Verzeihung +verzerrt +verzetteln +Verzicht +verzichten +verziehen +verzieren +verzinken +verzinsen +verzollen +Verzug +verzweigt +verzwickt +Veteran +Veto +Vetorecht +Vetter +Vibration +vibrieren +Videospiel +Videotext +Videothek +Vieh +Viehherde +Viehzucht +viel +Vieleck +vielerlei +vielfach +Vielfalt +vielleicht +vielmals +vier +Vierbeiner +vierbeinig +Viereck +vierfach +viermal +Viertel +vierteln +viertens +Vierzeiler +Villa +violett +Violine +Violinist +Virus +Visage +Visagist +Visier +Vision +Visitation +Visite +Visum +visumfrei +Vitamin +Vitrine +Vogel +Vogelbeere +vogelfrei +Vokabel +Vokabular +Vokal +Vokallist +Volant +Volk +Volksfest +Volkslied +voll +vollauf +Vollbart +volle +vollenden +vollends +Volleyball +vollgießen +vollkommen +vollladen +Vollmacht +Vollmilch +Vollmond +vollpacken +vollpumpen +volltanken +vollziehen +Volt +Volumen +vorab +voran +vorangehen +voraus +Voraussage +vorbei +vorbeugen +Vorbild +Vorbildung +vorbringen +Vordach +vordringen +voreilig +Vorfahren +Vorfahrt +Vorfall +vorfallen +Vorfilm +Vorfreude +Vorgabe +Vorgang +Vorgehen +vorgestern +Vorhand +vorhanden +Vorhang +vorher +vorherig +vorhin +Vorhinein +vorig +Vorkehrung +vorkommen +Vorkommnis +vorladen +Vorladung +Vorlage +Vorlauf +vorlesen +Vorlesung +vormachen +Vormittag +vormittags +Vormund +Vorname +vorne +vornehm +Vornehmen +vornherein +Vorort +Vorortzug +Vorrat +Vorrunde +Vorsatz +Vorschau +Vorschein +Vorschlag +vorschnell +Vorschrift +Vorschule +Vorschuss +vorsehen +Vorsehung +Vorsicht +vorsichtig +Vorsilbe +Vorsitz +Vorsorge +vorsorgen +Vorsprung +Vorstand +vorstellen +Vorstrafe +vortasten +Vorteil +Vortrag +vortragen +Vorurteil +Vorverkauf +Vorwahl +Vorwand +vorweg +vorwerfen +vorwiegend +Vorwort +Vorwurf +vorzeigen +Vorzeit +vorzeitig +Vorzensur +vorziehen +Vorzug +Votum +Vulkan +vulkanisch +Waage +waagerecht +wabbeln +Wabe +wach +Wacholder +Wachs +wachsen +Wacht +Wachtel +wackeln +wacker +Wade +Waffe +Waffel +wagen +Waggon +Wahl +Wahlurne +Wahn +wahr +wahres +Waise +Wald +Walhall +walken +Walkman +Wall +Wallach +Wallfahrt +Walnuss +Walross +Walstatt +walten +Walze +Walzer +Wand +Wandel +wandern +Wange +wanken +wann +Wanne +Wanze +Wappen +Ware +waren +Warenhaus +warf +warm +warnen +warte +warten +wartete +warteten +warum +Warze +waschen +Wasser +waten +Watsche +watscheln +Watt +Watte +weben +Wechsel +Wecke +wecken +Wedel +weder +wegen +wehen +Wehr +Weib +weich +Weiche +weichen +Weide +weiden +weigern +Weihe +weil +Weile +Wein +weinen +Weintraube +weise +weisen +weiß +weit +weiter +Weizen +welch +welk +Welle +Wellen +Welpe +Wels +Welt +wende +wenden +wenig +wenige +weniger +wenigstens +wenn +werben +werde +werden +werfen +Werft +Werk +Wermut +Wert +Wesen +weshalb +Wesir +Wespe +wessen +West +Weste +Westen +Westfalen +weswegen +Wette +Wetter +wetzen +Whisky +Wicht +wichtig +Wickel +wickeln +Widder +Widerhaken +widerlegen +widerlich +Widerruf +widerrufen +Widerstand +Widerwille +Widerworte +widmen +Widmung +widrig +Widrigkeit +wieder +Wiedergabe +Wiederwahl +Wiege +wiegen +Wiegenlied +wiehern +Wiese +Wiesel +wieso +wieviel +wievielmal +wieweit +wiewohl +Wigwam +Wild +Wildbret +Wilddieb +wildern +Wildfang +wildfremd +Wildgans +Wildnis +Wille +willkommen +wimmeln +wimmern +Wimpel +Wimper +Wind +Winde +Windel +winden +Winkel +winken +Winker +winseln +Winter +Winzer +winzig +Wipfel +wippen +Wirbel +wirbeln +wird +wirken +wirklich +wirr +Wirrkopf +Wirt +Wirtschaft +wischen +Wisent +wispern +wissen +wittern +Witwe +Witz +Woche +Wodka +Woge +wohl +wohnen +wohnhaft +Wohnung +Wolf +Wolke +Wolle +wollen +wollte +Wollust +Wonne +Workshop +Wort +wortgetreu +Wrack +wringen +Wucher +Wuchs +wuchsen +Wucht +Wulst +wund +Wunder +Wunsch +Wurf +Wurm +Wurst +Wurststand +Wurzel +wusch +wusste +Wust +Xantippe +Xylophon +Xylose +Yacht +Yankee +Yard +Yoga +Youngster +Yucca +Yuppie +Zacke +zagen +Zahl +zahm +Zahn +Zander +Zange +Zank +Zapfen +zappeln +zart +Zauber +zaudern +Zaum +Zaun +zausen +Zaziki +Zebra +Zeche +zechen +Zechgelage +Zecke +Zeckenbiss +Zeder +Zedernholz +Zehe +Zehen +zehn +Zehner +Zehnkampf +zehnmal +Zehntel +zehntens +zehren +Zehrgeld +Zeichen +zeichnen +Zeichnerin +Zeichnung +zeigen +Zeiger +Zeile +Zeir +Zeit +Zeiten +Zeitform +zeitgleich +zeitig +zeitlebens +Zeitlupe +Zeitraum +Zeitung +zeitweilig +zeitweise +Zeitzone +Zelle +Zellgewebe +Zellkern +Zellophan +Zellulose +Zelt +zelten +Zeltlager +Zeltplane +Zeltplatz +Zement +Zenit +zensieren +Zensor +Zensur +Zentaur +Zentimeter +Zentner +zentral +Zentrale +zentrieren +Zentrifuge +Zentrum +Zeppelin +Zepter +zerbrechen +zerdeppern +Zeremonie +zerfahren +Zerfall +zerfallen +zerfeddert +zerkauen +zerkratzen +zerlegbar +zerlegen +Zerlegung +zerlumpt +zerplatzen +zerplatzt +zerreißen +zerren +Zerrung +zersetzen +Zersetzung +zerstreuen +zerstreut +zerteilen +Zerteilung +Zertifikat +zerzausen +zerzaust +zeteilen +zetern +Zettel +Zeug +Zeuge +Zeugnis +Zeugniss +Zeugung +Zicke +zickig +Zickzack +Zickzeck +Ziege +Ziegel +Ziegelei +ziehen +Ziel +zielen +Zielgerade +ziellos +ziemen +ziemlich +Zier +Zierde +zieren +zierlich +Zierrat +Ziffer +Zigarette +Zigarillo +Zigarre +Zigeuner +Zikade +Zimbel +Zimmer +Zimmermann +zimmern +zimperlich +Zimt +zimtfarben +Zimtstange +Zimtstern +Zink +Zinke +Zinkeisen +Zinken +Zinker +Zinn +Zinnbecher +Zinne +Zinnsoldat +Zins +Zinseszins +zinslos +Zipfel +Zirkel +zirkeln +Zirkus +Zirkuszelt +zirpen +zischeln +zischen +Zischlaut +Zisterne +Zitadelle +Zitat +Zither +Zitrone +zitterig +zittern +zittrig +Zitze +zivil +Zivilist +Zobel +Zocker +Zofe +Zoff +Zoll +Zollbeamte +zollbreit +zollfrei +Zone +Zoologie +Zoom +Zopf +Zorn +zornig +Zote +zottelig +zubeißen +zubereiten +zubinden +Zubiss +Zubringer +Zucht +zuckeln +zucken +Zucker +zuckerig +zuckern +Zuckerrohr +Zuckungen +zudecken +zueinander +zuerst +Zufahrt +Zufall +zufallen +zufassen +Zuflucht +Zufluss +zufolge +zufrieden +zufrieren +Zufuhr +Zugabe +Zugabteil +zugeben +zugeguckt +zugestehen +zugig +Zugkraft +zugrunde +zugucken +zugunsten +zugute +Zugvogel +zuhauen +zujubeln +zuklappen +zukleben +Zukunft +Zulage +zulangen +zulasten +Zulauf +zulaufen +zuleide +zuleiten +Zuleitung +zuletzt +zuliebe +zumachen +zumeist +zumindest +zumute +Zunahme +Zuname +Zunder +zunehmen +Zuneigung +Zunft +Zunge +zunichte +zunutze +zupacken +zupfen +zurande +zurate +zurecht +zureden +Zuruf +zurufen +zurzeit +Zusage +zusagen +zusammen +Zusatz +Zusatzzahl +zuschaden +zuschanden +zuschauen +Zuschauer +zuschicken +Zuschlag +zuschulden +Zuschuss +zusehen +zusehends +zuspitzen +Zuspruch +Zustand +zustande +zustatten +zusteigen +zustellen +Zusteller +Zustellung +zustimmen +Zustimmung +zutage +Zutat +zutauen +zuteilen +Zuteilung +Zutrauen +zutraulich +zutreffen +zutreffend +Zutritt +Zutun +Zuversicht +zuvor +Zuwachs +zuwachsen +zuwege +zuweilen +zuweisen +Zuweisung +zuwider +zuziehen +Zuzug +Zwang +zwanglos +zwanzig +zwanzigste +zwar +Zweck +zwei +zweideutig +zweierlei +zweifach +Zweifel +zweifellos +zweifeln +Zweifler +Zweig +zweimal +zweispurig +Zweistzer +zweitens +Zwerchfell +Zwerg +Zwerghuhn +Zwetsche +Zwickel +zwicken +Zwicker +Zwieback +Zwiebel +zwiebeln +zwiefach +Zwielaut +Zwietracht +Zwilling +zwingen +Zwinger +zwinkern +Zwirn +zwischen +Zyklon +Zylinder +Zyniker +zynisch +Zypresse diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..6a08674 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6501 @@ +{ + "name": "timelimit-server-2018", + "version": "0.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@ladjs/i18n": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@ladjs/i18n/-/i18n-1.1.0.tgz", + "integrity": "sha512-Kynr5osjApDCyiik35MMNZC1lgjgrk7fbV6P1qHXKQ67sR/U85Ddnv1NNPc/2s08PQVjvIBNY96UACb0CivrWg==", + "requires": { + "auto-bind": "^2.0.0", + "boolean": "^0.2.0", + "boom": "7.3.0", + "country-language": "^0.1.7", + "i18n": "^0.8.3", + "i18n-locales": "^0.0.2", + "lodash": "^4.17.11", + "moment": "^2.23.0", + "qs": "^6.6.0", + "underscore.string": "^3.3.5" + }, + "dependencies": { + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "moment": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + }, + "qs": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.6.0.tgz", + "integrity": "sha512-KIJqT9jQJDQx5h5uAVPimw6yVg2SekOKu959OCtktD3FjzbpvaPr8i4zzg07DOMz+igA4W/aNM7OV8H37pFYfA==" + } + } + }, + "@types/babel-types": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/@types/babel-types/-/babel-types-7.0.5.tgz", + "integrity": "sha512-0t0R7fKAXT/P++S98djRkXbL9Sxd9NNtfNg3BNw2EQOjVIkiMBdmO55N2Tp3wGK3mylmM7Vck9h5tEoSuSUabA==" + }, + "@types/babylon": { + "version": "6.16.5", + "resolved": "https://registry.npmjs.org/@types/babylon/-/babylon-6.16.5.tgz", + "integrity": "sha512-xH2e58elpj1X4ynnKp9qSnWlsRTIs6n3tgLGNfwAGHwePw0mulHQllV34n0T25uYSu1k0hRKkWXF890B1yS47w==", + "requires": { + "@types/babel-types": "*" + } + }, + "@types/bluebird": { + "version": "3.5.23", + "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.23.tgz", + "integrity": "sha512-xlehmc6RT+wMEhy9ZqeqmozVmuFzTfsaV2NlfFFWhigy7n6sjMbUUB+SZBWK78lZgWHA4DBAdQvQxUvcB8N1tw==", + "dev": true + }, + "@types/body-parser": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", + "integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==", + "dev": true, + "requires": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "@types/bson": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@types/bson/-/bson-1.0.11.tgz", + "integrity": "sha512-j+UcCWI+FsbI5/FQP/Kj2CXyplWAz39ktHFkXk84h7dNblKRSoNJs95PZFRd96NQGqsPEPgeclqnznWZr14ZDA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/connect": { + "version": "3.4.32", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.32.tgz", + "integrity": "sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/continuation-local-storage": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@types/continuation-local-storage/-/continuation-local-storage-3.2.1.tgz", + "integrity": "sha1-oz4N+dzptCTRyY/E/evYV43O7H4=", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/email-templates": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@types/email-templates/-/email-templates-3.5.0.tgz", + "integrity": "sha512-4CRCtDogTManXlOcj9ixIcxoHTKcaxpqaJWuMN/Zw9tYL1nqVkI64IWcx+CQ9XT/JnpP12buionHQqgrHcH34Q==", + "dev": true + }, + "@types/events": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", + "integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA==", + "dev": true + }, + "@types/express": { + "version": "4.16.0", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.16.0.tgz", + "integrity": "sha512-TtPEYumsmSTtTetAPXlJVf3kEqb6wZK0bZojpJQrnD/djV4q1oB6QQ8aKvKqwNPACoe02GNiy5zDzcYivR5Z2w==", + "dev": true, + "requires": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "*", + "@types/serve-static": "*" + } + }, + "@types/express-serve-static-core": { + "version": "4.16.0", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.0.tgz", + "integrity": "sha512-lTeoCu5NxJU4OD9moCgm0ESZzweAx0YqsAcab6OB0EB3+As1OaHtKnaGJvcngQxYsi9UNv0abn4/DRavrRxt4w==", + "dev": true, + "requires": { + "@types/events": "*", + "@types/node": "*", + "@types/range-parser": "*" + } + }, + "@types/geojson": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-1.0.6.tgz", + "integrity": "sha512-Xqg/lIZMrUd0VRmSRbCAewtwGZiAk3mEUDvV4op1tGl+LvyPcb/MIOSxTl9z+9+J+R4/vpjiCAT4xeKzH9ji1w==" + }, + "@types/http-errors": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-1.6.1.tgz", + "integrity": "sha512-s+RHKSGc3r0m3YEE2UXomJYrpQaY9cDmNDLU2XvG1/LAZsQ7y8emYkTLfcw/ByDtcsTyRQKwr76Bj4PkN2hfWg==", + "dev": true + }, + "@types/lodash": { + "version": "4.14.116", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.116.tgz", + "integrity": "sha512-lRnAtKnxMXcYYXqOiotTmJd74uawNWuPnsnPrrO7HiFuE3npE2iQhfABatbYDyxTNqZNuXzcKGhw37R7RjBFLg==", + "dev": true + }, + "@types/mime": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.0.tgz", + "integrity": "sha512-A2TAGbTFdBw9azHbpVd+/FkdW2T6msN1uct1O9bH3vTerEHKZhTXJUQXy+hNq1B0RagfU8U+KBdqiZpxjhOUQA==", + "dev": true + }, + "@types/mongodb": { + "version": "3.1.12", + "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.1.12.tgz", + "integrity": "sha512-HKacBlbypwL3qR/W9o5G+3zCAcfLY2Wva1Ttq7u2y5HnkX20Huz8uNYnjo14eQeuOUyt8YZf963h2m64ajg5fA==", + "dev": true, + "requires": { + "@types/bson": "*", + "@types/node": "*" + } + }, + "@types/node": { + "version": "10.5.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.4.tgz", + "integrity": "sha512-8TqvB0ReZWwtcd3LXq3YSrBoLyXFgBX/sBZfGye9+YS8zH7/g+i6QRIuiDmwBoTzcQ/pk89nZYTYU4c5akKkzw==" + }, + "@types/range-parser": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.2.tgz", + "integrity": "sha512-HtKGu+qG1NPvYe1z7ezLsyIaXYyi8SoAVqWDZgDQ8dLrsZvSzUNCwZyfX33uhWxL/SU0ZDQZ3nwZ0nimt507Kw==", + "dev": true + }, + "@types/sequelize": { + "version": "4.27.24", + "resolved": "https://registry.npmjs.org/@types/sequelize/-/sequelize-4.27.24.tgz", + "integrity": "sha512-5uMFsMa/0hU/7/8znyfBKSJy2Mbd57uRpYk5X1+Phz9dN0MRZLbTbj1JMeB3CJ4R9b1coNQGfp2kXh4OjI9UyA==", + "dev": true, + "requires": { + "@types/bluebird": "*", + "@types/continuation-local-storage": "*", + "@types/lodash": "*", + "@types/validator": "*" + } + }, + "@types/serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-/BZ4QRLpH/bNYgZgwhKEh+5AsboDBcUdlBYgzoLX0fpj3Y2gp6EApyOlM3bK53wQS/OE1SrdSYBAbux2D1528Q==", + "dev": true, + "requires": { + "@types/express-serve-static-core": "*", + "@types/mime": "*" + } + }, + "@types/socket.io": { + "version": "1.4.36", + "resolved": "https://registry.npmjs.org/@types/socket.io/-/socket.io-1.4.36.tgz", + "integrity": "sha512-nwu9Fbz8VesmXhMzbN2r2095uvXQZy9QxyKHmHnU5/71f2/13kH7gdD9hRqTNDhNZvw/PIlhGyYgQg1t5rT1Ig==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/tokgen": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/tokgen/-/tokgen-1.0.0.tgz", + "integrity": "sha512-H1jyCXVxBrh2EfddtVJdgu9w65jaqBFYX0Tkm/rq7Sv1TYBURamJ3rE5C/+P9stsKj+Q/QQbQ5YXyY3SS6xG+g==", + "dev": true + }, + "@types/umzug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@types/umzug/-/umzug-2.2.0.tgz", + "integrity": "sha512-p9yaOdoKRYT8MuLOGKigzOFKaIrd6v6OwcfUEEGNiLYWldf1dLgoZ74e0vuo9/tpIuww9LuoqfJFEEslj4Z7Ng==", + "dev": true, + "requires": { + "@types/events": "*", + "@types/mongodb": "*", + "@types/sequelize": "*" + } + }, + "@types/validator": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-9.4.1.tgz", + "integrity": "sha512-Y8UyLZvBPgckGhEIFCGBPj1tsRbpcZn4rbAp7lUxC3EW/nDR2V6t9LltE+mvDJxQQ+Bg3saE3UAwn6lsG5O1yQ==", + "dev": true + }, + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, + "accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "requires": { + "mime-types": "~2.1.18", + "negotiator": "0.6.1" + } + }, + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=" + }, + "acorn-globals": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.1.0.tgz", + "integrity": "sha1-/YJw9x+7SZawBPqIDuXUZXOnMb8=", + "requires": { + "acorn": "^4.0.4" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=" + } + } + }, + "after": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", + "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" + }, + "ajv": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.2.tgz", + "integrity": "sha512-hOs7GfvI6tUI1LfZddH82ky6mOMyTuY0mk7kE2pWpmhhUSkumzaTO5vbVwij39MdwPQWCV4Zv57Eo06NtL/GVA==", + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.1" + } + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "requires": { + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "ambi": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ambi/-/ambi-2.5.0.tgz", + "integrity": "sha1-fI43K+SIkRV+fOoBy2+RQ9H3QiA=", + "requires": { + "editions": "^1.1.1", + "typechecker": "^4.3.0" + }, + "dependencies": { + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + }, + "typechecker": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/typechecker/-/typechecker-4.7.0.tgz", + "integrity": "sha512-4LHc1KMNJ6NDGO+dSM/yNfZQRtp8NN7psYrPHUblD62Dvkwsp3VShsbM78kOgpcmMkRTgvwdKOTjctS+uMllgQ==", + "requires": { + "editions": "^2.1.0" + }, + "dependencies": { + "editions": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/editions/-/editions-2.1.3.tgz", + "integrity": "sha512-xDZyVm0A4nLgMNWVVLJvcwMjI80ShiH/27RyLiCnW1L273TcJIA25C4pwJ33AWV01OX6UriP35Xu+lH4S7HWQw==", + "requires": { + "errlop": "^1.1.1", + "semver": "^5.6.0" + } + } + } + } + } + }, + "ansi-align": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", + "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", + "dev": true, + "requires": { + "string-width": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "ansicolors": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/ansicolors/-/ansicolors-0.3.2.tgz", + "integrity": "sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk=" + }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + } + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "arraybuffer.slice": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", + "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==" + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + }, + "async-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", + "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "dev": true + }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "atob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", + "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", + "dev": true + }, + "auto-bind": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-2.0.0.tgz", + "integrity": "sha512-rvRBv0/O7iriUMqSzTDhAfyAD1vVnElAEruo5rMSFeYLA0iKDEzLPSJiwMnL86+IPpTlhfOIAzjoKZ9TaySYdA==" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", + "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" + }, + "axios": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz", + "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", + "requires": { + "follow-redirects": "^1.3.0", + "is-buffer": "^1.1.5" + } + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + } + } + }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==" + }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "base64-arraybuffer": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", + "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" + }, + "base64id": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", + "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "optional": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "better-assert": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", + "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", + "requires": { + "callsite": "1.0.0" + } + }, + "binary-extensions": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", + "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", + "dev": true + }, + "blob": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", + "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=" + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "~1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "~2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "~1.6.16" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + } + } + }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" + }, + "boolean": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/boolean/-/boolean-0.2.0.tgz", + "integrity": "sha512-mDcM3ChboDuhv4glLXEH1us7jMiWXRSs3R13Okoo+kkFOlLIjvF1y88507wTfDf9zsuv0YffSDFUwX95VAT/mg==" + }, + "boom": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-7.3.0.tgz", + "integrity": "sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A==", + "requires": { + "hoek": "6.x.x" + } + }, + "boxen": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", + "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", + "dev": true, + "requires": { + "ansi-align": "^2.0.0", + "camelcase": "^4.0.0", + "chalk": "^2.0.1", + "cli-boxes": "^1.0.0", + "string-width": "^2.0.0", + "term-size": "^1.2.0", + "widest-line": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, + "buffer-writer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", + "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==" + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + }, + "capture-stack-trace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz", + "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", + "dev": true + }, + "cardinal": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/cardinal/-/cardinal-2.1.1.tgz", + "integrity": "sha1-fMEFXYItISlU0HsIXeolHMe8VQU=", + "requires": { + "ansicolors": "~0.3.2", + "redeyed": "~2.1.0" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "requires": { + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "character-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz", + "integrity": "sha1-x84o821LzZdE5f/CxfzeHHMmH8A=", + "requires": { + "is-regex": "^1.0.3" + } + }, + "cheerio": { + "version": "0.22.0", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.22.0.tgz", + "integrity": "sha1-qbqoYKP5tZWmuBsahocxIe06Jp4=", + "requires": { + "css-select": "~1.2.0", + "dom-serializer": "~0.1.0", + "entities": "~1.1.1", + "htmlparser2": "^3.9.1", + "lodash.assignin": "^4.0.9", + "lodash.bind": "^4.1.4", + "lodash.defaults": "^4.0.1", + "lodash.filter": "^4.4.0", + "lodash.flatten": "^4.2.0", + "lodash.foreach": "^4.3.0", + "lodash.map": "^4.4.0", + "lodash.merge": "^4.4.0", + "lodash.pick": "^4.2.1", + "lodash.reduce": "^4.4.0", + "lodash.reject": "^4.4.0", + "lodash.some": "^4.4.0" + } + }, + "chokidar": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", + "integrity": "sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ==", + "dev": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.0", + "braces": "^2.3.0", + "fsevents": "^1.2.2", + "glob-parent": "^3.1.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "lodash.debounce": "^4.0.8", + "normalize-path": "^2.1.1", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0", + "upath": "^1.0.5" + } + }, + "chownr": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", + "optional": true + }, + "ci-info": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.1.3.tgz", + "integrity": "sha512-SK/846h/Rcy8q9Z9CAwGBLfCJ6EkjJWdpelWDufQpqVDYq2Wnnv8zlSO6AMQap02jvhVruKKpEtQOufo3pFhLg==", + "dev": true + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "clean-css": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz", + "integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==", + "requires": { + "source-map": "~0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + } + } + }, + "cli-boxes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", + "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=", + "dev": true + }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "cls-bluebird": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cls-bluebird/-/cls-bluebird-2.1.0.tgz", + "integrity": "sha1-N+8eCAqP+1XC9BZPU28ZGeeWiu4=", + "requires": { + "is-bluebird": "^1.0.2", + "shimmer": "^1.1.0" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", + "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", + "dev": true, + "requires": { + "color-name": "1.1.1" + } + }, + "color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=", + "dev": true + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==" + }, + "component-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=" + }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "component-inherit": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", + "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "configstore": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz", + "integrity": "sha512-vtv5HtGjcYUgFrXc6Kx747B83MRRVS5R1VTEQoXvuP+kMI+if6uywV0nDGoiydJRy4yk7h9od5Og0kxx4zUXmw==", + "dev": true, + "requires": { + "dot-prop": "^4.1.0", + "graceful-fs": "^4.1.2", + "make-dir": "^1.0.0", + "unique-string": "^1.0.0", + "write-file-atomic": "^2.0.0", + "xdg-basedir": "^3.0.0" + } + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "consolidate": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/consolidate/-/consolidate-0.15.1.tgz", + "integrity": "sha512-DW46nrsMJgy9kqAbPt5rKaCr7uFtpo4mSUvLHIUbJEjm0vo+aY5QLwBUq3FK4tRnJr/X0Psc0C4jf/h+HtXSMw==", + "requires": { + "bluebird": "^3.1.1" + } + }, + "constantinople": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.1.2.tgz", + "integrity": "sha512-yePcBqEFhLOqSBtwYOGGS1exHo/s1xjekXiinh4itpNQGCu4KA1euPh1fg07N2wMITZXQkBz75Ntdt1ctGZouw==", + "requires": { + "@types/babel-types": "^7.0.0", + "@types/babylon": "^6.16.2", + "babel-types": "^6.26.0", + "babylon": "^6.18.0" + } + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, + "core-js": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", + "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "country-language": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/country-language/-/country-language-0.1.7.tgz", + "integrity": "sha1-eHD0uhJduaYHHxlze9nvk0OuNds=", + "requires": { + "underscore": "~1.7.0", + "underscore.deep": "~0.5.1" + } + }, + "create-error-class": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", + "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", + "dev": true, + "requires": { + "capture-stack-trace": "^1.0.0" + } + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "crypto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", + "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==" + }, + "crypto-random-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", + "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=", + "dev": true + }, + "csextends": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/csextends/-/csextends-1.2.0.tgz", + "integrity": "sha512-S/8k1bDTJIwuGgQYmsRoE+8P+ohV32WhQ0l4zqrc0XDdxOhjQQD7/wTZwCzoZX53jSX3V/qwjT+OkPTxWQcmjg==" + }, + "css-select": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", + "requires": { + "boolbase": "~1.0.0", + "css-what": "2.1", + "domutils": "1.5.1", + "nth-check": "~1.0.1" + }, + "dependencies": { + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + } + } + }, + "css-what": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", + "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==" + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "datauri": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/datauri/-/datauri-1.1.0.tgz", + "integrity": "sha512-0q+cTTKx7q8eDteZRIQLTFJuiIsVing17UbWTPssY4JLSMaYsk/VKpNulBDo9NSgQWcvlPrkEHW8kUO67T/7mQ==", + "requires": { + "image-size": "^0.6.2", + "mimer": "^0.3.2", + "semver": "^5.5.0" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "decamelize": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-2.0.0.tgz", + "integrity": "sha512-Ikpp5scV3MSYxY39ymh45ZLEecsTdv/Xj2CaQfI8RLMuwi7XvjX9H/fhraiSuU+C5w5NTDu4ZU72xNiZnurBPg==", + "dev": true, + "requires": { + "xregexp": "4.0.0" + } + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "optional": true + }, + "denque": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.3.0.tgz", + "integrity": "sha512-4SRaSj+PqmrS1soW5/Avd7eJIM2JJIqLLmwhRqIGleZM/8KwZq80njbSS2Iqas+6oARkSkLDHEk4mm78q3JlIg==" + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "optional": true + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "doctrine": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz", + "integrity": "sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=", + "dev": true, + "requires": { + "esutils": "^1.1.6", + "isarray": "0.0.1" + }, + "dependencies": { + "esutils": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz", + "integrity": "sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + } + } + }, + "doctypes": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz", + "integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk=" + }, + "dom-serializer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", + "requires": { + "domelementtype": "^1.3.0", + "entities": "^1.1.1" + } + }, + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" + }, + "domhandler": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", + "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", + "requires": { + "domelementtype": "1" + } + }, + "domutils": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz", + "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==", + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "dot-prop": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", + "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", + "dev": true, + "requires": { + "is-obj": "^1.0.0" + } + }, + "dottie": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.0.tgz", + "integrity": "sha1-2hkZgci41xPKARXViYzzl8Lw3dA=" + }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true + }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", + "dev": true + }, + "eachr": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/eachr/-/eachr-2.0.4.tgz", + "integrity": "sha1-Rm98qhBwj2EFCeMsgHqv5X/BIr8=", + "requires": { + "typechecker": "^2.0.8" + } + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "optional": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "ecdsa-sig-formatter": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz", + "integrity": "sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "editions": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/editions/-/editions-1.3.4.tgz", + "integrity": "sha512-gzao+mxnYDzIysXKMQi/+M1mjy/rjestjg6OPoYTtI+3Izp23oiGZitsl9lPDPiTGXbcSIk1iJWhliSaglxnUg==" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "ejs": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.6.1.tgz", + "integrity": "sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ==" + }, + "email-templates": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/email-templates/-/email-templates-5.0.4.tgz", + "integrity": "sha512-9g2I2HdY8nHSRInRfMLehUESCrrWiVwkezf8+2kHF+MeJPdVWby6UdWuLi34D1s3qLqNRu//aMSbIcChE9D/hA==", + "requires": { + "@ladjs/i18n": "^1.1.0", + "auto-bind": "^2.0.0", + "bluebird": "^3.5.3", + "consolidate": "^0.15.1", + "debug": "^4.1.1", + "get-paths": "^0.0.4", + "html-to-text": "^4.0.0", + "juice": "^5.1.0", + "lodash": "^4.17.11", + "nodemailer": "^5.1.1", + "preview-email": "^0.0.10", + "underscore.string": "^3.3.5" + }, + "dependencies": { + "bluebird": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", + "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==" + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "engine.io": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.2.0.tgz", + "integrity": "sha512-mRbgmAtQ4GAlKwuPnnAvXXwdPhEx+jkc0OBCLrXuD/CRvwNK3AxRSnqK4FSqmAMRRHryVJP8TopOvmEaA64fKw==", + "requires": { + "accepts": "~1.3.4", + "base64id": "1.0.0", + "cookie": "0.3.1", + "debug": "~3.1.0", + "engine.io-parser": "~2.1.0", + "ws": "~3.3.1" + } + }, + "engine.io-client": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.2.1.tgz", + "integrity": "sha512-y5AbkytWeM4jQr7m/koQLc5AxpRKC1hEVUb/s1FUAWEJq5AzJJ4NLvzuKPuxtDi5Mq755WuDvZ6Iv2rXj4PTzw==", + "requires": { + "component-emitter": "1.2.1", + "component-inherit": "0.0.3", + "debug": "~3.1.0", + "engine.io-parser": "~2.1.1", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "ws": "~3.3.1", + "xmlhttprequest-ssl": "~1.5.4", + "yeast": "0.1.2" + } + }, + "engine.io-parser": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.2.tgz", + "integrity": "sha512-dInLFzr80RijZ1rGpx1+56/uFoH7/7InhH3kZt+Ms6hT8tNx3NGW/WNSA/f8As1WkOfkuyb3tnRyuXGxusclMw==", + "requires": { + "after": "0.8.2", + "arraybuffer.slice": "~0.0.7", + "base64-arraybuffer": "0.1.5", + "blob": "0.0.4", + "has-binary2": "~1.0.2" + } + }, + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" + }, + "errlop": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/errlop/-/errlop-1.1.1.tgz", + "integrity": "sha512-WX7QjiPHhsny7/PQvrhS5VMizXXKoKCS3udaBp8gjlARdbn+XmK300eKBAAN0hGyRaTCtRpOaxK+xFVPUJ3zkw==", + "requires": { + "editions": "^2.1.2" + }, + "dependencies": { + "editions": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/editions/-/editions-2.1.3.tgz", + "integrity": "sha512-xDZyVm0A4nLgMNWVVLJvcwMjI80ShiH/27RyLiCnW1L273TcJIA25C4pwJ33AWV01OX6UriP35Xu+lH4S7HWQw==", + "requires": { + "errlop": "^1.1.1", + "semver": "^5.6.0" + } + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + } + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "event-stream": { + "version": "3.3.4", + "resolved": "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "dev": true, + "requires": { + "duplexer": "~0.1.1", + "from": "~0", + "map-stream": "~0.1.0", + "pause-stream": "0.0.11", + "split": "0.3", + "stream-combiner": "~0.0.4", + "through": "~2.3.1" + } + }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "dev": true, + "requires": { + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "expand-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/expand-string/-/expand-string-1.1.1.tgz", + "integrity": "sha1-fBHCis10tezZkluPKezSeT+HFU4=", + "requires": { + "lodash.defaults": "^4.0.1" + } + }, + "express": { + "version": "4.16.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", + "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "requires": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.3", + "qs": "6.5.1", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.1", + "http-errors": "~1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "~2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "~1.6.15" + }, + "dependencies": { + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + } + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": ">= 1.3.1 < 2" + } + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "extendr": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/extendr/-/extendr-2.1.0.tgz", + "integrity": "sha1-MBqgu+pWX00tyPVw8qImEahSe1Y=", + "requires": { + "typechecker": "~2.0.1" + }, + "dependencies": { + "typechecker": { + "version": "2.0.8", + "resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz", + "integrity": "sha1-6D2oS7ZMWEzLNFg4V2xAsDN9uC4=" + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "extract-opts": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/extract-opts/-/extract-opts-2.2.0.tgz", + "integrity": "sha1-H6KOunNSxttID4hc63GkaBC+bX0=", + "requires": { + "typechecker": "~2.0.1" + }, + "dependencies": { + "typechecker": { + "version": "2.0.8", + "resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz", + "integrity": "sha1-6D2oS7ZMWEzLNFg4V2xAsDN9uC4=" + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "follow-redirects": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.2.tgz", + "integrity": "sha512-kssLorP/9acIdpQ2udQVTiCS5LQmdEz9mvdIfDcl1gYX2tPKFADHSyFdvJS040XdFsPzemWtgI3q8mFVCxtX8A==", + "requires": { + "debug": "^3.1.0" + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "^0.2.2" + } + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "from": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", + "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", + "dev": true + }, + "fs-extra": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs-minipass": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", + "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fsevents": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz", + "integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==", + "dev": true, + "optional": true, + "requires": { + "nan": "^2.9.2", + "node-pre-gyp": "^0.10.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.21", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safer-buffer": "^2.1.0" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.5", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "minipass": { + "version": "2.2.4", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "^5.1.1", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "needle": { + "version": "2.2.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.10.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.0", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.1.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.1.10", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "^0.5.1", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "glob": "^7.0.5" + } + }, + "safe-buffer": { + "version": "5.1.1", + "bundled": true, + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "dev": true, + "optional": true + }, + "semver": { + "version": "5.5.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "4.4.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "chownr": "^1.0.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.2.4", + "minizlib": "^1.1.0", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.1", + "yallist": "^3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "yallist": { + "version": "3.0.2", + "bundled": true, + "dev": true + } + } + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "gcp-metadata": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-0.6.3.tgz", + "integrity": "sha512-MSmczZctbz91AxCvqp9GHBoZOSbJKAICV7Ow/AIWSJZRrRchUd5NL1b2P4OfP+4m490BEUPhhARfpHdqCxuCvg==", + "requires": { + "axios": "^0.18.0", + "extend": "^3.0.1", + "retry-axios": "0.3.2" + } + }, + "generate-function": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", + "integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==", + "requires": { + "is-property": "^1.0.2" + } + }, + "generic-pool": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.4.2.tgz", + "integrity": "sha512-H7cUpwCQSiJmAHM4c/aFu6fUfrhWXW1ncyh8ftxEPMu6AiYkHw9K8br720TGPZJbk5eOH2bynjZD1yPvdDAmag==" + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "get-paths": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/get-paths/-/get-paths-0.0.4.tgz", + "integrity": "sha512-+AxlfMGN7FuJr2zhT6aErH08HMKkRwynTTHtWCenIWkIZgx2OlkZKgt7SM4+rh8Dfi32lo6HcvqeTLxph3kjQw==", + "requires": { + "bluebird": "^3.5.1", + "fs-extra": "^4.0.2" + } + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", + "dev": true + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "dev": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "global-dirs": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", + "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", + "dev": true, + "requires": { + "ini": "^1.3.4" + } + }, + "google-auth-library": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-1.6.1.tgz", + "integrity": "sha512-jYiWC8NA9n9OtQM7ANn0Tk464do9yhKEtaJ72pKcaBiEwn4LwcGYIYOfwtfsSm3aur/ed3tlSxbmg24IAT6gAg==", + "requires": { + "axios": "^0.18.0", + "gcp-metadata": "^0.6.3", + "gtoken": "^2.3.0", + "jws": "^3.1.5", + "lodash.isstring": "^4.0.1", + "lru-cache": "^4.1.3", + "retry-axios": "^0.3.2" + } + }, + "google-p12-pem": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-1.0.2.tgz", + "integrity": "sha512-+EuKr4CLlGsnXx4XIJIVkcKYrsa2xkAmCvxRhX2HsazJzUBAJ35wARGeApHUn4nNfPD03Vl057FskNr20VaCyg==", + "requires": { + "node-forge": "^0.7.4", + "pify": "^3.0.0" + } + }, + "got": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", + "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", + "dev": true, + "requires": { + "create-error-class": "^3.0.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "is-redirect": "^1.0.0", + "is-retry-allowed": "^1.0.0", + "is-stream": "^1.0.0", + "lowercase-keys": "^1.0.0", + "safe-buffer": "^5.0.1", + "timed-out": "^4.0.0", + "unzip-response": "^2.0.1", + "url-parse-lax": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "gtoken": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-2.3.0.tgz", + "integrity": "sha512-Jc9/8mV630cZE9FC5tIlJCZNdUjwunvlwOtCz6IDlaiB4Sz68ki29a1+q97sWTnTYroiuF9B135rod9zrQdHLw==", + "requires": { + "axios": "^0.18.0", + "google-p12-pem": "^1.0.0", + "jws": "^3.1.4", + "mime": "^2.2.0", + "pify": "^3.0.0" + }, + "dependencies": { + "mime": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.3.1.tgz", + "integrity": "sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg==" + } + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", + "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "requires": { + "ajv": "^5.1.0", + "har-schema": "^2.0.0" + }, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + } + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-binary2": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", + "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", + "requires": { + "isarray": "2.0.1" + }, + "dependencies": { + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" + } + } + }, + "has-cors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", + "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "optional": true + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" + }, + "hoek": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.2.tgz", + "integrity": "sha512-6qhh/wahGYZHFSFw12tBbJw5fsAhhwrrG/y3Cs0YMTv2WzMnL0oLPnQJjv1QJvEfylRSOFuP+xCu+tdx0tD16Q==" + }, + "html-to-text": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-4.0.0.tgz", + "integrity": "sha512-QQl5EEd97h6+3crtgBhkEAO6sQnZyDff8DAeJzoSkOc1Dqe1UvTUZER0B+KjBe6fPZqq549l2VUhtracus3ndA==", + "requires": { + "he": "^1.0.0", + "htmlparser2": "^3.9.2", + "lodash": "^4.17.4", + "optimist": "^0.6.1" + } + }, + "htmlparser2": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", + "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", + "requires": { + "domelementtype": "^1.3.1", + "domhandler": "^2.3.0", + "domutils": "^1.5.1", + "entities": "^1.1.1", + "inherits": "^2.0.1", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.1.1.tgz", + "integrity": "sha512-DkN66hPyqDhnIQ6Jcsvx9bFjhw214O4poMBcIMgPVpQvNy9a0e0Uhg5SqySyDKAmUlwt8LonTBz1ezOnM8pUdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, + "http-errors": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.0.tgz", + "integrity": "sha512-hz3BtSHB7Z6dNWzYc+gUbWqG4dIpJedwwOhe1cvGUq5tGmcTTIRkPiAbyh/JlZx+ksSJyGJlgcHo5jGahiXnKw==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + }, + "dependencies": { + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + } + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "i18n": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/i18n/-/i18n-0.8.3.tgz", + "integrity": "sha1-LYzxwkciYCwgQdAbpq5eqlE4jw4=", + "requires": { + "debug": "*", + "make-plural": "^3.0.3", + "math-interval-parser": "^1.1.0", + "messageformat": "^0.3.1", + "mustache": "*", + "sprintf-js": ">=1.0.3" + } + }, + "i18n-locales": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/i18n-locales/-/i18n-locales-0.0.2.tgz", + "integrity": "sha512-WCaJVIfU10v0/ZNy+mG7fCUQb1o2PsM7tNf1dUg0uU9OxtygDkWRqLT9Q/X30V2XsUb6XUEPbSsdUiORfDPVQA==" + }, + "iab_verifier": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/iab_verifier/-/iab_verifier-0.1.2.tgz", + "integrity": "sha1-2t5VDuOJu96FaLL0ynHV0RFQCV4=", + "requires": { + "crypto": "*" + } + }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=", + "dev": true + }, + "ignore-walk": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "ignorefs": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ignorefs/-/ignorefs-1.2.0.tgz", + "integrity": "sha1-2ln7hYl25KXkNwLM0fKC/byeV1Y=", + "requires": { + "editions": "^1.3.3", + "ignorepatterns": "^1.1.0" + } + }, + "ignorepatterns": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ignorepatterns/-/ignorepatterns-1.1.0.tgz", + "integrity": "sha1-rI9DbyI5td+2bV8NOpBKh6xnzF4=" + }, + "image-size": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.6.3.tgz", + "integrity": "sha512-47xSUiQioGaB96nqtp5/q55m0aBQSQdyIloMOc/x+QVTDZLNmXE892IIDrJ0hM1A5vcNUDD5tDffkSP5lCaIIA==" + }, + "import-lazy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", + "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" + }, + "inflection": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.12.0.tgz", + "integrity": "sha1-ogCTVlbW9fa8TcdQLhrstwMihBY=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "dev": true + }, + "ipaddr.js": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", + "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "is-bluebird": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-bluebird/-/is-bluebird-1.0.2.tgz", + "integrity": "sha1-CWQ5Bg9KpBGr7hkUOoTWpVNG1uI=" + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "is-ci": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.1.0.tgz", + "integrity": "sha512-c7TnwxLePuqIlxHgr7xtxzycJPegNHFuIrBkwbf8hc58//+Op1CqFkyS+xnIMkwn9UsJIwc174BIjkyBmSpjKg==", + "dev": true, + "requires": { + "ci-info": "^1.0.0" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-expression": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-3.0.0.tgz", + "integrity": "sha1-Oayqa+f9HzRx3ELHQW5hwkMXrJ8=", + "requires": { + "acorn": "~4.0.2", + "object-assign": "^4.0.1" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=" + } + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-glob": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", + "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-installed-globally": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", + "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", + "dev": true, + "requires": { + "global-dirs": "^0.1.0", + "is-path-inside": "^1.0.0" + } + }, + "is-npm": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", + "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", + "dev": true + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", + "dev": true + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "dev": true, + "requires": { + "path-is-inside": "^1.0.1" + } + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" + }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=" + }, + "is-redirect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", + "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "requires": { + "has": "^1.0.1" + } + }, + "is-retry-allowed": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", + "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "js-stringify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", + "integrity": "sha1-Fzb939lyTyijaCrcYjCufk6Weds=" + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "jstransformer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-1.0.0.tgz", + "integrity": "sha1-7Yvwkh4vPx7U1cGkT2hwntJHIsM=", + "requires": { + "is-promise": "^2.0.0", + "promise": "^7.0.1" + } + }, + "juice": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/juice/-/juice-5.1.0.tgz", + "integrity": "sha512-SRfLv0y7xwAKnsd6HWS9aSF0+a9ozXEatKlXHiiTvozdZu0Vwz9dDk7NEpy/N2icFTnhYtk1Du3rPNtH7fFVHw==", + "requires": { + "cheerio": "^0.22.0", + "commander": "^2.15.1", + "cross-spawn": "^6.0.5", + "deep-extend": "^0.6.0", + "mensch": "^0.3.3", + "slick": "^1.12.2", + "web-resource-inliner": "^4.2.1" + }, + "dependencies": { + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + } + } + }, + "jwa": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.1.6.tgz", + "integrity": "sha512-tBO/cf++BUsJkYql/kBbJroKOgHWEigTKBAjjBEmrMGYd1QMBC74Hr4Wo2zCZw6ZrVhlJPvoMrkcOnlWR/DJfw==", + "requires": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.10", + "safe-buffer": "^5.0.1" + } + }, + "jws": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.1.5.tgz", + "integrity": "sha512-GsCSexFADNQUr8T5HPJvayTjvPIfoyJPtLQBwn5a4WZQchcrPMPMAWcC1AzJVRDKyD6ZPROPAxgv6rfHViO4uQ==", + "requires": { + "jwa": "^1.1.5", + "safe-buffer": "^5.0.1" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "latest-version": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", + "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", + "dev": true, + "requires": { + "package-json": "^4.0.0" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=" + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "lodash.assignin": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz", + "integrity": "sha1-uo31+4QesKPoBEIysOJjqNxqKKI=" + }, + "lodash.bind": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/lodash.bind/-/lodash.bind-4.2.1.tgz", + "integrity": "sha1-euMBfpOWIqwxt9fX3LGzTbFpDTU=" + }, + "lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", + "dev": true + }, + "lodash.defaults": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" + }, + "lodash.filter": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.filter/-/lodash.filter-4.6.0.tgz", + "integrity": "sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4=" + }, + "lodash.flatten": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", + "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" + }, + "lodash.foreach": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz", + "integrity": "sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM=" + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" + }, + "lodash.map": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz", + "integrity": "sha1-dx7Hg540c9nEzeKLGTlMNWL09tM=" + }, + "lodash.merge": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", + "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==" + }, + "lodash.pick": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", + "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=" + }, + "lodash.reduce": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", + "integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs=" + }, + "lodash.reject": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.reject/-/lodash.reject-4.6.0.tgz", + "integrity": "sha1-gNZJLcFHCGS79YNTO2UfQqn1JBU=" + }, + "lodash.some": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz", + "integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0=" + }, + "lodash.unescape": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz", + "integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=" + }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=" + }, + "lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", + "dev": true + }, + "lru-cache": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", + "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + }, + "dependencies": { + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + } + } + }, + "make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "dev": true, + "requires": { + "pify": "^3.0.0" + } + }, + "make-plural": { + "version": "3.0.6", + "resolved": "http://registry.npmjs.org/make-plural/-/make-plural-3.0.6.tgz", + "integrity": "sha1-IDOgO6wpC487uRJY9lud9+iwHKc=", + "requires": { + "minimist": "^1.2.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "optional": true + } + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "math-interval-parser": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-interval-parser/-/math-interval-parser-1.1.0.tgz", + "integrity": "sha1-2+2lsGsySZc8bfYXD94jhvCv2JM=", + "requires": { + "xregexp": "^2.0.0" + }, + "dependencies": { + "xregexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", + "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=" + } + } + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "mem": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", + "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "mensch": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/mensch/-/mensch-0.3.3.tgz", + "integrity": "sha1-4gD/TdgjcX+OBWOzLj9UgfyiYrI=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "messageformat": { + "version": "0.3.1", + "resolved": "http://registry.npmjs.org/messageformat/-/messageformat-0.3.1.tgz", + "integrity": "sha1-5Y//gkXps5cXmeW0PbWLPpQX9aI=", + "requires": { + "async": "~1.5.2", + "glob": "~6.0.4", + "make-plural": "~3.0.3", + "nopt": "~3.0.6", + "watchr": "~2.4.13" + }, + "dependencies": { + "glob": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", + "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", + "requires": { + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "requires": { + "abbrev": "1" + } + } + } + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.35.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", + "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" + }, + "mime-types": { + "version": "2.1.19", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", + "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", + "requires": { + "mime-db": "~1.35.0" + } + }, + "mimer": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/mimer/-/mimer-0.3.2.tgz", + "integrity": "sha512-N6NcgDQAevhP/02DQ/epK6daLy4NKrIHyTlJcO6qBiYn98q+Y4a/knNsAATCe1xLS2F0nEmJp+QYli2s8vKwyQ==" + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mixin-deep": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", + "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "moment": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" + }, + "moment-timezone": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.21.tgz", + "integrity": "sha512-j96bAh4otsgj3lKydm3K7kdtA3iKf2m6MY2iSYCzCm5a1zmHo1g+aK3068dDEeocLZQIS9kU8bsdQHLqEvgW0A==", + "requires": { + "moment": ">= 2.9.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mustache": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-3.0.1.tgz", + "integrity": "sha512-jFI/4UVRsRYdUbuDTKT7KzfOp7FiD5WzYmmwNwXyUVypC0xjoTL78Fqc0jHUPIvvGD+6DQSPHIt1NE7D1ArsqA==" + }, + "mysql2": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-1.6.1.tgz", + "integrity": "sha512-BNrJH5HavPqskXEy8oVz7ucRbkhegKQ7VD8rNGFwvTuk0WiUSi1wXFOg67NjCGquZnim8nKgHdDiih6LqG5knA==", + "requires": { + "cardinal": "2.1.1", + "denque": "1.3.0", + "generate-function": "^2.0.0", + "iconv-lite": "^0.4.18", + "long": "^4.0.0", + "lru-cache": "4.1.1", + "named-placeholders": "1.1.1", + "object-assign": "^4.1.1", + "seq-queue": "0.0.5", + "sqlstring": "2.3.1" + }, + "dependencies": { + "lru-cache": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", + "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + } + } + }, + "named-placeholders": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.1.tgz", + "integrity": "sha1-O3oNJiA910s6nfTJz7gnsvuQfmQ=", + "requires": { + "lru-cache": "2.5.0" + }, + "dependencies": { + "lru-cache": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz", + "integrity": "sha1-2COIrpyWC+y+oMc7uet5tsbOmus=" + } + } + }, + "nan": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", + "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", + "optional": true + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "needle": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", + "integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", + "optional": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "optional": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" + }, + "node-forge": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.5.tgz", + "integrity": "sha512-MmbQJ2MTESTjt3Gi/3yG1wGpIMhUfcIypUCGtTizFR9IiccFwxSpfp0vtIZlkFclEqERemxfnSdZEMR9VqqEFQ==" + }, + "node-pre-gyp": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", + "integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==", + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nodemailer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-5.1.1.tgz", + "integrity": "sha512-hKGCoeNdFL2W7S76J/Oucbw0/qRlfG815tENdhzcqTpSjKgAN91mFOqU2lQUflRRxFM7iZvCyaFcAR9noc/CqQ==" + }, + "nodemon": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.18.3.tgz", + "integrity": "sha512-XdVfAjGlDKU2nqoGgycxTndkJ5fdwvWJ/tlMGk2vHxMZBrSPVh86OM6z7viAv8BBJWjMgeuYQBofzr6LUoi+7g==", + "dev": true, + "requires": { + "chokidar": "^2.0.2", + "debug": "^3.1.0", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.0.4", + "pstree.remy": "^1.1.0", + "semver": "^5.5.0", + "supports-color": "^5.2.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.2", + "update-notifier": "^2.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + }, + "npm-bundled": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", + "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", + "optional": true + }, + "npm-packlist": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", + "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "nth-check": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", + "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", + "requires": { + "boolbase": "~1.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "object-component": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", + "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=" + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "opn": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-5.4.0.tgz", + "integrity": "sha512-YF9MNdVy/0qvJvDtunAOzFw9iasOQHpVthTCvGzxt61Il64AYSGdK+rYwld7NAfk9qJ7dt+hymBNSc9LNYS+Sw==", + "requires": { + "is-wsl": "^1.1.0" + } + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "optional": true + }, + "os-locale": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "dev": true, + "requires": { + "execa": "^0.7.0", + "lcid": "^1.0.0", + "mem": "^1.1.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "optional": true + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-limit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", + "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", + "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", + "dev": true + }, + "package-json": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", + "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", + "dev": true, + "requires": { + "got": "^6.7.1", + "registry-auth-token": "^3.0.1", + "registry-url": "^3.0.3", + "semver": "^5.1.0" + } + }, + "packet-reader": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-0.3.1.tgz", + "integrity": "sha1-zWLmCvjX/qinBexP+ZCHHEaHHyc=" + }, + "parseqs": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", + "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", + "requires": { + "better-assert": "~1.0.0" + } + }, + "parseuri": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", + "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", + "requires": { + "better-assert": "~1.0.0" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "pause-stream": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "dev": true, + "requires": { + "through": "~2.3" + } + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "pg": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-7.8.0.tgz", + "integrity": "sha512-yS3C9YD+ft0H7G47uU0eKajgTieggCXdA+Fxhm5G+wionY6kPBa8BEVDwPLMxQvkRkv3/LXiFEqjZm9gfxdW+g==", + "requires": { + "buffer-writer": "2.0.0", + "packet-reader": "0.3.1", + "pg-connection-string": "0.1.3", + "pg-pool": "^2.0.4", + "pg-types": "~2.0.0", + "pgpass": "1.x", + "semver": "4.3.2" + }, + "dependencies": { + "semver": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.2.tgz", + "integrity": "sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c=" + } + } + }, + "pg-connection-string": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz", + "integrity": "sha1-2hhHsglA5C7hSSvq9l1J2RskXfc=" + }, + "pg-hstore": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/pg-hstore/-/pg-hstore-2.3.2.tgz", + "integrity": "sha1-9+8FPnubiSrphq8vfL6GQy388k8=", + "requires": { + "underscore": "^1.7.0" + } + }, + "pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==" + }, + "pg-pool": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-2.0.6.tgz", + "integrity": "sha512-hod2zYQxM8Gt482q+qONGTYcg/qVcV32VHVPtktbBJs0us3Dj7xibISw0BAAXVMCzt8A/jhfJvpZaxUlqtqs0g==" + }, + "pg-types": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.0.0.tgz", + "integrity": "sha512-THUD7gQll5tys+5eQ8Rvs7DjHiIC3bLqixk3gMN9Hu8UrCBAOjf35FoI39rTGGc3lM2HU/R+Knpxvd11mCwOMA==", + "requires": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.0", + "postgres-interval": "^1.1.0" + } + }, + "pgpass": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.2.tgz", + "integrity": "sha1-Knu0G2BltnkH6R2hsHwYR8h3swY=", + "requires": { + "split": "^1.0.0" + }, + "dependencies": { + "split": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", + "requires": { + "through": "2" + } + } + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==" + }, + "postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" + }, + "postgres-date": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.3.tgz", + "integrity": "sha1-4tiXAu/bJY/52c7g/pG9BpdSV6g=" + }, + "postgres-interval": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.1.2.tgz", + "integrity": "sha512-fC3xNHeTskCxL1dC8KOtxXt7YeFmlbTYtn7ul8MkVERuTmf7pI4DrkAxcw3kh1fQ9uz4wQmd03a1mRiXUZChfQ==", + "requires": { + "xtend": "^4.0.0" + } + }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", + "dev": true + }, + "preview-email": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/preview-email/-/preview-email-0.0.10.tgz", + "integrity": "sha512-qv0+3/VjlqsewDi2gQSoVcpxTrYNezoFKbkVin2fqe8qGF/Bl5aa76LhVOzYQowXgchBhDibotnMqT8UtwDVfw==", + "requires": { + "bluebird": "^3.5.3", + "moment": "^2.23.0", + "nodemailer": "^5.1.1", + "opn": "^5.4.0", + "pug": "^2.0.3", + "uuid": "^3.3.2" + }, + "dependencies": { + "bluebird": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", + "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==" + }, + "moment": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + } + } + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "~2.0.3" + } + }, + "proxy-addr": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", + "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.8.0" + } + }, + "ps-tree": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-1.1.0.tgz", + "integrity": "sha1-tCGyQUDWID8e08dplrRCewjowBQ=", + "dev": true, + "requires": { + "event-stream": "~3.3.0" + } + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "pstree.remy": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.0.tgz", + "integrity": "sha512-q5I5vLRMVtdWa8n/3UEzZX7Lfghzrg9eG2IKk2ENLSofKRCXVqMvMUHxCKgXNaqH/8ebhBxrqftHWnyTFweJ5Q==", + "dev": true, + "requires": { + "ps-tree": "^1.1.0" + } + }, + "pug": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pug/-/pug-2.0.3.tgz", + "integrity": "sha1-ccuoJTfJWl6rftBGluQiH1Oqh44=", + "requires": { + "pug-code-gen": "^2.0.1", + "pug-filters": "^3.1.0", + "pug-lexer": "^4.0.0", + "pug-linker": "^3.0.5", + "pug-load": "^2.0.11", + "pug-parser": "^5.0.0", + "pug-runtime": "^2.0.4", + "pug-strip-comments": "^1.0.3" + } + }, + "pug-attrs": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pug-attrs/-/pug-attrs-2.0.3.tgz", + "integrity": "sha1-owlflw5kFR972tlX7vVftdeQXRU=", + "requires": { + "constantinople": "^3.0.1", + "js-stringify": "^1.0.1", + "pug-runtime": "^2.0.4" + } + }, + "pug-code-gen": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-2.0.1.tgz", + "integrity": "sha1-CVHsgyJddNjPxHan+Zolm199BQw=", + "requires": { + "constantinople": "^3.0.1", + "doctypes": "^1.1.0", + "js-stringify": "^1.0.1", + "pug-attrs": "^2.0.3", + "pug-error": "^1.3.2", + "pug-runtime": "^2.0.4", + "void-elements": "^2.0.1", + "with": "^5.0.0" + } + }, + "pug-error": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-1.3.2.tgz", + "integrity": "sha1-U659nSm7A89WRJOgJhCfVMR/XyY=" + }, + "pug-filters": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/pug-filters/-/pug-filters-3.1.0.tgz", + "integrity": "sha1-JxZVVbwEwjbkqisDZiRt+gIbYm4=", + "requires": { + "clean-css": "^4.1.11", + "constantinople": "^3.0.1", + "jstransformer": "1.0.0", + "pug-error": "^1.3.2", + "pug-walk": "^1.1.7", + "resolve": "^1.1.6", + "uglify-js": "^2.6.1" + } + }, + "pug-lexer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-4.0.0.tgz", + "integrity": "sha1-IQwYRX7y4XYCQnQMXmR715TOwng=", + "requires": { + "character-parser": "^2.1.1", + "is-expression": "^3.0.0", + "pug-error": "^1.3.2" + } + }, + "pug-linker": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/pug-linker/-/pug-linker-3.0.5.tgz", + "integrity": "sha1-npp65ABWgtAn3uuWsAD4juuDoC8=", + "requires": { + "pug-error": "^1.3.2", + "pug-walk": "^1.1.7" + } + }, + "pug-load": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/pug-load/-/pug-load-2.0.11.tgz", + "integrity": "sha1-5kjlftET/iwfRdV4WOorrWvAFSc=", + "requires": { + "object-assign": "^4.1.0", + "pug-walk": "^1.1.7" + } + }, + "pug-parser": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-5.0.0.tgz", + "integrity": "sha1-45Stmz/KkxI5QK/4hcBuRKt+aOQ=", + "requires": { + "pug-error": "^1.3.2", + "token-stream": "0.0.1" + } + }, + "pug-runtime": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pug-runtime/-/pug-runtime-2.0.4.tgz", + "integrity": "sha1-4XjhvaaKsujArPybztLFT9iM61g=" + }, + "pug-strip-comments": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pug-strip-comments/-/pug-strip-comments-1.0.3.tgz", + "integrity": "sha1-8VWVkiBu3G+FMQ2s9K+0igJa9Z8=", + "requires": { + "pug-error": "^1.3.2" + } + }, + "pug-walk": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/pug-walk/-/pug-walk-1.1.7.tgz", + "integrity": "sha1-wA1cUSi6xYBr7BXSt+fNq+QlMfM=" + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "rate-limiter-flexible": { + "version": "0.21.2", + "resolved": "https://registry.npmjs.org/rate-limiter-flexible/-/rate-limiter-flexible-0.21.2.tgz", + "integrity": "sha512-HlAD3B/8eeN+bILGuvkUJaBNM318S+08xdk8iGCeqWAaB3P5zgpUUZTIGQLJO72uH2lr6lZNyeUAIkoHxJR5Wg==" + }, + "raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + }, + "dependencies": { + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + } + } + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "readdirp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", + "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "minimatch": "^3.0.2", + "readable-stream": "^2.0.2", + "set-immediate-shim": "^1.0.1" + } + }, + "redeyed": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/redeyed/-/redeyed-2.1.1.tgz", + "integrity": "sha1-iYS1gV2ZyyIEacme7v/jiRPmzAs=", + "requires": { + "esprima": "~4.0.0" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "registry-auth-token": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz", + "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==", + "dev": true, + "requires": { + "rc": "^1.1.6", + "safe-buffer": "^5.0.1" + } + }, + "registry-url": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", + "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", + "dev": true, + "requires": { + "rc": "^1.0.1" + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "repeat-element": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" + }, + "request": { + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", + "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "resolve": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", + "requires": { + "path-parse": "^1.0.5" + } + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, + "retry-as-promised": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-2.3.2.tgz", + "integrity": "sha1-zZdO5P2bX+A8vzGHHuSCIcB3N7c=", + "requires": { + "bluebird": "^3.4.6", + "debug": "^2.6.9" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "retry-axios": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/retry-axios/-/retry-axios-0.3.2.tgz", + "integrity": "sha512-jp4YlI0qyDFfXiXGhkCOliBN1G7fRH03Nqy8YdShzGqbY5/9S2x/IR6C88ls2DFkbWuL3ASkP7QD3pVrNpPgwQ==" + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "requires": { + "align-text": "^0.1.1" + } + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "optional": true, + "requires": { + "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "optional": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safefs": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/safefs/-/safefs-3.2.2.tgz", + "integrity": "sha1-gXDBRE1wOOCMrqBaN0+uL6NJ4Vw=", + "requires": { + "graceful-fs": "*" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "optional": true + }, + "scandirectory": { + "version": "2.5.0", + "resolved": "http://registry.npmjs.org/scandirectory/-/scandirectory-2.5.0.tgz", + "integrity": "sha1-bOA/VKCQtmjjy+2/IO354xBZPnI=", + "requires": { + "ignorefs": "^1.0.0", + "safefs": "^3.1.2", + "taskgroup": "^4.0.5" + } + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" + }, + "semver-diff": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", + "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", + "dev": true, + "requires": { + "semver": "^5.0.3" + } + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + } + } + }, + "seq-queue": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz", + "integrity": "sha1-1WgS4cAXpuTnw+Ojeh2m143TyT4=" + }, + "sequelize": { + "version": "4.38.0", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-4.38.0.tgz", + "integrity": "sha512-ZCcV2HuzU+03xunWgVeyXnPa/RYY5D2U/WUNpq+xF8VmDTLnSDsHl+pEwmiWrpZD7KdBqDczCeTgjToYyVzYQg==", + "requires": { + "bluebird": "^3.5.0", + "cls-bluebird": "^2.1.0", + "debug": "^3.1.0", + "depd": "^1.1.0", + "dottie": "^2.0.0", + "generic-pool": "^3.4.0", + "inflection": "1.12.0", + "lodash": "^4.17.1", + "moment": "^2.20.0", + "moment-timezone": "^0.5.14", + "retry-as-promised": "^2.3.2", + "semver": "^5.5.0", + "terraformer-wkt-parser": "^1.1.2", + "toposort-class": "^1.0.1", + "uuid": "^3.2.1", + "validator": "^10.4.0", + "wkx": "^0.4.1" + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", + "dev": true + }, + "set-value": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + }, + "shimmer": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.0.tgz", + "integrity": "sha512-xTCx2vohXC2EWWDqY/zb4+5Mu28D+HYNSOuFzsyRDRvI/e1ICb69afwaUwfjr+25ZXldbOLyp+iDUZHq8UnTag==" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "slick": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/slick/-/slick-1.12.2.tgz", + "integrity": "sha1-vQSN23TefRymkV+qSldXCzVQwtc=" + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "socket.io": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.1.tgz", + "integrity": "sha512-rORqq9c+7W0DAK3cleWNSyfv/qKXV99hV4tZe+gGLfBECw3XEhBy7x85F3wypA9688LKjtwO9pX9L33/xQI8yA==", + "requires": { + "debug": "~3.1.0", + "engine.io": "~3.2.0", + "has-binary2": "~1.0.2", + "socket.io-adapter": "~1.1.0", + "socket.io-client": "2.1.1", + "socket.io-parser": "~3.2.0" + } + }, + "socket.io-adapter": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz", + "integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs=" + }, + "socket.io-client": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.1.1.tgz", + "integrity": "sha512-jxnFyhAuFxYfjqIgduQlhzqTcOEQSn+OHKVfAxWaNWa7ecP7xSNk2Dx/3UEsDcY7NcFafxvNvKPmmO7HTwTxGQ==", + "requires": { + "backo2": "1.0.2", + "base64-arraybuffer": "0.1.5", + "component-bind": "1.0.0", + "component-emitter": "1.2.1", + "debug": "~3.1.0", + "engine.io-client": "~3.2.0", + "has-binary2": "~1.0.2", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "object-component": "0.0.3", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "socket.io-parser": "~3.2.0", + "to-array": "0.1.4" + } + }, + "socket.io-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.2.0.tgz", + "integrity": "sha512-FYiBx7rc/KORMJlgsXysflWx/RIvtqZbyGLlHZvjfmPTPeuD/I8MaW7cfFrj5tRltICJdgwflhfZ3NVVbVLFQA==", + "requires": { + "component-emitter": "1.2.1", + "debug": "~3.1.0", + "isarray": "2.0.1" + }, + "dependencies": { + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" + } + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "dev": true, + "requires": { + "through": "2" + } + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "sqlite3": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-4.0.6.tgz", + "integrity": "sha512-EqBXxHdKiwvNMRCgml86VTL5TK1i0IKiumnfxykX0gh6H6jaKijAXvE9O1N7+omfNSawR2fOmIyJZcfe8HYWpw==", + "optional": true, + "requires": { + "nan": "~2.10.0", + "node-pre-gyp": "^0.11.0", + "request": "^2.87.0" + } + }, + "sqlstring": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", + "integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A=" + }, + "sshpk": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", + "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + }, + "stream-combiner": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", + "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "dev": true, + "requires": { + "duplexer": "~0.1.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + }, + "tar": { + "version": "4.4.8", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", + "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", + "optional": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "taskgroup": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/taskgroup/-/taskgroup-4.3.1.tgz", + "integrity": "sha1-feGT/r12gnPEV3MElwJNUSwnkVo=", + "requires": { + "ambi": "^2.2.0", + "csextends": "^1.0.3" + } + }, + "term-size": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", + "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", + "dev": true, + "requires": { + "execa": "^0.7.0" + } + }, + "terraformer": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/terraformer/-/terraformer-1.0.9.tgz", + "integrity": "sha512-YlmQ1fsMWTkKGDGibCRWgmLzrpDRUr63Q025LJ/taYQ6j1Yb8q9McKF7NBi6ACAyUXO6F/bl9w6v4MY307y5Ag==", + "requires": { + "@types/geojson": "^1.0.0" + } + }, + "terraformer-wkt-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/terraformer-wkt-parser/-/terraformer-wkt-parser-1.2.0.tgz", + "integrity": "sha512-QU3iA54St5lF8Za1jg1oj4NYc8sn5tCZ08aNSWDeGzrsaV48eZk1iAVWasxhNspYBoCqdHuoot1pUTUrE1AJ4w==", + "requires": { + "@types/geojson": "^1.0.0", + "terraformer": "~1.0.5" + } + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "timed-out": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", + "dev": true + }, + "to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=" + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "token-stream": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-0.0.1.tgz", + "integrity": "sha1-zu78cXp2xDFvEm0LnbqlXX598Bo=" + }, + "tokgen": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/tokgen/-/tokgen-1.0.0.tgz", + "integrity": "sha1-5wmIWfbnzKXwGSoFW0GN6kJQBOM=", + "requires": { + "expand-string": "^1.1.1", + "lodash.defaults": "^4.0.1" + } + }, + "toposort-class": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz", + "integrity": "sha1-f/0feMi+KMO6Rc1OGj9e4ZO9mYg=" + }, + "touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dev": true, + "requires": { + "nopt": "~1.0.10" + }, + "dependencies": { + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "dev": true, + "requires": { + "abbrev": "1" + } + } + } + }, + "tough-cookie": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", + "requires": { + "punycode": "^1.4.1" + } + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true + }, + "tslint": { + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz", + "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=", + "dev": true, + "requires": { + "babel-code-frame": "^6.22.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.7.0", + "minimatch": "^3.0.4", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.27.2" + } + }, + "tslint-config-standard": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/tslint-config-standard/-/tslint-config-standard-7.1.0.tgz", + "integrity": "sha512-cETzxZcEQ1RKjwtEScGryAtqwiRFc55xBxhZP6bePyOfXmo6i1/QKQrTgFKBiM4FjCvcqTjJq20/KGrh+TzTfQ==", + "dev": true, + "requires": { + "tslint-eslint-rules": "^5.3.1" + } + }, + "tslint-eslint-rules": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/tslint-eslint-rules/-/tslint-eslint-rules-5.3.1.tgz", + "integrity": "sha512-qq2H/AU/FlFbQJKXuxhtIk+ni/nQu9jHHhsFKa6hnA0/n3zl1/RWRc3TVFlL8HfWFMzkST350VeTrFpy1u4OUg==", + "dev": true, + "requires": { + "doctrine": "0.7.2", + "tslib": "1.9.0", + "tsutils": "2.8.0" + }, + "dependencies": { + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==", + "dev": true + }, + "tsutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.8.0.tgz", + "integrity": "sha1-AWAXNymzvxOGKN0UoVN+AIUdgUo=", + "dev": true, + "requires": { + "tslib": "^1.7.1" + } + } + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.18" + } + }, + "typechecker": { + "version": "2.1.0", + "resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.1.0.tgz", + "integrity": "sha1-0cIJOlT/ihn1jP+HfuqlTyJC04M=" + }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "dev": true + }, + "typescript-json-schema": { + "version": "0.31.0", + "resolved": "https://registry.npmjs.org/typescript-json-schema/-/typescript-json-schema-0.31.0.tgz", + "integrity": "sha512-YgG+lWiToGzlKPdO2ZjGx4Y5TdJh8N0eEA2p8IQDSGdUIv+fqQlO4YLbZNxMpFiomvparcxTOgRpPsIrk0sNWg==", + "dev": true, + "requires": { + "glob": "~7.1.2", + "json-stable-stringify": "^1.0.1", + "typescript": "^3.0.1", + "yargs": "^12.0.1" + }, + "dependencies": { + "typescript": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz", + "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==", + "dev": true + } + } + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "requires": { + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" + }, + "dependencies": { + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=" + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "requires": { + "center-align": "^0.1.1", + "right-align": "^0.1.1", + "wordwrap": "0.0.2" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=" + }, + "yargs": { + "version": "3.10.0", + "resolved": "http://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "requires": { + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", + "window-size": "0.1.0" + } + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "optional": true + }, + "ultron": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", + "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" + }, + "umzug": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/umzug/-/umzug-2.1.0.tgz", + "integrity": "sha512-BgT+ekpItEWaG+3JjLLj6yVTxw2wIH8Cr6JyKYIzukWAx9nzGhC6BGHb/IRMjpobMM1qtIrReATwLUjKpU2iOQ==", + "requires": { + "babel-runtime": "^6.23.0", + "bluebird": "^3.4.1", + "lodash": "^4.17.0", + "resolve": "^1.0.0" + } + }, + "undefsafe": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.2.tgz", + "integrity": "sha1-Il9rngM3Zj4Njnz9aG/Cg2zKznY=", + "dev": true, + "requires": { + "debug": "^2.2.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, + "underscore": { + "version": "1.7.0", + "resolved": "http://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", + "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" + }, + "underscore.deep": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/underscore.deep/-/underscore.deep-0.5.1.tgz", + "integrity": "sha1-ByZx9I1oc1w0Ij/P72PmnlJ2zCs=" + }, + "underscore.string": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.5.tgz", + "integrity": "sha512-g+dpmgn+XBneLmXXo+sGlW5xQEt4ErkS3mgeN2GFbremYeMBSJKr9Wf2KJplQVaiPY/f7FN6atosWYNm9ovrYg==", + "requires": { + "sprintf-js": "^1.0.3", + "util-deprecate": "^1.0.2" + } + }, + "union-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", + "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" + } + } + } + }, + "unique-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", + "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", + "dev": true, + "requires": { + "crypto-random-string": "^1.0.0" + } + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, + "unzip-response": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", + "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", + "dev": true + }, + "upath": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz", + "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", + "dev": true + }, + "update-notifier": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.5.0.tgz", + "integrity": "sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw==", + "dev": true, + "requires": { + "boxen": "^1.2.1", + "chalk": "^2.0.1", + "configstore": "^3.0.0", + "import-lazy": "^2.1.0", + "is-ci": "^1.0.10", + "is-installed-globally": "^0.1.0", + "is-npm": "^1.0.0", + "latest-version": "^3.0.0", + "semver-diff": "^2.0.0", + "xdg-basedir": "^3.0.0" + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "^2.1.0" + }, + "dependencies": { + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + } + } + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "url-parse-lax": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "dev": true, + "requires": { + "prepend-http": "^1.0.1" + } + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "valid-data-url": { + "version": "0.1.6", + "resolved": "http://registry.npmjs.org/valid-data-url/-/valid-data-url-0.1.6.tgz", + "integrity": "sha512-FXg2qXMzfAhZc0y2HzELNfUeiOjPr+52hU1DNBWiJJ2luXD+dD1R9NA48Ug5aj0ibbxroeGDc/RJv6ThiGgkDw==" + }, + "validator": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-10.4.0.tgz", + "integrity": "sha512-Q/wBy3LB1uOyssgNlXSRmaf22NxjvDNZM2MtIQ4jaEOAB61xsh1TQxsq1CgzUMBV1lDrVMogIh8GjG1DYW0zLg==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "void-elements": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", + "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=" + }, + "watchr": { + "version": "2.4.13", + "resolved": "http://registry.npmjs.org/watchr/-/watchr-2.4.13.tgz", + "integrity": "sha1-10hHu01vkPYf4sdPn2hmKqDgdgE=", + "requires": { + "eachr": "^2.0.2", + "extendr": "^2.1.0", + "extract-opts": "^2.2.0", + "ignorefs": "^1.0.0", + "safefs": "^3.1.2", + "scandirectory": "^2.5.0", + "taskgroup": "^4.2.0", + "typechecker": "^2.0.8" + } + }, + "web-resource-inliner": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/web-resource-inliner/-/web-resource-inliner-4.2.1.tgz", + "integrity": "sha512-fOWnBQHVX8zHvEbECDTxtYL0FXIIZZ5H3LWoez8mGopYJK7inEru1kVMDzM1lVdeJBNEqUnNP5FBGxvzuMcwwQ==", + "requires": { + "async": "^2.1.2", + "chalk": "^1.1.3", + "datauri": "^1.0.4", + "htmlparser2": "^3.9.2", + "lodash.unescape": "^4.0.1", + "request": "^2.78.0", + "valid-data-url": "^0.1.4", + "xtend": "^4.0.0" + }, + "dependencies": { + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "requires": { + "lodash": "^4.17.11" + } + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + } + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "widest-line": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-2.0.0.tgz", + "integrity": "sha1-AUKk6KJD+IgsAjOqDgKBqnYVInM=", + "dev": true, + "requires": { + "string-width": "^2.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=" + }, + "with": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/with/-/with-5.1.1.tgz", + "integrity": "sha1-+k2qktrzLE6pTtRTyB8EaGtXXf4=", + "requires": { + "acorn": "^3.1.0", + "acorn-globals": "^3.0.0" + } + }, + "wkx": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/wkx/-/wkx-0.4.5.tgz", + "integrity": "sha512-01dloEcJZAJabLO5XdcRgqdKpmnxS0zIT02LhkdWOZX2Zs2tPM6hlZ4XG9tWaWur1Qd1OO4kJxUbe2+5BofvnA==", + "requires": { + "@types/node": "*" + } + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "write-file-atomic": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", + "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "ws": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "requires": { + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" + } + }, + "xdg-basedir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", + "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", + "dev": true + }, + "xmlhttprequest-ssl": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", + "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=" + }, + "xregexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.0.0.tgz", + "integrity": "sha512-PHyM+sQouu7xspQQwELlGwwd05mXUFqwFYfqPO0cC7x4fxyHnnuetmQr6CjJiafIDoH4MogHb9dOoJzR/Y4rFg==", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + }, + "yargs": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.1.tgz", + "integrity": "sha512-B0vRAp1hRX4jgIOWFtjfNjd9OA9RWYZ6tqGA9/I/IrTMsxmKvtWy+ersM+jzpQqbC3YfLzeABPdeTgcJ9eu1qQ==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^2.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^2.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^10.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "yargs-parser": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", + "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", + "dev": true, + "requires": { + "camelcase": "^4.1.0" + } + }, + "yeast": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", + "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..dfc9872 --- /dev/null +++ b/package.json @@ -0,0 +1,64 @@ +{ + "name": "timelimit-server-2018", + "version": "0.0.0", + "private": true, + "description": "", + "scripts": { + "start": "node ./build/index.js", + "test": "echo \"Error: no test specified\" && exit 1", + "lint": "tslint --project .", + "lint:fix": "tslint --project . --fix", + "build": "npm run build:json && npm run build:ts && npm run lint", + "build:json": "node ./scripts/build-schemas.js", + "build:ts": "tsc", + "watch": "nodemon ./build/index.js" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@gitlab.com/timelimit.io/timelimit-server-2018.git" + }, + "author": "Jonas Lochmann", + "license": "AGPL-3.0", + "bugs": { + "url": "https://gitlab.com/timelimit.io/timelimit-server-2018/issues" + }, + "homepage": "https://gitlab.com/timelimit.io/timelimit-server-2018#README", + "devDependencies": { + "@types/body-parser": "^1.17.0", + "@types/email-templates": "^3.5.0", + "@types/express": "^4.16.0", + "@types/http-errors": "^1.6.1", + "@types/lodash": "^4.14.116", + "@types/sequelize": "^4.27.24", + "@types/socket.io": "^1.4.36", + "@types/tokgen": "^1.0.0", + "@types/umzug": "^2.2.0", + "nodemon": "^1.18.3", + "tslint": "^5.11.0", + "tslint-config-standard": "^7.1.0", + "typescript": "^2.9.2", + "typescript-json-schema": "^0.31.0" + }, + "dependencies": { + "ajv": "^6.5.2", + "body-parser": "^1.18.3", + "ejs": "^2.6.1", + "email-templates": "^5.0.4", + "express": "^4.16.3", + "google-auth-library": "^1.6.1", + "http-errors": "^1.7.0", + "iab_verifier": "^0.1.2", + "lodash": "^4.17.11", + "mysql2": "^1.6.1", + "pg": "^7.8.0", + "pg-hstore": "^2.3.2", + "rate-limiter-flexible": "^0.21.2", + "sequelize": "^4.38.0", + "socket.io": "^2.1.1", + "tokgen": "^1.0.0", + "umzug": "^2.1.0" + }, + "optionalDependencies": { + "sqlite3": "^4.0.6" + } +} diff --git a/scripts/build-schemas.js b/scripts/build-schemas.js new file mode 100644 index 0000000..e17db35 --- /dev/null +++ b/scripts/build-schemas.js @@ -0,0 +1,114 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +const { resolve } = require('path') +const TJS = require('typescript-json-schema') +const { writeFileSync } = require('fs') +const { each, isEqual } = require('lodash') + +const randomString = 'WK9fxjlOcM' + +const types = [ + 'ClientPushChangesRequest', + 'ClientPullChangesRequest', + 'SignInWithGoogleRequest', + 'MailAuthTokenRequestBody', + 'CreateFamilyByMailTokenRequest', + 'SignIntoFamilyRequest', + 'RecoverParentPasswordRequest', + 'CanRecoverPasswordRequest', + 'RegisterChildDeviceRequest', + 'SerializedParentAction', + 'SerializedAppLogicAction', + 'SerializedChildAction', + 'CreateRegisterDeviceTokenRequest', + 'CanDoPurchaseRequest', + 'FinishPurchaseByGooglePlayRequest', + 'LinkParentMailAddressRequest', + 'UpdatePrimaryDeviceRequest', + 'RemoveDeviceRequest', + 'RequestWithAuthToken', + 'SendMailLoginCodeRequest', + 'SignInByMailCodeRequest' +] + +const settings = { + required: true, + noExtraProps: true +}; + +const compilerOptions = { + strictNullChecks: true, + lib: ['es2015'] +} + +// optionally pass a base path +const program = TJS.getProgramFromFiles([ + resolve(__dirname, '../src/api/schema.ts') +], compilerOptions, __dirname) + +const generator = TJS.buildGenerator(program, settings) + +let definitions = {} +let schemas = {} +let output = '' + +types.forEach((type) => { + const schema = generator.getSchemaForSymbol(type) + + schemas[type] = schema + + if (schema.definitions) { + each(schema.definitions, (value, name) => { + if (!definitions[name]) { + definitions[name] = value + } else { + if (!isEqual(definitions[name], value)) { + throw new Error('different schemas for ' + name) + } + } + }) + } +}) + +output += '// tslint:disable \n' +output += 'import { ' + types.join(', ') + ' } from \'./schema\'\n' +output += 'const Ajv = require(\'ajv\')\n' +output += 'const ajv = new Ajv()\n' +output += '\n' +output += 'const definitions = ' + JSON.stringify(definitions, null, 2) + '\n\n' + +types.forEach((type) => { + const schema = schemas[type] + let schemaString + + if (schema.definitions) { + schemaString = JSON.stringify({ + ...schema, + definitions: randomString + }, null, 2).replace(JSON.stringify(randomString), 'definitions') + } else { + schemaString = JSON.stringify(schema, null, 2) + } + + const functionBody = 'ajv.compile(' + schemaString + ')' + const functionName = 'is' + type.substr(0, 1).toUpperCase() + type.substr(1) + + output += 'export const ' + functionName + ': (value: object) => value is ' + type + ' = ' + functionBody + '\n' +}) + +writeFileSync(resolve(__dirname, '../src/api/validator.ts'), output) diff --git a/src/action/addcategoryapps.ts b/src/action/addcategoryapps.ts new file mode 100644 index 0000000..6afc978 --- /dev/null +++ b/src/action/addcategoryapps.ts @@ -0,0 +1,51 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertNonEmptyListWithoutDuplicates } from '../util/list' +import { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class AddCategoryAppsAction extends ParentAction { + readonly categoryId: string + readonly packageNames: Array + + constructor ({ categoryId, packageNames }: {categoryId: string, packageNames: Array}) { + super() + + assertIdWithinFamily(categoryId) + assertNonEmptyListWithoutDuplicates(packageNames) + + this.categoryId = categoryId + this.packageNames = packageNames + } + + serialize = (): SerializedAddCategoryAppsAction => ({ + type: 'ADD_CATEGORY_APPS', + categoryId: this.categoryId, + packageNames: this.packageNames + }) + + static parse = ({ categoryId, packageNames }: SerializedAddCategoryAppsAction) => ( + new AddCategoryAppsAction({ categoryId, packageNames }) + ) +} + +export interface SerializedAddCategoryAppsAction { + type: 'ADD_CATEGORY_APPS' + categoryId: string + packageNames: Array +} diff --git a/src/action/addinstalledapps.ts b/src/action/addinstalledapps.ts new file mode 100644 index 0000000..43bab7a --- /dev/null +++ b/src/action/addinstalledapps.ts @@ -0,0 +1,48 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { InstalledApp, SerializedInstalledApp } from '../model/installedapp' +import { assertNonEmptyListWithoutDuplicates } from '../util/list' +import { AppLogicAction } from './basetypes' + +export class AddInstalledAppsAction extends AppLogicAction { + readonly apps: Array + + constructor ({ apps }: {apps: Array}) { + super() + + assertNonEmptyListWithoutDuplicates(apps.map((app) => app.packageName)) + + this.apps = apps + } + + serialize = (): SerializedAddInstalledAppsAction => ({ + type: 'ADD_INSTALLED_APPS', + apps: this.apps.map((app) => app.serialize()) + }) + + static parse = ({ apps }: SerializedAddInstalledAppsAction) => ( + new AddInstalledAppsAction({ + apps: apps.map((app) => InstalledApp.parse(app)) + }) + ) +} + +export interface SerializedAddInstalledAppsAction { + type: 'ADD_INSTALLED_APPS' + apps: Array +} diff --git a/src/action/addusedtime.ts b/src/action/addusedtime.ts new file mode 100644 index 0000000..442d10e --- /dev/null +++ b/src/action/addusedtime.ts @@ -0,0 +1,79 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { AppLogicAction } from './basetypes' + +export class AddUsedTimeAction extends AppLogicAction { + readonly categoryId: string + readonly dayOfEpoch: number + readonly timeToAdd: number + readonly extraTimeToSubtract: number + + constructor ({ categoryId, dayOfEpoch, timeToAdd, extraTimeToSubtract }: { + categoryId: string + dayOfEpoch: number + timeToAdd: number + extraTimeToSubtract: number + }) { + super() + + assertIdWithinFamily(categoryId) + + if (dayOfEpoch < 0 || (!Number.isSafeInteger(dayOfEpoch))) { + throw new Error('illegal dayOfEpoch') + } + + if (timeToAdd < 0 || (!Number.isSafeInteger(timeToAdd))) { + throw new Error('illegal timeToAdd') + } + + if (extraTimeToSubtract < 0 || (!Number.isSafeInteger(extraTimeToSubtract))) { + throw new Error('illegal extra time to subtract') + } + + this.categoryId = categoryId + this.dayOfEpoch = dayOfEpoch + this.timeToAdd = timeToAdd + this.extraTimeToSubtract = extraTimeToSubtract + } + + serialize = (): SerializedAddUsedTimeAction => ({ + type: 'ADD_USED_TIME', + categoryId: this.categoryId, + day: this.dayOfEpoch, + timeToAdd: this.timeToAdd, + extraTimeToSubtract: this.extraTimeToSubtract + }) + + static parse = ({ categoryId, day, timeToAdd, extraTimeToSubtract }: SerializedAddUsedTimeAction) => ( + new AddUsedTimeAction({ + categoryId, + dayOfEpoch: day, + timeToAdd, + extraTimeToSubtract + }) + ) +} + +export interface SerializedAddUsedTimeAction { + type: 'ADD_USED_TIME' + categoryId: string + day: number + timeToAdd: number + extraTimeToSubtract: number +} diff --git a/src/action/adduser.ts b/src/action/adduser.ts new file mode 100644 index 0000000..b621be6 --- /dev/null +++ b/src/action/adduser.ts @@ -0,0 +1,84 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertParentPasswordValid, ParentPassword } from '../api/schema' +import { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class AddUserAction extends ParentAction { + readonly userId: string + readonly name: string + readonly userType: 'parent' | 'child' + readonly password?: ParentPassword + readonly timeZone: string + + constructor ({ userId, name, userType, password, timeZone }: { + userId: string + name: string + userType: 'parent' | 'child' + password?: ParentPassword + timeZone: string + }) { + super() + + assertIdWithinFamily(userId) + + this.userId = userId + this.name = name + this.userType = userType + this.password = password + this.timeZone = timeZone + + if (userType === 'parent') { + if (!password) { + throw new Error('parent users must have got an password') + } + } + + if (password) { + assertParentPasswordValid(password) + } + } + + serialize = (): SerializedAddUserAction => ({ + type: 'ADD_USER', + name: this.name, + userType: this.userType, + userId: this.userId, + password: this.password, + timeZone: this.timeZone + }) + + static parse = ({ name, userId, userType, password, timeZone }: SerializedAddUserAction) => ( + new AddUserAction({ + name, + userId, + userType, + password, + timeZone + }) + ) +} + +export interface SerializedAddUserAction { + type: 'ADD_USER' + name: string + userType: 'parent' | 'child' + userId: string + password?: ParentPassword + timeZone: string +} diff --git a/src/action/basetypes.ts b/src/action/basetypes.ts new file mode 100644 index 0000000..4eebd62 --- /dev/null +++ b/src/action/basetypes.ts @@ -0,0 +1,26 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export abstract class Action { + abstract serialize: () => object +} + +export abstract class AppLogicAction extends Action {} + +export abstract class ParentAction extends Action {} + +export abstract class ChildAction extends Action {} diff --git a/src/action/changeparentpassword.ts b/src/action/changeparentpassword.ts new file mode 100644 index 0000000..6c6ef35 --- /dev/null +++ b/src/action/changeparentpassword.ts @@ -0,0 +1,126 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { createDecipheriv, createHash } from 'crypto' +import { assertIsHexString } from '../util/hexstring' +import { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class ChangeParentPasswordAction extends ParentAction { + readonly parentUserId: string + readonly newPasswordFirstHash: string + readonly newPasswordSecondSalt: string + readonly newPasswordSecondHashEncrypted: string + readonly integrity: string + + constructor ({ parentUserId, newPasswordFirstHash, newPasswordSecondSalt, newPasswordSecondHashEncrypted, integrity }: { + parentUserId: string + newPasswordFirstHash: string + newPasswordSecondSalt: string + newPasswordSecondHashEncrypted: string + integrity: string + }) { + super() + + assertIdWithinFamily(parentUserId) + + if ( + (!parentUserId) || + (!newPasswordFirstHash) || + (!newPasswordSecondSalt) || + (!newPasswordSecondHashEncrypted) || + (!integrity) + ) { + throw new Error('missing required parameter for change parent password') + } + + if (integrity.length !== 128) { + throw new Error('wrong length of integrity data') + } + + assertIsHexString(newPasswordSecondHashEncrypted) + assertIsHexString(integrity) + + this.parentUserId = parentUserId + this.newPasswordFirstHash = newPasswordFirstHash + this.newPasswordSecondSalt = newPasswordSecondSalt + this.newPasswordSecondHashEncrypted = newPasswordSecondHashEncrypted + this.integrity = integrity + } + + serialize = (): SerializedChangeParentPasswordAction => ({ + type: 'CHANGE_PARENT_PASSWORD', + userId: this.parentUserId, + hash: this.newPasswordFirstHash, + secondSalt: this.newPasswordSecondSalt, + secondHashEncrypted: this.newPasswordSecondHashEncrypted, + integrity: this.integrity + }) + + static parse = ({ userId, hash, secondSalt, secondHashEncrypted, integrity }: SerializedChangeParentPasswordAction) => ( + new ChangeParentPasswordAction({ + parentUserId: userId, + newPasswordFirstHash: hash, + newPasswordSecondSalt: secondSalt, + newPasswordSecondHashEncrypted: secondHashEncrypted, + integrity + }) + ) + + assertIntegrityValid ({ oldPasswordSecondHash }: {oldPasswordSecondHash: string}) { + const integrityData = oldPasswordSecondHash + + this.parentUserId + + this.newPasswordFirstHash + + this.newPasswordSecondSalt + + this.newPasswordSecondHashEncrypted + + const expected = createHash('sha512').update(integrityData).digest('hex') + + if (expected !== this.integrity) { + throw new Error('invalid integrity for change parent password action') + } + } + + decryptSecondHash ({ oldPasswordSecondHash }: {oldPasswordSecondHash: string}) { + if (this.newPasswordSecondHashEncrypted.length <= 70) { + throw new Error('wrong length of the new password') + } + + const ivHex = this.newPasswordSecondHashEncrypted.substring(0, 32) + const salt = this.newPasswordSecondHashEncrypted.substring(32, 64) + const encryptedData = this.newPasswordSecondHashEncrypted.substring(64) + + const keyData = oldPasswordSecondHash + salt + const key = createHash('sha512').update(keyData).digest().slice(0, 16) + + const decipher = createDecipheriv('aes-128-ctr', key, Buffer.from(ivHex, 'hex')) + decipher.setAutoPadding(false) + + const decryptedSecondHash = decipher.update(Buffer.from(encryptedData, 'hex')).toString() + decipher.final().toString() + + return decryptedSecondHash + } +} + +export interface SerializedChangeParentPasswordAction { + type: 'CHANGE_PARENT_PASSWORD' + userId: string + hash: string + secondSalt: string + secondHashEncrypted: string + integrity: string +} diff --git a/src/action/childchangepassword.ts b/src/action/childchangepassword.ts new file mode 100644 index 0000000..a586666 --- /dev/null +++ b/src/action/childchangepassword.ts @@ -0,0 +1,47 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertParentPasswordValid, ParentPassword } from '../api/schema' +import { ChildAction } from './basetypes' + +export class ChildChangePasswordAction extends ChildAction { + readonly password: ParentPassword + + constructor ({ password }: { + password: ParentPassword + }) { + super() + + assertParentPasswordValid(password) + + this.password = password + } + + serialize = (): SerializedChildChangePasswordAction => ({ + type: 'CHILD_CHANGE_PASSWORD', + password: this.password + }) + + static parse = ({ password }: SerializedChildChangePasswordAction) => ( + new ChildChangePasswordAction({ password }) + ) +} + +export interface SerializedChildChangePasswordAction { + type: 'CHILD_CHANGE_PASSWORD' + password: ParentPassword +} diff --git a/src/action/childsignin.ts b/src/action/childsignin.ts new file mode 100644 index 0000000..892474d --- /dev/null +++ b/src/action/childsignin.ts @@ -0,0 +1,36 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { ChildAction } from './basetypes' + +export class ChildSignInAction extends ChildAction { + constructor () { + super() + } + + serialize = (): SerializedChildSignInAction => ({ + type: 'CHILD_SIGN_IN' + }) + + static parse = (action: SerializedChildSignInAction) => ( + new ChildSignInAction() + ) +} + +export interface SerializedChildSignInAction { + type: 'CHILD_SIGN_IN' +} diff --git a/src/action/createcategory.ts b/src/action/createcategory.ts new file mode 100644 index 0000000..314e876 --- /dev/null +++ b/src/action/createcategory.ts @@ -0,0 +1,54 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class CreateCategoryAction extends ParentAction { + readonly categoryId: string + readonly childId: string + readonly title: string + + constructor ({ categoryId, childId, title }: {categoryId: string, childId: string, title: string}) { + super() + + assertIdWithinFamily(categoryId) + assertIdWithinFamily(childId) + + this.categoryId = categoryId + this.childId = childId + this.title = title + } + + serialize = (): SerializedCreateCategoryAction => ({ + type: 'CREATE_CATEGORY', + childId: this.childId, + categoryId: this.categoryId, + title: this.title + }) + + static parse = ({ childId, categoryId, title }: SerializedCreateCategoryAction) => ( + new CreateCategoryAction({ childId, categoryId, title }) + ) +} + +export interface SerializedCreateCategoryAction { + type: 'CREATE_CATEGORY' + childId: string + categoryId: string + title: string +} diff --git a/src/action/createtimelimitrule.ts b/src/action/createtimelimitrule.ts new file mode 100644 index 0000000..50f2413 --- /dev/null +++ b/src/action/createtimelimitrule.ts @@ -0,0 +1,45 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SerializedTimeLimitRule, TimelimitRule } from '../model/timelimitrule' +import { ParentAction } from './basetypes' + +export class CreateTimeLimitRuleAction extends ParentAction { + rule: TimelimitRule + + constructor ({ rule }: {rule: TimelimitRule}) { + super() + + this.rule = rule + } + + serialize = (): SerializedCreateTimelimtRuleAction => ({ + type: 'CREATE_TIMELIMIT_RULE', + rule: this.rule.serialize() + }) + + static parse = ({ rule }: SerializedCreateTimelimtRuleAction) => ( + new CreateTimeLimitRuleAction({ + rule: TimelimitRule.parse(rule) + }) + ) +} + +export interface SerializedCreateTimelimtRuleAction { + type: 'CREATE_TIMELIMIT_RULE' + rule: SerializedTimeLimitRule +} diff --git a/src/action/deletecategory.ts b/src/action/deletecategory.ts new file mode 100644 index 0000000..5e16d10 --- /dev/null +++ b/src/action/deletecategory.ts @@ -0,0 +1,45 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class DeleteCategoryAction extends ParentAction { + readonly categoryId: string + + constructor ({ categoryId }: {categoryId: string}) { + super() + + assertIdWithinFamily(categoryId) + + this.categoryId = categoryId + } + + serialize = (): SerializedDeleteCategoryAction => ({ + type: 'DELETE_CATEGORY', + categoryId: this.categoryId + }) + + static parse = ({ categoryId }: SerializedDeleteCategoryAction) => ( + new DeleteCategoryAction({ categoryId }) + ) +} + +export interface SerializedDeleteCategoryAction { + type: 'DELETE_CATEGORY' + categoryId: string +} diff --git a/src/action/deletetimelimitrule.ts b/src/action/deletetimelimitrule.ts new file mode 100644 index 0000000..78e0272 --- /dev/null +++ b/src/action/deletetimelimitrule.ts @@ -0,0 +1,45 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class DeleteTimeLimitRuleAction extends ParentAction { + readonly ruleId: string + + constructor ({ ruleId }: {ruleId: string}) { + super() + + assertIdWithinFamily(ruleId) + + this.ruleId = ruleId + } + + serialize = (): SerializedDeleteTimeLimitRuleAction => ({ + type: 'DELETE_TIMELIMIT_RULE', + ruleId: this.ruleId + }) + + static parse = ({ ruleId }: SerializedDeleteTimeLimitRuleAction) => ( + new DeleteTimeLimitRuleAction({ ruleId }) + ) +} + +export interface SerializedDeleteTimeLimitRuleAction { + type: 'DELETE_TIMELIMIT_RULE' + ruleId: string +} diff --git a/src/action/ignoremanipulation.ts b/src/action/ignoremanipulation.ts new file mode 100644 index 0000000..322ee86 --- /dev/null +++ b/src/action/ignoremanipulation.ts @@ -0,0 +1,95 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class IgnoreManipulationAction extends ParentAction { + readonly deviceId: string + readonly ignoreDeviceAdminManipulation: boolean + readonly ignoreDeviceAdminManipulationAttempt: boolean + readonly ignoreAppDowngrade: boolean + readonly ignoreNotificationAccessManipulation: boolean + readonly ignoreUsageStatsAccessManipulation: boolean + readonly ignoreDidReboot: boolean + readonly ignoreHadManipulation: boolean + + constructor ({ + deviceId, ignoreDeviceAdminManipulation, ignoreDeviceAdminManipulationAttempt, + ignoreAppDowngrade, ignoreNotificationAccessManipulation, ignoreUsageStatsAccessManipulation, + ignoreDidReboot, ignoreHadManipulation + }: { + deviceId: string + ignoreDeviceAdminManipulation: boolean + ignoreDeviceAdminManipulationAttempt: boolean + ignoreAppDowngrade: boolean + ignoreNotificationAccessManipulation: boolean + ignoreUsageStatsAccessManipulation: boolean + ignoreDidReboot: boolean + ignoreHadManipulation: boolean + }) { + super() + + assertIdWithinFamily(deviceId) + + this.deviceId = deviceId + this.ignoreDeviceAdminManipulation = ignoreDeviceAdminManipulation + this.ignoreDeviceAdminManipulationAttempt = ignoreDeviceAdminManipulationAttempt + this.ignoreAppDowngrade = ignoreAppDowngrade + this.ignoreNotificationAccessManipulation = ignoreNotificationAccessManipulation + this.ignoreUsageStatsAccessManipulation = ignoreUsageStatsAccessManipulation + this.ignoreDidReboot = ignoreDidReboot + this.ignoreHadManipulation = ignoreHadManipulation + } + + serialize = (): SerializedIgnoreManipulationAction => ({ + type: 'IGNORE_MANIPULATION', + deviceId: this.deviceId, + admin: this.ignoreDeviceAdminManipulation, + adminA: this.ignoreDeviceAdminManipulationAttempt, + downgrade: this.ignoreAppDowngrade, + notification: this.ignoreNotificationAccessManipulation, + usageStats: this.ignoreUsageStatsAccessManipulation, + hadManipulation: this.ignoreHadManipulation + }) + + static parse = ({ deviceId, admin, adminA, downgrade, notification, usageStats, reboot, hadManipulation }: SerializedIgnoreManipulationAction) => ( + new IgnoreManipulationAction({ + deviceId, + ignoreDeviceAdminManipulation: admin, + ignoreDeviceAdminManipulationAttempt: adminA, + ignoreAppDowngrade: downgrade, + ignoreUsageStatsAccessManipulation: usageStats, + ignoreNotificationAccessManipulation: notification, + ignoreDidReboot: !!reboot, + ignoreHadManipulation: hadManipulation + }) + ) +} + +export interface SerializedIgnoreManipulationAction { + type: 'IGNORE_MANIPULATION' + deviceId: string + admin: boolean + adminA: boolean + downgrade: boolean + notification: boolean + usageStats: boolean + hadManipulation: boolean + // was added at a later version + reboot?: boolean +} diff --git a/src/action/incrementcategoryextratime.ts b/src/action/incrementcategoryextratime.ts new file mode 100644 index 0000000..7d9742a --- /dev/null +++ b/src/action/incrementcategoryextratime.ts @@ -0,0 +1,53 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class IncrementCategoryExtraTimeAction extends ParentAction { + readonly categoryId: string + readonly addedExtraTime: number + + constructor ({ categoryId, addedExtraTime }: {categoryId: string, addedExtraTime: number}) { + super() + + assertIdWithinFamily(categoryId) + + if (addedExtraTime <= 0 || (!Number.isSafeInteger(addedExtraTime))) { + throw new Error('must add some extra time with IncrementCategoryExtraTimeAction') + } + + this.categoryId = categoryId + this.addedExtraTime = addedExtraTime + } + + serialize = (): SerializedIncrementCategoryExtraTimeAction => ({ + type: 'INCREMENT_CATEGORY_EXTRATIME', + categoryId: this.categoryId, + addedExtraTime: this.addedExtraTime + }) + + static parse = ({ categoryId, addedExtraTime }: SerializedIncrementCategoryExtraTimeAction) => ( + new IncrementCategoryExtraTimeAction({ categoryId, addedExtraTime }) + ) +} + +export interface SerializedIncrementCategoryExtraTimeAction { + type: 'INCREMENT_CATEGORY_EXTRATIME' + categoryId: string + addedExtraTime: number +} diff --git a/src/action/index.ts b/src/action/index.ts new file mode 100644 index 0000000..6b68291 --- /dev/null +++ b/src/action/index.ts @@ -0,0 +1,59 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export { AppLogicAction, ChildAction, ParentAction } from './basetypes' + +export { AddCategoryAppsAction } from './addcategoryapps' +export { AddUserAction } from './adduser' +export { AddInstalledAppsAction } from './addinstalledapps' +export { AddUsedTimeAction } from './addusedtime' +export { ChangeParentPasswordAction } from './changeparentpassword' +export { ChildChangePasswordAction } from './childchangepassword' +export { ChildSignInAction } from './childsignin' +export { CreateCategoryAction } from './createcategory' +export { CreateTimeLimitRuleAction } from './createtimelimitrule' +export { DeleteCategoryAction } from './deletecategory' +export { DeleteTimeLimitRuleAction } from './deletetimelimitrule' +export { IgnoreManipulationAction } from './ignoremanipulation' +export { IncrementCategoryExtraTimeAction } from './incrementcategoryextratime' +export { RemoveCategoryAppsAction } from './removecategoryapps' +export { RemoveInstalledAppsAction } from './removeinstalledapps' +export { RemoveUserAction } from './removeuser' +export { RenameChildAction } from './renamechild' +export { SetCategoryExtraTimeAction } from './setcategoryextratime' +export { SetCategoryForUnassignedAppsAction } from './setcategoryforunassignedapps' +export { SetChildPasswordAction } from './setchildpassword' +export { SetConsiderRebootManipulationAction } from './setconsiderrebootmanipulation' +export { SetDeviceDefaultUserAction } from './setdevicedefaultuser' +export { SetDeviceDefaultUserTimeoutAction } from './setdevicedefaultusertimeout' +export { SetDeviceUserAction } from './setdeviceuser' +export { SetKeepSignedInAction } from './setkeepsignedin' +export { SetParentCategoryAction } from './setparentcategory' +export { SetRelaxPrimaryDeviceAction } from './setrelaxprimarydevice' +export { SetSendDeviceConnected } from './setsenddeviceconnected' +export { SetUserDisableLimitsUntilAction } from './setuserdisablelimitsuntil' +export { SetUserTimezoneAction } from './setusertimezone' +export { SignOutAtDeviceAction } from './signoutatdevice' +export { TriedDisablingDeviceAdminAction } from './trieddisablingdeviceadmin' +export { UpdateCategoryBlockedTimesAction } from './updatecategoryblockedtimes' +export { UpdateCategoryTemporarilyBlockedAction } from './updatecategorytemporarilyblocked' +export { UpdateCategoryTitleAction } from './updatecategorytitle' +export { UpdateDeviceNameAction } from './updatedevicename' +export { UpdateDeviceStatusAction } from './updatedevicestatus' +export { UpdateNetworkTimeVerificationAction } from './updatenetworktimeverification' +export { UpdateParentNotificationFlagsAction } from './updateparentnotificationflags' +export { UpdateTimelimitRuleAction } from './updatetimelimitrule' diff --git a/src/action/removecategoryapps.ts b/src/action/removecategoryapps.ts new file mode 100644 index 0000000..9dae5ec --- /dev/null +++ b/src/action/removecategoryapps.ts @@ -0,0 +1,51 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertNonEmptyListWithoutDuplicates } from '../util/list' +import { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class RemoveCategoryAppsAction extends ParentAction { + readonly categoryId: string + readonly packageNames: Array + + constructor ({ categoryId, packageNames }: {categoryId: string, packageNames: Array}) { + super() + + assertIdWithinFamily(categoryId) + assertNonEmptyListWithoutDuplicates(packageNames) + + this.categoryId = categoryId + this.packageNames = packageNames + } + + serialize = (): SerializedRemoveCategoryAppsAction => ({ + type: 'REMOVE_CATEGORY_APPS', + categoryId: this.categoryId, + packageNames: this.packageNames + }) + + static parse = ({ categoryId, packageNames }: SerializedRemoveCategoryAppsAction) => ( + new RemoveCategoryAppsAction({ categoryId, packageNames }) + ) +} + +export interface SerializedRemoveCategoryAppsAction { + type: 'REMOVE_CATEGORY_APPS' + categoryId: string + packageNames: Array +} diff --git a/src/action/removeinstalledapps.ts b/src/action/removeinstalledapps.ts new file mode 100644 index 0000000..8b8dabc --- /dev/null +++ b/src/action/removeinstalledapps.ts @@ -0,0 +1,45 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertNonEmptyListWithoutDuplicates } from '../util/list' +import { AppLogicAction } from './basetypes' + +export class RemoveInstalledAppsAction extends AppLogicAction { + readonly packageNames: Array + + constructor ({ packageNames }: {packageNames: Array}) { + super() + + assertNonEmptyListWithoutDuplicates(packageNames) + + this.packageNames = packageNames + } + + serialize = (): SerializedRemoveInstalledAppsAction => ({ + type: 'REMOVE_INSTALLED_APPS', + packageNames: this.packageNames + }) + + static parse = ({ packageNames }: SerializedRemoveInstalledAppsAction) => ( + new RemoveInstalledAppsAction({ packageNames }) + ) +} + +export interface SerializedRemoveInstalledAppsAction { + type: 'REMOVE_INSTALLED_APPS' + packageNames: Array +} diff --git a/src/action/removeuser.ts b/src/action/removeuser.ts new file mode 100644 index 0000000..c251d15 --- /dev/null +++ b/src/action/removeuser.ts @@ -0,0 +1,55 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class RemoveUserAction extends ParentAction { + readonly userId: string + // required for deleting parent users + // parent users can only be removed by other parent users + // this should be the value of sha512(userId + secondPasswordHash + 'remove').substring(0, 16) + readonly authentication?: string + + constructor ({ userId, authentication }: { + userId: string + authentication?: string + }) { + super() + + assertIdWithinFamily(userId) + + this.userId = userId + this.authentication = authentication + } + + serialize = (): SerializedRemoveUserAction => ({ + type: 'REMOVE_USER', + userId: this.userId, + authentication: this.authentication + }) + + static parse = ({ userId, authentication }: SerializedRemoveUserAction) => ( + new RemoveUserAction({ userId, authentication }) + ) +} + +export interface SerializedRemoveUserAction { + type: 'REMOVE_USER' + userId: string + authentication?: string +} diff --git a/src/action/renamechild.ts b/src/action/renamechild.ts new file mode 100644 index 0000000..925c58f --- /dev/null +++ b/src/action/renamechild.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class RenameChildAction extends ParentAction { + readonly childId: string + readonly newName: string + + constructor ({ childId, newName }: { + childId: string + newName: string + }) { + super() + + assertIdWithinFamily(childId) + + if (newName === '') { + throw new Error('new name must not be empty') + } + + this.childId = childId + this.newName = newName + } + + serialize = (): SerializedRenameChildAction => ({ + type: 'RENAME_CHILD', + childId: this.childId, + newName: this.newName + }) + + static parse = ({ childId, newName }: SerializedRenameChildAction) => ( + new RenameChildAction({ childId, newName }) + ) +} + +export interface SerializedRenameChildAction { + type: 'RENAME_CHILD' + childId: string + newName: string +} diff --git a/src/action/serialization/applogicaction.ts b/src/action/serialization/applogicaction.ts new file mode 100644 index 0000000..d015318 --- /dev/null +++ b/src/action/serialization/applogicaction.ts @@ -0,0 +1,50 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { AddInstalledAppsAction, SerializedAddInstalledAppsAction } from '../addinstalledapps' +import { AddUsedTimeAction, SerializedAddUsedTimeAction } from '../addusedtime' +import { AppLogicAction } from '../basetypes' +import { RemoveInstalledAppsAction, SerializedRemoveInstalledAppsAction } from '../removeinstalledapps' +import { SerializedSignOutAtDeviceAction, SignOutAtDeviceAction } from '../signoutatdevice' +import { SerialiezdTriedDisablingDeviceAdminAction, TriedDisablingDeviceAdminAction } from '../trieddisablingdeviceadmin' +import { SerializedUpdateDeviceStatusAction, UpdateDeviceStatusAction } from '../updatedevicestatus' + +export type SerializedAppLogicAction = + SerializedAddInstalledAppsAction | + SerializedAddUsedTimeAction | + SerializedRemoveInstalledAppsAction | + SerializedSignOutAtDeviceAction | + SerialiezdTriedDisablingDeviceAdminAction | + SerializedUpdateDeviceStatusAction + +export const parseAppLogicAction = (serialized: SerializedAppLogicAction): AppLogicAction => { + if (serialized.type === 'ADD_USED_TIME') { + return AddUsedTimeAction.parse(serialized) + } else if (serialized.type === 'ADD_INSTALLED_APPS') { + return AddInstalledAppsAction.parse(serialized) + } else if (serialized.type === 'REMOVE_INSTALLED_APPS') { + return RemoveInstalledAppsAction.parse(serialized) + } else if (serialized.type === 'SIGN_OUT_AT_DEVICE') { + return SignOutAtDeviceAction.parse(serialized) + } else if (serialized.type === 'TRIED_DISABLING_DEVICE_ADMIN') { + return new TriedDisablingDeviceAdminAction() + } else if (serialized.type === 'UPDATE_DEVICE_STATUS') { + return UpdateDeviceStatusAction.parse(serialized) + } else { + throw new Error('illegal state: unsupported type at parseAppLogicAction') + } +} diff --git a/src/action/serialization/childaction.ts b/src/action/serialization/childaction.ts new file mode 100644 index 0000000..880568c --- /dev/null +++ b/src/action/serialization/childaction.ts @@ -0,0 +1,31 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { ChildChangePasswordAction, SerializedChildChangePasswordAction } from '../childchangepassword' +import { ChildSignInAction, SerializedChildSignInAction } from '../childsignin' + +export type SerializedChildAction = SerializedChildChangePasswordAction | SerializedChildSignInAction + +export const parseChildAction = (serialized: SerializedChildAction) => { + if (serialized.type === 'CHILD_CHANGE_PASSWORD') { + return ChildChangePasswordAction.parse(serialized) + } else if (serialized.type === 'CHILD_SIGN_IN') { + return ChildSignInAction.parse(serialized) + } else { + throw new Error('illegal state: unsupported type at parseChildAction') + } +} diff --git a/src/action/serialization/index.ts b/src/action/serialization/index.ts new file mode 100644 index 0000000..914dd32 --- /dev/null +++ b/src/action/serialization/index.ts @@ -0,0 +1,20 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export { parseAppLogicAction, SerializedAppLogicAction } from './applogicaction' +export { parseChildAction, SerializedChildAction } from './childaction' +export { parseParentAction, SerializedParentAction } from './parentaction' diff --git a/src/action/serialization/parentaction.ts b/src/action/serialization/parentaction.ts new file mode 100644 index 0000000..ff156da --- /dev/null +++ b/src/action/serialization/parentaction.ts @@ -0,0 +1,154 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { AddCategoryAppsAction, SerializedAddCategoryAppsAction } from '../addcategoryapps' +import { AddUserAction, SerializedAddUserAction } from '../adduser' +import { ParentAction } from '../basetypes' +import { ChangeParentPasswordAction, SerializedChangeParentPasswordAction } from '../changeparentpassword' +import { CreateCategoryAction, SerializedCreateCategoryAction } from '../createcategory' +import { CreateTimeLimitRuleAction, SerializedCreateTimelimtRuleAction } from '../createtimelimitrule' +import { DeleteCategoryAction, SerializedDeleteCategoryAction } from '../deletecategory' +import { DeleteTimeLimitRuleAction, SerializedDeleteTimeLimitRuleAction } from '../deletetimelimitrule' +import { IgnoreManipulationAction, SerializedIgnoreManipulationAction } from '../ignoremanipulation' +import { IncrementCategoryExtraTimeAction, SerializedIncrementCategoryExtraTimeAction } from '../incrementcategoryextratime' +import { RemoveCategoryAppsAction, SerializedRemoveCategoryAppsAction } from '../removecategoryapps' +import { RemoveUserAction, SerializedRemoveUserAction } from '../removeuser' +import { RenameChildAction, SerializedRenameChildAction } from '../renamechild' +import { SerializedSetCategoryExtraTimeAction, SetCategoryExtraTimeAction } from '../setcategoryextratime' +import { SerializedSetCategoryForUnassignedAppsAction, SetCategoryForUnassignedAppsAction } from '../setcategoryforunassignedapps' +import { SerializedSetChildPasswordAction, SetChildPasswordAction } from '../setchildpassword' +import { SerializedSetConsiderRebootManipulationAction, SetConsiderRebootManipulationAction } from '../setconsiderrebootmanipulation' +import { SerializedSetDeviceDefaultUserAction, SetDeviceDefaultUserAction } from '../setdevicedefaultuser' +import { SerializedSetDeviceDefaultUserTimeoutAction, SetDeviceDefaultUserTimeoutAction } from '../setdevicedefaultusertimeout' +import { SerializedSetDeviceUserAction, SetDeviceUserAction } from '../setdeviceuser' +import { SerializedSetKeepSignedInAction, SetKeepSignedInAction } from '../setkeepsignedin' +import { SerializedSetParentCategoryAction, SetParentCategoryAction } from '../setparentcategory' +import { SerializedSetRelaxPrimaryDeviceAction, SetRelaxPrimaryDeviceAction } from '../setrelaxprimarydevice' +import { SerializedSetSendDeviceConnected, SetSendDeviceConnected } from '../setsenddeviceconnected' +import { SerializedSetUserDisableLimitsUntilAction, SetUserDisableLimitsUntilAction } from '../setuserdisablelimitsuntil' +import { SerializedSetUserTimezoneAction, SetUserTimezoneAction } from '../setusertimezone' +import { SerializedUpdateCategoryBlockedTimesAction, UpdateCategoryBlockedTimesAction } from '../updatecategoryblockedtimes' +import { SerializedUpdateCategoryTemporarilyBlockedAction, UpdateCategoryTemporarilyBlockedAction } from '../updatecategorytemporarilyblocked' +import { SerializedUpdateCategoryTitleAction, UpdateCategoryTitleAction } from '../updatecategorytitle' +import { SerializedUpdateDeviceNameAction, UpdateDeviceNameAction } from '../updatedevicename' +import { SerialiizedUpdateNetworkTimeVerificationAction, UpdateNetworkTimeVerificationAction } from '../updatenetworktimeverification' +import { SerializedUpdateParentNotificationFlagsAction, UpdateParentNotificationFlagsAction } from '../updateparentnotificationflags' +import { SerializedUpdateTimelimitRuleAction, UpdateTimelimitRuleAction } from '../updatetimelimitrule' + +export type SerializedParentAction = + SerializedAddCategoryAppsAction | + SerializedAddUserAction | + SerializedChangeParentPasswordAction | + SerializedCreateCategoryAction | + SerializedCreateTimelimtRuleAction | + SerializedDeleteCategoryAction | + SerializedDeleteTimeLimitRuleAction | + SerializedIgnoreManipulationAction | + SerializedIncrementCategoryExtraTimeAction | + SerializedRemoveCategoryAppsAction | + SerializedRemoveUserAction | + SerializedRenameChildAction | + SerializedSetCategoryForUnassignedAppsAction | + SerializedSetChildPasswordAction | + SerializedSetConsiderRebootManipulationAction | + SerializedSetDeviceDefaultUserAction | + SerializedSetDeviceDefaultUserTimeoutAction | + SerializedSetCategoryExtraTimeAction | + SerializedSetDeviceUserAction | + SerializedSetKeepSignedInAction | + SerializedSetParentCategoryAction | + SerializedSetRelaxPrimaryDeviceAction | + SerializedSetSendDeviceConnected | + SerializedSetUserDisableLimitsUntilAction | + SerializedSetUserTimezoneAction | + SerializedUpdateCategoryBlockedTimesAction | + SerializedUpdateCategoryTemporarilyBlockedAction | + SerializedUpdateCategoryTitleAction | + SerializedUpdateDeviceNameAction | + SerialiizedUpdateNetworkTimeVerificationAction | + SerializedUpdateParentNotificationFlagsAction | + SerializedUpdateTimelimitRuleAction + +export const parseParentAction = (action: SerializedParentAction): ParentAction => { + if (action.type === 'ADD_CATEGORY_APPS') { + return AddCategoryAppsAction.parse(action) + } else if (action.type === 'ADD_USER') { + return AddUserAction.parse(action) + } else if (action.type === 'CHANGE_PARENT_PASSWORD') { + return ChangeParentPasswordAction.parse(action) + } else if (action.type === 'CREATE_CATEGORY') { + return CreateCategoryAction.parse(action) + } else if (action.type === 'CREATE_TIMELIMIT_RULE') { + return CreateTimeLimitRuleAction.parse(action) + } else if (action.type === 'DELETE_CATEGORY') { + return DeleteCategoryAction.parse(action) + } else if (action.type === 'DELETE_TIMELIMIT_RULE') { + return DeleteTimeLimitRuleAction.parse(action) + } else if (action.type === 'IGNORE_MANIPULATION') { + return IgnoreManipulationAction.parse(action) + } else if (action.type === 'INCREMENT_CATEGORY_EXTRATIME') { + return IncrementCategoryExtraTimeAction.parse(action) + } else if (action.type === 'REMOVE_CATEGORY_APPS') { + return RemoveCategoryAppsAction.parse(action) + } else if (action.type === 'REMOVE_USER') { + return RemoveUserAction.parse(action) + } else if (action.type === 'RENAME_CHILD') { + return RenameChildAction.parse(action) + } else if (action.type === 'SET_CATEGORY_EXTRA_TIME') { + return SetCategoryExtraTimeAction.parse(action) + } else if (action.type === 'SET_CATEGORY_FOR_UNASSIGNED_APPS') { + return SetCategoryForUnassignedAppsAction.parse(action) + } else if (action.type === 'SET_CHILD_PASSWORD') { + return SetChildPasswordAction.parse(action) + } else if (action.type === 'SET_CONSIDER_REBOOT_MANIPULATION') { + return SetConsiderRebootManipulationAction.parse(action) + } else if (action.type === 'SET_DEVICE_DEFAULT_USER') { + return SetDeviceDefaultUserAction.parse(action) + } else if (action.type === 'SET_DEVICE_DEFAULT_USER_TIMEOUT') { + return SetDeviceDefaultUserTimeoutAction.parse(action) + } else if (action.type === 'SET_DEVICE_USER') { + return SetDeviceUserAction.parse(action) + } else if (action.type === 'SET_KEEP_SIGNED_IN') { + return SetKeepSignedInAction.parse(action) + } else if (action.type === 'SET_PARENT_CATEGORY') { + return SetParentCategoryAction.parse(action) + } else if (action.type === 'SET_RELAX_PRIMARY_DEVICE') { + return SetRelaxPrimaryDeviceAction.parse(action) + } else if (action.type === 'SET_SEND_DEVICE_CONNECTED') { + return SetSendDeviceConnected.parse(action) + } else if (action.type === 'SET_USER_DISABLE_LIMITS_UNTIL') { + return SetUserDisableLimitsUntilAction.parse(action) + } else if (action.type === 'SET_USER_TIMEZONE') { + return SetUserTimezoneAction.parse(action) + } else if (action.type === 'UPDATE_CATEGORY_BLOCKED_TIMES') { + return UpdateCategoryBlockedTimesAction.parse(action) + } else if (action.type === 'UPDATE_CATEGORY_TITLE') { + return UpdateCategoryTitleAction.parse(action) + } else if (action.type === 'UPDATE_CATEGORY_TEMPORARILY_BLOCKED') { + return UpdateCategoryTemporarilyBlockedAction.parse(action) + } else if (action.type === 'UPDATE_DEVICE_NAME') { + return UpdateDeviceNameAction.parse(action) + } else if (action.type === 'UPDATE_NETWORK_TIME_VERIFICATION') { + return UpdateNetworkTimeVerificationAction.parse(action) + } else if (action.type === 'UPDATE_PARENT_NOTIFICATION_FLAGS') { + return UpdateParentNotificationFlagsAction.parse(action) + } else if (action.type === 'UPDATE_TIMELIMIT_RULE') { + return UpdateTimelimitRuleAction.parse(action) + } else { + throw new Error('illegal state: invalid type for action at parseParentAction') + } +} diff --git a/src/action/setcategoryextratime.ts b/src/action/setcategoryextratime.ts new file mode 100644 index 0000000..801b8b6 --- /dev/null +++ b/src/action/setcategoryextratime.ts @@ -0,0 +1,53 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetCategoryExtraTimeAction extends ParentAction { + readonly categoryId: string + readonly newExtraTime: number + + constructor ({ categoryId, newExtraTime }: {categoryId: string, newExtraTime: number}) { + super() + + assertIdWithinFamily(categoryId) + + if (newExtraTime < 0 || (!Number.isSafeInteger(newExtraTime))) { + throw Error('newExtraTime must be >= 0') + } + + this.categoryId = categoryId + this.newExtraTime = newExtraTime + } + + serialize = (): SerializedSetCategoryExtraTimeAction => ({ + type: 'SET_CATEGORY_EXTRA_TIME', + categoryId: this.categoryId, + newExtraTime: this.newExtraTime + }) + + static parse = ({ categoryId, newExtraTime }: SerializedSetCategoryExtraTimeAction) => ( + new SetCategoryExtraTimeAction({ categoryId, newExtraTime }) + ) +} + +export interface SerializedSetCategoryExtraTimeAction { + type: 'SET_CATEGORY_EXTRA_TIME' + categoryId: string + newExtraTime: number +} diff --git a/src/action/setcategoryforunassignedapps.ts b/src/action/setcategoryforunassignedapps.ts new file mode 100644 index 0000000..1ea4e28 --- /dev/null +++ b/src/action/setcategoryforunassignedapps.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetCategoryForUnassignedAppsAction extends ParentAction { + readonly childId: string + readonly categoryId: string + + constructor ({ childId, categoryId }: { + childId: string + categoryId: string + }) { + super() + + assertIdWithinFamily(childId) + + if (categoryId !== '') { + assertIdWithinFamily(categoryId) + } + + this.childId = childId + this.categoryId = categoryId + } + + serialize = (): SerializedSetCategoryForUnassignedAppsAction => ({ + type: 'SET_CATEGORY_FOR_UNASSIGNED_APPS', + childId: this.childId, + categoryId: this.categoryId + }) + + static parse = ({ childId, categoryId }: SerializedSetCategoryForUnassignedAppsAction) => ( + new SetCategoryForUnassignedAppsAction({ childId, categoryId }) + ) +} + +export interface SerializedSetCategoryForUnassignedAppsAction { + type: 'SET_CATEGORY_FOR_UNASSIGNED_APPS' + childId: string + categoryId: string +} diff --git a/src/action/setchildpassword.ts b/src/action/setchildpassword.ts new file mode 100644 index 0000000..7c6ec46 --- /dev/null +++ b/src/action/setchildpassword.ts @@ -0,0 +1,57 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertParentPasswordValid, ParentPassword } from '../api/schema' +import { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetChildPasswordAction extends ParentAction { + readonly childUserId: string + readonly newPassword: ParentPassword + + constructor ({ childUserId, newPassword }: { + childUserId: string + newPassword: ParentPassword + }) { + super() + + assertIdWithinFamily(childUserId) + assertParentPasswordValid(newPassword) + + this.childUserId = childUserId + this.newPassword = newPassword + } + + serialize = (): SerializedSetChildPasswordAction => ({ + type: 'SET_CHILD_PASSWORD', + childId: this.childUserId, + newPassword: this.newPassword + }) + + static parse = ({ childId, newPassword }: SerializedSetChildPasswordAction) => ( + new SetChildPasswordAction({ + childUserId: childId, + newPassword + }) + ) +} + +export interface SerializedSetChildPasswordAction { + type: 'SET_CHILD_PASSWORD' + childId: string + newPassword: ParentPassword +} diff --git a/src/action/setconsiderrebootmanipulation.ts b/src/action/setconsiderrebootmanipulation.ts new file mode 100644 index 0000000..94e3afa --- /dev/null +++ b/src/action/setconsiderrebootmanipulation.ts @@ -0,0 +1,49 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetConsiderRebootManipulationAction extends ParentAction { + readonly deviceId: string + readonly enable: boolean + + constructor ({ deviceId, enable }: {deviceId: string, enable: boolean}) { + super() + + assertIdWithinFamily(deviceId) + + this.deviceId = deviceId + this.enable = enable + } + + serialize = (): SerializedSetConsiderRebootManipulationAction => ({ + type: 'SET_CONSIDER_REBOOT_MANIPULATION', + deviceId: this.deviceId, + enable: this.enable + }) + + static parse = ({ deviceId, enable }: SerializedSetConsiderRebootManipulationAction) => ( + new SetConsiderRebootManipulationAction({ deviceId, enable }) + ) +} + +export interface SerializedSetConsiderRebootManipulationAction { + type: 'SET_CONSIDER_REBOOT_MANIPULATION' + deviceId: string + enable: boolean +} diff --git a/src/action/setdevicedefaultuser.ts b/src/action/setdevicedefaultuser.ts new file mode 100644 index 0000000..baa4fc0 --- /dev/null +++ b/src/action/setdevicedefaultuser.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetDeviceDefaultUserAction extends ParentAction { + readonly deviceId: string + readonly defaultUserId: string + + constructor ({ deviceId, defaultUserId }: { + deviceId: string + defaultUserId: string + }) { + super() + + assertIdWithinFamily(deviceId) + + if (defaultUserId !== '') { + assertIdWithinFamily(defaultUserId) + } + + this.deviceId = deviceId + this.defaultUserId = defaultUserId + } + + serialize = (): SerializedSetDeviceDefaultUserAction => ({ + type: 'SET_DEVICE_DEFAULT_USER', + deviceId: this.deviceId, + defaultUserId: this.defaultUserId + }) + + static parse = ({ deviceId, defaultUserId }: SerializedSetDeviceDefaultUserAction) => ( + new SetDeviceDefaultUserAction({ deviceId, defaultUserId }) + ) +} + +export interface SerializedSetDeviceDefaultUserAction { + type: 'SET_DEVICE_DEFAULT_USER' + deviceId: string + defaultUserId: string +} diff --git a/src/action/setdevicedefaultusertimeout.ts b/src/action/setdevicedefaultusertimeout.ts new file mode 100644 index 0000000..cd8dd1e --- /dev/null +++ b/src/action/setdevicedefaultusertimeout.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetDeviceDefaultUserTimeoutAction extends ParentAction { + readonly deviceId: string + readonly timeout: number + + constructor ({ deviceId, timeout }: { + deviceId: string + timeout: number + }) { + super() + + assertIdWithinFamily(deviceId) + + if ((!Number.isInteger(timeout)) || (timeout < 0)) { + throw new Error('timeout must be a non-negative integer') + } + + this.deviceId = deviceId + this.timeout = timeout + } + + serialize = (): SerializedSetDeviceDefaultUserTimeoutAction => ({ + type: 'SET_DEVICE_DEFAULT_USER_TIMEOUT', + deviceId: this.deviceId, + timeout: this.timeout + }) + + static parse = ({ deviceId, timeout }: SerializedSetDeviceDefaultUserTimeoutAction) => ( + new SetDeviceDefaultUserTimeoutAction({ deviceId, timeout }) + ) +} + +export interface SerializedSetDeviceDefaultUserTimeoutAction { + type: 'SET_DEVICE_DEFAULT_USER_TIMEOUT' + deviceId: string + timeout: number +} diff --git a/src/action/setdeviceuser.ts b/src/action/setdeviceuser.ts new file mode 100644 index 0000000..cd9c886 --- /dev/null +++ b/src/action/setdeviceuser.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetDeviceUserAction extends ParentAction { + readonly deviceId: string + readonly userId: string // user id can be "" + + constructor ({ deviceId, userId }: { + deviceId: string + userId: string + }) { + super() + + assertIdWithinFamily(deviceId) + + if (userId !== '') { + assertIdWithinFamily(userId) + } + + this.deviceId = deviceId + this.userId = userId + } + + serialize = (): SerializedSetDeviceUserAction => ({ + type: 'SET_DEVICE_USER', + deviceId: this.deviceId, + userId: this.userId + }) + + static parse = ({ deviceId, userId }: SerializedSetDeviceUserAction) => ( + new SetDeviceUserAction({ deviceId, userId }) + ) +} + +export interface SerializedSetDeviceUserAction { + type: 'SET_DEVICE_USER' + deviceId: string + userId: string +} diff --git a/src/action/setkeepsignedin.ts b/src/action/setkeepsignedin.ts new file mode 100644 index 0000000..8a1067c --- /dev/null +++ b/src/action/setkeepsignedin.ts @@ -0,0 +1,55 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetKeepSignedInAction extends ParentAction { + readonly deviceId: string + readonly keepSignedIn: boolean + + constructor ({ deviceId, keepSignedIn }: { + deviceId: string + keepSignedIn: boolean + }) { + super() + + assertIdWithinFamily(deviceId) + + this.deviceId = deviceId + this.keepSignedIn = keepSignedIn + } + + serialize = (): SerializedSetKeepSignedInAction => ({ + type: 'SET_KEEP_SIGNED_IN', + deviceId: this.deviceId, + keepSignedIn: this.keepSignedIn + }) + + static parse = ({ deviceId, keepSignedIn }: SerializedSetKeepSignedInAction) => ( + new SetKeepSignedInAction({ + deviceId, + keepSignedIn + }) + ) +} + +export interface SerializedSetKeepSignedInAction { + type: 'SET_KEEP_SIGNED_IN' + deviceId: string + keepSignedIn: boolean +} diff --git a/src/action/setparentcategory.ts b/src/action/setparentcategory.ts new file mode 100644 index 0000000..ae7db9c --- /dev/null +++ b/src/action/setparentcategory.ts @@ -0,0 +1,59 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetParentCategoryAction extends ParentAction { + readonly categoryId: string + readonly parentCategory: string + + constructor ({ categoryId, parentCategory }: { + categoryId: string + parentCategory: string + }) { + super() + + assertIdWithinFamily(categoryId) + + if (parentCategory !== '') { + assertIdWithinFamily(parentCategory) + } + + this.categoryId = categoryId + this.parentCategory = parentCategory + } + + serialize = (): SerializedSetParentCategoryAction => ({ + type: 'SET_PARENT_CATEGORY', + categoryId: this.categoryId, + parentCategory: this.parentCategory + }) + + static parse = ({ categoryId, parentCategory }: SerializedSetParentCategoryAction) => ( + new SetParentCategoryAction({ + categoryId, + parentCategory + }) + ) +} + +export interface SerializedSetParentCategoryAction { + type: 'SET_PARENT_CATEGORY' + categoryId: string + parentCategory: string +} diff --git a/src/action/setrelaxprimarydevice.ts b/src/action/setrelaxprimarydevice.ts new file mode 100644 index 0000000..8892220 --- /dev/null +++ b/src/action/setrelaxprimarydevice.ts @@ -0,0 +1,52 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetRelaxPrimaryDeviceAction extends ParentAction { + readonly userId: string + readonly relax: boolean + + constructor ({ userId, relax }: { + userId: string + relax: boolean + }) { + super() + + assertIdWithinFamily(userId) + + this.userId = userId + this.relax = relax + } + + serialize = (): SerializedSetRelaxPrimaryDeviceAction => ({ + type: 'SET_RELAX_PRIMARY_DEVICE', + userId: this.userId, + relax: this.relax + }) + + static parse = ({ userId, relax }: SerializedSetRelaxPrimaryDeviceAction) => ( + new SetRelaxPrimaryDeviceAction({ userId, relax }) + ) +} + +export interface SerializedSetRelaxPrimaryDeviceAction { + type: 'SET_RELAX_PRIMARY_DEVICE' + userId: string + relax: boolean +} diff --git a/src/action/setsenddeviceconnected.ts b/src/action/setsenddeviceconnected.ts new file mode 100644 index 0000000..613dbe3 --- /dev/null +++ b/src/action/setsenddeviceconnected.ts @@ -0,0 +1,55 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetSendDeviceConnected extends ParentAction { + readonly deviceId: string + readonly enable: boolean + + constructor ({ deviceId, enable }: { + deviceId: string + enable: boolean + }) { + super() + + assertIdWithinFamily(deviceId) + + this.deviceId = deviceId + this.enable = enable + } + + serialize = (): SerializedSetSendDeviceConnected => ({ + type: 'SET_SEND_DEVICE_CONNECTED', + deviceId: this.deviceId, + enable: this.enable + }) + + static parse = ({ deviceId, enable }: SerializedSetSendDeviceConnected) => ( + new SetSendDeviceConnected({ + deviceId, + enable + }) + ) +} + +export interface SerializedSetSendDeviceConnected { + type: 'SET_SEND_DEVICE_CONNECTED' + deviceId: string + enable: boolean +} diff --git a/src/action/setuserdisablelimitsuntil.ts b/src/action/setuserdisablelimitsuntil.ts new file mode 100644 index 0000000..5de820f --- /dev/null +++ b/src/action/setuserdisablelimitsuntil.ts @@ -0,0 +1,59 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetUserDisableLimitsUntilAction extends ParentAction { + readonly childId: string + readonly timestamp: number + + constructor ({ childId, timestamp }: { + childId: string + timestamp: number + }) { + super() + + assertIdWithinFamily(childId) + + if (timestamp < 0 || (!Number.isSafeInteger(timestamp))) { + throw new Error('timestamp for set user disabe limits until must be >= 0') + } + + this.childId = childId + this.timestamp = timestamp + } + + serialize = (): SerializedSetUserDisableLimitsUntilAction => ({ + type: 'SET_USER_DISABLE_LIMITS_UNTIL', + childId: this.childId, + time: this.timestamp + }) + + static parse = ({ childId, time }: SerializedSetUserDisableLimitsUntilAction) => ( + new SetUserDisableLimitsUntilAction({ + childId, + timestamp: time + }) + ) +} + +export interface SerializedSetUserDisableLimitsUntilAction { + type: 'SET_USER_DISABLE_LIMITS_UNTIL' + childId: string + time: number +} diff --git a/src/action/setusertimezone.ts b/src/action/setusertimezone.ts new file mode 100644 index 0000000..22a1e12 --- /dev/null +++ b/src/action/setusertimezone.ts @@ -0,0 +1,52 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class SetUserTimezoneAction extends ParentAction { + readonly userId: string + readonly timezone: string + + constructor ({ userId, timezone }: { + userId: string + timezone: string + }) { + super() + + assertIdWithinFamily(userId) + + this.userId = userId + this.timezone = timezone + } + + serialize = (): SerializedSetUserTimezoneAction => ({ + type: 'SET_USER_TIMEZONE', + userId: this.userId, + timezone: this.timezone + }) + + static parse = ({ userId, timezone }: SerializedSetUserTimezoneAction) => ( + new SetUserTimezoneAction({ userId, timezone }) + ) +} + +export interface SerializedSetUserTimezoneAction { + type: 'SET_USER_TIMEZONE' + userId: string + timezone: string +} diff --git a/src/action/signoutatdevice.ts b/src/action/signoutatdevice.ts new file mode 100644 index 0000000..b8453a8 --- /dev/null +++ b/src/action/signoutatdevice.ts @@ -0,0 +1,36 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { AppLogicAction } from './basetypes' + +export class SignOutAtDeviceAction extends AppLogicAction { + static instance = new SignOutAtDeviceAction() + + private constructor () { + super() + } + + serialize = (): SerializedSignOutAtDeviceAction => ({ + type: 'SIGN_OUT_AT_DEVICE' + }) + + static parse = (action: SerializedSignOutAtDeviceAction) => SignOutAtDeviceAction.instance +} + +export interface SerializedSignOutAtDeviceAction { + type: 'SIGN_OUT_AT_DEVICE' +} diff --git a/src/action/trieddisablingdeviceadmin.ts b/src/action/trieddisablingdeviceadmin.ts new file mode 100644 index 0000000..a9469fb --- /dev/null +++ b/src/action/trieddisablingdeviceadmin.ts @@ -0,0 +1,32 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { AppLogicAction } from './basetypes' + +export class TriedDisablingDeviceAdminAction extends AppLogicAction { + constructor () { + super() + } + + serialize = (): SerialiezdTriedDisablingDeviceAdminAction => ({ + type: 'TRIED_DISABLING_DEVICE_ADMIN' + }) +} + +export interface SerialiezdTriedDisablingDeviceAdminAction { + type: 'TRIED_DISABLING_DEVICE_ADMIN' +} diff --git a/src/action/updatecategoryblockedtimes.ts b/src/action/updatecategoryblockedtimes.ts new file mode 100644 index 0000000..c29c7e4 --- /dev/null +++ b/src/action/updatecategoryblockedtimes.ts @@ -0,0 +1,57 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { validateBitmask } from '../util/bitmask' +import { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class UpdateCategoryBlockedTimesAction extends ParentAction { + readonly categoryId: string + readonly blockedTimes: string + + constructor ({ categoryId, blockedTimes }: { + categoryId: string + blockedTimes: string + }) { + super() + + assertIdWithinFamily(categoryId) + validateBitmask(blockedTimes, 60 * 24 * 7 /* number of minutes per week */) + + this.categoryId = categoryId + this.blockedTimes = blockedTimes + } + + serialize = (): SerializedUpdateCategoryBlockedTimesAction => ({ + type: 'UPDATE_CATEGORY_BLOCKED_TIMES', + categoryId: this.categoryId, + times: this.blockedTimes + }) + + static parse = ({ categoryId, times }: SerializedUpdateCategoryBlockedTimesAction) => ( + new UpdateCategoryBlockedTimesAction({ + categoryId, + blockedTimes: times + }) + ) +} + +export interface SerializedUpdateCategoryBlockedTimesAction { + type: 'UPDATE_CATEGORY_BLOCKED_TIMES' + categoryId: string + times: string +} diff --git a/src/action/updatecategorytemporarilyblocked.ts b/src/action/updatecategorytemporarilyblocked.ts new file mode 100644 index 0000000..1768f16 --- /dev/null +++ b/src/action/updatecategorytemporarilyblocked.ts @@ -0,0 +1,49 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class UpdateCategoryTemporarilyBlockedAction extends ParentAction { + readonly categoryId: string + readonly blocked: boolean + + constructor ({ categoryId, blocked }: {categoryId: string, blocked: boolean}) { + super() + + assertIdWithinFamily(categoryId) + + this.categoryId = categoryId + this.blocked = blocked + } + + serialize = (): SerializedUpdateCategoryTemporarilyBlockedAction => ({ + type: 'UPDATE_CATEGORY_TEMPORARILY_BLOCKED', + categoryId: this.categoryId, + blocked: this.blocked + }) + + static parse = ({ categoryId, blocked }: SerializedUpdateCategoryTemporarilyBlockedAction) => ( + new UpdateCategoryTemporarilyBlockedAction({ categoryId, blocked }) + ) +} + +export interface SerializedUpdateCategoryTemporarilyBlockedAction { + type: 'UPDATE_CATEGORY_TEMPORARILY_BLOCKED' + categoryId: string + blocked: boolean +} diff --git a/src/action/updatecategorytitle.ts b/src/action/updatecategorytitle.ts new file mode 100644 index 0000000..3647fb9 --- /dev/null +++ b/src/action/updatecategorytitle.ts @@ -0,0 +1,49 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class UpdateCategoryTitleAction extends ParentAction { + readonly categoryId: string + readonly newTitle: string + + constructor ({ categoryId, newTitle }: {categoryId: string, newTitle: string}) { + super() + + assertIdWithinFamily(categoryId) + + this.categoryId = categoryId + this.newTitle = newTitle + } + + serialize = (): SerializedUpdateCategoryTitleAction => ({ + type: 'UPDATE_CATEGORY_TITLE', + categoryId: this.categoryId, + newTitle: this.newTitle + }) + + static parse = ({ categoryId, newTitle }: SerializedUpdateCategoryTitleAction) => ( + new UpdateCategoryTitleAction({ categoryId, newTitle }) + ) +} + +export interface SerializedUpdateCategoryTitleAction { + type: 'UPDATE_CATEGORY_TITLE' + categoryId: string + newTitle: string +} diff --git a/src/action/updatedevicename.ts b/src/action/updatedevicename.ts new file mode 100644 index 0000000..a0f2805 --- /dev/null +++ b/src/action/updatedevicename.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class UpdateDeviceNameAction extends ParentAction { + readonly deviceId: string + readonly name: string + + constructor ({ deviceId, name }: { + deviceId: string + name: string + }) { + super() + + this.deviceId = deviceId + this.name = name + + assertIdWithinFamily(deviceId) + + if (name.trim().length === 0) { + throw new Error('new device name must not be blank') + } + } + + serialize = (): SerializedUpdateDeviceNameAction => ({ + type: 'UPDATE_DEVICE_NAME', + deviceId: this.deviceId, + name: this.name + }) + + static parse = ({ deviceId, name }: SerializedUpdateDeviceNameAction) => ( + new UpdateDeviceNameAction({ deviceId, name }) + ) +} + +export interface SerializedUpdateDeviceNameAction { + type: 'UPDATE_DEVICE_NAME' + deviceId: string + name: string +} diff --git a/src/action/updatedevicestatus.ts b/src/action/updatedevicestatus.ts new file mode 100644 index 0000000..fe5dcad --- /dev/null +++ b/src/action/updatedevicestatus.ts @@ -0,0 +1,79 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { NewPermissionStatus } from '../model/newpermissionstatus' +import { ProtectionLevel } from '../model/protectionlevel' +import { RuntimePermissionStatus } from '../model/runtimepermissionstatus' +import { AppLogicAction } from './basetypes' + +export class UpdateDeviceStatusAction extends AppLogicAction { + readonly newProtetionLevel?: ProtectionLevel + readonly newUsageStatsPermissionStatus?: RuntimePermissionStatus + readonly newNotificationAccessPermission?: NewPermissionStatus + readonly newAppVersion?: number + readonly didReboot: boolean + + constructor ({ newProtetionLevel, newUsageStatsPermissionStatus, newNotificationAccessPermission, newAppVersion, didReboot }: { + newProtetionLevel?: ProtectionLevel + newUsageStatsPermissionStatus?: RuntimePermissionStatus + newNotificationAccessPermission?: NewPermissionStatus + newAppVersion?: number + didReboot: boolean + }) { + super() + + if (newAppVersion !== undefined) { + if (!Number.isSafeInteger(newAppVersion) || (newAppVersion < 0)) { + throw new Error('invalid new ap version') + } + } + + this.newProtetionLevel = newProtetionLevel + this.newUsageStatsPermissionStatus = newUsageStatsPermissionStatus + this.newNotificationAccessPermission = newNotificationAccessPermission + this.newAppVersion = newAppVersion + this.didReboot = didReboot + } + + serialize = (): SerializedUpdateDeviceStatusAction => ({ + type: 'UPDATE_DEVICE_STATUS', + protectionLevel: this.newProtetionLevel, + usageStats: this.newUsageStatsPermissionStatus, + notificationAccess: this.newNotificationAccessPermission, + appVersion: this.newAppVersion, + didReboot: this.didReboot + }) + + static parse = ({ protectionLevel, usageStats, notificationAccess, appVersion, didReboot }: SerializedUpdateDeviceStatusAction) => ( + new UpdateDeviceStatusAction({ + newProtetionLevel: protectionLevel, + newUsageStatsPermissionStatus: usageStats, + newNotificationAccessPermission: notificationAccess, + newAppVersion: appVersion, + didReboot: !!didReboot + }) + ) +} + +export interface SerializedUpdateDeviceStatusAction { + type: 'UPDATE_DEVICE_STATUS' + protectionLevel?: ProtectionLevel + usageStats?: RuntimePermissionStatus + notificationAccess?: NewPermissionStatus + appVersion?: number + didReboot?: boolean +} diff --git a/src/action/updatenetworktimeverification.ts b/src/action/updatenetworktimeverification.ts new file mode 100644 index 0000000..17963ec --- /dev/null +++ b/src/action/updatenetworktimeverification.ts @@ -0,0 +1,55 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class UpdateNetworkTimeVerificationAction extends ParentAction { + readonly deviceId: string + readonly mode: 'disabled' | 'if possible' | 'enabled' + + constructor ({ deviceId, mode }: { + deviceId: string + mode: 'disabled' | 'if possible' | 'enabled' + }) { + super() + + assertIdWithinFamily(deviceId) + + this.deviceId = deviceId + this.mode = mode + } + + serialize = (): SerialiizedUpdateNetworkTimeVerificationAction => ({ + type: 'UPDATE_NETWORK_TIME_VERIFICATION', + deviceId: this.deviceId, + mode: this.mode + }) + + static parse = ({ deviceId, mode }: SerialiizedUpdateNetworkTimeVerificationAction) => ( + new UpdateNetworkTimeVerificationAction({ + deviceId, + mode + }) + ) +} + +export interface SerialiizedUpdateNetworkTimeVerificationAction { + type: 'UPDATE_NETWORK_TIME_VERIFICATION' + deviceId: string + mode: 'disabled' | 'if possible' | 'enabled' +} diff --git a/src/action/updateparentnotificationflags.ts b/src/action/updateparentnotificationflags.ts new file mode 100644 index 0000000..60ee9af --- /dev/null +++ b/src/action/updateparentnotificationflags.ts @@ -0,0 +1,65 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class UpdateParentNotificationFlagsAction extends ParentAction { + readonly parentId: string + readonly flags: number + readonly set: boolean + + constructor ({ parentId, flags, set }: { + parentId: string + flags: number + set: boolean + }) { + super() + + assertIdWithinFamily(parentId) + + if (!Number.isSafeInteger(flags)) { + throw new Error('flags must be an integer') + } + + if (flags < 0 || flags > 1) { + throw new Error('flags are out of the valid range') + } + + this.parentId = parentId + this.flags = flags + this.set = set + } + + serialize = (): SerializedUpdateParentNotificationFlagsAction => ({ + type: 'UPDATE_PARENT_NOTIFICATION_FLAGS', + parentId: this.parentId, + flags: this.flags, + set: this.set + }) + + static parse = ({ parentId, flags, set }: SerializedUpdateParentNotificationFlagsAction) => ( + new UpdateParentNotificationFlagsAction({ parentId, flags, set }) + ) +} + +export interface SerializedUpdateParentNotificationFlagsAction { + type: 'UPDATE_PARENT_NOTIFICATION_FLAGS' + parentId: string + flags: number + set: boolean +} diff --git a/src/action/updatetimelimitrule.ts b/src/action/updatetimelimitrule.ts new file mode 100644 index 0000000..d43fd2b --- /dev/null +++ b/src/action/updatetimelimitrule.ts @@ -0,0 +1,79 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' +import { ParentAction } from './basetypes' + +export class UpdateTimelimitRuleAction extends ParentAction { + readonly ruleId: string + readonly maximumTimeInMillis: number + readonly dayMask: number + readonly applyToExtraTimeUsage: boolean + + constructor ({ ruleId, maximumTimeInMillis, dayMask, applyToExtraTimeUsage }: { + ruleId: string + maximumTimeInMillis: number + dayMask: number + applyToExtraTimeUsage: boolean + }) { + super() + + this.ruleId = ruleId + this.maximumTimeInMillis = maximumTimeInMillis + this.dayMask = dayMask + this.applyToExtraTimeUsage = applyToExtraTimeUsage + + assertIdWithinFamily(ruleId) + + if (maximumTimeInMillis < 0 || (!Number.isSafeInteger(maximumTimeInMillis))) { + throw new Error('maximumTimeInMillis must be >= 0') + } + + if (!( + Number.isSafeInteger(dayMask) || + dayMask < 0 || + dayMask > (1 | 2 | 4 | 8 | 16 | 32 | 64) + )) { + throw new Error('invalid day mask') + } + } + + serialize = (): SerializedUpdateTimelimitRuleAction => ({ + type: 'UPDATE_TIMELIMIT_RULE', + ruleId: this.ruleId, + time: this.maximumTimeInMillis, + days: this.dayMask, + extraTime: this.applyToExtraTimeUsage + }) + + static parse = ({ ruleId, time, days, extraTime }: SerializedUpdateTimelimitRuleAction) => ( + new UpdateTimelimitRuleAction({ + ruleId, + maximumTimeInMillis: time, + dayMask: days, + applyToExtraTimeUsage: extraTime + }) + ) +} + +export interface SerializedUpdateTimelimitRuleAction { + type: 'UPDATE_TIMELIMIT_RULE' + ruleId: string + time: number + days: number + extraTime: boolean +} diff --git a/src/api/auth.ts b/src/api/auth.ts new file mode 100644 index 0000000..f0c841b --- /dev/null +++ b/src/api/auth.ts @@ -0,0 +1,130 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { json } from 'body-parser' +import { Router } from 'express' +import { OAuth2Client } from 'google-auth-library' +import { BadRequest } from 'http-errors' +import { Database } from '../database' +import { createAuthTokenByMailAddress } from '../function/authentication' +import { sendLoginCode, signInByMailCode } from '../function/authentication/login-by-mail' +import { + isSendMailLoginCodeRequest, + isSignInByMailCodeRequest, + isSignInWithGoogleRequest +} from './validator' + +const CLIENT_ID = process.env.GOOGLE_SIGN_IN_CLIENT_ID || '' +const client = new OAuth2Client(CLIENT_ID) + +const getMailByGoogleAuthToken = async (idToken: string) => { + const ticket = await client.verifyIdToken({ + idToken, + audience: CLIENT_ID + }) + + if (!ticket) { + throw new BadRequest() + } + + const payload = ticket.getPayload() + + if (!payload) { + throw new BadRequest() + } + + if (!payload.email_verified) { + throw new BadRequest() + } + + const mail = payload.email + + if (!mail) { + throw new BadRequest() + } + + if (!( + mail.endsWith('@gmail.com') || + mail.endsWith('@googlemail.com') + )) { + throw new BadRequest() + } + + return mail +} + +export const createAuthRouter = (database: Database) => { + const router = Router() + + router.post('/sign-in-with-google', json(), async (req, res, next) => { + try { + if (!isSignInWithGoogleRequest(req.body)) { + res.sendStatus(400) + return + } + + const { googleAuthToken } = req.body + + const mail = await getMailByGoogleAuthToken(googleAuthToken) + const mailAuthToken = await createAuthTokenByMailAddress({ mail, database }) + + res.json({ + mailAuthToken + }) + } catch (ex) { + next(ex) + } + }) + + router.post('/send-mail-login-code', json(), async (req, res, next) => { + try { + if (!isSendMailLoginCodeRequest(req.body)) { + throw new BadRequest() + } + + const { mailLoginToken } = await sendLoginCode({ + mail: req.body.mail, + locale: req.body.locale, + database + }) + + res.json({ mailLoginToken }) + } catch (ex) { + next(ex) + } + }) + + router.post('/sign-in-by-mail-code', json(), async (req, res, next) => { + try { + if (!isSignInByMailCodeRequest(req.body)) { + throw new BadRequest() + } + + const { mailAuthToken } = await signInByMailCode({ + receivedCode: req.body.receivedCode, + mailLoginToken: req.body.mailLoginToken, + database + }) + + res.json({ mailAuthToken }) + } catch (ex) { + next(ex) + } + }) + + return router +} diff --git a/src/api/child.ts b/src/api/child.ts new file mode 100644 index 0000000..f14ad7a --- /dev/null +++ b/src/api/child.ts @@ -0,0 +1,98 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { json } from 'body-parser' +import { Router } from 'express' +import { BadRequest } from 'http-errors' +import { Database } from '../database' +import { addChildDevice } from '../function/child/add-device' +import { logoutAtPrimaryDevice } from '../function/child/logout-at-primary-device' +import { setPrimaryDevice } from '../function/child/set-primary-device' +import { WebsocketApi } from '../websocket' +import { isRegisterChildDeviceRequest, isRequestWithAuthToken, isUpdatePrimaryDeviceRequest } from './validator' + +export const createChildRouter = ({ database, websocket }: { + database: Database, + websocket: WebsocketApi +}) => { + const router = Router() + + router.post('/add-device', json(), async (req, res, next) => { + try { + if (!isRegisterChildDeviceRequest(req.body)) { + throw new BadRequest() + } + + const { deviceAuthToken, deviceId } = await addChildDevice({ + request: req.body, + database, + websocket + }) + + res.json({ + deviceAuthToken, + ownDeviceId: deviceId + }) + } catch (ex) { + next(ex) + } + }) + + router.post('/update-primary-device', json(), async (req, res, next) => { + try { + if (!isUpdatePrimaryDeviceRequest(req.body)) { + throw new BadRequest() + } + + const response = await setPrimaryDevice({ + database, + deviceAuthToken: req.body.authToken, + currentUserId: req.body.currentUserId, + websocket, + action: req.body.action + }) + + res.json({ + status: response + }) + } catch (ex) { + next(ex) + } + }) + + router.post('/logout-at-primary-device', json(), async (req, res, next) => { + try { + if (!isRequestWithAuthToken(req.body)) { + throw new BadRequest() + } + + await logoutAtPrimaryDevice({ + deviceAuthToken: req.body.deviceAuthToken, + database, + websocket + }) + + res.json({ + ok: true + }) + } catch (ex) { + next(ex) + } + }) + + return router +} diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..3f9931e --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,50 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as express from 'express' +import { VisibleConnectedDevicesManager } from '../connected-devices' +import { Database } from '../database' +import { WebsocketApi } from '../websocket' +import { createAuthRouter } from './auth' +import { createChildRouter } from './child' +import { createParentRouter } from './parent' +import { createPurchaseRouter } from './purchase' +import { createSyncRouter } from './sync' + +export const createApi = ({ database, websocket, connectedDevicesManager }: { + database: Database + websocket: WebsocketApi + connectedDevicesManager: VisibleConnectedDevicesManager +}) => { + const app = express() + + app.disable('x-powered-by') + + app.get('/time', (req, res) => { + res.json({ + ms: Date.now() + }) + }) + + app.use('/auth', createAuthRouter(database)) + app.use('/child', createChildRouter({ database, websocket })) + app.use('/parent', createParentRouter({ database, websocket })) + app.use('/purchase', createPurchaseRouter({ database, websocket })) + app.use('/sync', createSyncRouter({ database, websocket, connectedDevicesManager })) + + return app +} diff --git a/src/api/parent.ts b/src/api/parent.ts new file mode 100644 index 0000000..ef534cd --- /dev/null +++ b/src/api/parent.ts @@ -0,0 +1,257 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { json } from 'body-parser' +import { Router } from 'express' +import { BadRequest, Unauthorized } from 'http-errors' +import { Database } from '../database' +import { removeDevice } from '../function/device/remove-device' +import { canRecoverPassword } from '../function/parent/can-recover-password' +import { createAddDeviceToken } from '../function/parent/create-add-device-token' +import { createFamily } from '../function/parent/create-family' +import { getStatusByMailToken } from '../function/parent/get-status-by-mail-address' +import { linkMailAddress } from '../function/parent/link-mail-address' +import { recoverParentPassword } from '../function/parent/recover-parent-password' +import { signInIntoFamily } from '../function/parent/sign-in-into-family' +import { WebsocketApi } from '../websocket' +import { + isCanRecoverPasswordRequest, isCreateFamilyByMailTokenRequest, + isCreateRegisterDeviceTokenRequest, isLinkParentMailAddressRequest, + isMailAuthTokenRequestBody, isRecoverParentPasswordRequest, + isRemoveDeviceRequest, isSignIntoFamilyRequest +} from './validator' + +export const createParentRouter = ({ database, websocket }: {database: Database, websocket: WebsocketApi}) => { + const router = Router() + + router.post('/get-status-by-mail-address', json(), async (req, res, next) => { + try { + if (!isMailAuthTokenRequestBody(req.body)) { + throw new BadRequest() + } + + const { mailAuthToken } = req.body + const { status, mail } = await getStatusByMailToken({ database, mailAuthToken }) + + res.json({ status, mail }) + } catch (ex) { + next(ex) + } + }) + + router.post('/create-family', json(), async (req, res, next) => { + try { + if (!isCreateFamilyByMailTokenRequest(req.body)) { + throw new BadRequest() + } + + const result = await createFamily({ + database, + firstParentDevice: req.body.parentDevice, + mailAuthToken: req.body.mailAuthToken, + password: req.body.parentPassword, + deviceName: req.body.deviceName, + parentName: req.body.parentName, + timeZone: req.body.timeZone + }) + + res.json({ + deviceAuthToken: result.deviceAuthToken, + ownDeviceId: result.deviceId + }) + } catch (ex) { + next(ex) + } + }) + + router.post('/sign-in-into-family', json(), async (req, res, next) => { + try { + if (!isSignIntoFamilyRequest(req.body)) { + throw new BadRequest() + } + + const result = await signInIntoFamily({ + database, + newDeviceInfo: req.body.parentDevice, + mailAuthToken: req.body.mailAuthToken, + deviceName: req.body.deviceName, + websocket + }) + + res.json({ + deviceAuthToken: result.deviceAuthToken, + ownDeviceId: result.deviceId + }) + } catch (ex) { + next(ex) + } + }) + + router.post('/can-recover-password', json(), async (req, res, next) => { + try { + if (!isCanRecoverPasswordRequest(req.body)) { + throw new BadRequest() + } + + const canRecover = await canRecoverPassword({ + database, + parentUserId: req.body.parentUserId, + mailAuthToken: req.body.mailAuthToken + }) + + res.json({ canRecover }) + } catch (ex) { + next(ex) + } + }) + + router.post('/recover-parent-password', json(), async (req, res, next) => { + try { + if (!isRecoverParentPasswordRequest(req.body)) { + throw new BadRequest() + } + + await recoverParentPassword({ + database, + websocket, + password: req.body.password, + mailAuthToken: req.body.mailAuthToken + }) + + res.json({ ok: true }) + } catch (ex) { + next(ex) + } + }) + + async function assertAuthValidAndReturnDeviceEntry ({ deviceAuthToken, parentId, secondPasswordHash }: { + deviceAuthToken: string + parentId: string + secondPasswordHash: string + }) { + const deviceEntry = await database.device.findOne({ + where: { + deviceAuthToken: deviceAuthToken + } + }) + + if (!deviceEntry) { + throw new Unauthorized() + } + + if (secondPasswordHash === 'device') { + if (!deviceEntry.isUserKeptSignedIn) { + throw new Unauthorized() + } + + const parentEntry = await database.user.findOne({ + where: { + familyId: deviceEntry.familyId, + type: 'parent', + userId: deviceEntry.currentUserId + } + }) + + if (!parentEntry) { + throw new Unauthorized() + } + } else { + const parentEntry = await database.user.findOne({ + where: { + familyId: deviceEntry.familyId, + type: 'parent', + userId: parentId, + secondPasswordHash: secondPasswordHash + } + }) + + if (!parentEntry) { + throw new Unauthorized() + } + } + + return deviceEntry + } + + router.post('/create-add-device-token', json(), async (req, res, next) => { + try { + if (!isCreateRegisterDeviceTokenRequest(req.body)) { + throw new BadRequest() + } + + const deviceEntry = await assertAuthValidAndReturnDeviceEntry({ + deviceAuthToken: req.body.deviceAuthToken, + parentId: req.body.parentId, + secondPasswordHash: req.body.parentPasswordSecondHash + }) + + const { token, deviceId } = await createAddDeviceToken({ familyId: deviceEntry.familyId, database }) + + res.json({ token, deviceId }) + } catch (ex) { + next(ex) + } + }) + + router.post('/link-mail-address', json(), async (req, res, next) => { + try { + if (!isLinkParentMailAddressRequest(req.body)) { + throw new BadRequest() + } + + await linkMailAddress({ + mailAuthToken: req.body.mailAuthToken, + deviceAuthToken: req.body.deviceAuthToken, + parentPasswordSecondHash: req.body.parentPasswordSecondHash, + parentUserId: req.body.parentUserId, + websocket, + database + }) + + res.json({ ok: true }) + } catch (ex) { + next(ex) + } + }) + + router.post('/remove-device', json(), async (req, res, next) => { + try { + if (!isRemoveDeviceRequest(req.body)) { + throw new BadRequest() + } + + const deviceEntry = await assertAuthValidAndReturnDeviceEntry({ + deviceAuthToken: req.body.deviceAuthToken, + parentId: req.body.parentUserId, + secondPasswordHash: req.body.parentPasswordSecondHash + }) + + await removeDevice({ + database, + familyId: deviceEntry.familyId, + deviceId: req.body.deviceId, + websocket + }) + + res.json({ ok: true }) + } catch (ex) { + next(ex) + } + }) + + return router +} diff --git a/src/api/purchase.ts b/src/api/purchase.ts new file mode 100644 index 0000000..fcf80b9 --- /dev/null +++ b/src/api/purchase.ts @@ -0,0 +1,129 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { json } from 'body-parser' +import { Router } from 'express' +import { BadRequest, Conflict, Unauthorized } from 'http-errors' +import { Database } from '../database' +import { + addPurchase, + areGooglePlayPaymentsPossible, + canDoNextPurchase, + isGooglePlayPurchaseSignatureValid, + requireFamilyEntry +} from '../function/purchase' +import { WebsocketApi } from '../websocket' +import { isCanDoPurchaseRequest, isFinishPurchaseByGooglePlayRequest } from './validator' + +export const createPurchaseRouter = ({ database, websocket }: { + database: Database + websocket: WebsocketApi +}) => { + const router = Router() + + router.post('/can-do-purchase', json(), async (req, res, next) => { + if (!areGooglePlayPaymentsPossible) { + res.json({ canDoPurchase: 'no because not supported by the server' }) + return + } + + try { + if (!isCanDoPurchaseRequest(req.body)) { + throw new BadRequest() + } + + const familyEntry = await requireFamilyEntry({ + database, + deviceAuthToken: req.body.deviceAuthToken + }) + + const result = canDoNextPurchase({ fullVersionUntil: parseInt(familyEntry.fullVersionUntil, 10) }) + + res.json({ + canDoPurchase: result ? 'yes' : 'no due to old purchase' + }) + } catch (ex) { + next(ex) + } + }) + + router.post('/finish-purchase-by-google-play', json(), async (req, res, next) => { + try { + if (!isFinishPurchaseByGooglePlayRequest(req.body)) { + throw new BadRequest() + } + + const deviceEntryUnsafe = await database.device.findOne({ + where: { + deviceAuthToken: req.body.deviceAuthToken + }, + attributes: ['familyId'] + }) + + if (!deviceEntryUnsafe) { + throw new Unauthorized() + } + + const deviceEntry = { + familyId: deviceEntryUnsafe.familyId + } + + if (!isGooglePlayPurchaseSignatureValid({ + receipt: req.body.receipt, + signature: req.body.signature + })) { + throw new Conflict() + } + + const receipt = JSON.parse(req.body.receipt) + + if (typeof receipt !== 'object') { + throw new Conflict() + } + + let type: 'month' | 'year' + + if (receipt.productId === 'premium_year_2018') { + type = 'year' + } else if (receipt.productId === 'premium_month_2018') { + type = 'month' + } else { + throw new Conflict() + } + + const orderId = receipt.orderId + + if (typeof orderId !== 'string') { + throw new Conflict() + } + + await addPurchase({ + database, + familyId: deviceEntry.familyId, + type, + transactionId: orderId, + websocket + }) + + res.json({ ok: true }) + } catch (ex) { + next(ex) + } + }) + + return router +} diff --git a/src/api/schema.ts b/src/api/schema.ts new file mode 100644 index 0000000..2343792 --- /dev/null +++ b/src/api/schema.ts @@ -0,0 +1,147 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { ClientDataStatus } from '../object/clientdatastatus' +import { optionalPasswordRegex, optionalSaltRegex } from '../util/password' + +export interface ClientPushChangesRequest { + deviceAuthToken: string + actions: Array<{ + encodedAction: string + sequenceNumber: number + integrity: string + type: 'appLogic' | 'parent' | 'child' + userId: string + }> +} + +export interface ClientPullChangesRequest { + deviceAuthToken: string + status: ClientDataStatus +} + +export interface SignInWithGoogleRequest { + googleAuthToken: string +} + +export interface MailAuthTokenRequestBody { + mailAuthToken: string +} + +export interface NewDeviceInfo { + model: string +} + +export interface ParentPassword { + hash: string + secondHash: string + secondSalt: string +} + +export const assertParentPasswordValid = (password: ParentPassword) => { + if (password.hash === '' || password.secondHash === '' || password.secondSalt === '') { + throw new Error('missing fields at parent password') + } + + if (!(optionalPasswordRegex.test(password.hash) && optionalPasswordRegex.test(password.secondHash) && optionalSaltRegex.test(password.secondSalt))) { + throw new Error('invalid parent password') + } +} + +export interface CreateFamilyByMailTokenRequest { + mailAuthToken: string + parentPassword: ParentPassword + parentDevice: NewDeviceInfo + deviceName: string + timeZone: string + parentName: string +} + +export interface SignIntoFamilyRequest { + mailAuthToken: string + parentDevice: NewDeviceInfo + deviceName: string +} + +export interface RecoverParentPasswordRequest { + mailAuthToken: string + password: ParentPassword +} + +export interface CanRecoverPasswordRequest { + mailAuthToken: string + parentUserId: string +} + +export interface RegisterChildDeviceRequest { + registerToken: string + childDevice: NewDeviceInfo + deviceName: string +} + +export interface CreateRegisterDeviceTokenRequest { + deviceAuthToken: string + parentId: string + parentPasswordSecondHash: string +} + +export interface CanDoPurchaseRequest { + type: 'googleplay' | 'any' + deviceAuthToken: string +} + +export interface FinishPurchaseByGooglePlayRequest { + deviceAuthToken: string + receipt: string + signature: string +} + +export interface LinkParentMailAddressRequest { + mailAuthToken: string + deviceAuthToken: string + parentUserId: string + parentPasswordSecondHash: string +} + +export interface UpdatePrimaryDeviceRequest { + action: 'set this device' | 'unset this device' + currentUserId: string + authToken: string +} + +export interface RemoveDeviceRequest { + deviceAuthToken: string + parentUserId: string + parentPasswordSecondHash: string + deviceId: string +} + +export interface RequestWithAuthToken { + deviceAuthToken: string +} + +export interface SendMailLoginCodeRequest { + mail: string + locale: string +} + +export interface SignInByMailCodeRequest { + mailLoginToken: string + receivedCode: string +} + +export { SerializedParentAction, SerializedChildAction, SerializedAppLogicAction } from '../action/serialization' diff --git a/src/api/sync.ts b/src/api/sync.ts new file mode 100644 index 0000000..414113b --- /dev/null +++ b/src/api/sync.ts @@ -0,0 +1,151 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { json } from 'body-parser' +import { Router } from 'express' +import { BadRequest, Unauthorized } from 'http-errors' +import { VisibleConnectedDevicesManager } from '../connected-devices' +import { Database } from '../database' +import { reportDeviceRemoved } from '../function/device/report-device-removed' +import { applyActionsFromDevice } from '../function/sync/apply-actions' +import { generateServerDataStatus } from '../function/sync/get-server-data-status' +import { WebsocketApi } from '../websocket' +import { isClientPullChangesRequest, isClientPushChangesRequest, isRequestWithAuthToken } from './validator' + +const getRoundedTimestampForLastConnectivity = () => { + const now = Date.now() + + return now - (now % (1000 * 60 * 60 * 12 /* 12 hours */)) +} + +export const createSyncRouter = ({ database, websocket, connectedDevicesManager }: { + database: Database + websocket: WebsocketApi + connectedDevicesManager: VisibleConnectedDevicesManager +}) => { + const router = Router() + + router.post('/push-actions', json(), async (req, res, next) => { + try { + if (!isClientPushChangesRequest(req.body)) { + throw new BadRequest() + } + + const { shouldDoFullSync } = await applyActionsFromDevice({ + request: req.body, + database, + websocket, + connectedDevicesManager + }) + + res.json({ + shouldDoFullSync + }) + } catch (ex) { + next(ex) + } + }) + + router.post('/pull-status', json(), async (req, res, next) => { + try { + const { body } = req + + if (!isClientPullChangesRequest(body)) { + throw new BadRequest() + } + + await database.transaction(async (transaction) => { + const deviceEntryUnsafe = await database.device.findOne({ + where: { + deviceAuthToken: body.deviceAuthToken + }, + attributes: ['familyId', 'lastConnectivity'], + transaction + }) + + if (!deviceEntryUnsafe) { + throw new Unauthorized() + } + + const { familyId, lastConnectivity } = deviceEntryUnsafe + const now = getRoundedTimestampForLastConnectivity() + + if (parseInt(lastConnectivity, 10) !== now) { + await database.device.update({ + lastConnectivity: now.toString(10) + }, { + where: { + deviceAuthToken: body.deviceAuthToken + }, + transaction + }) + } + + const serverStatus = await generateServerDataStatus({ + database, + familyId, + clientStatus: body.status, + transaction + }) + + res.json(serverStatus) + }) + } catch (ex) { + next(ex) + } + }) + + router.post('/report-removed', json(), async (req, res, next) => { + try { + if (!isRequestWithAuthToken(req.body)) { + throw new BadRequest() + } + + await reportDeviceRemoved({ + database, + deviceAuthToken: req.body.deviceAuthToken, + websocket + }) + + res.json({ ok: true }) + } catch (ex) { + next(ex) + } + }) + + router.post('/is-device-removed', json(), async (req, res, next) => { + try { + if (!isRequestWithAuthToken(req.body)) { + throw new BadRequest() + } + + const removedEntry = await database.oldDevice.findOne({ + where: { + deviceAuthToken: req.body.deviceAuthToken + } + }) + + res.json({ + isDeviceRemoved: !!removedEntry + }) + } catch (ex) { + next(ex) + } + }) + + return router +} diff --git a/src/api/validator.ts b/src/api/validator.ts new file mode 100644 index 0000000..7b2a808 --- /dev/null +++ b/src/api/validator.ts @@ -0,0 +1,1681 @@ +// tslint:disable +import { ClientPushChangesRequest, ClientPullChangesRequest, SignInWithGoogleRequest, MailAuthTokenRequestBody, CreateFamilyByMailTokenRequest, SignIntoFamilyRequest, RecoverParentPasswordRequest, CanRecoverPasswordRequest, RegisterChildDeviceRequest, SerializedParentAction, SerializedAppLogicAction, SerializedChildAction, CreateRegisterDeviceTokenRequest, CanDoPurchaseRequest, FinishPurchaseByGooglePlayRequest, LinkParentMailAddressRequest, UpdatePrimaryDeviceRequest, RemoveDeviceRequest, RequestWithAuthToken, SendMailLoginCodeRequest, SignInByMailCodeRequest } from './schema' +const Ajv = require('ajv') +const ajv = new Ajv() + +const definitions = { + "ClientDataStatus": { + "type": "object", + "properties": { + "devices": { + "type": "string" + }, + "apps": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "categories": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/CategoryDataStatus" + } + }, + "users": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "apps", + "categories", + "devices", + "users" + ] + }, + "CategoryDataStatus": { + "type": "object", + "properties": { + "base": { + "type": "string" + }, + "apps": { + "type": "string" + }, + "rules": { + "type": "string" + }, + "usedTime": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "apps", + "base", + "rules", + "usedTime" + ] + }, + "ParentPassword": { + "type": "object", + "properties": { + "hash": { + "type": "string" + }, + "secondHash": { + "type": "string" + }, + "secondSalt": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "hash", + "secondHash", + "secondSalt" + ] + }, + "NewDeviceInfo": { + "type": "object", + "properties": { + "model": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "model" + ] + }, + "SerializedAddCategoryAppsAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "ADD_CATEGORY_APPS" + ] + }, + "categoryId": { + "type": "string" + }, + "packageNames": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "packageNames", + "type" + ] + }, + "SerializedAddUserAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "ADD_USER" + ] + }, + "name": { + "type": "string" + }, + "userType": { + "enum": [ + "child", + "parent" + ], + "type": "string" + }, + "userId": { + "type": "string" + }, + "password": { + "$ref": "#/definitions/ParentPassword" + }, + "timeZone": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "name", + "timeZone", + "type", + "userId", + "userType" + ] + }, + "SerializedChangeParentPasswordAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "CHANGE_PARENT_PASSWORD" + ] + }, + "userId": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "secondSalt": { + "type": "string" + }, + "secondHashEncrypted": { + "type": "string" + }, + "integrity": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "hash", + "integrity", + "secondHashEncrypted", + "secondSalt", + "type", + "userId" + ] + }, + "SerializedCreateCategoryAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "CREATE_CATEGORY" + ] + }, + "childId": { + "type": "string" + }, + "categoryId": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "childId", + "title", + "type" + ] + }, + "SerializedCreateTimelimtRuleAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "CREATE_TIMELIMIT_RULE" + ] + }, + "rule": { + "$ref": "#/definitions/SerializedTimeLimitRule" + } + }, + "additionalProperties": false, + "required": [ + "rule", + "type" + ] + }, + "SerializedTimeLimitRule": { + "type": "object", + "properties": { + "ruleId": { + "type": "string" + }, + "categoryId": { + "type": "string" + }, + "time": { + "type": "number" + }, + "days": { + "type": "number" + }, + "extraTime": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "days", + "extraTime", + "ruleId", + "time" + ] + }, + "SerializedDeleteCategoryAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "DELETE_CATEGORY" + ] + }, + "categoryId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "type" + ] + }, + "SerializedDeleteTimeLimitRuleAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "DELETE_TIMELIMIT_RULE" + ] + }, + "ruleId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ruleId", + "type" + ] + }, + "SerializedIgnoreManipulationAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "IGNORE_MANIPULATION" + ] + }, + "deviceId": { + "type": "string" + }, + "admin": { + "type": "boolean" + }, + "adminA": { + "type": "boolean" + }, + "downgrade": { + "type": "boolean" + }, + "notification": { + "type": "boolean" + }, + "usageStats": { + "type": "boolean" + }, + "hadManipulation": { + "type": "boolean" + }, + "reboot": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "admin", + "adminA", + "deviceId", + "downgrade", + "hadManipulation", + "notification", + "type", + "usageStats" + ] + }, + "SerializedIncrementCategoryExtraTimeAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "INCREMENT_CATEGORY_EXTRATIME" + ] + }, + "categoryId": { + "type": "string" + }, + "addedExtraTime": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "addedExtraTime", + "categoryId", + "type" + ] + }, + "SerializedRemoveCategoryAppsAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "REMOVE_CATEGORY_APPS" + ] + }, + "categoryId": { + "type": "string" + }, + "packageNames": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "packageNames", + "type" + ] + }, + "SerializedRemoveUserAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "REMOVE_USER" + ] + }, + "userId": { + "type": "string" + }, + "authentication": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "type", + "userId" + ] + }, + "SerializedRenameChildAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "RENAME_CHILD" + ] + }, + "childId": { + "type": "string" + }, + "newName": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "childId", + "newName", + "type" + ] + }, + "SerializedSetCategoryExtraTimeAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_CATEGORY_EXTRA_TIME" + ] + }, + "categoryId": { + "type": "string" + }, + "newExtraTime": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "newExtraTime", + "type" + ] + }, + "SerializedSetCategoryForUnassignedAppsAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_CATEGORY_FOR_UNASSIGNED_APPS" + ] + }, + "childId": { + "type": "string" + }, + "categoryId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "childId", + "type" + ] + }, + "SerializedSetChildPasswordAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_CHILD_PASSWORD" + ] + }, + "childId": { + "type": "string" + }, + "newPassword": { + "$ref": "#/definitions/ParentPassword" + } + }, + "additionalProperties": false, + "required": [ + "childId", + "newPassword", + "type" + ] + }, + "SerializedSetConsiderRebootManipulationAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_CONSIDER_REBOOT_MANIPULATION" + ] + }, + "deviceId": { + "type": "string" + }, + "enable": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "deviceId", + "enable", + "type" + ] + }, + "SerializedSetDeviceDefaultUserAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_DEVICE_DEFAULT_USER" + ] + }, + "deviceId": { + "type": "string" + }, + "defaultUserId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "defaultUserId", + "deviceId", + "type" + ] + }, + "SerializedSetDeviceDefaultUserTimeoutAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_DEVICE_DEFAULT_USER_TIMEOUT" + ] + }, + "deviceId": { + "type": "string" + }, + "timeout": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "deviceId", + "timeout", + "type" + ] + }, + "SerializedSetDeviceUserAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_DEVICE_USER" + ] + }, + "deviceId": { + "type": "string" + }, + "userId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceId", + "type", + "userId" + ] + }, + "SerializedSetKeepSignedInAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_KEEP_SIGNED_IN" + ] + }, + "deviceId": { + "type": "string" + }, + "keepSignedIn": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "deviceId", + "keepSignedIn", + "type" + ] + }, + "SerializedSetParentCategoryAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_PARENT_CATEGORY" + ] + }, + "categoryId": { + "type": "string" + }, + "parentCategory": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "parentCategory", + "type" + ] + }, + "SerializedSetRelaxPrimaryDeviceAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_RELAX_PRIMARY_DEVICE" + ] + }, + "userId": { + "type": "string" + }, + "relax": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "relax", + "type", + "userId" + ] + }, + "SerializedSetSendDeviceConnected": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_SEND_DEVICE_CONNECTED" + ] + }, + "deviceId": { + "type": "string" + }, + "enable": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "deviceId", + "enable", + "type" + ] + }, + "SerializedSetUserDisableLimitsUntilAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_USER_DISABLE_LIMITS_UNTIL" + ] + }, + "childId": { + "type": "string" + }, + "time": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "childId", + "time", + "type" + ] + }, + "SerializedSetUserTimezoneAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SET_USER_TIMEZONE" + ] + }, + "userId": { + "type": "string" + }, + "timezone": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "timezone", + "type", + "userId" + ] + }, + "SerializedUpdateCategoryBlockedTimesAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "UPDATE_CATEGORY_BLOCKED_TIMES" + ] + }, + "categoryId": { + "type": "string" + }, + "times": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "times", + "type" + ] + }, + "SerializedUpdateCategoryTemporarilyBlockedAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "UPDATE_CATEGORY_TEMPORARILY_BLOCKED" + ] + }, + "categoryId": { + "type": "string" + }, + "blocked": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "blocked", + "categoryId", + "type" + ] + }, + "SerializedUpdateCategoryTitleAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "UPDATE_CATEGORY_TITLE" + ] + }, + "categoryId": { + "type": "string" + }, + "newTitle": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "newTitle", + "type" + ] + }, + "SerializedUpdateDeviceNameAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "UPDATE_DEVICE_NAME" + ] + }, + "deviceId": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceId", + "name", + "type" + ] + }, + "SerialiizedUpdateNetworkTimeVerificationAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "UPDATE_NETWORK_TIME_VERIFICATION" + ] + }, + "deviceId": { + "type": "string" + }, + "mode": { + "enum": [ + "disabled", + "enabled", + "if possible" + ], + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceId", + "mode", + "type" + ] + }, + "SerializedUpdateParentNotificationFlagsAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "UPDATE_PARENT_NOTIFICATION_FLAGS" + ] + }, + "parentId": { + "type": "string" + }, + "flags": { + "type": "number" + }, + "set": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "flags", + "parentId", + "set", + "type" + ] + }, + "SerializedUpdateTimelimitRuleAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "UPDATE_TIMELIMIT_RULE" + ] + }, + "ruleId": { + "type": "string" + }, + "time": { + "type": "number" + }, + "days": { + "type": "number" + }, + "extraTime": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "days", + "extraTime", + "ruleId", + "time", + "type" + ] + }, + "SerializedAddInstalledAppsAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "ADD_INSTALLED_APPS" + ] + }, + "apps": { + "type": "array", + "items": { + "$ref": "#/definitions/SerializedInstalledApp" + } + } + }, + "additionalProperties": false, + "required": [ + "apps", + "type" + ] + }, + "SerializedInstalledApp": { + "type": "object", + "properties": { + "packageName": { + "type": "string" + }, + "title": { + "type": "string" + }, + "isLaunchable": { + "type": "boolean" + }, + "recommendation": { + "$ref": "#/definitions/AppRecommendation" + } + }, + "additionalProperties": false, + "required": [ + "isLaunchable", + "packageName", + "recommendation", + "title" + ] + }, + "AppRecommendation": { + "enum": [ + "blacklist", + "none", + "whitelist" + ], + "type": "string" + }, + "SerializedAddUsedTimeAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "ADD_USED_TIME" + ] + }, + "categoryId": { + "type": "string" + }, + "day": { + "type": "number" + }, + "timeToAdd": { + "type": "number" + }, + "extraTimeToSubtract": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "categoryId", + "day", + "extraTimeToSubtract", + "timeToAdd", + "type" + ] + }, + "SerializedRemoveInstalledAppsAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "REMOVE_INSTALLED_APPS" + ] + }, + "packageNames": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false, + "required": [ + "packageNames", + "type" + ] + }, + "SerializedSignOutAtDeviceAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "SIGN_OUT_AT_DEVICE" + ] + } + }, + "additionalProperties": false, + "required": [ + "type" + ] + }, + "SerialiezdTriedDisablingDeviceAdminAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "TRIED_DISABLING_DEVICE_ADMIN" + ] + } + }, + "additionalProperties": false, + "required": [ + "type" + ] + }, + "SerializedUpdateDeviceStatusAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "UPDATE_DEVICE_STATUS" + ] + }, + "protectionLevel": { + "enum": [ + "device owner", + "none", + "password device admin", + "simple device admin" + ], + "type": "string" + }, + "usageStats": { + "enum": [ + "granted", + "not granted", + "not required" + ], + "type": "string" + }, + "notificationAccess": { + "enum": [ + "granted", + "not granted", + "not supported" + ], + "type": "string" + }, + "appVersion": { + "type": "number" + }, + "didReboot": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "type" + ] + }, + "SerializedChildChangePasswordAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "CHILD_CHANGE_PASSWORD" + ] + }, + "password": { + "$ref": "#/definitions/ParentPassword" + } + }, + "additionalProperties": false, + "required": [ + "password", + "type" + ] + }, + "SerializedChildSignInAction": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "CHILD_SIGN_IN" + ] + } + }, + "additionalProperties": false, + "required": [ + "type" + ] + } +} + +export const isClientPushChangesRequest: (value: object) => value is ClientPushChangesRequest = ajv.compile({ + "type": "object", + "properties": { + "deviceAuthToken": { + "type": "string" + }, + "actions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "encodedAction": { + "type": "string" + }, + "sequenceNumber": { + "type": "number" + }, + "integrity": { + "type": "string" + }, + "type": { + "enum": [ + "appLogic", + "child", + "parent" + ], + "type": "string" + }, + "userId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "encodedAction", + "integrity", + "sequenceNumber", + "type", + "userId" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "actions", + "deviceAuthToken" + ], + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isClientPullChangesRequest: (value: object) => value is ClientPullChangesRequest = ajv.compile({ + "type": "object", + "properties": { + "deviceAuthToken": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/ClientDataStatus" + } + }, + "additionalProperties": false, + "required": [ + "deviceAuthToken", + "status" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isSignInWithGoogleRequest: (value: object) => value is SignInWithGoogleRequest = ajv.compile({ + "type": "object", + "properties": { + "googleAuthToken": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "googleAuthToken" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isMailAuthTokenRequestBody: (value: object) => value is MailAuthTokenRequestBody = ajv.compile({ + "type": "object", + "properties": { + "mailAuthToken": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "mailAuthToken" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isCreateFamilyByMailTokenRequest: (value: object) => value is CreateFamilyByMailTokenRequest = ajv.compile({ + "type": "object", + "properties": { + "mailAuthToken": { + "type": "string" + }, + "parentPassword": { + "$ref": "#/definitions/ParentPassword" + }, + "parentDevice": { + "$ref": "#/definitions/NewDeviceInfo" + }, + "deviceName": { + "type": "string" + }, + "timeZone": { + "type": "string" + }, + "parentName": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceName", + "mailAuthToken", + "parentDevice", + "parentName", + "parentPassword", + "timeZone" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isSignIntoFamilyRequest: (value: object) => value is SignIntoFamilyRequest = ajv.compile({ + "type": "object", + "properties": { + "mailAuthToken": { + "type": "string" + }, + "parentDevice": { + "$ref": "#/definitions/NewDeviceInfo" + }, + "deviceName": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceName", + "mailAuthToken", + "parentDevice" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isRecoverParentPasswordRequest: (value: object) => value is RecoverParentPasswordRequest = ajv.compile({ + "type": "object", + "properties": { + "mailAuthToken": { + "type": "string" + }, + "password": { + "$ref": "#/definitions/ParentPassword" + } + }, + "additionalProperties": false, + "required": [ + "mailAuthToken", + "password" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isCanRecoverPasswordRequest: (value: object) => value is CanRecoverPasswordRequest = ajv.compile({ + "type": "object", + "properties": { + "mailAuthToken": { + "type": "string" + }, + "parentUserId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "mailAuthToken", + "parentUserId" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isRegisterChildDeviceRequest: (value: object) => value is RegisterChildDeviceRequest = ajv.compile({ + "type": "object", + "properties": { + "registerToken": { + "type": "string" + }, + "childDevice": { + "$ref": "#/definitions/NewDeviceInfo" + }, + "deviceName": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "childDevice", + "deviceName", + "registerToken" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isSerializedParentAction: (value: object) => value is SerializedParentAction = ajv.compile({ + "anyOf": [ + { + "$ref": "#/definitions/SerializedAddCategoryAppsAction" + }, + { + "$ref": "#/definitions/SerializedAddUserAction" + }, + { + "$ref": "#/definitions/SerializedChangeParentPasswordAction" + }, + { + "$ref": "#/definitions/SerializedCreateCategoryAction" + }, + { + "$ref": "#/definitions/SerializedCreateTimelimtRuleAction" + }, + { + "$ref": "#/definitions/SerializedDeleteCategoryAction" + }, + { + "$ref": "#/definitions/SerializedDeleteTimeLimitRuleAction" + }, + { + "$ref": "#/definitions/SerializedIgnoreManipulationAction" + }, + { + "$ref": "#/definitions/SerializedIncrementCategoryExtraTimeAction" + }, + { + "$ref": "#/definitions/SerializedRemoveCategoryAppsAction" + }, + { + "$ref": "#/definitions/SerializedRemoveUserAction" + }, + { + "$ref": "#/definitions/SerializedRenameChildAction" + }, + { + "$ref": "#/definitions/SerializedSetCategoryExtraTimeAction" + }, + { + "$ref": "#/definitions/SerializedSetCategoryForUnassignedAppsAction" + }, + { + "$ref": "#/definitions/SerializedSetChildPasswordAction" + }, + { + "$ref": "#/definitions/SerializedSetConsiderRebootManipulationAction" + }, + { + "$ref": "#/definitions/SerializedSetDeviceDefaultUserAction" + }, + { + "$ref": "#/definitions/SerializedSetDeviceDefaultUserTimeoutAction" + }, + { + "$ref": "#/definitions/SerializedSetDeviceUserAction" + }, + { + "$ref": "#/definitions/SerializedSetKeepSignedInAction" + }, + { + "$ref": "#/definitions/SerializedSetParentCategoryAction" + }, + { + "$ref": "#/definitions/SerializedSetRelaxPrimaryDeviceAction" + }, + { + "$ref": "#/definitions/SerializedSetSendDeviceConnected" + }, + { + "$ref": "#/definitions/SerializedSetUserDisableLimitsUntilAction" + }, + { + "$ref": "#/definitions/SerializedSetUserTimezoneAction" + }, + { + "$ref": "#/definitions/SerializedUpdateCategoryBlockedTimesAction" + }, + { + "$ref": "#/definitions/SerializedUpdateCategoryTemporarilyBlockedAction" + }, + { + "$ref": "#/definitions/SerializedUpdateCategoryTitleAction" + }, + { + "$ref": "#/definitions/SerializedUpdateDeviceNameAction" + }, + { + "$ref": "#/definitions/SerialiizedUpdateNetworkTimeVerificationAction" + }, + { + "$ref": "#/definitions/SerializedUpdateParentNotificationFlagsAction" + }, + { + "$ref": "#/definitions/SerializedUpdateTimelimitRuleAction" + } + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isSerializedAppLogicAction: (value: object) => value is SerializedAppLogicAction = ajv.compile({ + "anyOf": [ + { + "$ref": "#/definitions/SerializedAddInstalledAppsAction" + }, + { + "$ref": "#/definitions/SerializedAddUsedTimeAction" + }, + { + "$ref": "#/definitions/SerializedRemoveInstalledAppsAction" + }, + { + "$ref": "#/definitions/SerializedSignOutAtDeviceAction" + }, + { + "$ref": "#/definitions/SerialiezdTriedDisablingDeviceAdminAction" + }, + { + "$ref": "#/definitions/SerializedUpdateDeviceStatusAction" + } + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isSerializedChildAction: (value: object) => value is SerializedChildAction = ajv.compile({ + "anyOf": [ + { + "$ref": "#/definitions/SerializedChildChangePasswordAction" + }, + { + "$ref": "#/definitions/SerializedChildSignInAction" + } + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isCreateRegisterDeviceTokenRequest: (value: object) => value is CreateRegisterDeviceTokenRequest = ajv.compile({ + "type": "object", + "properties": { + "deviceAuthToken": { + "type": "string" + }, + "parentId": { + "type": "string" + }, + "parentPasswordSecondHash": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceAuthToken", + "parentId", + "parentPasswordSecondHash" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isCanDoPurchaseRequest: (value: object) => value is CanDoPurchaseRequest = ajv.compile({ + "type": "object", + "properties": { + "type": { + "enum": [ + "any", + "googleplay" + ], + "type": "string" + }, + "deviceAuthToken": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceAuthToken", + "type" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isFinishPurchaseByGooglePlayRequest: (value: object) => value is FinishPurchaseByGooglePlayRequest = ajv.compile({ + "type": "object", + "properties": { + "deviceAuthToken": { + "type": "string" + }, + "receipt": { + "type": "string" + }, + "signature": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceAuthToken", + "receipt", + "signature" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isLinkParentMailAddressRequest: (value: object) => value is LinkParentMailAddressRequest = ajv.compile({ + "type": "object", + "properties": { + "mailAuthToken": { + "type": "string" + }, + "deviceAuthToken": { + "type": "string" + }, + "parentUserId": { + "type": "string" + }, + "parentPasswordSecondHash": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceAuthToken", + "mailAuthToken", + "parentPasswordSecondHash", + "parentUserId" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isUpdatePrimaryDeviceRequest: (value: object) => value is UpdatePrimaryDeviceRequest = ajv.compile({ + "type": "object", + "properties": { + "action": { + "enum": [ + "set this device", + "unset this device" + ], + "type": "string" + }, + "currentUserId": { + "type": "string" + }, + "authToken": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "action", + "authToken", + "currentUserId" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isRemoveDeviceRequest: (value: object) => value is RemoveDeviceRequest = ajv.compile({ + "type": "object", + "properties": { + "deviceAuthToken": { + "type": "string" + }, + "parentUserId": { + "type": "string" + }, + "parentPasswordSecondHash": { + "type": "string" + }, + "deviceId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceAuthToken", + "deviceId", + "parentPasswordSecondHash", + "parentUserId" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isRequestWithAuthToken: (value: object) => value is RequestWithAuthToken = ajv.compile({ + "type": "object", + "properties": { + "deviceAuthToken": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "deviceAuthToken" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isSendMailLoginCodeRequest: (value: object) => value is SendMailLoginCodeRequest = ajv.compile({ + "type": "object", + "properties": { + "mail": { + "type": "string" + }, + "locale": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "locale", + "mail" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) +export const isSignInByMailCodeRequest: (value: object) => value is SignInByMailCodeRequest = ajv.compile({ + "type": "object", + "properties": { + "mailLoginToken": { + "type": "string" + }, + "receivedCode": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "mailLoginToken", + "receivedCode" + ], + "definitions": definitions, + "$schema": "http://json-schema.org/draft-07/schema#" +}) diff --git a/src/connected-devices/index.ts b/src/connected-devices/index.ts new file mode 100644 index 0000000..85b71ff --- /dev/null +++ b/src/connected-devices/index.ts @@ -0,0 +1,214 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { EventEmitter } from 'events' +import { Database } from '../database' + +export class ConnectedDevicesManager { + private deviceConnectionCounters = new Map() + // event name = key, value = boolean/ isConnected + deviceConnectionChangeEmitter = new EventEmitter() + + static buildKey = ({ familyId, deviceId }: {familyId: string, deviceId: string}) => `${familyId}_${deviceId}` + + reportDeviceConnected = ({ key }: {key: string}) => { + const oldValue = this.deviceConnectionCounters.get(key) || 0 + const newValue = oldValue + 1 + + this.deviceConnectionCounters.set(key, newValue) + + if (oldValue === 0) { + this.deviceConnectionChangeEmitter.emit(key, true) + } + } + + reportDeviceDisconnected = ({ key }: {key: string}) => { + const oldValue = this.deviceConnectionCounters.get(key) || 0 + const newValue = Math.max(0, oldValue - 1) + + if (newValue === 0) { + this.deviceConnectionCounters.delete(key) + } else { + this.deviceConnectionCounters.set(key, newValue) + } + + if (oldValue !== 0 && newValue === 0) { + this.deviceConnectionChangeEmitter.emit(key, false) + } + } + + isDeviceConnected = ({ key }: {key: string}) => ( + this.deviceConnectionCounters.has(key) && + (this.deviceConnectionCounters.get(key) !== 0) + ) +} + +export class VisibleConnectedDevicesManager { + connectedDevicesManager = new ConnectedDevicesManager() + private database: Database + + constructor ({ database }: { + database: Database + }) { + this.database = database + } + + private familyDeviceShareConnectedChangeEmitter = new EventEmitter() + + notifyShareConnectedChanged = ({ familyId, deviceId, showDeviceConnected }: { familyId: string, deviceId: string, showDeviceConnected: boolean }) => { + this.familyDeviceShareConnectedChangeEmitter.emit(familyId, { deviceId, showDeviceConnected }) + } + + observeConnectedDevicesOfFamily = ({ familyId, listener }: { + familyId: string + listener: (deviceIds: Array) => void + }): { + shutdown: () => void + } => { + let observesDevices = new Set() + let devicesWithSharingEnabled = new Set() + let connectedDevices = new Set() + let sentConnectedDevices = new Set() + let hasShutDown = false + let shutdownHooks: Array<() => void> = [] + + const shutdown = () => { + hasShutDown = true + + shutdownHooks.forEach((hook) => hook()) + } + + const sendStatus = () => { + if (hasShutDown) { + return + } + + let result: Array = [] + + sentConnectedDevices.forEach((deviceId) => result.push(deviceId)) + + listener(result) + } + + const addDevice = ({ deviceId, showDeviceConnected }: { + deviceId: string + showDeviceConnected: boolean + }) => { + const key = ConnectedDevicesManager.buildKey({ familyId, deviceId }) + const isConnected = this.connectedDevicesManager.isDeviceConnected({ key }) + + if (!observesDevices.has(deviceId)) { + observesDevices.add(deviceId) + + if (isConnected) { + connectedDevices.add(deviceId) + } + + if (!hasShutDown) { + const listener = (nowConnected: boolean) => { + const oldConnected = connectedDevices.has(deviceId) + + if (oldConnected !== nowConnected) { + if (nowConnected) { + connectedDevices.add(deviceId) + + if (devicesWithSharingEnabled.has(deviceId)) { + sentConnectedDevices.add(deviceId) + sendStatus() + } + } else { + connectedDevices.delete(deviceId) + + if (devicesWithSharingEnabled.has(deviceId)) { + sentConnectedDevices.delete(deviceId) + sendStatus() + } + } + } + } + + this.connectedDevicesManager.deviceConnectionChangeEmitter.addListener(key, listener) + + shutdownHooks.push(() => { + this.connectedDevicesManager.deviceConnectionChangeEmitter.removeListener(key, listener) + }) + } + } + + if (showDeviceConnected) { + if (!devicesWithSharingEnabled.has(deviceId)) { + devicesWithSharingEnabled.add(deviceId) + } + + if (isConnected) { + if (!sentConnectedDevices.has(deviceId)) { + sentConnectedDevices.add(deviceId) + sendStatus() + } + } + } else { + if (devicesWithSharingEnabled.has(deviceId)) { + devicesWithSharingEnabled.delete(deviceId) + + if (sentConnectedDevices.has(deviceId)) { + sentConnectedDevices.delete(deviceId) + sendStatus() + } + } + } + } + + // add all current devices + ;(async () => { + const devicesUnsafe = await this.database.device.findAll({ + where: { + familyId + }, + attributes: [ + 'deviceId', + 'showDeviceConnected' + ] + }) + + const devices = devicesUnsafe.map(({ deviceId, showDeviceConnected }) => ({ + deviceId, showDeviceConnected + })) + + devices.forEach(({ deviceId, showDeviceConnected }) => { + addDevice({ deviceId, showDeviceConnected }) + }) + })().catch((ex) => { /* ignore */ }) + + { + // add all new devices + apply changes of sharing + const listener = ({ deviceId, showDeviceConnected }: { + deviceId: string + showDeviceConnected: boolean + }) => { + addDevice({ + deviceId, + showDeviceConnected + }) + } + + this.familyDeviceShareConnectedChangeEmitter.addListener(familyId, listener) + shutdownHooks.push(() => this.familyDeviceShareConnectedChangeEmitter.removeListener(familyId, listener)) + } + + return { shutdown } + } +} diff --git a/src/database/adddevicetoken.ts b/src/database/adddevicetoken.ts new file mode 100644 index 0000000..466612e --- /dev/null +++ b/src/database/adddevicetoken.ts @@ -0,0 +1,42 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { familyIdColumn, idWithinFamilyColumn, labelColumn, timestampColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface AddDeviceTokenAttributes { + token: string + familyId: string + deviceId: string + createdAt: string +} + +export type AddDeviceTokenInstance = Sequelize.Instance & AddDeviceTokenAttributes +export type AddDeviceTokenModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + token: { + ...labelColumn, + primaryKey: true + }, + familyId: { ...familyIdColumn }, + deviceId: { ...idWithinFamilyColumn }, + createdAt: { ...timestampColumn } +} + +export const createAddDeviceTokenModel = (sequelize: Sequelize.Sequelize): AddDeviceTokenModel => sequelize.define('AddDeviceToken', attributes) diff --git a/src/database/app.ts b/src/database/app.ts new file mode 100644 index 0000000..295fb11 --- /dev/null +++ b/src/database/app.ts @@ -0,0 +1,57 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { AppRecommendation, appRecommendationValues } from '../model/apprecommendation' +import { booleanColumn, createEnumColumn, familyIdColumn, idWithinFamilyColumn, optionalLabelColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface AppAttributes { + familyId: string + deviceId: string + packageName: string + title: string + isLaunchable: boolean + recommendation: AppRecommendation +} + +export type AppInstance = Sequelize.Instance & AppAttributes +export type AppModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + familyId: { + ...familyIdColumn, + primaryKey: true + }, + deviceId: { + ...idWithinFamilyColumn, + primaryKey: true + }, + packageName: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: true + }, + primaryKey: true + }, + title: { ...optionalLabelColumn }, + isLaunchable: { ...booleanColumn }, + recommendation: createEnumColumn(appRecommendationValues) +} + +export const createAppModel = (sequelize: Sequelize.Sequelize): AppModel => sequelize.define('App', attributes) diff --git a/src/database/authtoken.ts b/src/database/authtoken.ts new file mode 100644 index 0000000..a11195b --- /dev/null +++ b/src/database/authtoken.ts @@ -0,0 +1,46 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { authTokenColumn, timestampColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface AuthTokenAttributes { + token: string + mail: string + createdAt: string +} + +export type AuthTokenInstance = Sequelize.Instance & AuthTokenAttributes +export type AuthTokenModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + token: { + ...authTokenColumn, + primaryKey: true + }, + mail: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: true + } + }, + createdAt: { ...timestampColumn } +} + +export const createAuthtokenModel = (sequelize: Sequelize.Sequelize): AuthTokenModel => sequelize.define('AuthToken', attributes) diff --git a/src/database/category.ts b/src/database/category.ts new file mode 100644 index 0000000..f1f9d52 --- /dev/null +++ b/src/database/category.ts @@ -0,0 +1,90 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { serializedBitmaskRegex } from '../util/bitmask' +import { booleanColumn, familyIdColumn, idWithinFamilyColumn, labelColumn, optionalIdWithinFamilyColumn, versionColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface CategoryAttributesVersion1 { + familyId: string + categoryId: string + childId: string + title: string + blockedMinutesInWeek: string + extraTimeInMillis: number + temporarilyBlocked: boolean + baseVersion: string + assignedAppsVersion: string + timeLimitRulesVersion: string + usedTimesVersion: string +} + +export interface CategoryAttributesVersion2 { + parentCategoryId: string +} + +export type CategoryAttributes = CategoryAttributesVersion1 & CategoryAttributesVersion2 + +export type CategoryInstance = Sequelize.Instance & CategoryAttributes +export type CategoryModel = Sequelize.Model + +export const attributesVersion1: SequelizeAttributes = { + familyId: { + ...familyIdColumn, + primaryKey: true + }, + categoryId: { + ...idWithinFamilyColumn, + primaryKey: true + }, + childId: { ...idWithinFamilyColumn }, + title: { ...labelColumn }, + blockedMinutesInWeek: { + type: Sequelize.TEXT, + allowNull: false, + validate: { + is: serializedBitmaskRegex + } + }, + extraTimeInMillis: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + min: 0 + } + }, + temporarilyBlocked: { ...booleanColumn }, + baseVersion: { ...versionColumn }, + assignedAppsVersion: { ...versionColumn }, + timeLimitRulesVersion: { ...versionColumn }, + usedTimesVersion: { ...versionColumn } +} + +export const attributesVersion2: SequelizeAttributes = { + parentCategoryId: { + ...optionalIdWithinFamilyColumn, + defaultValue: '' + } +} + +export const attributes: SequelizeAttributes = { + ...attributesVersion1, + ...attributesVersion2 +} + +export const createCategoryModel = (sequelize: Sequelize.Sequelize): CategoryModel => sequelize.define('Category', attributes) diff --git a/src/database/categoryapp.ts b/src/database/categoryapp.ts new file mode 100644 index 0000000..bc88c1b --- /dev/null +++ b/src/database/categoryapp.ts @@ -0,0 +1,50 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { familyIdColumn, idWithinFamilyColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface CategoryAppAttributes { + familyId: string + categoryId: string + packageName: string +} + +export type CategoryAppInstance = Sequelize.Instance & CategoryAppAttributes +export type CategoryAppModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + familyId: { + ...familyIdColumn, + primaryKey: true + }, + categoryId: { + ...idWithinFamilyColumn, + primaryKey: true + }, + packageName: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: true + }, + primaryKey: true + } +} + +export const createCategoryAppModel = (sequelize: Sequelize.Sequelize): CategoryAppModel => sequelize.define('CategoryApp', attributes) diff --git a/src/database/columns.ts b/src/database/columns.ts new file mode 100644 index 0000000..93f2616 --- /dev/null +++ b/src/database/columns.ts @@ -0,0 +1,97 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' + +export const familyIdColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.STRING(10), + allowNull: false, + validate: { + notEmpty: true, + is: /^[a-zA-Z0-9]{10}$/ + } +} + +export const idWithinFamilyColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.STRING(6), + allowNull: false, + validate: { + notEmpty: true, + is: /^[a-zA-Z0-9]{6}$/ + } +} + +export const optionalIdWithinFamilyColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.STRING(6), + allowNull: false, + validate: { + is: /^([a-zA-Z0-9]{6})?$/ + } +} + +export const versionColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.STRING(4), + allowNull: false, + validate: { + notEmpty: true, + is: /^[a-zA-Z0-9]{4}$/ + } +} +export const labelColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: true + } +} + +export const optionalLabelColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.STRING, + allowNull: false +} + +export const createEnumColumn = (possibleValues: Array): Sequelize.DefineAttributeColumnOptions => ({ + type: Sequelize.STRING, + allowNull: false, + validate: { + isIn: [possibleValues], + notEmpty: true + } +}) + +// warning: this results in an string field +export const timestampColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.BIGINT, + allowNull: false, + validate: { + min: 0 + } +} + +export const booleanColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.BOOLEAN, + allowNull: false +} + +export const authTokenColumn: Sequelize.DefineAttributeColumnOptions = { + type: Sequelize.STRING(32), + allowNull: false, + validate: { + notEmpty: true, + is: /^[a-zA-Z0-9]{32}$/ + } +} diff --git a/src/database/device.ts b/src/database/device.ts new file mode 100644 index 0000000..434c9b2 --- /dev/null +++ b/src/database/device.ts @@ -0,0 +1,204 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { NewPermissionStatus, newPermissionStatusValues } from '../model/newpermissionstatus' +import { ProtectionLevel, protetionLevels } from '../model/protectionlevel' +import { RuntimePermissionStatus, runtimePermissionStatusValues } from '../model/runtimepermissionstatus' +import { authTokenColumn, booleanColumn, createEnumColumn, familyIdColumn, idWithinFamilyColumn, labelColumn, optionalIdWithinFamilyColumn, timestampColumn, versionColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface DeviceAttributesVersion1 { + familyId: string + deviceId: string + name: string + model: string + addedAt: string + currentUserId: string + installedAppsVersion: string + deviceAuthToken: string + networkTime: 'disabled' | 'if possible' | 'enabled' + nextSequenceNumber: number + currentProtectionLevel: ProtectionLevel + highestProtectionLevel: ProtectionLevel + currentUsageStatsPermission: RuntimePermissionStatus + highestUsageStatsPermission: RuntimePermissionStatus + currentNotificationAccessPermission: NewPermissionStatus + highestNotificationAccessPermission: NewPermissionStatus + currentAppVersion: number + highestAppVersion: number + triedDisablingDeviceAdmin: boolean + hadManipulation: boolean +} + +export interface DeviceAttributesVersion2 { + lastConnectivity: string + notSeenForLongTime: boolean + didDeviceReportUninstall: boolean +} + +export interface DeviceAttributesVersion3 { + isUserKeptSignedIn: boolean +} + +export interface DeviceAttributesVersion4 { + showDeviceConnected: boolean +} + +export interface DeviceAttributesVersion5 { + defaultUserId: string + defaultUserTimeout: number +} + +export interface DeviceAttributesVersion6 { + didReboot: boolean + considerRebootManipulation: boolean +} + +export type DeviceAttributes = DeviceAttributesVersion1 & DeviceAttributesVersion2 & + DeviceAttributesVersion3 & DeviceAttributesVersion4 & DeviceAttributesVersion5 & + DeviceAttributesVersion6 + +export type DeviceInstance = Sequelize.Instance & DeviceAttributes +export type DeviceModel = Sequelize.Model + +export const attributesVersion1: SequelizeAttributes = { + familyId: { + ...familyIdColumn, + primaryKey: true + }, + deviceId: { + ...idWithinFamilyColumn, + primaryKey: true + }, + name: { ...labelColumn }, + model: { ...labelColumn }, + addedAt: { ...timestampColumn }, + currentUserId: { ...optionalIdWithinFamilyColumn }, + installedAppsVersion: { ...versionColumn }, + deviceAuthToken: { ...authTokenColumn }, + networkTime: createEnumColumn(['disabled', 'if possible', 'enabled']), + nextSequenceNumber: { + type: Sequelize.INTEGER, + allowNull: false + }, + currentProtectionLevel: createEnumColumn(protetionLevels), + highestProtectionLevel: createEnumColumn(protetionLevels), + currentUsageStatsPermission: createEnumColumn(runtimePermissionStatusValues), + highestUsageStatsPermission: createEnumColumn(runtimePermissionStatusValues), + currentNotificationAccessPermission: createEnumColumn(newPermissionStatusValues), + highestNotificationAccessPermission: createEnumColumn(newPermissionStatusValues), + currentAppVersion: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + min: 0 + } + }, + highestAppVersion: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + min: 0 + } + }, + triedDisablingDeviceAdmin: { ...booleanColumn }, + hadManipulation: { ...booleanColumn } +} + +export const attributesVersion2: SequelizeAttributes = { + lastConnectivity: { + ...timestampColumn, + defaultValue: 0 + }, + notSeenForLongTime: { + ...booleanColumn, + defaultValue: false + }, + didDeviceReportUninstall: { + ...booleanColumn, + defaultValue: false + } +} + +export const attributesVersion3: SequelizeAttributes = { + isUserKeptSignedIn: { + ...booleanColumn, + defaultValue: false + } +} + +export const attributesVersion4: SequelizeAttributes = { + showDeviceConnected: { + ...booleanColumn, + defaultValue: false + } +} + +export const attributesVersion5: SequelizeAttributes = { + defaultUserId: { + ...optionalIdWithinFamilyColumn, + defaultValue: '' + }, + defaultUserTimeout: { + type: Sequelize.INTEGER, + allowNull: false, + defaultValue: 0, + validate: { + min: 0 + } + } +} + +export const attributesVersion6: SequelizeAttributes = { + didReboot: { + ...booleanColumn, + defaultValue: false + }, + considerRebootManipulation: { + ...booleanColumn, + defaultValue: false + } +} + +export const attributes: SequelizeAttributes = { + ...attributesVersion1, + ...attributesVersion2, + ...attributesVersion3, + ...attributesVersion4, + ...attributesVersion5, + ...attributesVersion6 +} + +export const createDeviceModel = (sequelize: Sequelize.Sequelize): DeviceModel => sequelize.define('Device', attributes) +export const hasDeviceManipulation = (device: DeviceAttributes) => { + const manipulationOfProtectionLevel = device.currentProtectionLevel !== device.highestProtectionLevel + const manipulationOfUsageStats = device.currentUsageStatsPermission !== device.highestUsageStatsPermission + const manipulationOfNotificationAccess = device.currentNotificationAccessPermission !== device.highestNotificationAccessPermission + const manipulationOfAppVersion = device.currentAppVersion !== device.highestAppVersion + + const hasActiveManipulationWarning = manipulationOfProtectionLevel || + manipulationOfUsageStats || + manipulationOfNotificationAccess || + manipulationOfAppVersion || + device.triedDisablingDeviceAdmin || + device.didReboot + + const hasAnyManipulation = hasActiveManipulationWarning || device.hadManipulation + + return hasAnyManipulation +} diff --git a/src/database/family.ts b/src/database/family.ts new file mode 100644 index 0000000..82dbdaa --- /dev/null +++ b/src/database/family.ts @@ -0,0 +1,48 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { booleanColumn, familyIdColumn, optionalLabelColumn, timestampColumn, versionColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface FamilyAttributes { + familyId: string + name: string + createdAt: string + userListVersion: string + deviceListVersion: string + fullVersionUntil: string + hasFullVersion: boolean +} + +export type FamilyInstance = Sequelize.Instance & FamilyAttributes +export type FamilyModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + familyId: { + ...familyIdColumn, + primaryKey: true + }, + name: { ...optionalLabelColumn }, + createdAt: { ...timestampColumn }, + userListVersion: { ...versionColumn }, + deviceListVersion: { ...versionColumn }, + fullVersionUntil: { ...timestampColumn }, + hasFullVersion: { ...booleanColumn } +} + +export const createFamilyModel = (sequelize: Sequelize.Sequelize): FamilyModel => sequelize.define('Family', attributes) diff --git a/src/database/index.ts b/src/database/index.ts new file mode 100644 index 0000000..94c8103 --- /dev/null +++ b/src/database/index.ts @@ -0,0 +1,79 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { AddDeviceTokenModel, createAddDeviceTokenModel } from './adddevicetoken' +import { AppModel, createAppModel } from './app' +import { AuthTokenModel, createAuthtokenModel } from './authtoken' +import { CategoryModel, createCategoryModel } from './category' +import { CategoryAppModel, createCategoryAppModel } from './categoryapp' +import { createDeviceModel, DeviceModel } from './device' +import { createFamilyModel, FamilyModel } from './family' +import { createMailLoginTokenModel, MailLoginTokenModel } from './maillogintoken' +import { createUmzug } from './migration/umzug' +import { createOldDeviceModel, OldDeviceModel } from './olddevice' +import { createPurchaseModel, PurchaseModel } from './purchase' +import { createTimelimitRuleModel, TimelimitRuleModel } from './timelimitrule' +import { createUsedTimeModel, UsedTimeModel } from './usedtime' +import { createUserModel, UserModel } from './user' + +export interface Database { + addDeviceToken: AddDeviceTokenModel + authtoken: AuthTokenModel + app: AppModel + category: CategoryModel + categoryApp: CategoryAppModel + device: DeviceModel + family: FamilyModel + mailLoginToken: MailLoginTokenModel + oldDevice: OldDeviceModel + purchase: PurchaseModel + timelimitRule: TimelimitRuleModel + usedTime: UsedTimeModel + user: UserModel + transaction: (autoCallback: (t: Sequelize.Transaction) => Promise) => Promise +} + +const createDatabase = (sequelize: Sequelize.Sequelize): Database => ({ + addDeviceToken: createAddDeviceTokenModel(sequelize), + authtoken: createAuthtokenModel(sequelize), + app: createAppModel(sequelize), + category: createCategoryModel(sequelize), + categoryApp: createCategoryAppModel(sequelize), + device: createDeviceModel(sequelize), + family: createFamilyModel(sequelize), + mailLoginToken: createMailLoginTokenModel(sequelize), + oldDevice: createOldDeviceModel(sequelize), + purchase: createPurchaseModel(sequelize), + timelimitRule: createTimelimitRuleModel(sequelize), + usedTime: createUsedTimeModel(sequelize), + user: createUserModel(sequelize), + transaction: (autoCallback: (transaction: Sequelize.Transaction) => Promise) => (sequelize.transaction({ + isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED + }, autoCallback) as any) as Promise +}) + +export const sequelize = new Sequelize(process.env.DATABASE_URL || 'sqlite://test.db', { + define: { + timestamps: false + }, + operatorsAliases: false, + logging: false +}) + +export const defaultDatabase = createDatabase(sequelize) +export const defaultUmzug = createUmzug(sequelize) diff --git a/src/database/maillogintoken.ts b/src/database/maillogintoken.ts new file mode 100644 index 0000000..c0b7af1 --- /dev/null +++ b/src/database/maillogintoken.ts @@ -0,0 +1,62 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { authTokenColumn, timestampColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface MailLoginTokenAttributes { + mailLoginToken: string + receivedCode: string + mail: string + createdAt: string + remainingAttempts: number +} + +export type MailLoginTokenInstance = Sequelize.Instance & MailLoginTokenAttributes +export type MailLoginTokenModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + mailLoginToken: { + ...authTokenColumn, + primaryKey: true + }, + receivedCode: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: true + } + }, + mail: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: true + } + }, + createdAt: { ...timestampColumn }, + remainingAttempts: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + min: 0 + } + } +} + +export const createMailLoginTokenModel = (sequelize: Sequelize.Sequelize): MailLoginTokenModel => sequelize.define('MailLoginToken', attributes) diff --git a/src/database/migration/migrations/20181014-setup-tables.ts b/src/database/migration/migrations/20181014-setup-tables.ts new file mode 100644 index 0000000..f31bfcc --- /dev/null +++ b/src/database/migration/migrations/20181014-setup-tables.ts @@ -0,0 +1,51 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributes as addDeviceTokenAttributes } from '../../adddevicetoken' +import { attributes as appAttributes } from '../../app' +import { attributes as authTokenAttributes } from '../../authtoken' +import { attributesVersion1 as categoryAttributes } from '../../category' +import { attributes as categoryAppAttributes } from '../../categoryapp' +import { attributesVersion1 as deviceAttributes } from '../../device' +import { attributes as familyAttributes } from '../../family' +import { attributes as purchaseAttributes } from '../../purchase' +import { attributes as timelimitruleAttributes } from '../../timelimitrule' +import { attributesVersion1 as usedTimeAttribute } from '../../usedtime' +import { attributesVersion1 as userAttributes } from '../../user' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.createTable('AddDeviceTokens', addDeviceTokenAttributes, { transaction }) + await queryInterface.createTable('Apps', appAttributes, { transaction }) + await queryInterface.createTable('AuthTokens', authTokenAttributes, { transaction }) + await queryInterface.createTable('Categories', categoryAttributes, { transaction }) + await queryInterface.createTable('CategoryApps', categoryAppAttributes, { transaction }) + await queryInterface.createTable('Devices', deviceAttributes, { transaction }) + await queryInterface.createTable('Families', familyAttributes, { transaction }) + await queryInterface.createTable('Purchases', purchaseAttributes, { transaction }) + await queryInterface.createTable('TimelimitRules', timelimitruleAttributes, { transaction }) + await queryInterface.createTable('UsedTimes', usedTimeAttribute, { transaction }) + await queryInterface.createTable('Users', userAttributes, { transaction }) + }) +} + +export async function down () { + throw new Error('not possible') +} diff --git a/src/database/migration/migrations/20181022-extend-device-table-and-create-old-devices.ts b/src/database/migration/migrations/20181022-extend-device-table-and-create-old-devices.ts new file mode 100644 index 0000000..fcead0e --- /dev/null +++ b/src/database/migration/migrations/20181022-extend-device-table-and-create-old-devices.ts @@ -0,0 +1,58 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion2 } from '../../device' +import { attributes as oldDeviceAttributes } from '../../olddevice' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.addColumn('Devices', 'lastConnectivity', { + ...attributesVersion2.lastConnectivity + }, { + transaction + }) + + await queryInterface.addColumn('Devices', 'notSeenForLongTime', { + ...attributesVersion2.notSeenForLongTime + }, { + transaction + }) + + await queryInterface.addColumn('Devices', 'didDeviceReportUninstall', { + ...attributesVersion2.didDeviceReportUninstall + }, { + transaction + }) + + await queryInterface.createTable('OldDevices', oldDeviceAttributes, { transaction }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.removeColumn('Devices', 'lastConnectivity', { transaction }) + await queryInterface.removeColumn('Devices', 'notSeenForLongTime', { transaction }) + await queryInterface.removeColumn('Devices', 'didDeviceReportUninstall', { transaction }) + + await queryInterface.dropTable('OldDevices', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190113-mail-login-tokens.ts b/src/database/migration/migrations/20190113-mail-login-tokens.ts new file mode 100644 index 0000000..cf16bc7 --- /dev/null +++ b/src/database/migration/migrations/20190113-mail-login-tokens.ts @@ -0,0 +1,35 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributes as mailLoginTokenAttributes } from '../../maillogintoken' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.createTable('MailLoginTokens', mailLoginTokenAttributes, { transaction }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.dropTable('MailLoginTokens', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190124-add-device-user-keep-signed-in.ts b/src/database/migration/migrations/20190124-add-device-user-keep-signed-in.ts new file mode 100644 index 0000000..e189dee --- /dev/null +++ b/src/database/migration/migrations/20190124-add-device-user-keep-signed-in.ts @@ -0,0 +1,39 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion3 } from '../../device' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.addColumn('Devices', 'isUserKeptSignedIn', { + ...attributesVersion3.isUserKeptSignedIn + }, { + transaction + }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.removeColumn('Devices', 'isUserKeptSignedIn', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190125-add-category-for-unused-apps.ts b/src/database/migration/migrations/20190125-add-category-for-unused-apps.ts new file mode 100644 index 0000000..67c2ea6 --- /dev/null +++ b/src/database/migration/migrations/20190125-add-category-for-unused-apps.ts @@ -0,0 +1,39 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion2 } from '../../user' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.addColumn('Users', 'categoryForNotAssignedApps', { + ...attributesVersion2.categoryForNotAssignedApps + }, { + transaction + }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.removeColumn('Users', 'categoryForNotAssignedApps', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190128-add-parent-categories.ts b/src/database/migration/migrations/20190128-add-parent-categories.ts new file mode 100644 index 0000000..27cfa77 --- /dev/null +++ b/src/database/migration/migrations/20190128-add-parent-categories.ts @@ -0,0 +1,39 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion2 } from '../../category' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.addColumn('Categories', 'parentCategoryId', { + ...attributesVersion2.parentCategoryId + }, { + transaction + }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.removeColumn('Categories', 'parentCategoryId', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190129-add-show-device-connected.ts b/src/database/migration/migrations/20190129-add-show-device-connected.ts new file mode 100644 index 0000000..e9ce27e --- /dev/null +++ b/src/database/migration/migrations/20190129-add-show-device-connected.ts @@ -0,0 +1,39 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion4 } from '../../device' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.addColumn('Devices', 'showDeviceConnected', { + ...attributesVersion4.showDeviceConnected + }, { + transaction + }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.removeColumn('Devices', 'showDeviceConnected', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190207-add-used-time-items-last-update.ts b/src/database/migration/migrations/20190207-add-used-time-items-last-update.ts new file mode 100644 index 0000000..a5ec28c --- /dev/null +++ b/src/database/migration/migrations/20190207-add-used-time-items-last-update.ts @@ -0,0 +1,42 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion2 } from '../../usedtime' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.addColumn('UsedTimes', 'lastUpdate', { + ...attributesVersion2.lastUpdate + }, { + transaction + }) + }) + + await queryInterface.addIndex('UsedTimes', ['lastUpdate']) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.removeIndex('UsedTimes', ['lastUpdate'], { transaction }) + await queryInterface.removeColumn('UsedTimes', 'lastUpdate', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190210-extend-tables-for-improved-user-system.ts b/src/database/migration/migrations/20190210-extend-tables-for-improved-user-system.ts new file mode 100644 index 0000000..06ec219 --- /dev/null +++ b/src/database/migration/migrations/20190210-extend-tables-for-improved-user-system.ts @@ -0,0 +1,53 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion5 as deviceAttributes } from '../../device' +import { attributesVersion3 as userAttributes } from '../../user' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + // users + await queryInterface.addColumn('Users', 'relaxPrimaryDeviceRule', { + ...userAttributes.relaxPrimaryDeviceRule + }, { transaction }) + + // devices + await queryInterface.addColumn('Devices', 'defaultUserId', { + ...deviceAttributes.defaultUserId + }, { transaction }) + + await queryInterface.addColumn('Devices', 'defaultUserTimeout', { + ...deviceAttributes.defaultUserTimeout + }, { transaction }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + // users + await queryInterface.removeColumn('Users', 'relaxPrimaryDeviceRule', { transaction }) + + // devices + await queryInterface.removeColumn('Devices', 'defaultUserId', { transaction }) + await queryInterface.removeColumn('Devices', 'defaultUserTimeout', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190218-add-reboot-manipulation-columns.ts b/src/database/migration/migrations/20190218-add-reboot-manipulation-columns.ts new file mode 100644 index 0000000..233cf76 --- /dev/null +++ b/src/database/migration/migrations/20190218-add-reboot-manipulation-columns.ts @@ -0,0 +1,46 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion6 } from '../../device' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.addColumn('Devices', 'considerRebootManipulation', { + ...attributesVersion6.considerRebootManipulation + }, { + transaction + }) + + await queryInterface.addColumn('Devices', 'didReboot', { + ...attributesVersion6.didReboot + }, { + transaction + }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.removeColumn('Devices', 'considerRebootManipulation', { transaction }) + await queryInterface.removeColumn('Devices', 'didReboot', { transaction }) + }) +} diff --git a/src/database/migration/migrations/20190224-add-mail-notification-flags.ts b/src/database/migration/migrations/20190224-add-mail-notification-flags.ts new file mode 100644 index 0000000..76d1a4f --- /dev/null +++ b/src/database/migration/migrations/20190224-add-mail-notification-flags.ts @@ -0,0 +1,37 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { QueryInterface, Sequelize } from 'sequelize' +import { attributesVersion4 as userAttributes } from '../../user' + +export async function up (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.addColumn('Users', 'mailNotificationFlags', { + ...userAttributes.mailNotificationFlags + }, { transaction }) + }) +} + +export async function down (queryInterface: QueryInterface, sequelize: Sequelize) { + await sequelize.transaction({ + type: 'EXCLUSIVE' + }, async (transaction) => { + await queryInterface.removeColumn('Users', 'mailNotificationFlags', { transaction }) + }) +} diff --git a/src/database/migration/umzug.ts b/src/database/migration/umzug.ts new file mode 100644 index 0000000..05febc4 --- /dev/null +++ b/src/database/migration/umzug.ts @@ -0,0 +1,34 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { resolve } from 'path' +import { Sequelize } from 'sequelize' +import * as Umzug from 'umzug' + +export const createUmzug = (sequelize: Sequelize) => ( + new Umzug({ + storage: 'sequelize', + storageOptions: { + sequelize + }, + migrations: { + params: [sequelize.getQueryInterface(), sequelize], + path: resolve(__dirname, '../../../build/database/migration/migrations'), + pattern: /^\d+[\w-]+\.js$/ + } + }) +) diff --git a/src/database/olddevice.ts b/src/database/olddevice.ts new file mode 100644 index 0000000..b221e3b --- /dev/null +++ b/src/database/olddevice.ts @@ -0,0 +1,36 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { authTokenColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface OldDeviceAttributes { + deviceAuthToken: string +} + +export type OldDeviceInstance = Sequelize.Instance & OldDeviceAttributes +export type OldDeviceModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + deviceAuthToken: { + ...authTokenColumn, + primaryKey: true + } +} + +export const createOldDeviceModel = (sequelize: Sequelize.Sequelize): OldDeviceModel => sequelize.define('OldDevice', attributes) diff --git a/src/database/purchase.ts b/src/database/purchase.ts new file mode 100644 index 0000000..4c70747 --- /dev/null +++ b/src/database/purchase.ts @@ -0,0 +1,51 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { createEnumColumn, familyIdColumn, timestampColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface PurchaseAttributes { + familyId: string + service: 'googleplay' + transactionId: string + type: 'month' | 'year' + loggedAt: string + previousFullVersionEndTime: string + newFullVersionEndTime: string +} + +export type PurchaseInstance = Sequelize.Instance & PurchaseAttributes +export type PurchaseModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + familyId: { ...familyIdColumn }, + service: { + ...createEnumColumn(['googleplay']), + primaryKey: true + }, + transactionId: { + type: Sequelize.STRING, + primaryKey: true + }, + type: createEnumColumn(['month', 'year']), + loggedAt: timestampColumn, + previousFullVersionEndTime: timestampColumn, + newFullVersionEndTime: timestampColumn +} + +export const createPurchaseModel = (sequelize: Sequelize.Sequelize): PurchaseModel => sequelize.define('Purchase', attributes) diff --git a/src/database/timelimitrule.ts b/src/database/timelimitrule.ts new file mode 100644 index 0000000..1cfcd39 --- /dev/null +++ b/src/database/timelimitrule.ts @@ -0,0 +1,62 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { booleanColumn, familyIdColumn, idWithinFamilyColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface TimelimitRuleAttributes { + familyId: string + ruleId: string + categoryId: string + applyToExtraTimeUsage: boolean + dayMaskAsBitmask: number + maximumTimeInMillis: number +} + +export type TimelimitRuleInstance = Sequelize.Instance & TimelimitRuleAttributes +export type TimelimitRuleModel = Sequelize.Model + +export const attributes: SequelizeAttributes = { + familyId: { + ...familyIdColumn, + primaryKey: true + }, + ruleId: { + ...idWithinFamilyColumn, + primaryKey: true + }, + categoryId: { ...idWithinFamilyColumn }, + applyToExtraTimeUsage: { ...booleanColumn }, + dayMaskAsBitmask: { + type: Sequelize.TINYINT, + allowNull: false, + validate: { + min: 0, + max: 1 | 2 | 4 | 8 | 16 | 32 | 64 + } + }, + maximumTimeInMillis: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + min: 0 + } + } +} + +export const createTimelimitRuleModel = (sequelize: Sequelize.Sequelize): TimelimitRuleModel => sequelize.define('TimelimitRule', attributes) diff --git a/src/database/types.ts b/src/database/types.ts new file mode 100644 index 0000000..4a02e62 --- /dev/null +++ b/src/database/types.ts @@ -0,0 +1,22 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' + +export type SequelizeAttributes = { + [P in keyof T]: Sequelize.DefineAttributeColumnOptions; +} diff --git a/src/database/usedtime.ts b/src/database/usedtime.ts new file mode 100644 index 0000000..010a402 --- /dev/null +++ b/src/database/usedtime.ts @@ -0,0 +1,76 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { familyIdColumn, idWithinFamilyColumn, timestampColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface UsedTimeAttributesVersion1 { + familyId: string + categoryId: string + dayOfEpoch: number + usedTime: number +} + +export interface UsedTimeAttributesVersion2 { + lastUpdate: string +} + +export type UsedTimeAttributes = UsedTimeAttributesVersion1 & UsedTimeAttributesVersion2 + +export type UsedTimeInstance = Sequelize.Instance & UsedTimeAttributes +export type UsedTimeModel = Sequelize.Model + +export const attributesVersion1: SequelizeAttributes = { + familyId: { + ...familyIdColumn, + primaryKey: true + }, + categoryId: { + ...idWithinFamilyColumn, + primaryKey: true + }, + dayOfEpoch: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + min: 0 + }, + primaryKey: true + }, + usedTime: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + min: 0 + } + } +} + +export const attributesVersion2: SequelizeAttributes = { + lastUpdate: { + ...timestampColumn, + defaultValue: 0 + } +} + +export const attributes = { + ...attributesVersion1, + ...attributesVersion2 +} + +export const createUsedTimeModel = (sequelize: Sequelize.Sequelize): UsedTimeModel => sequelize.define('UsedTime', attributes) diff --git a/src/database/user.ts b/src/database/user.ts new file mode 100644 index 0000000..ce19333 --- /dev/null +++ b/src/database/user.ts @@ -0,0 +1,131 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { optionalPasswordRegex, optionalSaltRegex } from '../util/password' +import { booleanColumn, createEnumColumn, familyIdColumn, idWithinFamilyColumn, labelColumn, optionalIdWithinFamilyColumn, timestampColumn } from './columns' +import { SequelizeAttributes } from './types' + +export interface UserAttributesVersion1 { + familyId: string + userId: string + name: string + passwordHash: string + secondPasswordHash: string + secondPasswordSalt: string + type: 'parent' | 'child' + mail: string + timeZone: string + disableTimelimitsUntil: string + // empty = unset; can contain an invalid device id or the id of an device which is not used by this user + // in this case, it should be treated like unset + currentDevice: string +} + +export interface UserAttributesVersion2 { + categoryForNotAssignedApps: string +} + +export interface UserAttributesVersion3 { + relaxPrimaryDeviceRule: boolean +} + +export interface UserAttributesVersion4 { + // 1: manipulation warnings + mailNotificationFlags: number +} + +export type UserAttributes = UserAttributesVersion1 & UserAttributesVersion2 & + UserAttributesVersion3 & UserAttributesVersion4 + +export type UserInstance = Sequelize.Instance & UserAttributes +export type UserModel = Sequelize.Model + +export const attributesVersion1: SequelizeAttributes = { + familyId: { + ...familyIdColumn, + primaryKey: true + }, + userId: { + ...idWithinFamilyColumn, + primaryKey: true + }, + name: { ...labelColumn }, + passwordHash: { + type: Sequelize.STRING, + allowNull: false, + validate: { + is: optionalPasswordRegex + } + }, + secondPasswordHash: { + type: Sequelize.STRING, + allowNull: false, + validate: { + is: optionalPasswordRegex + } + }, + secondPasswordSalt: { + type: Sequelize.STRING, + allowNull: false, + validate: { + is: optionalSaltRegex + } + }, + type: createEnumColumn(['parent', 'child']), + mail: { + type: Sequelize.STRING, + allowNull: false + }, + timeZone: { ...labelColumn }, + disableTimelimitsUntil: { ...timestampColumn }, + currentDevice: { ...optionalIdWithinFamilyColumn } +} + +export const attributesVersion2: SequelizeAttributes = { + categoryForNotAssignedApps: { + ...optionalIdWithinFamilyColumn, + defaultValue: '' + } +} + +export const attributesVersion3: SequelizeAttributes = { + relaxPrimaryDeviceRule: { + ...booleanColumn, + defaultValue: false + } +} + +export const attributesVersion4: SequelizeAttributes = { + mailNotificationFlags: { + type: Sequelize.INTEGER, + defaultValue: 0, + validate: { + min: 0, + max: 1 + } + } +} + +export const attributes: SequelizeAttributes = { + ...attributesVersion1, + ...attributesVersion2, + ...attributesVersion3, + ...attributesVersion4 +} + +export const createUserModel = (sequelize: Sequelize.Sequelize): UserModel => sequelize.define('User', attributes) diff --git a/src/function/authentication/index.ts b/src/function/authentication/index.ts new file mode 100644 index 0000000..1a6afae --- /dev/null +++ b/src/function/authentication/index.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Unauthorized } from 'http-errors' +import { Database } from '../../database' +import { generateAuthToken } from '../../util/token' + +export const createAuthTokenByMailAddress = async ({ mail, database }: {mail: string, database: Database}) => { + const token = generateAuthToken() + + await database.authtoken.create({ + token, + mail, + createdAt: Date.now().toString() + }) + + return token +} + +export const getMailByAuthToken = async ({ mailAuthToken, database }: {mailAuthToken: string, database: Database}) => { + const entry = await database.authtoken.findOne({ + where: { + token: mailAuthToken + } + }) + + if (entry) { + return entry.mail + } else { + return null + } +} + +export const requireMailByAuthToken = async ({ mailAuthToken, database }: {mailAuthToken: string, database: Database}) => { + const mail = await getMailByAuthToken({ mailAuthToken, database }) + + if (!mail) { + throw new Unauthorized() + } + + return mail +} diff --git a/src/function/authentication/login-by-mail.ts b/src/function/authentication/login-by-mail.ts new file mode 100644 index 0000000..62c7938 --- /dev/null +++ b/src/function/authentication/login-by-mail.ts @@ -0,0 +1,118 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Forbidden, Gone, InternalServerError, TooManyRequests } from 'http-errors' +import { Database } from '../../database' +import { sendAuthenticationMail } from '../../util/mail' +import { randomWords } from '../../util/random-words' +import { checkMailSendLimit } from '../../util/ratelimit-authmail' +import { generateAuthToken } from '../../util/token' +import { createAuthTokenByMailAddress } from './index' + +export const sendLoginCode = async ({ mail, locale, database }: { + mail: string + locale: string + database: Database +}): Promise<{mailLoginToken: string}> => { + try { + await checkMailSendLimit(mail) + } catch (ex) { + throw new TooManyRequests() + } + + const mailLoginToken = generateAuthToken() + const code = randomWords(3) + + await sendAuthenticationMail({ + receiver: mail, + code, + locale + }) + + await database.mailLoginToken.create({ + mailLoginToken, + receivedCode: code, + mail, + createdAt: Date.now().toString(10), + remainingAttempts: 3 + }) + + return { + mailLoginToken + } +} + +// 403 Forbidden = receivedCode is invalid +// 410 Gone = mailLoginToken is invalid or expired +export const signInByMailCode = async ({ mailLoginToken, receivedCode, database }: { + mailLoginToken: string + receivedCode: string + database: Database +}): Promise<{mailAuthToken: string}> => { + const { mail, status } = await database.transaction(async (transaction) => { + const entry = await database.mailLoginToken.findOne({ + where: { + mailLoginToken + }, + transaction + }) + + if ((!entry) || entry.remainingAttempts === 0) { + return { + mail: null, + status: 'gone' + } + } + + if (entry.receivedCode !== receivedCode) { + entry.remainingAttempts-- + + await entry.save({ transaction }) + + if (entry.remainingAttempts === 0) { + return { + mail: null, + status: 'gone' + } + } else { + return { + mail: null, + status: 'forbidden' + } + } + } + + return { + mail: entry.mail, + status: null + } + }) + + if (!mail) { + if (status === 'gone') { + throw new Gone() + } else if (status === 'forbidden') { + throw new Forbidden() + } else { + throw new InternalServerError() + } + } + + const mailAuthToken = await createAuthTokenByMailAddress({ mail, database }) + + return { mailAuthToken } +} diff --git a/src/function/child/add-device.ts b/src/function/child/add-device.ts new file mode 100644 index 0000000..6926ac6 --- /dev/null +++ b/src/function/child/add-device.ts @@ -0,0 +1,78 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Unauthorized } from 'http-errors' +import { RegisterChildDeviceRequest } from '../../api/schema' +import { Database } from '../../database' +import { generateAuthToken, generateVersionId } from '../../util/token' +import { WebsocketApi } from '../../websocket' +import { prepareDeviceEntry } from '../device/prepare-device-entry' +import { notifyClientsAboutChanges } from '../websocket' + +export const addChildDevice = async ({ database, websocket, request }: { + database: Database + websocket: WebsocketApi + request: RegisterChildDeviceRequest +}) => { + const { response, familyId } = await database.transaction(async (transaction) => { + const entry = await database.addDeviceToken.findOne({ + where: { + token: request.registerToken.toLowerCase() + }, + transaction + }) + + if (!entry) { + throw new Unauthorized() + } + + await entry.destroy({ transaction }) + + const { deviceId, familyId } = entry + const deviceAuthToken = generateAuthToken() + + await database.device.create(prepareDeviceEntry({ + familyId, + deviceId, + deviceAuthToken, + deviceName: request.deviceName, + newDeviceInfo: request.childDevice, + userId: '' + }), { transaction }) + + await database.family.update({ + deviceListVersion: generateVersionId() + }, { + where: { + familyId + }, + transaction + }) + + return { + response: { + deviceId, + deviceAuthToken + }, + familyId + } + }) + + await notifyClientsAboutChanges({ familyId, websocket, database, isImportant: true, sourceDeviceId: response.deviceId }) + + return response +} diff --git a/src/function/child/logout-at-primary-device.ts b/src/function/child/logout-at-primary-device.ts new file mode 100644 index 0000000..ea364b7 --- /dev/null +++ b/src/function/child/logout-at-primary-device.ts @@ -0,0 +1,85 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Conflict, Unauthorized } from 'http-errors' +import { Database } from '../../database' +import { WebsocketApi } from '../../websocket' + +export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websocket }: { + deviceAuthToken: string + database: Database + websocket: WebsocketApi +}) => { + await database.transaction(async (transaction) => { + const ownDeviceEntryUnsafe = await database.device.findOne({ + where: { + deviceAuthToken + }, + transaction, + attributes: ['familyId', 'currentUserId', 'deviceId'] + }) + + if (!ownDeviceEntryUnsafe) { + throw new Unauthorized() + } + + const ownDeviceEntry = { + familyId: ownDeviceEntryUnsafe.familyId, + currentUserId: ownDeviceEntryUnsafe.currentUserId + } + + const deviceUserEntryUnsafe = await database.user.findOne({ + where: { + familyId: ownDeviceEntry.familyId, + userId: ownDeviceEntry.currentUserId, + type: 'child' + }, + attributes: ['currentDevice'], + transaction + }) + + if (!deviceUserEntryUnsafe) { + throw new Conflict() + } + + const deviceUserEntry = { + currentDevice: deviceUserEntryUnsafe.currentDevice + } + + const otherDeviceEntryUnsafe = await database.device.findOne({ + where: { + familyId: ownDeviceEntry.familyId, + deviceId: deviceUserEntry.currentDevice, + currentUserId: ownDeviceEntry.currentUserId + }, + attributes: ['deviceAuthToken'], + transaction + }) + + if (!otherDeviceEntryUnsafe) { + throw new Conflict() + } + + const otherDeviceEntry = { + deviceAuthToken: otherDeviceEntryUnsafe.deviceAuthToken + } + + websocket.triggerLogoutByDeviceAuthToken({ + deviceAuthToken: otherDeviceEntry.deviceAuthToken + }) + }) +} diff --git a/src/function/child/set-primary-device.ts b/src/function/child/set-primary-device.ts new file mode 100644 index 0000000..53e6866 --- /dev/null +++ b/src/function/child/set-primary-device.ts @@ -0,0 +1,192 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Conflict, Unauthorized } from 'http-errors' +import * as Sequelize from 'sequelize' +import { Database } from '../../database' +import { generateVersionId } from '../../util/token' +import { WebsocketApi } from '../../websocket' +import { notifyClientsAboutChanges } from '../websocket' + +export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, currentUserId, action }: { + database: Database + websocket: WebsocketApi + deviceAuthToken: string + currentUserId: string + action: 'set this device' | 'unset this device' +}): Promise<'assigned to other device' | 'requires full version' | 'success'> => { + const response = await database.transaction(async (transaction): Promise<{ + response: 'assigned to other device' | 'requires full version' | 'success', + sourceDeviceId: string, + familyId: string + }> => { + const deviceEntryUnsafe = await database.device.findOne({ + where: { + deviceAuthToken + }, + transaction, + attributes: ['familyId', 'currentUserId', 'deviceId'] + }) + + if (!deviceEntryUnsafe) { + throw new Unauthorized() + } + + const deviceEntry = { + familyId: deviceEntryUnsafe.familyId, + currentUserId: deviceEntryUnsafe.currentUserId, + deviceId: deviceEntryUnsafe.deviceId + } + + if ((deviceEntry.currentUserId !== currentUserId) || (currentUserId === '')) { + throw new Conflict() + } + + const userEntryUnsafe = await database.user.findOne({ + where: { + familyId: deviceEntry.familyId, + userId: deviceEntry.currentUserId + }, + transaction, + lock: Sequelize.Transaction.LOCK.UPDATE, + attributes: ['currentDevice'] + }) + + if (!userEntryUnsafe) { + throw new Conflict() + } + + const userEntry = { + currentDevice: userEntryUnsafe.currentDevice + } + + const userDeviceEntriesUnsafe = await database.device.findAll({ + where: { + familyId: deviceEntry.familyId, + currentUserId + }, + transaction, + attributes: ['deviceId'] + }) + + const userDeviceEntries = userDeviceEntriesUnsafe.map((item) => ({ + deviceId: item.deviceId + })) + + if (userDeviceEntries.length >= 2) { + const familyEntryUnsafe = await database.family.findOne({ + where: { + familyId: deviceEntry.familyId + }, + transaction, + attributes: ['hasFullVersion'] + }) + + if (!familyEntryUnsafe) { + throw new Conflict() + } + + const familyEntry = { + hasFullVersion: familyEntryUnsafe.hasFullVersion + } + + if (!familyEntry.hasFullVersion) { + return { + response: 'requires full version', + sourceDeviceId: deviceEntry.deviceId, + familyId: deviceEntry.familyId + } + } + } + + if (action === 'set this device') { + // check that no other device is selected + if (userDeviceEntries.find((item) => item.deviceId === userEntry.currentDevice)) { + return { + response: 'assigned to other device', + sourceDeviceId: deviceEntry.deviceId, + familyId: deviceEntry.familyId + } + } + + // update + const [affectedRows] = await database.user.update({ + currentDevice: deviceEntry.deviceId + }, { + where: { + familyId: deviceEntry.familyId, + userId: currentUserId + }, + transaction + }) + + if (affectedRows !== 1) { + throw new Conflict() + } + } else if (action === 'unset this device') { + if (userEntry.currentDevice !== deviceEntry.deviceId) { + throw new Conflict() + } + + // update + const [affectedRows] = await database.user.update({ + currentDevice: '' + }, { + where: { + familyId: deviceEntry.familyId, + userId: currentUserId + }, + transaction + }) + + if (affectedRows !== 1) { + throw new Conflict() + } + } else { + throw new Error('illegal state') + } + + // invalidiate user list + await database.family.update({ + userListVersion: generateVersionId() + }, { + transaction, + where: { + familyId: deviceEntry.familyId + } + }) + + return { + response: 'success', + sourceDeviceId: deviceEntry.deviceId, + familyId: deviceEntry.familyId + } + }) + + if (response.response === 'success') { + // trigger sync + await notifyClientsAboutChanges({ + familyId: response.familyId, + sourceDeviceId: response.sourceDeviceId, + websocket, + database, + isImportant: false // the source device knows it already + }) + } + + return response.response +} diff --git a/src/function/device/prepare-device-entry.ts b/src/function/device/prepare-device-entry.ts new file mode 100644 index 0000000..16dcbd6 --- /dev/null +++ b/src/function/device/prepare-device-entry.ts @@ -0,0 +1,59 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { NewDeviceInfo } from '../../api/schema' +import { DeviceAttributes } from '../../database/device' +import { generateVersionId } from '../../util/token' + +export const prepareDeviceEntry = ({ familyId, userId, deviceAuthToken, deviceId, deviceName, newDeviceInfo }: { + familyId: string + userId: string + deviceAuthToken: string + deviceId: string + deviceName: string + newDeviceInfo: NewDeviceInfo +}): DeviceAttributes => ({ + familyId, + deviceId, + currentUserId: userId, + installedAppsVersion: generateVersionId(), + name: deviceName, + model: newDeviceInfo.model, + addedAt: Date.now().toString(10), + deviceAuthToken, + networkTime: 'disabled', + nextSequenceNumber: 0, + currentProtectionLevel: 'none', + highestProtectionLevel: 'none', + currentUsageStatsPermission: 'not granted', + highestUsageStatsPermission: 'not granted', + currentNotificationAccessPermission: 'not granted', + highestNotificationAccessPermission: 'not granted', + currentAppVersion: 0, + highestAppVersion: 0, + triedDisablingDeviceAdmin: false, + didReboot: false, + hadManipulation: false, + lastConnectivity: '0', + notSeenForLongTime: false, + didDeviceReportUninstall: false, + isUserKeptSignedIn: false, + showDeviceConnected: false, + defaultUserId: '', + defaultUserTimeout: 0, + considerRebootManipulation: false +}) diff --git a/src/function/device/remove-device.ts b/src/function/device/remove-device.ts new file mode 100644 index 0000000..945ff04 --- /dev/null +++ b/src/function/device/remove-device.ts @@ -0,0 +1,109 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Conflict } from 'http-errors' +import { Database } from '../../database' +import { generateVersionId } from '../../util/token' +import { WebsocketApi } from '../../websocket' +import { notifyClientsAboutChanges } from '../websocket' + +export async function removeDevice ({ database, familyId, deviceId, websocket }: { + database: Database + familyId: string + deviceId: string + websocket: WebsocketApi +}) { + const { oldDeviceAuthToken } = await database.transaction(async (transaction) => { + const deviceEntry = await database.device.findOne({ + where: { + familyId, + deviceId + }, + transaction + }) + + if (!deviceEntry) { + throw new Conflict() + } + + // remove app entries + await database.app.destroy({ + where: { + familyId, + deviceId + }, + transaction + }) + + // remove as current device + await database.user.update({ + currentDevice: '' + }, { + where: { + familyId, + currentDevice: deviceId + }, + transaction + }) + + // add to old devices if it is not yet there (it could be there if it reported a uninstall) + const oldOldDeviceEntry = await database.oldDevice.findOne({ + where: { + deviceAuthToken: deviceEntry.deviceAuthToken + }, + transaction + }) + + if (!oldOldDeviceEntry) { + await database.oldDevice.create({ + deviceAuthToken: deviceEntry.deviceAuthToken + }, { + transaction + }) + } + + // remove from the device list + await deviceEntry.destroy({ transaction }) + + // invalidiate the caches + await database.family.update({ + deviceListVersion: generateVersionId(), + // the device could have become unassigned during this + userListVersion: generateVersionId() + }, { + where: { + familyId: deviceEntry.familyId + }, + transaction + }) + + return { oldDeviceAuthToken: deviceEntry.deviceAuthToken } + }) + + await notifyClientsAboutChanges({ + database, + websocket, + familyId, + sourceDeviceId: null, + isImportant: false + }) + + websocket.triggerSyncByDeviceAuthToken({ + deviceAuthToken: oldDeviceAuthToken, + isImportant: true + }) +} diff --git a/src/function/device/report-device-removed.ts b/src/function/device/report-device-removed.ts new file mode 100644 index 0000000..43e36d4 --- /dev/null +++ b/src/function/device/report-device-removed.ts @@ -0,0 +1,91 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Database } from '../../database' +import { generateAuthToken, generateVersionId } from '../../util/token' +import { WebsocketApi } from '../../websocket' +import { sendUninstallWarnings } from '../warningmail/uninstall' +import { notifyClientsAboutChanges } from '../websocket' + +export async function reportDeviceRemoved ({ database, deviceAuthToken, websocket }: { + database: Database + deviceAuthToken: string + websocket: WebsocketApi +}) { + const result = await database.transaction(async (transaction) => { + const deviceEntry = await database.device.findOne({ + where: { + deviceAuthToken + }, + transaction + }) + + if (deviceEntry) { + deviceEntry.didDeviceReportUninstall = true + deviceEntry.deviceAuthToken = generateAuthToken() // invalidiate the token + deviceEntry.save({ transaction }) + + // invalidiate device list + await database.family.update({ + deviceListVersion: generateVersionId() + }, { + where: { + familyId: deviceEntry.familyId + }, + transaction + }) + + // add to old devices + await database.oldDevice.create({ + deviceAuthToken: deviceEntry.deviceAuthToken + }, { + transaction + }) + + return { familyId: deviceEntry.familyId, deviceName: deviceEntry.name } + } else { + const oldDeviceEntry = await database.oldDevice.findOne({ + where: { + deviceAuthToken + }, + transaction + }) + + if (!oldDeviceEntry) { + throw new Error('device not found') + } + + return null + } + }) + + if (result) { + await notifyClientsAboutChanges({ + database, + websocket, + familyId: result.familyId, + sourceDeviceId: null, + isImportant: false + }) + + await sendUninstallWarnings({ + database, + familyId: result.familyId, + deviceName: result.deviceName + }) + } +} diff --git a/src/function/parent/can-recover-password.ts b/src/function/parent/can-recover-password.ts new file mode 100644 index 0000000..e0b7bb0 --- /dev/null +++ b/src/function/parent/can-recover-password.ts @@ -0,0 +1,37 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Database } from '../../database' +import { requireMailByAuthToken } from '../authentication' + +export const canRecoverPassword = async ({ database, mailAuthToken, parentUserId }: { + database: Database + mailAuthToken: string + parentUserId: string +}) => { + const mail = await requireMailByAuthToken({ mailAuthToken, database }) + + const entry = await database.user.findOne({ + where: { + mail, + userId: parentUserId, + type: 'parent' + } + }) + + return !!entry +} diff --git a/src/function/parent/create-add-device-token.ts b/src/function/parent/create-add-device-token.ts new file mode 100644 index 0000000..9064608 --- /dev/null +++ b/src/function/parent/create-add-device-token.ts @@ -0,0 +1,43 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Database } from '../../database' +import { randomWords } from '../../util/random-words' +import { generateIdWithinFamily } from '../../util/token' + +export const createAddDeviceToken = async ({ familyId, database }: { + familyId: string + database: Database +}) => { + const token = randomWords(5) + const deviceId = generateIdWithinFamily() + + await database.addDeviceToken.destroy({ + where: { + familyId + } + }) + + await database.addDeviceToken.create({ + familyId, + token: token.toLowerCase(), + deviceId, + createdAt: Date.now().toString() + }) + + return { token, deviceId } +} diff --git a/src/function/parent/create-family.ts b/src/function/parent/create-family.ts new file mode 100644 index 0000000..8bc664a --- /dev/null +++ b/src/function/parent/create-family.ts @@ -0,0 +1,102 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Conflict } from 'http-errors' +import { NewDeviceInfo, ParentPassword } from '../../api/schema' +import { Database } from '../../database' +import { + generateAuthToken, generateFamilyId, generateIdWithinFamily, generateVersionId +} from '../../util/token' +import { requireMailByAuthToken } from '../authentication' +import { prepareDeviceEntry } from '../device/prepare-device-entry' + +export const createFamily = async ({ database, mailAuthToken, firstParentDevice, password, timeZone, parentName, deviceName }: { + database: Database, + mailAuthToken: string, + firstParentDevice: NewDeviceInfo, + password: ParentPassword, + timeZone: string, + parentName: string, + deviceName: string +}) => { + const now = Date.now().toString(10) + const mail = await requireMailByAuthToken({ database, mailAuthToken }) + + return database.transaction(async (transaction) => { + // ensure that no family was created for this mail yet + const exisitngUserEntry = await database.user.findOne({ + where: { + mail + }, + transaction + }) + + if (exisitngUserEntry) { + throw new Conflict() + } + + const familyId = generateFamilyId() + const userId = generateIdWithinFamily() + const deviceId = generateIdWithinFamily() + const deviceAuthToken = generateAuthToken() + + // create family + await database.family.create({ + familyId, + name: '', + createdAt: now, + userListVersion: generateVersionId(), + deviceListVersion: generateVersionId(), + // 14 days demo version + fullVersionUntil: (Date.now() + 1000 * 60 * 60 * 24 * 14).toString(10), + hasFullVersion: true + }, { transaction }) + + // create parent user + await database.user.create({ + familyId, + userId, + name: parentName, + passwordHash: password.hash, + secondPasswordHash: password.secondHash, + secondPasswordSalt: password.secondSalt, + type: 'parent', + mail, + timeZone, + disableTimelimitsUntil: '0', + currentDevice: '', + categoryForNotAssignedApps: '', + relaxPrimaryDeviceRule: false, + mailNotificationFlags: 1 // enable warning notifications + }, { transaction }) + + // add parent device + await database.device.create(prepareDeviceEntry({ + familyId, + deviceId, + deviceName, + newDeviceInfo: firstParentDevice, + userId, + deviceAuthToken + }), { transaction }) + + return { + deviceAuthToken, + deviceId + } + }) +} diff --git a/src/function/parent/get-status-by-mail-address.ts b/src/function/parent/get-status-by-mail-address.ts new file mode 100644 index 0000000..18e9ac7 --- /dev/null +++ b/src/function/parent/get-status-by-mail-address.ts @@ -0,0 +1,44 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Database } from '../../database' +import { requireMailByAuthToken } from '../authentication' + +const getStatusByMailAddress = async ({ mail, database }: {mail: string, database: Database}) => { + if (!mail) { + throw new Error('no mail address') + } + + const entry = await database.user.findOne({ + where: { + mail + } + }) + + if (entry) { + return 'with family' + } else { + return 'without family' + } +} + +export const getStatusByMailToken = async ({ mailAuthToken, database }: {mailAuthToken: string, database: Database}) => { + const mail = await requireMailByAuthToken({ mailAuthToken, database }) + const status = await getStatusByMailAddress({ mail, database }) + + return { mail, status } +} diff --git a/src/function/parent/link-mail-address.ts b/src/function/parent/link-mail-address.ts new file mode 100644 index 0000000..5924492 --- /dev/null +++ b/src/function/parent/link-mail-address.ts @@ -0,0 +1,107 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Conflict, Unauthorized } from 'http-errors' +import * as Sequelize from 'sequelize' +import { Database } from '../../database' +import { generateVersionId } from '../../util/token' +import { WebsocketApi } from '../../websocket' +import { requireMailByAuthToken } from '../authentication' +import { notifyClientsAboutChanges } from '../websocket' + +export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUserId, parentPasswordSecondHash, database, websocket }: { + mailAuthToken: string + deviceAuthToken: string + parentUserId: string + parentPasswordSecondHash: string + database: Database + websocket: WebsocketApi +}) => { + const deviceEntry = await database.device.findOne({ + where: { + deviceAuthToken + } + }) + + if (!deviceEntry) { + throw new Unauthorized() + } + + const familyId = deviceEntry.familyId + + const mailAddress = await requireMailByAuthToken({ mailAuthToken, database }) + + const exisitingUser = await database.user.findOne({ + where: { + mail: mailAddress + } + }) + + if (exisitingUser) { + throw new Conflict() + } + + await database.transaction(async (transaction) => { + const parentEntry = await database.user.findOne({ + where: { + type: 'parent', + familyId, + userId: parentUserId + }, + transaction, + lock: Sequelize.Transaction.LOCK.UPDATE + }) + + if (!parentEntry) { + throw new Conflict() + } + + if (parentEntry.mail !== '') { + throw new Conflict() + } + + if (parentEntry.secondPasswordHash !== parentPasswordSecondHash) { + throw new Conflict() + } + + if (!parentEntry.secondPasswordSalt) { + throw new Conflict() + } + + parentEntry.mail = mailAddress + + await parentEntry.save({ transaction }) + + // invalidiate client caches + await database.family.update({ + userListVersion: generateVersionId() + }, { + where: { + familyId + }, + transaction + }) + }) + + await notifyClientsAboutChanges({ + familyId, + sourceDeviceId: null, + database, + websocket, + isImportant: true + }) +} diff --git a/src/function/parent/recover-parent-password.ts b/src/function/parent/recover-parent-password.ts new file mode 100644 index 0000000..426fb79 --- /dev/null +++ b/src/function/parent/recover-parent-password.ts @@ -0,0 +1,79 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Conflict } from 'http-errors' +import * as Sequelize from 'sequelize' +import { ParentPassword } from '../../api/schema' +import { Database } from '../../database' +import { generateVersionId } from '../../util/token' +import { WebsocketApi } from '../../websocket' +import { requireMailByAuthToken } from '../authentication' +import { notifyClientsAboutChanges } from '../websocket' + +export const recoverParentPassword = async ({ database, websocket, password, mailAuthToken }: { + database: Database + websocket: WebsocketApi + password: ParentPassword + mailAuthToken: string +}) => { + const mail = await requireMailByAuthToken({ mailAuthToken, database }) + + const { familyId } = await database.transaction(async (transaction) => { + // update the user entry + const userEntry = await database.user.findOne({ + where: { + mail + }, + transaction, + lock: Sequelize.Transaction.LOCK.UPDATE + }) + + if (!userEntry) { + return { familyId: null } + } + + userEntry.passwordHash = password.hash + userEntry.secondPasswordHash = password.secondHash + userEntry.secondPasswordSalt = password.secondSalt + + await userEntry.save({ transaction }) + + // invalidate the user list + await database.family.update({ + userListVersion: generateVersionId() + }, { + where: { + familyId: userEntry.familyId + }, + transaction + }) + + return { familyId: userEntry.familyId } + }) + + if (familyId === null) { + throw new Conflict() + } + + await notifyClientsAboutChanges({ + database, + familyId, + websocket, + isImportant: true, + sourceDeviceId: null + }) +} diff --git a/src/function/parent/sign-in-into-family.ts b/src/function/parent/sign-in-into-family.ts new file mode 100644 index 0000000..6e18b94 --- /dev/null +++ b/src/function/parent/sign-in-into-family.ts @@ -0,0 +1,96 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Conflict } from 'http-errors' +import { NewDeviceInfo } from '../../api/schema' +import { Database } from '../../database' +import { generateAuthToken, generateIdWithinFamily, generateVersionId } from '../../util/token' +import { WebsocketApi } from '../../websocket' +import { requireMailByAuthToken } from '../authentication' +import { prepareDeviceEntry } from '../device/prepare-device-entry' +import { notifyClientsAboutChanges } from '../websocket' + +export const signInIntoFamily = async ({ database, mailAuthToken, newDeviceInfo, deviceName, websocket }: { + database: Database + mailAuthToken: string + newDeviceInfo: NewDeviceInfo + deviceName: string + websocket: WebsocketApi +}) => { + const mail = await requireMailByAuthToken({ database, mailAuthToken }) + + const { response, familyId, sourceDeviceId } = await database.transaction(async (transaction) => { + const userEntryUnsafe = await database.user.findOne({ + where: { + mail + }, + attributes: ['familyId', 'userId'], + transaction + }) + + if (!userEntryUnsafe) { + throw new Conflict() + } + + const userEntry = { + familyId: userEntryUnsafe.familyId, + userId: userEntryUnsafe.userId, + transaction + } + + const deviceAuthToken = generateAuthToken() + const deviceId = generateIdWithinFamily() + + await database.device.create(prepareDeviceEntry({ + familyId: userEntry.familyId, + deviceId, + userId: userEntry.userId, + deviceName, + deviceAuthToken, + newDeviceInfo + }), { transaction }) + + // notify about changes + await database.family.update({ + deviceListVersion: generateVersionId() + }, { + where: { + familyId: userEntry.familyId + }, + transaction + }) + + return { + response: { + deviceId, + deviceAuthToken + }, + sourceDeviceId: deviceId, + familyId: userEntry.familyId + } + }) + + await notifyClientsAboutChanges({ + familyId, + websocket, + database, + isImportant: true, + sourceDeviceId + }) + + return response +} diff --git a/src/function/purchase/add-purchase.ts b/src/function/purchase/add-purchase.ts new file mode 100644 index 0000000..d0fc209 --- /dev/null +++ b/src/function/purchase/add-purchase.ts @@ -0,0 +1,91 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Conflict } from 'http-errors' +import * as Sequelize from 'sequelize' +import { Database } from '../../database' +import { notifyClientsAboutChanges } from '../../function/websocket' +import { WebsocketApi } from '../../websocket' + +const day = 1000 * 60 * 60 * 24 +const month = day * 31 +const year = day * 366 + +export const addPurchase = async ({ database, familyId, type, transactionId, websocket }: { + database: Database + familyId: string + type: 'month' | 'year' + transactionId: string + websocket: WebsocketApi +}) => { + const service = 'googleplay' + + await database.transaction(async (transaction) => { + const oldPurchaseEntry = await database.purchase.findOne({ + where: { + service, + transactionId + }, + transaction + }) + + if (oldPurchaseEntry) { + return + } + + const familyEntry = await database.family.findOne({ + where: { + familyId + }, + transaction, + lock: Sequelize.Transaction.LOCK.UPDATE + }) + + if (!familyEntry) { + throw new Conflict() + } + + const previousFullVersionEndTime = familyEntry.fullVersionUntil + + const newFullVersionUntil = Math.max(parseInt(familyEntry.fullVersionUntil, 10), Date.now()) + (type === 'year' ? year : month) + + familyEntry.fullVersionUntil = newFullVersionUntil.toString(10) + familyEntry.hasFullVersion = true + + await familyEntry.save({ transaction }) + + await database.purchase.create({ + familyId, + service, + transactionId, + type, + loggedAt: Date.now().toString(10), + previousFullVersionEndTime, + newFullVersionEndTime: newFullVersionUntil.toString(10) + }, { + transaction + }) + + await notifyClientsAboutChanges({ + familyId, + sourceDeviceId: null, + database, + websocket, + isImportant: true + }) + }) +} diff --git a/src/function/purchase/can-do-next-purchase.ts b/src/function/purchase/can-do-next-purchase.ts new file mode 100644 index 0000000..50f5dbc --- /dev/null +++ b/src/function/purchase/can-do-next-purchase.ts @@ -0,0 +1,20 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export const canDoNextPurchase = ({ fullVersionUntil }: {fullVersionUntil: number}) => ( + fullVersionUntil < (Date.now() + 1000 * 60 * 60 * 24 * 31) // 31 days +) diff --git a/src/function/purchase/index.ts b/src/function/purchase/index.ts new file mode 100644 index 0000000..2d70929 --- /dev/null +++ b/src/function/purchase/index.ts @@ -0,0 +1,21 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export { canDoNextPurchase } from './can-do-next-purchase' +export { requireFamilyEntry } from './require-family-entry' +export { isGooglePlayPurchaseSignatureValid, areGooglePlayPaymentsPossible } from './verification' +export { addPurchase } from './add-purchase' diff --git a/src/function/purchase/require-family-entry.ts b/src/function/purchase/require-family-entry.ts new file mode 100644 index 0000000..22458a6 --- /dev/null +++ b/src/function/purchase/require-family-entry.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { InternalServerError, Unauthorized } from 'http-errors' +import { Database } from '../../database' + +export const requireFamilyEntry = async ({ database, deviceAuthToken }: { + database: Database + deviceAuthToken: string +}) => { + const deviceEntryUnsafe = await database.device.findOne({ + where: { + deviceAuthToken + }, + attributes: ['familyId'] + }) + + if (!deviceEntryUnsafe) { + throw new Unauthorized() + } + + const deviceEntry = { + familyId: deviceEntryUnsafe.familyId + } + + const familyEntryUnsafe = await database.family.findOne({ + where: { + familyId: deviceEntry.familyId + }, + attributes: ['fullVersionUntil'] + }) + + if (!familyEntryUnsafe) { + throw new InternalServerError() + } + + const familyEntry = { + fullVersionUntil: familyEntryUnsafe.fullVersionUntil + } + + return familyEntry +} diff --git a/src/function/purchase/verification.ts b/src/function/purchase/verification.ts new file mode 100644 index 0000000..fbe9b52 --- /dev/null +++ b/src/function/purchase/verification.ts @@ -0,0 +1,36 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +const IABVerifier: new (publicKey: string) => { + verifyReceipt: (data: string, signature: string) => boolean +} = require('iab_verifier') + +const googlePlayPublicKey = process.env.GOOGLE_PLAY_PUBLIC_KEY || '' + +const verifier = new IABVerifier(googlePlayPublicKey) + +export const areGooglePlayPaymentsPossible = !!googlePlayPublicKey +export const isGooglePlayPurchaseSignatureValid = ({ receipt, signature }: { + receipt: string + signature: string +}) => { + if (googlePlayPublicKey) { + return verifier.verifyReceipt(receipt, signature) + } else { + return false + } +} diff --git a/src/function/sync/apply-actions/cache.ts b/src/function/sync/apply-actions/cache.ts new file mode 100644 index 0000000..a38317d --- /dev/null +++ b/src/function/sync/apply-actions/cache.ts @@ -0,0 +1,242 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { memoize, uniq } from 'lodash' +import * as Sequelize from 'sequelize' +import { VisibleConnectedDevicesManager } from '../../../connected-devices' +import { Database } from '../../../database' +import { generateVersionId } from '../../../util/token' + +export class Cache { + readonly familyId: string + readonly hasFullVersion: boolean + readonly transaction: Sequelize.Transaction + readonly database: Database + readonly connectedDevicesManager: VisibleConnectedDevicesManager + private shouldTriggerFullSync = false + + categoriesWithModifiedApps: Array = [] + categoriesWithModifiedBaseData: Array = [] + categoriesWithModifiedTimeLimitRules: Array = [] + categoriesWithModifiedUsedTimes: Array = [] + + devicesWithModifiedInstalledApps: Array = [] + devicesWithModifiedShowDeviceConnected = new Map() + + invalidiateUserList = false + invalidiateDeviceList = false + areChangesImportant = false + + constructor ({ familyId, hasFullVersion, database, transaction, connectedDevicesManager }: { + familyId: string + hasFullVersion: boolean + database: Database + transaction: Sequelize.Transaction + connectedDevicesManager: VisibleConnectedDevicesManager + }) { + this.familyId = familyId + this.hasFullVersion = hasFullVersion + this.database = database + this.transaction = transaction + this.connectedDevicesManager = connectedDevicesManager + } + + getSecondPasswordHashOfParent = memoize(async (parentId: string) => { + const userEntryUnsafe = await this.database.user.findOne({ + where: { + familyId: this.familyId, + userId: parentId, + type: 'parent' + }, + attributes: ['secondPasswordHash'], + transaction: this.transaction + }) + + if (!userEntryUnsafe) { + throw new Error('user not found') + } + + return userEntryUnsafe.secondPasswordHash + }) + + getSecondPasswordHashOfChild = memoize(async (childId: string) => { + const userEntryUnsafe = await this.database.user.findOne({ + where: { + familyId: this.familyId, + userId: childId, + type: 'child' + }, + attributes: ['secondPasswordHash'], + transaction: this.transaction + }) + + if (!userEntryUnsafe) { + throw new Error('user not found') + } + + if (!userEntryUnsafe.secondPasswordHash) { + throw new Error('user does not have a password') + } + + return userEntryUnsafe.secondPasswordHash + }) + + doesCategoryExist = memoize(async (categoryId: string) => { + const categoryEntry = await this.database.category.findOne({ + where: { + familyId: this.familyId, + categoryId + }, + transaction: this.transaction + }) + + return !!categoryEntry + }) + + doesUserExist = memoize(async (userId: string) => { + const userEntry = await this.database.user.findOne({ + where: { + familyId: this.familyId, + userId + }, + transaction: this.transaction + }) + + return !!userEntry + }) + + shouldDoFullSync = () => this.shouldTriggerFullSync + requireFullSync = () => this.shouldTriggerFullSync = true + + async saveModifiedVersionNumbers () { + const { database, transaction, familyId } = this + + if (this.categoriesWithModifiedApps.length > 0) { + await database.category.update({ + assignedAppsVersion: generateVersionId() + }, { + where: { + familyId, + categoryId: { + [Sequelize.Op.in]: uniq(this.categoriesWithModifiedApps) + } + }, + transaction + }) + + this.categoriesWithModifiedApps = [] + } + + if (this.categoriesWithModifiedBaseData.length > 0) { + await database.category.update({ + baseVersion: generateVersionId() + }, { + where: { + familyId, + categoryId: { + [Sequelize.Op.in]: uniq(this.categoriesWithModifiedBaseData) + } + }, + transaction + }) + + this.categoriesWithModifiedBaseData = [] + } + + if (this.categoriesWithModifiedTimeLimitRules.length > 0) { + await database.category.update({ + timeLimitRulesVersion: generateVersionId() + }, { + where: { + familyId, + categoryId: { + [Sequelize.Op.in]: uniq(this.categoriesWithModifiedTimeLimitRules) + } + }, + transaction + }) + + this.categoriesWithModifiedTimeLimitRules = [] + } + + if (this.categoriesWithModifiedUsedTimes.length > 0) { + await database.category.update({ + usedTimesVersion: generateVersionId() + }, { + where: { + familyId, + categoryId: { + [Sequelize.Op.in]: uniq(this.categoriesWithModifiedUsedTimes) + } + }, + transaction + }) + + this.categoriesWithModifiedUsedTimes = [] + } + + if (this.devicesWithModifiedInstalledApps.length > 0) { + await database.device.update({ + installedAppsVersion: generateVersionId() + }, { + where: { + familyId, + deviceId: { + [Sequelize.Op.in]: uniq(this.devicesWithModifiedInstalledApps) + } + }, + transaction + }) + + this.devicesWithModifiedInstalledApps = [] + } + + if (this.invalidiateUserList) { + await database.family.update({ + userListVersion: generateVersionId() + }, { + where: { + familyId: this.familyId + }, + transaction + }) + + this.invalidiateUserList = false + } + + if (this.invalidiateDeviceList) { + await database.family.update({ + deviceListVersion: generateVersionId() + }, { + where: { + familyId: this.familyId + }, + transaction + }) + + this.invalidiateDeviceList = false + } + + this.devicesWithModifiedShowDeviceConnected.forEach((showDeviceConnected, deviceId) => { + this.connectedDevicesManager.notifyShareConnectedChanged({ + familyId: this.familyId, + deviceId, + showDeviceConnected + }) + }) + } +} diff --git a/src/function/sync/apply-actions/dispatch-app-logic-action/addinstalledapps.ts b/src/function/sync/apply-actions/dispatch-app-logic-action/addinstalledapps.ts new file mode 100644 index 0000000..3391f30 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-app-logic-action/addinstalledapps.ts @@ -0,0 +1,52 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { AddInstalledAppsAction } from '../../../../action' +import { AppAttributes } from '../../../../database/app' +import { Cache } from '../cache' + +export async function dispatchAddInstalledApps ({ deviceId, action, cache }: { + deviceId: string + action: AddInstalledAppsAction + cache: Cache +}) { + await cache.database.app.destroy({ + where: { + familyId: cache.familyId, + deviceId, + packageName: { + [Sequelize.Op.in]: action.apps.map((app) => app.packageName) + } + }, + transaction: cache.transaction + }) + + await cache.database.app.bulkCreate( + action.apps.map((app): AppAttributes => ({ + familyId: cache.familyId, + deviceId, + packageName: app.packageName, + title: app.title, + isLaunchable: app.isLaunchable, + recommendation: app.recommendation + })), + { transaction: cache.transaction } + ) + + cache.devicesWithModifiedInstalledApps.push(deviceId) +} diff --git a/src/function/sync/apply-actions/dispatch-app-logic-action/addusedtime.ts b/src/function/sync/apply-actions/dispatch-app-logic-action/addusedtime.ts new file mode 100644 index 0000000..bf8cd7f --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-app-logic-action/addusedtime.ts @@ -0,0 +1,129 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { AddUsedTimeAction } from '../../../../action' +import { Cache } from '../cache' + +const getRoundedTimestamp = () => { + const now = Date.now() + + return now - (now % (1000 * 60 * 60 * 24 * 2 /* 2 days */)) +} + +export async function dispatchAddUsedTime ({ deviceId, action, cache }: { + deviceId: string + action: AddUsedTimeAction + cache: Cache +}) { + const roundedTimestamp = getRoundedTimestamp().toString(10) + + const categoryEntryUnsafe = await cache.database.category.findOne({ + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction, + attributes: [ + 'childId', + 'parentCategoryId', + 'extraTimeInMillis' + ] + }) + // verify that the category exists + if (!categoryEntryUnsafe) { + throw new Error('invalid category id') + } + + const categoryEntry = { + childId: categoryEntryUnsafe.childId, + parentCategoryId: categoryEntryUnsafe.parentCategoryId, + extraTimeInMillis: categoryEntryUnsafe.extraTimeInMillis + } + + const handleAddUsedTime = async ({ categoryId, currentExtraTime }: { + categoryId: string, + currentExtraTime: number + }) => { + if (action.timeToAdd !== 0) { + // try to update first + const [updatedRows] = await cache.database.usedTime.update({ + usedTime: Sequelize.literal(`usedTime + ${action.timeToAdd}`) as any, + lastUpdate: roundedTimestamp + }, { + where: { + familyId: cache.familyId, + categoryId: categoryId, + dayOfEpoch: action.dayOfEpoch + }, + transaction: cache.transaction + }) + + // otherwise create + if (updatedRows === 0) { + await cache.database.usedTime.create({ + familyId: cache.familyId, + categoryId: categoryId, + dayOfEpoch: action.dayOfEpoch, + usedTime: action.timeToAdd, + lastUpdate: roundedTimestamp + }, { + transaction: cache.transaction + }) + } + } + + if (action.extraTimeToSubtract !== 0) { + await cache.database.category.update({ + extraTimeInMillis: Math.max(0, currentExtraTime - action.extraTimeToSubtract) + }, { + where: { + familyId: cache.familyId, + categoryId: categoryId + }, + transaction: cache.transaction + }) + + cache.categoriesWithModifiedBaseData.push(categoryId) + } + + cache.categoriesWithModifiedUsedTimes.push(categoryId) + } + + await handleAddUsedTime({ + categoryId: action.categoryId, + currentExtraTime: categoryEntry.extraTimeInMillis + }) + + if (categoryEntry.parentCategoryId !== '') { + const parentCategoryEntry = await cache.database.category.findOne({ + where: { + familyId: cache.familyId, + categoryId: categoryEntry.parentCategoryId, + childId: categoryEntry.childId + }, + transaction: cache.transaction + }) + + if (parentCategoryEntry) { + await handleAddUsedTime({ + categoryId: categoryEntry.parentCategoryId, + currentExtraTime: parentCategoryEntry.extraTimeInMillis + }) + } + } +} diff --git a/src/function/sync/apply-actions/dispatch-app-logic-action/index.ts b/src/function/sync/apply-actions/dispatch-app-logic-action/index.ts new file mode 100644 index 0000000..168cb47 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-app-logic-action/index.ts @@ -0,0 +1,55 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { + AddInstalledAppsAction, + AddUsedTimeAction, + AppLogicAction, + RemoveInstalledAppsAction, + SignOutAtDeviceAction, + TriedDisablingDeviceAdminAction, + UpdateDeviceStatusAction +} from '../../../../action' +import { Cache } from '../cache' +import { dispatchAddInstalledApps } from './addinstalledapps' +import { dispatchAddUsedTime } from './addusedtime' +import { dispatchRemoveInstalledApps } from './removeinstalledapps' +import { dispatchSignOutAtDevice } from './signoutatdevice' +import { dispatchTriedDisablingDeviceAdmin } from './trieddisablingdeviceadmin' +import { dispatchUpdateDeviceStatus } from './updatedevicestatus' + +export const dispatchAppLogicAction = async ({ action, deviceId, cache }: { + action: AppLogicAction + deviceId: string + cache: Cache +}) => { + if (action instanceof AddInstalledAppsAction) { + await dispatchAddInstalledApps({ deviceId, action, cache }) + } else if (action instanceof AddUsedTimeAction) { + await dispatchAddUsedTime({ deviceId, action, cache }) + } else if (action instanceof RemoveInstalledAppsAction) { + await dispatchRemoveInstalledApps({ deviceId, action, cache }) + } else if (action instanceof SignOutAtDeviceAction) { + await dispatchSignOutAtDevice({ deviceId, action, cache }) + } else if (action instanceof UpdateDeviceStatusAction) { + await dispatchUpdateDeviceStatus({ deviceId, action, cache }) + } else if (action instanceof TriedDisablingDeviceAdminAction) { + await dispatchTriedDisablingDeviceAdmin({ deviceId, action, cache }) + } else { + throw new Error('unsupported action type') + } +} diff --git a/src/function/sync/apply-actions/dispatch-app-logic-action/removeinstalledapps.ts b/src/function/sync/apply-actions/dispatch-app-logic-action/removeinstalledapps.ts new file mode 100644 index 0000000..0324e9a --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-app-logic-action/removeinstalledapps.ts @@ -0,0 +1,39 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { RemoveInstalledAppsAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchRemoveInstalledApps ({ deviceId, action, cache }: { + deviceId: string + action: RemoveInstalledAppsAction + cache: Cache +}) { + await cache.database.app.destroy({ + where: { + familyId: cache.familyId, + deviceId, + packageName: { + [Sequelize.Op.in]: action.packageNames + } + }, + transaction: cache.transaction + }) + + cache.devicesWithModifiedInstalledApps.push(deviceId) +} diff --git a/src/function/sync/apply-actions/dispatch-app-logic-action/signoutatdevice.ts b/src/function/sync/apply-actions/dispatch-app-logic-action/signoutatdevice.ts new file mode 100644 index 0000000..154da97 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-app-logic-action/signoutatdevice.ts @@ -0,0 +1,56 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetDeviceUserAction, SignOutAtDeviceAction } from '../../../../action' +import { Cache } from '../cache' +import { dispatchSetDeviceUser } from '../dispatch-parent-action/setdeviceuser' + +export async function dispatchSignOutAtDevice ({ deviceId, action, cache }: { + deviceId: string + action: SignOutAtDeviceAction + cache: Cache +}) { + if (!cache.hasFullVersion) { + throw new Error('action requires full version') + } + + const deviceEntry = await cache.database.device.findOne({ + where: { + familyId: cache.familyId, + deviceId + }, + transaction: cache.transaction + }) + + if (!deviceEntry) { + throw new Error('illegal state: missing device which dispatched the action') + } + + if (deviceEntry.defaultUserId === '') { + throw new Error('no default user available') + } + + if (deviceEntry.currentUserId !== deviceEntry.defaultUserId) { + await dispatchSetDeviceUser({ + cache, + action: new SetDeviceUserAction({ + deviceId, + userId: deviceEntry.defaultUserId + }) + }) + } +} diff --git a/src/function/sync/apply-actions/dispatch-app-logic-action/trieddisablingdeviceadmin.ts b/src/function/sync/apply-actions/dispatch-app-logic-action/trieddisablingdeviceadmin.ts new file mode 100644 index 0000000..e2283f9 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-app-logic-action/trieddisablingdeviceadmin.ts @@ -0,0 +1,59 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { TriedDisablingDeviceAdminAction } from '../../../../action' +import { hasDeviceManipulation } from '../../../../database/device' +import { sendManipulationWarnings } from '../../../warningmail/manipulation' +import { Cache } from '../cache' + +export async function dispatchTriedDisablingDeviceAdmin ({ deviceId, action, cache }: { + deviceId: string + action: TriedDisablingDeviceAdminAction + cache: Cache +}) { + const deviceEntry = await cache.database.device.findOne({ + where: { + familyId: cache.familyId, + deviceId + }, + transaction: cache.transaction + }) + + if (deviceEntry === null) { + throw new Error('illegal state: missing device which dispatched the action') + } + + const hadManipulationBefore = hasDeviceManipulation(deviceEntry) + + if (!deviceEntry.triedDisablingDeviceAdmin) { + deviceEntry.triedDisablingDeviceAdmin = true + + await deviceEntry.save({ transaction: cache.transaction }) + + cache.invalidiateDeviceList = true + cache.areChangesImportant = true + } + + if (!hadManipulationBefore) { + await sendManipulationWarnings({ + database: cache.database, + transaction: cache.transaction, + deviceName: deviceEntry.name, + familyId: cache.familyId + }) + } +} diff --git a/src/function/sync/apply-actions/dispatch-app-logic-action/updatedevicestatus.ts b/src/function/sync/apply-actions/dispatch-app-logic-action/updatedevicestatus.ts new file mode 100644 index 0000000..afdd2d7 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-app-logic-action/updatedevicestatus.ts @@ -0,0 +1,128 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { UpdateDeviceStatusAction } from '../../../../action' +import { hasDeviceManipulation } from '../../../../database/device' +import { newPermissionStatusValues } from '../../../../model/newpermissionstatus' +import { protetionLevels } from '../../../../model/protectionlevel' +import { runtimePermissionStatusValues } from '../../../../model/runtimepermissionstatus' +import { enumMax } from '../../../../util/enum' +import { sendManipulationWarnings } from '../../../warningmail/manipulation' +import { Cache } from '../cache' + +export async function dispatchUpdateDeviceStatus ({ deviceId, action, cache }: { + deviceId: string + action: UpdateDeviceStatusAction + cache: Cache +}) { + const deviceEntry = await cache.database.device.findOne({ + where: { + familyId: cache.familyId, + deviceId + }, + transaction: cache.transaction + }) + + if (!deviceEntry) { + throw new Error('device not found') + } + + const hadManipulationBefore = hasDeviceManipulation(deviceEntry) + + if (action.newProtetionLevel) { + const hasChanged = deviceEntry.currentProtectionLevel !== action.newProtetionLevel + + deviceEntry.currentProtectionLevel = action.newProtetionLevel + + deviceEntry.highestProtectionLevel = enumMax( + deviceEntry.currentProtectionLevel, + deviceEntry.highestProtectionLevel, + protetionLevels + ) + + if (hasChanged && (deviceEntry.currentProtectionLevel !== deviceEntry.highestProtectionLevel)) { + deviceEntry.hadManipulation = true + } + } + + if (action.newUsageStatsPermissionStatus) { + const hasChanged = deviceEntry.currentUsageStatsPermission !== action.newUsageStatsPermissionStatus + + deviceEntry.currentUsageStatsPermission = action.newUsageStatsPermissionStatus + + deviceEntry.highestUsageStatsPermission = enumMax( + deviceEntry.currentUsageStatsPermission, + deviceEntry.highestUsageStatsPermission, + runtimePermissionStatusValues + ) + + if (hasChanged && (deviceEntry.currentUsageStatsPermission !== deviceEntry.highestUsageStatsPermission)) { + deviceEntry.hadManipulation = true + } + } + + if (action.newNotificationAccessPermission) { + const hasChanged = deviceEntry.currentNotificationAccessPermission !== action.newNotificationAccessPermission + + deviceEntry.currentNotificationAccessPermission = action.newNotificationAccessPermission + + deviceEntry.highestNotificationAccessPermission = enumMax( + deviceEntry.currentNotificationAccessPermission, + deviceEntry.highestNotificationAccessPermission, + newPermissionStatusValues + ) + + if (hasChanged && (deviceEntry.currentNotificationAccessPermission !== deviceEntry.highestNotificationAccessPermission)) { + deviceEntry.hadManipulation = true + } + } + + if (action.newAppVersion !== undefined) { + const hasChanged = deviceEntry.currentAppVersion !== action.newAppVersion + + deviceEntry.currentAppVersion = action.newAppVersion + + deviceEntry.highestAppVersion = Math.max( + deviceEntry.currentAppVersion, + deviceEntry.highestAppVersion + ) + + if (hasChanged && (deviceEntry.currentAppVersion !== deviceEntry.highestAppVersion)) { + deviceEntry.hadManipulation = true + } + } + + if (action.didReboot) { + deviceEntry.didReboot = true + } + + await deviceEntry.save({ transaction: cache.transaction }) + + if (hasDeviceManipulation(deviceEntry)) { + if (!hadManipulationBefore) { + await sendManipulationWarnings({ + database: cache.database, + transaction: cache.transaction, + deviceName: deviceEntry.name, + familyId: cache.familyId + }) + } + } + + cache.invalidiateDeviceList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-child-action/childchangepassword.ts b/src/function/sync/apply-actions/dispatch-child-action/childchangepassword.ts new file mode 100644 index 0000000..1ba8d25 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-child-action/childchangepassword.ts @@ -0,0 +1,50 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { ChildChangePasswordAction } from '../../../../action' +import { Cache } from '../cache' + +export const dispatchChildChangePassword = async ({ action, childUserId, cache }: { + action: ChildChangePasswordAction + childUserId: string + cache: Cache +}) => { + const childEntry = await cache.database.user.findOne({ + where: { + familyId: cache.familyId, + userId: childUserId, + type: 'child' + }, + transaction: cache.transaction, + lock: Sequelize.Transaction.LOCK.UPDATE + }) + + if (!childEntry) { + throw new Error('child entry not found') + } + + childEntry.passwordHash = action.password.hash + childEntry.secondPasswordSalt = action.password.secondSalt + childEntry.secondPasswordHash = action.password.secondHash + + await childEntry.save({ transaction: cache.transaction }) + + cache.getSecondPasswordHashOfChild.cache.clear() + cache.invalidiateUserList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-child-action/childsignin.ts b/src/function/sync/apply-actions/dispatch-child-action/childsignin.ts new file mode 100644 index 0000000..f84d80b --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-child-action/childsignin.ts @@ -0,0 +1,72 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { ChildSignInAction, SetDeviceUserAction } from '../../../../action' +import { Cache } from '../cache' +import { dispatchSetDeviceUser } from '../dispatch-parent-action/setdeviceuser' + +export const dispatchChildSignIn = async ({ action, deviceId, childUserId, cache }: { + action: ChildSignInAction + deviceId: string + childUserId: string + cache: Cache +}) => { + if (!cache.hasFullVersion) { + throw new Error('action requires full version') + } + + await dispatchSetDeviceUser({ + action: new SetDeviceUserAction({ + deviceId, + userId: childUserId + }), + cache + }) + + const userEntryUnsafe = await cache.database.user.findOne({ + where: { + familyId: cache.familyId, + type: 'child', + userId: childUserId + }, + transaction: cache.transaction, + attributes: [ + 'currentDevice' + ] + }) + + if (!userEntryUnsafe) { + throw new Error('illegal state') + } + + if (userEntryUnsafe.currentDevice === deviceId) { + // unassign to prevent way aroundprimary device rule + + await cache.database.user.update({ + currentDevice: '' + }, { + where: { + familyId: cache.familyId, + type: 'child', + userId: childUserId + }, + transaction: cache.transaction + }) + + cache.invalidiateUserList = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-child-action/index.ts b/src/function/sync/apply-actions/dispatch-child-action/index.ts new file mode 100644 index 0000000..d0cbc76 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-child-action/index.ts @@ -0,0 +1,40 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { + ChildAction, + ChildChangePasswordAction, + ChildSignInAction +} from '../../../../action' +import { Cache } from '../cache' +import { dispatchChildChangePassword } from './childchangepassword' +import { dispatchChildSignIn } from './childsignin' + +export const dispatchChildAction = async ({ action, deviceId, childUserId, cache }: { + action: ChildAction + deviceId: string + childUserId: string + cache: Cache +}) => { + if (action instanceof ChildChangePasswordAction) { + await dispatchChildChangePassword({ action, childUserId, cache }) + } else if (action instanceof ChildSignInAction) { + await dispatchChildSignIn({ action, childUserId, deviceId, cache }) + } else { + throw new Error('unsupported action type') + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/addcategoryapps.ts b/src/function/sync/apply-actions/dispatch-parent-action/addcategoryapps.ts new file mode 100644 index 0000000..22f5278 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/addcategoryapps.ts @@ -0,0 +1,77 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { AddCategoryAppsAction } from '../../../../action' +import { CategoryAppAttributes } from '../../../../database/categoryapp' +import { Cache } from '../cache' + +export async function dispatchAddCategoryApps ({ action, cache }: { + action: AddCategoryAppsAction + cache: Cache +}) { + const categoryEntryUnsafe = await cache.database.category.findOne({ + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction, + attributes: ['childId'] + }) + + if (!categoryEntryUnsafe) { + throw new Error('invalid category id') + } + + const { childId } = categoryEntryUnsafe + + const categoriesOfSameChild = await cache.database.category.findAll({ + where: { + familyId: cache.familyId, + childId + }, + attributes: ['categoryId'], + transaction: cache.transaction + }).map((item) => ({ categoryId: item.categoryId })) + + await cache.database.categoryApp.destroy({ + where: { + familyId: cache.familyId, + categoryId: { + [Sequelize.Op.in]: categoriesOfSameChild.map((item) => item.categoryId) + }, + packageName: { + [Sequelize.Op.in]: action.packageNames + } + }, + transaction: cache.transaction + }) + + await cache.database.categoryApp.bulkCreate( + action.packageNames.map((packageName): CategoryAppAttributes => ({ + familyId: cache.familyId, + categoryId: action.categoryId, + packageName + })), + { + transaction: cache.transaction + } + ) + + cache.categoriesWithModifiedApps.push(action.categoryId) + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/adduser.ts b/src/function/sync/apply-actions/dispatch-parent-action/adduser.ts new file mode 100644 index 0000000..b92c777 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/adduser.ts @@ -0,0 +1,46 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { AddUserAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchAddUser ({ action, cache }: { + action: AddUserAction + cache: Cache +}) { + await cache.database.user.create({ + familyId: cache.familyId, + userId: action.userId, + type: action.userType, + name: action.name, + timeZone: action.timeZone, + passwordHash: action.password ? action.password.hash : '', + secondPasswordHash: action.password ? action.password.secondHash : '', + secondPasswordSalt: action.password ? action.password.secondSalt : '', + mail: '', + disableTimelimitsUntil: '0', + currentDevice: '', + categoryForNotAssignedApps: '', + relaxPrimaryDeviceRule: false, + mailNotificationFlags: 0 + }, { transaction: cache.transaction }) + + cache.invalidiateUserList = true + cache.areChangesImportant = true + + cache.doesUserExist.cache.set(action.userId, true) +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/changeparentpassword.ts b/src/function/sync/apply-actions/dispatch-parent-action/changeparentpassword.ts new file mode 100644 index 0000000..3de0cc9 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/changeparentpassword.ts @@ -0,0 +1,52 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { ChangeParentPasswordAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchChangeParentPassword ({ action, cache }: { + action: ChangeParentPasswordAction + cache: Cache +}) { + const parentEntry = await cache.database.user.findOne({ + where: { + familyId: cache.familyId, + userId: action.parentUserId, + type: 'parent' + }, + transaction: cache.transaction, + lock: Sequelize.Transaction.LOCK.UPDATE + }) + + if (!parentEntry) { + throw new Error('parent entry not found') + } + + action.assertIntegrityValid({ oldPasswordSecondHash: parentEntry.secondPasswordHash }) + const newSecondPasswordHash = action.decryptSecondHash({ oldPasswordSecondHash: parentEntry.secondPasswordHash }) + + parentEntry.passwordHash = action.newPasswordFirstHash + parentEntry.secondPasswordSalt = action.newPasswordSecondSalt + parentEntry.secondPasswordHash = newSecondPasswordHash + + await parentEntry.save({ transaction: cache.transaction }) + + cache.getSecondPasswordHashOfParent.cache.clear() + cache.invalidiateUserList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/createcategory.ts b/src/function/sync/apply-actions/dispatch-parent-action/createcategory.ts new file mode 100644 index 0000000..ab3f7a3 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/createcategory.ts @@ -0,0 +1,59 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { CreateCategoryAction } from '../../../../action' +import { generateVersionId } from '../../../../util/token' +import { Cache } from '../cache' + +export async function dispatchCreateCategory ({ action, cache }: { + action: CreateCategoryAction + cache: Cache +}) { + // check that the child exists + const childEntry = await cache.database.user.findOne({ + where: { + familyId: cache.familyId, + userId: action.childId, + type: 'child' + }, + transaction: cache.transaction + }) + + if (!childEntry) { + throw new Error('missing child for new category') + } + + // no version number needs to be updated + await cache.database.category.create({ + familyId: cache.familyId, + categoryId: action.categoryId, + childId: action.childId, + title: action.title, + blockedMinutesInWeek: '', + temporarilyBlocked: false, + extraTimeInMillis: 0, + timeLimitRulesVersion: generateVersionId(), + baseVersion: generateVersionId(), + assignedAppsVersion: generateVersionId(), + usedTimesVersion: generateVersionId(), + parentCategoryId: '' + }, { transaction: cache.transaction }) + + // update the cache + cache.doesCategoryExist.cache.set(action.categoryId, true) + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/createtimelimitrule.ts b/src/function/sync/apply-actions/dispatch-parent-action/createtimelimitrule.ts new file mode 100644 index 0000000..ea6a135 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/createtimelimitrule.ts @@ -0,0 +1,42 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { CreateTimeLimitRuleAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchCreateTimeLimitRule ({ action, cache }: { + action: CreateTimeLimitRuleAction + cache: Cache +}) { + const doesCategoryExist = await cache.doesCategoryExist(action.rule.categoryId) + + if (!doesCategoryExist) { + throw new Error('invalid category id for new rule') + } + + await cache.database.timelimitRule.create({ + familyId: cache.familyId, + ruleId: action.rule.ruleId, + categoryId: action.rule.categoryId, + applyToExtraTimeUsage: action.rule.applyToExtraTimeUsage, + maximumTimeInMillis: action.rule.maxTimeInMillis, + dayMaskAsBitmask: action.rule.dayMask + }, { transaction: cache.transaction }) + + cache.categoriesWithModifiedTimeLimitRules.push(action.rule.categoryId) + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/deletecategory.ts b/src/function/sync/apply-actions/dispatch-parent-action/deletecategory.ts new file mode 100644 index 0000000..a55a460 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/deletecategory.ts @@ -0,0 +1,78 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { DeleteCategoryAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchDeleteCategory ({ action, cache }: { + action: DeleteCategoryAction + cache: Cache +}) { + // no version number needs to be updated + const { familyId, transaction } = cache + const { categoryId } = action + + await cache.database.timelimitRule.destroy({ + where: { + familyId, + categoryId + }, + transaction + }) + + await cache.database.usedTime.destroy({ + where: { + familyId, + categoryId + }, + transaction + }) + + await cache.database.categoryApp.destroy({ + where: { + familyId, + categoryId + }, + transaction + }) + + const [affectedUserRows] = await cache.database.user.update({ + categoryForNotAssignedApps: '' + }, { + where: { + familyId, + categoryForNotAssignedApps: categoryId + }, + transaction + }) + + await cache.database.category.destroy({ + where: { + familyId, + categoryId + }, + transaction + }) + + // update the cache + cache.doesCategoryExist.cache.set(action.categoryId, false) + cache.areChangesImportant = true + + if (affectedUserRows !== 0) { + cache.invalidiateUserList = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/deletetimelimitrule.ts b/src/function/sync/apply-actions/dispatch-parent-action/deletetimelimitrule.ts new file mode 100644 index 0000000..eb7ea47 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/deletetimelimitrule.ts @@ -0,0 +1,39 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { DeleteTimeLimitRuleAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchDeleteTimeLimitRule ({ action, cache }: { + action: DeleteTimeLimitRuleAction + cache: Cache +}) { + const ruleEntry = await cache.database.timelimitRule.findOne({ + where: { + familyId: cache.familyId, + ruleId: action.ruleId + }, + transaction: cache.transaction + }) + + if (ruleEntry) { + await ruleEntry.destroy({ transaction: cache.transaction }) + + cache.categoriesWithModifiedTimeLimitRules.push(ruleEntry.categoryId) + cache.areChangesImportant = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/ignoremanipulation.ts b/src/function/sync/apply-actions/dispatch-parent-action/ignoremanipulation.ts new file mode 100644 index 0000000..0951401 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/ignoremanipulation.ts @@ -0,0 +1,67 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { IgnoreManipulationAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchIgnoreManipulation ({ action, cache }: { + action: IgnoreManipulationAction + cache: Cache +}) { + const deviceEntry = await cache.database.device.findOne({ + where: { + familyId: cache.familyId, + deviceId: action.deviceId + }, + transaction: cache.transaction + }) + + if (deviceEntry === null) { + throw new Error('illegal state: missing device which dispatched the action') + } + + if (action.ignoreDeviceAdminManipulation) { + deviceEntry.highestProtectionLevel = deviceEntry.currentProtectionLevel + } + + if (action.ignoreDeviceAdminManipulationAttempt) { + deviceEntry.triedDisablingDeviceAdmin = false + } + + if (action.ignoreAppDowngrade) { + deviceEntry.highestAppVersion = deviceEntry.currentAppVersion + } + + if (action.ignoreNotificationAccessManipulation) { + deviceEntry.highestNotificationAccessPermission = deviceEntry.currentNotificationAccessPermission + } + + if (action.ignoreUsageStatsAccessManipulation) { + deviceEntry.highestUsageStatsPermission = deviceEntry.currentUsageStatsPermission + } + + if (action.ignoreDidReboot) { + deviceEntry.didReboot = false + } + + if (action.ignoreHadManipulation) { + deviceEntry.hadManipulation = false + } + + await deviceEntry.save({ transaction: cache.transaction }) + cache.invalidiateDeviceList = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/incrementcategoryextratime.ts b/src/function/sync/apply-actions/dispatch-parent-action/incrementcategoryextratime.ts new file mode 100644 index 0000000..e49efc0 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/incrementcategoryextratime.ts @@ -0,0 +1,80 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { IncrementCategoryExtraTimeAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchIncrementCategoryExtraTime ({ action, cache }: { + action: IncrementCategoryExtraTimeAction + cache: Cache +}) { + if (!cache.hasFullVersion) { + throw new Error('action requires full version') + } + + const categoryEntryUnsafe = await cache.database.category.findOne({ + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction, + attributes: [ + 'childId', + 'parentCategoryId' + ] + }) + + if (!categoryEntryUnsafe) { + throw new Error(`tried to add extra time to ${action.categoryId} but it does not exist`) + } + + const categoryEntry = { + childId: categoryEntryUnsafe.childId, + parentCategoryId: categoryEntryUnsafe.parentCategoryId + } + + await cache.database.category.update({ + extraTimeInMillis: Sequelize.literal(`extraTimeInMillis + ${action.addedExtraTime}`) as any + }, { + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction + }) + + cache.categoriesWithModifiedBaseData.push(action.categoryId) + cache.areChangesImportant = true + + if (categoryEntry.parentCategoryId !== '') { + const [affectedRows] = await cache.database.category.update({ + extraTimeInMillis: Sequelize.literal(`extraTimeInMillis + ${action.addedExtraTime}`) as any + }, { + where: { + familyId: cache.familyId, + categoryId: categoryEntry.parentCategoryId, + childId: categoryEntry.childId + }, + transaction: cache.transaction + }) + + if (affectedRows !== 0) { + cache.categoriesWithModifiedBaseData.push(categoryEntry.parentCategoryId) + } + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/index.ts b/src/function/sync/apply-actions/dispatch-parent-action/index.ts new file mode 100644 index 0000000..cfb3fb0 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/index.ts @@ -0,0 +1,160 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { + AddCategoryAppsAction, + AddUserAction, + ChangeParentPasswordAction, + CreateCategoryAction, + CreateTimeLimitRuleAction, + DeleteCategoryAction, + DeleteTimeLimitRuleAction, + IgnoreManipulationAction, + IncrementCategoryExtraTimeAction, + ParentAction, + RemoveCategoryAppsAction, + RemoveUserAction, + RenameChildAction, + SetCategoryExtraTimeAction, + SetCategoryForUnassignedAppsAction, + SetChildPasswordAction, + SetConsiderRebootManipulationAction, + SetDeviceDefaultUserAction, + SetDeviceDefaultUserTimeoutAction, + SetDeviceUserAction, + SetKeepSignedInAction, + SetParentCategoryAction, + SetRelaxPrimaryDeviceAction, + SetSendDeviceConnected, + SetUserDisableLimitsUntilAction, + SetUserTimezoneAction, + UpdateCategoryBlockedTimesAction, + UpdateCategoryTemporarilyBlockedAction, + UpdateCategoryTitleAction, + UpdateDeviceNameAction, + UpdateNetworkTimeVerificationAction, + UpdateParentNotificationFlagsAction, + UpdateTimelimitRuleAction +} from '../../../../action' +import { Cache } from '../cache' +import { dispatchAddCategoryApps } from './addcategoryapps' +import { dispatchAddUser } from './adduser' +import { dispatchChangeParentPassword } from './changeparentpassword' +import { dispatchCreateCategory } from './createcategory' +import { dispatchCreateTimeLimitRule } from './createtimelimitrule' +import { dispatchDeleteCategory } from './deletecategory' +import { dispatchDeleteTimeLimitRule } from './deletetimelimitrule' +import { dispatchIgnoreManipulation } from './ignoremanipulation' +import { dispatchIncrementCategoryExtraTime } from './incrementcategoryextratime' +import { dispatchRemoveCategoryApps } from './removecategoryapps' +import { dispatchRemoveUser } from './removeuser' +import { dispatchRenameChild } from './renamechild' +import { dispatchSetCategoryExtraTime } from './setcategoryextratime' +import { dispatchSetCategoryForUnassignedApps } from './setcategoryforunassignedapps' +import { dispatchSetChildPassword } from './setchildpassword' +import { dispatchSetConsiderRebootManipulation } from './setconsiderrebootmanipulation' +import { dispatchSetDeviceDefaultUser } from './setdevicedefaultuser' +import { dispatchSetDeviceDefaultUserTimeout } from './setdevicedefaultusertimeout' +import { dispatchSetDeviceUser } from './setdeviceuser' +import { dispatchSetKeepSignedIn } from './setkeepsignedin' +import { dispatchSetParentCategory } from './setparentcategory' +import { dispatchSetRelaxPrimaryDevice } from './setrelaxprimarydevice' +import { dispatchSetSendDeviceConnected } from './setsenddeviceconnected' +import { dispatchUserSetDisableLimitsUntil } from './setuserdisablelmitsuntil' +import { dispatchSetUserTimezone } from './setusertimezone' +import { dispatchUpdateCategoryBlockedTimes } from './updatecategoryblockedtimes' +import { dispatchUpdateCategoryTemporarilyBlocked } from './updatecategorytemporarilyblocked' +import { dispatchUpdateCategoryTitle } from './updatecategorytitle' +import { dispatchUpdateDeviceName } from './updatedevicename' +import { dispatchUpdateNetworkTimeVerification } from './updatenetworktimeverification' +import { dispatchUpdateParentNotificationFlags } from './updateparentnotificationflags' +import { dispatchUpdateTimelimitRule } from './updatetimelimitrule' + +export const dispatchParentAction = async ({ action, cache, parentUserId, sourceDeviceId }: { + action: ParentAction + cache: Cache + parentUserId: string + sourceDeviceId: string | null +}) => { + if (action instanceof AddCategoryAppsAction) { + await dispatchAddCategoryApps({ action, cache }) + } else if (action instanceof AddUserAction) { + await dispatchAddUser({ action, cache }) + } else if (action instanceof RemoveCategoryAppsAction) { + await dispatchRemoveCategoryApps({ action, cache }) + } else if (action instanceof CreateCategoryAction) { + await dispatchCreateCategory({ action, cache }) + } else if (action instanceof CreateTimeLimitRuleAction) { + await dispatchCreateTimeLimitRule({ action, cache }) + } else if (action instanceof DeleteCategoryAction) { + await dispatchDeleteCategory({ action, cache }) + } else if (action instanceof UpdateCategoryTitleAction) { + await dispatchUpdateCategoryTitle({ action, cache }) + } else if (action instanceof SetCategoryExtraTimeAction) { + await dispatchSetCategoryExtraTime({ action, cache }) + } else if (action instanceof SetCategoryForUnassignedAppsAction) { + await dispatchSetCategoryForUnassignedApps({ action, cache }) + } else if (action instanceof SetChildPasswordAction) { + await dispatchSetChildPassword({ action, cache }) + } else if (action instanceof SetConsiderRebootManipulationAction) { + await dispatchSetConsiderRebootManipulation({ action, cache }) + } else if (action instanceof SetDeviceDefaultUserAction) { + await dispatchSetDeviceDefaultUser({ action, cache }) + } else if (action instanceof SetDeviceDefaultUserTimeoutAction) { + await dispatchSetDeviceDefaultUserTimeout({ action, cache }) + } else if (action instanceof SetDeviceUserAction) { + await dispatchSetDeviceUser({ action, cache }) + } else if (action instanceof SetKeepSignedInAction) { + await dispatchSetKeepSignedIn({ action, cache, parentUserId }) + } else if (action instanceof SetParentCategoryAction) { + await dispatchSetParentCategory({ action, cache }) + } else if (action instanceof SetRelaxPrimaryDeviceAction) { + await dispatchSetRelaxPrimaryDevice({ action, cache }) + } else if (action instanceof SetSendDeviceConnected) { + await dispatchSetSendDeviceConnected({ action, cache, sourceDeviceId }) + } else if (action instanceof SetUserDisableLimitsUntilAction) { + await dispatchUserSetDisableLimitsUntil({ action, cache }) + } else if (action instanceof SetUserTimezoneAction) { + await dispatchSetUserTimezone({ action, cache }) + } else if (action instanceof UpdateCategoryBlockedTimesAction) { + await dispatchUpdateCategoryBlockedTimes({ action, cache }) + } else if (action instanceof IncrementCategoryExtraTimeAction) { + await dispatchIncrementCategoryExtraTime({ action, cache }) + } else if (action instanceof UpdateCategoryTemporarilyBlockedAction) { + await dispatchUpdateCategoryTemporarilyBlocked({ action, cache }) + } else if (action instanceof DeleteTimeLimitRuleAction) { + await dispatchDeleteTimeLimitRule({ action, cache }) + } else if (action instanceof UpdateDeviceNameAction) { + await dispatchUpdateDeviceName({ action, cache }) + } else if (action instanceof UpdateNetworkTimeVerificationAction) { + await dispatchUpdateNetworkTimeVerification({ action, cache }) + } else if (action instanceof UpdateParentNotificationFlagsAction) { + await dispatchUpdateParentNotificationFlags({ action, cache }) + } else if (action instanceof UpdateTimelimitRuleAction) { + await dispatchUpdateTimelimitRule({ action, cache }) + } else if (action instanceof RemoveUserAction) { + await dispatchRemoveUser({ action, cache, parentUserId }) + } else if (action instanceof RenameChildAction) { + await dispatchRenameChild({ action, cache }) + } else if (action instanceof ChangeParentPasswordAction) { + await dispatchChangeParentPassword({ action, cache }) + } else if (action instanceof IgnoreManipulationAction) { + await dispatchIgnoreManipulation({ action, cache }) + } else { + throw new Error('unsupported action type') + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/removecategoryapps.ts b/src/function/sync/apply-actions/dispatch-parent-action/removecategoryapps.ts new file mode 100644 index 0000000..de56752 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/removecategoryapps.ts @@ -0,0 +1,43 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { RemoveCategoryAppsAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchRemoveCategoryApps ({ action, cache }: { + action: RemoveCategoryAppsAction + cache: Cache +}) { + const affectedRows = await cache.database.categoryApp.destroy({ + where: { + familyId: cache.familyId, + categoryId: action.categoryId, + packageName: { + [Sequelize.Op.in]: action.packageNames + } + }, + transaction: cache.transaction + }) + + if (affectedRows !== action.packageNames.length) { + throw new Error('could not delete as much entries as requested') + } + + cache.categoriesWithModifiedApps.push(action.categoryId) + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/removeuser.ts b/src/function/sync/apply-actions/dispatch-parent-action/removeuser.ts new file mode 100644 index 0000000..1fcd91b --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/removeuser.ts @@ -0,0 +1,159 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { createHash } from 'crypto' +import { InternalServerError } from 'http-errors' +import * as Sequelize from 'sequelize' +import { RemoveUserAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchRemoveUser ({ action, cache, parentUserId }: { + action: RemoveUserAction + cache: Cache + parentUserId: string +}) { + const user = await cache.database.user.findOne({ + where: { + familyId: cache.familyId, + userId: action.userId + }, + transaction: cache.transaction + }) + + if (!user) { + throw new Error('invalid user id') + } + + if (user.type === 'parent') { + if (!parentUserId) { + throw new InternalServerError() + } + + if (parentUserId === action.userId) { + throw new Error('users can not delete themself') + } + + const expectedIntegrityValue = createHash('sha512').update( + action.userId + user.secondPasswordHash + 'remove' + ).digest('hex').substring(0, 16) + + if (expectedIntegrityValue !== action.authentication) { + throw new Error('invalid authentication value') + } + + if (user.mail !== '') { + const usersWithLinkedMail = await cache.database.user.count({ + transaction: cache.transaction, + where: { + familyId: cache.familyId, + type: 'parent', + mail: { + [Sequelize.Op.not]: '' + } + } + }) + + if (usersWithLinkedMail <= 1) { + throw new Error('this user is the last one with a linked mail address') + } + } + } + + if (user.type === 'child') { + const categories = await cache.database.category.findAll({ + where: { + familyId: cache.familyId, + childId: action.userId + }, + transaction: cache.transaction, + lock: Sequelize.Transaction.LOCK.UPDATE + }) + + await cache.database.categoryApp.destroy({ + where: { + familyId: cache.familyId, + categoryId: { + [Sequelize.Op.in]: categories.map((category) => category.categoryId) + } + }, + transaction: cache.transaction + }) + + await cache.database.timelimitRule.destroy({ + where: { + familyId: cache.familyId, + categoryId: { + [Sequelize.Op.in]: categories.map((category) => category.categoryId) + } + }, + transaction: cache.transaction + }) + + await cache.database.usedTime.destroy({ + where: { + familyId: cache.familyId, + categoryId: { + [Sequelize.Op.in]: categories.map((category) => category.categoryId) + } + }, + transaction: cache.transaction + }) + + await cache.database.category.destroy({ + where: { + familyId: cache.familyId, + categoryId: { + [Sequelize.Op.in]: categories.map((category) => category.categoryId) + } + }, + transaction: cache.transaction + }) + } + + const [updatedDevices1] = await cache.database.device.update({ + currentUserId: '', + isUserKeptSignedIn: false + }, { + where: { + familyId: cache.familyId, + currentUserId: action.userId + }, + transaction: cache.transaction + }) + + const [updatedDevices2] = await cache.database.device.update({ + defaultUserId: '' + }, { + where: { + familyId: cache.familyId, + defaultUserId: action.userId + }, + transaction: cache.transaction + }) + + if (updatedDevices1 > 0 || updatedDevices2 > 0) { + cache.invalidiateDeviceList = true + } + + await user.destroy({ transaction: cache.transaction }) + + cache.invalidiateUserList = true + cache.areChangesImportant = true + + cache.doesUserExist.cache.set(action.userId, false) + cache.getSecondPasswordHashOfParent.cache.delete(action.userId) +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/renamechild.ts b/src/function/sync/apply-actions/dispatch-parent-action/renamechild.ts new file mode 100644 index 0000000..1ce5b59 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/renamechild.ts @@ -0,0 +1,42 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { RenameChildAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchRenameChild ({ action, cache }: { + action: RenameChildAction + cache: Cache +}) { + const [affectedRows] = await cache.database.user.update({ + name: action.newName + }, { + where: { + familyId: cache.familyId, + userId: action.childId, + type: 'child' + }, + transaction: cache.transaction + }) + + if (affectedRows !== 1) { + throw new Error('can not update child name if child does not exist') + } + + cache.invalidiateUserList = true + cache.doesUserExist.cache.set(action.childId, false) +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setcategoryextratime.ts b/src/function/sync/apply-actions/dispatch-parent-action/setcategoryextratime.ts new file mode 100644 index 0000000..545c9f6 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setcategoryextratime.ts @@ -0,0 +1,43 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetCategoryExtraTimeAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetCategoryExtraTime ({ action, cache }: { + action: SetCategoryExtraTimeAction + cache: Cache +}) { + if (!cache.hasFullVersion) { + throw new Error('action requires full version') + } + + const [affectedRows] = await cache.database.category.update({ + extraTimeInMillis: action.newExtraTime + }, { + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction + }) + + if (affectedRows !== 0) { + cache.categoriesWithModifiedBaseData.push(action.categoryId) + cache.areChangesImportant = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setcategoryforunassignedapps.ts b/src/function/sync/apply-actions/dispatch-parent-action/setcategoryforunassignedapps.ts new file mode 100644 index 0000000..5ed561a --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setcategoryforunassignedapps.ts @@ -0,0 +1,67 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetCategoryForUnassignedAppsAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetCategoryForUnassignedApps ({ action, cache }: { + action: SetCategoryForUnassignedAppsAction + cache: Cache +}) { + if (action.categoryId === '') { + // nothing to check + } else { + const categoryEntryUnsafe = await cache.database.category.findOne({ + attributes: ['childId'], + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction + }) + + if (!categoryEntryUnsafe) { + throw new Error('can not set a category which does not exist as category for unassigned apps') + } + + const categoryEntry = { + childId: categoryEntryUnsafe.childId + } + + if (categoryEntry.childId !== action.childId) { + throw new Error('can not set a category of one child as category for unassigned apps for an other child') + } + } + + const [affectedRows] = await cache.database.user.update({ + categoryForNotAssignedApps: action.categoryId + }, { + where: { + familyId: cache.familyId, + userId: action.childId, + type: 'child' + }, + transaction: cache.transaction + }) + + if (affectedRows !== 1) { + throw new Error('could not find a child with matching id for setting the category for not assigned apps') + } + + cache.invalidiateUserList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setchildpassword.ts b/src/function/sync/apply-actions/dispatch-parent-action/setchildpassword.ts new file mode 100644 index 0000000..da2b000 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setchildpassword.ts @@ -0,0 +1,49 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { SetChildPasswordAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetChildPassword ({ action, cache }: { + action: SetChildPasswordAction + cache: Cache +}) { + const childEntry = await cache.database.user.findOne({ + where: { + familyId: cache.familyId, + userId: action.childUserId, + type: 'child' + }, + transaction: cache.transaction, + lock: Sequelize.Transaction.LOCK.UPDATE + }) + + if (!childEntry) { + throw new Error('parent entry not found') + } + + childEntry.passwordHash = action.newPassword.hash + childEntry.secondPasswordSalt = action.newPassword.secondSalt + childEntry.secondPasswordHash = action.newPassword.secondHash + + await childEntry.save({ transaction: cache.transaction }) + + cache.getSecondPasswordHashOfChild.cache.clear() + cache.invalidiateUserList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setconsiderrebootmanipulation.ts b/src/function/sync/apply-actions/dispatch-parent-action/setconsiderrebootmanipulation.ts new file mode 100644 index 0000000..588eee7 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setconsiderrebootmanipulation.ts @@ -0,0 +1,41 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetConsiderRebootManipulationAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetConsiderRebootManipulation ({ action, cache }: { + action: SetConsiderRebootManipulationAction + cache: Cache +}) { + const [affectedRows] = await cache.database.device.update({ + considerRebootManipulation: action.enable + }, { + transaction: cache.transaction, + where: { + familyId: cache.familyId, + deviceId: action.deviceId + } + }) + + if (affectedRows === 0) { + throw new Error('did not find device to update consider reboot manipulation') + } + + cache.invalidiateDeviceList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setdevicedefaultuser.ts b/src/function/sync/apply-actions/dispatch-parent-action/setdevicedefaultuser.ts new file mode 100644 index 0000000..ac4c45b --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setdevicedefaultuser.ts @@ -0,0 +1,49 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetDeviceDefaultUserAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetDeviceDefaultUser ({ action, cache }: { + action: SetDeviceDefaultUserAction + cache: Cache +}) { + if (action.defaultUserId !== '') { + const doesUserExist = await cache.doesUserExist(action.defaultUserId) + + if (!doesUserExist) { + throw new Error('can not set invalid user as default user') + } + } + + const [affectedRows] = await cache.database.device.update({ + defaultUserId: action.defaultUserId + }, { + transaction: cache.transaction, + where: { + familyId: cache.familyId, + deviceId: action.deviceId + } + }) + + if (affectedRows === 0) { + throw new Error('did not find device to update default user') + } + + cache.invalidiateDeviceList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setdevicedefaultusertimeout.ts b/src/function/sync/apply-actions/dispatch-parent-action/setdevicedefaultusertimeout.ts new file mode 100644 index 0000000..8b3e217 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setdevicedefaultusertimeout.ts @@ -0,0 +1,41 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetDeviceDefaultUserTimeoutAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetDeviceDefaultUserTimeout ({ action, cache }: { + action: SetDeviceDefaultUserTimeoutAction + cache: Cache +}) { + const [affectedRows] = await cache.database.device.update({ + defaultUserTimeout: action.timeout + }, { + transaction: cache.transaction, + where: { + familyId: cache.familyId, + deviceId: action.deviceId + } + }) + + if (affectedRows === 0) { + throw new Error('did not find device to update default user timeout') + } + + cache.invalidiateDeviceList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setdeviceuser.ts b/src/function/sync/apply-actions/dispatch-parent-action/setdeviceuser.ts new file mode 100644 index 0000000..e242c86 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setdeviceuser.ts @@ -0,0 +1,48 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetDeviceUserAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetDeviceUser ({ action, cache }: { + action: SetDeviceUserAction + cache: Cache +}) { + if (action.userId !== '') { + const doesUserExist = await cache.doesUserExist(action.userId) + + if (!doesUserExist) { + throw new Error('invalid user id provided') + } + } + + const [affectedRows] = await cache.database.device.update({ + currentUserId: action.userId, + isUserKeptSignedIn: false + }, { + where: { + familyId: cache.familyId, + deviceId: action.deviceId + }, + transaction: cache.transaction + }) + + if (affectedRows !== 0) { + cache.invalidiateDeviceList = true + cache.areChangesImportant = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setkeepsignedin.ts b/src/function/sync/apply-actions/dispatch-parent-action/setkeepsignedin.ts new file mode 100644 index 0000000..d001ead --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setkeepsignedin.ts @@ -0,0 +1,65 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetKeepSignedInAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetKeepSignedIn ({ action, cache, parentUserId }: { + action: SetKeepSignedInAction + cache: Cache + parentUserId: string +}) { + const doesUserExist = await cache.doesUserExist(parentUserId) + + if (!doesUserExist) { + throw new Error('invalid user id provided') + } + + const deviceEntry = await cache.database.device.findOne({ + where: { + familyId: cache.familyId, + deviceId: action.deviceId + }, + transaction: cache.transaction + }) + + if (!deviceEntry) { + throw new Error('device does not exist') + } + + if (deviceEntry.currentUserId !== parentUserId) { + if (action.keepSignedIn) { + throw new Error('only the user itself can disable asking for the password') + } + } + + const [affectedRows] = await cache.database.device.update({ + isUserKeptSignedIn: action.keepSignedIn + }, { + where: { + familyId: cache.familyId, + deviceId: action.deviceId, + currentUserId: deviceEntry.currentUserId + }, + transaction: cache.transaction + }) + + if (affectedRows !== 0) { + cache.invalidiateDeviceList = true + cache.areChangesImportant = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setparentcategory.ts b/src/function/sync/apply-actions/dispatch-parent-action/setparentcategory.ts new file mode 100644 index 0000000..d9e5991 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setparentcategory.ts @@ -0,0 +1,80 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetParentCategoryAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetParentCategory ({ action, cache }: { + action: SetParentCategoryAction + cache: Cache +}) { + const categoryEntry = await cache.database.category.findOne({ + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction + }) + + if (!categoryEntry) { + throw new Error('tried to set parent category of non existent category') + } + + if (action.parentCategory !== '') { + const parentCategoryEntry = await cache.database.category.findOne({ + where: { + familyId: cache.familyId, + categoryId: action.parentCategory, + childId: categoryEntry.childId + }, + transaction: cache.transaction + }) + + if (!parentCategoryEntry) { + throw new Error('tried to set parent category to non existent category') + } + + if (parentCategoryEntry.parentCategoryId !== '') { + throw new Error('tried to set a category as parent which itself has got a parent') + } + + const countChildCategories = await cache.database.category.findAndCountAll({ + where: { + familyId: cache.familyId, + parentCategoryId: action.categoryId + }, + transaction: cache.transaction + }) + + if (countChildCategories.count > 0) { + throw new Error('tried to make category a child category altough it is already a parent category') + } + } + + await cache.database.category.update({ + parentCategoryId: action.parentCategory + }, { + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction + }) + + cache.categoriesWithModifiedBaseData.push(action.categoryId) + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setrelaxprimarydevice.ts b/src/function/sync/apply-actions/dispatch-parent-action/setrelaxprimarydevice.ts new file mode 100644 index 0000000..d981a1e --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setrelaxprimarydevice.ts @@ -0,0 +1,42 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetRelaxPrimaryDeviceAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetRelaxPrimaryDevice ({ action, cache }: { + action: SetRelaxPrimaryDeviceAction + cache: Cache +}) { + const [affectedRows] = await cache.database.user.update({ + relaxPrimaryDeviceRule: action.relax + }, { + transaction: cache.transaction, + where: { + familyId: cache.familyId, + userId: action.userId, + type: 'child' + } + }) + + if (affectedRows === 0) { + throw new Error('did not find user to update relax primary device') + } + + cache.invalidiateUserList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setsenddeviceconnected.ts b/src/function/sync/apply-actions/dispatch-parent-action/setsenddeviceconnected.ts new file mode 100644 index 0000000..3d3cce0 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setsenddeviceconnected.ts @@ -0,0 +1,46 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetSendDeviceConnected } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetSendDeviceConnected ({ action, cache, sourceDeviceId }: { + action: SetSendDeviceConnected + cache: Cache + sourceDeviceId: string | null +}) { + if (sourceDeviceId === null || action.deviceId !== sourceDeviceId) { + throw new Error('only can do that from the device itself') + } + + const [affectedRows] = await cache.database.device.update({ + showDeviceConnected: action.enable + }, { + transaction: cache.transaction, + where: { + familyId: cache.familyId, + deviceId: action.deviceId + } + }) + + if (affectedRows === 0) { + throw new Error('did not find device to update send if connected') + } + + cache.devicesWithModifiedShowDeviceConnected.set(action.deviceId, action.enable) + cache.invalidiateDeviceList = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setuserdisablelmitsuntil.ts b/src/function/sync/apply-actions/dispatch-parent-action/setuserdisablelmitsuntil.ts new file mode 100644 index 0000000..e7a6f8a --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setuserdisablelmitsuntil.ts @@ -0,0 +1,48 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetUserDisableLimitsUntilAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchUserSetDisableLimitsUntil ({ action, cache }: { + action: SetUserDisableLimitsUntilAction + cache: Cache +}) { + if (action.timestamp !== 0) { + if (!cache.hasFullVersion) { + throw new Error('action requires full version') + } + } + + const [affectedRows] = await cache.database.user.update({ + disableTimelimitsUntil: action.timestamp.toString(10) + }, { + where: { + familyId: cache.familyId, + userId: action.childId, + type: 'child' + }, + transaction: cache.transaction + }) + + if (affectedRows === 0) { + throw new Error('invalid user id provided') + } + + cache.invalidiateUserList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/setusertimezone.ts b/src/function/sync/apply-actions/dispatch-parent-action/setusertimezone.ts new file mode 100644 index 0000000..4487a11 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/setusertimezone.ts @@ -0,0 +1,41 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SetUserTimezoneAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchSetUserTimezone ({ action, cache }: { + action: SetUserTimezoneAction + cache: Cache +}) { + const [affectedRows] = await cache.database.user.update({ + timeZone: action.timezone + }, { + transaction: cache.transaction, + where: { + familyId: cache.familyId, + userId: action.userId + } + }) + + if (affectedRows === 0) { + throw new Error('did not find user to update timezone') + } + + cache.invalidiateUserList = true + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/updatecategoryblockedtimes.ts b/src/function/sync/apply-actions/dispatch-parent-action/updatecategoryblockedtimes.ts new file mode 100644 index 0000000..cc8bad4 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/updatecategoryblockedtimes.ts @@ -0,0 +1,41 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { UpdateCategoryBlockedTimesAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchUpdateCategoryBlockedTimes ({ action, cache }: { + action: UpdateCategoryBlockedTimesAction + cache: Cache +}) { + const [affectedRows] = await cache.database.category.update({ + blockedMinutesInWeek: action.blockedTimes + }, { + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction + }) + + if (affectedRows === 0) { + throw new Error('invalid category id provided') + } + + cache.categoriesWithModifiedBaseData.push(action.categoryId) + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/updatecategorytemporarilyblocked.ts b/src/function/sync/apply-actions/dispatch-parent-action/updatecategorytemporarilyblocked.ts new file mode 100644 index 0000000..20c1506 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/updatecategorytemporarilyblocked.ts @@ -0,0 +1,45 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { UpdateCategoryTemporarilyBlockedAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchUpdateCategoryTemporarilyBlocked ({ action, cache }: { + action: UpdateCategoryTemporarilyBlockedAction + cache: Cache +}) { + if (action.blocked === true) { + if (!cache.hasFullVersion) { + throw new Error('action requires full version') + } + } + + const [affectedRows] = await cache.database.category.update({ + temporarilyBlocked: action.blocked + }, { + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction + }) + + if (affectedRows !== 0) { + cache.categoriesWithModifiedBaseData.push(action.categoryId) + cache.areChangesImportant = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/updatecategorytitle.ts b/src/function/sync/apply-actions/dispatch-parent-action/updatecategorytitle.ts new file mode 100644 index 0000000..c0726f6 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/updatecategorytitle.ts @@ -0,0 +1,39 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { UpdateCategoryTitleAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchUpdateCategoryTitle ({ action, cache }: { + action: UpdateCategoryTitleAction + cache: Cache +}) { + const [affectedRows] = await cache.database.category.update({ + title: action.newTitle + }, { + where: { + familyId: cache.familyId, + categoryId: action.categoryId + }, + transaction: cache.transaction + }) + + if (affectedRows !== 0) { + cache.categoriesWithModifiedBaseData.push(action.categoryId) + cache.areChangesImportant = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/updatedevicename.ts b/src/function/sync/apply-actions/dispatch-parent-action/updatedevicename.ts new file mode 100644 index 0000000..2a9af64 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/updatedevicename.ts @@ -0,0 +1,41 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { UpdateDeviceNameAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchUpdateDeviceName ({ action, cache }: { + action: UpdateDeviceNameAction + cache: Cache +}) { + const [affectedRows] = await cache.database.device.update({ + name: action.name + }, { + where: { + familyId: cache.familyId, + deviceId: action.deviceId + }, + transaction: cache.transaction + }) + + if (affectedRows === 0) { + throw new Error('invalid device id') + } else { + cache.invalidiateDeviceList = true + cache.areChangesImportant = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/updatenetworktimeverification.ts b/src/function/sync/apply-actions/dispatch-parent-action/updatenetworktimeverification.ts new file mode 100644 index 0000000..dd66df7 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/updatenetworktimeverification.ts @@ -0,0 +1,41 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { UpdateNetworkTimeVerificationAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchUpdateNetworkTimeVerification ({ action, cache }: { + action: UpdateNetworkTimeVerificationAction + cache: Cache +}) { + const [affectedRows] = await cache.database.device.update({ + networkTime: action.mode + }, { + where: { + familyId: cache.familyId, + deviceId: action.deviceId + }, + transaction: cache.transaction + }) + + if (affectedRows === 0) { + throw new Error('invalid device id') + } else { + cache.invalidiateDeviceList = true + cache.areChangesImportant = true + } +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/updateparentnotificationflags.ts b/src/function/sync/apply-actions/dispatch-parent-action/updateparentnotificationflags.ts new file mode 100644 index 0000000..695f26e --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/updateparentnotificationflags.ts @@ -0,0 +1,47 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { UpdateParentNotificationFlagsAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchUpdateParentNotificationFlags ({ action, cache }: { + action: UpdateParentNotificationFlagsAction + cache: Cache +}) { + const parentEntry = await cache.database.user.findOne({ + where: { + familyId: cache.familyId, + userId: action.parentId, + type: 'parent' + }, + transaction: cache.transaction + }) + + if (!parentEntry) { + throw new Error('parent not found') + } + + if (action.set) { + parentEntry.mailNotificationFlags |= action.flags + } else { + parentEntry.mailNotificationFlags &= ~action.flags + } + + await parentEntry.save({ transaction: cache.transaction }) + + cache.invalidiateUserList = true +} diff --git a/src/function/sync/apply-actions/dispatch-parent-action/updatetimelimitrule.ts b/src/function/sync/apply-actions/dispatch-parent-action/updatetimelimitrule.ts new file mode 100644 index 0000000..ba0f6e4 --- /dev/null +++ b/src/function/sync/apply-actions/dispatch-parent-action/updatetimelimitrule.ts @@ -0,0 +1,45 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { UpdateTimelimitRuleAction } from '../../../../action' +import { Cache } from '../cache' + +export async function dispatchUpdateTimelimitRule ({ action, cache }: { + action: UpdateTimelimitRuleAction + cache: Cache +}) { + const ruleEntry = await cache.database.timelimitRule.findOne({ + where: { + familyId: cache.familyId, + ruleId: action.ruleId + }, + transaction: cache.transaction + }) + + if (!ruleEntry) { + throw new Error('invalid rule id provided') + } + + ruleEntry.applyToExtraTimeUsage = action.applyToExtraTimeUsage + ruleEntry.dayMaskAsBitmask = action.dayMask + ruleEntry.maximumTimeInMillis = action.maximumTimeInMillis + + await ruleEntry.save({ transaction: cache.transaction }) + + cache.categoriesWithModifiedTimeLimitRules.push(ruleEntry.categoryId) + cache.areChangesImportant = true +} diff --git a/src/function/sync/apply-actions/index.ts b/src/function/sync/apply-actions/index.ts new file mode 100644 index 0000000..d5ff6df --- /dev/null +++ b/src/function/sync/apply-actions/index.ts @@ -0,0 +1,231 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { createHash } from 'crypto' +import { BadRequest, Unauthorized } from 'http-errors' +import { parseAppLogicAction, parseChildAction, parseParentAction } from '../../../action/serialization' +import { ClientPushChangesRequest } from '../../../api/schema' +import { isSerializedAppLogicAction, isSerializedChildAction, isSerializedParentAction } from '../../../api/validator' +import { VisibleConnectedDevicesManager } from '../../../connected-devices' +import { Database } from '../../../database' +import { WebsocketApi } from '../../../websocket' +import { notifyClientsAboutChanges } from '../../websocket' +import { Cache } from './cache' +import { dispatchAppLogicAction } from './dispatch-app-logic-action' +import { dispatchChildAction } from './dispatch-child-action' +import { dispatchParentAction } from './dispatch-parent-action' + +export const applyActionsFromDevice = async ({ database, request, websocket, connectedDevicesManager }: { + database: Database + websocket: WebsocketApi + request: ClientPushChangesRequest + connectedDevicesManager: VisibleConnectedDevicesManager +}) => { + if (request.actions.length > 50) { + throw new BadRequest() + } + + const { shouldDoFullSync, areChangesImportant, sourceDeviceId, familyId } = await database.transaction(async (transaction) => { + const deviceEntryUnsafe = await database.device.findOne({ + where: { + deviceAuthToken: request.deviceAuthToken + }, + attributes: ['familyId', 'deviceId', 'nextSequenceNumber'], + transaction + }) + + if (!deviceEntryUnsafe) { + throw new Unauthorized() + } + + const deviceEntry = { + familyId: deviceEntryUnsafe.familyId, + deviceId: deviceEntryUnsafe.deviceId, + nextSequenceNumber: deviceEntryUnsafe.nextSequenceNumber + } + + const familyEntryUnsafe = await database.family.findOne({ + where: { + familyId: deviceEntry.familyId + }, + transaction, + attributes: ['hasFullVersion'] + }) + + if (!familyEntryUnsafe) { + throw new Error('missing family entry') + } + + const familyEntry = { + hasFullVersion: familyEntryUnsafe.hasFullVersion + } + + const cache = new Cache({ + database, + hasFullVersion: familyEntry.hasFullVersion, + transaction, + familyId: deviceEntry.familyId, + connectedDevicesManager + }) + + let { nextSequenceNumber } = deviceEntry + + for (let i = 0; i < request.actions.length; i++) { + const action = request.actions[i] + + if (action.sequenceNumber < nextSequenceNumber) { + // action was already received + + cache.requireFullSync() + continue + } + + try { + // update the next sequence number + nextSequenceNumber = action.sequenceNumber + 1 + + if (action.type === 'parent') { + if (action.integrity === 'device') { + const deviceEntryUnsafe2 = await cache.database.device.findOne({ + attributes: ['currentUserId'], + where: { + familyId: cache.familyId, + deviceId: deviceEntry.deviceId, + currentUserId: action.userId, + isUserKeptSignedIn: true + }, + transaction: cache.transaction + }) + + if (!deviceEntryUnsafe2) { + throw new Error('user is not signed in at this device') + } + + // this ensures that the parent exists + await cache.getSecondPasswordHashOfParent(action.userId) + } else { + const parentSecondHash = await cache.getSecondPasswordHashOfParent(action.userId) + + const integrityData = action.sequenceNumber.toString(10) + + deviceEntry.deviceId + + parentSecondHash + + action.encodedAction + + const expectedIntegrityValue = createHash('sha512').update(integrityData).digest('hex') + + if (action.integrity !== expectedIntegrityValue) { + throw new Error('invalid integrity value') + } + } + } + + if (action.type === 'child') { + const childSecondHash = await cache.getSecondPasswordHashOfChild(action.userId) + + const integrityData = action.sequenceNumber.toString(10) + + deviceEntry.deviceId + + childSecondHash + + action.encodedAction + + const expectedIntegrityValue = createHash('sha512').update(integrityData).digest('hex') + + if (action.integrity !== expectedIntegrityValue) { + throw new Error('invalid integrity value') + } + } + + const parsedSerializedAction = JSON.parse(action.encodedAction) + + if (action.type === 'appLogic') { + if (!isSerializedAppLogicAction(parsedSerializedAction)) { + throw new Error('invalid action: ' + action.encodedAction) + } + + const parsedAction = parseAppLogicAction(parsedSerializedAction) + + await dispatchAppLogicAction({ + action: parsedAction, + cache, + deviceId: deviceEntry.deviceId + }) + } else if (action.type === 'parent') { + if (!isSerializedParentAction(parsedSerializedAction)) { + throw new Error('invalid action' + action.encodedAction) + } + + const parsedAction = parseParentAction(parsedSerializedAction) + + await dispatchParentAction({ + action: parsedAction, + cache, + parentUserId: action.userId, + sourceDeviceId: deviceEntry.deviceId + }) + } else if (action.type === 'child') { + if (!isSerializedChildAction(parsedSerializedAction)) { + throw new Error('invalid action: ' + action.encodedAction) + } + + const parsedAction = parseChildAction(parsedSerializedAction) + + await dispatchChildAction({ + action: parsedAction, + cache, + childUserId: action.userId, + deviceId: deviceEntry.deviceId + }) + } else { + throw new Error('illegal state') + } + } catch (ex) { + cache.requireFullSync() + } + } + + // save new next sequence number + if (nextSequenceNumber !== deviceEntry.nextSequenceNumber) { + await database.device.update({ + nextSequenceNumber + }, { + where: { + familyId: deviceEntry.familyId, + deviceId: deviceEntry.deviceId + }, + transaction + }) + } + + await cache.saveModifiedVersionNumbers() + + return { + shouldDoFullSync: cache.shouldDoFullSync(), + areChangesImportant: cache.areChangesImportant, + sourceDeviceId: deviceEntry.deviceId, + familyId: deviceEntry.familyId + } + }) + + await notifyClientsAboutChanges({ + familyId, + sourceDeviceId, + isImportant: areChangesImportant, + websocket, + database + }) + + return { shouldDoFullSync } +} diff --git a/src/function/sync/get-server-data-status.ts b/src/function/sync/get-server-data-status.ts new file mode 100644 index 0000000..0b3a205 --- /dev/null +++ b/src/function/sync/get-server-data-status.ts @@ -0,0 +1,443 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { difference, filter, intersection } from 'lodash' +import * as Sequelize from 'sequelize' +import { Database } from '../../database' +import { ClientDataStatus } from '../../object/clientdatastatus' +import { + ServerDataStatus, ServerInstalledAppsData, ServerUpdatedCategoryAssignedApps, + ServerUpdatedCategoryBaseData, ServerUpdatedCategoryUsedTimes, + ServerUpdatedTimeLimitRules +} from '../../object/serverdatastatus' + +export const generateServerDataStatus = async ({ database, clientStatus, familyId, transaction }: { + database: Database, + clientStatus: ClientDataStatus, + familyId: string + transaction: Sequelize.Transaction +}): Promise => { + const familyEntryUnsafe = await database.family.findOne({ + where: { + familyId + }, + attributes: [ + 'deviceListVersion', + 'userListVersion', + 'hasFullVersion', + 'fullVersionUntil' + ], + transaction + }) + + if (!familyEntryUnsafe) { + throw new Error('illegal state') + } + + const familyEntry = { + deviceListVersion: familyEntryUnsafe.deviceListVersion, + userListVersion: familyEntryUnsafe.userListVersion, + hasFullVersion: familyEntryUnsafe.hasFullVersion, + fullVersionUntil: familyEntryUnsafe.fullVersionUntil + } + + let result: ServerDataStatus = { + fullVersion: familyEntry.hasFullVersion ? parseInt(familyEntry.fullVersionUntil, 10) : 0, + message: process.env.STATUS_MESSAGE || undefined + } + + if (familyEntry.deviceListVersion !== clientStatus.devices) { + const devices = (await database.device.findAll({ + where: { + familyId + }, + transaction + })) + + result.devices = { + version: familyEntry.deviceListVersion, + data: devices.map((item) => ({ + deviceId: item.deviceId, + name: item.name, + model: item.model, + addedAt: parseInt(item.addedAt, 10), + currentUserId: item.currentUserId, + networkTime: item.networkTime, + cProtectionLevel: item.currentProtectionLevel, + hProtectionLevel: item.highestProtectionLevel, + cUsageStats: item.currentUsageStatsPermission, + hUsageStats: item.highestUsageStatsPermission, + cNotificationAccess: item.currentNotificationAccessPermission, + hNotificationAccess: item.highestNotificationAccessPermission, + cAppVersion: item.currentAppVersion, + hAppVersion: item.highestAppVersion, + tDisablingAdmin: item.triedDisablingDeviceAdmin, + reboot: item.didReboot, + hadManipulation: item.hadManipulation, + reportUninstall: item.didDeviceReportUninstall, + isUserKeptSignedIn: item.isUserKeptSignedIn, + showDeviceConnected: item.showDeviceConnected, + defUser: item.defaultUserId, + defUserTimeout: item.defaultUserTimeout, + rebootIsManipulation: item.considerRebootManipulation + })) + } + } + + if (familyEntry.userListVersion !== clientStatus.users) { + const users = (await database.user.findAll({ + where: { + familyId + }, + attributes: [ + 'userId', + 'name', + 'passwordHash', + 'secondPasswordSalt', + 'type', + 'timeZone', + 'disableTimelimitsUntil', + 'mail', + 'currentDevice', + 'categoryForNotAssignedApps', + 'relaxPrimaryDeviceRule', + 'mailNotificationFlags' + ], + transaction + })).map((item) => ({ + userId: item.userId, + name: item.name, + passwordHash: item.passwordHash, + secondPasswordSalt: item.secondPasswordSalt, + type: item.type, + timeZone: item.timeZone, + disableTimelimitsUntil: item.disableTimelimitsUntil, + mail: item.mail, + currentDevice: item.currentDevice, + categoryForNotAssignedApps: item.categoryForNotAssignedApps, + relaxPrimaryDeviceRule: item.relaxPrimaryDeviceRule, + mailNotificationFlags: item.mailNotificationFlags + })) + + result.users = { + version: familyEntry.userListVersion, + data: users.map((item) => ({ + id: item.userId, + name: item.name, + password: item.passwordHash, + secondPasswordSalt: item.secondPasswordSalt, + type: item.type, + timeZone: item.timeZone, + disableLimitsUntil: parseInt(item.disableTimelimitsUntil, 10), + mail: item.mail, + currentDevice: item.currentDevice, + categoryForNotAssignedApps: item.categoryForNotAssignedApps, + relaxPrimaryDevice: item.relaxPrimaryDeviceRule, + mailNotificationFlags: item.mailNotificationFlags + })) + } + } + + const serverInstalledAppsVersions = (await database.device.findAll({ + where: { + familyId + }, + attributes: ['deviceId', 'installedAppsVersion'], + transaction + })).map((item) => ({ + deviceId: item.deviceId, + installedAppsVersion: item.installedAppsVersion + })) + + const getServerInstalledAppsVersionByDeviceId = (deviceId: string) => { + const entry = serverInstalledAppsVersions.find((item) => item.deviceId === deviceId) + + if (!entry) { + throw new Error('illegal state') + } + + return entry.installedAppsVersion + } + + const serverDeviceIds = serverInstalledAppsVersions.map((item) => item.deviceId) + const clientDeviceIds = Object.keys(clientStatus.apps) + const addedDeviceIds = difference(serverDeviceIds, clientDeviceIds) + const deviceIdsWhereInstalledAppsHaveChanged = filter(Object.keys(clientStatus.apps), (deviceId) => { + const installedAppsVersion = clientStatus.apps[deviceId] + + const serverEntry = serverInstalledAppsVersions.find((item) => item.deviceId === deviceId) + + return !!serverEntry && serverEntry.installedAppsVersion !== installedAppsVersion + }) + const idsOfDevicesWhereInstalledAppsMustBeSynced = [...addedDeviceIds, ...deviceIdsWhereInstalledAppsHaveChanged] + + if (idsOfDevicesWhereInstalledAppsMustBeSynced.length > 0) { + const dataToSync = (await database.app.findAll({ + where: { + familyId, + deviceId: { + [Sequelize.Op.in]: idsOfDevicesWhereInstalledAppsMustBeSynced + } + }, + attributes: [ + 'deviceId', + 'packageName', + 'title', + 'isLaunchable', + 'recommendation' + ], + transaction + })).map((item) => ({ + deviceId: item.deviceId, + packageName: item.packageName, + title: item.title, + isLaunchable: item.isLaunchable, + recommendation: item.recommendation + })) + + result.apps = idsOfDevicesWhereInstalledAppsMustBeSynced.map((deviceId): ServerInstalledAppsData => ({ + deviceId, + apps: dataToSync.filter((item) => item.deviceId === deviceId).map((item) => ({ + packageName: item.packageName, + title: item.title, + isLaunchable: item.isLaunchable, + recommendation: item.recommendation + })), + version: getServerInstalledAppsVersionByDeviceId(deviceId) + })) + } + + const serverCategoriesVersions = (await database.category.findAll({ + where: { + familyId + }, + attributes: [ + 'categoryId', + 'baseVersion', + 'assignedAppsVersion', + 'timeLimitRulesVersion', + 'usedTimesVersion' + ], + transaction + })).map((item) => ({ + categoryId: item.categoryId, + baseVersion: item.baseVersion, + assignedAppsVersion: item.assignedAppsVersion, + timeLimitRulesVersion: item.timeLimitRulesVersion, + usedTimesVersion: item.usedTimesVersion + })) + + const serverCategoryIds = serverCategoriesVersions.map((item) => item.categoryId) + const clientCategoryIds = Object.keys(clientStatus.categories) + + const removedCategoryIds = difference(clientCategoryIds, serverCategoryIds) + + if (removedCategoryIds.length > 0) { + result.rmCategories = removedCategoryIds + } + + const addedCategoryIds = difference(serverCategoryIds, clientCategoryIds) + const categoryIdsOfClientAndServer = intersection(serverCategoryIds, clientCategoryIds) + + const categoryIdsToSyncBaseData = [...addedCategoryIds] + const categoryIdsToSyncAssignedApps = [...addedCategoryIds] + const categoryIdsToSyncRules = [...addedCategoryIds] + const categoryIdsToSyncUsedTimes = [...addedCategoryIds] + + categoryIdsOfClientAndServer.forEach((categoryId) => { + const serverEntry = serverCategoriesVersions.find((item) => item.categoryId === categoryId) + const clientEntry = clientStatus.categories[categoryId] + + if ((!serverEntry) || (!clientEntry)) { + throw new Error('illegal state') + } + + if (serverEntry.baseVersion !== clientEntry.base) { + categoryIdsToSyncBaseData.push(categoryId) + } + + if (serverEntry.assignedAppsVersion !== clientEntry.apps) { + categoryIdsToSyncAssignedApps.push(categoryId) + } + + if (serverEntry.timeLimitRulesVersion !== clientEntry.rules) { + categoryIdsToSyncRules.push(categoryId) + } + + if (serverEntry.usedTimesVersion !== clientEntry.usedTime) { + categoryIdsToSyncUsedTimes.push(categoryId) + } + }) + + if (categoryIdsToSyncBaseData.length > 0) { + const dataForSyncing = (await database.category.findAll({ + where: { + familyId, + categoryId: { + [Sequelize.Op.in]: categoryIdsToSyncBaseData + } + }, + attributes: [ + 'categoryId', + 'childId', + 'title', + 'blockedMinutesInWeek', + 'extraTimeInMillis', + 'temporarilyBlocked', + 'baseVersion', + 'parentCategoryId' + ], + transaction + })).map((item) => ({ + categoryId: item.categoryId, + childId: item.childId, + title: item.title, + blockedMinutesInWeek: item.blockedMinutesInWeek, + extraTimeInMillis: item.extraTimeInMillis, + temporarilyBlocked: item.temporarilyBlocked, + baseVersion: item.baseVersion, + parentCategoryId: item.parentCategoryId + })) + + result.categoryBase = dataForSyncing.map((item): ServerUpdatedCategoryBaseData => ({ + categoryId: item.categoryId, + childId: item.childId, + title: item.title, + blockedTimes: item.blockedMinutesInWeek, + extraTime: item.extraTimeInMillis, + tempBlocked: item.temporarilyBlocked, + version: item.baseVersion, + parentCategoryId: item.parentCategoryId + })) + } + + if (categoryIdsToSyncAssignedApps.length > 0) { + const dataForSyncing = (await database.categoryApp.findAll({ + where: { + familyId, + categoryId: { + [Sequelize.Op.in]: categoryIdsToSyncAssignedApps + } + }, + attributes: ['categoryId', 'packageName'], + transaction + })).map((item) => ({ + categoryId: item.categoryId, + packageName: item.packageName + })) + + const getCategoryAssingedAppsVersion = (categoryId: string) => { + const categoryEntry = serverCategoriesVersions.find((item) => item.categoryId === categoryId) + + if (!categoryEntry) { + throw new Error('illegal state') + } + + return categoryEntry.assignedAppsVersion + } + + result.categoryApp = categoryIdsToSyncAssignedApps.map((categoryId): ServerUpdatedCategoryAssignedApps => ({ + categoryId, + apps: dataForSyncing.filter((item) => item.categoryId === categoryId).map((item) => item.packageName), + version: getCategoryAssingedAppsVersion(categoryId) + })) + } + + if (categoryIdsToSyncRules.length > 0) { + const dataForSyncing = (await database.timelimitRule.findAll({ + where: { + familyId, + categoryId: { + [Sequelize.Op.in]: categoryIdsToSyncRules + } + }, + attributes: [ + 'ruleId', + 'categoryId', + 'applyToExtraTimeUsage', + 'maximumTimeInMillis', + 'dayMaskAsBitmask' + ], + transaction + })).map((item) => ({ + ruleId: item.ruleId, + categoryId: item.categoryId, + applyToExtraTimeUsage: item.applyToExtraTimeUsage, + maximumTimeInMillis: item.maximumTimeInMillis, + dayMaskAsBitmask: item.dayMaskAsBitmask + })) + + const getCategoryRulesVersion = (categoryId: string) => { + const categoryEntry = serverCategoriesVersions.find((item) => item.categoryId === categoryId) + + if (!categoryEntry) { + throw new Error('illegal state') + } + + return categoryEntry.timeLimitRulesVersion + } + + result.rules = categoryIdsToSyncRules.map((categoryId): ServerUpdatedTimeLimitRules => ({ + categoryId, + rules: dataForSyncing.filter((item) => item.categoryId === categoryId).map((item) => ({ + id: item.ruleId, + extraTime: item.applyToExtraTimeUsage, + dayMask: item.dayMaskAsBitmask, + maxTime: item.maximumTimeInMillis + })), + version: getCategoryRulesVersion(categoryId) + })) + } + + if (categoryIdsToSyncUsedTimes.length > 0) { + const dataForSyncing = (await database.usedTime.findAll({ + where: { + familyId, + categoryId: { + [Sequelize.Op.in]: categoryIdsToSyncUsedTimes + } + }, + attributes: ['categoryId', 'dayOfEpoch', 'usedTime'], + transaction + })).map((item) => ({ + categoryId: item.categoryId, + dayOfEpoch: item.dayOfEpoch, + usedTime: item.usedTime + })) + + const getCategoryUsedTimesVersion = (categoryId: string) => { + const categoryEntry = serverCategoriesVersions.find((item) => item.categoryId === categoryId) + + if (!categoryEntry) { + throw new Error('illegal state') + } + + return categoryEntry.usedTimesVersion + } + + result.usedTimes = categoryIdsToSyncUsedTimes.map((categoryId): ServerUpdatedCategoryUsedTimes => ({ + categoryId, + times: dataForSyncing.filter((item) => item.categoryId === categoryId).map((item) => ({ + day: item.dayOfEpoch, + time: item.usedTime + })), + version: getCategoryUsedTimesVersion(categoryId) + })) + } + + return result +} diff --git a/src/function/warningmail/manipulation.ts b/src/function/warningmail/manipulation.ts new file mode 100644 index 0000000..aacb76c --- /dev/null +++ b/src/function/warningmail/manipulation.ts @@ -0,0 +1,32 @@ +import * as Sequelize from 'sequelize' +import { Database } from '../../database' +import { sendManipulationWarningMail } from '../../util/mail' +import { canSendWarningMail } from '../../util/ratelimit-warningmail' + +export const sendManipulationWarnings = async ({ database, familyId, deviceName, transaction }: { + database: Database + familyId: string + deviceName: string + transaction: Sequelize.Transaction +}) => { + const parentEntries = await database.user.findAll({ + where: { + familyId, + type: 'parent' + }, + transaction + }) + + const targetMailAddresses = parentEntries + .filter((item) => item.mail !== '') + .filter((item) => (item.mailNotificationFlags & 1) === 1) + .map((item) => item.mail) + + await Promise.all( + targetMailAddresses.map(async (receiver) => { + if (await canSendWarningMail(receiver)) { + await sendManipulationWarningMail({ receiver, deviceName }) + } + }) + ) +} diff --git a/src/function/warningmail/uninstall.ts b/src/function/warningmail/uninstall.ts new file mode 100644 index 0000000..0699593 --- /dev/null +++ b/src/function/warningmail/uninstall.ts @@ -0,0 +1,29 @@ +import { Database } from '../../database' +import { sendUninstallWarningMail } from '../../util/mail' +import { canSendWarningMail } from '../../util/ratelimit-warningmail' + +export const sendUninstallWarnings = async ({ database, familyId, deviceName }: { + database: Database + familyId: string + deviceName: string +}) => { + const parentEntries = await database.user.findAll({ + where: { + familyId, + type: 'parent' + } + }) + + const targetMailAddresses = parentEntries + .filter((item) => item.mail !== '') + .filter((item) => (item.mailNotificationFlags & 1) === 1) + .map((item) => item.mail) + + await Promise.all( + targetMailAddresses.map(async (receiver) => { + if (await canSendWarningMail(receiver)) { + await sendUninstallWarningMail({ receiver, deviceName }) + } + }) + ) +} diff --git a/src/function/websocket/index.ts b/src/function/websocket/index.ts new file mode 100644 index 0000000..7932331 --- /dev/null +++ b/src/function/websocket/index.ts @@ -0,0 +1,50 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { Database } from '../../database' +import { WebsocketApi } from '../../websocket' + +// this should be called AFTER an transaction was commited +export const notifyClientsAboutChanges = async ({ familyId, sourceDeviceId, database, websocket, isImportant }: { + familyId: string + sourceDeviceId: string | null // this device will not get an push + database: Database + websocket: WebsocketApi + isImportant: boolean +}) => { + const relatedDeviceEntries = (await database.device.findAll({ + where: sourceDeviceId ? { + familyId, + deviceId: { + [Sequelize.Op.not]: sourceDeviceId + } + } : { + familyId + }, + attributes: ['deviceAuthToken'] + })).map((item) => ({ + deviceAuthToken: item.deviceAuthToken + })) + + relatedDeviceEntries.forEach((item) => { + websocket.triggerSyncByDeviceAuthToken({ + deviceAuthToken: item.deviceAuthToken, + isImportant + }) + }) +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..625d11e --- /dev/null +++ b/src/index.ts @@ -0,0 +1,63 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Server } from 'http' +import { createApi } from './api' +import { VisibleConnectedDevicesManager } from './connected-devices' +import { defaultDatabase, defaultUmzug } from './database' +import { createWebsocketHandler } from './websocket' +import { initWorkers } from './worker' + +async function main () { + await defaultUmzug.up() + const database = defaultDatabase + + const connectedDevicesManager = new VisibleConnectedDevicesManager({ + database + }) + + const { websocketApi, websocketServer } = createWebsocketHandler({ + database, + connectedDevicesManager + }) + + initWorkers({ + websocket: websocketApi, + database + }) + + const api = createApi({ + database, + websocket: websocketApi, + connectedDevicesManager + }) + + const server = new Server(api) + + websocketServer.attach(server, { + serveClient: false + }) + + server.listen(process.env.PORT || 8080) + + console.log('ready') +} + +main().catch((ex) => { + console.warn(ex) + process.exit(1) +}) diff --git a/src/model/apprecommendation.ts b/src/model/apprecommendation.ts new file mode 100644 index 0000000..44c4421 --- /dev/null +++ b/src/model/apprecommendation.ts @@ -0,0 +1,19 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export type AppRecommendation = 'whitelist' | 'blacklist' | 'none' +export const appRecommendationValues: Array = ['whitelist', 'blacklist', 'none'] diff --git a/src/model/installedapp.ts b/src/model/installedapp.ts new file mode 100644 index 0000000..a870eb0 --- /dev/null +++ b/src/model/installedapp.ts @@ -0,0 +1,50 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { AppRecommendation } from './apprecommendation' + +export class InstalledApp { + readonly packageName: string + readonly title: string + readonly isLaunchable: boolean + readonly recommendation: AppRecommendation + + constructor ({ packageName, title, isLaunchable, recommendation }: {packageName: string, title: string, isLaunchable: boolean, recommendation: AppRecommendation}) { + this.packageName = packageName + this.title = title + this.isLaunchable = isLaunchable + this.recommendation = recommendation + } + + serialize = (): SerializedInstalledApp => ({ + packageName: this.packageName, + title: this.title, + isLaunchable: this.isLaunchable, + recommendation: this.recommendation + }) + + static parse = ({ packageName, title, isLaunchable, recommendation }: SerializedInstalledApp) => ( + new InstalledApp({ packageName, title, isLaunchable, recommendation }) + ) +} + +export interface SerializedInstalledApp { + packageName: string + title: string + isLaunchable: boolean + recommendation: AppRecommendation +} diff --git a/src/model/newpermissionstatus.ts b/src/model/newpermissionstatus.ts new file mode 100644 index 0000000..2a843c4 --- /dev/null +++ b/src/model/newpermissionstatus.ts @@ -0,0 +1,19 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export type NewPermissionStatus = 'not granted' | 'not supported' | 'granted' +export const newPermissionStatusValues: Array = ['not granted', 'not supported', 'granted'] diff --git a/src/model/protectionlevel.ts b/src/model/protectionlevel.ts new file mode 100644 index 0000000..4411b51 --- /dev/null +++ b/src/model/protectionlevel.ts @@ -0,0 +1,19 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export type ProtectionLevel = 'none' | 'simple device admin' | 'password device admin' | 'device owner' +export const protetionLevels: Array = ['none', 'simple device admin', 'password device admin', 'device owner'] diff --git a/src/model/runtimepermissionstatus.ts b/src/model/runtimepermissionstatus.ts new file mode 100644 index 0000000..42ffe2b --- /dev/null +++ b/src/model/runtimepermissionstatus.ts @@ -0,0 +1,19 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export type RuntimePermissionStatus = 'not granted' | 'not required' | 'granted' +export const runtimePermissionStatusValues: Array = ['not granted', 'not required', 'granted'] diff --git a/src/model/timelimitrule.ts b/src/model/timelimitrule.ts new file mode 100644 index 0000000..59c06b1 --- /dev/null +++ b/src/model/timelimitrule.ts @@ -0,0 +1,81 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { assertIdWithinFamily } from '../util/token' + +export class TimelimitRule { + readonly ruleId: string + readonly categoryId: string + readonly maxTimeInMillis: number + readonly dayMask: number // stored as bitmask + readonly applyToExtraTimeUsage: boolean + + constructor ({ ruleId, categoryId, maxTimeInMillis, dayMask, applyToExtraTimeUsage }: { + ruleId: string + categoryId: string + maxTimeInMillis: number + dayMask: number + applyToExtraTimeUsage: boolean + }) { + this.ruleId = ruleId + this.categoryId = categoryId + this.maxTimeInMillis = maxTimeInMillis + this.dayMask = dayMask + this.applyToExtraTimeUsage = applyToExtraTimeUsage + + assertIdWithinFamily(ruleId) + assertIdWithinFamily(categoryId) + + if (maxTimeInMillis < 0 || (!Number.isSafeInteger(maxTimeInMillis))) { + throw new Error('maxTimeInMillis must be >= 0') + } + + if (!( + Number.isSafeInteger(dayMask) || + dayMask < 0 || + dayMask > (1 | 2 | 4 | 8 | 16 | 32 | 64) + )) { + throw new Error('invalid day mask') + } + } + + serialize = (): SerializedTimeLimitRule => ({ + ruleId: this.ruleId, + categoryId: this.categoryId, + time: this.maxTimeInMillis, + days: this.dayMask, + extraTime: this.applyToExtraTimeUsage + }) + + static parse = ({ ruleId, categoryId, time, days, extraTime }: SerializedTimeLimitRule) => ( + new TimelimitRule({ + ruleId, + categoryId, + maxTimeInMillis: time, + dayMask: days, + applyToExtraTimeUsage: extraTime + }) + ) +} + +export interface SerializedTimeLimitRule { + ruleId: string + categoryId: string + time: number + days: number + extraTime: boolean +} diff --git a/src/object/clientdatastatus.ts b/src/object/clientdatastatus.ts new file mode 100644 index 0000000..42676d4 --- /dev/null +++ b/src/object/clientdatastatus.ts @@ -0,0 +1,30 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export interface ClientDataStatus { + devices: string // deviceListVersion + apps: {[key: string]: string} // installedAppsVersionsByDeviceId + categories: {[key: string]: CategoryDataStatus} + users: string // userListVersion +} + +export interface CategoryDataStatus { + base: string // baseVersion + apps: string // assignedAppsVersion + rules: string // timeLimitRulesVersion + usedTime: string // usedTimeItemsVersion +} diff --git a/src/object/serverdatastatus.ts b/src/object/serverdatastatus.ts new file mode 100644 index 0000000..4bc932e --- /dev/null +++ b/src/object/serverdatastatus.ts @@ -0,0 +1,132 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { SerializedInstalledApp } from '../model/installedapp' +import { NewPermissionStatus } from '../model/newpermissionstatus' +import { ProtectionLevel } from '../model/protectionlevel' +import { RuntimePermissionStatus } from '../model/runtimepermissionstatus' + +export interface ServerDataStatus { + devices?: ServerDeviceList // newDeviceList + apps?: Array // newInstalledApps + rmCategories?: Array // removedCategories + categoryBase?: Array // newCategoryBaseData + categoryApp?: Array // newCategoryAssignedApps + usedTimes?: Array // newCategoryUsedTimes + rules?: Array // newOrUpdatedTimeLimitRules + users?: ServerUserList // newUserList + fullVersion: number // fullVersionUntil + message?: string +} + +export interface ServerDeviceList { + version: string + data: Array +} + +export interface ServerUserList { + version: string + data: Array +} + +export interface ServerUserEntry { + id: string + name: string + password: string + secondPasswordSalt: string + type: 'parent' | 'child' + timeZone: string + disableLimitsUntil: number + mail: string + currentDevice: string + categoryForNotAssignedApps: string + relaxPrimaryDevice: boolean + mailNotificationFlags: number +} + +export interface ServerDeviceData { + deviceId: string + name: string + model: string + addedAt: number + currentUserId: string + networkTime: 'disabled' | 'if possible' | 'enabled' + cProtectionLevel: ProtectionLevel + hProtectionLevel: ProtectionLevel + cUsageStats: RuntimePermissionStatus + hUsageStats: RuntimePermissionStatus + cNotificationAccess: NewPermissionStatus + hNotificationAccess: NewPermissionStatus + cAppVersion: number + hAppVersion: number + tDisablingAdmin: boolean + reboot: boolean + hadManipulation: boolean + reportUninstall: boolean + isUserKeptSignedIn: boolean + showDeviceConnected: boolean + defUser: string + defUserTimeout: number + rebootIsManipulation: boolean +} + +export interface ServerUpdatedCategoryBaseData { + categoryId: string + childId: string + title: string + blockedTimes: string // blockedMinutesInWeek + extraTime: number + tempBlocked: boolean + version: string + parentCategoryId: string +} + +export interface ServerUpdatedCategoryAssignedApps { + categoryId: string + apps: Array + version: string +} + +export interface ServerUpdatedCategoryUsedTimes { + categoryId: string + times: Array + version: string +} + +export interface ServerUsedTimeItem { + day: number // day of epoch + time: number // in milliseconds +} + +export interface ServerUpdatedTimeLimitRules { + categoryId: string + version: string + rules: Array +} + +export interface ServerTimeLimitRule { + id: string + extraTime: boolean // applyToExtraTimeUsage + dayMask: number // as binary bitmask + maxTime: number // maximumTimeInMillis +} + +export interface ServerInstalledAppsData { + deviceId: string + version: string + apps: Array +} diff --git a/src/util/bitmask.ts b/src/util/bitmask.ts new file mode 100644 index 0000000..29affef --- /dev/null +++ b/src/util/bitmask.ts @@ -0,0 +1,54 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { split } from 'lodash' + +export const serializedBitmaskRegex = /^(\d*,\d*(,\d*,\d*)*)?$/ + +export const validateBitmask = (bitmask: string, maxLength: number) => { + if (!serializedBitmaskRegex.test(bitmask)) { + throw new Error('bitmask does not match regex') + } + + if (bitmask === '') { + return + } + + const splitpoints = split(bitmask, ',').map((item) => parseInt(item, 10)) + + if (splitpoints.findIndex((item) => !Number.isSafeInteger(item)) !== -1) { + throw new Error('bitmask contains non-safe integers') + } + + if (splitpoints.findIndex((item) => item < 0) !== -1) { + throw new Error('bitmask contains negative integers') + } + + if (splitpoints.findIndex((item) => item > maxLength) !== -1) { + throw new Error('bitmask contains integers bigger than maxSize') + } + + let previousValue = -1 + + splitpoints.forEach((item) => { + if (item <= previousValue) { + throw new Error('bitmask numbers are not strictly sorted') + } + + previousValue = item + }) +} diff --git a/src/util/enum.ts b/src/util/enum.ts new file mode 100644 index 0000000..f0c86d2 --- /dev/null +++ b/src/util/enum.ts @@ -0,0 +1,20 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export const enumMax = (a: T, b: T, values: Array): T => ( + values[Math.max(values.indexOf(a), values.indexOf(b))] +) diff --git a/src/util/hexstring.ts b/src/util/hexstring.ts new file mode 100644 index 0000000..ee90fb2 --- /dev/null +++ b/src/util/hexstring.ts @@ -0,0 +1,30 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export function assertIsHexString (value: string) { + if (value.length % 2 !== 0) { + throw new Error('expected hex string but has got uneven length') + } + + for (let i = 0; i < value.length; i++) { + const char = value[i] + + if ('0123456789abcdef'.indexOf(char) === -1) { + throw new Error('expected hex string but got invalid char') + } + } +} diff --git a/src/util/list.ts b/src/util/list.ts new file mode 100644 index 0000000..f2b3785 --- /dev/null +++ b/src/util/list.ts @@ -0,0 +1,28 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { uniq } from 'lodash' + +export function assertNonEmptyListWithoutDuplicates (list: Array) { + if (list.length === 0) { + throw new Error('expected not empty list') + } + + if (uniq(list).length !== list.length) { + throw new Error('expected list without duplicates') + } +} diff --git a/src/util/mail.ts b/src/util/mail.ts new file mode 100644 index 0000000..7892b38 --- /dev/null +++ b/src/util/mail.ts @@ -0,0 +1,83 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Email from 'email-templates' +import { join } from 'path' + +const mailimprint = process.env.MAIL_IMPRINT || 'not defined' + +const email = new Email({ + message: { + from: process.env.MAIL_SENDER || '' + }, + transport: JSON.parse(process.env.MAIL_TRANSPORT || 'null') || undefined, + views: { + options: { + extension: 'ejs' + } + } +}) + +export const sendAuthenticationMail = async ({ receiver, code, locale }: {receiver: string, code: string, locale: string}) => { + await email.send({ + template: join(__dirname, '../../other/mail/login'), + message: { + to: receiver + }, + locals: { + subject: locale === 'de' ? 'Anmeldung bei TimeLimit' : 'Sign in at TimeLimit', + introtext: locale === 'de' ? 'Geben Sie zum Authentifizieren folgenden Code in TimeLimit ein' : 'To authenticate, enter the following code in TimeLimit', + code, + outrotext: locale === 'de' ? 'Geben Sie diesen Code nicht an Dritte weiter.' : 'Do not share this code with third parties.', + mailimprint + } + }) +} + +export const sendManipulationWarningMail = async ({ receiver, deviceName }: { + receiver: string + deviceName: string +}) => { + await email.send({ + template: join(__dirname, '../../other/mail/manipulation'), + message: { + to: receiver + }, + locals: { + subject: 'TimeLimit@' + deviceName + ' - Manipulation', + deviceName, + mailimprint + } + }) +} + +export const sendUninstallWarningMail = async ({ receiver, deviceName }: { + receiver: string + deviceName: string +}) => { + await email.send({ + template: join(__dirname, '../../other/mail/uninstall'), + message: { + to: receiver + }, + locals: { + subject: 'TimeLimit removed from ' + deviceName, + deviceName, + mailimprint + } + }) +} diff --git a/src/util/password.ts b/src/util/password.ts new file mode 100644 index 0000000..a6ef1ca --- /dev/null +++ b/src/util/password.ts @@ -0,0 +1,19 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export const optionalPasswordRegex = /^(\$2a\$[123][0-9]\$[./A-Za-z0-9]{53})?$/ +export const optionalSaltRegex = /^(\$2a\$[123][0-9]\$[./A-Za-z0-9]{22})?$/ diff --git a/src/util/random-words.ts b/src/util/random-words.ts new file mode 100644 index 0000000..8a8fbc1 --- /dev/null +++ b/src/util/random-words.ts @@ -0,0 +1,33 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { readFileSync } from 'fs' +import { range } from 'lodash' +import { resolve } from 'path' + +const wordlist = readFileSync(resolve(__dirname, '../../other/wordlist/de.txt')) + .toString() + .split('\n') + .filter((item) => item.trim().length > 0) + +const randomWord = () => wordlist[Math.floor(Math.random() * (wordlist.length - 1))] + +export const randomWords = (numberOfWords: number) => ( + range(numberOfWords) + .map((item) => randomWord()) + .join(' ') +) diff --git a/src/util/ratelimit-authmail.ts b/src/util/ratelimit-authmail.ts new file mode 100644 index 0000000..0c9b0a9 --- /dev/null +++ b/src/util/ratelimit-authmail.ts @@ -0,0 +1,64 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { RateLimiterAbstract, RateLimiterMemory } from 'rate-limiter-flexible' + +const globalMailSendLimitMinute: RateLimiterAbstract = new RateLimiterMemory({ + keyPrefix: 'timelimit:sendmail-auth:global:minute', + points: 5, + duration: 60 // 1 minute +}) + +const globalMailSendLimitHour: RateLimiterAbstract = new RateLimiterMemory({ + keyPrefix: 'timelimit:sendmail-auth:global:hour', + points: 30, + duration: 60 * 60 // 1 hour +}) + +const gloablMailSendLimitDay: RateLimiterAbstract = new RateLimiterMemory({ + keyPrefix: 'timelimit:sendmail-auth:global:day', + points: 100, + duration: 60 * 60 * 24 // 1 day +}) + +const checkGlobalMailSendLimit = async () => { + await globalMailSendLimitMinute.consume('global') + await globalMailSendLimitHour.consume('global') + await gloablMailSendLimitDay.consume('global') +} + +const individualMailLimitFiveMinutes: RateLimiterAbstract = new RateLimiterMemory({ + keyPrefix: 'timelimit:sendmail-auth:individual:5minutes', + points: 2, + duration: 60 * 5 // 5 minutes +}) + +const individualMailLimitDay: RateLimiterAbstract = new RateLimiterMemory({ + keyPrefix: 'timelimit:sendmail-auth:individual:day', + points: 6, + duration: 60 * 60 * 24 // 1 day +}) + +const checkIndividualMailSendLimit = async (receiver: string) => { + await individualMailLimitFiveMinutes.consume(receiver) + await individualMailLimitDay.consume(receiver) +} + +export const checkMailSendLimit = async (receiver: string) => { + await checkIndividualMailSendLimit(receiver) + await checkGlobalMailSendLimit() +} diff --git a/src/util/ratelimit-warningmail.ts b/src/util/ratelimit-warningmail.ts new file mode 100644 index 0000000..4ee1eb7 --- /dev/null +++ b/src/util/ratelimit-warningmail.ts @@ -0,0 +1,49 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { RateLimiterAbstract, RateLimiterMemory } from 'rate-limiter-flexible' + +const individualMailLimitMinute: RateLimiterAbstract = new RateLimiterMemory({ + keyPrefix: 'timelimit:sendmail-warning:individual:minute', + points: 2, + duration: 60 // 1 minute +}) + +const individualMailLimitDay: RateLimiterAbstract = new RateLimiterMemory({ + keyPrefix: 'timelimit:sendmail-warning:individual:day', + points: 20, + duration: 60 * 60 * 24 // 1 day +}) + +const checkIndividualMailSendLimit = async (receiver: string) => { + await individualMailLimitMinute.consume(receiver) + await individualMailLimitDay.consume(receiver) +} + +const checkMailSendLimit = async (receiver: string) => { + await checkIndividualMailSendLimit(receiver) +} + +export const canSendWarningMail = async (receiver: string) => { + try { + await checkMailSendLimit(receiver) + + return true + } catch (ex) { + return false + } +} diff --git a/src/util/token.ts b/src/util/token.ts new file mode 100644 index 0000000..e4d58d4 --- /dev/null +++ b/src/util/token.ts @@ -0,0 +1,52 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as TokenGenerator from 'tokgen' + +const authTokenGenerator = new TokenGenerator({ + length: 32, + chars: 'a-zA-Z0-9' +}) + +export const generateAuthToken = () => authTokenGenerator.generate() + +const idWithinFamilyGenerator = new TokenGenerator({ + length: 6, + chars: 'a-zA-Z0-9' +}) + +export const generateIdWithinFamily = () => idWithinFamilyGenerator.generate() +export const isIdWithinFamily = (id: string) => id.length === 6 && /^[a-zA-Z0-9]+$/.test(id) +export const assertIdWithinFamily = (id: string) => { + if (!isIdWithinFamily(id)) { + throw new Error('invalid id within family') + } +} + +const versionIdGenerator = new TokenGenerator({ + length: 4, + chars: 'a-zA-Z0-9' +}) + +export const generateVersionId = () => versionIdGenerator.generate() + +const familyIdGenerator = new TokenGenerator({ + length: 10, + chars: 'a-zA-Z0-9' +}) + +export const generateFamilyId = () => familyIdGenerator.generate() diff --git a/src/websocket/index.ts b/src/websocket/index.ts new file mode 100644 index 0000000..a851880 --- /dev/null +++ b/src/websocket/index.ts @@ -0,0 +1,104 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as io from 'socket.io' +import { ConnectedDevicesManager, VisibleConnectedDevicesManager } from '../connected-devices' +import { Database } from '../database' +import { deviceByAuthTokenRoom } from './rooms' + +export const createWebsocketHandler = ({ connectedDevicesManager, database }: { + connectedDevicesManager: VisibleConnectedDevicesManager + database: Database +}): { + websocketServer: io.Server + websocketApi: WebsocketApi +} => { + const server = io() + + server.on('connection', (socket) => { + socket.on('devicelogin', (deviceAuthToken: any, ack: any) => { + socket.leaveAll() + + if (typeof deviceAuthToken !== 'string') { + return + } + + socket.join(deviceByAuthTokenRoom(deviceAuthToken)) + + ;(async () => { + const deviceEntryUnsafe = await database.device.findOne({ + where: { + deviceAuthToken + }, + attributes: ['familyId', 'deviceId'] + }) + + if (deviceEntryUnsafe && socket.connected) { + const deviceEntry = { + familyId: deviceEntryUnsafe.familyId, + deviceId: deviceEntryUnsafe.deviceId + } + + const key = ConnectedDevicesManager.buildKey({ + familyId: deviceEntry.familyId, + deviceId: deviceEntry.deviceId + }) + + connectedDevicesManager.connectedDevicesManager.reportDeviceConnected({ key }) + const { shutdown } = connectedDevicesManager.observeConnectedDevicesOfFamily({ + familyId: deviceEntry.familyId, + listener: (connectedDevices) => { + socket.emit('connected devices', connectedDevices) + } + }) + + socket.on('disconnect', () => { + connectedDevicesManager.connectedDevicesManager.reportDeviceDisconnected({ key }) + shutdown() + }) + } + })().catch((ex) => { /* ignore */ }) + + if (typeof ack === 'function') { + ack() + } + }) + }) + + const websocketApi: WebsocketApi = { + triggerSyncByDeviceAuthToken: ({ deviceAuthToken, isImportant }: {deviceAuthToken: string, isImportant: boolean}) => { + server + .to(deviceByAuthTokenRoom(deviceAuthToken)) + .emit('should sync', { isImportant }) + }, + triggerLogoutByDeviceAuthToken: ({ deviceAuthToken }: {deviceAuthToken: string}) => { + server + .to(deviceByAuthTokenRoom(deviceAuthToken)) + .emit('sign out') + } + } + + return { + websocketServer: server, + websocketApi + } +} + +export interface WebsocketApi { + triggerSyncByDeviceAuthToken: (params: {deviceAuthToken: string, isImportant: boolean}) => void + triggerLogoutByDeviceAuthToken: (params: {deviceAuthToken: string}) => void +} diff --git a/src/websocket/rooms.ts b/src/websocket/rooms.ts new file mode 100644 index 0000000..8ad55fa --- /dev/null +++ b/src/websocket/rooms.ts @@ -0,0 +1,18 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 . + */ + +export const deviceByAuthTokenRoom = (deviceAuthToken: string) => 'deviceauthtoken:' + deviceAuthToken diff --git a/src/worker/delete-deprecated-purchases.ts b/src/worker/delete-deprecated-purchases.ts new file mode 100644 index 0000000..9d04ec2 --- /dev/null +++ b/src/worker/delete-deprecated-purchases.ts @@ -0,0 +1,85 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { Database } from '../database' +import { notifyClientsAboutChanges } from '../function/websocket' +import { WebsocketApi } from '../websocket' + +export function initDeleteDeprecatedPurchasesWorker ({ database, websocket }: { + database: Database + websocket: WebsocketApi +}) { + function doWorkSafe () { + deleteDeprecatedPurchases({ database, websocket }).catch((ex) => { + console.warn('error deleting deprecated purchases', ex) + }) + } + + setTimeout(() => { + doWorkSafe() + + setInterval(() => { + doWorkSafe() + }, 1000 * 60 * 60 /* every hour */) + }, 1000 * 60 * 5 /* after 5 minutes */) +} + +async function deleteDeprecatedPurchases ({ database, websocket }: { + database: Database + websocket: WebsocketApi +}) { + const { affectedFamilyIds } = await database.transaction(async (transaction) => { + const affectedFamilyIds = await database.family.findAll({ + where: { + hasFullVersion: true, + fullVersionUntil: { + [Sequelize.Op.lt]: Date.now().toString(10) + } + }, + attributes: ['familyId'], + transaction, + lock: Sequelize.Transaction.LOCK.UPDATE, + limit: 100 + }).map((item) => item.familyId) + + await database.family.update({ + hasFullVersion: false + }, { + where: { + familyid: { + [Sequelize.Op.in]: affectedFamilyIds + } + }, + transaction + }) + + return { affectedFamilyIds } + }) + + for (let i = 0; i < affectedFamilyIds.length; i++) { + const familyId = affectedFamilyIds[i] + + await notifyClientsAboutChanges({ + familyId, + sourceDeviceId: null, + database, + websocket, + isImportant: true + }) + } +} diff --git a/src/worker/delete-old-tokens.ts b/src/worker/delete-old-tokens.ts new file mode 100644 index 0000000..010d6f3 --- /dev/null +++ b/src/worker/delete-old-tokens.ts @@ -0,0 +1,70 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 * as Sequelize from 'sequelize' +import { Database } from '../database' + +export function initDeleteOldTokensWorker ({ database }: { + database: Database +}) { + function doWorkSafe () { + deleteOldTokens({ database }).catch((ex) => { + console.warn('error deleting old tokens', ex) + }) + } + + setTimeout(() => { + doWorkSafe() + + setInterval(() => { + doWorkSafe() + }, 1000 * 60 * 60 /* every hour */) + }, 1000 * 60 * 7 /* after 7 minutes */) +} + +async function deleteOldTokens ({ database }: { + database: Database +}) { + await database.transaction(async (transaction) => { + await database.authtoken.destroy({ + where: { + createdAt: { + [Sequelize.Op.lt]: (Date.now() - 1000 * 60 * 60 * 3 /* 3 hours */).toString() + } + }, + transaction + }) + + await database.addDeviceToken.destroy({ + where: { + createdAt: { + [Sequelize.Op.lt]: (Date.now() - 1000 * 60 * 60 * 3 /* 3 hours */).toString() + } + }, + transaction + }) + + await database.mailLoginToken.destroy({ + where: { + createdAt: { + [Sequelize.Op.lt]: (Date.now() - 1000 * 60 * 60 * 3 /* 3 hours */).toString() + } + }, + transaction + }) + }) +} diff --git a/src/worker/delete-old-used-times.ts b/src/worker/delete-old-used-times.ts new file mode 100644 index 0000000..c4725a3 --- /dev/null +++ b/src/worker/delete-old-used-times.ts @@ -0,0 +1,94 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { uniqBy } from 'lodash' +import * as Sequelize from 'sequelize' +import { Database } from '../database' +import { generateVersionId } from '../util/token' + +export function initDeleteOldUsedTimesWorker ({ database }: { + database: Database +}) { + function doWorkSafe () { + deleteOldUsedTimes({ database }).catch((ex) => { + console.warn('error deleting old used times', ex) + }) + } + + setTimeout(() => { + doWorkSafe() + + setInterval(() => { + doWorkSafe() + }, 1000 * 60 * 30 /* every 30 minutes */) + }, 1000 * 60 * 13 /* after 13 minutes */) +} + +async function deleteOldUsedTimes ({ database }: { + database: Database +}) { + const now = Date.now() + + await database.transaction(async (transaction) => { + // get matching categories + const categoriesToCleanUp = await database.usedTime.findAll({ + transaction, + where: { + lastUpdate: { + [Sequelize.Op.lt]: (now - 1000 * 60 * 60 * 24 * 10 /* 10 days */).toString() + } + }, + attributes: [ + 'familyId', + 'categoryId' + ], + limit: 100 + }).map((item) => ({ + familyId: item.familyId, + categoryId: item.categoryId + })) + + const distinctCategoriesToCleanUp = uniqBy(categoriesToCleanUp, (item) => item.familyId + '_' + item.categoryId) + + if (distinctCategoriesToCleanUp.length > 0) { + // delete old items of matching categories + await database.usedTime.destroy({ + transaction, + where: { + [Sequelize.Op.or]: ( + distinctCategoriesToCleanUp + ), + lastUpdate: { + [Sequelize.Op.lt]: (now - 1000 * 60 * 60 * 24 * 10 /* 10 days */).toString() + } + } + }) + + // invalidiate categories + await database.category.update({ + usedTimesVersion: generateVersionId() + }, { + transaction, + where: { + [Sequelize.Op.or]: ( + distinctCategoriesToCleanUp + ) + } + }) + } + }) +} diff --git a/src/worker/index.ts b/src/worker/index.ts new file mode 100644 index 0000000..bf1ea4b --- /dev/null +++ b/src/worker/index.ts @@ -0,0 +1,31 @@ +/* + * server component for the TimeLimit App + * Copyright (C) 2019 Jonas Lochmann + * + * 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, version 3 of the License. + * + * 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 { Database } from '../database' +import { WebsocketApi } from '../websocket' +import { initDeleteDeprecatedPurchasesWorker } from './delete-deprecated-purchases' +import { initDeleteOldTokensWorker } from './delete-old-tokens' +import { initDeleteOldUsedTimesWorker } from './delete-old-used-times' + +export function initWorkers ({ database, websocket }: { + database: Database + websocket: WebsocketApi +}) { + initDeleteDeprecatedPurchasesWorker({ database, websocket }) + initDeleteOldTokensWorker({ database }) + initDeleteOldUsedTimesWorker({ database }) +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..74c283a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "outDir": "./build", + "allowJs": true, + "target": "es2017", + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "module": "commonjs", + "noUnusedLocals": true, + "noUnusedParameters": false, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "sourceMap": true + }, + "include": [ + "./src/**/*" + ], + "compileOnSave": true +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..4a21430 --- /dev/null +++ b/tslint.json @@ -0,0 +1,12 @@ +{ + "defaultSeverity": "error", + "extends": [ + "tslint-config-standard" + ], + "jsRules": {}, + "rules": { + "await-promise": [true, "Bluebird"], + "ordered-imports": true + }, + "rulesDirectory": [] +}