diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md diff --git a/.gitignore b/.gitignore index 85a69ad..6e1e759 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ config.json config.js data/ test.js +musicsettings.json # Runtime data pids diff --git a/LICENSE b/LICENSE index 2368cab..dbbe355 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,661 @@ -Copyright (c) 2018 Matthew R -Copyright (c) 2018 Fortnite Community Council + 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/allowedGuildDB.json b/allowedGuildDB.json new file mode 100644 index 0000000..04d52d1 --- /dev/null +++ b/allowedGuildDB.json @@ -0,0 +1 @@ +{"allowedGuildIDs":["446067825673633794","446067825673633794"]} \ No newline at end of file diff --git a/build/config.gypi b/build/config.gypi new file mode 100644 index 0000000..d1c6c19 --- /dev/null +++ b/build/config.gypi @@ -0,0 +1,181 @@ +# Do not edit. File was generated by node-gyp's "configure" step +{ + "target_defaults": { + "cflags": [], + "default_configuration": "Release", + "defines": [], + "include_dirs": [], + "libraries": [] + }, + "variables": { + "asan": 0, + "coverage": "false", + "debug_devtools": "node", + "debug_http2": "false", + "debug_nghttp2": "false", + "force_dynamic_crt": 0, + "host_arch": "x64", + "icu_data_file": "icudt60l.dat", + "icu_data_in": "..\\..\\deps/icu-small\\source/data/in\\icudt60l.dat", + "icu_endianness": "l", + "icu_gyp_path": "tools/icu/icu-generic.gyp", + "icu_locales": "en,root", + "icu_path": "deps/icu-small", + "icu_small": "true", + "icu_ver_major": "60", + "node_byteorder": "little", + "node_enable_d8": "false", + "node_enable_v8_vtunejit": "false", + "node_install_npm": "true", + "node_module_version": 57, + "node_no_browser_globals": "false", + "node_prefix": "/usr/local", + "node_release_urlbase": "https://nodejs.org/download/release/", + "node_shared": "false", + "node_shared_cares": "false", + "node_shared_http_parser": "false", + "node_shared_libuv": "false", + "node_shared_nghttp2": "false", + "node_shared_openssl": "false", + "node_shared_zlib": "false", + "node_tag": "", + "node_target_type": "executable", + "node_use_bundled_v8": "true", + "node_use_dtrace": "false", + "node_use_etw": "true", + "node_use_lttng": "false", + "node_use_openssl": "true", + "node_use_perfctr": "true", + "node_use_v8_platform": "true", + "node_without_node_options": "false", + "openssl_fips": "", + "openssl_no_asm": 0, + "shlib_suffix": "so.57", + "target_arch": "x64", + "v8_enable_gdbjit": 0, + "v8_enable_i18n_support": 1, + "v8_enable_inspector": 1, + "v8_no_strict_aliasing": 1, + "v8_optimized_debug": 0, + "v8_promise_internal_field_count": 1, + "v8_random_seed": 0, + "v8_trace_maps": 0, + "v8_use_snapshot": "true", + "want_separate_host_toolset": 0, + "nodedir": "C:\\Users\\matth\\.node-gyp\\8.11.4", + "standalone_static_library": 1, + "access": "", + "allow_same_version": "", + "also": "", + "always_auth": "", + "auth_type": "legacy", + "bin_links": "true", + "browser": "", + "ca": "", + "cache": "C:\\Users\\matth\\AppData\\Roaming\\npm-cache", + "cache_lock_retries": "10", + "cache_lock_stale": "60000", + "cache_lock_wait": "10000", + "cache_max": "Infinity", + "cache_min": "10", + "cert": "", + "cidr": "", + "color": "true", + "commit_hooks": "true", + "depth": "Infinity", + "description": "true", + "dev": "", + "dry_run": "", + "editor": "notepad.exe", + "engine_strict": "", + "fetch_retries": "2", + "fetch_retry_factor": "10", + "fetch_retry_maxtimeout": "60000", + "fetch_retry_mintimeout": "10000", + "force": "", + "git": "git", + "git_tag_version": "true", + "global": "", + "globalconfig": "C:\\Users\\matth\\AppData\\Roaming\\npm\\etc\\npmrc", + "globalignorefile": "C:\\Users\\matth\\AppData\\Roaming\\npm\\etc\\npmignore", + "global_style": "", + "group": "", + "ham_it_up": "", + "heading": "npm", + "https_proxy": "", + "if_present": "", + "ignore_prepublish": "", + "ignore_scripts": "", + "init_author_email": "", + "init_author_name": "", + "init_author_url": "", + "init_license": "ISC", + "init_module": "C:\\Users\\matth\\.npm-init.js", + "init_version": "1.0.0", + "json": "", + "key": "", + "legacy_bundling": "", + "link": "", + "local_address": "", + "logs_max": "10", + "long": "", + "maxsockets": "50", + "message": "%s", + "metrics_registry": "https://registry.npmjs.org/", + "node_gyp": "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js", + "node_options": "", + "node_version": "8.11.4", + "offline": "", + "onload_script": "", + "only": "", + "optional": "true", + "otp": "", + "package_lock": "true", + "package_lock_only": "", + "parseable": "", + "prefer_offline": "", + "prefer_online": "", + "prefix": "C:\\Users\\matth\\AppData\\Roaming\\npm", + "production": "", + "progress": "true", + "read_only": "", + "rebuild_bundle": "true", + "registry": "https://registry.npmjs.org/", + "rollback": "true", + "save": "true", + "save_bundle": "", + "save_dev": "", + "save_exact": "", + "save_optional": "", + "save_prefix": "^", + "save_prod": "", + "scope": "", + "scripts_prepend_node_path": "warn-only", + "script_shell": "", + "searchexclude": "", + "searchlimit": "20", + "searchopts": "", + "searchstaleness": "900", + "send_metrics": "", + "shell": "C:\\Windows\\system32\\cmd.exe", + "shrinkwrap": "true", + "sign_git_tag": "", + "sso_poll_frequency": "500", + "sso_type": "oauth", + "strict_ssl": "true", + "tag": "latest", + "tag_version_prefix": "v", + "timing": "", + "tmp": "C:\\Users\\matth\\AppData\\Local\\Temp", + "umask": "0000", + "unicode": "", + "unsafe_perm": "true", + "usage": "", + "user": "", + "userconfig": "C:\\Users\\matth\\.npmrc", + "user_agent": "npm/5.6.0 node/v8.11.4 win32 x64", + "version": "", + "versions": "", + "viewer": "browser" + } +} diff --git a/commands/channelinfo.js b/commands/channelinfo.js index 0ce68f2..da453c9 100644 --- a/commands/channelinfo.js +++ b/commands/channelinfo.js @@ -4,13 +4,17 @@ const Discord = require("discord.js"); exports.run = async (client, message) => { + const msg = await message.channel.send("Loading..."); const embed = new Discord.RichEmbed() .setAuthor(message.guild.name, message.guild.iconURL) .setTitle('Channel Information') .addField('Name', `${message.channel.name}`, true) - .addField('Category', `${message.channel.parent.name}`, true) - .addField('Topic', `${message.channel.topic}`, true) - if (message.channel.topic != true) { + try { + embed.addField('Category', `${message.channel.parent.name}`, true) + } catch(err) { + embed.addField('Category', 'None', true) + } + if (!message.channel.topic) { embed.addField('Topic', 'None', true) } else { @@ -22,12 +26,13 @@ exports.run = async (client, message) => { embed.addField('NSFW', 'Yes', true) } embed.setFooter(client.user.username, client.user.avatarURL) - message.channel.send(embed) + embed.setTimestamp() + msg.edit(embed) } exports.conf = { enabled: true, - guildOnly: false, + guildOnly: true, aliases: [], permLevel: "Standard User" }; @@ -37,4 +42,4 @@ exports.conf = { category: "Misc", description: "Provides information for the channel.", usage: "channel info" - }; \ No newline at end of file + }; diff --git a/commands/checkinvites.js b/commands/checkgames.js similarity index 86% rename from commands/checkinvites.js rename to commands/checkgames.js index fa2cf8e..bfb1d7a 100644 --- a/commands/checkinvites.js +++ b/commands/checkgames.js @@ -7,12 +7,12 @@ exports.run = (client, msg, args, level) => { enabled: true, guildOnly: true, aliases: ["ci"], - permLevel: "Systems Alpha/Dev Tester" + permLevel: "Server Moderator" }; exports.help = { - name: 'checkinvites', + name: 'checkgames', category: 'Moderation', description: 'Returns a list of members with an invite as their game.', - usage: 'checkinvites' + usage: 'checkgames' }; diff --git a/commands/checkservers.js b/commands/checkservers.js new file mode 100644 index 0000000..b937a52 --- /dev/null +++ b/commands/checkservers.js @@ -0,0 +1,18 @@ +exports.run = (client, message, guild, msg) => { + const members = message.guild.members.filter(member => member.user.username && /(discord\.(gg|io|me|li)\/.+|discordapp\.com\/invite\/.+)/i.test(member.user.username)); + return message.channel.send(members.map(member => `\`${member.id}\` ${member.displayName}`).join("\n") || "No one in this server has a Discord invite as their user name."); +} + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: ["cs"], + permLevel: "Server Moderator" + }; + + exports.help = { + name: 'checkservers', + category: 'Moderation', + description: 'Returns a list of members with an invite as their username.', + usage: 'checkservers' + }; diff --git a/commands/createinvite.js b/commands/createinvite.js new file mode 100644 index 0000000..a6be51a --- /dev/null +++ b/commands/createinvite.js @@ -0,0 +1,30 @@ +const Discord = require('discord.js') + +exports.run = (client, message, args) => { + if(args < 1) {message.channel.createInvite({ + maxAge: 0 + }) + .then(invite => message.channel.send(`Created an invite with a code of discord.gg/${invite.code}`)) + .catch(console.error); +} +if(args > 1) { + message.channel.createInvite({ + maxAge: args[0] + }) + .then(invite => message.channel.send(`Created invite with a code of discord.gg/${invite.code} with the age of ${args[0]} seconds`)) +} +} + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "Standard User" + }; + + exports.help = { + name: 'createinvite', + category: 'Misc', + description: 'Creates an invite for the channel.', + usage: 'createinvite [...# of seconds]' + }; diff --git a/commands/embed.js b/commands/embed.js new file mode 100644 index 0000000..4a6e490 --- /dev/null +++ b/commands/embed.js @@ -0,0 +1,26 @@ +const Discord = require('discord.js') + +exports.run = (client, message, args) => { + const embed = new Discord.RichEmbed() + .setFooter(client.user.username, client.user.avatarURL) + .setDescription(args.join(" ")) + .setTimestamp() + + message.delete() + message.channel.send(embed) +} + + exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "Server Moderator" + }; + + exports.help = { + name: "embed", + category: "Fun", + description: "Sends an embed, like a say command. But with an embed.", + usage: "embed [...text]" + }; + diff --git a/commands/eping.js b/commands/eping.js new file mode 100644 index 0000000..9062d7f --- /dev/null +++ b/commands/eping.js @@ -0,0 +1,36 @@ +const Discord = require("discord.js"); +const talkedRecently = new Set(); +exports.run = async (client, message) => { + if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) { + + message.channel.send("You are being rate limited!" + message.author); + } else { // eslint-disable-line no-unused-vars + const msg = await message.channel.send("Ping?"); + const embed = new Discord.RichEmbed() + .setAuthor(`${client.user.username}`, `${client.user.avatarURL}`) + .setColor(message.member.displayColor) + .addField("• Ping Latency", `${msg.createdTimestamp - message.createdTimestamp}ms`, true) + .addField("• API Latency", `${Math.round(client.ping)}ms`, true) + .setFooter(`${client.user.username} | Beta - Master`); + msg.edit(embed); + talkedRecently.add(message.author.id); + setTimeout(() => { + // Removes the user from the set after a minute + talkedRecently.delete(message.author.id); + }, 2000); +}; +} + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "Standard User" +}; + +exports.help = { + name: "eping", + category: "Misc", + description: "Pings the bot, but replies with an embed.", + usage: "eping" +}; diff --git a/commands/eval.js b/commands/eval.js index a179e27..ca39acb 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -1,12 +1,25 @@ const os = require('os') -exports.run = async (client, message, args, level) => { // eslint-disable-line no-unused-vars +const Discord = require('discord.js') +exports.run = async (client, message, args, level) => { const code = args.join(" "); try { const evaled = eval(code); const clean = await client.clean(client, evaled); - message.channel.send(`\`\`\`js\n${clean}\n\`\`\``); + const embed1 = new Discord.RichEmbed() + .setAuthor(client.user.username, client.user.avatarURL) + .setTitle('__JAVASCRIPT EVALUATION__') + .setDescription(`\`\`\`js\n${clean}\n\`\`\``) + .setTimestamp() + .setFooter(`${client.user.username} | Requested by ${message.author.username}#${message.author.discriminator}`); + message.channel.send(embed1) } catch (err) { - message.channel.send(`\`ERROR\` \`\`\`xl\n${await client.clean(client, err)}\n\`\`\``); + const embed2 = new Discord.RichEmbed() + embed2.setAuthor(client.user.username, client.user.avatarURL) + embed2.setTitle('__JAVASCRIPT EVALUATION__') + embed2.setDescription(`\`ERROR\` \`\`\`xl\n${await client.clean(client, err)}\n\`\`\``); + embed2.setTimestamp() + embed2.setFooter(`${client.user.username} | Requested by ${message.author.username}#${message.author.discriminator}`); + message.channel.send(embed2) } }; @@ -14,7 +27,7 @@ exports.conf = { enabled: true, guildOnly: false, aliases: ["e"], - permLevel: "Systems Administrator" + permLevel: "Systems Developer" }; exports.help = { diff --git a/commands/game.js b/commands/game.js index 5253d88..ad64d7b 100644 --- a/commands/game.js +++ b/commands/game.js @@ -63,8 +63,8 @@ exports.run = async (client, message, args) => { exports.conf = { enabled: true, guildOnly: true, - aliases: ["g"], - permLevel: "Systems Alpha/Dev Tester" + aliases: [], + permLevel: "Standard User" }; exports.help = { diff --git a/commands/help.js b/commands/help.js index 125bb97..5bcaf22 100644 --- a/commands/help.js +++ b/commands/help.js @@ -10,28 +10,62 @@ exports.run = (client, message, args, level) => { const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0); let currentCategory = ""; - let output = `= Command List =\n\n[Use ${message.settings.prefix}help for details]\n`; + let output = `__**Command List**__\n\n[Use ${message.settings.prefix}help for details]\n`; const sorted = myCommands.array().sort((p, c) => p.help.category > c.help.category ? 1 : p.help.name > c.help.name && p.help.category === c.help.category ? 1 : -1 ); sorted.forEach( c => { const cat = c.help.category.toProperCase(); if (currentCategory !== cat) { - output += `\u200b\n== ${cat} ==\n`; + output += `\u200b\n **${cat}** \n`; currentCategory = cat; } - output += `${message.settings.prefix}${c.help.name}${" ".repeat(longest - c.help.name.length)} :: ${c.help.description}\n`; + output += `${message.settings.prefix}${c.help.name}${" ".repeat(longest - c.help.name.length)} :: *${c.help.description}*\n`; }); - message.channel.send(output, {code: "asciidoc", split: { char: "\u200b" }}); + const Discord = require('discord.js') + if (output.length > 2048) { + const loe = new Discord.RichEmbed() + .setAuthor(`${client.user.username}`, `${client.user.avatarURL}`) + .setDescription('Sorry, but the embed is too long to be sent. We are working on a website for a list of commands, please be patient.') + .addField('Workaround', `In the meantime, however. You're more than welcome to use help to lookup information on individual commands.`) + .setTitle(`${client.user.username} Help Manual`) + .setFooter(`${client.user.username} | Beta - Master`) + .setTimestamp() + message.channel.send(loe) + + } else { + const embed1 = new Discord.RichEmbed() + .setAuthor(`${client.user.username}`, `${client.user.avatarURL}`) + .setDescription(output, {code: "asciidoc", split: { char: "\u200b" }}) + .setTitle(`${client.user.username} Help Manual`) + .setFooter(`${client.user.username} | Beta - Master`) + .setTimestamp() + message.channel.send(embed1) + } + // message.channel.send(output, {code: "asciidoc", split: { char: "\u200b" }}); } else { // Show individual command's help. let command = args[0]; if (client.commands.has(command)) { command = client.commands.get(command); if (level < client.levelCache[command.conf.permLevel]) return; - message.channel.send(`= ${command.help.name} = \n${command.help.description}\nusage:: ${command.help.usage}\naliases:: ${command.conf.aliases.join(", ")}\n= ${command.help.name} =`, {code:"asciidoc"}); + const Discord = require('discord.js') + const embed2 = new Discord.RichEmbed() + .setAuthor(`${client.user.username}`, `${client.user.avatarURL}`) + .setTitle(`${client.user.username} Help Manual`) + .addField('Command', `${command.help.name}`, true) + .addField('Description', `${command.help.description}`, true) + .addField('Usage', `${command.help.usage}`, true) + .setFooter(`${client.user.username} | Beta - Master`) + .setTimestamp() + message.channel.send(embed2) + + // message.channel.send(`= ${command.help.name} = \n${command.help.description}\nusage:: ${command.help.usage}\naliases:: ${command.conf.aliases.join(", ")}\n= ${command.help.name} =`, {code:"asciidoc"}); } } }; +/* This was an idea by Flatbird, making this an embed, thank him. Not me. +*/ + exports.conf = { enabled: true, guildOnly: false, diff --git a/commands/info.js b/commands/info.js index 80d65bf..39ee87a 100644 --- a/commands/info.js +++ b/commands/info.js @@ -8,9 +8,11 @@ exports.run = async (client, message, args, level) => { .addField("Created At", `${client.user.createdAt}`, true) .addField("Library", "[Discord.js](https://github.com/discordjs/discord.js)", true) .addField("Language", "JavaScript", true) - .addField("Contributors", `NightRaven#2172, CoalSephos#7566, FlatBird#9461, TheSkele27#1337`, true) + .addField("Contributors", `FlatBird#9461, TheSkele27#1337, The Phoenix of Phoebus#9935`, true) + .addField('Developers', `Matthew#0008, NightRaven#2172, CoalSephos#7566`) .addField("Creator", `Matthew#0008`, true) - .setFooter(`${client.user.username} | Beta - Master`); + .setTimestamp() + .setFooter(`${client.user.username} | Beta - Master`, 'https://cdn.discordapp.com/attachments/358674161566220288/493662532746084352/js.png'); diff --git a/commands/invite.js b/commands/invite.js index 813bdcb..24e13cf 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -6,6 +6,8 @@ const embed = new Discord.RichEmbed() .setAuthor(`${client.user.username}`, `${client.user.avatarURL}`) .setColor(message.member.displayColor) .addField("Invite Link", "https://discordapp.com/api/oauth2/authorize?client_id=460639060851949569&permissions=8&scope=bot", true) + .addField('Activation', `Don't forget, ${client.user.username} has to be activated before you can invite it. If you want to request activation, do \`moon serverinvite\` and post your server ID anywhere and ping a staff member.`) + .setTimestamp() .setFooter(`${client.user.username} | Beta - Master`); message.member.user.createDM().then(channel => channel.send(embed)) @@ -13,6 +15,8 @@ const embed = new Discord.RichEmbed() .setAuthor(`${client.user.username}`, `${client.user.avatarURL}`) .setColor(message.member.displayColor) .setDescription("Invite link sent, check your DMs.") + .addField('Activation', `Don't forget, ${client.user.username} has to be activated before you can invite it. If you want to request activation, do \`moon serverinvite\` and post your server ID anywhere and ping a staff member.`) + .setTimestamp() .setFooter(`${client.user.username} | Beta - Master`); message.channel.send(em1) }; @@ -25,7 +29,7 @@ const embed = new Discord.RichEmbed() enabled: true, guildOnly: false, aliases: ["get", "join"], - permLevel: "Systems Alpha/Dev Tester" + permLevel: "Standard User" }; exports.help = { diff --git a/commands/joe.js b/commands/joe.js new file mode 100644 index 0000000..fff28d7 --- /dev/null +++ b/commands/joe.js @@ -0,0 +1,23 @@ +exports.run = (client, message, args) => { + if(message.author.id === '208688963936845824' || '278620217221971968') { + message.channel.send(`Joe have declared war on ${args[0]}, their anus will now be destroyed by the one and only... Virgin Slayer 69`); + } + else { + return; + } + +} + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "Standard User" +}; + + exports.help = { + name: "joe", + category: "Fun", + description: "Joe, just Joe.", + usage: "joe [...mention]" + }; \ No newline at end of file diff --git a/commands/kick.js b/commands/kick.js index 29f3ba9..1d7b45d 100644 --- a/commands/kick.js +++ b/commands/kick.js @@ -7,9 +7,10 @@ exports.run = (client, message, [mention, ...reason]) => { return message.reply("I do not have the kick members permission."); const kickMember = message.mentions.members.first(); + message.delete(); kickMember.kick(reason.join(" ")).then(member => { - message.reply(`${member.user.username} was succesfully kicked.`); + message.reply(`***${member.user.username} has been kicked.***`); }); } catch (err) { msg.edit("EXCPT*- " + diff --git a/commands/ping.js b/commands/ping.js index ed0abe9..d508338 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -1,36 +1,19 @@ -const Discord = require("discord.js"); -const talkedRecently = new Set(); exports.run = async (client, message) => { - if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) { - - message.channel.send("You are being rate limited!" + message.author); - } else { // eslint-disable-line no-unused-vars - const msg = await message.channel.send("Ping?"); - const embed = new Discord.RichEmbed() - .setAuthor(`${client.user.username}`, `${client.user.avatarURL}`) - .setColor(message.member.displayColor) - .addField("• Ping Latency", `${msg.createdTimestamp - message.createdTimestamp}ms`, true) - .addField("• API Latency", `${Math.round(client.ping)}ms`, true) - .setFooter(`${client.user.username} | Beta - Master`); - msg.edit(embed); - talkedRecently.add(message.author.id); - setTimeout(() => { - // Removes the user from the set after a minute - talkedRecently.delete(message.author.id); - }, 2000); -}; + const msg = await message.channel.send("Ping..."); + + msg.edit(`🏓 Pong! \`${msg.createdTimestamp - message.createdTimestamp}ms\``) } exports.conf = { - enabled: true, - guildOnly: false, - aliases: [], - permLevel: "Standard User" -}; - -exports.help = { - name: "ping", - category: "Misc", - description: "Pings the bot, responds with API and regular latencies.", - usage: "ping" -}; + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "Standard User" + }; + + exports.help = { + name: "ping", + category: "Misc", + description: "Pings the bot, without the embed.", + usage: "ping" + }; \ No newline at end of file diff --git a/commands/purge.js b/commands/purge.js index 7d2c255..9631b55 100644 --- a/commands/purge.js +++ b/commands/purge.js @@ -1,7 +1,4 @@ exports.run = async (client, message, args) => { - - if (!message.member.hasPermission("MANAGE_MESSAGES")) - return message.reply("Sorry, you don't have permissions to use this!"); message.delete(); const deleteCount = parseInt(args[0], 10); @@ -18,7 +15,7 @@ exports.conf = { enabled: true, guildOnly: true, aliases: [], - permLevel: "Server Moderator" + permLevel: "Server Admin" }; exports.help = { diff --git a/commands/racd.js b/commands/racd.js new file mode 100644 index 0000000..db6070e --- /dev/null +++ b/commands/racd.js @@ -0,0 +1,46 @@ +const Discord = require("discord.js"); +const fs = require("fs"); +exports.run = (client, message, args) => { + fs.readFile("./allowedGuildDB.json", "utf8", async (err, data) => { // readFile method basically allows us to read the data in that file + if (err !== null) { // Just an error checker + return console.log(err); + } else { +const guildID = args[0]; + +const requiredData = JSON.parse(data); +const index = requiredData.allowedGuildIDs.indexOf(guildID); +if (index !== -1) { +requiredData.allowedGuildIDs.splice(index, 1); + // And now we write the final data again + const json = JSON.stringify(requiredData); + fs.writeFile("./allowedGuildDB.json", json, "utf8", (err) => { + if (err !== null) { + console.log(err); +} + }); + message.delete(); +const guild = client.guilds.get(guildID); +(guild !== undefined) ? guild.leave() : null; + message.channel.send(`✅ Deactivated Moonglow on ${args[0]}`); +} +else { +message.channel.send(`Specified guild was never activated.`); +} + } + }); + } + + + exports.conf = { + enabled: true, + guildOnly: true, + aliases: ["remove"], + permLevel: "Systems Support" + }; + + exports.help = { + name: "racd", + category: "System", + description: "Removes a server from activation.", + usage: "racd [...server ID]" + }; \ No newline at end of file diff --git a/commands/racr.js b/commands/racr.js new file mode 100644 index 0000000..42883b8 --- /dev/null +++ b/commands/racr.js @@ -0,0 +1,59 @@ +const Discord = require("discord.js"); +const fs = require("fs"); +exports.run = async (client, message, args) => { + + fs.readFile("./allowedGuildDB.json", "utf8", async (err, data) => { // readFile method basically allows us to read the data in that file + if (err !== null) { // Just an error checker + return console.log(err); + } + else { + const guildID = args[0]; + if (data.length === 0) { // So let's use this case when the file data is empty + // So let's get the guild ID first. In eris, the arguments (Whatever follows the command name) is split by spaces, so it should be pretty easy to get the guild ID we need + const requiredObject = { + allowedGuildIDs: [] + } + requiredObject.allowedGuildIDs.push(guildID); + // After we push the data, we convert it to JSON + const json = JSON.stringify(requiredObject); + // And now we write the data to the same file + fs.writeFile("./allowedGuildDB.json", json, "utf8", (err) => { + if (err !== null) { + console.log(err); + } + }); + // Make sure you send message when this condition occurs too + } + else { // this case would mean that the file isn't empty + const requiredData = JSON.parse(data); + requiredData.allowedGuildIDs.push(guildID); + // And now we write the final data again + const json = JSON.stringify(requiredData); + fs.writeFile("./allowedGuildDB.json", json, "utf8", (err) => { + if (err !== null) { + console.log(err); + } + + }); + message.delete() + message.channel.send(`✅ Moonglow has been activated on ${guildID} for <@!${args[1]}>`) + // I'm going to convert this over to discord.js really quick btw + // Alright + } + } + }); +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: ["confirm"], + permLevel: "Systems Support" + }; + + exports.help = { + name: "racr", + category: "System", + description: "Confirms server activation.", + usage: "racr [...server ID]" + }; diff --git a/commands/serverinvite.js b/commands/serverinvite.js new file mode 100644 index 0000000..eb0c39f --- /dev/null +++ b/commands/serverinvite.js @@ -0,0 +1,26 @@ +const Discord = require("discord.js"); +exports.run = async (client, message, args, level) => { + const invite = 'https://discord.gg/F7KXaFk' + + const embed = new Discord.RichEmbed() + .setAuthor(message.guild.name, 'https://cdn.discordapp.com/icons/446067825673633794/19a38486fb2a04bda9bd064c6010ec06.png?size=128') + .setTitle('Server Invitation') + .setTimestamp(message.createdAt) + .setFooter(client.user.username, client.user.avatarURL) + .setDescription(invite) + message.channel.send(embed) +} + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "Standard User" + }; + + exports.help = { + name: "serverinvite", + category: "System", + description: "Posts the invite URL to the main server.", + usage: "serverinvite" + }; \ No newline at end of file diff --git a/commands/slowmode.js b/commands/slowmode.js new file mode 100644 index 0000000..d755d10 --- /dev/null +++ b/commands/slowmode.js @@ -0,0 +1,48 @@ +const Discord = require("discord.js"); +const axios = require("axios") + +exports.run = (client, message, args) => { + function slowmode(s, m){ + axios({ + method: 'patch', + url: `https://discordapp.com/api/v6/channels/${message.channel.id}`, + headers: { + "Authorization" : `Bot ${client.config.token}` + }, + data: { + rate_limit_per_user: s, + reason: args.slice(1).join(" ") + } + }).then(message.channel.send(m)) + .catch((err) =>{ + message.channel.send('An error has occurred, either I do not have permissions or the ID is undefined.'); + }); +} + + + + if(args[0] === "off"){ + message.delete() + slowmode(0, `***Slowmode has been disabled in this channel.***`); + } else if(isNaN(args[0]) || parseInt(args[0]) > 120 || parseInt(args[0]) < 1){ + message.channel.send(`${client.config.emotes.error} **Error:** Please use a number between 1 and 120`); + } else { + message.delete() + slowmode(args[0], `***Slowmode is enabled in this channel for ${args[0]} seconds.***`); + } +} + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "Server Moderator" + }; + + exports.help = { + name: "slowmode", + category: "Moderation", + description: "Prevents users from sending messages too fast.", + usage: "Slowmode [...# of secs]" + }; + \ No newline at end of file diff --git a/commands/stats.js b/commands/stats.js index d8f34ae..44de8a7 100644 --- a/commands/stats.js +++ b/commands/stats.js @@ -23,6 +23,7 @@ exports.run = (client, message, args, level) => { // eslint-disable-line no-unus .addField("• Discord.js Version", `v${version}`, true) .addField("• Node Version", `${process.version}`, true) .addField("Creator", `Matthew#0008`, true) + .setTimestamp() .setFooter(`${client.user.username} | Beta - Master`); message.channel.send(embed); }; diff --git a/commands/whois.js b/commands/whois.js index f215331..e910a25 100644 --- a/commands/whois.js +++ b/commands/whois.js @@ -7,21 +7,23 @@ const status = { offline: "Offline/Invisible" }; exports.run = async (client, message, args, level) => { + const resolvedUser = (args[0] !== undefined) ? message.guild.members.get(args[0].match(/[0-9]/g).join("")) : null; if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) { - message.channel.send("You are being rate limited!" + message.author); + const botmessage = await message.channel.send("You are being rate limited!" + message.author) + botmessage.delete(10000) } else { - if (message.mentions.users.first()) + if (resolvedUser) try { - level = client.permlevel(message.mentions.users.first().lastMessage); + level = client.permlevel(resolvedUser.lastMessage); } catch (e) { level = 0; } const msg = await message.channel.send("Loading..."); try { const friendly = client.config.permLevels.find(l => l.level === level).name; - const botuser = message.mentions.users.first() ? message.guild.members.get(message.mentions.users.first().id) : message.member; - const matt = message.mentions.users.first() ? message.guild.members.get(message.mentions.users.first().id).roles.sort((a, b) => b.position - a.position).map(i => i.id).slice(0, -1) : message.member.roles.sort((a, b) => b.position - a.position).map(i => i.id).slice(0, -1); + const botuser = resolvedUser ? message.guild.members.get(resolvedUser.id) : message.member; + const matt = resolvedUser ? message.guild.members.get(resolvedUser.id).roles.sort((a, b) => b.position - a.position).map(i => i.id).slice(0, -1) : message.member.roles.sort((a, b) => b.position - a.position).map(i => i.id).slice(0, -1); let bot = ""; let myDick = ""; for (let i = 0; i < matt.length; i++) { @@ -45,6 +47,7 @@ exports.run = async (client, message, args, level) => { .addField("Roles", `${myDick}`, true) .addField("Acknowledgements", `${friendly}`, true) .addField("System Level", `${level}`, true) + .setTimestamp() .setFooter(`${client.user.username} | ID ${botuser.id} | Beta - Master`); if (bot == "Yes") { embed.addField("Bot", `${bot}`, true) @@ -73,4 +76,4 @@ exports.help = { category: "Misc", description: "Provides user information.", usage: "whois" -}; +}; \ No newline at end of file diff --git a/events/guildCreate.js b/events/guildCreate.js index c133186..998bb9a 100644 --- a/events/guildCreate.js +++ b/events/guildCreate.js @@ -1,5 +1,30 @@ // This event executes when a new guild (server) is joined. - +const fs = require("fs"); module.exports = (client, guild) => { + /* this code checks to make sure that the bot is in the authorized list of servers below in the "activatedServers" + If it's not in this list, then the bot will leave the server and then will return a DEBUG message to the console. */ + + fs.readFile("./allowedGuildDB.json", "utf8", (err, data) => { + if (err !== null) { + console.log(err); + } + else { + const allowedGuild = JSON.parse(data); + if (allowedGuild.allowedGuildIDs.includes(guild.id)) { + return; + } + else { + return guild.leave(guild.id); + } + } +}); + +// If you don't want this feature on your bot, feel free to remove everything from this line of text to the above comment. + + + client.logger.cmd(`[GUILD JOIN] ${guild.name} (${guild.id}) added the bot. Owner: ${guild.owner.user.tag} (${guild.owner.user.id})`); + + + }; diff --git a/events/guildDelete.js b/events/guildDelete.js index c24d0d5..7bfcae2 100644 --- a/events/guildDelete.js +++ b/events/guildDelete.js @@ -1,7 +1,25 @@ // This event executes when a new guild (server) is left. - +const fs = require('fs') module.exports = (client, guild) => { client.logger.cmd(`[GUILD LEAVE] ${guild.name} (${guild.id}) removed the bot.`); + fs.readFile("./allowedGuildDB.json", "utf8", async (err, data) => { // readFile method basically allows us to read the data in that file + if (err !== null) { // Just an error checker + return console.log(err); + } + else { + const guildID = args[0]; + } + const requiredData = JSON.parse(data); + requiredData.allowedGuildIDs.shift(guildID); + // And now we write the final data again + const json = JSON.stringify(requiredData); + fs.writeFile("./allowedGuildDB.json", json, "utf8", (err) => { + if (err !== null) { + console.log(err); + } + + }); +}) // If the settings Enmap contains any guild overrides, remove them. // No use keeping stale data! diff --git a/events/ready.js b/events/ready.js index 0eb506f..a19ee79 100644 --- a/events/ready.js +++ b/events/ready.js @@ -4,4 +4,6 @@ module.exports = async client => { // Make the bot "play the game" which is the help command with default prefix. client.user.setActivity(`${client.config.defaultSettings.prefix}help | Beta - Master`, {type: "PLAYING"}); +//die + }; diff --git a/modules/functions.js b/modules/functions.js index 653127a..0e16bee 100644 --- a/modules/functions.js +++ b/modules/functions.js @@ -85,7 +85,7 @@ module.exports = (client) => { text = text .replace(/`/g, "`" + String.fromCharCode(8203)) .replace(/@/g, "@" + String.fromCharCode(8203)) - .replace(client.token, "mfa.VkO_2G4Qv3T--NO--lWetW_tjND--TOKEN--QFTm6YGtzq9PH--4U--tG0"); + .replace(client.token, "Token is classfied and hidden from this field."); return text; }; diff --git a/music.js b/music.js new file mode 100644 index 0000000..193357c --- /dev/null +++ b/music.js @@ -0,0 +1,38 @@ +//AIzaSyD7ZRm5CCh-LU2YsrnhCc6ulIRb62m8gGY +const Discord = require('discord.js'); +const Music = require('discord.js-musicbot-addon'); +const client = new Discord.Client(); //replace client with what you want your Discord Client to be. +const settings = require('./musicsettings.json'); //Load the token, prefix, and other info from a JSON file. + +client.on('ready', () => { + console.log(`[Start] ${new Date()}`); +}); + +// A random, empty map. +// This will contain the data for the prefixs. +// Note this has to be a map. +var mapper = new Map(); +// A valid set of data needs an id and prefix in the object. +let mprop = { + id: "387727240047230976", + prefix: "click" +} +// Set the data into the map. +// Change be changed latter with the set command. +mapper.set('387727240047230976', mprop); + +Music.start(client, { + youtubeKey: "AIzaSyD7ZRm5CCh-LU2YsrnhCc6ulIRb62m8gGY", // The youtube api key. + prefix: settings.prefix, // Prefix for the commands. Will be used for deafult prefix's for servers. + botAdmins: ["275147928249827338"], // List of ID's for admins (bypasses all permissions). // Prefix for the commands. + global: true, // Non-server-specific queues. + maxQueueSize: 25, // Maximum queue size of 25. + clearInvoker: true, // If permissions applicable, allow the bot to delete the messages that invoke it. + helpCmd: 'mhelp', // Sets the name for the help command. + playCmd: 'moon music play', // Sets the name for the 'play' command. + volumeCmd: 'moon music volume', // Sets the name for the 'volume' command. + leaveCmd: 'moon music leave', // Sets the name for the 'leave' command. + disableLoop: true // Disable the loop command. + }); + +client.login(musicsettings.token); \ No newline at end of file diff --git a/node_modules/.bin/base64url b/node_modules/.bin/base64url new file mode 100644 index 0000000..2dea2e5 --- /dev/null +++ b/node_modules/.bin/base64url @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../base64url/bin/base64url" "$@" + ret=$? +else + node "$basedir/../base64url/bin/base64url" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/base64url.cmd b/node_modules/.bin/base64url.cmd new file mode 100644 index 0000000..c36f7b9 --- /dev/null +++ b/node_modules/.bin/base64url.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\base64url\bin\base64url" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\base64url\bin\base64url" %* +) \ No newline at end of file diff --git a/node_modules/.bin/gp12-pem b/node_modules/.bin/gp12-pem new file mode 100644 index 0000000..d917364 --- /dev/null +++ b/node_modules/.bin/gp12-pem @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../google-p12-pem/bin/gp12-pem" "$@" + ret=$? +else + node "$basedir/../google-p12-pem/bin/gp12-pem" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/gp12-pem.cmd b/node_modules/.bin/gp12-pem.cmd new file mode 100644 index 0000000..841f5d1 --- /dev/null +++ b/node_modules/.bin/gp12-pem.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\google-p12-pem\bin\gp12-pem" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\google-p12-pem\bin\gp12-pem" %* +) \ No newline at end of file diff --git a/node_modules/.bin/indent-string b/node_modules/.bin/indent-string new file mode 100644 index 0000000..3b48959 --- /dev/null +++ b/node_modules/.bin/indent-string @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../indent-string/cli.js" "$@" + ret=$? +else + node "$basedir/../indent-string/cli.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/indent-string.cmd b/node_modules/.bin/indent-string.cmd new file mode 100644 index 0000000..cfb1650 --- /dev/null +++ b/node_modules/.bin/indent-string.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\indent-string\cli.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\indent-string\cli.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/repeating b/node_modules/.bin/repeating new file mode 100644 index 0000000..6eedc68 --- /dev/null +++ b/node_modules/.bin/repeating @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../repeating/cli.js" "$@" + ret=$? +else + node "$basedir/../repeating/cli.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/repeating.cmd b/node_modules/.bin/repeating.cmd new file mode 100644 index 0000000..a53acf7 --- /dev/null +++ b/node_modules/.bin/repeating.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\repeating\cli.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\repeating\cli.js" %* +) \ No newline at end of file diff --git a/node_modules/ansi-regex/index.js b/node_modules/ansi-regex/index.js new file mode 100644 index 0000000..b9574ed --- /dev/null +++ b/node_modules/ansi-regex/index.js @@ -0,0 +1,4 @@ +'use strict'; +module.exports = function () { + return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g; +}; diff --git a/node_modules/ansi-regex/license b/node_modules/ansi-regex/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/node_modules/ansi-regex/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/ansi-regex/package.json b/node_modules/ansi-regex/package.json new file mode 100644 index 0000000..d736c37 --- /dev/null +++ b/node_modules/ansi-regex/package.json @@ -0,0 +1,109 @@ +{ + "_from": "ansi-regex@^2.0.0", + "_id": "ansi-regex@2.1.1", + "_inBundle": false, + "_integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "_location": "/ansi-regex", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "ansi-regex@^2.0.0", + "name": "ansi-regex", + "escapedName": "ansi-regex", + "rawSpec": "^2.0.0", + "saveSpec": null, + "fetchSpec": "^2.0.0" + }, + "_requiredBy": [ + "/has-ansi", + "/strip-ansi" + ], + "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "_shasum": "c3b33ab5ee360d86e0e628f0468ae7ef27d654df", + "_spec": "ansi-regex@^2.0.0", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\has-ansi", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/chalk/ansi-regex/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Regular expression for matching ANSI escape codes", + "devDependencies": { + "ava": "0.17.0", + "xo": "0.16.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/chalk/ansi-regex#readme", + "keywords": [ + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "string", + "tty", + "escape", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "command-line", + "text", + "regex", + "regexp", + "re", + "match", + "test", + "find", + "pattern" + ], + "license": "MIT", + "maintainers": [ + { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + { + "name": "Joshua Appelman", + "email": "jappelman@xebia.com", + "url": "jbnicolai.com" + }, + { + "name": "JD Ballard", + "email": "i.am.qix@gmail.com", + "url": "github.com/qix-" + } + ], + "name": "ansi-regex", + "repository": { + "type": "git", + "url": "git+https://github.com/chalk/ansi-regex.git" + }, + "scripts": { + "test": "xo && ava --verbose", + "view-supported": "node fixtures/view-codes.js" + }, + "version": "2.1.1", + "xo": { + "rules": { + "guard-for-in": 0, + "no-loop-func": 0 + } + } +} diff --git a/node_modules/ansi-regex/readme.md b/node_modules/ansi-regex/readme.md new file mode 100644 index 0000000..6a928ed --- /dev/null +++ b/node_modules/ansi-regex/readme.md @@ -0,0 +1,39 @@ +# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex) + +> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install --save ansi-regex +``` + + +## Usage + +```js +const ansiRegex = require('ansi-regex'); + +ansiRegex().test('\u001b[4mcake\u001b[0m'); +//=> true + +ansiRegex().test('cake'); +//=> false + +'\u001b[4mcake\u001b[0m'.match(ansiRegex()); +//=> ['\u001b[4m', '\u001b[0m'] +``` + +## FAQ + +### Why do you test for codes not in the ECMA 48 standard? + +Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. If I recall correctly, we test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them. + +On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/axios/CHANGELOG.md b/node_modules/axios/CHANGELOG.md new file mode 100644 index 0000000..d336ec1 --- /dev/null +++ b/node_modules/axios/CHANGELOG.md @@ -0,0 +1,245 @@ +# Changelog + +### 0.18.0 (Feb 19, 2018) + +- Adding support for UNIX Sockets when running with Node.js ([#1070](https://github.com/axios/axios/pull/1070)) +- Fixing typings ([#1177](https://github.com/axios/axios/pull/1177)): + - AxiosRequestConfig.proxy: allows type false + - AxiosProxyConfig: added auth field +- Adding function signature in AxiosInstance interface so AxiosInstance can be invoked ([#1192](https://github.com/axios/axios/pull/1192), [#1254](https://github.com/axios/axios/pull/1254)) +- Allowing maxContentLength to pass through to redirected calls as maxBodyLength in follow-redirects config ([#1287](https://github.com/axios/axios/pull/1287)) +- Fixing configuration when using an instance - method can now be set ([#1342](https://github.com/axios/axios/pull/1342)) + + +### 0.17.1 (Nov 11, 2017) + +- Fixing issue with web workers ([#1160](https://github.com/axios/axios/pull/1160)) +- Allowing overriding transport ([#1080](https://github.com/axios/axios/pull/1080)) +- Updating TypeScript typings ([#1165](https://github.com/axios/axios/pull/1165), [#1125](https://github.com/axios/axios/pull/1125), [#1131](https://github.com/axios/axios/pull/1131)) + +### 0.17.0 (Oct 21, 2017) + +- **BREAKING** Fixing issue with `baseURL` and interceptors ([#950](https://github.com/axios/axios/pull/950)) +- **BREAKING** Improving handing of duplicate headers ([#874](https://github.com/axios/axios/pull/874)) +- Adding support for disabling proxies ([#691](https://github.com/axios/axios/pull/691)) +- Updating TypeScript typings with generic type parameters ([#1061](https://github.com/axios/axios/pull/1061)) + +### 0.16.2 (Jun 3, 2017) + +- Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887)) +- Including underlying request in errors ([#830](https://github.com/axios/axios/pull/830)) +- Convert `method` to lowercase ([#930](https://github.com/axios/axios/pull/930)) + +### 0.16.1 (Apr 8, 2017) + +- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/axios/axios/pull/828)) +- Updating `follow-redirects` dependency ([#829](https://github.com/axios/axios/pull/829)) +- Adding support for passing `Buffer` in node ([#773](https://github.com/axios/axios/pull/773)) + +### 0.16.0 (Mar 31, 2017) + +- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/axios/axios/issues/480)) +- Adding `options` shortcut method ([#461](https://github.com/axios/axios/pull/461)) +- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/axios/axios/pull/654)) +- Improving React Native detection ([#731](https://github.com/axios/axios/pull/731)) +- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/axios/axios/pull/581)) +- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/axios/axios/pull/561)) + +### 0.15.3 (Nov 27, 2016) + +- Fixing issue with custom instances and global defaults ([#443](https://github.com/axios/axios/issues/443)) +- Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/axios/axios/issues/519)) +- Adding `get`, `head`, and `delete` to `defaults.headers` ([#509](https://github.com/axios/axios/issues/509)) +- Fixing issue with `btoa` and IE ([#507](https://github.com/axios/axios/issues/507)) +- Adding support for proxy authentication ([#483](https://github.com/axios/axios/pull/483)) +- Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/axios/axios/pull/493)) +- Fixing proxy issues ([#491](https://github.com/axios/axios/pull/491)) + +### 0.15.2 (Oct 17, 2016) + +- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/axios/axios/issues/482)) + +### 0.15.1 (Oct 14, 2016) + +- Fixing issue with UMD ([#485](https://github.com/axios/axios/issues/485)) + +### 0.15.0 (Oct 10, 2016) + +- Adding cancellation support ([#452](https://github.com/axios/axios/pull/452)) +- Moving default adapter to global defaults ([#437](https://github.com/axios/axios/pull/437)) +- Fixing issue with `file` URI scheme ([#440](https://github.com/axios/axios/pull/440)) +- Fixing issue with `params` objects that have no prototype ([#445](https://github.com/axios/axios/pull/445)) + +### 0.14.0 (Aug 27, 2016) + +- **BREAKING** Updating TypeScript definitions ([#419](https://github.com/axios/axios/pull/419)) +- **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/axios/axios/pull/387)) +- **BREAKING** Splitting `progress` event handlers into `onUploadProgress` and `onDownloadProgress` ([#423](https://github.com/axios/axios/pull/423)) +- Adding support for `http_proxy` and `https_proxy` environment variables ([#366](https://github.com/axios/axios/pull/366)) +- Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/axios/axios/pull/397)) +- Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/axios/axios/pull/406)) + +### 0.13.1 (Jul 16, 2016) + +- Fixing issue with response data not being transformed on error ([#378](https://github.com/axios/axios/issues/378)) + +### 0.13.0 (Jul 13, 2016) + +- **BREAKING** Improved error handling ([#345](https://github.com/axios/axios/pull/345)) +- **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)) +- **BREAKING** Request adapters now return a `Promise` ([157efd5](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)) +- Fixing issue with `withCredentials` not being overwritten ([#343](https://github.com/axios/axios/issues/343)) +- Fixing regression with request transformer being called before request interceptor ([#352](https://github.com/axios/axios/issues/352)) +- Fixing custom instance defaults ([#341](https://github.com/axios/axios/issues/341)) +- Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/axios/axios/issues/217)) + +### 0.12.0 (May 31, 2016) + +- Adding support for `URLSearchParams` ([#317](https://github.com/axios/axios/pull/317)) +- Adding `maxRedirects` option ([#307](https://github.com/axios/axios/pull/307)) + +### 0.11.1 (May 17, 2016) + +- Fixing IE CORS support ([#313](https://github.com/axios/axios/pull/313)) +- Fixing detection of `FormData` ([#325](https://github.com/axios/axios/pull/325)) +- Adding `Axios` class to exports ([#321](https://github.com/axios/axios/pull/321)) + +### 0.11.0 (Apr 26, 2016) + +- Adding support for Stream with HTTP adapter ([#296](https://github.com/axios/axios/pull/296)) +- Adding support for custom HTTP status code error ranges ([#308](https://github.com/axios/axios/pull/308)) +- Fixing issue with ArrayBuffer ([#299](https://github.com/axios/axios/pull/299)) + +### 0.10.0 (Apr 20, 2016) + +- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/axios/axios/pull/250)) +- Fixing basic auth for HTTP adapter ([#252](https://github.com/axios/axios/pull/252)) +- Fixing request timeout for XHR adapter ([#227](https://github.com/axios/axios/pull/227)) +- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/axios/axios/pull/249)) +- Fixing IE9 cross domain requests ([#251](https://github.com/axios/axios/pull/251)) +- Adding `maxContentLength` option ([#275](https://github.com/axios/axios/pull/275)) +- Fixing XHR support for WebWorker environment ([#279](https://github.com/axios/axios/pull/279)) +- Adding request instance to response ([#200](https://github.com/axios/axios/pull/200)) + +### 0.9.1 (Jan 24, 2016) + +- Improving handling of request timeout in node ([#124](https://github.com/axios/axios/issues/124)) +- Fixing network errors not rejecting ([#205](https://github.com/axios/axios/pull/205)) +- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/axios/axios/issues/201)) +- Fixing host/port when following redirects ([#198](https://github.com/axios/axios/pull/198)) + +### 0.9.0 (Jan 18, 2016) + +- Adding support for custom adapters +- Fixing Content-Type header being removed when data is false ([#195](https://github.com/axios/axios/pull/195)) +- Improving XDomainRequest implementation ([#185](https://github.com/axios/axios/pull/185)) +- Improving config merging and order of precedence ([#183](https://github.com/axios/axios/pull/183)) +- Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/axios/axios/pull/182)) + +### 0.8.1 (Dec 14, 2015) + +- Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/axios/axios/pull/168)) +- Fixing error with format of basic auth header ([#178](https://github.com/axios/axios/pull/173)) +- Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/axios/axios/pull/174)) + +### 0.8.0 (Dec 11, 2015) + +- Adding support for creating instances of axios ([#123](https://github.com/axios/axios/pull/123)) +- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/axios/axios/pull/128)) +- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/axios/axios/pull/121)) +- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/axios/axios/pull/127)) +- Adding support for following redirects in node ([#146](https://github.com/axios/axios/pull/146)) +- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/axios/axios/pull/149)) +- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/axios/axios/pull/140)) +- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/axios/axios/pull/167)) +- Adding support for baseURL option ([#160](https://github.com/axios/axios/pull/160)) + +### 0.7.0 (Sep 29, 2015) + +- Fixing issue with minified bundle in IE8 ([#87](https://github.com/axios/axios/pull/87)) +- Adding support for passing agent in node ([#102](https://github.com/axios/axios/pull/102)) +- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/axios/axios/pull/106)) +- Fixing typescript definition ([#105](https://github.com/axios/axios/pull/105)) +- Fixing default timeout config for node ([#112](https://github.com/axios/axios/pull/112)) +- Adding support for use in web workers, and react-native ([#70](https://github.com/axios/axios/issue/70)), ([#98](https://github.com/axios/axios/pull/98)) +- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/axios/axios/issues/116)) + +### 0.6.0 (Sep 21, 2015) + +- Removing deprecated success/error aliases +- Fixing issue with array params not being properly encoded ([#49](https://github.com/axios/axios/pull/49)) +- Fixing issue with User-Agent getting overridden ([#69](https://github.com/axios/axios/issues/69)) +- Adding support for timeout config ([#56](https://github.com/axios/axios/issues/56)) +- Removing es6-promise dependency +- Fixing issue preventing `length` to be used as a parameter ([#91](https://github.com/axios/axios/pull/91)) +- Fixing issue with IE8 ([#85](https://github.com/axios/axios/pull/85)) +- Converting build to UMD + +### 0.5.4 (Apr 08, 2015) + +- Fixing issue with FormData not being sent ([#53](https://github.com/axios/axios/issues/53)) + +### 0.5.3 (Apr 07, 2015) + +- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/axios/axios/issues/55)) + +### 0.5.2 (Mar 13, 2015) + +- Adding support for `statusText` in response ([#46](https://github.com/axios/axios/issues/46)) + +### 0.5.1 (Mar 10, 2015) + +- Fixing issue using strict mode ([#45](https://github.com/axios/axios/issues/45)) +- Fixing issue with standalone build ([#47](https://github.com/axios/axios/issues/47)) + +### 0.5.0 (Jan 23, 2015) + +- Adding support for intercepetors ([#14](https://github.com/axios/axios/issues/14)) +- Updating es6-promise dependency + +### 0.4.2 (Dec 10, 2014) + +- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/axios/axios/issues/22)) +- Adding support for TypeScript ([#25](https://github.com/axios/axios/issues/25)) +- Fixing issue with standalone build ([#29](https://github.com/axios/axios/issues/29)) +- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/axios/axios/issues/30)) + +### 0.4.1 (Oct 15, 2014) + +- Adding error handling to request for node.js ([#18](https://github.com/axios/axios/issues/18)) + +### 0.4.0 (Oct 03, 2014) + +- Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/axios/axios/issues/10)) +- Adding support for utf-8 for node.js ([#13](https://github.com/axios/axios/issues/13)) +- Adding support for SSL for node.js ([#12](https://github.com/axios/axios/issues/12)) +- Fixing incorrect `Content-Type` header ([#9](https://github.com/axios/axios/issues/9)) +- Adding standalone build without bundled es6-promise ([#11](https://github.com/axios/axios/issues/11)) +- Deprecating `success`/`error` in favor of `then`/`catch` + +### 0.3.1 (Sep 16, 2014) + +- Fixing missing post body when using node.js ([#3](https://github.com/axios/axios/issues/3)) + +### 0.3.0 (Sep 16, 2014) + +- Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/axios/axios/issues/8)) +- Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/axios/axios/issues/6)) +- Fixing issue with `all` not working ([#7](https://github.com/axios/axios/issues/7)) + +### 0.2.2 (Sep 14, 2014) + +- Fixing bundling with browserify ([#4](https://github.com/axios/axios/issues/4)) + +### 0.2.1 (Sep 12, 2014) + +- Fixing build problem causing ridiculous file sizes + +### 0.2.0 (Sep 12, 2014) + +- Adding support for `all` and `spread` +- Adding support for node.js ([#1](https://github.com/axios/axios/issues/1)) + +### 0.1.0 (Aug 29, 2014) + +- Initial release diff --git a/node_modules/axios/LICENSE b/node_modules/axios/LICENSE new file mode 100644 index 0000000..d36c80e --- /dev/null +++ b/node_modules/axios/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014-present Matt Zabriskie + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/axios/README.md b/node_modules/axios/README.md new file mode 100644 index 0000000..ec78817 --- /dev/null +++ b/node_modules/axios/README.md @@ -0,0 +1,625 @@ +# axios + +[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios) +[![build status](https://img.shields.io/travis/axios/axios.svg?style=flat-square)](https://travis-ci.org/axios/axios) +[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios) +[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios) +[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios) +[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios) + +Promise based HTTP client for the browser and node.js + +## Features + +- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser +- Make [http](http://nodejs.org/api/http.html) requests from node.js +- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API +- Intercept request and response +- Transform request and response data +- Cancel requests +- Automatic transforms for JSON data +- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) + +## Browser Support + +![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | +--- | --- | --- | --- | --- | --- | +Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ | + +[![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios) + +## Installing + +Using npm: + +```bash +$ npm install axios +``` + +Using bower: + +```bash +$ bower install axios +``` + +Using cdn: + +```html + +``` + +## Example + +Performing a `GET` request + +```js +// Make a request for a user with a given ID +axios.get('/user?ID=12345') + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }); + +// Optionally the request above could also be done as +axios.get('/user', { + params: { + ID: 12345 + } + }) + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }); +``` + +Performing a `POST` request + +```js +axios.post('/user', { + firstName: 'Fred', + lastName: 'Flintstone' + }) + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }); +``` + +Performing multiple concurrent requests + +```js +function getUserAccount() { + return axios.get('/user/12345'); +} + +function getUserPermissions() { + return axios.get('/user/12345/permissions'); +} + +axios.all([getUserAccount(), getUserPermissions()]) + .then(axios.spread(function (acct, perms) { + // Both requests are now complete + })); +``` + +## axios API + +Requests can be made by passing the relevant config to `axios`. + +##### axios(config) + +```js +// Send a POST request +axios({ + method: 'post', + url: '/user/12345', + data: { + firstName: 'Fred', + lastName: 'Flintstone' + } +}); +``` + +```js +// GET request for remote image +axios({ + method:'get', + url:'http://bit.ly/2mTM3nY', + responseType:'stream' +}) + .then(function(response) { + response.data.pipe(fs.createWriteStream('ada_lovelace.jpg')) +}); +``` + +##### axios(url[, config]) + +```js +// Send a GET request (default method) +axios('/user/12345'); +``` + +### Request method aliases + +For convenience aliases have been provided for all supported request methods. + +##### axios.request(config) +##### axios.get(url[, config]) +##### axios.delete(url[, config]) +##### axios.head(url[, config]) +##### axios.options(url[, config]) +##### axios.post(url[, data[, config]]) +##### axios.put(url[, data[, config]]) +##### axios.patch(url[, data[, config]]) + +###### NOTE +When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config. + +### Concurrency + +Helper functions for dealing with concurrent requests. + +##### axios.all(iterable) +##### axios.spread(callback) + +### Creating an instance + +You can create a new instance of axios with a custom config. + +##### axios.create([config]) + +```js +var instance = axios.create({ + baseURL: 'https://some-domain.com/api/', + timeout: 1000, + headers: {'X-Custom-Header': 'foobar'} +}); +``` + +### Instance methods + +The available instance methods are listed below. The specified config will be merged with the instance config. + +##### axios#request(config) +##### axios#get(url[, config]) +##### axios#delete(url[, config]) +##### axios#head(url[, config]) +##### axios#options(url[, config]) +##### axios#post(url[, data[, config]]) +##### axios#put(url[, data[, config]]) +##### axios#patch(url[, data[, config]]) + +## Request Config + +These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified. + +```js +{ + // `url` is the server URL that will be used for the request + url: '/user', + + // `method` is the request method to be used when making the request + method: 'get', // default + + // `baseURL` will be prepended to `url` unless `url` is absolute. + // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs + // to methods of that instance. + baseURL: 'https://some-domain.com/api/', + + // `transformRequest` allows changes to the request data before it is sent to the server + // This is only applicable for request methods 'PUT', 'POST', and 'PATCH' + // The last function in the array must return a string or an instance of Buffer, ArrayBuffer, + // FormData or Stream + // You may modify the headers object. + transformRequest: [function (data, headers) { + // Do whatever you want to transform the data + + return data; + }], + + // `transformResponse` allows changes to the response data to be made before + // it is passed to then/catch + transformResponse: [function (data) { + // Do whatever you want to transform the data + + return data; + }], + + // `headers` are custom headers to be sent + headers: {'X-Requested-With': 'XMLHttpRequest'}, + + // `params` are the URL parameters to be sent with the request + // Must be a plain object or a URLSearchParams object + params: { + ID: 12345 + }, + + // `paramsSerializer` is an optional function in charge of serializing `params` + // (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/) + paramsSerializer: function(params) { + return Qs.stringify(params, {arrayFormat: 'brackets'}) + }, + + // `data` is the data to be sent as the request body + // Only applicable for request methods 'PUT', 'POST', and 'PATCH' + // When no `transformRequest` is set, must be of one of the following types: + // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams + // - Browser only: FormData, File, Blob + // - Node only: Stream, Buffer + data: { + firstName: 'Fred' + }, + + // `timeout` specifies the number of milliseconds before the request times out. + // If the request takes longer than `timeout`, the request will be aborted. + timeout: 1000, + + // `withCredentials` indicates whether or not cross-site Access-Control requests + // should be made using credentials + withCredentials: false, // default + + // `adapter` allows custom handling of requests which makes testing easier. + // Return a promise and supply a valid response (see lib/adapters/README.md). + adapter: function (config) { + /* ... */ + }, + + // `auth` indicates that HTTP Basic auth should be used, and supplies credentials. + // This will set an `Authorization` header, overwriting any existing + // `Authorization` custom headers you have set using `headers`. + auth: { + username: 'janedoe', + password: 's00pers3cret' + }, + + // `responseType` indicates the type of data that the server will respond with + // options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream' + responseType: 'json', // default + + // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token + xsrfCookieName: 'XSRF-TOKEN', // default + + // `xsrfHeaderName` is the name of the http header that carries the xsrf token value + xsrfHeaderName: 'X-XSRF-TOKEN', // default + + // `onUploadProgress` allows handling of progress events for uploads + onUploadProgress: function (progressEvent) { + // Do whatever you want with the native progress event + }, + + // `onDownloadProgress` allows handling of progress events for downloads + onDownloadProgress: function (progressEvent) { + // Do whatever you want with the native progress event + }, + + // `maxContentLength` defines the max size of the http response content allowed + maxContentLength: 2000, + + // `validateStatus` defines whether to resolve or reject the promise for a given + // HTTP response status code. If `validateStatus` returns `true` (or is set to `null` + // or `undefined`), the promise will be resolved; otherwise, the promise will be + // rejected. + validateStatus: function (status) { + return status >= 200 && status < 300; // default + }, + + // `maxRedirects` defines the maximum number of redirects to follow in node.js. + // If set to 0, no redirects will be followed. + maxRedirects: 5, // default + + // `socketPath` defines a UNIX Socket to be used in node.js. + // e.g. '/var/run/docker.sock' to send requests to the docker daemon. + // Only either `socketPath` or `proxy` can be specified. + // If both are specified, `socketPath` is used. + socketPath: null, // default + + // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http + // and https requests, respectively, in node.js. This allows options to be added like + // `keepAlive` that are not enabled by default. + httpAgent: new http.Agent({ keepAlive: true }), + httpsAgent: new https.Agent({ keepAlive: true }), + + // 'proxy' defines the hostname and port of the proxy server + // Use `false` to disable proxies, ignoring environment variables. + // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and + // supplies credentials. + // This will set an `Proxy-Authorization` header, overwriting any existing + // `Proxy-Authorization` custom headers you have set using `headers`. + proxy: { + host: '127.0.0.1', + port: 9000, + auth: { + username: 'mikeymike', + password: 'rapunz3l' + } + }, + + // `cancelToken` specifies a cancel token that can be used to cancel the request + // (see Cancellation section below for details) + cancelToken: new CancelToken(function (cancel) { + }) +} +``` + +## Response Schema + +The response for a request contains the following information. + +```js +{ + // `data` is the response that was provided by the server + data: {}, + + // `status` is the HTTP status code from the server response + status: 200, + + // `statusText` is the HTTP status message from the server response + statusText: 'OK', + + // `headers` the headers that the server responded with + // All header names are lower cased + headers: {}, + + // `config` is the config that was provided to `axios` for the request + config: {}, + + // `request` is the request that generated this response + // It is the last ClientRequest instance in node.js (in redirects) + // and an XMLHttpRequest instance the browser + request: {} +} +``` + +When using `then`, you will receive the response as follows: + +```js +axios.get('/user/12345') + .then(function(response) { + console.log(response.data); + console.log(response.status); + console.log(response.statusText); + console.log(response.headers); + console.log(response.config); + }); +``` + +When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as second parameter of `then`, the response will be available through the `error` object as explained in the [Handling Errors](#handling-errors) section. + +## Config Defaults + +You can specify config defaults that will be applied to every request. + +### Global axios defaults + +```js +axios.defaults.baseURL = 'https://api.example.com'; +axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; +axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; +``` + +### Custom instance defaults + +```js +// Set config defaults when creating the instance +var instance = axios.create({ + baseURL: 'https://api.example.com' +}); + +// Alter defaults after instance has been created +instance.defaults.headers.common['Authorization'] = AUTH_TOKEN; +``` + +### Config order of precedence + +Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. + +```js +// Create an instance using the config defaults provided by the library +// At this point the timeout config value is `0` as is the default for the library +var instance = axios.create(); + +// Override timeout default for the library +// Now all requests will wait 2.5 seconds before timing out +instance.defaults.timeout = 2500; + +// Override timeout for this request as it's known to take a long time +instance.get('/longRequest', { + timeout: 5000 +}); +``` + +## Interceptors + +You can intercept requests or responses before they are handled by `then` or `catch`. + +```js +// Add a request interceptor +axios.interceptors.request.use(function (config) { + // Do something before request is sent + return config; + }, function (error) { + // Do something with request error + return Promise.reject(error); + }); + +// Add a response interceptor +axios.interceptors.response.use(function (response) { + // Do something with response data + return response; + }, function (error) { + // Do something with response error + return Promise.reject(error); + }); +``` + +If you may need to remove an interceptor later you can. + +```js +var myInterceptor = axios.interceptors.request.use(function () {/*...*/}); +axios.interceptors.request.eject(myInterceptor); +``` + +You can add interceptors to a custom instance of axios. + +```js +var instance = axios.create(); +instance.interceptors.request.use(function () {/*...*/}); +``` + +## Handling Errors + +```js +axios.get('/user/12345') + .catch(function (error) { + if (error.response) { + // The request was made and the server responded with a status code + // that falls out of the range of 2xx + console.log(error.response.data); + console.log(error.response.status); + console.log(error.response.headers); + } else if (error.request) { + // The request was made but no response was received + // `error.request` is an instance of XMLHttpRequest in the browser and an instance of + // http.ClientRequest in node.js + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + console.log('Error', error.message); + } + console.log(error.config); + }); +``` + +You can define a custom HTTP status code error range using the `validateStatus` config option. + +```js +axios.get('/user/12345', { + validateStatus: function (status) { + return status < 500; // Reject only if the status code is greater than or equal to 500 + } +}) +``` + +## Cancellation + +You can cancel a request using a *cancel token*. + +> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises). + +You can create a cancel token using the `CancelToken.source` factory as shown below: + +```js +var CancelToken = axios.CancelToken; +var source = CancelToken.source(); + +axios.get('/user/12345', { + cancelToken: source.token +}).catch(function(thrown) { + if (axios.isCancel(thrown)) { + console.log('Request canceled', thrown.message); + } else { + // handle error + } +}); + +axios.post('/user/12345', { + name: 'new name' +}, { + cancelToken: source.token +}) + +// cancel the request (the message parameter is optional) +source.cancel('Operation canceled by the user.'); +``` + +You can also create a cancel token by passing an executor function to the `CancelToken` constructor: + +```js +var CancelToken = axios.CancelToken; +var cancel; + +axios.get('/user/12345', { + cancelToken: new CancelToken(function executor(c) { + // An executor function receives a cancel function as a parameter + cancel = c; + }) +}); + +// cancel the request +cancel(); +``` + +> Note: you can cancel several requests with the same cancel token. + +## Using application/x-www-form-urlencoded format + +By default, axios serializes JavaScript objects to `JSON`. To send data in the `application/x-www-form-urlencoded` format instead, you can use one of the following options. + +### Browser + +In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows: + +```js +var params = new URLSearchParams(); +params.append('param1', 'value1'); +params.append('param2', 'value2'); +axios.post('/foo', params); +``` + +> Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). + +Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library: + +```js +var qs = require('qs'); +axios.post('/foo', qs.stringify({ 'bar': 123 })); +``` + +### Node.js + +In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: + +```js +var querystring = require('querystring'); +axios.post('http://something.com/', querystring.stringify({ foo: 'bar' })); +``` + +You can also use the [`qs`](https://github.com/ljharb/qs) library. + +## Semver + +Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes. + +## Promises + +axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises). +If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise). + +## TypeScript +axios includes [TypeScript](http://typescriptlang.org) definitions. +```typescript +import axios from 'axios'; +axios.get('/user?ID=12345'); +``` + +## Resources + +* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) +* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md) +* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) +* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md) +* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md) + +## Credits + +axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. + +## License + +MIT diff --git a/node_modules/axios/UPGRADE_GUIDE.md b/node_modules/axios/UPGRADE_GUIDE.md new file mode 100644 index 0000000..eedb049 --- /dev/null +++ b/node_modules/axios/UPGRADE_GUIDE.md @@ -0,0 +1,162 @@ +# Upgrade Guide + +### 0.15.x -> 0.16.0 + +#### `Promise` Type Declarations + +The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details. + +### 0.13.x -> 0.14.0 + +#### TypeScript Definitions + +The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax. + +Please use the following `import` statement to import axios in TypeScript: + +```typescript +import axios from 'axios'; + +axios.get('/foo') + .then(response => console.log(response)) + .catch(error => console.log(error)); +``` + +#### `agent` Config Option + +The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead. + +```js +{ + // Define a custom agent for HTTP + httpAgent: new http.Agent({ keepAlive: true }), + // Define a custom agent for HTTPS + httpsAgent: new https.Agent({ keepAlive: true }) +} +``` + +#### `progress` Config Option + +The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options. + +```js +{ + // Define a handler for upload progress events + onUploadProgress: function (progressEvent) { + // ... + }, + + // Define a handler for download progress events + onDownloadProgress: function (progressEvent) { + // ... + } +} +``` + +### 0.12.x -> 0.13.0 + +The `0.13.0` release contains several changes to custom adapters and error handling. + +#### Error Handling + +Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response. + +```js +axios.get('/user/12345') + .catch((error) => { + console.log(error.message); + console.log(error.code); // Not always specified + console.log(error.config); // The config that was used to make the request + console.log(error.response); // Only available if response was received from the server + }); +``` + +#### Request Adapters + +This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter. + +1. Response transformer is now called outside of adapter. +2. Request adapter returns a `Promise`. + +This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter. + +Previous code: + +```js +function myAdapter(resolve, reject, config) { + var response = { + data: transformData( + responseData, + responseHeaders, + config.transformResponse + ), + status: request.status, + statusText: request.statusText, + headers: responseHeaders + }; + settle(resolve, reject, response); +} +``` + +New code: + +```js +function myAdapter(config) { + return new Promise(function (resolve, reject) { + var response = { + data: responseData, + status: request.status, + statusText: request.statusText, + headers: responseHeaders + }; + settle(resolve, reject, response); + }); +} +``` + +See the related commits for more details: +- [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) +- [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) + +### 0.5.x -> 0.6.0 + +The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading. + +#### ES6 Promise Polyfill + +Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it. + +```js +require('es6-promise').polyfill(); +var axios = require('axios'); +``` + +This will polyfill the global environment, and only needs to be done once. + +#### `axios.success`/`axios.error` + +The `success`, and `error` aliases were deprectated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. + +```js +axios.get('some/url') + .then(function (res) { + /* ... */ + }) + .catch(function (err) { + /* ... */ + }); +``` + +#### UMD + +Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build. + +```js +// AMD +require(['bower_components/axios/dist/axios'], function (axios) { + /* ... */ +}); + +// CommonJS +var axios = require('axios/dist/axios'); +``` diff --git a/node_modules/axios/dist/axios.js b/node_modules/axios/dist/axios.js new file mode 100644 index 0000000..cf8b39d --- /dev/null +++ b/node_modules/axios/dist/axios.js @@ -0,0 +1,1603 @@ +/* axios v0.18.0 | (c) 2018 by Matt Zabriskie */ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["axios"] = factory(); + else + root["axios"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(1); + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var bind = __webpack_require__(3); + var Axios = __webpack_require__(5); + var defaults = __webpack_require__(6); + + /** + * Create an instance of Axios + * + * @param {Object} defaultConfig The default config for the instance + * @return {Axios} A new instance of Axios + */ + function createInstance(defaultConfig) { + var context = new Axios(defaultConfig); + var instance = bind(Axios.prototype.request, context); + + // Copy axios.prototype to instance + utils.extend(instance, Axios.prototype, context); + + // Copy context to instance + utils.extend(instance, context); + + return instance; + } + + // Create the default instance to be exported + var axios = createInstance(defaults); + + // Expose Axios class to allow class inheritance + axios.Axios = Axios; + + // Factory for creating new instances + axios.create = function create(instanceConfig) { + return createInstance(utils.merge(defaults, instanceConfig)); + }; + + // Expose Cancel & CancelToken + axios.Cancel = __webpack_require__(23); + axios.CancelToken = __webpack_require__(24); + axios.isCancel = __webpack_require__(20); + + // Expose all/spread + axios.all = function all(promises) { + return Promise.all(promises); + }; + axios.spread = __webpack_require__(25); + + module.exports = axios; + + // Allow use of default import syntax in TypeScript + module.exports.default = axios; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var bind = __webpack_require__(3); + var isBuffer = __webpack_require__(4); + + /*global toString:true*/ + + // utils is a library of generic helper functions non-specific to axios + + var toString = Object.prototype.toString; + + /** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Array, otherwise false + */ + function isArray(val) { + return toString.call(val) === '[object Array]'; + } + + /** + * Determine if a value is an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an ArrayBuffer, otherwise false + */ + function isArrayBuffer(val) { + return toString.call(val) === '[object ArrayBuffer]'; + } + + /** + * Determine if a value is a FormData + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an FormData, otherwise false + */ + function isFormData(val) { + return (typeof FormData !== 'undefined') && (val instanceof FormData); + } + + /** + * Determine if a value is a view on an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false + */ + function isArrayBufferView(val) { + var result; + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { + result = ArrayBuffer.isView(val); + } else { + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); + } + return result; + } + + /** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a String, otherwise false + */ + function isString(val) { + return typeof val === 'string'; + } + + /** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Number, otherwise false + */ + function isNumber(val) { + return typeof val === 'number'; + } + + /** + * Determine if a value is undefined + * + * @param {Object} val The value to test + * @returns {boolean} True if the value is undefined, otherwise false + */ + function isUndefined(val) { + return typeof val === 'undefined'; + } + + /** + * Determine if a value is an Object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Object, otherwise false + */ + function isObject(val) { + return val !== null && typeof val === 'object'; + } + + /** + * Determine if a value is a Date + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Date, otherwise false + */ + function isDate(val) { + return toString.call(val) === '[object Date]'; + } + + /** + * Determine if a value is a File + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a File, otherwise false + */ + function isFile(val) { + return toString.call(val) === '[object File]'; + } + + /** + * Determine if a value is a Blob + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Blob, otherwise false + */ + function isBlob(val) { + return toString.call(val) === '[object Blob]'; + } + + /** + * Determine if a value is a Function + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Function, otherwise false + */ + function isFunction(val) { + return toString.call(val) === '[object Function]'; + } + + /** + * Determine if a value is a Stream + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Stream, otherwise false + */ + function isStream(val) { + return isObject(val) && isFunction(val.pipe); + } + + /** + * Determine if a value is a URLSearchParams object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a URLSearchParams object, otherwise false + */ + function isURLSearchParams(val) { + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; + } + + /** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * @returns {String} The String freed of excess whitespace + */ + function trim(str) { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); + } + + /** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + */ + function isStandardBrowserEnv() { + if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { + return false; + } + return ( + typeof window !== 'undefined' && + typeof document !== 'undefined' + ); + } + + /** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + */ + function forEach(obj, fn) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + // Force an array if not already something iterable + if (typeof obj !== 'object') { + /*eslint no-param-reassign:0*/ + obj = [obj]; + } + + if (isArray(obj)) { + // Iterate over array values + for (var i = 0, l = obj.length; i < l; i++) { + fn.call(null, obj[i], i, obj); + } + } else { + // Iterate over object keys + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + fn.call(null, obj[key], key, obj); + } + } + } + } + + /** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * Example: + * + * ```js + * var result = merge({foo: 123}, {foo: 456}); + * console.log(result.foo); // outputs 456 + * ``` + * + * @param {Object} obj1 Object to merge + * @returns {Object} Result of all merge properties + */ + function merge(/* obj1, obj2, obj3, ... */) { + var result = {}; + function assignValue(val, key) { + if (typeof result[key] === 'object' && typeof val === 'object') { + result[key] = merge(result[key], val); + } else { + result[key] = val; + } + } + + for (var i = 0, l = arguments.length; i < l; i++) { + forEach(arguments[i], assignValue); + } + return result; + } + + /** + * Extends object a by mutably adding to it the properties of object b. + * + * @param {Object} a The object to be extended + * @param {Object} b The object to copy properties from + * @param {Object} thisArg The object to bind function to + * @return {Object} The resulting value of object a + */ + function extend(a, b, thisArg) { + forEach(b, function assignValue(val, key) { + if (thisArg && typeof val === 'function') { + a[key] = bind(val, thisArg); + } else { + a[key] = val; + } + }); + return a; + } + + module.exports = { + isArray: isArray, + isArrayBuffer: isArrayBuffer, + isBuffer: isBuffer, + isFormData: isFormData, + isArrayBufferView: isArrayBufferView, + isString: isString, + isNumber: isNumber, + isObject: isObject, + isUndefined: isUndefined, + isDate: isDate, + isFile: isFile, + isBlob: isBlob, + isFunction: isFunction, + isStream: isStream, + isURLSearchParams: isURLSearchParams, + isStandardBrowserEnv: isStandardBrowserEnv, + forEach: forEach, + merge: merge, + extend: extend, + trim: trim + }; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + + 'use strict'; + + module.exports = function bind(fn, thisArg) { + return function wrap() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + return fn.apply(thisArg, args); + }; + }; + + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + + /*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT + */ + + // The _isBuffer check is for Safari 5-7 support, because it's missing + // Object.prototype.constructor. Remove this eventually + module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) + } + + function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) + } + + // For Node v0.10 support. Remove this eventually. + function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) + } + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var defaults = __webpack_require__(6); + var utils = __webpack_require__(2); + var InterceptorManager = __webpack_require__(17); + var dispatchRequest = __webpack_require__(18); + + /** + * Create a new instance of Axios + * + * @param {Object} instanceConfig The default config for the instance + */ + function Axios(instanceConfig) { + this.defaults = instanceConfig; + this.interceptors = { + request: new InterceptorManager(), + response: new InterceptorManager() + }; + } + + /** + * Dispatch a request + * + * @param {Object} config The config specific for this request (merged with this.defaults) + */ + Axios.prototype.request = function request(config) { + /*eslint no-param-reassign:0*/ + // Allow for axios('example/url'[, config]) a la fetch API + if (typeof config === 'string') { + config = utils.merge({ + url: arguments[0] + }, arguments[1]); + } + + config = utils.merge(defaults, {method: 'get'}, this.defaults, config); + config.method = config.method.toLowerCase(); + + // Hook up interceptors middleware + var chain = [dispatchRequest, undefined]; + var promise = Promise.resolve(config); + + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { + chain.unshift(interceptor.fulfilled, interceptor.rejected); + }); + + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { + chain.push(interceptor.fulfilled, interceptor.rejected); + }); + + while (chain.length) { + promise = promise.then(chain.shift(), chain.shift()); + } + + return promise; + }; + + // Provide aliases for supported request methods + utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, config) { + return this.request(utils.merge(config || {}, { + method: method, + url: url + })); + }; + }); + + utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, data, config) { + return this.request(utils.merge(config || {}, { + method: method, + url: url, + data: data + })); + }; + }); + + module.exports = Axios; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var normalizeHeaderName = __webpack_require__(7); + + var DEFAULT_CONTENT_TYPE = { + 'Content-Type': 'application/x-www-form-urlencoded' + }; + + function setContentTypeIfUnset(headers, value) { + if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { + headers['Content-Type'] = value; + } + } + + function getDefaultAdapter() { + var adapter; + if (typeof XMLHttpRequest !== 'undefined') { + // For browsers use XHR adapter + adapter = __webpack_require__(8); + } else if (typeof process !== 'undefined') { + // For node use HTTP adapter + adapter = __webpack_require__(8); + } + return adapter; + } + + var defaults = { + adapter: getDefaultAdapter(), + + transformRequest: [function transformRequest(data, headers) { + normalizeHeaderName(headers, 'Content-Type'); + if (utils.isFormData(data) || + utils.isArrayBuffer(data) || + utils.isBuffer(data) || + utils.isStream(data) || + utils.isFile(data) || + utils.isBlob(data) + ) { + return data; + } + if (utils.isArrayBufferView(data)) { + return data.buffer; + } + if (utils.isURLSearchParams(data)) { + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); + return data.toString(); + } + if (utils.isObject(data)) { + setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); + return JSON.stringify(data); + } + return data; + }], + + transformResponse: [function transformResponse(data) { + /*eslint no-param-reassign:0*/ + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { /* Ignore */ } + } + return data; + }], + + /** + * A timeout in milliseconds to abort a request. If set to 0 (default) a + * timeout is not created. + */ + timeout: 0, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + maxContentLength: -1, + + validateStatus: function validateStatus(status) { + return status >= 200 && status < 300; + } + }; + + defaults.headers = { + common: { + 'Accept': 'application/json, text/plain, */*' + } + }; + + utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { + defaults.headers[method] = {}; + }); + + utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); + }); + + module.exports = defaults; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + module.exports = function normalizeHeaderName(headers, normalizedName) { + utils.forEach(headers, function processHeader(value, name) { + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { + headers[normalizedName] = value; + delete headers[name]; + } + }); + }; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var settle = __webpack_require__(9); + var buildURL = __webpack_require__(12); + var parseHeaders = __webpack_require__(13); + var isURLSameOrigin = __webpack_require__(14); + var createError = __webpack_require__(10); + var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15); + + module.exports = function xhrAdapter(config) { + return new Promise(function dispatchXhrRequest(resolve, reject) { + var requestData = config.data; + var requestHeaders = config.headers; + + if (utils.isFormData(requestData)) { + delete requestHeaders['Content-Type']; // Let the browser set it + } + + var request = new XMLHttpRequest(); + var loadEvent = 'onreadystatechange'; + var xDomain = false; + + // For IE 8/9 CORS support + // Only supports POST and GET calls and doesn't returns the response headers. + // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest. + if (("production") !== 'test' && + typeof window !== 'undefined' && + window.XDomainRequest && !('withCredentials' in request) && + !isURLSameOrigin(config.url)) { + request = new window.XDomainRequest(); + loadEvent = 'onload'; + xDomain = true; + request.onprogress = function handleProgress() {}; + request.ontimeout = function handleTimeout() {}; + } + + // HTTP basic authentication + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password || ''; + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); + } + + request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true); + + // Set the request timeout in MS + request.timeout = config.timeout; + + // Listen for ready state + request[loadEvent] = function handleLoad() { + if (!request || (request.readyState !== 4 && !xDomain)) { + return; + } + + // The request errored out and we didn't get a response, this will be + // handled by onerror instead + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { + return; + } + + // Prepare the response + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; + var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; + var response = { + data: responseData, + // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201) + status: request.status === 1223 ? 204 : request.status, + statusText: request.status === 1223 ? 'No Content' : request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // Clean up request + request = null; + }; + + // Handle low level network errors + request.onerror = function handleError() { + // Real errors are hidden from us by the browser + // onerror should only fire if it's a network error + reject(createError('Network Error', config, null, request)); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', + request)); + + // Clean up request + request = null; + }; + + // Add xsrf header + // This is only done if running in a standard browser environment. + // Specifically not if we're in a web worker, or react-native. + if (utils.isStandardBrowserEnv()) { + var cookies = __webpack_require__(16); + + // Add xsrf header + var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? + cookies.read(config.xsrfCookieName) : + undefined; + + if (xsrfValue) { + requestHeaders[config.xsrfHeaderName] = xsrfValue; + } + } + + // Add headers to the request + if ('setRequestHeader' in request) { + utils.forEach(requestHeaders, function setRequestHeader(val, key) { + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { + // Remove Content-Type if data is undefined + delete requestHeaders[key]; + } else { + // Otherwise add header to the request + request.setRequestHeader(key, val); + } + }); + } + + // Add withCredentials to request if needed + if (config.withCredentials) { + request.withCredentials = true; + } + + // Add responseType to request if needed + if (config.responseType) { + try { + request.responseType = config.responseType; + } catch (e) { + // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. + // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. + if (config.responseType !== 'json') { + throw e; + } + } + } + + // Handle progress if needed + if (typeof config.onDownloadProgress === 'function') { + request.addEventListener('progress', config.onDownloadProgress); + } + + // Not all browsers support upload events + if (typeof config.onUploadProgress === 'function' && request.upload) { + request.upload.addEventListener('progress', config.onUploadProgress); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (!request) { + return; + } + + request.abort(); + reject(cancel); + // Clean up request + request = null; + }); + } + + if (requestData === undefined) { + requestData = null; + } + + // Send the request + request.send(requestData); + }); + }; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var createError = __webpack_require__(10); + + /** + * Resolve or reject a Promise based on response status. + * + * @param {Function} resolve A function that resolves the promise. + * @param {Function} reject A function that rejects the promise. + * @param {object} response The response. + */ + module.exports = function settle(resolve, reject, response) { + var validateStatus = response.config.validateStatus; + // Note: status is not exposed by XDomainRequest + if (!response.status || !validateStatus || validateStatus(response.status)) { + resolve(response); + } else { + reject(createError( + 'Request failed with status code ' + response.status, + response.config, + null, + response.request, + response + )); + } + }; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var enhanceError = __webpack_require__(11); + + /** + * Create an Error with the specified message, config, error code, request and response. + * + * @param {string} message The error message. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The created error. + */ + module.exports = function createError(message, config, code, request, response) { + var error = new Error(message); + return enhanceError(error, config, code, request, response); + }; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Update an Error with the specified config, error code, and response. + * + * @param {Error} error The error to update. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The error. + */ + module.exports = function enhanceError(error, config, code, request, response) { + error.config = config; + if (code) { + error.code = code; + } + error.request = request; + error.response = response; + return error; + }; + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + function encode(val) { + return encodeURIComponent(val). + replace(/%40/gi, '@'). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'). + replace(/%5B/gi, '['). + replace(/%5D/gi, ']'); + } + + /** + * Build a URL by appending params to the end + * + * @param {string} url The base of the url (e.g., http://www.google.com) + * @param {object} [params] The params to be appended + * @returns {string} The formatted url + */ + module.exports = function buildURL(url, params, paramsSerializer) { + /*eslint no-param-reassign:0*/ + if (!params) { + return url; + } + + var serializedParams; + if (paramsSerializer) { + serializedParams = paramsSerializer(params); + } else if (utils.isURLSearchParams(params)) { + serializedParams = params.toString(); + } else { + var parts = []; + + utils.forEach(params, function serialize(val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + + if (utils.isArray(val)) { + key = key + '[]'; + } else { + val = [val]; + } + + utils.forEach(val, function parseValue(v) { + if (utils.isDate(v)) { + v = v.toISOString(); + } else if (utils.isObject(v)) { + v = JSON.stringify(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + serializedParams = parts.join('&'); + } + + if (serializedParams) { + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; + } + + return url; + }; + + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + // Headers whose duplicates are ignored by node + // c.f. https://nodejs.org/api/http.html#http_message_headers + var ignoreDuplicateOf = [ + 'age', 'authorization', 'content-length', 'content-type', 'etag', + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', + 'last-modified', 'location', 'max-forwards', 'proxy-authorization', + 'referer', 'retry-after', 'user-agent' + ]; + + /** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} headers Headers needing to be parsed + * @returns {Object} Headers parsed into an object + */ + module.exports = function parseHeaders(headers) { + var parsed = {}; + var key; + var val; + var i; + + if (!headers) { return parsed; } + + utils.forEach(headers.split('\n'), function parser(line) { + i = line.indexOf(':'); + key = utils.trim(line.substr(0, i)).toLowerCase(); + val = utils.trim(line.substr(i + 1)); + + if (key) { + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { + return; + } + if (key === 'set-cookie') { + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); + } else { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + } + }); + + return parsed; + }; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + module.exports = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs have full support of the APIs needed to test + // whether the request URL is of the same origin as current location. + (function standardBrowserEnv() { + var msie = /(msie|trident)/i.test(navigator.userAgent); + var urlParsingNode = document.createElement('a'); + var originURL; + + /** + * Parse a URL to discover it's components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ + function resolveURL(url) { + var href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? + urlParsingNode.pathname : + '/' + urlParsingNode.pathname + }; + } + + originURL = resolveURL(window.location.href); + + /** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestURL The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ + return function isURLSameOrigin(requestURL) { + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + return (parsed.protocol === originURL.protocol && + parsed.host === originURL.host); + }; + })() : + + // Non standard browser envs (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return function isURLSameOrigin() { + return true; + }; + })() + ); + + +/***/ }), +/* 15 */ +/***/ (function(module, exports) { + + 'use strict'; + + // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js + + var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + function E() { + this.message = 'String contains an invalid character'; + } + E.prototype = new Error; + E.prototype.code = 5; + E.prototype.name = 'InvalidCharacterError'; + + function btoa(input) { + var str = String(input); + var output = ''; + for ( + // initialize result and counter + var block, charCode, idx = 0, map = chars; + // if the next str index does not exist: + // change the mapping table to "=" + // check if d has no fractional digits + str.charAt(idx | 0) || (map = '=', idx % 1); + // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 + output += map.charAt(63 & block >> 8 - idx % 1 * 8) + ) { + charCode = str.charCodeAt(idx += 3 / 4); + if (charCode > 0xFF) { + throw new E(); + } + block = block << 8 | charCode; + } + return output; + } + + module.exports = btoa; + + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + module.exports = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs support document.cookie + (function standardBrowserEnv() { + return { + write: function write(name, value, expires, path, domain, secure) { + var cookie = []; + cookie.push(name + '=' + encodeURIComponent(value)); + + if (utils.isNumber(expires)) { + cookie.push('expires=' + new Date(expires).toGMTString()); + } + + if (utils.isString(path)) { + cookie.push('path=' + path); + } + + if (utils.isString(domain)) { + cookie.push('domain=' + domain); + } + + if (secure === true) { + cookie.push('secure'); + } + + document.cookie = cookie.join('; '); + }, + + read: function read(name) { + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove: function remove(name) { + this.write(name, '', Date.now() - 86400000); + } + }; + })() : + + // Non standard browser env (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return { + write: function write() {}, + read: function read() { return null; }, + remove: function remove() {} + }; + })() + ); + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + function InterceptorManager() { + this.handlers = []; + } + + /** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ + InterceptorManager.prototype.use = function use(fulfilled, rejected) { + this.handlers.push({ + fulfilled: fulfilled, + rejected: rejected + }); + return this.handlers.length - 1; + }; + + /** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + */ + InterceptorManager.prototype.eject = function eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null; + } + }; + + /** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + */ + InterceptorManager.prototype.forEach = function forEach(fn) { + utils.forEach(this.handlers, function forEachHandler(h) { + if (h !== null) { + fn(h); + } + }); + }; + + module.exports = InterceptorManager; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var transformData = __webpack_require__(19); + var isCancel = __webpack_require__(20); + var defaults = __webpack_require__(6); + var isAbsoluteURL = __webpack_require__(21); + var combineURLs = __webpack_require__(22); + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + function throwIfCancellationRequested(config) { + if (config.cancelToken) { + config.cancelToken.throwIfRequested(); + } + } + + /** + * Dispatch a request to the server using the configured adapter. + * + * @param {object} config The config that is to be used for the request + * @returns {Promise} The Promise to be fulfilled + */ + module.exports = function dispatchRequest(config) { + throwIfCancellationRequested(config); + + // Support baseURL config + if (config.baseURL && !isAbsoluteURL(config.url)) { + config.url = combineURLs(config.baseURL, config.url); + } + + // Ensure headers exist + config.headers = config.headers || {}; + + // Transform request data + config.data = transformData( + config.data, + config.headers, + config.transformRequest + ); + + // Flatten headers + config.headers = utils.merge( + config.headers.common || {}, + config.headers[config.method] || {}, + config.headers || {} + ); + + utils.forEach( + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], + function cleanHeaderConfig(method) { + delete config.headers[method]; + } + ); + + var adapter = config.adapter || defaults.adapter; + + return adapter(config).then(function onAdapterResolution(response) { + throwIfCancellationRequested(config); + + // Transform response data + response.data = transformData( + response.data, + response.headers, + config.transformResponse + ); + + return response; + }, function onAdapterRejection(reason) { + if (!isCancel(reason)) { + throwIfCancellationRequested(config); + + // Transform response data + if (reason && reason.response) { + reason.response.data = transformData( + reason.response.data, + reason.response.headers, + config.transformResponse + ); + } + } + + return Promise.reject(reason); + }); + }; + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + /** + * Transform the data for a request or a response + * + * @param {Object|String} data The data to be transformed + * @param {Array} headers The headers for the request or response + * @param {Array|Function} fns A single function or Array of functions + * @returns {*} The resulting transformed data + */ + module.exports = function transformData(data, headers, fns) { + /*eslint no-param-reassign:0*/ + utils.forEach(fns, function transform(fn) { + data = fn(data, headers); + }); + + return data; + }; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports) { + + 'use strict'; + + module.exports = function isCancel(value) { + return !!(value && value.__CANCEL__); + }; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ + module.exports = function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); + }; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Creates a new URL by combining the specified URLs + * + * @param {string} baseURL The base URL + * @param {string} relativeURL The relative URL + * @returns {string} The combined URL + */ + module.exports = function combineURLs(baseURL, relativeURL) { + return relativeURL + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; + }; + + +/***/ }), +/* 23 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * A `Cancel` is an object that is thrown when an operation is canceled. + * + * @class + * @param {string=} message The message. + */ + function Cancel(message) { + this.message = message; + } + + Cancel.prototype.toString = function toString() { + return 'Cancel' + (this.message ? ': ' + this.message : ''); + }; + + Cancel.prototype.__CANCEL__ = true; + + module.exports = Cancel; + + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var Cancel = __webpack_require__(23); + + /** + * A `CancelToken` is an object that can be used to request cancellation of an operation. + * + * @class + * @param {Function} executor The executor function. + */ + function CancelToken(executor) { + if (typeof executor !== 'function') { + throw new TypeError('executor must be a function.'); + } + + var resolvePromise; + this.promise = new Promise(function promiseExecutor(resolve) { + resolvePromise = resolve; + }); + + var token = this; + executor(function cancel(message) { + if (token.reason) { + // Cancellation has already been requested + return; + } + + token.reason = new Cancel(message); + resolvePromise(token.reason); + }); + } + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + CancelToken.prototype.throwIfRequested = function throwIfRequested() { + if (this.reason) { + throw this.reason; + } + }; + + /** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ + CancelToken.source = function source() { + var cancel; + var token = new CancelToken(function executor(c) { + cancel = c; + }); + return { + token: token, + cancel: cancel + }; + }; + + module.exports = CancelToken; + + +/***/ }), +/* 25 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Syntactic sugar for invoking a function and expanding an array for arguments. + * + * Common use case would be to use `Function.prototype.apply`. + * + * ```js + * function f(x, y, z) {} + * var args = [1, 2, 3]; + * f.apply(null, args); + * ``` + * + * With `spread` this example can be re-written. + * + * ```js + * spread(function(x, y, z) {})([1, 2, 3]); + * ``` + * + * @param {Function} callback + * @returns {Function} + */ + module.exports = function spread(callback) { + return function wrap(arr) { + return callback.apply(null, arr); + }; + }; + + +/***/ }) +/******/ ]) +}); +; +//# sourceMappingURL=axios.map \ No newline at end of file diff --git a/node_modules/axios/dist/axios.map b/node_modules/axios/dist/axios.map new file mode 100644 index 0000000..6b76578 --- /dev/null +++ b/node_modules/axios/dist/axios.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 48f4719183d3ec9e4379","webpack:///./index.js","webpack:///./lib/axios.js","webpack:///./lib/utils.js","webpack:///./lib/helpers/bind.js","webpack:///./~/is-buffer/index.js","webpack:///./lib/core/Axios.js","webpack:///./lib/defaults.js","webpack:///./lib/helpers/normalizeHeaderName.js","webpack:///./lib/adapters/xhr.js","webpack:///./lib/core/settle.js","webpack:///./lib/core/createError.js","webpack:///./lib/core/enhanceError.js","webpack:///./lib/helpers/buildURL.js","webpack:///./lib/helpers/parseHeaders.js","webpack:///./lib/helpers/isURLSameOrigin.js","webpack:///./lib/helpers/btoa.js","webpack:///./lib/helpers/cookies.js","webpack:///./lib/core/InterceptorManager.js","webpack:///./lib/core/dispatchRequest.js","webpack:///./lib/core/transformData.js","webpack:///./lib/cancel/isCancel.js","webpack:///./lib/helpers/isAbsoluteURL.js","webpack:///./lib/helpers/combineURLs.js","webpack:///./lib/cancel/Cancel.js","webpack:///./lib/cancel/CancelToken.js","webpack:///./lib/helpers/spread.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA,yC;;;;;;ACAA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,aAAY,MAAM;AAClB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;;;;;;ACnDA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,aAAa;AACxB,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAmC,OAAO;AAC1C;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAuB,SAAS,GAAG,SAAS;AAC5C,4BAA2B;AAC3B;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;;AAEA,wCAAuC,OAAO;AAC9C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,aAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC9SA;;AAEA;AACA;AACA;AACA,oBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;ACpBA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;;AAEA,mCAAkC,cAAc;AAChD;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA,MAAK;AACL;AACA,EAAC;;AAED;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA;AACA,MAAK;AACL;AACA,EAAC;;AAED;;;;;;;AC9EA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE;AACxE;AACA;AACA;AACA,wDAAuD;AACvD;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,QAAO,YAAY;AACnB;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAC;;AAED;AACA;AACA,EAAC;;AAED;;;;;;;AC/FA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;;;;;;ACXA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,6CAA4C;AAC5C;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAG;AACH;;;;;;;ACnLA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,SAAS;AACpB,YAAW,SAAS;AACpB,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACzBA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;;;;;;;ACjBA;;AAEA;AACA;AACA;AACA,YAAW,MAAM;AACjB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACpBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;AACH;AACA,IAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,QAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;;;;;;ACjEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAiB,eAAe;;AAEhC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACpDA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;;;;;;ACnEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACnCA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,yCAAwC;AACxC,QAAO;;AAEP;AACA,2DAA0D,wBAAwB;AAClF;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,iCAAgC;AAChC,8BAA6B,aAAa,EAAE;AAC5C;AACA;AACA,IAAG;AACH;;;;;;;ACpDA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,SAAS;AACpB,YAAW,SAAS;AACpB;AACA,aAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;AAEA;;;;;;;ACnDA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gCAA+B;AAC/B,wCAAuC;AACvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAG;AACH;;;;;;;ACrFA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,cAAc;AACzB,YAAW,MAAM;AACjB,YAAW,eAAe;AAC1B,cAAa,EAAE;AACf;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACnBA;;AAEA;AACA;AACA;;;;;;;ACJA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACbA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;;;;;;ACbA;;AAEA;AACA;AACA;AACA;AACA,YAAW,QAAQ;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;;;;;;AClBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACxDA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAA+B;AAC/B;AACA;AACA,YAAW,SAAS;AACpB,cAAa;AACb;AACA;AACA;AACA;AACA;AACA","file":"axios.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 48f4719183d3ec9e4379","module.exports = require('./lib/axios');\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./index.js\n// module id = 0\n// module chunks = 0","'use strict';\n\nvar utils = require('./utils');\nvar bind = require('./helpers/bind');\nvar Axios = require('./core/Axios');\nvar defaults = require('./defaults');\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n * @return {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n var context = new Axios(defaultConfig);\n var instance = bind(Axios.prototype.request, context);\n\n // Copy axios.prototype to instance\n utils.extend(instance, Axios.prototype, context);\n\n // Copy context to instance\n utils.extend(instance, context);\n\n return instance;\n}\n\n// Create the default instance to be exported\nvar axios = createInstance(defaults);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios;\n\n// Factory for creating new instances\naxios.create = function create(instanceConfig) {\n return createInstance(utils.merge(defaults, instanceConfig));\n};\n\n// Expose Cancel & CancelToken\naxios.Cancel = require('./cancel/Cancel');\naxios.CancelToken = require('./cancel/CancelToken');\naxios.isCancel = require('./cancel/isCancel');\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\nmodule.exports = axios;\n\n// Allow use of default import syntax in TypeScript\nmodule.exports.default = axios;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/axios.js\n// module id = 1\n// module chunks = 0","'use strict';\n\nvar bind = require('./helpers/bind');\nvar isBuffer = require('is-buffer');\n\n/*global toString:true*/\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return (typeof FormData !== 'undefined') && (val instanceof FormData);\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\nfunction isURLSearchParams(val) {\n return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n */\nfunction isStandardBrowserEnv() {\n if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n return false;\n }\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object') {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (typeof result[key] === 'object' && typeof val === 'object') {\n result[key] = merge(result[key], val);\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n * @return {Object} The resulting value of object a\n */\nfunction extend(a, b, thisArg) {\n forEach(b, function assignValue(val, key) {\n if (thisArg && typeof val === 'function') {\n a[key] = bind(val, thisArg);\n } else {\n a[key] = val;\n }\n });\n return a;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isBuffer: isBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isURLSearchParams: isURLSearchParams,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n extend: extend,\n trim: trim\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/utils.js\n// module id = 2\n// module chunks = 0","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/bind.js\n// module id = 3\n// module chunks = 0","/*!\n * Determine if an object is a Buffer\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n\n// The _isBuffer check is for Safari 5-7 support, because it's missing\n// Object.prototype.constructor. Remove this eventually\nmodule.exports = function (obj) {\n return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)\n}\n\nfunction isBuffer (obj) {\n return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n}\n\n// For Node v0.10 support. Remove this eventually.\nfunction isSlowBuffer (obj) {\n return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/is-buffer/index.js\n// module id = 4\n// module chunks = 0","'use strict';\n\nvar defaults = require('./../defaults');\nvar utils = require('./../utils');\nvar InterceptorManager = require('./InterceptorManager');\nvar dispatchRequest = require('./dispatchRequest');\n\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n */\nfunction Axios(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\n/**\n * Dispatch a request\n *\n * @param {Object} config The config specific for this request (merged with this.defaults)\n */\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = utils.merge({\n url: arguments[0]\n }, arguments[1]);\n }\n\n config = utils.merge(defaults, {method: 'get'}, this.defaults, config);\n config.method = config.method.toLowerCase();\n\n // Hook up interceptors middleware\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url\n }));\n };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n});\n\nmodule.exports = Axios;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/Axios.js\n// module id = 5\n// module chunks = 0","'use strict';\n\nvar utils = require('./utils');\nvar normalizeHeaderName = require('./helpers/normalizeHeaderName');\n\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nfunction setContentTypeIfUnset(headers, value) {\n if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = value;\n }\n}\n\nfunction getDefaultAdapter() {\n var adapter;\n if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('./adapters/xhr');\n } else if (typeof process !== 'undefined') {\n // For node use HTTP adapter\n adapter = require('./adapters/http');\n }\n return adapter;\n}\n\nvar defaults = {\n adapter: getDefaultAdapter(),\n\n transformRequest: [function transformRequest(data, headers) {\n normalizeHeaderName(headers, 'Content-Type');\n if (utils.isFormData(data) ||\n utils.isArrayBuffer(data) ||\n utils.isBuffer(data) ||\n utils.isStream(data) ||\n utils.isFile(data) ||\n utils.isBlob(data)\n ) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isURLSearchParams(data)) {\n setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n return data.toString();\n }\n if (utils.isObject(data)) {\n setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n return JSON.stringify(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponse(data) {\n /*eslint no-param-reassign:0*/\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data);\n } catch (e) { /* Ignore */ }\n }\n return data;\n }],\n\n /**\n * A timeout in milliseconds to abort a request. If set to 0 (default) a\n * timeout is not created.\n */\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n\n maxContentLength: -1,\n\n validateStatus: function validateStatus(status) {\n return status >= 200 && status < 300;\n }\n};\n\ndefaults.headers = {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n }\n};\n\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n defaults.headers[method] = {};\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n});\n\nmodule.exports = defaults;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/defaults.js\n// module id = 6\n// module chunks = 0","'use strict';\n\nvar utils = require('../utils');\n\nmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n utils.forEach(headers, function processHeader(value, name) {\n if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n headers[normalizedName] = value;\n delete headers[name];\n }\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/normalizeHeaderName.js\n// module id = 7\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar buildURL = require('./../helpers/buildURL');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar createError = require('../core/createError');\nvar btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');\n\nmodule.exports = function xhrAdapter(config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n var loadEvent = 'onreadystatechange';\n var xDomain = false;\n\n // For IE 8/9 CORS support\n // Only supports POST and GET calls and doesn't returns the response headers.\n // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.\n if (process.env.NODE_ENV !== 'test' &&\n typeof window !== 'undefined' &&\n window.XDomainRequest && !('withCredentials' in request) &&\n !isURLSameOrigin(config.url)) {\n request = new window.XDomainRequest();\n loadEvent = 'onload';\n xDomain = true;\n request.onprogress = function handleProgress() {};\n request.ontimeout = function handleTimeout() {};\n }\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password || '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n // Listen for ready state\n request[loadEvent] = function handleLoad() {\n if (!request || (request.readyState !== 4 && !xDomain)) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n }\n\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n var response = {\n data: responseData,\n // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)\n status: request.status === 1223 ? 204 : request.status,\n statusText: request.status === 1223 ? 'No Content' : request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n\n settle(resolve, reject, response);\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(createError('Network Error', config, null, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',\n request));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n var cookies = require('./../helpers/cookies');\n\n // Add xsrf header\n var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (config.withCredentials) {\n request.withCredentials = true;\n }\n\n // Add responseType to request if needed\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n if (config.responseType !== 'json') {\n throw e;\n }\n }\n }\n\n // Handle progress if needed\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', config.onDownloadProgress);\n }\n\n // Not all browsers support upload events\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', config.onUploadProgress);\n }\n\n if (config.cancelToken) {\n // Handle cancellation\n config.cancelToken.promise.then(function onCanceled(cancel) {\n if (!request) {\n return;\n }\n\n request.abort();\n reject(cancel);\n // Clean up request\n request = null;\n });\n }\n\n if (requestData === undefined) {\n requestData = null;\n }\n\n // Send the request\n request.send(requestData);\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/adapters/xhr.js\n// module id = 8\n// module chunks = 0","'use strict';\n\nvar createError = require('./createError');\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n // Note: status is not exposed by XDomainRequest\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(createError(\n 'Request failed with status code ' + response.status,\n response.config,\n null,\n response.request,\n response\n ));\n }\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/settle.js\n// module id = 9\n// module chunks = 0","'use strict';\n\nvar enhanceError = require('./enhanceError');\n\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The created error.\n */\nmodule.exports = function createError(message, config, code, request, response) {\n var error = new Error(message);\n return enhanceError(error, config, code, request, response);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/createError.js\n// module id = 10\n// module chunks = 0","'use strict';\n\n/**\n * Update an Error with the specified config, error code, and response.\n *\n * @param {Error} error The error to update.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The error.\n */\nmodule.exports = function enhanceError(error, config, code, request, response) {\n error.config = config;\n if (code) {\n error.code = code;\n }\n error.request = request;\n error.response = response;\n return error;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/enhanceError.js\n// module id = 11\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%40/gi, '@').\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else if (utils.isURLSearchParams(params)) {\n serializedParams = params.toString();\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n } else {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/buildURL.js\n// module id = 12\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\n// Headers whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nvar ignoreDuplicateOf = [\n 'age', 'authorization', 'content-length', 'content-type', 'etag',\n 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n 'referer', 'retry-after', 'user-agent'\n];\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n return;\n }\n if (key === 'set-cookie') {\n parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n }\n });\n\n return parsed;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/parseHeaders.js\n// module id = 13\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isURLSameOrigin.js\n// module id = 14\n// module chunks = 0","'use strict';\n\n// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\nfunction E() {\n this.message = 'String contains an invalid character';\n}\nE.prototype = new Error;\nE.prototype.code = 5;\nE.prototype.name = 'InvalidCharacterError';\n\nfunction btoa(input) {\n var str = String(input);\n var output = '';\n for (\n // initialize result and counter\n var block, charCode, idx = 0, map = chars;\n // if the next str index does not exist:\n // change the mapping table to \"=\"\n // check if d has no fractional digits\n str.charAt(idx | 0) || (map = '=', idx % 1);\n // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n ) {\n charCode = str.charCodeAt(idx += 3 / 4);\n if (charCode > 0xFF) {\n throw new E();\n }\n block = block << 8 | charCode;\n }\n return output;\n}\n\nmodule.exports = btoa;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/btoa.js\n// module id = 15\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/cookies.js\n// module id = 16\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/InterceptorManager.js\n// module id = 17\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar transformData = require('./transformData');\nvar isCancel = require('../cancel/isCancel');\nvar defaults = require('../defaults');\nvar isAbsoluteURL = require('./../helpers/isAbsoluteURL');\nvar combineURLs = require('./../helpers/combineURLs');\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nfunction throwIfCancellationRequested(config) {\n if (config.cancelToken) {\n config.cancelToken.throwIfRequested();\n }\n}\n\n/**\n * Dispatch a request to the server using the configured adapter.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n throwIfCancellationRequested(config);\n\n // Support baseURL config\n if (config.baseURL && !isAbsoluteURL(config.url)) {\n config.url = combineURLs(config.baseURL, config.url);\n }\n\n // Ensure headers exist\n config.headers = config.headers || {};\n\n // Transform request data\n config.data = transformData(\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers || {}\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n var adapter = config.adapter || defaults.adapter;\n\n return adapter(config).then(function onAdapterResolution(response) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n response.data = transformData(\n response.data,\n response.headers,\n config.transformResponse\n );\n\n return response;\n }, function onAdapterRejection(reason) {\n if (!isCancel(reason)) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n if (reason && reason.response) {\n reason.response.data = transformData(\n reason.response.data,\n reason.response.headers,\n config.transformResponse\n );\n }\n }\n\n return Promise.reject(reason);\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/dispatchRequest.js\n// module id = 18\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn(data, headers);\n });\n\n return data;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/transformData.js\n// module id = 19\n// module chunks = 0","'use strict';\n\nmodule.exports = function isCancel(value) {\n return !!(value && value.__CANCEL__);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/isCancel.js\n// module id = 20\n// module chunks = 0","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isAbsoluteURL.js\n// module id = 21\n// module chunks = 0","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return relativeURL\n ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n : baseURL;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/combineURLs.js\n// module id = 22\n// module chunks = 0","'use strict';\n\n/**\n * A `Cancel` is an object that is thrown when an operation is canceled.\n *\n * @class\n * @param {string=} message The message.\n */\nfunction Cancel(message) {\n this.message = message;\n}\n\nCancel.prototype.toString = function toString() {\n return 'Cancel' + (this.message ? ': ' + this.message : '');\n};\n\nCancel.prototype.__CANCEL__ = true;\n\nmodule.exports = Cancel;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/Cancel.js\n// module id = 23\n// module chunks = 0","'use strict';\n\nvar Cancel = require('./Cancel');\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @class\n * @param {Function} executor The executor function.\n */\nfunction CancelToken(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n var resolvePromise;\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n var token = this;\n executor(function cancel(message) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new Cancel(message);\n resolvePromise(token.reason);\n });\n}\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n};\n\n/**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\nCancelToken.source = function source() {\n var cancel;\n var token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token: token,\n cancel: cancel\n };\n};\n\nmodule.exports = CancelToken;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/CancelToken.js\n// module id = 24\n// module chunks = 0","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/spread.js\n// module id = 25\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/node_modules/axios/dist/axios.min.js b/node_modules/axios/dist/axios.min.js new file mode 100644 index 0000000..69cc188 --- /dev/null +++ b/node_modules/axios/dist/axios.min.js @@ -0,0 +1,9 @@ +/* axios v0.18.0 | (c) 2018 by Matt Zabriskie */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new s(e),n=i(s.prototype.request,t);return o.extend(n,s.prototype,t),o.extend(n,t),n}var o=n(2),i=n(3),s=n(5),u=n(6),a=r(u);a.Axios=s,a.create=function(e){return r(o.merge(u,e))},a.Cancel=n(23),a.CancelToken=n(24),a.isCancel=n(20),a.all=function(e){return Promise.all(e)},a.spread=n(25),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";function r(e){return"[object Array]"===R.call(e)}function o(e){return"[object ArrayBuffer]"===R.call(e)}function i(e){return"undefined"!=typeof FormData&&e instanceof FormData}function s(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function u(e){return"string"==typeof e}function a(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===R.call(e)}function d(e){return"[object File]"===R.call(e)}function l(e){return"[object Blob]"===R.call(e)}function h(e){return"[object Function]"===R.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function w(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function g(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n + * @license MIT + */ +e.exports=function(e){return null!=e&&(n(e)||r(e)||!!e._isBuffer)}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new s,response:new s}}var o=n(6),i=n(2),s=n(17),u=n(18);r.prototype.request=function(e){"string"==typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),e=i.merge(o,{method:"get"},this.defaults,e),e.method=e.method.toLowerCase();var t=[u,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},i.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(i.merge(n||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(i.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e,t){!i.isUndefined(e)&&i.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof XMLHttpRequest?e=n(8):"undefined"!=typeof process&&(e=n(8)),e}var i=n(2),s=n(7),u={"Content-Type":"application/x-www-form-urlencoded"},a={adapter:o(),transformRequest:[function(e,t){return s(t,"Content-Type"),i.isFormData(e)||i.isArrayBuffer(e)||i.isBuffer(e)||i.isStream(e)||i.isFile(e)||i.isBlob(e)?e:i.isArrayBufferView(e)?e.buffer:i.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):i.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(e){a.headers[e]={}}),i.forEach(["post","put","patch"],function(e){a.headers[e]=i.merge(u)}),e.exports=a},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(9),i=n(12),s=n(13),u=n(14),a=n(10),c="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(15);e.exports=function(e){return new Promise(function(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest,h="onreadystatechange",m=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in l||u(e.url)||(l=new window.XDomainRequest,h="onload",m=!0,l.onprogress=function(){},l.ontimeout=function(){}),e.auth){var y=e.auth.username||"",w=e.auth.password||"";d.Authorization="Basic "+c(y+":"+w)}if(l.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l[h]=function(){if(l&&(4===l.readyState||m)&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in l?s(l.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?l.response:l.responseText,i={data:r,status:1223===l.status?204:l.status,statusText:1223===l.status?"No Content":l.statusText,headers:n,config:e,request:l};o(t,f,i),l=null}},l.onerror=function(){f(a("Network Error",e,null,l)),l=null},l.ontimeout=function(){f(a("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",l)),l=null},r.isStandardBrowserEnv()){var g=n(16),v=(e.withCredentials||u(e.url))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;v&&(d[e.xsrfHeaderName]=v)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),e.withCredentials&&(l.withCredentials=!0),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),f(e),l=null)}),void 0===p&&(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(10);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(11);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(o.isURLSearchParams(t))i=t.toString();else{var s=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),s.push(r(t)+"="+r(e))}))}),i=s.join("&")}return i&&(e+=(e.indexOf("?")===-1?"?":"&")+i),e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?s[t]=(s[t]?s[t]:[]).concat([n]):s[t]=s[t]?s[t]+", "+n:n}}),s):s}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function n(){this.message="String contains an invalid character"}function r(e){for(var t,r,i=String(e),s="",u=0,a=o;i.charAt(0|u)||(a="=",u%1);s+=a.charAt(63&t>>8-u%1*8)){if(r=i.charCodeAt(u+=.75),r>255)throw new n;t=t<<8|r}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,i,s){var u=[];u.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),r.isString(o)&&u.push("path="+o),r.isString(i)&&u.push("domain="+i),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),i=n(19),s=n(20),u=n(6),a=n(21),c=n(22);e.exports=function(e){r(e),e.baseURL&&!a(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||u.adapter;return t(e).then(function(t){return r(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return s(t)||(r(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])}); +//# sourceMappingURL=axios.min.map \ No newline at end of file diff --git a/node_modules/axios/dist/axios.min.map b/node_modules/axios/dist/axios.min.map new file mode 100644 index 0000000..f7fdd44 --- /dev/null +++ b/node_modules/axios/dist/axios.min.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///axios.min.js","webpack:///webpack/bootstrap dad8263224c86c166a30","webpack:///./index.js","webpack:///./lib/axios.js","webpack:///./lib/utils.js","webpack:///./lib/helpers/bind.js","webpack:///./~/is-buffer/index.js","webpack:///./lib/core/Axios.js","webpack:///./lib/defaults.js","webpack:///./lib/helpers/normalizeHeaderName.js","webpack:///./lib/adapters/xhr.js","webpack:///./lib/core/settle.js","webpack:///./lib/core/createError.js","webpack:///./lib/core/enhanceError.js","webpack:///./lib/helpers/buildURL.js","webpack:///./lib/helpers/parseHeaders.js","webpack:///./lib/helpers/isURLSameOrigin.js","webpack:///./lib/helpers/btoa.js","webpack:///./lib/helpers/cookies.js","webpack:///./lib/core/InterceptorManager.js","webpack:///./lib/core/dispatchRequest.js","webpack:///./lib/core/transformData.js","webpack:///./lib/cancel/isCancel.js","webpack:///./lib/helpers/isAbsoluteURL.js","webpack:///./lib/helpers/combineURLs.js","webpack:///./lib/cancel/Cancel.js","webpack:///./lib/cancel/CancelToken.js","webpack:///./lib/helpers/spread.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","createInstance","defaultConfig","context","Axios","instance","bind","prototype","request","utils","extend","defaults","axios","create","instanceConfig","merge","Cancel","CancelToken","isCancel","all","promises","Promise","spread","default","isArray","val","toString","isArrayBuffer","isFormData","FormData","isArrayBufferView","result","ArrayBuffer","isView","buffer","isString","isNumber","isUndefined","isObject","isDate","isFile","isBlob","isFunction","isStream","pipe","isURLSearchParams","URLSearchParams","trim","str","replace","isStandardBrowserEnv","navigator","product","window","document","forEach","obj","fn","i","l","length","key","Object","hasOwnProperty","assignValue","arguments","a","b","thisArg","isBuffer","args","Array","apply","constructor","isSlowBuffer","readFloatLE","slice","_isBuffer","interceptors","InterceptorManager","response","dispatchRequest","config","url","method","toLowerCase","chain","undefined","promise","resolve","interceptor","unshift","fulfilled","rejected","push","then","shift","data","setContentTypeIfUnset","headers","value","getDefaultAdapter","adapter","XMLHttpRequest","process","normalizeHeaderName","DEFAULT_CONTENT_TYPE","Content-Type","transformRequest","JSON","stringify","transformResponse","parse","e","timeout","xsrfCookieName","xsrfHeaderName","maxContentLength","validateStatus","status","common","Accept","normalizedName","name","toUpperCase","settle","buildURL","parseHeaders","isURLSameOrigin","createError","btoa","reject","requestData","requestHeaders","loadEvent","xDomain","XDomainRequest","onprogress","ontimeout","auth","username","password","Authorization","open","params","paramsSerializer","readyState","responseURL","indexOf","responseHeaders","getAllResponseHeaders","responseData","responseType","responseText","statusText","onerror","cookies","xsrfValue","withCredentials","read","setRequestHeader","onDownloadProgress","addEventListener","onUploadProgress","upload","cancelToken","cancel","abort","send","enhanceError","message","code","error","Error","encode","encodeURIComponent","serializedParams","parts","v","toISOString","join","ignoreDuplicateOf","parsed","split","line","substr","concat","resolveURL","href","msie","urlParsingNode","setAttribute","protocol","host","search","hash","hostname","port","pathname","charAt","originURL","test","userAgent","createElement","location","requestURL","E","input","block","charCode","String","output","idx","map","chars","charCodeAt","write","expires","path","domain","secure","cookie","Date","toGMTString","match","RegExp","decodeURIComponent","remove","now","handlers","use","eject","h","throwIfCancellationRequested","throwIfRequested","transformData","isAbsoluteURL","combineURLs","baseURL","reason","fns","__CANCEL__","relativeURL","executor","TypeError","resolvePromise","token","source","callback","arr"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,MAAAD,IAEAD,EAAA,MAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAP,WACAS,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,QAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAAUL,EAAQD,EAASM,GEtDjCL,EAAAD,QAAAM,EAAA,IF4DM,SAAUL,EAAQD,EAASM,GG5DjC,YAaA,SAAAS,GAAAC,GACA,GAAAC,GAAA,GAAAC,GAAAF,GACAG,EAAAC,EAAAF,EAAAG,UAAAC,QAAAL,EAQA,OALAM,GAAAC,OAAAL,EAAAD,EAAAG,UAAAJ,GAGAM,EAAAC,OAAAL,EAAAF,GAEAE,EArBA,GAAAI,GAAAjB,EAAA,GACAc,EAAAd,EAAA,GACAY,EAAAZ,EAAA,GACAmB,EAAAnB,EAAA,GAsBAoB,EAAAX,EAAAU,EAGAC,GAAAR,QAGAQ,EAAAC,OAAA,SAAAC,GACA,MAAAb,GAAAQ,EAAAM,MAAAJ,EAAAG,KAIAF,EAAAI,OAAAxB,EAAA,IACAoB,EAAAK,YAAAzB,EAAA,IACAoB,EAAAM,SAAA1B,EAAA,IAGAoB,EAAAO,IAAA,SAAAC,GACA,MAAAC,SAAAF,IAAAC,IAEAR,EAAAU,OAAA9B,EAAA,IAEAL,EAAAD,QAAA0B,EAGAzB,EAAAD,QAAAqC,QAAAX,GHmEM,SAAUzB,EAAQD,EAASM,GItHjC,YAiBA,SAAAgC,GAAAC,GACA,yBAAAC,EAAA7B,KAAA4B,GASA,QAAAE,GAAAF,GACA,+BAAAC,EAAA7B,KAAA4B,GASA,QAAAG,GAAAH,GACA,yBAAAI,WAAAJ,YAAAI,UASA,QAAAC,GAAAL,GACA,GAAAM,EAMA,OAJAA,GADA,mBAAAC,0BAAA,OACAA,YAAAC,OAAAR,GAEA,GAAAA,EAAA,QAAAA,EAAAS,iBAAAF,aAWA,QAAAG,GAAAV,GACA,sBAAAA,GASA,QAAAW,GAAAX,GACA,sBAAAA,GASA,QAAAY,GAAAZ,GACA,yBAAAA,GASA,QAAAa,GAAAb,GACA,cAAAA,GAAA,gBAAAA,GASA,QAAAc,GAAAd,GACA,wBAAAC,EAAA7B,KAAA4B,GASA,QAAAe,GAAAf,GACA,wBAAAC,EAAA7B,KAAA4B,GASA,QAAAgB,GAAAhB,GACA,wBAAAC,EAAA7B,KAAA4B,GASA,QAAAiB,GAAAjB,GACA,4BAAAC,EAAA7B,KAAA4B,GASA,QAAAkB,GAAAlB,GACA,MAAAa,GAAAb,IAAAiB,EAAAjB,EAAAmB,MASA,QAAAC,GAAApB,GACA,yBAAAqB,kBAAArB,YAAAqB,iBASA,QAAAC,GAAAC,GACA,MAAAA,GAAAC,QAAA,WAAAA,QAAA,WAgBA,QAAAC,KACA,0BAAAC,YAAA,gBAAAA,UAAAC,WAIA,mBAAAC,SACA,mBAAAC,WAgBA,QAAAC,GAAAC,EAAAC,GAEA,UAAAD,GAAA,mBAAAA,GAUA,GALA,gBAAAA,KAEAA,OAGAhC,EAAAgC,GAEA,OAAAE,GAAA,EAAAC,EAAAH,EAAAI,OAAmCF,EAAAC,EAAOD,IAC1CD,EAAA5D,KAAA,KAAA2D,EAAAE,KAAAF,OAIA,QAAAK,KAAAL,GACAM,OAAAvD,UAAAwD,eAAAlE,KAAA2D,EAAAK,IACAJ,EAAA5D,KAAA,KAAA2D,EAAAK,KAAAL,GAuBA,QAAAzC,KAEA,QAAAiD,GAAAvC,EAAAoC,GACA,gBAAA9B,GAAA8B,IAAA,gBAAApC,GACAM,EAAA8B,GAAA9C,EAAAgB,EAAA8B,GAAApC,GAEAM,EAAA8B,GAAApC,EAIA,OATAM,MASA2B,EAAA,EAAAC,EAAAM,UAAAL,OAAuCF,EAAAC,EAAOD,IAC9CH,EAAAU,UAAAP,GAAAM,EAEA,OAAAjC,GAWA,QAAArB,GAAAwD,EAAAC,EAAAC,GAQA,MAPAb,GAAAY,EAAA,SAAA1C,EAAAoC,GACAO,GAAA,kBAAA3C,GACAyC,EAAAL,GAAAvD,EAAAmB,EAAA2C,GAEAF,EAAAL,GAAApC,IAGAyC,EApRA,GAAA5D,GAAAd,EAAA,GACA6E,EAAA7E,EAAA,GAMAkC,EAAAoC,OAAAvD,UAAAmB,QAgRAvC,GAAAD,SACAsC,UACAG,gBACA0C,WACAzC,aACAE,oBACAK,WACAC,WACAE,WACAD,cACAE,SACAC,SACAC,SACAC,aACAC,WACAE,oBACAK,uBACAK,UACAxC,QACAL,SACAqC,SJ8HM,SAAU5D,EAAQD,GK3axB,YAEAC,GAAAD,QAAA,SAAAuE,EAAAW,GACA,kBAEA,OADAE,GAAA,GAAAC,OAAAN,UAAAL,QACAF,EAAA,EAAmBA,EAAAY,EAAAV,OAAiBF,IACpCY,EAAAZ,GAAAO,UAAAP,EAEA,OAAAD,GAAAe,MAAAJ,EAAAE,MLobM,SAAUnF,EAAQD,GM/axB,QAAAmF,GAAAb,GACA,QAAAA,EAAAiB,aAAA,kBAAAjB,GAAAiB,YAAAJ,UAAAb,EAAAiB,YAAAJ,SAAAb,GAIA,QAAAkB,GAAAlB,GACA,wBAAAA,GAAAmB,aAAA,kBAAAnB,GAAAoB,OAAAP,EAAAb,EAAAoB,MAAA;;;;;;AAVAzF,EAAAD,QAAA,SAAAsE,GACA,aAAAA,IAAAa,EAAAb,IAAAkB,EAAAlB,QAAAqB,aN6cM,SAAU1F,EAAQD,EAASM,GOvdjC,YAYA,SAAAY,GAAAU,GACAxB,KAAAqB,SAAAG,EACAxB,KAAAwF,cACAtE,QAAA,GAAAuE,GACAC,SAAA,GAAAD,IAdA,GAAApE,GAAAnB,EAAA,GACAiB,EAAAjB,EAAA,GACAuF,EAAAvF,EAAA,IACAyF,EAAAzF,EAAA,GAoBAY,GAAAG,UAAAC,QAAA,SAAA0E,GAGA,gBAAAA,KACAA,EAAAzE,EAAAM,OACAoE,IAAAlB,UAAA,IACKA,UAAA,KAGLiB,EAAAzE,EAAAM,MAAAJ,GAAkCyE,OAAA,OAAc9F,KAAAqB,SAAAuE,GAChDA,EAAAE,OAAAF,EAAAE,OAAAC,aAGA,IAAAC,IAAAL,EAAAM,QACAC,EAAAnE,QAAAoE,QAAAP,EAUA,KARA5F,KAAAwF,aAAAtE,QAAA+C,QAAA,SAAAmC,GACAJ,EAAAK,QAAAD,EAAAE,UAAAF,EAAAG,YAGAvG,KAAAwF,aAAAE,SAAAzB,QAAA,SAAAmC,GACAJ,EAAAQ,KAAAJ,EAAAE,UAAAF,EAAAG,YAGAP,EAAA1B,QACA4B,IAAAO,KAAAT,EAAAU,QAAAV,EAAAU,QAGA,OAAAR,IAIA/E,EAAA8C,SAAA,0CAAA6B,GAEAhF,EAAAG,UAAA6E,GAAA,SAAAD,EAAAD,GACA,MAAA5F,MAAAkB,QAAAC,EAAAM,MAAAmE,OACAE,SACAD,YAKA1E,EAAA8C,SAAA,+BAAA6B,GAEAhF,EAAAG,UAAA6E,GAAA,SAAAD,EAAAc,EAAAf,GACA,MAAA5F,MAAAkB,QAAAC,EAAAM,MAAAmE,OACAE,SACAD,MACAc,aAKA9G,EAAAD,QAAAkB,GP8dM,SAAUjB,EAAQD,EAASM,GQ5iBjC,YASA,SAAA0G,GAAAC,EAAAC,IACA3F,EAAA4B,YAAA8D,IAAA1F,EAAA4B,YAAA8D,EAAA,mBACAA,EAAA,gBAAAC,GAIA,QAAAC,KACA,GAAAC,EAQA,OAPA,mBAAAC,gBAEAD,EAAA9G,EAAA,GACG,mBAAAgH,WAEHF,EAAA9G,EAAA,IAEA8G,EAtBA,GAAA7F,GAAAjB,EAAA,GACAiH,EAAAjH,EAAA,GAEAkH,GACAC,eAAA,qCAqBAhG,GACA2F,QAAAD,IAEAO,kBAAA,SAAAX,EAAAE,GAEA,MADAM,GAAAN,EAAA,gBACA1F,EAAAmB,WAAAqE,IACAxF,EAAAkB,cAAAsE,IACAxF,EAAA4D,SAAA4B,IACAxF,EAAAkC,SAAAsD,IACAxF,EAAA+B,OAAAyD,IACAxF,EAAAgC,OAAAwD,GAEAA,EAEAxF,EAAAqB,kBAAAmE,GACAA,EAAA/D,OAEAzB,EAAAoC,kBAAAoD,IACAC,EAAAC,EAAA,mDACAF,EAAAvE,YAEAjB,EAAA6B,SAAA2D,IACAC,EAAAC,EAAA,kCACAU,KAAAC,UAAAb,IAEAA,IAGAc,mBAAA,SAAAd,GAEA,mBAAAA,GACA,IACAA,EAAAY,KAAAG,MAAAf,GACO,MAAAgB,IAEP,MAAAhB,KAOAiB,QAAA,EAEAC,eAAA,aACAC,eAAA,eAEAC,kBAAA,EAEAC,eAAA,SAAAC,GACA,MAAAA,IAAA,KAAAA,EAAA,KAIA5G,GAAAwF,SACAqB,QACAC,OAAA,sCAIAhH,EAAA8C,SAAA,gCAAA6B,GACAzE,EAAAwF,QAAAf,QAGA3E,EAAA8C,SAAA,+BAAA6B,GACAzE,EAAAwF,QAAAf,GAAA3E,EAAAM,MAAA2F,KAGAvH,EAAAD,QAAAyB,GRmjBM,SAAUxB,EAAQD,EAASM,GSlpBjC,YAEA,IAAAiB,GAAAjB,EAAA,EAEAL,GAAAD,QAAA,SAAAiH,EAAAuB,GACAjH,EAAA8C,QAAA4C,EAAA,SAAAC,EAAAuB,GACAA,IAAAD,GAAAC,EAAAC,gBAAAF,EAAAE,gBACAzB,EAAAuB,GAAAtB,QACAD,GAAAwB,QT4pBM,SAAUxI,EAAQD,EAASM,GUpqBjC,YAEA,IAAAiB,GAAAjB,EAAA,GACAqI,EAAArI,EAAA,GACAsI,EAAAtI,EAAA,IACAuI,EAAAvI,EAAA,IACAwI,EAAAxI,EAAA,IACAyI,EAAAzI,EAAA,IACA0I,EAAA,mBAAA7E,gBAAA6E,MAAA7E,OAAA6E,KAAA5H,KAAA+C,SAAA7D,EAAA,GAEAL,GAAAD,QAAA,SAAAgG,GACA,UAAA7D,SAAA,SAAAoE,EAAA0C,GACA,GAAAC,GAAAlD,EAAAe,KACAoC,EAAAnD,EAAAiB,OAEA1F,GAAAmB,WAAAwG,UACAC,GAAA,eAGA,IAAA7H,GAAA,GAAA+F,gBACA+B,EAAA,qBACAC,GAAA,CAiBA,IAXA,mBAAAlF,UACAA,OAAAmF,gBAAA,mBAAAhI,IACAwH,EAAA9C,EAAAC,OACA3E,EAAA,GAAA6C,QAAAmF,eACAF,EAAA,SACAC,GAAA,EACA/H,EAAAiI,WAAA,aACAjI,EAAAkI,UAAA,cAIAxD,EAAAyD,KAAA,CACA,GAAAC,GAAA1D,EAAAyD,KAAAC,UAAA,GACAC,EAAA3D,EAAAyD,KAAAE,UAAA,EACAR,GAAAS,cAAA,SAAAZ,EAAAU,EAAA,IAAAC,GA+DA,GA5DArI,EAAAuI,KAAA7D,EAAAE,OAAAwC,cAAAE,EAAA5C,EAAAC,IAAAD,EAAA8D,OAAA9D,EAAA+D,mBAAA,GAGAzI,EAAA0G,QAAAhC,EAAAgC,QAGA1G,EAAA8H,GAAA,WACA,GAAA9H,IAAA,IAAAA,EAAA0I,YAAAX,KAQA,IAAA/H,EAAA+G,QAAA/G,EAAA2I,aAAA,IAAA3I,EAAA2I,YAAAC,QAAA,WAKA,GAAAC,GAAA,yBAAA7I,GAAAuH,EAAAvH,EAAA8I,yBAAA,KACAC,EAAArE,EAAAsE,cAAA,SAAAtE,EAAAsE,aAAAhJ,EAAAwE,SAAAxE,EAAAiJ,aACAzE,GACAiB,KAAAsD,EAEAhC,OAAA,OAAA/G,EAAA+G,OAAA,IAAA/G,EAAA+G,OACAmC,WAAA,OAAAlJ,EAAA+G,OAAA,aAAA/G,EAAAkJ,WACAvD,QAAAkD,EACAnE,SACA1E,UAGAqH,GAAApC,EAAA0C,EAAAnD,GAGAxE,EAAA,OAIAA,EAAAmJ,QAAA,WAGAxB,EAAAF,EAAA,gBAAA/C,EAAA,KAAA1E,IAGAA,EAAA,MAIAA,EAAAkI,UAAA,WACAP,EAAAF,EAAA,cAAA/C,EAAAgC,QAAA,cAAAhC,EAAA,eACA1E,IAGAA,EAAA,MAMAC,EAAAyC,uBAAA,CACA,GAAA0G,GAAApK,EAAA,IAGAqK,GAAA3E,EAAA4E,iBAAA9B,EAAA9C,EAAAC,OAAAD,EAAAiC,eACAyC,EAAAG,KAAA7E,EAAAiC,gBACA5B,MAEAsE,KACAxB,EAAAnD,EAAAkC,gBAAAyC,GAuBA,GAlBA,oBAAArJ,IACAC,EAAA8C,QAAA8E,EAAA,SAAA5G,EAAAoC,GACA,mBAAAuE,IAAA,iBAAAvE,EAAAwB,oBAEAgD,GAAAxE,GAGArD,EAAAwJ,iBAAAnG,EAAApC,KAMAyD,EAAA4E,kBACAtJ,EAAAsJ,iBAAA,GAIA5E,EAAAsE,aACA,IACAhJ,EAAAgJ,aAAAtE,EAAAsE,aACO,MAAAvC,GAGP,YAAA/B,EAAAsE,aACA,KAAAvC,GAMA,kBAAA/B,GAAA+E,oBACAzJ,EAAA0J,iBAAA,WAAAhF,EAAA+E,oBAIA,kBAAA/E,GAAAiF,kBAAA3J,EAAA4J,QACA5J,EAAA4J,OAAAF,iBAAA,WAAAhF,EAAAiF,kBAGAjF,EAAAmF,aAEAnF,EAAAmF,YAAA7E,QAAAO,KAAA,SAAAuE,GACA9J,IAIAA,EAAA+J,QACApC,EAAAmC,GAEA9J,EAAA,QAIA+E,SAAA6C,IACAA,EAAA,MAIA5H,EAAAgK,KAAApC,OV6qBM,SAAUjJ,EAAQD,EAASM,GW91BjC,YAEA,IAAAyI,GAAAzI,EAAA,GASAL,GAAAD,QAAA,SAAAuG,EAAA0C,EAAAnD,GACA,GAAAsC,GAAAtC,EAAAE,OAAAoC,cAEAtC,GAAAuC,QAAAD,MAAAtC,EAAAuC,QAGAY,EAAAF,EACA,mCAAAjD,EAAAuC,OACAvC,EAAAE,OACA,KACAF,EAAAxE,QACAwE,IAPAS,EAAAT,KX+2BM,SAAU7F,EAAQD,EAASM,GY93BjC,YAEA,IAAAiL,GAAAjL,EAAA,GAYAL,GAAAD,QAAA,SAAAwL,EAAAxF,EAAAyF,EAAAnK,EAAAwE,GACA,GAAA4F,GAAA,GAAAC,OAAAH,EACA,OAAAD,GAAAG,EAAA1F,EAAAyF,EAAAnK,EAAAwE,KZs4BM,SAAU7F,EAAQD,Gat5BxB,YAYAC,GAAAD,QAAA,SAAA0L,EAAA1F,EAAAyF,EAAAnK,EAAAwE,GAOA,MANA4F,GAAA1F,SACAyF,IACAC,EAAAD,QAEAC,EAAApK,UACAoK,EAAA5F,WACA4F,Ib85BM,SAAUzL,EAAQD,EAASM,Gcj7BjC,YAIA,SAAAsL,GAAArJ,GACA,MAAAsJ,oBAAAtJ,GACAwB,QAAA,aACAA,QAAA,aACAA,QAAA,YACAA,QAAA,aACAA,QAAA,YACAA,QAAA,aACAA,QAAA,aAVA,GAAAxC,GAAAjB,EAAA,EAoBAL,GAAAD,QAAA,SAAAiG,EAAA6D,EAAAC,GAEA,IAAAD,EACA,MAAA7D,EAGA,IAAA6F,EACA,IAAA/B,EACA+B,EAAA/B,EAAAD,OACG,IAAAvI,EAAAoC,kBAAAmG,GACHgC,EAAAhC,EAAAtH,eACG,CACH,GAAAuJ,KAEAxK,GAAA8C,QAAAyF,EAAA,SAAAvH,EAAAoC,GACA,OAAApC,GAAA,mBAAAA,KAIAhB,EAAAe,QAAAC,GACAoC,GAAA,KAEApC,MAGAhB,EAAA8C,QAAA9B,EAAA,SAAAyJ,GACAzK,EAAA8B,OAAA2I,GACAA,IAAAC,cACS1K,EAAA6B,SAAA4I,KACTA,EAAArE,KAAAC,UAAAoE,IAEAD,EAAAnF,KAAAgF,EAAAjH,GAAA,IAAAiH,EAAAI,SAIAF,EAAAC,EAAAG,KAAA,KAOA,MAJAJ,KACA7F,MAAAiE,QAAA,mBAAA4B,GAGA7F,Idy7BM,SAAUhG,EAAQD,EAASM,Gez/BjC,YAEA,IAAAiB,GAAAjB,EAAA,GAIA6L,GACA,6DACA,kEACA,gEACA,qCAgBAlM,GAAAD,QAAA,SAAAiH,GACA,GACAtC,GACApC,EACAiC,EAHA4H,IAKA,OAAAnF,IAEA1F,EAAA8C,QAAA4C,EAAAoF,MAAA,eAAAC,GAKA,GAJA9H,EAAA8H,EAAApC,QAAA,KACAvF,EAAApD,EAAAsC,KAAAyI,EAAAC,OAAA,EAAA/H,IAAA2B,cACA5D,EAAAhB,EAAAsC,KAAAyI,EAAAC,OAAA/H,EAAA,IAEAG,EAAA,CACA,GAAAyH,EAAAzH,IAAAwH,EAAAjC,QAAAvF,IAAA,EACA,MAEA,gBAAAA,EACAyH,EAAAzH,IAAAyH,EAAAzH,GAAAyH,EAAAzH,OAAA6H,QAAAjK,IAEA6J,EAAAzH,GAAAyH,EAAAzH,GAAAyH,EAAAzH,GAAA,KAAApC,OAKA6J,GAnBiBA,IfohCX,SAAUnM,EAAQD,EAASM,GgBpjCjC,YAEA,IAAAiB,GAAAjB,EAAA,EAEAL,GAAAD,QACAuB,EAAAyC,uBAIA,WAWA,QAAAyI,GAAAxG,GACA,GAAAyG,GAAAzG,CAWA,OATA0G,KAEAC,EAAAC,aAAA,OAAAH,GACAA,EAAAE,EAAAF,MAGAE,EAAAC,aAAA,OAAAH,IAIAA,KAAAE,EAAAF,KACAI,SAAAF,EAAAE,SAAAF,EAAAE,SAAA/I,QAAA,YACAgJ,KAAAH,EAAAG,KACAC,OAAAJ,EAAAI,OAAAJ,EAAAI,OAAAjJ,QAAA,aACAkJ,KAAAL,EAAAK,KAAAL,EAAAK,KAAAlJ,QAAA,YACAmJ,SAAAN,EAAAM,SACAC,KAAAP,EAAAO,KACAC,SAAA,MAAAR,EAAAQ,SAAAC,OAAA,GACAT,EAAAQ,SACA,IAAAR,EAAAQ,UAhCA,GAEAE,GAFAX,EAAA,kBAAAY,KAAAtJ,UAAAuJ,WACAZ,EAAAxI,SAAAqJ,cAAA,IA2CA,OARAH,GAAAb,EAAAtI,OAAAuJ,SAAAhB,MAQA,SAAAiB,GACA,GAAAvB,GAAA7K,EAAA0B,SAAA0K,GAAAlB,EAAAkB,IACA,OAAAvB,GAAAU,WAAAQ,EAAAR,UACAV,EAAAW,OAAAO,EAAAP,SAKA,WACA,kBACA,chB8jCM,SAAU9M,EAAQD,GiB9nCxB,YAMA,SAAA4N,KACAxN,KAAAoL,QAAA,uCAMA,QAAAxC,GAAA6E,GAGA,IAEA,GAAAC,GAAAC,EAJAjK,EAAAkK,OAAAH,GACAI,EAAA,GAGAC,EAAA,EAAAC,EAAAC,EAIAtK,EAAAuJ,OAAA,EAAAa,KAAAC,EAAA,IAAAD,EAAA,GAEAD,GAAAE,EAAAd,OAAA,GAAAS,GAAA,EAAAI,EAAA,KACA,CAEA,GADAH,EAAAjK,EAAAuK,WAAAH,GAAA,KACAH,EAAA,IACA,SAAAH,EAEAE,MAAA,EAAAC,EAEA,MAAAE,GA5BA,GAAAG,GAAA,mEAKAR,GAAAvM,UAAA,GAAAsK,OACAiC,EAAAvM,UAAAoK,KAAA,EACAmC,EAAAvM,UAAAoH,KAAA,wBAwBAxI,EAAAD,QAAAgJ,GjBqoCM,SAAU/I,EAAQD,EAASM,GkBxqCjC,YAEA,IAAAiB,GAAAjB,EAAA,EAEAL,GAAAD,QACAuB,EAAAyC,uBAGA,WACA,OACAsK,MAAA,SAAA7F,EAAAvB,EAAAqH,EAAAC,EAAAC,EAAAC,GACA,GAAAC,KACAA,GAAA/H,KAAA6B,EAAA,IAAAoD,mBAAA3E,IAEA3F,EAAA2B,SAAAqL,IACAI,EAAA/H,KAAA,cAAAgI,MAAAL,GAAAM,eAGAtN,EAAA0B,SAAAuL,IACAG,EAAA/H,KAAA,QAAA4H,GAGAjN,EAAA0B,SAAAwL,IACAE,EAAA/H,KAAA,UAAA6H,GAGAC,KAAA,GACAC,EAAA/H,KAAA,UAGAxC,SAAAuK,SAAAzC,KAAA,OAGArB,KAAA,SAAApC,GACA,GAAAqG,GAAA1K,SAAAuK,OAAAG,MAAA,GAAAC,QAAA,aAA0DtG,EAAA,aAC1D,OAAAqG,GAAAE,mBAAAF,EAAA,UAGAG,OAAA,SAAAxG,GACArI,KAAAkO,MAAA7F,EAAA,GAAAmG,KAAAM,MAAA,YAMA,WACA,OACAZ,MAAA,aACAzD,KAAA,WAA6B,aAC7BoE,OAAA,kBlBkrCM,SAAUhP,EAAQD,EAASM,GmBnuCjC,YAIA,SAAAuF,KACAzF,KAAA+O,YAHA,GAAA5N,GAAAjB,EAAA,EAcAuF,GAAAxE,UAAA+N,IAAA,SAAA1I,EAAAC,GAKA,MAJAvG,MAAA+O,SAAAvI,MACAF,YACAC,aAEAvG,KAAA+O,SAAAzK,OAAA,GAQAmB,EAAAxE,UAAAgO,MAAA,SAAA5O,GACAL,KAAA+O,SAAA1O,KACAL,KAAA+O,SAAA1O,GAAA,OAYAoF,EAAAxE,UAAAgD,QAAA,SAAAE,GACAhD,EAAA8C,QAAAjE,KAAA+O,SAAA,SAAAG,GACA,OAAAA,GACA/K,EAAA+K,MAKArP,EAAAD,QAAA6F,GnB0uCM,SAAU5F,EAAQD,EAASM,GoB7xCjC,YAYA,SAAAiP,GAAAvJ,GACAA,EAAAmF,aACAnF,EAAAmF,YAAAqE,mBAZA,GAAAjO,GAAAjB,EAAA,GACAmP,EAAAnP,EAAA,IACA0B,EAAA1B,EAAA,IACAmB,EAAAnB,EAAA,GACAoP,EAAApP,EAAA,IACAqP,EAAArP,EAAA,GAiBAL,GAAAD,QAAA,SAAAgG,GACAuJ,EAAAvJ,GAGAA,EAAA4J,UAAAF,EAAA1J,EAAAC,OACAD,EAAAC,IAAA0J,EAAA3J,EAAA4J,QAAA5J,EAAAC,MAIAD,EAAAiB,QAAAjB,EAAAiB,YAGAjB,EAAAe,KAAA0I,EACAzJ,EAAAe,KACAf,EAAAiB,QACAjB,EAAA0B,kBAIA1B,EAAAiB,QAAA1F,EAAAM,MACAmE,EAAAiB,QAAAqB,WACAtC,EAAAiB,QAAAjB,EAAAE,YACAF,EAAAiB,aAGA1F,EAAA8C,SACA,qDACA,SAAA6B,SACAF,GAAAiB,QAAAf,IAIA,IAAAkB,GAAApB,EAAAoB,SAAA3F,EAAA2F,OAEA,OAAAA,GAAApB,GAAAa,KAAA,SAAAf,GAUA,MATAyJ,GAAAvJ,GAGAF,EAAAiB,KAAA0I,EACA3J,EAAAiB,KACAjB,EAAAmB,QACAjB,EAAA6B,mBAGA/B,GACG,SAAA+J,GAcH,MAbA7N,GAAA6N,KACAN,EAAAvJ,GAGA6J,KAAA/J,WACA+J,EAAA/J,SAAAiB,KAAA0I,EACAI,EAAA/J,SAAAiB,KACA8I,EAAA/J,SAAAmB,QACAjB,EAAA6B,qBAKA1F,QAAA8G,OAAA4G,OpBsyCM,SAAU5P,EAAQD,EAASM,GqBz3CjC,YAEA,IAAAiB,GAAAjB,EAAA,EAUAL,GAAAD,QAAA,SAAA+G,EAAAE,EAAA6I,GAMA,MAJAvO,GAAA8C,QAAAyL,EAAA,SAAAvL,GACAwC,EAAAxC,EAAAwC,EAAAE,KAGAF,IrBi4CM,SAAU9G,EAAQD,GsBn5CxB,YAEAC,GAAAD,QAAA,SAAAkH,GACA,SAAAA,MAAA6I,ctB25CM,SAAU9P,EAAQD,GuB95CxB,YAQAC,GAAAD,QAAA,SAAAiG,GAIA,sCAAAsH,KAAAtH,KvBs6CM,SAAUhG,EAAQD,GwBl7CxB,YASAC,GAAAD,QAAA,SAAA4P,EAAAI,GACA,MAAAA,GACAJ,EAAA7L,QAAA,eAAAiM,EAAAjM,QAAA,WACA6L,IxB07CM,SAAU3P,EAAQD,GyBt8CxB,YAQA,SAAA8B,GAAA0J,GACApL,KAAAoL,UAGA1J,EAAAT,UAAAmB,SAAA,WACA,gBAAApC,KAAAoL,QAAA,KAAApL,KAAAoL,QAAA,KAGA1J,EAAAT,UAAA0O,YAAA,EAEA9P,EAAAD,QAAA8B,GzB68CM,SAAU7B,EAAQD,EAASM,G0B/9CjC,YAUA,SAAAyB,GAAAkO,GACA,qBAAAA,GACA,SAAAC,WAAA,+BAGA,IAAAC,EACA/P,MAAAkG,QAAA,GAAAnE,SAAA,SAAAoE,GACA4J,EAAA5J,GAGA,IAAA6J,GAAAhQ,IACA6P,GAAA,SAAAzE,GACA4E,EAAAP,SAKAO,EAAAP,OAAA,GAAA/N,GAAA0J,GACA2E,EAAAC,EAAAP,WA1BA,GAAA/N,GAAAxB,EAAA,GAiCAyB,GAAAV,UAAAmO,iBAAA,WACA,GAAApP,KAAAyP,OACA,KAAAzP,MAAAyP,QAQA9N,EAAAsO,OAAA,WACA,GAAAjF,GACAgF,EAAA,GAAArO,GAAA,SAAAlB,GACAuK,EAAAvK,GAEA,QACAuP,QACAhF,WAIAnL,EAAAD,QAAA+B,G1Bs+CM,SAAU9B,EAAQD,G2B9hDxB,YAsBAC,GAAAD,QAAA,SAAAsQ,GACA,gBAAAC,GACA,MAAAD,GAAAhL,MAAA,KAAAiL","file":"axios.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(1);\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar bind = __webpack_require__(3);\n\tvar Axios = __webpack_require__(5);\n\tvar defaults = __webpack_require__(6);\n\t\n\t/**\n\t * Create an instance of Axios\n\t *\n\t * @param {Object} defaultConfig The default config for the instance\n\t * @return {Axios} A new instance of Axios\n\t */\n\tfunction createInstance(defaultConfig) {\n\t var context = new Axios(defaultConfig);\n\t var instance = bind(Axios.prototype.request, context);\n\t\n\t // Copy axios.prototype to instance\n\t utils.extend(instance, Axios.prototype, context);\n\t\n\t // Copy context to instance\n\t utils.extend(instance, context);\n\t\n\t return instance;\n\t}\n\t\n\t// Create the default instance to be exported\n\tvar axios = createInstance(defaults);\n\t\n\t// Expose Axios class to allow class inheritance\n\taxios.Axios = Axios;\n\t\n\t// Factory for creating new instances\n\taxios.create = function create(instanceConfig) {\n\t return createInstance(utils.merge(defaults, instanceConfig));\n\t};\n\t\n\t// Expose Cancel & CancelToken\n\taxios.Cancel = __webpack_require__(23);\n\taxios.CancelToken = __webpack_require__(24);\n\taxios.isCancel = __webpack_require__(20);\n\t\n\t// Expose all/spread\n\taxios.all = function all(promises) {\n\t return Promise.all(promises);\n\t};\n\taxios.spread = __webpack_require__(25);\n\t\n\tmodule.exports = axios;\n\t\n\t// Allow use of default import syntax in TypeScript\n\tmodule.exports.default = axios;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar bind = __webpack_require__(3);\n\tvar isBuffer = __webpack_require__(4);\n\t\n\t/*global toString:true*/\n\t\n\t// utils is a library of generic helper functions non-specific to axios\n\t\n\tvar toString = Object.prototype.toString;\n\t\n\t/**\n\t * Determine if a value is an Array\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Array, otherwise false\n\t */\n\tfunction isArray(val) {\n\t return toString.call(val) === '[object Array]';\n\t}\n\t\n\t/**\n\t * Determine if a value is an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBuffer(val) {\n\t return toString.call(val) === '[object ArrayBuffer]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a FormData\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an FormData, otherwise false\n\t */\n\tfunction isFormData(val) {\n\t return (typeof FormData !== 'undefined') && (val instanceof FormData);\n\t}\n\t\n\t/**\n\t * Determine if a value is a view on an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBufferView(val) {\n\t var result;\n\t if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n\t result = ArrayBuffer.isView(val);\n\t } else {\n\t result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Determine if a value is a String\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a String, otherwise false\n\t */\n\tfunction isString(val) {\n\t return typeof val === 'string';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Number\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Number, otherwise false\n\t */\n\tfunction isNumber(val) {\n\t return typeof val === 'number';\n\t}\n\t\n\t/**\n\t * Determine if a value is undefined\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if the value is undefined, otherwise false\n\t */\n\tfunction isUndefined(val) {\n\t return typeof val === 'undefined';\n\t}\n\t\n\t/**\n\t * Determine if a value is an Object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Object, otherwise false\n\t */\n\tfunction isObject(val) {\n\t return val !== null && typeof val === 'object';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Date\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Date, otherwise false\n\t */\n\tfunction isDate(val) {\n\t return toString.call(val) === '[object Date]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a File\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a File, otherwise false\n\t */\n\tfunction isFile(val) {\n\t return toString.call(val) === '[object File]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Blob\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Blob, otherwise false\n\t */\n\tfunction isBlob(val) {\n\t return toString.call(val) === '[object Blob]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Function\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Function, otherwise false\n\t */\n\tfunction isFunction(val) {\n\t return toString.call(val) === '[object Function]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Stream\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Stream, otherwise false\n\t */\n\tfunction isStream(val) {\n\t return isObject(val) && isFunction(val.pipe);\n\t}\n\t\n\t/**\n\t * Determine if a value is a URLSearchParams object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n\t */\n\tfunction isURLSearchParams(val) {\n\t return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n\t}\n\t\n\t/**\n\t * Trim excess whitespace off the beginning and end of a string\n\t *\n\t * @param {String} str The String to trim\n\t * @returns {String} The String freed of excess whitespace\n\t */\n\tfunction trim(str) {\n\t return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n\t}\n\t\n\t/**\n\t * Determine if we're running in a standard browser environment\n\t *\n\t * This allows axios to run in a web worker, and react-native.\n\t * Both environments support XMLHttpRequest, but not fully standard globals.\n\t *\n\t * web workers:\n\t * typeof window -> undefined\n\t * typeof document -> undefined\n\t *\n\t * react-native:\n\t * navigator.product -> 'ReactNative'\n\t */\n\tfunction isStandardBrowserEnv() {\n\t if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n\t return false;\n\t }\n\t return (\n\t typeof window !== 'undefined' &&\n\t typeof document !== 'undefined'\n\t );\n\t}\n\t\n\t/**\n\t * Iterate over an Array or an Object invoking a function for each item.\n\t *\n\t * If `obj` is an Array callback will be called passing\n\t * the value, index, and complete array for each item.\n\t *\n\t * If 'obj' is an Object callback will be called passing\n\t * the value, key, and complete object for each property.\n\t *\n\t * @param {Object|Array} obj The object to iterate\n\t * @param {Function} fn The callback to invoke for each item\n\t */\n\tfunction forEach(obj, fn) {\n\t // Don't bother if no value provided\n\t if (obj === null || typeof obj === 'undefined') {\n\t return;\n\t }\n\t\n\t // Force an array if not already something iterable\n\t if (typeof obj !== 'object') {\n\t /*eslint no-param-reassign:0*/\n\t obj = [obj];\n\t }\n\t\n\t if (isArray(obj)) {\n\t // Iterate over array values\n\t for (var i = 0, l = obj.length; i < l; i++) {\n\t fn.call(null, obj[i], i, obj);\n\t }\n\t } else {\n\t // Iterate over object keys\n\t for (var key in obj) {\n\t if (Object.prototype.hasOwnProperty.call(obj, key)) {\n\t fn.call(null, obj[key], key, obj);\n\t }\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Accepts varargs expecting each argument to be an object, then\n\t * immutably merges the properties of each object and returns result.\n\t *\n\t * When multiple objects contain the same key the later object in\n\t * the arguments list will take precedence.\n\t *\n\t * Example:\n\t *\n\t * ```js\n\t * var result = merge({foo: 123}, {foo: 456});\n\t * console.log(result.foo); // outputs 456\n\t * ```\n\t *\n\t * @param {Object} obj1 Object to merge\n\t * @returns {Object} Result of all merge properties\n\t */\n\tfunction merge(/* obj1, obj2, obj3, ... */) {\n\t var result = {};\n\t function assignValue(val, key) {\n\t if (typeof result[key] === 'object' && typeof val === 'object') {\n\t result[key] = merge(result[key], val);\n\t } else {\n\t result[key] = val;\n\t }\n\t }\n\t\n\t for (var i = 0, l = arguments.length; i < l; i++) {\n\t forEach(arguments[i], assignValue);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Extends object a by mutably adding to it the properties of object b.\n\t *\n\t * @param {Object} a The object to be extended\n\t * @param {Object} b The object to copy properties from\n\t * @param {Object} thisArg The object to bind function to\n\t * @return {Object} The resulting value of object a\n\t */\n\tfunction extend(a, b, thisArg) {\n\t forEach(b, function assignValue(val, key) {\n\t if (thisArg && typeof val === 'function') {\n\t a[key] = bind(val, thisArg);\n\t } else {\n\t a[key] = val;\n\t }\n\t });\n\t return a;\n\t}\n\t\n\tmodule.exports = {\n\t isArray: isArray,\n\t isArrayBuffer: isArrayBuffer,\n\t isBuffer: isBuffer,\n\t isFormData: isFormData,\n\t isArrayBufferView: isArrayBufferView,\n\t isString: isString,\n\t isNumber: isNumber,\n\t isObject: isObject,\n\t isUndefined: isUndefined,\n\t isDate: isDate,\n\t isFile: isFile,\n\t isBlob: isBlob,\n\t isFunction: isFunction,\n\t isStream: isStream,\n\t isURLSearchParams: isURLSearchParams,\n\t isStandardBrowserEnv: isStandardBrowserEnv,\n\t forEach: forEach,\n\t merge: merge,\n\t extend: extend,\n\t trim: trim\n\t};\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function bind(fn, thisArg) {\n\t return function wrap() {\n\t var args = new Array(arguments.length);\n\t for (var i = 0; i < args.length; i++) {\n\t args[i] = arguments[i];\n\t }\n\t return fn.apply(thisArg, args);\n\t };\n\t};\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\n\t/*!\n\t * Determine if an object is a Buffer\n\t *\n\t * @author Feross Aboukhadijeh \n\t * @license MIT\n\t */\n\t\n\t// The _isBuffer check is for Safari 5-7 support, because it's missing\n\t// Object.prototype.constructor. Remove this eventually\n\tmodule.exports = function (obj) {\n\t return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)\n\t}\n\t\n\tfunction isBuffer (obj) {\n\t return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n\t}\n\t\n\t// For Node v0.10 support. Remove this eventually.\n\tfunction isSlowBuffer (obj) {\n\t return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))\n\t}\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar defaults = __webpack_require__(6);\n\tvar utils = __webpack_require__(2);\n\tvar InterceptorManager = __webpack_require__(17);\n\tvar dispatchRequest = __webpack_require__(18);\n\t\n\t/**\n\t * Create a new instance of Axios\n\t *\n\t * @param {Object} instanceConfig The default config for the instance\n\t */\n\tfunction Axios(instanceConfig) {\n\t this.defaults = instanceConfig;\n\t this.interceptors = {\n\t request: new InterceptorManager(),\n\t response: new InterceptorManager()\n\t };\n\t}\n\t\n\t/**\n\t * Dispatch a request\n\t *\n\t * @param {Object} config The config specific for this request (merged with this.defaults)\n\t */\n\tAxios.prototype.request = function request(config) {\n\t /*eslint no-param-reassign:0*/\n\t // Allow for axios('example/url'[, config]) a la fetch API\n\t if (typeof config === 'string') {\n\t config = utils.merge({\n\t url: arguments[0]\n\t }, arguments[1]);\n\t }\n\t\n\t config = utils.merge(defaults, {method: 'get'}, this.defaults, config);\n\t config.method = config.method.toLowerCase();\n\t\n\t // Hook up interceptors middleware\n\t var chain = [dispatchRequest, undefined];\n\t var promise = Promise.resolve(config);\n\t\n\t this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n\t chain.unshift(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n\t chain.push(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t while (chain.length) {\n\t promise = promise.then(chain.shift(), chain.shift());\n\t }\n\t\n\t return promise;\n\t};\n\t\n\t// Provide aliases for supported request methods\n\tutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, config) {\n\t return this.request(utils.merge(config || {}, {\n\t method: method,\n\t url: url\n\t }));\n\t };\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, data, config) {\n\t return this.request(utils.merge(config || {}, {\n\t method: method,\n\t url: url,\n\t data: data\n\t }));\n\t };\n\t});\n\t\n\tmodule.exports = Axios;\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar normalizeHeaderName = __webpack_require__(7);\n\t\n\tvar DEFAULT_CONTENT_TYPE = {\n\t 'Content-Type': 'application/x-www-form-urlencoded'\n\t};\n\t\n\tfunction setContentTypeIfUnset(headers, value) {\n\t if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n\t headers['Content-Type'] = value;\n\t }\n\t}\n\t\n\tfunction getDefaultAdapter() {\n\t var adapter;\n\t if (typeof XMLHttpRequest !== 'undefined') {\n\t // For browsers use XHR adapter\n\t adapter = __webpack_require__(8);\n\t } else if (typeof process !== 'undefined') {\n\t // For node use HTTP adapter\n\t adapter = __webpack_require__(8);\n\t }\n\t return adapter;\n\t}\n\t\n\tvar defaults = {\n\t adapter: getDefaultAdapter(),\n\t\n\t transformRequest: [function transformRequest(data, headers) {\n\t normalizeHeaderName(headers, 'Content-Type');\n\t if (utils.isFormData(data) ||\n\t utils.isArrayBuffer(data) ||\n\t utils.isBuffer(data) ||\n\t utils.isStream(data) ||\n\t utils.isFile(data) ||\n\t utils.isBlob(data)\n\t ) {\n\t return data;\n\t }\n\t if (utils.isArrayBufferView(data)) {\n\t return data.buffer;\n\t }\n\t if (utils.isURLSearchParams(data)) {\n\t setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n\t return data.toString();\n\t }\n\t if (utils.isObject(data)) {\n\t setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n\t return JSON.stringify(data);\n\t }\n\t return data;\n\t }],\n\t\n\t transformResponse: [function transformResponse(data) {\n\t /*eslint no-param-reassign:0*/\n\t if (typeof data === 'string') {\n\t try {\n\t data = JSON.parse(data);\n\t } catch (e) { /* Ignore */ }\n\t }\n\t return data;\n\t }],\n\t\n\t /**\n\t * A timeout in milliseconds to abort a request. If set to 0 (default) a\n\t * timeout is not created.\n\t */\n\t timeout: 0,\n\t\n\t xsrfCookieName: 'XSRF-TOKEN',\n\t xsrfHeaderName: 'X-XSRF-TOKEN',\n\t\n\t maxContentLength: -1,\n\t\n\t validateStatus: function validateStatus(status) {\n\t return status >= 200 && status < 300;\n\t }\n\t};\n\t\n\tdefaults.headers = {\n\t common: {\n\t 'Accept': 'application/json, text/plain, */*'\n\t }\n\t};\n\t\n\tutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n\t defaults.headers[method] = {};\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n\t});\n\t\n\tmodule.exports = defaults;\n\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n\t utils.forEach(headers, function processHeader(value, name) {\n\t if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n\t headers[normalizedName] = value;\n\t delete headers[name];\n\t }\n\t });\n\t};\n\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar settle = __webpack_require__(9);\n\tvar buildURL = __webpack_require__(12);\n\tvar parseHeaders = __webpack_require__(13);\n\tvar isURLSameOrigin = __webpack_require__(14);\n\tvar createError = __webpack_require__(10);\n\tvar btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15);\n\t\n\tmodule.exports = function xhrAdapter(config) {\n\t return new Promise(function dispatchXhrRequest(resolve, reject) {\n\t var requestData = config.data;\n\t var requestHeaders = config.headers;\n\t\n\t if (utils.isFormData(requestData)) {\n\t delete requestHeaders['Content-Type']; // Let the browser set it\n\t }\n\t\n\t var request = new XMLHttpRequest();\n\t var loadEvent = 'onreadystatechange';\n\t var xDomain = false;\n\t\n\t // For IE 8/9 CORS support\n\t // Only supports POST and GET calls and doesn't returns the response headers.\n\t // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.\n\t if ((\"production\") !== 'test' &&\n\t typeof window !== 'undefined' &&\n\t window.XDomainRequest && !('withCredentials' in request) &&\n\t !isURLSameOrigin(config.url)) {\n\t request = new window.XDomainRequest();\n\t loadEvent = 'onload';\n\t xDomain = true;\n\t request.onprogress = function handleProgress() {};\n\t request.ontimeout = function handleTimeout() {};\n\t }\n\t\n\t // HTTP basic authentication\n\t if (config.auth) {\n\t var username = config.auth.username || '';\n\t var password = config.auth.password || '';\n\t requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n\t }\n\t\n\t request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\t\n\t // Set the request timeout in MS\n\t request.timeout = config.timeout;\n\t\n\t // Listen for ready state\n\t request[loadEvent] = function handleLoad() {\n\t if (!request || (request.readyState !== 4 && !xDomain)) {\n\t return;\n\t }\n\t\n\t // The request errored out and we didn't get a response, this will be\n\t // handled by onerror instead\n\t // With one exception: request that using file: protocol, most browsers\n\t // will return status as 0 even though it's a successful request\n\t if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n\t return;\n\t }\n\t\n\t // Prepare the response\n\t var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n\t var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n\t var response = {\n\t data: responseData,\n\t // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)\n\t status: request.status === 1223 ? 204 : request.status,\n\t statusText: request.status === 1223 ? 'No Content' : request.statusText,\n\t headers: responseHeaders,\n\t config: config,\n\t request: request\n\t };\n\t\n\t settle(resolve, reject, response);\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle low level network errors\n\t request.onerror = function handleError() {\n\t // Real errors are hidden from us by the browser\n\t // onerror should only fire if it's a network error\n\t reject(createError('Network Error', config, null, request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle timeout\n\t request.ontimeout = function handleTimeout() {\n\t reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',\n\t request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Add xsrf header\n\t // This is only done if running in a standard browser environment.\n\t // Specifically not if we're in a web worker, or react-native.\n\t if (utils.isStandardBrowserEnv()) {\n\t var cookies = __webpack_require__(16);\n\t\n\t // Add xsrf header\n\t var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?\n\t cookies.read(config.xsrfCookieName) :\n\t undefined;\n\t\n\t if (xsrfValue) {\n\t requestHeaders[config.xsrfHeaderName] = xsrfValue;\n\t }\n\t }\n\t\n\t // Add headers to the request\n\t if ('setRequestHeader' in request) {\n\t utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n\t if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n\t // Remove Content-Type if data is undefined\n\t delete requestHeaders[key];\n\t } else {\n\t // Otherwise add header to the request\n\t request.setRequestHeader(key, val);\n\t }\n\t });\n\t }\n\t\n\t // Add withCredentials to request if needed\n\t if (config.withCredentials) {\n\t request.withCredentials = true;\n\t }\n\t\n\t // Add responseType to request if needed\n\t if (config.responseType) {\n\t try {\n\t request.responseType = config.responseType;\n\t } catch (e) {\n\t // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n\t // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n\t if (config.responseType !== 'json') {\n\t throw e;\n\t }\n\t }\n\t }\n\t\n\t // Handle progress if needed\n\t if (typeof config.onDownloadProgress === 'function') {\n\t request.addEventListener('progress', config.onDownloadProgress);\n\t }\n\t\n\t // Not all browsers support upload events\n\t if (typeof config.onUploadProgress === 'function' && request.upload) {\n\t request.upload.addEventListener('progress', config.onUploadProgress);\n\t }\n\t\n\t if (config.cancelToken) {\n\t // Handle cancellation\n\t config.cancelToken.promise.then(function onCanceled(cancel) {\n\t if (!request) {\n\t return;\n\t }\n\t\n\t request.abort();\n\t reject(cancel);\n\t // Clean up request\n\t request = null;\n\t });\n\t }\n\t\n\t if (requestData === undefined) {\n\t requestData = null;\n\t }\n\t\n\t // Send the request\n\t request.send(requestData);\n\t });\n\t};\n\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar createError = __webpack_require__(10);\n\t\n\t/**\n\t * Resolve or reject a Promise based on response status.\n\t *\n\t * @param {Function} resolve A function that resolves the promise.\n\t * @param {Function} reject A function that rejects the promise.\n\t * @param {object} response The response.\n\t */\n\tmodule.exports = function settle(resolve, reject, response) {\n\t var validateStatus = response.config.validateStatus;\n\t // Note: status is not exposed by XDomainRequest\n\t if (!response.status || !validateStatus || validateStatus(response.status)) {\n\t resolve(response);\n\t } else {\n\t reject(createError(\n\t 'Request failed with status code ' + response.status,\n\t response.config,\n\t null,\n\t response.request,\n\t response\n\t ));\n\t }\n\t};\n\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar enhanceError = __webpack_require__(11);\n\t\n\t/**\n\t * Create an Error with the specified message, config, error code, request and response.\n\t *\n\t * @param {string} message The error message.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t * @param {Object} [request] The request.\n\t * @param {Object} [response] The response.\n\t * @returns {Error} The created error.\n\t */\n\tmodule.exports = function createError(message, config, code, request, response) {\n\t var error = new Error(message);\n\t return enhanceError(error, config, code, request, response);\n\t};\n\n\n/***/ }),\n/* 11 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Update an Error with the specified config, error code, and response.\n\t *\n\t * @param {Error} error The error to update.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t * @param {Object} [request] The request.\n\t * @param {Object} [response] The response.\n\t * @returns {Error} The error.\n\t */\n\tmodule.exports = function enhanceError(error, config, code, request, response) {\n\t error.config = config;\n\t if (code) {\n\t error.code = code;\n\t }\n\t error.request = request;\n\t error.response = response;\n\t return error;\n\t};\n\n\n/***/ }),\n/* 12 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction encode(val) {\n\t return encodeURIComponent(val).\n\t replace(/%40/gi, '@').\n\t replace(/%3A/gi, ':').\n\t replace(/%24/g, '$').\n\t replace(/%2C/gi, ',').\n\t replace(/%20/g, '+').\n\t replace(/%5B/gi, '[').\n\t replace(/%5D/gi, ']');\n\t}\n\t\n\t/**\n\t * Build a URL by appending params to the end\n\t *\n\t * @param {string} url The base of the url (e.g., http://www.google.com)\n\t * @param {object} [params] The params to be appended\n\t * @returns {string} The formatted url\n\t */\n\tmodule.exports = function buildURL(url, params, paramsSerializer) {\n\t /*eslint no-param-reassign:0*/\n\t if (!params) {\n\t return url;\n\t }\n\t\n\t var serializedParams;\n\t if (paramsSerializer) {\n\t serializedParams = paramsSerializer(params);\n\t } else if (utils.isURLSearchParams(params)) {\n\t serializedParams = params.toString();\n\t } else {\n\t var parts = [];\n\t\n\t utils.forEach(params, function serialize(val, key) {\n\t if (val === null || typeof val === 'undefined') {\n\t return;\n\t }\n\t\n\t if (utils.isArray(val)) {\n\t key = key + '[]';\n\t } else {\n\t val = [val];\n\t }\n\t\n\t utils.forEach(val, function parseValue(v) {\n\t if (utils.isDate(v)) {\n\t v = v.toISOString();\n\t } else if (utils.isObject(v)) {\n\t v = JSON.stringify(v);\n\t }\n\t parts.push(encode(key) + '=' + encode(v));\n\t });\n\t });\n\t\n\t serializedParams = parts.join('&');\n\t }\n\t\n\t if (serializedParams) {\n\t url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n\t }\n\t\n\t return url;\n\t};\n\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t// Headers whose duplicates are ignored by node\n\t// c.f. https://nodejs.org/api/http.html#http_message_headers\n\tvar ignoreDuplicateOf = [\n\t 'age', 'authorization', 'content-length', 'content-type', 'etag',\n\t 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n\t 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n\t 'referer', 'retry-after', 'user-agent'\n\t];\n\t\n\t/**\n\t * Parse headers into an object\n\t *\n\t * ```\n\t * Date: Wed, 27 Aug 2014 08:58:49 GMT\n\t * Content-Type: application/json\n\t * Connection: keep-alive\n\t * Transfer-Encoding: chunked\n\t * ```\n\t *\n\t * @param {String} headers Headers needing to be parsed\n\t * @returns {Object} Headers parsed into an object\n\t */\n\tmodule.exports = function parseHeaders(headers) {\n\t var parsed = {};\n\t var key;\n\t var val;\n\t var i;\n\t\n\t if (!headers) { return parsed; }\n\t\n\t utils.forEach(headers.split('\\n'), function parser(line) {\n\t i = line.indexOf(':');\n\t key = utils.trim(line.substr(0, i)).toLowerCase();\n\t val = utils.trim(line.substr(i + 1));\n\t\n\t if (key) {\n\t if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n\t return;\n\t }\n\t if (key === 'set-cookie') {\n\t parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n\t } else {\n\t parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n\t }\n\t }\n\t });\n\t\n\t return parsed;\n\t};\n\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs have full support of the APIs needed to test\n\t // whether the request URL is of the same origin as current location.\n\t (function standardBrowserEnv() {\n\t var msie = /(msie|trident)/i.test(navigator.userAgent);\n\t var urlParsingNode = document.createElement('a');\n\t var originURL;\n\t\n\t /**\n\t * Parse a URL to discover it's components\n\t *\n\t * @param {String} url The URL to be parsed\n\t * @returns {Object}\n\t */\n\t function resolveURL(url) {\n\t var href = url;\n\t\n\t if (msie) {\n\t // IE needs attribute set twice to normalize properties\n\t urlParsingNode.setAttribute('href', href);\n\t href = urlParsingNode.href;\n\t }\n\t\n\t urlParsingNode.setAttribute('href', href);\n\t\n\t // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n\t return {\n\t href: urlParsingNode.href,\n\t protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n\t host: urlParsingNode.host,\n\t search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n\t hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n\t hostname: urlParsingNode.hostname,\n\t port: urlParsingNode.port,\n\t pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n\t urlParsingNode.pathname :\n\t '/' + urlParsingNode.pathname\n\t };\n\t }\n\t\n\t originURL = resolveURL(window.location.href);\n\t\n\t /**\n\t * Determine if a URL shares the same origin as the current location\n\t *\n\t * @param {String} requestURL The URL to test\n\t * @returns {boolean} True if URL shares the same origin, otherwise false\n\t */\n\t return function isURLSameOrigin(requestURL) {\n\t var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n\t return (parsed.protocol === originURL.protocol &&\n\t parsed.host === originURL.host);\n\t };\n\t })() :\n\t\n\t // Non standard browser envs (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return function isURLSameOrigin() {\n\t return true;\n\t };\n\t })()\n\t);\n\n\n/***/ }),\n/* 15 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\t\n\tvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\t\n\tfunction E() {\n\t this.message = 'String contains an invalid character';\n\t}\n\tE.prototype = new Error;\n\tE.prototype.code = 5;\n\tE.prototype.name = 'InvalidCharacterError';\n\t\n\tfunction btoa(input) {\n\t var str = String(input);\n\t var output = '';\n\t for (\n\t // initialize result and counter\n\t var block, charCode, idx = 0, map = chars;\n\t // if the next str index does not exist:\n\t // change the mapping table to \"=\"\n\t // check if d has no fractional digits\n\t str.charAt(idx | 0) || (map = '=', idx % 1);\n\t // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n\t output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n\t ) {\n\t charCode = str.charCodeAt(idx += 3 / 4);\n\t if (charCode > 0xFF) {\n\t throw new E();\n\t }\n\t block = block << 8 | charCode;\n\t }\n\t return output;\n\t}\n\t\n\tmodule.exports = btoa;\n\n\n/***/ }),\n/* 16 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs support document.cookie\n\t (function standardBrowserEnv() {\n\t return {\n\t write: function write(name, value, expires, path, domain, secure) {\n\t var cookie = [];\n\t cookie.push(name + '=' + encodeURIComponent(value));\n\t\n\t if (utils.isNumber(expires)) {\n\t cookie.push('expires=' + new Date(expires).toGMTString());\n\t }\n\t\n\t if (utils.isString(path)) {\n\t cookie.push('path=' + path);\n\t }\n\t\n\t if (utils.isString(domain)) {\n\t cookie.push('domain=' + domain);\n\t }\n\t\n\t if (secure === true) {\n\t cookie.push('secure');\n\t }\n\t\n\t document.cookie = cookie.join('; ');\n\t },\n\t\n\t read: function read(name) {\n\t var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n\t return (match ? decodeURIComponent(match[3]) : null);\n\t },\n\t\n\t remove: function remove(name) {\n\t this.write(name, '', Date.now() - 86400000);\n\t }\n\t };\n\t })() :\n\t\n\t // Non standard browser env (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return {\n\t write: function write() {},\n\t read: function read() { return null; },\n\t remove: function remove() {}\n\t };\n\t })()\n\t);\n\n\n/***/ }),\n/* 17 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction InterceptorManager() {\n\t this.handlers = [];\n\t}\n\t\n\t/**\n\t * Add a new interceptor to the stack\n\t *\n\t * @param {Function} fulfilled The function to handle `then` for a `Promise`\n\t * @param {Function} rejected The function to handle `reject` for a `Promise`\n\t *\n\t * @return {Number} An ID used to remove interceptor later\n\t */\n\tInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n\t this.handlers.push({\n\t fulfilled: fulfilled,\n\t rejected: rejected\n\t });\n\t return this.handlers.length - 1;\n\t};\n\t\n\t/**\n\t * Remove an interceptor from the stack\n\t *\n\t * @param {Number} id The ID that was returned by `use`\n\t */\n\tInterceptorManager.prototype.eject = function eject(id) {\n\t if (this.handlers[id]) {\n\t this.handlers[id] = null;\n\t }\n\t};\n\t\n\t/**\n\t * Iterate over all the registered interceptors\n\t *\n\t * This method is particularly useful for skipping over any\n\t * interceptors that may have become `null` calling `eject`.\n\t *\n\t * @param {Function} fn The function to call for each interceptor\n\t */\n\tInterceptorManager.prototype.forEach = function forEach(fn) {\n\t utils.forEach(this.handlers, function forEachHandler(h) {\n\t if (h !== null) {\n\t fn(h);\n\t }\n\t });\n\t};\n\t\n\tmodule.exports = InterceptorManager;\n\n\n/***/ }),\n/* 18 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar transformData = __webpack_require__(19);\n\tvar isCancel = __webpack_require__(20);\n\tvar defaults = __webpack_require__(6);\n\tvar isAbsoluteURL = __webpack_require__(21);\n\tvar combineURLs = __webpack_require__(22);\n\t\n\t/**\n\t * Throws a `Cancel` if cancellation has been requested.\n\t */\n\tfunction throwIfCancellationRequested(config) {\n\t if (config.cancelToken) {\n\t config.cancelToken.throwIfRequested();\n\t }\n\t}\n\t\n\t/**\n\t * Dispatch a request to the server using the configured adapter.\n\t *\n\t * @param {object} config The config that is to be used for the request\n\t * @returns {Promise} The Promise to be fulfilled\n\t */\n\tmodule.exports = function dispatchRequest(config) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Support baseURL config\n\t if (config.baseURL && !isAbsoluteURL(config.url)) {\n\t config.url = combineURLs(config.baseURL, config.url);\n\t }\n\t\n\t // Ensure headers exist\n\t config.headers = config.headers || {};\n\t\n\t // Transform request data\n\t config.data = transformData(\n\t config.data,\n\t config.headers,\n\t config.transformRequest\n\t );\n\t\n\t // Flatten headers\n\t config.headers = utils.merge(\n\t config.headers.common || {},\n\t config.headers[config.method] || {},\n\t config.headers || {}\n\t );\n\t\n\t utils.forEach(\n\t ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n\t function cleanHeaderConfig(method) {\n\t delete config.headers[method];\n\t }\n\t );\n\t\n\t var adapter = config.adapter || defaults.adapter;\n\t\n\t return adapter(config).then(function onAdapterResolution(response) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Transform response data\n\t response.data = transformData(\n\t response.data,\n\t response.headers,\n\t config.transformResponse\n\t );\n\t\n\t return response;\n\t }, function onAdapterRejection(reason) {\n\t if (!isCancel(reason)) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Transform response data\n\t if (reason && reason.response) {\n\t reason.response.data = transformData(\n\t reason.response.data,\n\t reason.response.headers,\n\t config.transformResponse\n\t );\n\t }\n\t }\n\t\n\t return Promise.reject(reason);\n\t });\n\t};\n\n\n/***/ }),\n/* 19 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Transform the data for a request or a response\n\t *\n\t * @param {Object|String} data The data to be transformed\n\t * @param {Array} headers The headers for the request or response\n\t * @param {Array|Function} fns A single function or Array of functions\n\t * @returns {*} The resulting transformed data\n\t */\n\tmodule.exports = function transformData(data, headers, fns) {\n\t /*eslint no-param-reassign:0*/\n\t utils.forEach(fns, function transform(fn) {\n\t data = fn(data, headers);\n\t });\n\t\n\t return data;\n\t};\n\n\n/***/ }),\n/* 20 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function isCancel(value) {\n\t return !!(value && value.__CANCEL__);\n\t};\n\n\n/***/ }),\n/* 21 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Determines whether the specified URL is absolute\n\t *\n\t * @param {string} url The URL to test\n\t * @returns {boolean} True if the specified URL is absolute, otherwise false\n\t */\n\tmodule.exports = function isAbsoluteURL(url) {\n\t // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n\t // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n\t // by any combination of letters, digits, plus, period, or hyphen.\n\t return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n\t};\n\n\n/***/ }),\n/* 22 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Creates a new URL by combining the specified URLs\n\t *\n\t * @param {string} baseURL The base URL\n\t * @param {string} relativeURL The relative URL\n\t * @returns {string} The combined URL\n\t */\n\tmodule.exports = function combineURLs(baseURL, relativeURL) {\n\t return relativeURL\n\t ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n\t : baseURL;\n\t};\n\n\n/***/ }),\n/* 23 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * A `Cancel` is an object that is thrown when an operation is canceled.\n\t *\n\t * @class\n\t * @param {string=} message The message.\n\t */\n\tfunction Cancel(message) {\n\t this.message = message;\n\t}\n\t\n\tCancel.prototype.toString = function toString() {\n\t return 'Cancel' + (this.message ? ': ' + this.message : '');\n\t};\n\t\n\tCancel.prototype.__CANCEL__ = true;\n\t\n\tmodule.exports = Cancel;\n\n\n/***/ }),\n/* 24 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar Cancel = __webpack_require__(23);\n\t\n\t/**\n\t * A `CancelToken` is an object that can be used to request cancellation of an operation.\n\t *\n\t * @class\n\t * @param {Function} executor The executor function.\n\t */\n\tfunction CancelToken(executor) {\n\t if (typeof executor !== 'function') {\n\t throw new TypeError('executor must be a function.');\n\t }\n\t\n\t var resolvePromise;\n\t this.promise = new Promise(function promiseExecutor(resolve) {\n\t resolvePromise = resolve;\n\t });\n\t\n\t var token = this;\n\t executor(function cancel(message) {\n\t if (token.reason) {\n\t // Cancellation has already been requested\n\t return;\n\t }\n\t\n\t token.reason = new Cancel(message);\n\t resolvePromise(token.reason);\n\t });\n\t}\n\t\n\t/**\n\t * Throws a `Cancel` if cancellation has been requested.\n\t */\n\tCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n\t if (this.reason) {\n\t throw this.reason;\n\t }\n\t};\n\t\n\t/**\n\t * Returns an object that contains a new `CancelToken` and a function that, when called,\n\t * cancels the `CancelToken`.\n\t */\n\tCancelToken.source = function source() {\n\t var cancel;\n\t var token = new CancelToken(function executor(c) {\n\t cancel = c;\n\t });\n\t return {\n\t token: token,\n\t cancel: cancel\n\t };\n\t};\n\t\n\tmodule.exports = CancelToken;\n\n\n/***/ }),\n/* 25 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Syntactic sugar for invoking a function and expanding an array for arguments.\n\t *\n\t * Common use case would be to use `Function.prototype.apply`.\n\t *\n\t * ```js\n\t * function f(x, y, z) {}\n\t * var args = [1, 2, 3];\n\t * f.apply(null, args);\n\t * ```\n\t *\n\t * With `spread` this example can be re-written.\n\t *\n\t * ```js\n\t * spread(function(x, y, z) {})([1, 2, 3]);\n\t * ```\n\t *\n\t * @param {Function} callback\n\t * @returns {Function}\n\t */\n\tmodule.exports = function spread(callback) {\n\t return function wrap(arr) {\n\t return callback.apply(null, arr);\n\t };\n\t};\n\n\n/***/ })\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// axios.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap dad8263224c86c166a30","module.exports = require('./lib/axios');\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./index.js\n// module id = 0\n// module chunks = 0","'use strict';\n\nvar utils = require('./utils');\nvar bind = require('./helpers/bind');\nvar Axios = require('./core/Axios');\nvar defaults = require('./defaults');\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n * @return {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n var context = new Axios(defaultConfig);\n var instance = bind(Axios.prototype.request, context);\n\n // Copy axios.prototype to instance\n utils.extend(instance, Axios.prototype, context);\n\n // Copy context to instance\n utils.extend(instance, context);\n\n return instance;\n}\n\n// Create the default instance to be exported\nvar axios = createInstance(defaults);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios;\n\n// Factory for creating new instances\naxios.create = function create(instanceConfig) {\n return createInstance(utils.merge(defaults, instanceConfig));\n};\n\n// Expose Cancel & CancelToken\naxios.Cancel = require('./cancel/Cancel');\naxios.CancelToken = require('./cancel/CancelToken');\naxios.isCancel = require('./cancel/isCancel');\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\nmodule.exports = axios;\n\n// Allow use of default import syntax in TypeScript\nmodule.exports.default = axios;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/axios.js\n// module id = 1\n// module chunks = 0","'use strict';\n\nvar bind = require('./helpers/bind');\nvar isBuffer = require('is-buffer');\n\n/*global toString:true*/\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return (typeof FormData !== 'undefined') && (val instanceof FormData);\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\nfunction isURLSearchParams(val) {\n return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n */\nfunction isStandardBrowserEnv() {\n if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n return false;\n }\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object') {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (typeof result[key] === 'object' && typeof val === 'object') {\n result[key] = merge(result[key], val);\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n * @return {Object} The resulting value of object a\n */\nfunction extend(a, b, thisArg) {\n forEach(b, function assignValue(val, key) {\n if (thisArg && typeof val === 'function') {\n a[key] = bind(val, thisArg);\n } else {\n a[key] = val;\n }\n });\n return a;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isBuffer: isBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isURLSearchParams: isURLSearchParams,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n extend: extend,\n trim: trim\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/utils.js\n// module id = 2\n// module chunks = 0","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/bind.js\n// module id = 3\n// module chunks = 0","/*!\n * Determine if an object is a Buffer\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n\n// The _isBuffer check is for Safari 5-7 support, because it's missing\n// Object.prototype.constructor. Remove this eventually\nmodule.exports = function (obj) {\n return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)\n}\n\nfunction isBuffer (obj) {\n return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n}\n\n// For Node v0.10 support. Remove this eventually.\nfunction isSlowBuffer (obj) {\n return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/is-buffer/index.js\n// module id = 4\n// module chunks = 0","'use strict';\n\nvar defaults = require('./../defaults');\nvar utils = require('./../utils');\nvar InterceptorManager = require('./InterceptorManager');\nvar dispatchRequest = require('./dispatchRequest');\n\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n */\nfunction Axios(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\n/**\n * Dispatch a request\n *\n * @param {Object} config The config specific for this request (merged with this.defaults)\n */\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = utils.merge({\n url: arguments[0]\n }, arguments[1]);\n }\n\n config = utils.merge(defaults, {method: 'get'}, this.defaults, config);\n config.method = config.method.toLowerCase();\n\n // Hook up interceptors middleware\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url\n }));\n };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n});\n\nmodule.exports = Axios;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/Axios.js\n// module id = 5\n// module chunks = 0","'use strict';\n\nvar utils = require('./utils');\nvar normalizeHeaderName = require('./helpers/normalizeHeaderName');\n\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nfunction setContentTypeIfUnset(headers, value) {\n if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = value;\n }\n}\n\nfunction getDefaultAdapter() {\n var adapter;\n if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('./adapters/xhr');\n } else if (typeof process !== 'undefined') {\n // For node use HTTP adapter\n adapter = require('./adapters/http');\n }\n return adapter;\n}\n\nvar defaults = {\n adapter: getDefaultAdapter(),\n\n transformRequest: [function transformRequest(data, headers) {\n normalizeHeaderName(headers, 'Content-Type');\n if (utils.isFormData(data) ||\n utils.isArrayBuffer(data) ||\n utils.isBuffer(data) ||\n utils.isStream(data) ||\n utils.isFile(data) ||\n utils.isBlob(data)\n ) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isURLSearchParams(data)) {\n setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n return data.toString();\n }\n if (utils.isObject(data)) {\n setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n return JSON.stringify(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponse(data) {\n /*eslint no-param-reassign:0*/\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data);\n } catch (e) { /* Ignore */ }\n }\n return data;\n }],\n\n /**\n * A timeout in milliseconds to abort a request. If set to 0 (default) a\n * timeout is not created.\n */\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n\n maxContentLength: -1,\n\n validateStatus: function validateStatus(status) {\n return status >= 200 && status < 300;\n }\n};\n\ndefaults.headers = {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n }\n};\n\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n defaults.headers[method] = {};\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n});\n\nmodule.exports = defaults;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/defaults.js\n// module id = 6\n// module chunks = 0","'use strict';\n\nvar utils = require('../utils');\n\nmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n utils.forEach(headers, function processHeader(value, name) {\n if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n headers[normalizedName] = value;\n delete headers[name];\n }\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/normalizeHeaderName.js\n// module id = 7\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar buildURL = require('./../helpers/buildURL');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar createError = require('../core/createError');\nvar btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');\n\nmodule.exports = function xhrAdapter(config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n var loadEvent = 'onreadystatechange';\n var xDomain = false;\n\n // For IE 8/9 CORS support\n // Only supports POST and GET calls and doesn't returns the response headers.\n // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.\n if (process.env.NODE_ENV !== 'test' &&\n typeof window !== 'undefined' &&\n window.XDomainRequest && !('withCredentials' in request) &&\n !isURLSameOrigin(config.url)) {\n request = new window.XDomainRequest();\n loadEvent = 'onload';\n xDomain = true;\n request.onprogress = function handleProgress() {};\n request.ontimeout = function handleTimeout() {};\n }\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password || '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n // Listen for ready state\n request[loadEvent] = function handleLoad() {\n if (!request || (request.readyState !== 4 && !xDomain)) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n }\n\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n var response = {\n data: responseData,\n // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)\n status: request.status === 1223 ? 204 : request.status,\n statusText: request.status === 1223 ? 'No Content' : request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n\n settle(resolve, reject, response);\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(createError('Network Error', config, null, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',\n request));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n var cookies = require('./../helpers/cookies');\n\n // Add xsrf header\n var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (config.withCredentials) {\n request.withCredentials = true;\n }\n\n // Add responseType to request if needed\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n if (config.responseType !== 'json') {\n throw e;\n }\n }\n }\n\n // Handle progress if needed\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', config.onDownloadProgress);\n }\n\n // Not all browsers support upload events\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', config.onUploadProgress);\n }\n\n if (config.cancelToken) {\n // Handle cancellation\n config.cancelToken.promise.then(function onCanceled(cancel) {\n if (!request) {\n return;\n }\n\n request.abort();\n reject(cancel);\n // Clean up request\n request = null;\n });\n }\n\n if (requestData === undefined) {\n requestData = null;\n }\n\n // Send the request\n request.send(requestData);\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/adapters/xhr.js\n// module id = 8\n// module chunks = 0","'use strict';\n\nvar createError = require('./createError');\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n // Note: status is not exposed by XDomainRequest\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(createError(\n 'Request failed with status code ' + response.status,\n response.config,\n null,\n response.request,\n response\n ));\n }\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/settle.js\n// module id = 9\n// module chunks = 0","'use strict';\n\nvar enhanceError = require('./enhanceError');\n\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The created error.\n */\nmodule.exports = function createError(message, config, code, request, response) {\n var error = new Error(message);\n return enhanceError(error, config, code, request, response);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/createError.js\n// module id = 10\n// module chunks = 0","'use strict';\n\n/**\n * Update an Error with the specified config, error code, and response.\n *\n * @param {Error} error The error to update.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The error.\n */\nmodule.exports = function enhanceError(error, config, code, request, response) {\n error.config = config;\n if (code) {\n error.code = code;\n }\n error.request = request;\n error.response = response;\n return error;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/enhanceError.js\n// module id = 11\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%40/gi, '@').\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else if (utils.isURLSearchParams(params)) {\n serializedParams = params.toString();\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n } else {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/buildURL.js\n// module id = 12\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\n// Headers whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nvar ignoreDuplicateOf = [\n 'age', 'authorization', 'content-length', 'content-type', 'etag',\n 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n 'referer', 'retry-after', 'user-agent'\n];\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n return;\n }\n if (key === 'set-cookie') {\n parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n }\n });\n\n return parsed;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/parseHeaders.js\n// module id = 13\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isURLSameOrigin.js\n// module id = 14\n// module chunks = 0","'use strict';\n\n// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\nfunction E() {\n this.message = 'String contains an invalid character';\n}\nE.prototype = new Error;\nE.prototype.code = 5;\nE.prototype.name = 'InvalidCharacterError';\n\nfunction btoa(input) {\n var str = String(input);\n var output = '';\n for (\n // initialize result and counter\n var block, charCode, idx = 0, map = chars;\n // if the next str index does not exist:\n // change the mapping table to \"=\"\n // check if d has no fractional digits\n str.charAt(idx | 0) || (map = '=', idx % 1);\n // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n ) {\n charCode = str.charCodeAt(idx += 3 / 4);\n if (charCode > 0xFF) {\n throw new E();\n }\n block = block << 8 | charCode;\n }\n return output;\n}\n\nmodule.exports = btoa;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/btoa.js\n// module id = 15\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/cookies.js\n// module id = 16\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/InterceptorManager.js\n// module id = 17\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar transformData = require('./transformData');\nvar isCancel = require('../cancel/isCancel');\nvar defaults = require('../defaults');\nvar isAbsoluteURL = require('./../helpers/isAbsoluteURL');\nvar combineURLs = require('./../helpers/combineURLs');\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nfunction throwIfCancellationRequested(config) {\n if (config.cancelToken) {\n config.cancelToken.throwIfRequested();\n }\n}\n\n/**\n * Dispatch a request to the server using the configured adapter.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n throwIfCancellationRequested(config);\n\n // Support baseURL config\n if (config.baseURL && !isAbsoluteURL(config.url)) {\n config.url = combineURLs(config.baseURL, config.url);\n }\n\n // Ensure headers exist\n config.headers = config.headers || {};\n\n // Transform request data\n config.data = transformData(\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers || {}\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n var adapter = config.adapter || defaults.adapter;\n\n return adapter(config).then(function onAdapterResolution(response) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n response.data = transformData(\n response.data,\n response.headers,\n config.transformResponse\n );\n\n return response;\n }, function onAdapterRejection(reason) {\n if (!isCancel(reason)) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n if (reason && reason.response) {\n reason.response.data = transformData(\n reason.response.data,\n reason.response.headers,\n config.transformResponse\n );\n }\n }\n\n return Promise.reject(reason);\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/dispatchRequest.js\n// module id = 18\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn(data, headers);\n });\n\n return data;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/transformData.js\n// module id = 19\n// module chunks = 0","'use strict';\n\nmodule.exports = function isCancel(value) {\n return !!(value && value.__CANCEL__);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/isCancel.js\n// module id = 20\n// module chunks = 0","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isAbsoluteURL.js\n// module id = 21\n// module chunks = 0","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return relativeURL\n ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n : baseURL;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/combineURLs.js\n// module id = 22\n// module chunks = 0","'use strict';\n\n/**\n * A `Cancel` is an object that is thrown when an operation is canceled.\n *\n * @class\n * @param {string=} message The message.\n */\nfunction Cancel(message) {\n this.message = message;\n}\n\nCancel.prototype.toString = function toString() {\n return 'Cancel' + (this.message ? ': ' + this.message : '');\n};\n\nCancel.prototype.__CANCEL__ = true;\n\nmodule.exports = Cancel;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/Cancel.js\n// module id = 23\n// module chunks = 0","'use strict';\n\nvar Cancel = require('./Cancel');\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @class\n * @param {Function} executor The executor function.\n */\nfunction CancelToken(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n var resolvePromise;\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n var token = this;\n executor(function cancel(message) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new Cancel(message);\n resolvePromise(token.reason);\n });\n}\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n};\n\n/**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\nCancelToken.source = function source() {\n var cancel;\n var token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token: token,\n cancel: cancel\n };\n};\n\nmodule.exports = CancelToken;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/CancelToken.js\n// module id = 24\n// module chunks = 0","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/spread.js\n// module id = 25\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/node_modules/axios/index.d.ts b/node_modules/axios/index.d.ts new file mode 100644 index 0000000..403fd1a --- /dev/null +++ b/node_modules/axios/index.d.ts @@ -0,0 +1,131 @@ +export interface AxiosTransformer { + (data: any, headers?: any): any; +} + +export interface AxiosAdapter { + (config: AxiosRequestConfig): AxiosPromise; +} + +export interface AxiosBasicCredentials { + username: string; + password: string; +} + +export interface AxiosProxyConfig { + host: string; + port: number; + auth?: { + username: string; + password:string; + } +} + +export interface AxiosRequestConfig { + url?: string; + method?: string; + baseURL?: string; + transformRequest?: AxiosTransformer | AxiosTransformer[]; + transformResponse?: AxiosTransformer | AxiosTransformer[]; + headers?: any; + params?: any; + paramsSerializer?: (params: any) => string; + data?: any; + timeout?: number; + withCredentials?: boolean; + adapter?: AxiosAdapter; + auth?: AxiosBasicCredentials; + responseType?: string; + xsrfCookieName?: string; + xsrfHeaderName?: string; + onUploadProgress?: (progressEvent: any) => void; + onDownloadProgress?: (progressEvent: any) => void; + maxContentLength?: number; + validateStatus?: (status: number) => boolean; + maxRedirects?: number; + httpAgent?: any; + httpsAgent?: any; + proxy?: AxiosProxyConfig | false; + cancelToken?: CancelToken; +} + +export interface AxiosResponse { + data: T; + status: number; + statusText: string; + headers: any; + config: AxiosRequestConfig; + request?: any; +} + +export interface AxiosError extends Error { + config: AxiosRequestConfig; + code?: string; + request?: any; + response?: AxiosResponse; +} + +export interface AxiosPromise extends Promise> { +} + +export interface CancelStatic { + new (message?: string): Cancel; +} + +export interface Cancel { + message: string; +} + +export interface Canceler { + (message?: string): void; +} + +export interface CancelTokenStatic { + new (executor: (cancel: Canceler) => void): CancelToken; + source(): CancelTokenSource; +} + +export interface CancelToken { + promise: Promise; + reason?: Cancel; + throwIfRequested(): void; +} + +export interface CancelTokenSource { + token: CancelToken; + cancel: Canceler; +} + +export interface AxiosInterceptorManager { + use(onFulfilled?: (value: V) => V | Promise, onRejected?: (error: any) => any): number; + eject(id: number): void; +} + +export interface AxiosInstance { + (config: AxiosRequestConfig): AxiosPromise; + (url: string, config?: AxiosRequestConfig): AxiosPromise; + defaults: AxiosRequestConfig; + interceptors: { + request: AxiosInterceptorManager; + response: AxiosInterceptorManager; + }; + request(config: AxiosRequestConfig): AxiosPromise; + get(url: string, config?: AxiosRequestConfig): AxiosPromise; + delete(url: string, config?: AxiosRequestConfig): AxiosPromise; + head(url: string, config?: AxiosRequestConfig): AxiosPromise; + post(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; + put(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; + patch(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; +} + +export interface AxiosStatic extends AxiosInstance { + create(config?: AxiosRequestConfig): AxiosInstance; + Cancel: CancelStatic; + CancelToken: CancelTokenStatic; + isCancel(value: any): boolean; + all(values: (T | Promise)[]): Promise; + spread(callback: (...args: T[]) => R): (array: T[]) => R; +} + +declare const Axios: AxiosStatic; + +export default Axios; diff --git a/node_modules/axios/index.js b/node_modules/axios/index.js new file mode 100644 index 0000000..79dfd09 --- /dev/null +++ b/node_modules/axios/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/axios'); \ No newline at end of file diff --git a/node_modules/axios/lib/adapters/README.md b/node_modules/axios/lib/adapters/README.md new file mode 100644 index 0000000..68f1118 --- /dev/null +++ b/node_modules/axios/lib/adapters/README.md @@ -0,0 +1,37 @@ +# axios // adapters + +The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received. + +## Example + +```js +var settle = require('./../core/settle'); + +module.exports = function myAdapter(config) { + // At this point: + // - config has been merged with defaults + // - request transformers have already run + // - request interceptors have already run + + // Make the request using config provided + // Upon response settle the Promise + + return new Promise(function(resolve, reject) { + + var response = { + data: responseData, + status: request.status, + statusText: request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // From here: + // - response transformers will run + // - response interceptors will run + }); +} +``` diff --git a/node_modules/axios/lib/adapters/http.js b/node_modules/axios/lib/adapters/http.js new file mode 100644 index 0000000..b986487 --- /dev/null +++ b/node_modules/axios/lib/adapters/http.js @@ -0,0 +1,237 @@ +'use strict'; + +var utils = require('./../utils'); +var settle = require('./../core/settle'); +var buildURL = require('./../helpers/buildURL'); +var http = require('http'); +var https = require('https'); +var httpFollow = require('follow-redirects').http; +var httpsFollow = require('follow-redirects').https; +var url = require('url'); +var zlib = require('zlib'); +var pkg = require('./../../package.json'); +var createError = require('../core/createError'); +var enhanceError = require('../core/enhanceError'); + +/*eslint consistent-return:0*/ +module.exports = function httpAdapter(config) { + return new Promise(function dispatchHttpRequest(resolve, reject) { + var data = config.data; + var headers = config.headers; + var timer; + + // Set User-Agent (required by some servers) + // Only set header if it hasn't been set in config + // See https://github.com/axios/axios/issues/69 + if (!headers['User-Agent'] && !headers['user-agent']) { + headers['User-Agent'] = 'axios/' + pkg.version; + } + + if (data && !utils.isStream(data)) { + if (Buffer.isBuffer(data)) { + // Nothing to do... + } else if (utils.isArrayBuffer(data)) { + data = new Buffer(new Uint8Array(data)); + } else if (utils.isString(data)) { + data = new Buffer(data, 'utf-8'); + } else { + return reject(createError( + 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', + config + )); + } + + // Add Content-Length header if data exists + headers['Content-Length'] = data.length; + } + + // HTTP basic authentication + var auth = undefined; + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password || ''; + auth = username + ':' + password; + } + + // Parse url + var parsed = url.parse(config.url); + var protocol = parsed.protocol || 'http:'; + + if (!auth && parsed.auth) { + var urlAuth = parsed.auth.split(':'); + var urlUsername = urlAuth[0] || ''; + var urlPassword = urlAuth[1] || ''; + auth = urlUsername + ':' + urlPassword; + } + + if (auth) { + delete headers.Authorization; + } + + var isHttps = protocol === 'https:'; + var agent = isHttps ? config.httpsAgent : config.httpAgent; + + var options = { + path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), + method: config.method, + headers: headers, + agent: agent, + auth: auth + }; + + if (config.socketPath) { + options.socketPath = config.socketPath; + } else { + options.hostname = parsed.hostname; + options.port = parsed.port; + } + + var proxy = config.proxy; + if (!proxy && proxy !== false) { + var proxyEnv = protocol.slice(0, -1) + '_proxy'; + var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()]; + if (proxyUrl) { + var parsedProxyUrl = url.parse(proxyUrl); + proxy = { + host: parsedProxyUrl.hostname, + port: parsedProxyUrl.port + }; + + if (parsedProxyUrl.auth) { + var proxyUrlAuth = parsedProxyUrl.auth.split(':'); + proxy.auth = { + username: proxyUrlAuth[0], + password: proxyUrlAuth[1] + }; + } + } + } + + if (proxy) { + options.hostname = proxy.host; + options.host = proxy.host; + options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : ''); + options.port = proxy.port; + options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path; + + // Basic proxy authorization + if (proxy.auth) { + var base64 = new Buffer(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64'); + options.headers['Proxy-Authorization'] = 'Basic ' + base64; + } + } + + var transport; + if (config.transport) { + transport = config.transport; + } else if (config.maxRedirects === 0) { + transport = isHttps ? https : http; + } else { + if (config.maxRedirects) { + options.maxRedirects = config.maxRedirects; + } + transport = isHttps ? httpsFollow : httpFollow; + } + + if (config.maxContentLength && config.maxContentLength > -1) { + options.maxBodyLength = config.maxContentLength; + } + + // Create the request + var req = transport.request(options, function handleResponse(res) { + if (req.aborted) return; + + // Response has been received so kill timer that handles request timeout + clearTimeout(timer); + timer = null; + + // uncompress the response body transparently if required + var stream = res; + switch (res.headers['content-encoding']) { + /*eslint default-case:0*/ + case 'gzip': + case 'compress': + case 'deflate': + // add the unzipper to the body stream processing pipeline + stream = stream.pipe(zlib.createUnzip()); + + // remove the content-encoding in order to not confuse downstream operations + delete res.headers['content-encoding']; + break; + } + + // return the last request in case of redirects + var lastRequest = res.req || req; + + var response = { + status: res.statusCode, + statusText: res.statusMessage, + headers: res.headers, + config: config, + request: lastRequest + }; + + if (config.responseType === 'stream') { + response.data = stream; + settle(resolve, reject, response); + } else { + var responseBuffer = []; + stream.on('data', function handleStreamData(chunk) { + responseBuffer.push(chunk); + + // make sure the content length is not over the maxContentLength if specified + if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) { + reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', + config, null, lastRequest)); + } + }); + + stream.on('error', function handleStreamError(err) { + if (req.aborted) return; + reject(enhanceError(err, config, null, lastRequest)); + }); + + stream.on('end', function handleStreamEnd() { + var responseData = Buffer.concat(responseBuffer); + if (config.responseType !== 'arraybuffer') { + responseData = responseData.toString('utf8'); + } + + response.data = responseData; + settle(resolve, reject, response); + }); + } + }); + + // Handle errors + req.on('error', function handleRequestError(err) { + if (req.aborted) return; + reject(enhanceError(err, config, null, req)); + }); + + // Handle request timeout + if (config.timeout && !timer) { + timer = setTimeout(function handleRequestTimeout() { + req.abort(); + reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req)); + }, config.timeout); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (req.aborted) return; + + req.abort(); + reject(cancel); + }); + } + + // Send the request + if (utils.isStream(data)) { + data.pipe(req); + } else { + req.end(data); + } + }); +}; diff --git a/node_modules/axios/lib/adapters/xhr.js b/node_modules/axios/lib/adapters/xhr.js new file mode 100644 index 0000000..81364bd --- /dev/null +++ b/node_modules/axios/lib/adapters/xhr.js @@ -0,0 +1,180 @@ +'use strict'; + +var utils = require('./../utils'); +var settle = require('./../core/settle'); +var buildURL = require('./../helpers/buildURL'); +var parseHeaders = require('./../helpers/parseHeaders'); +var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); +var createError = require('../core/createError'); +var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa'); + +module.exports = function xhrAdapter(config) { + return new Promise(function dispatchXhrRequest(resolve, reject) { + var requestData = config.data; + var requestHeaders = config.headers; + + if (utils.isFormData(requestData)) { + delete requestHeaders['Content-Type']; // Let the browser set it + } + + var request = new XMLHttpRequest(); + var loadEvent = 'onreadystatechange'; + var xDomain = false; + + // For IE 8/9 CORS support + // Only supports POST and GET calls and doesn't returns the response headers. + // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest. + if (process.env.NODE_ENV !== 'test' && + typeof window !== 'undefined' && + window.XDomainRequest && !('withCredentials' in request) && + !isURLSameOrigin(config.url)) { + request = new window.XDomainRequest(); + loadEvent = 'onload'; + xDomain = true; + request.onprogress = function handleProgress() {}; + request.ontimeout = function handleTimeout() {}; + } + + // HTTP basic authentication + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password || ''; + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); + } + + request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true); + + // Set the request timeout in MS + request.timeout = config.timeout; + + // Listen for ready state + request[loadEvent] = function handleLoad() { + if (!request || (request.readyState !== 4 && !xDomain)) { + return; + } + + // The request errored out and we didn't get a response, this will be + // handled by onerror instead + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { + return; + } + + // Prepare the response + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; + var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; + var response = { + data: responseData, + // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201) + status: request.status === 1223 ? 204 : request.status, + statusText: request.status === 1223 ? 'No Content' : request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // Clean up request + request = null; + }; + + // Handle low level network errors + request.onerror = function handleError() { + // Real errors are hidden from us by the browser + // onerror should only fire if it's a network error + reject(createError('Network Error', config, null, request)); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', + request)); + + // Clean up request + request = null; + }; + + // Add xsrf header + // This is only done if running in a standard browser environment. + // Specifically not if we're in a web worker, or react-native. + if (utils.isStandardBrowserEnv()) { + var cookies = require('./../helpers/cookies'); + + // Add xsrf header + var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? + cookies.read(config.xsrfCookieName) : + undefined; + + if (xsrfValue) { + requestHeaders[config.xsrfHeaderName] = xsrfValue; + } + } + + // Add headers to the request + if ('setRequestHeader' in request) { + utils.forEach(requestHeaders, function setRequestHeader(val, key) { + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { + // Remove Content-Type if data is undefined + delete requestHeaders[key]; + } else { + // Otherwise add header to the request + request.setRequestHeader(key, val); + } + }); + } + + // Add withCredentials to request if needed + if (config.withCredentials) { + request.withCredentials = true; + } + + // Add responseType to request if needed + if (config.responseType) { + try { + request.responseType = config.responseType; + } catch (e) { + // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. + // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. + if (config.responseType !== 'json') { + throw e; + } + } + } + + // Handle progress if needed + if (typeof config.onDownloadProgress === 'function') { + request.addEventListener('progress', config.onDownloadProgress); + } + + // Not all browsers support upload events + if (typeof config.onUploadProgress === 'function' && request.upload) { + request.upload.addEventListener('progress', config.onUploadProgress); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (!request) { + return; + } + + request.abort(); + reject(cancel); + // Clean up request + request = null; + }); + } + + if (requestData === undefined) { + requestData = null; + } + + // Send the request + request.send(requestData); + }); +}; diff --git a/node_modules/axios/lib/axios.js b/node_modules/axios/lib/axios.js new file mode 100644 index 0000000..ed1f519 --- /dev/null +++ b/node_modules/axios/lib/axios.js @@ -0,0 +1,52 @@ +'use strict'; + +var utils = require('./utils'); +var bind = require('./helpers/bind'); +var Axios = require('./core/Axios'); +var defaults = require('./defaults'); + +/** + * Create an instance of Axios + * + * @param {Object} defaultConfig The default config for the instance + * @return {Axios} A new instance of Axios + */ +function createInstance(defaultConfig) { + var context = new Axios(defaultConfig); + var instance = bind(Axios.prototype.request, context); + + // Copy axios.prototype to instance + utils.extend(instance, Axios.prototype, context); + + // Copy context to instance + utils.extend(instance, context); + + return instance; +} + +// Create the default instance to be exported +var axios = createInstance(defaults); + +// Expose Axios class to allow class inheritance +axios.Axios = Axios; + +// Factory for creating new instances +axios.create = function create(instanceConfig) { + return createInstance(utils.merge(defaults, instanceConfig)); +}; + +// Expose Cancel & CancelToken +axios.Cancel = require('./cancel/Cancel'); +axios.CancelToken = require('./cancel/CancelToken'); +axios.isCancel = require('./cancel/isCancel'); + +// Expose all/spread +axios.all = function all(promises) { + return Promise.all(promises); +}; +axios.spread = require('./helpers/spread'); + +module.exports = axios; + +// Allow use of default import syntax in TypeScript +module.exports.default = axios; diff --git a/node_modules/axios/lib/cancel/Cancel.js b/node_modules/axios/lib/cancel/Cancel.js new file mode 100644 index 0000000..e0de400 --- /dev/null +++ b/node_modules/axios/lib/cancel/Cancel.js @@ -0,0 +1,19 @@ +'use strict'; + +/** + * A `Cancel` is an object that is thrown when an operation is canceled. + * + * @class + * @param {string=} message The message. + */ +function Cancel(message) { + this.message = message; +} + +Cancel.prototype.toString = function toString() { + return 'Cancel' + (this.message ? ': ' + this.message : ''); +}; + +Cancel.prototype.__CANCEL__ = true; + +module.exports = Cancel; diff --git a/node_modules/axios/lib/cancel/CancelToken.js b/node_modules/axios/lib/cancel/CancelToken.js new file mode 100644 index 0000000..6b46e66 --- /dev/null +++ b/node_modules/axios/lib/cancel/CancelToken.js @@ -0,0 +1,57 @@ +'use strict'; + +var Cancel = require('./Cancel'); + +/** + * A `CancelToken` is an object that can be used to request cancellation of an operation. + * + * @class + * @param {Function} executor The executor function. + */ +function CancelToken(executor) { + if (typeof executor !== 'function') { + throw new TypeError('executor must be a function.'); + } + + var resolvePromise; + this.promise = new Promise(function promiseExecutor(resolve) { + resolvePromise = resolve; + }); + + var token = this; + executor(function cancel(message) { + if (token.reason) { + // Cancellation has already been requested + return; + } + + token.reason = new Cancel(message); + resolvePromise(token.reason); + }); +} + +/** + * Throws a `Cancel` if cancellation has been requested. + */ +CancelToken.prototype.throwIfRequested = function throwIfRequested() { + if (this.reason) { + throw this.reason; + } +}; + +/** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ +CancelToken.source = function source() { + var cancel; + var token = new CancelToken(function executor(c) { + cancel = c; + }); + return { + token: token, + cancel: cancel + }; +}; + +module.exports = CancelToken; diff --git a/node_modules/axios/lib/cancel/isCancel.js b/node_modules/axios/lib/cancel/isCancel.js new file mode 100644 index 0000000..051f3ae --- /dev/null +++ b/node_modules/axios/lib/cancel/isCancel.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isCancel(value) { + return !!(value && value.__CANCEL__); +}; diff --git a/node_modules/axios/lib/core/Axios.js b/node_modules/axios/lib/core/Axios.js new file mode 100644 index 0000000..d21edbc --- /dev/null +++ b/node_modules/axios/lib/core/Axios.js @@ -0,0 +1,79 @@ +'use strict'; + +var defaults = require('./../defaults'); +var utils = require('./../utils'); +var InterceptorManager = require('./InterceptorManager'); +var dispatchRequest = require('./dispatchRequest'); + +/** + * Create a new instance of Axios + * + * @param {Object} instanceConfig The default config for the instance + */ +function Axios(instanceConfig) { + this.defaults = instanceConfig; + this.interceptors = { + request: new InterceptorManager(), + response: new InterceptorManager() + }; +} + +/** + * Dispatch a request + * + * @param {Object} config The config specific for this request (merged with this.defaults) + */ +Axios.prototype.request = function request(config) { + /*eslint no-param-reassign:0*/ + // Allow for axios('example/url'[, config]) a la fetch API + if (typeof config === 'string') { + config = utils.merge({ + url: arguments[0] + }, arguments[1]); + } + + config = utils.merge(defaults, {method: 'get'}, this.defaults, config); + config.method = config.method.toLowerCase(); + + // Hook up interceptors middleware + var chain = [dispatchRequest, undefined]; + var promise = Promise.resolve(config); + + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { + chain.unshift(interceptor.fulfilled, interceptor.rejected); + }); + + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { + chain.push(interceptor.fulfilled, interceptor.rejected); + }); + + while (chain.length) { + promise = promise.then(chain.shift(), chain.shift()); + } + + return promise; +}; + +// Provide aliases for supported request methods +utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, config) { + return this.request(utils.merge(config || {}, { + method: method, + url: url + })); + }; +}); + +utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, data, config) { + return this.request(utils.merge(config || {}, { + method: method, + url: url, + data: data + })); + }; +}); + +module.exports = Axios; diff --git a/node_modules/axios/lib/core/InterceptorManager.js b/node_modules/axios/lib/core/InterceptorManager.js new file mode 100644 index 0000000..50d667b --- /dev/null +++ b/node_modules/axios/lib/core/InterceptorManager.js @@ -0,0 +1,52 @@ +'use strict'; + +var utils = require('./../utils'); + +function InterceptorManager() { + this.handlers = []; +} + +/** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ +InterceptorManager.prototype.use = function use(fulfilled, rejected) { + this.handlers.push({ + fulfilled: fulfilled, + rejected: rejected + }); + return this.handlers.length - 1; +}; + +/** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + */ +InterceptorManager.prototype.eject = function eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null; + } +}; + +/** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + */ +InterceptorManager.prototype.forEach = function forEach(fn) { + utils.forEach(this.handlers, function forEachHandler(h) { + if (h !== null) { + fn(h); + } + }); +}; + +module.exports = InterceptorManager; diff --git a/node_modules/axios/lib/core/README.md b/node_modules/axios/lib/core/README.md new file mode 100644 index 0000000..253bc48 --- /dev/null +++ b/node_modules/axios/lib/core/README.md @@ -0,0 +1,7 @@ +# axios // core + +The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are: + +- Dispatching requests +- Managing interceptors +- Handling config diff --git a/node_modules/axios/lib/core/createError.js b/node_modules/axios/lib/core/createError.js new file mode 100644 index 0000000..933680f --- /dev/null +++ b/node_modules/axios/lib/core/createError.js @@ -0,0 +1,18 @@ +'use strict'; + +var enhanceError = require('./enhanceError'); + +/** + * Create an Error with the specified message, config, error code, request and response. + * + * @param {string} message The error message. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The created error. + */ +module.exports = function createError(message, config, code, request, response) { + var error = new Error(message); + return enhanceError(error, config, code, request, response); +}; diff --git a/node_modules/axios/lib/core/dispatchRequest.js b/node_modules/axios/lib/core/dispatchRequest.js new file mode 100644 index 0000000..9ea70f2 --- /dev/null +++ b/node_modules/axios/lib/core/dispatchRequest.js @@ -0,0 +1,86 @@ +'use strict'; + +var utils = require('./../utils'); +var transformData = require('./transformData'); +var isCancel = require('../cancel/isCancel'); +var defaults = require('../defaults'); +var isAbsoluteURL = require('./../helpers/isAbsoluteURL'); +var combineURLs = require('./../helpers/combineURLs'); + +/** + * Throws a `Cancel` if cancellation has been requested. + */ +function throwIfCancellationRequested(config) { + if (config.cancelToken) { + config.cancelToken.throwIfRequested(); + } +} + +/** + * Dispatch a request to the server using the configured adapter. + * + * @param {object} config The config that is to be used for the request + * @returns {Promise} The Promise to be fulfilled + */ +module.exports = function dispatchRequest(config) { + throwIfCancellationRequested(config); + + // Support baseURL config + if (config.baseURL && !isAbsoluteURL(config.url)) { + config.url = combineURLs(config.baseURL, config.url); + } + + // Ensure headers exist + config.headers = config.headers || {}; + + // Transform request data + config.data = transformData( + config.data, + config.headers, + config.transformRequest + ); + + // Flatten headers + config.headers = utils.merge( + config.headers.common || {}, + config.headers[config.method] || {}, + config.headers || {} + ); + + utils.forEach( + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], + function cleanHeaderConfig(method) { + delete config.headers[method]; + } + ); + + var adapter = config.adapter || defaults.adapter; + + return adapter(config).then(function onAdapterResolution(response) { + throwIfCancellationRequested(config); + + // Transform response data + response.data = transformData( + response.data, + response.headers, + config.transformResponse + ); + + return response; + }, function onAdapterRejection(reason) { + if (!isCancel(reason)) { + throwIfCancellationRequested(config); + + // Transform response data + if (reason && reason.response) { + reason.response.data = transformData( + reason.response.data, + reason.response.headers, + config.transformResponse + ); + } + } + + return Promise.reject(reason); + }); +}; diff --git a/node_modules/axios/lib/core/enhanceError.js b/node_modules/axios/lib/core/enhanceError.js new file mode 100644 index 0000000..8dfd5b4 --- /dev/null +++ b/node_modules/axios/lib/core/enhanceError.js @@ -0,0 +1,21 @@ +'use strict'; + +/** + * Update an Error with the specified config, error code, and response. + * + * @param {Error} error The error to update. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The error. + */ +module.exports = function enhanceError(error, config, code, request, response) { + error.config = config; + if (code) { + error.code = code; + } + error.request = request; + error.response = response; + return error; +}; diff --git a/node_modules/axios/lib/core/settle.js b/node_modules/axios/lib/core/settle.js new file mode 100644 index 0000000..8db5e23 --- /dev/null +++ b/node_modules/axios/lib/core/settle.js @@ -0,0 +1,26 @@ +'use strict'; + +var createError = require('./createError'); + +/** + * Resolve or reject a Promise based on response status. + * + * @param {Function} resolve A function that resolves the promise. + * @param {Function} reject A function that rejects the promise. + * @param {object} response The response. + */ +module.exports = function settle(resolve, reject, response) { + var validateStatus = response.config.validateStatus; + // Note: status is not exposed by XDomainRequest + if (!response.status || !validateStatus || validateStatus(response.status)) { + resolve(response); + } else { + reject(createError( + 'Request failed with status code ' + response.status, + response.config, + null, + response.request, + response + )); + } +}; diff --git a/node_modules/axios/lib/core/transformData.js b/node_modules/axios/lib/core/transformData.js new file mode 100644 index 0000000..e065362 --- /dev/null +++ b/node_modules/axios/lib/core/transformData.js @@ -0,0 +1,20 @@ +'use strict'; + +var utils = require('./../utils'); + +/** + * Transform the data for a request or a response + * + * @param {Object|String} data The data to be transformed + * @param {Array} headers The headers for the request or response + * @param {Array|Function} fns A single function or Array of functions + * @returns {*} The resulting transformed data + */ +module.exports = function transformData(data, headers, fns) { + /*eslint no-param-reassign:0*/ + utils.forEach(fns, function transform(fn) { + data = fn(data, headers); + }); + + return data; +}; diff --git a/node_modules/axios/lib/defaults.js b/node_modules/axios/lib/defaults.js new file mode 100644 index 0000000..65a25d5 --- /dev/null +++ b/node_modules/axios/lib/defaults.js @@ -0,0 +1,96 @@ +'use strict'; + +var utils = require('./utils'); +var normalizeHeaderName = require('./helpers/normalizeHeaderName'); + +var DEFAULT_CONTENT_TYPE = { + 'Content-Type': 'application/x-www-form-urlencoded' +}; + +function setContentTypeIfUnset(headers, value) { + if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { + headers['Content-Type'] = value; + } +} + +function getDefaultAdapter() { + var adapter; + if (typeof XMLHttpRequest !== 'undefined') { + // For browsers use XHR adapter + adapter = require('./adapters/xhr'); + } else if (typeof process !== 'undefined') { + // For node use HTTP adapter + adapter = require('./adapters/http'); + } + return adapter; +} + +var defaults = { + adapter: getDefaultAdapter(), + + transformRequest: [function transformRequest(data, headers) { + normalizeHeaderName(headers, 'Content-Type'); + if (utils.isFormData(data) || + utils.isArrayBuffer(data) || + utils.isBuffer(data) || + utils.isStream(data) || + utils.isFile(data) || + utils.isBlob(data) + ) { + return data; + } + if (utils.isArrayBufferView(data)) { + return data.buffer; + } + if (utils.isURLSearchParams(data)) { + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); + return data.toString(); + } + if (utils.isObject(data)) { + setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); + return JSON.stringify(data); + } + return data; + }], + + transformResponse: [function transformResponse(data) { + /*eslint no-param-reassign:0*/ + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { /* Ignore */ } + } + return data; + }], + + /** + * A timeout in milliseconds to abort a request. If set to 0 (default) a + * timeout is not created. + */ + timeout: 0, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + maxContentLength: -1, + + validateStatus: function validateStatus(status) { + return status >= 200 && status < 300; + } +}; + +defaults.headers = { + common: { + 'Accept': 'application/json, text/plain, */*' + } +}; + +utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { + defaults.headers[method] = {}; +}); + +utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); +}); + +module.exports = defaults; diff --git a/node_modules/axios/lib/helpers/README.md b/node_modules/axios/lib/helpers/README.md new file mode 100644 index 0000000..4ae3419 --- /dev/null +++ b/node_modules/axios/lib/helpers/README.md @@ -0,0 +1,7 @@ +# axios // helpers + +The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like: + +- Browser polyfills +- Managing cookies +- Parsing HTTP headers diff --git a/node_modules/axios/lib/helpers/bind.js b/node_modules/axios/lib/helpers/bind.js new file mode 100644 index 0000000..6147c60 --- /dev/null +++ b/node_modules/axios/lib/helpers/bind.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function bind(fn, thisArg) { + return function wrap() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + return fn.apply(thisArg, args); + }; +}; diff --git a/node_modules/axios/lib/helpers/btoa.js b/node_modules/axios/lib/helpers/btoa.js new file mode 100644 index 0000000..2fe5014 --- /dev/null +++ b/node_modules/axios/lib/helpers/btoa.js @@ -0,0 +1,36 @@ +'use strict'; + +// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js + +var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + +function E() { + this.message = 'String contains an invalid character'; +} +E.prototype = new Error; +E.prototype.code = 5; +E.prototype.name = 'InvalidCharacterError'; + +function btoa(input) { + var str = String(input); + var output = ''; + for ( + // initialize result and counter + var block, charCode, idx = 0, map = chars; + // if the next str index does not exist: + // change the mapping table to "=" + // check if d has no fractional digits + str.charAt(idx | 0) || (map = '=', idx % 1); + // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 + output += map.charAt(63 & block >> 8 - idx % 1 * 8) + ) { + charCode = str.charCodeAt(idx += 3 / 4); + if (charCode > 0xFF) { + throw new E(); + } + block = block << 8 | charCode; + } + return output; +} + +module.exports = btoa; diff --git a/node_modules/axios/lib/helpers/buildURL.js b/node_modules/axios/lib/helpers/buildURL.js new file mode 100644 index 0000000..be83cd0 --- /dev/null +++ b/node_modules/axios/lib/helpers/buildURL.js @@ -0,0 +1,66 @@ +'use strict'; + +var utils = require('./../utils'); + +function encode(val) { + return encodeURIComponent(val). + replace(/%40/gi, '@'). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'). + replace(/%5B/gi, '['). + replace(/%5D/gi, ']'); +} + +/** + * Build a URL by appending params to the end + * + * @param {string} url The base of the url (e.g., http://www.google.com) + * @param {object} [params] The params to be appended + * @returns {string} The formatted url + */ +module.exports = function buildURL(url, params, paramsSerializer) { + /*eslint no-param-reassign:0*/ + if (!params) { + return url; + } + + var serializedParams; + if (paramsSerializer) { + serializedParams = paramsSerializer(params); + } else if (utils.isURLSearchParams(params)) { + serializedParams = params.toString(); + } else { + var parts = []; + + utils.forEach(params, function serialize(val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + + if (utils.isArray(val)) { + key = key + '[]'; + } else { + val = [val]; + } + + utils.forEach(val, function parseValue(v) { + if (utils.isDate(v)) { + v = v.toISOString(); + } else if (utils.isObject(v)) { + v = JSON.stringify(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + serializedParams = parts.join('&'); + } + + if (serializedParams) { + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; + } + + return url; +}; diff --git a/node_modules/axios/lib/helpers/combineURLs.js b/node_modules/axios/lib/helpers/combineURLs.js new file mode 100644 index 0000000..f1b58a5 --- /dev/null +++ b/node_modules/axios/lib/helpers/combineURLs.js @@ -0,0 +1,14 @@ +'use strict'; + +/** + * Creates a new URL by combining the specified URLs + * + * @param {string} baseURL The base URL + * @param {string} relativeURL The relative URL + * @returns {string} The combined URL + */ +module.exports = function combineURLs(baseURL, relativeURL) { + return relativeURL + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; +}; diff --git a/node_modules/axios/lib/helpers/cookies.js b/node_modules/axios/lib/helpers/cookies.js new file mode 100644 index 0000000..e45a4f9 --- /dev/null +++ b/node_modules/axios/lib/helpers/cookies.js @@ -0,0 +1,53 @@ +'use strict'; + +var utils = require('./../utils'); + +module.exports = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs support document.cookie + (function standardBrowserEnv() { + return { + write: function write(name, value, expires, path, domain, secure) { + var cookie = []; + cookie.push(name + '=' + encodeURIComponent(value)); + + if (utils.isNumber(expires)) { + cookie.push('expires=' + new Date(expires).toGMTString()); + } + + if (utils.isString(path)) { + cookie.push('path=' + path); + } + + if (utils.isString(domain)) { + cookie.push('domain=' + domain); + } + + if (secure === true) { + cookie.push('secure'); + } + + document.cookie = cookie.join('; '); + }, + + read: function read(name) { + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove: function remove(name) { + this.write(name, '', Date.now() - 86400000); + } + }; + })() : + + // Non standard browser env (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return { + write: function write() {}, + read: function read() { return null; }, + remove: function remove() {} + }; + })() +); diff --git a/node_modules/axios/lib/helpers/deprecatedMethod.js b/node_modules/axios/lib/helpers/deprecatedMethod.js new file mode 100644 index 0000000..ed40965 --- /dev/null +++ b/node_modules/axios/lib/helpers/deprecatedMethod.js @@ -0,0 +1,24 @@ +'use strict'; + +/*eslint no-console:0*/ + +/** + * Supply a warning to the developer that a method they are using + * has been deprecated. + * + * @param {string} method The name of the deprecated method + * @param {string} [instead] The alternate method to use if applicable + * @param {string} [docs] The documentation URL to get further details + */ +module.exports = function deprecatedMethod(method, instead, docs) { + try { + console.warn( + 'DEPRECATED method `' + method + '`.' + + (instead ? ' Use `' + instead + '` instead.' : '') + + ' This method will be removed in a future release.'); + + if (docs) { + console.warn('For more information about usage see ' + docs); + } + } catch (e) { /* Ignore */ } +}; diff --git a/node_modules/axios/lib/helpers/isAbsoluteURL.js b/node_modules/axios/lib/helpers/isAbsoluteURL.js new file mode 100644 index 0000000..d33e992 --- /dev/null +++ b/node_modules/axios/lib/helpers/isAbsoluteURL.js @@ -0,0 +1,14 @@ +'use strict'; + +/** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ +module.exports = function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); +}; diff --git a/node_modules/axios/lib/helpers/isURLSameOrigin.js b/node_modules/axios/lib/helpers/isURLSameOrigin.js new file mode 100644 index 0000000..e292745 --- /dev/null +++ b/node_modules/axios/lib/helpers/isURLSameOrigin.js @@ -0,0 +1,68 @@ +'use strict'; + +var utils = require('./../utils'); + +module.exports = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs have full support of the APIs needed to test + // whether the request URL is of the same origin as current location. + (function standardBrowserEnv() { + var msie = /(msie|trident)/i.test(navigator.userAgent); + var urlParsingNode = document.createElement('a'); + var originURL; + + /** + * Parse a URL to discover it's components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ + function resolveURL(url) { + var href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? + urlParsingNode.pathname : + '/' + urlParsingNode.pathname + }; + } + + originURL = resolveURL(window.location.href); + + /** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestURL The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ + return function isURLSameOrigin(requestURL) { + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + return (parsed.protocol === originURL.protocol && + parsed.host === originURL.host); + }; + })() : + + // Non standard browser envs (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return function isURLSameOrigin() { + return true; + }; + })() +); diff --git a/node_modules/axios/lib/helpers/normalizeHeaderName.js b/node_modules/axios/lib/helpers/normalizeHeaderName.js new file mode 100644 index 0000000..738c9fe --- /dev/null +++ b/node_modules/axios/lib/helpers/normalizeHeaderName.js @@ -0,0 +1,12 @@ +'use strict'; + +var utils = require('../utils'); + +module.exports = function normalizeHeaderName(headers, normalizedName) { + utils.forEach(headers, function processHeader(value, name) { + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { + headers[normalizedName] = value; + delete headers[name]; + } + }); +}; diff --git a/node_modules/axios/lib/helpers/parseHeaders.js b/node_modules/axios/lib/helpers/parseHeaders.js new file mode 100644 index 0000000..8af2cc7 --- /dev/null +++ b/node_modules/axios/lib/helpers/parseHeaders.js @@ -0,0 +1,53 @@ +'use strict'; + +var utils = require('./../utils'); + +// Headers whose duplicates are ignored by node +// c.f. https://nodejs.org/api/http.html#http_message_headers +var ignoreDuplicateOf = [ + 'age', 'authorization', 'content-length', 'content-type', 'etag', + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', + 'last-modified', 'location', 'max-forwards', 'proxy-authorization', + 'referer', 'retry-after', 'user-agent' +]; + +/** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} headers Headers needing to be parsed + * @returns {Object} Headers parsed into an object + */ +module.exports = function parseHeaders(headers) { + var parsed = {}; + var key; + var val; + var i; + + if (!headers) { return parsed; } + + utils.forEach(headers.split('\n'), function parser(line) { + i = line.indexOf(':'); + key = utils.trim(line.substr(0, i)).toLowerCase(); + val = utils.trim(line.substr(i + 1)); + + if (key) { + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { + return; + } + if (key === 'set-cookie') { + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); + } else { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + } + }); + + return parsed; +}; diff --git a/node_modules/axios/lib/helpers/spread.js b/node_modules/axios/lib/helpers/spread.js new file mode 100644 index 0000000..25e3cdd --- /dev/null +++ b/node_modules/axios/lib/helpers/spread.js @@ -0,0 +1,27 @@ +'use strict'; + +/** + * Syntactic sugar for invoking a function and expanding an array for arguments. + * + * Common use case would be to use `Function.prototype.apply`. + * + * ```js + * function f(x, y, z) {} + * var args = [1, 2, 3]; + * f.apply(null, args); + * ``` + * + * With `spread` this example can be re-written. + * + * ```js + * spread(function(x, y, z) {})([1, 2, 3]); + * ``` + * + * @param {Function} callback + * @returns {Function} + */ +module.exports = function spread(callback) { + return function wrap(arr) { + return callback.apply(null, arr); + }; +}; diff --git a/node_modules/axios/lib/utils.js b/node_modules/axios/lib/utils.js new file mode 100644 index 0000000..b3fd865 --- /dev/null +++ b/node_modules/axios/lib/utils.js @@ -0,0 +1,303 @@ +'use strict'; + +var bind = require('./helpers/bind'); +var isBuffer = require('is-buffer'); + +/*global toString:true*/ + +// utils is a library of generic helper functions non-specific to axios + +var toString = Object.prototype.toString; + +/** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Array, otherwise false + */ +function isArray(val) { + return toString.call(val) === '[object Array]'; +} + +/** + * Determine if a value is an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an ArrayBuffer, otherwise false + */ +function isArrayBuffer(val) { + return toString.call(val) === '[object ArrayBuffer]'; +} + +/** + * Determine if a value is a FormData + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an FormData, otherwise false + */ +function isFormData(val) { + return (typeof FormData !== 'undefined') && (val instanceof FormData); +} + +/** + * Determine if a value is a view on an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false + */ +function isArrayBufferView(val) { + var result; + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { + result = ArrayBuffer.isView(val); + } else { + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); + } + return result; +} + +/** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a String, otherwise false + */ +function isString(val) { + return typeof val === 'string'; +} + +/** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Number, otherwise false + */ +function isNumber(val) { + return typeof val === 'number'; +} + +/** + * Determine if a value is undefined + * + * @param {Object} val The value to test + * @returns {boolean} True if the value is undefined, otherwise false + */ +function isUndefined(val) { + return typeof val === 'undefined'; +} + +/** + * Determine if a value is an Object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Object, otherwise false + */ +function isObject(val) { + return val !== null && typeof val === 'object'; +} + +/** + * Determine if a value is a Date + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Date, otherwise false + */ +function isDate(val) { + return toString.call(val) === '[object Date]'; +} + +/** + * Determine if a value is a File + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a File, otherwise false + */ +function isFile(val) { + return toString.call(val) === '[object File]'; +} + +/** + * Determine if a value is a Blob + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Blob, otherwise false + */ +function isBlob(val) { + return toString.call(val) === '[object Blob]'; +} + +/** + * Determine if a value is a Function + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Function, otherwise false + */ +function isFunction(val) { + return toString.call(val) === '[object Function]'; +} + +/** + * Determine if a value is a Stream + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Stream, otherwise false + */ +function isStream(val) { + return isObject(val) && isFunction(val.pipe); +} + +/** + * Determine if a value is a URLSearchParams object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a URLSearchParams object, otherwise false + */ +function isURLSearchParams(val) { + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; +} + +/** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * @returns {String} The String freed of excess whitespace + */ +function trim(str) { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); +} + +/** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + */ +function isStandardBrowserEnv() { + if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { + return false; + } + return ( + typeof window !== 'undefined' && + typeof document !== 'undefined' + ); +} + +/** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + */ +function forEach(obj, fn) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + // Force an array if not already something iterable + if (typeof obj !== 'object') { + /*eslint no-param-reassign:0*/ + obj = [obj]; + } + + if (isArray(obj)) { + // Iterate over array values + for (var i = 0, l = obj.length; i < l; i++) { + fn.call(null, obj[i], i, obj); + } + } else { + // Iterate over object keys + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + fn.call(null, obj[key], key, obj); + } + } + } +} + +/** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * Example: + * + * ```js + * var result = merge({foo: 123}, {foo: 456}); + * console.log(result.foo); // outputs 456 + * ``` + * + * @param {Object} obj1 Object to merge + * @returns {Object} Result of all merge properties + */ +function merge(/* obj1, obj2, obj3, ... */) { + var result = {}; + function assignValue(val, key) { + if (typeof result[key] === 'object' && typeof val === 'object') { + result[key] = merge(result[key], val); + } else { + result[key] = val; + } + } + + for (var i = 0, l = arguments.length; i < l; i++) { + forEach(arguments[i], assignValue); + } + return result; +} + +/** + * Extends object a by mutably adding to it the properties of object b. + * + * @param {Object} a The object to be extended + * @param {Object} b The object to copy properties from + * @param {Object} thisArg The object to bind function to + * @return {Object} The resulting value of object a + */ +function extend(a, b, thisArg) { + forEach(b, function assignValue(val, key) { + if (thisArg && typeof val === 'function') { + a[key] = bind(val, thisArg); + } else { + a[key] = val; + } + }); + return a; +} + +module.exports = { + isArray: isArray, + isArrayBuffer: isArrayBuffer, + isBuffer: isBuffer, + isFormData: isFormData, + isArrayBufferView: isArrayBufferView, + isString: isString, + isNumber: isNumber, + isObject: isObject, + isUndefined: isUndefined, + isDate: isDate, + isFile: isFile, + isBlob: isBlob, + isFunction: isFunction, + isStream: isStream, + isURLSearchParams: isURLSearchParams, + isStandardBrowserEnv: isStandardBrowserEnv, + forEach: forEach, + merge: merge, + extend: extend, + trim: trim +}; diff --git a/node_modules/axios/package.json b/node_modules/axios/package.json new file mode 100644 index 0000000..4789b60 --- /dev/null +++ b/node_modules/axios/package.json @@ -0,0 +1,111 @@ +{ + "_from": "axios", + "_id": "axios@0.18.0", + "_inBundle": false, + "_integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", + "_location": "/axios", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "axios", + "name": "axios", + "escapedName": "axios", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz", + "_shasum": "32d53e4851efdc0a11993b6cd000789d70c05102", + "_spec": "axios", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow", + "author": { + "name": "Matt Zabriskie" + }, + "browser": { + "./lib/adapters/http.js": "./lib/adapters/xhr.js" + }, + "bugs": { + "url": "https://github.com/axios/axios/issues" + }, + "bundleDependencies": false, + "bundlesize": [ + { + "path": "./dist/axios.min.js", + "threshold": "5kB" + } + ], + "dependencies": { + "follow-redirects": "^1.3.0", + "is-buffer": "^1.1.5" + }, + "deprecated": false, + "description": "Promise based HTTP client for the browser and node.js", + "devDependencies": { + "bundlesize": "^0.5.7", + "coveralls": "^2.11.9", + "es6-promise": "^4.0.5", + "grunt": "^1.0.1", + "grunt-banner": "^0.6.0", + "grunt-cli": "^1.2.0", + "grunt-contrib-clean": "^1.0.0", + "grunt-contrib-nodeunit": "^1.0.0", + "grunt-contrib-watch": "^1.0.0", + "grunt-eslint": "^19.0.0", + "grunt-karma": "^2.0.0", + "grunt-ts": "^6.0.0-beta.3", + "grunt-webpack": "^1.0.18", + "istanbul-instrumenter-loader": "^1.0.0", + "jasmine-core": "^2.4.1", + "karma": "^1.3.0", + "karma-chrome-launcher": "^2.0.0", + "karma-coverage": "^1.0.0", + "karma-firefox-launcher": "^1.0.0", + "karma-jasmine": "^1.0.2", + "karma-jasmine-ajax": "^0.1.13", + "karma-opera-launcher": "^1.0.0", + "karma-safari-launcher": "^1.0.0", + "karma-sauce-launcher": "^1.1.0", + "karma-sinon": "^1.0.5", + "karma-sourcemap-loader": "^0.3.7", + "karma-webpack": "^1.7.0", + "load-grunt-tasks": "^3.5.2", + "minimist": "^1.2.0", + "sinon": "^1.17.4", + "typescript": "^2.0.3", + "url-search-params": "^0.6.1", + "webpack": "^1.13.1", + "webpack-dev-server": "^1.14.1" + }, + "homepage": "https://github.com/axios/axios", + "keywords": [ + "xhr", + "http", + "ajax", + "promise", + "node" + ], + "license": "MIT", + "main": "index.js", + "name": "axios", + "repository": { + "type": "git", + "url": "git+https://github.com/axios/axios.git" + }, + "scripts": { + "build": "NODE_ENV=production grunt build", + "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", + "examples": "node ./examples/server.js", + "postversion": "git push && git push --tags", + "preversion": "npm test", + "start": "node ./sandbox/server.js", + "test": "grunt test && bundlesize", + "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json" + }, + "typings": "./index.d.ts", + "version": "0.18.0" +} diff --git a/node_modules/base64url/.npmignore b/node_modules/base64url/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/node_modules/base64url/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/base64url/.travis.yml b/node_modules/base64url/.travis.yml new file mode 100644 index 0000000..20fd86b --- /dev/null +++ b/node_modules/base64url/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - 0.10 diff --git a/node_modules/base64url/LICENSE b/node_modules/base64url/LICENSE new file mode 100644 index 0000000..8c2ca83 --- /dev/null +++ b/node_modules/base64url/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2013 Brian J. Brennan + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/base64url/bin/base64url b/node_modules/base64url/bin/base64url new file mode 100644 index 0000000..a9445b7 --- /dev/null +++ b/node_modules/base64url/bin/base64url @@ -0,0 +1,105 @@ +#!/usr/bin/env node + +var fs = require('fs'); +var concat = require('concat-stream'); +var base64url = require('../'); +var cli = require('meow')({ + pkg: '../package.json', + help: [ + 'Usage: base64url [-hvD] [-b num] [-i in_file] [-o out_file]', + ' -h, --help display this message', + ' -v, --version display version info', + ' -D, --decode decodes input', + ' -b, --break break encoded string into num character lines', + ' -i, --input input file (default: stdin)', + ' -o, --output output file (default: stdout)' + ].join('\n') +}, { + boolean: [ + 'D', 'decode', + 'h', 'help', + 'v', 'version', + ], + string: [ + 'i', 'input', + 'o', 'output', + 'b', 'break', + ], +}); + +var decode = cli.flags.d || cli.flags.decode; +var fn = decode && base64url.decode || base64url.encode; + +function processStream(outputStream, breakLength) { + outputStream = outputStream || process.stdout; + return concat(function (buf) { + outputStream.write(format(fn(buf), breakLength)); + process.exit(0); + }); +} + +function format(string, breakLength) { + if (!breakLength) + return string; + var regex = new RegExp('(.{' + breakLength + '})', 'g'); + return string.replace(regex, '$1\n'); +} + +function main() { + var help = cli.flags.h || cli.flags.help; + var version = cli.flags.v || cli.flags.version; + + if (help) { + return cli.showHelp(); + } + + if (version) { + console.log(cli.pkg.version); + process.exit(0); + } + + var breakLines = parseInt(cli.flags.b || cli.flags.break, 10); + var inputFile = cli.flags.i || cli.flags.input; + var outputFile = cli.flags.o || cli.flags.output; + var writeStream = process.stdout; + + if (Array.isArray(inputFile)) + inputFile = inputFile.pop(); + + if (cli.input.length > 0) + inputFile = cli.input.pop(); + + if (outputFile) { + writeStream = fs.createWriteStream(outputFile); + writeStream.on('error', fileStreamErrHandler(outputFile)); + } + + var outStream = processStream(writeStream, breakLines); + + if (!inputFile) { + return process.stdin.pipe(outStream); + } + + var readStream = fs.createReadStream(inputFile); + readStream.on('error', fileStreamErrHandler(inputFile)); + + return readStream.pipe(outStream); +} + +function fileStreamErrHandler(file) { + return function (err) { + switch (err.code) { + case 'ENOENT': + console.error('Unable to open \'%s\': No such file or directory', file); + break; + case 'EISDIR': + console.error('Unable to process \'%s\': Cannot operate on directories', file); + break; + } + + process.exit(err.errno || 1); + console.log(err); + }; +} + +main(); diff --git a/node_modules/base64url/index.js b/node_modules/base64url/index.js new file mode 100644 index 0000000..519a47e --- /dev/null +++ b/node_modules/base64url/index.js @@ -0,0 +1,54 @@ +function fromBase64(base64string) { + return ( + base64string + .replace(/=/g, '') + .replace(/\+/g, '-') + .replace(/\//g, '_') + ); +} + +function toBase64(base64UrlString) { + if (Buffer.isBuffer(base64UrlString)) + base64UrlString = base64UrlString.toString(); + + var b64str = padString(base64UrlString) + .replace(/\-/g, '+') + .replace(/_/g, '/'); + return b64str; +} + +function padString(string) { + var segmentLength = 4; + var stringLength = string.length; + var diff = string.length % segmentLength; + if (!diff) + return string; + var position = stringLength; + var padLength = segmentLength - diff; + var paddedStringLength = stringLength + padLength; + var buffer = Buffer(paddedStringLength); + buffer.write(string); + while (padLength--) + buffer.write('=', position++); + return buffer.toString(); +} + +function decodeBase64Url(base64UrlString, encoding) { + return Buffer(toBase64(base64UrlString), 'base64').toString(encoding); +} + +function base64url(stringOrBuffer, encoding) { + return fromBase64(Buffer(stringOrBuffer, encoding).toString('base64')); +} + +function toBuffer(base64string) { + return Buffer(toBase64(base64string), 'base64'); +} + +base64url.toBase64 = toBase64; +base64url.fromBase64 = fromBase64; +base64url.decode = decodeBase64Url; +base64url.encode = base64url; +base64url.toBuffer = toBuffer; + +module.exports = base64url; diff --git a/node_modules/base64url/node_modules/concat-stream/LICENSE b/node_modules/base64url/node_modules/concat-stream/LICENSE new file mode 100644 index 0000000..99c130e --- /dev/null +++ b/node_modules/base64url/node_modules/concat-stream/LICENSE @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2013 Max Ogden + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/base64url/node_modules/concat-stream/index.js b/node_modules/base64url/node_modules/concat-stream/index.js new file mode 100644 index 0000000..a40010a --- /dev/null +++ b/node_modules/base64url/node_modules/concat-stream/index.js @@ -0,0 +1,138 @@ +var Writable = require('readable-stream').Writable +var inherits = require('inherits') + +if (typeof Uint8Array === 'undefined') { + var U8 = require('typedarray').Uint8Array +} else { + var U8 = Uint8Array +} + +function ConcatStream(opts, cb) { + if (!(this instanceof ConcatStream)) return new ConcatStream(opts, cb) + + if (typeof opts === 'function') { + cb = opts + opts = {} + } + if (!opts) opts = {} + + var encoding = opts.encoding + var shouldInferEncoding = false + + if (!encoding) { + shouldInferEncoding = true + } else { + encoding = String(encoding).toLowerCase() + if (encoding === 'u8' || encoding === 'uint8') { + encoding = 'uint8array' + } + } + + Writable.call(this, { objectMode: true }) + + this.encoding = encoding + this.shouldInferEncoding = shouldInferEncoding + + if (cb) this.on('finish', function () { cb(this.getBody()) }) + this.body = [] +} + +module.exports = ConcatStream +inherits(ConcatStream, Writable) + +ConcatStream.prototype._write = function(chunk, enc, next) { + this.body.push(chunk) + next() +} + +ConcatStream.prototype.inferEncoding = function (buff) { + var firstBuffer = buff === undefined ? this.body[0] : buff; + if (Buffer.isBuffer(firstBuffer)) return 'buffer' + if (typeof Uint8Array !== 'undefined' && firstBuffer instanceof Uint8Array) return 'uint8array' + if (Array.isArray(firstBuffer)) return 'array' + if (typeof firstBuffer === 'string') return 'string' + if (Object.prototype.toString.call(firstBuffer) === "[object Object]") return 'object' + return 'buffer' +} + +ConcatStream.prototype.getBody = function () { + if (!this.encoding && this.body.length === 0) return [] + if (this.shouldInferEncoding) this.encoding = this.inferEncoding() + if (this.encoding === 'array') return arrayConcat(this.body) + if (this.encoding === 'string') return stringConcat(this.body) + if (this.encoding === 'buffer') return bufferConcat(this.body) + if (this.encoding === 'uint8array') return u8Concat(this.body) + return this.body +} + +var isArray = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]' +} + +function isArrayish (arr) { + return /Array\]$/.test(Object.prototype.toString.call(arr)) +} + +function stringConcat (parts) { + var strings = [] + var needsToString = false + for (var i = 0; i < parts.length; i++) { + var p = parts[i] + if (typeof p === 'string') { + strings.push(p) + } else if (Buffer.isBuffer(p)) { + strings.push(p) + } else if (typeof p !== 'number') { + strings.push(Buffer(p)) + } else { + strings.push(Buffer(String(p))) + } + } + if (Buffer.isBuffer(parts[0])) { + strings = Buffer.concat(strings) + strings = strings.toString('utf8') + } else { + strings = strings.join('') + } + return strings +} + +function bufferConcat (parts) { + var bufs = [] + for (var i = 0; i < parts.length; i++) { + var p = parts[i] + if (Buffer.isBuffer(p)) { + bufs.push(p) + } else if (typeof p === 'string' || isArrayish(p) + || (p && typeof p.subarray === 'function')) { + bufs.push(Buffer(p)) + } else bufs.push(Buffer(String(p))) + } + return Buffer.concat(bufs) +} + +function arrayConcat (parts) { + var res = [] + for (var i = 0; i < parts.length; i++) { + res.push.apply(res, parts[i]) + } + return res +} + +function u8Concat (parts) { + var len = 0 + for (var i = 0; i < parts.length; i++) { + if (typeof parts[i] === 'string') { + parts[i] = Buffer(parts[i]) + } + len += parts[i].length + } + var u8 = new U8(len) + for (var i = 0, offset = 0; i < parts.length; i++) { + var part = parts[i] + for (var j = 0; j < part.length; j++) { + u8[offset++] = part[j] + } + } + return u8 +} diff --git a/node_modules/base64url/node_modules/concat-stream/package.json b/node_modules/base64url/node_modules/concat-stream/package.json new file mode 100644 index 0000000..3be9ad3 --- /dev/null +++ b/node_modules/base64url/node_modules/concat-stream/package.json @@ -0,0 +1,83 @@ +{ + "_from": "concat-stream@~1.4.7", + "_id": "concat-stream@1.4.11", + "_inBundle": false, + "_integrity": "sha512-X3JMh8+4je3U1cQpG87+f9lXHDrqcb2MVLg9L7o8b1UZ0DzhRrUpdn65ttzu10PpJPPI3MQNkis+oha6TSA9Mw==", + "_location": "/base64url/concat-stream", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "concat-stream@~1.4.7", + "name": "concat-stream", + "escapedName": "concat-stream", + "rawSpec": "~1.4.7", + "saveSpec": null, + "fetchSpec": "~1.4.7" + }, + "_requiredBy": [ + "/base64url" + ], + "_resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.4.11.tgz", + "_shasum": "1dc9f666f2621da9c618b1e7f8f3b2ff70b5f76f", + "_spec": "concat-stream@~1.4.7", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\base64url", + "author": { + "name": "Max Ogden", + "email": "max@maxogden.com" + }, + "bugs": { + "url": "http://github.com/maxogden/concat-stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "inherits": "~2.0.1", + "readable-stream": "~1.1.9", + "typedarray": "~0.0.5" + }, + "deprecated": false, + "description": "writable stream that concatenates strings or binary data and calls a callback with the result", + "devDependencies": { + "tape": "~2.3.2" + }, + "engines": [ + "node >= 0.8" + ], + "files": [ + "index.js" + ], + "homepage": "https://github.com/maxogden/concat-stream#readme", + "license": "MIT", + "main": "index.js", + "name": "concat-stream", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/maxogden/concat-stream.git" + }, + "scripts": { + "test": "tape test/*.js test/server/*.js" + }, + "tags": [ + "stream", + "simple", + "util", + "utility" + ], + "testling": { + "files": "test/*.js", + "browsers": [ + "ie/8..latest", + "firefox/17..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "version": "1.4.11" +} diff --git a/node_modules/base64url/node_modules/concat-stream/readme.md b/node_modules/base64url/node_modules/concat-stream/readme.md new file mode 100644 index 0000000..69234d5 --- /dev/null +++ b/node_modules/base64url/node_modules/concat-stream/readme.md @@ -0,0 +1,94 @@ +# concat-stream + +Writable stream that concatenates strings or binary data and calls a callback with the result. Not a transform stream -- more of a stream sink. + +[![Build Status](https://travis-ci.org/maxogden/concat-stream.svg?branch=master)](https://travis-ci.org/maxogden/concat-stream) + +[![NPM](https://nodei.co/npm/concat-stream.png)](https://nodei.co/npm/concat-stream/) + +### description + +Streams emit many buffers. If you want to collect all of the buffers, and when the stream ends concatenate all of the buffers together and receive a single buffer then this is the module for you. + +Only use this if you know you can fit all of the output of your stream into a single Buffer (e.g. in RAM). + +There are also `objectMode` streams that emit things other than Buffers, and you can concatenate these too. See below for details. + +### examples + +#### Buffers + +```js +var fs = require('fs') +var concat = require('concat-stream') + +var readStream = fs.createReadStream('cat.png') +var concatStream = concat(gotPicture) + +readStream.on('error', handleError) +readStream.pipe(concatStream) + +function gotPicture(imageBuffer) { + // imageBuffer is all of `cat.png` as a node.js Buffer +} + +function handleError(err) { + // handle your error appropriately here, e.g.: + console.error(err) // print the error to STDERR + process.exit(1) // exit program with non-zero exit code +} + +``` + +#### Arrays + +```js +var write = concat(function(data) {}) +write.write([1,2,3]) +write.write([4,5,6]) +write.end() +// data will be [1,2,3,4,5,6] in the above callback +``` + +#### Uint8Arrays + +```js +var write = concat(function(data) {}) +var a = new Uint8Array(3) +a[0] = 97; a[1] = 98; a[2] = 99 +write.write(a) +write.write('!') +write.end(Buffer('!!1')) +``` + +See `test/` for more examples + +# methods + +```js +var concat = require('concat-stream') +``` + +## var writable = concat(opts={}, cb) + +Return a `writable` stream that will fire `cb(data)` with all of the data that +was written to the stream. Data can be written to `writable` as strings, +Buffers, arrays of byte integers, and Uint8Arrays. + +By default `concat-stream` will give you back the same data type as the type of the first buffer written to the stream. Use `opts.encoding` to set what format `data` should be returned as, e.g. if you if you don't want to rely on the built-in type checking or for some other reason. + +* `string` - get a string +* `buffer` - get back a Buffer +* `array` - get an array of byte integers +* `uint8array`, `u8`, `uint8` - get back a Uint8Array +* `object`, get back an array of Objects + +If you don't specify an encoding, and the types can't be inferred (e.g. you write things that aren't in the list above), it will try to convert concat them into a `Buffer`. + +# error handling + +`concat-stream` does not handle errors for you, so you must handle errors on whatever streams you pipe into `concat-stream`. This is a general rule when programming with node.js streams: always handle errors on each and every stream. Since `concat-stream` is not itself a stream it does not emit errors. + +# license + +MIT LICENSE diff --git a/node_modules/base64url/package.json b/node_modules/base64url/package.json new file mode 100644 index 0000000..6ba1945 --- /dev/null +++ b/node_modules/base64url/package.json @@ -0,0 +1,65 @@ +{ + "_from": "base64url@~1.0.4", + "_id": "base64url@1.0.6", + "_inBundle": false, + "_integrity": "sha1-1k03XWinxkDZEuI1jRcNylu1RoE=", + "_location": "/base64url", + "_phantomChildren": { + "inherits": "2.0.3", + "readable-stream": "1.1.14", + "typedarray": "0.0.6" + }, + "_requested": { + "type": "range", + "registry": true, + "raw": "base64url@~1.0.4", + "name": "base64url", + "escapedName": "base64url", + "rawSpec": "~1.0.4", + "saveSpec": null, + "fetchSpec": "~1.0.4" + }, + "_requiredBy": [ + "/jws" + ], + "_resolved": "https://registry.npmjs.org/base64url/-/base64url-1.0.6.tgz", + "_shasum": "d64d375d68a7c640d912e2358d170dca5bb54681", + "_spec": "base64url@~1.0.4", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\jws", + "author": { + "name": "Brian J Brennan" + }, + "bin": { + "base64url": "./bin/base64url" + }, + "bugs": { + "url": "https://github.com/brianloveswords/base64url/issues" + }, + "bundleDependencies": false, + "dependencies": { + "concat-stream": "~1.4.7", + "meow": "~2.0.0" + }, + "deprecated": false, + "description": "For encoding to/from base64urls", + "devDependencies": { + "tap": "~0.3.3" + }, + "gitHead": "a219306e93712cb4380286b44360fea4406d49d3", + "homepage": "https://github.com/brianloveswords/base64url#readme", + "keywords": [ + "base64", + "base64url" + ], + "license": "MIT", + "main": "index.js", + "name": "base64url", + "repository": { + "type": "git", + "url": "git://github.com/brianloveswords/base64url.git" + }, + "scripts": { + "test": "tap test/*.test.js" + }, + "version": "1.0.6" +} diff --git a/node_modules/base64url/readme.md b/node_modules/base64url/readme.md new file mode 100644 index 0000000..a2214ee --- /dev/null +++ b/node_modules/base64url/readme.md @@ -0,0 +1,126 @@ +# base64url [![Build Status](https://secure.travis-ci.org/brianloveswords/base64url.png)](http://travis-ci.org/brianloveswords/base64url) + +Converting to, and from, [base64url](http://en.wikipedia.org/wiki/Base64#RFC_4648) + +# Install + +```bash +$ npm install base64url +``` + +# Usage + +## CLI + +```bash +$ npm install -g base64url + +$ echo 'Here is some text to encode' | base64url +> SGVyZSBpcyBzb21lIHRleHQgdG8gZW5jb2RlCg + +$ echo SGVyZSBpcyBzb21lIHRleHQgdG8gZW5jb2RlCg | base64url -D +> Here is some text to encode + +$ base64url --help + + For encoding to/from base64urls + + Usage: base64url [-hvD] [-b num] [-i in_file] [-o out_file] + -h, --help display this message + -v, --version display version info + -D, --decode decodes input + -b, --break break encoded string into num character lines + -i, --input input file (default: stdin) + -o, --output output file (default: stdout), +``` + +## Library + +### base64url(stringOrBuffer) ### + +### base64url.encode(stringOrBuffer) ### + +base64url encode `stringOrBuffer` + + +Example + +```js +> base64url('ladies and gentlemen, we are floating in space') +'bGFkaWVzIGFuZCBnZW50bGVtYW4sIHdlIGFyZSBmbG9hdGluZyBpbiBzcGFjZQ' +``` + +--- + +### base64url.decode(b64UrlEncodedString, [encoding]) + +Convert a base64url encoded string into a raw string. Encoding defaults to `'utf8'`. + +```js +> base64url.decode('cmlkZTogZHJlYW1zIGJ1cm4gZG93bg') +'ride: dreams burn down' +``` + +--- + +### base64url.fromBase64(b64EncodedString) + +Convert a base64 encoded string to a base64url encoded string + +Example + +```js +> base64url.fromBase64('qL8R4QIcQ/ZsRqOAbeRfcZhilN/MksRtDaErMA==') +'qL8R4QIcQ_ZsRqOAbeRfcZhilN_MksRtDaErMA' +``` + +--- + + +### base64url.toBase64(b64UrlEncodedString) + +Convert a base64url encoded string to a base64 encoded string + +```js +> base64url.toBase64('qL8R4QIcQ_ZsRqOAbeRfcZhilN_MksRtDaErMA') +'qL8R4QIcQ/ZsRqOAbeRfcZhilN/MksRtDaErMA==' +``` + +--- + + +### base64url.toBuffer(b64UrlEncodedString) + +Convert a base64url encoded string to a Buffer + +```js +> base64url.toBuffer('c3Bpcml0dWFsaXplZA') + +``` + +# License + +MIT + +``` +Copyright (c) 2014 Brian J. Brennan + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` diff --git a/node_modules/base64url/test/base64url.test.js b/node_modules/base64url/test/base64url.test.js new file mode 100644 index 0000000..61ef6f4 --- /dev/null +++ b/node_modules/base64url/test/base64url.test.js @@ -0,0 +1,56 @@ +const fs = require('fs'); +const test = require('tap').test; +const base64url = require('..'); +const testBuffer = fs.readFileSync(__dirname + '/test.jpg'); + +function base64(s) { + return Buffer(s, 'binary').toString('base64'); +} + +test('from string to base64url', function (t) { + const b64 = base64(testBuffer); + const b64url = base64url(testBuffer, 'binary'); + t.same(b64url.indexOf('+'), -1, 'should not contain plus signs'); + t.same(b64url.indexOf('/'), -1, 'should not contain slashes'); + t.same(b64url.indexOf('='), -1, 'should not contain equal signs'); + t.same(b64.indexOf('+'), b64url.indexOf('-'), 'should replace + with -'); + t.same(b64.indexOf('/'), b64url.indexOf('_'), 'should replace / with _'); + t.end(); +}); + +test('from base64url to base64', function (t) { + const b64 = base64(testBuffer); + const b64url = base64url(testBuffer, 'binary'); + const result = base64url.toBase64(b64url); + t.same(result, b64, 'should be able to convert back'); + t.end(); +}); + +test('from base64 to base64url', function (t) { + const b64 = base64(testBuffer); + const b64url = base64url(testBuffer, 'binary'); + const result = base64url.fromBase64(b64); + t.same(result, b64url, 'should be able to convert to b64url from b64'); + t.end(); +}); + +test('from base64url to string', function (t) { + const b64url = base64url(testBuffer, 'binary'); + const result = base64url.decode(b64url, 'binary'); + t.same(result, testBuffer.toString('binary'), 'should be able to decode'); + t.end(); +}); + +test('from base64url to string (buffer)', function (t) { + const b64url = base64url(testBuffer, 'binary'); + const result = base64url.decode(new Buffer(b64url), 'binary'); + t.same(result, testBuffer.toString('binary'), 'should be able to decode'); + t.end(); +}); + +test('from base64url to buffer', function (t) { + const b64url = base64url(testBuffer, 'binary'); + const result = base64url.toBuffer(b64url); + t.same(result, testBuffer, 'should be able to convert to buffer'); + t.end(); +}); diff --git a/node_modules/base64url/test/test.jpg b/node_modules/base64url/test/test.jpg new file mode 100644 index 0000000..0b80cb4 Binary files /dev/null and b/node_modules/base64url/test/test.jpg differ diff --git a/node_modules/bl/.jshintrc b/node_modules/bl/.jshintrc new file mode 100644 index 0000000..c8ef3ca --- /dev/null +++ b/node_modules/bl/.jshintrc @@ -0,0 +1,59 @@ +{ + "predef": [ ] + , "bitwise": false + , "camelcase": false + , "curly": false + , "eqeqeq": false + , "forin": false + , "immed": false + , "latedef": false + , "noarg": true + , "noempty": true + , "nonew": true + , "plusplus": false + , "quotmark": true + , "regexp": false + , "undef": true + , "unused": true + , "strict": false + , "trailing": true + , "maxlen": 120 + , "asi": true + , "boss": true + , "debug": true + , "eqnull": true + , "esnext": true + , "evil": true + , "expr": true + , "funcscope": false + , "globalstrict": false + , "iterator": false + , "lastsemic": true + , "laxbreak": true + , "laxcomma": true + , "loopfunc": true + , "multistr": false + , "onecase": false + , "proto": false + , "regexdash": false + , "scripturl": true + , "smarttabs": false + , "shadow": false + , "sub": true + , "supernew": false + , "validthis": true + , "browser": true + , "couch": false + , "devel": false + , "dojo": false + , "mootools": false + , "node": true + , "nonstandard": true + , "prototypejs": false + , "rhino": false + , "worker": true + , "wsh": false + , "nomen": false + , "onevar": false + , "passfail": false +} \ No newline at end of file diff --git a/node_modules/bl/.npmignore b/node_modules/bl/.npmignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/node_modules/bl/.npmignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/node_modules/bl/.travis.yml b/node_modules/bl/.travis.yml new file mode 100644 index 0000000..5cb0480 --- /dev/null +++ b/node_modules/bl/.travis.yml @@ -0,0 +1,13 @@ +sudo: false +language: node_js +node_js: + - '0.10' + - '0.12' + - '4' + - '5' +branches: + only: + - master +notifications: + email: + - rod@vagg.org diff --git a/node_modules/bl/LICENSE.md b/node_modules/bl/LICENSE.md new file mode 100644 index 0000000..ccb2479 --- /dev/null +++ b/node_modules/bl/LICENSE.md @@ -0,0 +1,13 @@ +The MIT License (MIT) +===================== + +Copyright (c) 2014 bl contributors +---------------------------------- + +*bl contributors listed at * + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/bl/README.md b/node_modules/bl/README.md new file mode 100644 index 0000000..f7044db --- /dev/null +++ b/node_modules/bl/README.md @@ -0,0 +1,200 @@ +# bl *(BufferList)* + +[![Build Status](https://travis-ci.org/rvagg/bl.svg?branch=master)](https://travis-ci.org/rvagg/bl) + +**A Node.js Buffer list collector, reader and streamer thingy.** + +[![NPM](https://nodei.co/npm/bl.png?downloads=true&downloadRank=true)](https://nodei.co/npm/bl/) +[![NPM](https://nodei.co/npm-dl/bl.png?months=6&height=3)](https://nodei.co/npm/bl/) + +**bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them! + +The original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently. + +```js +const BufferList = require('bl') + +var bl = new BufferList() +bl.append(new Buffer('abcd')) +bl.append(new Buffer('efg')) +bl.append('hi') // bl will also accept & convert Strings +bl.append(new Buffer('j')) +bl.append(new Buffer([ 0x3, 0x4 ])) + +console.log(bl.length) // 12 + +console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij' +console.log(bl.slice(3, 10).toString('ascii')) // 'defghij' +console.log(bl.slice(3, 6).toString('ascii')) // 'def' +console.log(bl.slice(3, 8).toString('ascii')) // 'defgh' +console.log(bl.slice(5, 10).toString('ascii')) // 'fghij' + +// or just use toString! +console.log(bl.toString()) // 'abcdefghij\u0003\u0004' +console.log(bl.toString('ascii', 3, 8)) // 'defgh' +console.log(bl.toString('ascii', 5, 10)) // 'fghij' + +// other standard Buffer readables +console.log(bl.readUInt16BE(10)) // 0x0304 +console.log(bl.readUInt16LE(10)) // 0x0403 +``` + +Give it a callback in the constructor and use it just like **[concat-stream](https://github.com/maxogden/node-concat-stream)**: + +```js +const bl = require('bl') + , fs = require('fs') + +fs.createReadStream('README.md') + .pipe(bl(function (err, data) { // note 'new' isn't strictly required + // `data` is a complete Buffer object containing the full data + console.log(data.toString()) + })) +``` + +Note that when you use the *callback* method like this, the resulting `data` parameter is a concatenation of all `Buffer` objects in the list. If you want to avoid the overhead of this concatenation (in cases of extreme performance consciousness), then avoid the *callback* method and just listen to `'end'` instead, like a standard Stream. + +Or to fetch a URL using [hyperquest](https://github.com/substack/hyperquest) (should work with [request](http://github.com/mikeal/request) and even plain Node http too!): +```js +const hyperquest = require('hyperquest') + , bl = require('bl') + , url = 'https://raw.github.com/rvagg/bl/master/README.md' + +hyperquest(url).pipe(bl(function (err, data) { + console.log(data.toString()) +})) +``` + +Or, use it as a readable stream to recompose a list of Buffers to an output source: + +```js +const BufferList = require('bl') + , fs = require('fs') + +var bl = new BufferList() +bl.append(new Buffer('abcd')) +bl.append(new Buffer('efg')) +bl.append(new Buffer('hi')) +bl.append(new Buffer('j')) + +bl.pipe(fs.createWriteStream('gibberish.txt')) +``` + +## API + + * new BufferList([ callback ]) + * bl.length + * bl.append(buffer) + * bl.get(index) + * bl.slice([ start[, end ] ]) + * bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ]) + * bl.duplicate() + * bl.consume(bytes) + * bl.toString([encoding, [ start, [ end ]]]) + * bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8() + * Streams + +-------------------------------------------------------- + +### new BufferList([ callback | Buffer | Buffer array | BufferList | BufferList array | String ]) +The constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream. + +Normally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object. + +`new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with: + +```js +var bl = require('bl') +var myinstance = bl() + +// equivilant to: + +var BufferList = require('bl') +var myinstance = new BufferList() +``` + +-------------------------------------------------------- + +### bl.length +Get the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list. + +-------------------------------------------------------- + +### bl.append(Buffer | Buffer array | BufferList | BufferList array | String) +`append(buffer)` adds an additional buffer or BufferList to the internal list. `this` is returned so it can be chained. + +-------------------------------------------------------- + +### bl.get(index) +`get()` will return the byte at the specified index. + +-------------------------------------------------------- + +### bl.slice([ start, [ end ] ]) +`slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively. + +If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer. + +-------------------------------------------------------- + +### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ]) +`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively. + +-------------------------------------------------------- + +### bl.duplicate() +`duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example: + +```js +var bl = new BufferList() + +bl.append('hello') +bl.append(' world') +bl.append('\n') + +bl.duplicate().pipe(process.stdout, { end: false }) + +console.log(bl.toString()) +``` + +-------------------------------------------------------- + +### bl.consume(bytes) +`consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers—initial offsets will be calculated accordingly in order to give you a consistent view of the data. + +-------------------------------------------------------- + +### bl.toString([encoding, [ start, [ end ]]]) +`toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information. + +-------------------------------------------------------- + +### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8() + +All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently. + +See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work. + +-------------------------------------------------------- + +### Streams +**bl** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **bl** instance. + +-------------------------------------------------------- + +## Contributors + +**bl** is brought to you by the following hackers: + + * [Rod Vagg](https://github.com/rvagg) + * [Matteo Collina](https://github.com/mcollina) + * [Jarett Cruger](https://github.com/jcrugzz) + +======= + + +## License & copyright + +Copyright (c) 2013-2014 bl contributors (listed above). + +bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details. diff --git a/node_modules/bl/bl.js b/node_modules/bl/bl.js new file mode 100644 index 0000000..f585df1 --- /dev/null +++ b/node_modules/bl/bl.js @@ -0,0 +1,243 @@ +var DuplexStream = require('readable-stream/duplex') + , util = require('util') + + +function BufferList (callback) { + if (!(this instanceof BufferList)) + return new BufferList(callback) + + this._bufs = [] + this.length = 0 + + if (typeof callback == 'function') { + this._callback = callback + + var piper = function piper (err) { + if (this._callback) { + this._callback(err) + this._callback = null + } + }.bind(this) + + this.on('pipe', function onPipe (src) { + src.on('error', piper) + }) + this.on('unpipe', function onUnpipe (src) { + src.removeListener('error', piper) + }) + } else { + this.append(callback) + } + + DuplexStream.call(this) +} + + +util.inherits(BufferList, DuplexStream) + + +BufferList.prototype._offset = function _offset (offset) { + var tot = 0, i = 0, _t + for (; i < this._bufs.length; i++) { + _t = tot + this._bufs[i].length + if (offset < _t) + return [ i, offset - tot ] + tot = _t + } +} + + +BufferList.prototype.append = function append (buf) { + var i = 0 + , newBuf + + if (Array.isArray(buf)) { + for (; i < buf.length; i++) + this.append(buf[i]) + } else if (buf instanceof BufferList) { + // unwrap argument into individual BufferLists + for (; i < buf._bufs.length; i++) + this.append(buf._bufs[i]) + } else if (buf != null) { + // coerce number arguments to strings, since Buffer(number) does + // uninitialized memory allocation + if (typeof buf == 'number') + buf = buf.toString() + + newBuf = Buffer.isBuffer(buf) ? buf : new Buffer(buf) + this._bufs.push(newBuf) + this.length += newBuf.length + } + + return this +} + + +BufferList.prototype._write = function _write (buf, encoding, callback) { + this.append(buf) + + if (typeof callback == 'function') + callback() +} + + +BufferList.prototype._read = function _read (size) { + if (!this.length) + return this.push(null) + + size = Math.min(size, this.length) + this.push(this.slice(0, size)) + this.consume(size) +} + + +BufferList.prototype.end = function end (chunk) { + DuplexStream.prototype.end.call(this, chunk) + + if (this._callback) { + this._callback(null, this.slice()) + this._callback = null + } +} + + +BufferList.prototype.get = function get (index) { + return this.slice(index, index + 1)[0] +} + + +BufferList.prototype.slice = function slice (start, end) { + return this.copy(null, 0, start, end) +} + + +BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) { + if (typeof srcStart != 'number' || srcStart < 0) + srcStart = 0 + if (typeof srcEnd != 'number' || srcEnd > this.length) + srcEnd = this.length + if (srcStart >= this.length) + return dst || new Buffer(0) + if (srcEnd <= 0) + return dst || new Buffer(0) + + var copy = !!dst + , off = this._offset(srcStart) + , len = srcEnd - srcStart + , bytes = len + , bufoff = (copy && dstStart) || 0 + , start = off[1] + , l + , i + + // copy/slice everything + if (srcStart === 0 && srcEnd == this.length) { + if (!copy) // slice, just return a full concat + return Buffer.concat(this._bufs) + + // copy, need to copy individual buffers + for (i = 0; i < this._bufs.length; i++) { + this._bufs[i].copy(dst, bufoff) + bufoff += this._bufs[i].length + } + + return dst + } + + // easy, cheap case where it's a subset of one of the buffers + if (bytes <= this._bufs[off[0]].length - start) { + return copy + ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes) + : this._bufs[off[0]].slice(start, start + bytes) + } + + if (!copy) // a slice, we need something to copy in to + dst = new Buffer(len) + + for (i = off[0]; i < this._bufs.length; i++) { + l = this._bufs[i].length - start + + if (bytes > l) { + this._bufs[i].copy(dst, bufoff, start) + } else { + this._bufs[i].copy(dst, bufoff, start, start + bytes) + break + } + + bufoff += l + bytes -= l + + if (start) + start = 0 + } + + return dst +} + +BufferList.prototype.toString = function toString (encoding, start, end) { + return this.slice(start, end).toString(encoding) +} + +BufferList.prototype.consume = function consume (bytes) { + while (this._bufs.length) { + if (bytes >= this._bufs[0].length) { + bytes -= this._bufs[0].length + this.length -= this._bufs[0].length + this._bufs.shift() + } else { + this._bufs[0] = this._bufs[0].slice(bytes) + this.length -= bytes + break + } + } + return this +} + + +BufferList.prototype.duplicate = function duplicate () { + var i = 0 + , copy = new BufferList() + + for (; i < this._bufs.length; i++) + copy.append(this._bufs[i]) + + return copy +} + + +BufferList.prototype.destroy = function destroy () { + this._bufs.length = 0 + this.length = 0 + this.push(null) +} + + +;(function () { + var methods = { + 'readDoubleBE' : 8 + , 'readDoubleLE' : 8 + , 'readFloatBE' : 4 + , 'readFloatLE' : 4 + , 'readInt32BE' : 4 + , 'readInt32LE' : 4 + , 'readUInt32BE' : 4 + , 'readUInt32LE' : 4 + , 'readInt16BE' : 2 + , 'readInt16LE' : 2 + , 'readUInt16BE' : 2 + , 'readUInt16LE' : 2 + , 'readInt8' : 1 + , 'readUInt8' : 1 + } + + for (var m in methods) { + (function (m) { + BufferList.prototype[m] = function (offset) { + return this.slice(offset, offset + methods[m])[m](0) + } + }(m)) + } +}()) + + +module.exports = BufferList diff --git a/node_modules/bl/node_modules/isarray/.npmignore b/node_modules/bl/node_modules/isarray/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/node_modules/bl/node_modules/isarray/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/bl/node_modules/isarray/.travis.yml b/node_modules/bl/node_modules/isarray/.travis.yml new file mode 100644 index 0000000..cc4dba2 --- /dev/null +++ b/node_modules/bl/node_modules/isarray/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/node_modules/bl/node_modules/isarray/Makefile b/node_modules/bl/node_modules/isarray/Makefile new file mode 100644 index 0000000..787d56e --- /dev/null +++ b/node_modules/bl/node_modules/isarray/Makefile @@ -0,0 +1,6 @@ + +test: + @node_modules/.bin/tape test.js + +.PHONY: test + diff --git a/node_modules/bl/node_modules/isarray/README.md b/node_modules/bl/node_modules/isarray/README.md new file mode 100644 index 0000000..16d2c59 --- /dev/null +++ b/node_modules/bl/node_modules/isarray/README.md @@ -0,0 +1,60 @@ + +# isarray + +`Array#isArray` for older browsers. + +[![build status](https://secure.travis-ci.org/juliangruber/isarray.svg)](http://travis-ci.org/juliangruber/isarray) +[![downloads](https://img.shields.io/npm/dm/isarray.svg)](https://www.npmjs.org/package/isarray) + +[![browser support](https://ci.testling.com/juliangruber/isarray.png) +](https://ci.testling.com/juliangruber/isarray) + +## Usage + +```js +var isArray = require('isarray'); + +console.log(isArray([])); // => true +console.log(isArray({})); // => false +``` + +## Installation + +With [npm](http://npmjs.org) do + +```bash +$ npm install isarray +``` + +Then bundle for the browser with +[browserify](https://github.com/substack/browserify). + +With [component](http://component.io) do + +```bash +$ component install juliangruber/isarray +``` + +## License + +(MIT) + +Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/bl/node_modules/isarray/component.json b/node_modules/bl/node_modules/isarray/component.json new file mode 100644 index 0000000..9e31b68 --- /dev/null +++ b/node_modules/bl/node_modules/isarray/component.json @@ -0,0 +1,19 @@ +{ + "name" : "isarray", + "description" : "Array#isArray for older browsers", + "version" : "0.0.1", + "repository" : "juliangruber/isarray", + "homepage": "https://github.com/juliangruber/isarray", + "main" : "index.js", + "scripts" : [ + "index.js" + ], + "dependencies" : {}, + "keywords": ["browser","isarray","array"], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT" +} diff --git a/node_modules/bl/node_modules/isarray/index.js b/node_modules/bl/node_modules/isarray/index.js new file mode 100644 index 0000000..a57f634 --- /dev/null +++ b/node_modules/bl/node_modules/isarray/index.js @@ -0,0 +1,5 @@ +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; diff --git a/node_modules/bl/node_modules/isarray/package.json b/node_modules/bl/node_modules/isarray/package.json new file mode 100644 index 0000000..3f088fb --- /dev/null +++ b/node_modules/bl/node_modules/isarray/package.json @@ -0,0 +1,73 @@ +{ + "_from": "isarray@~1.0.0", + "_id": "isarray@1.0.0", + "_inBundle": false, + "_integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "_location": "/bl/isarray", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "isarray@~1.0.0", + "name": "isarray", + "escapedName": "isarray", + "rawSpec": "~1.0.0", + "saveSpec": null, + "fetchSpec": "~1.0.0" + }, + "_requiredBy": [ + "/bl/readable-stream" + ], + "_resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "_shasum": "bb935d48582cba168c06834957a54a3e07124f11", + "_spec": "isarray@~1.0.0", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\bl\\node_modules\\readable-stream", + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "bugs": { + "url": "https://github.com/juliangruber/isarray/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "Array#isArray for older browsers", + "devDependencies": { + "tape": "~2.13.4" + }, + "homepage": "https://github.com/juliangruber/isarray", + "keywords": [ + "browser", + "isarray", + "array" + ], + "license": "MIT", + "main": "index.js", + "name": "isarray", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/isarray.git" + }, + "scripts": { + "test": "tape test.js" + }, + "testling": { + "files": "test.js", + "browsers": [ + "ie/8..latest", + "firefox/17..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "version": "1.0.0" +} diff --git a/node_modules/bl/node_modules/process-nextick-args/.travis.yml b/node_modules/bl/node_modules/process-nextick-args/.travis.yml new file mode 100644 index 0000000..36201b1 --- /dev/null +++ b/node_modules/bl/node_modules/process-nextick-args/.travis.yml @@ -0,0 +1,12 @@ +language: node_js +node_js: + - "0.8" + - "0.10" + - "0.11" + - "0.12" + - "1.7.1" + - 1 + - 2 + - 3 + - 4 + - 5 diff --git a/node_modules/bl/node_modules/process-nextick-args/index.js b/node_modules/bl/node_modules/process-nextick-args/index.js new file mode 100644 index 0000000..a4f40f8 --- /dev/null +++ b/node_modules/bl/node_modules/process-nextick-args/index.js @@ -0,0 +1,43 @@ +'use strict'; + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = nextTick; +} else { + module.exports = process.nextTick; +} + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } +} diff --git a/node_modules/bl/node_modules/process-nextick-args/license.md b/node_modules/bl/node_modules/process-nextick-args/license.md new file mode 100644 index 0000000..c67e353 --- /dev/null +++ b/node_modules/bl/node_modules/process-nextick-args/license.md @@ -0,0 +1,19 @@ +# Copyright (c) 2015 Calvin Metcalf + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.** diff --git a/node_modules/bl/node_modules/process-nextick-args/package.json b/node_modules/bl/node_modules/process-nextick-args/package.json new file mode 100644 index 0000000..ecaf610 --- /dev/null +++ b/node_modules/bl/node_modules/process-nextick-args/package.json @@ -0,0 +1,47 @@ +{ + "_from": "process-nextick-args@~1.0.6", + "_id": "process-nextick-args@1.0.7", + "_inBundle": false, + "_integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "_location": "/bl/process-nextick-args", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "process-nextick-args@~1.0.6", + "name": "process-nextick-args", + "escapedName": "process-nextick-args", + "rawSpec": "~1.0.6", + "saveSpec": null, + "fetchSpec": "~1.0.6" + }, + "_requiredBy": [ + "/bl/readable-stream" + ], + "_resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "_shasum": "150e20b756590ad3f91093f25a4f2ad8bff30ba3", + "_spec": "process-nextick-args@~1.0.6", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\bl\\node_modules\\readable-stream", + "author": "", + "bugs": { + "url": "https://github.com/calvinmetcalf/process-nextick-args/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "process.nextTick but always with args", + "devDependencies": { + "tap": "~0.2.6" + }, + "homepage": "https://github.com/calvinmetcalf/process-nextick-args", + "license": "MIT", + "main": "index.js", + "name": "process-nextick-args", + "repository": { + "type": "git", + "url": "git+https://github.com/calvinmetcalf/process-nextick-args.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.7" +} diff --git a/node_modules/bl/node_modules/process-nextick-args/readme.md b/node_modules/bl/node_modules/process-nextick-args/readme.md new file mode 100644 index 0000000..78e7cfa --- /dev/null +++ b/node_modules/bl/node_modules/process-nextick-args/readme.md @@ -0,0 +1,18 @@ +process-nextick-args +===== + +[![Build Status](https://travis-ci.org/calvinmetcalf/process-nextick-args.svg?branch=master)](https://travis-ci.org/calvinmetcalf/process-nextick-args) + +```bash +npm install --save process-nextick-args +``` + +Always be able to pass arguments to process.nextTick, no matter the platform + +```js +var nextTick = require('process-nextick-args'); + +nextTick(function (a, b, c) { + console.log(a, b, c); +}, 'step', 3, 'profit'); +``` diff --git a/node_modules/bl/node_modules/readable-stream/.npmignore b/node_modules/bl/node_modules/readable-stream/.npmignore new file mode 100644 index 0000000..38344f8 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/.npmignore @@ -0,0 +1,5 @@ +build/ +test/ +examples/ +fs.js +zlib.js \ No newline at end of file diff --git a/node_modules/bl/node_modules/readable-stream/.travis.yml b/node_modules/bl/node_modules/readable-stream/.travis.yml new file mode 100644 index 0000000..1b82118 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/.travis.yml @@ -0,0 +1,52 @@ +sudo: false +language: node_js +before_install: + - npm install -g npm@2 + - npm install -g npm +notifications: + email: false +matrix: + fast_finish: true + allow_failures: + - env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="6.0..latest" + - env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="6.0..latest" + include: + - node_js: '0.8' + env: TASK=test + - node_js: '0.10' + env: TASK=test + - node_js: '0.11' + env: TASK=test + - node_js: '0.12' + env: TASK=test + - node_js: 1 + env: TASK=test + - node_js: 2 + env: TASK=test + - node_js: 3 + env: TASK=test + - node_js: 4 + env: TASK=test + - node_js: 5 + env: TASK=test + - node_js: 5 + env: TASK=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=ie BROWSER_VERSION="9..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=opera BROWSER_VERSION="11..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=chrome BROWSER_VERSION="-3..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="-3..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="6.0..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="6.0..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest" +script: "npm run $TASK" +env: + global: + - secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc= + - secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI= diff --git a/node_modules/bl/node_modules/readable-stream/.zuul.yml b/node_modules/bl/node_modules/readable-stream/.zuul.yml new file mode 100644 index 0000000..96d9cfb --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/.zuul.yml @@ -0,0 +1 @@ +ui: tape diff --git a/node_modules/bl/node_modules/readable-stream/LICENSE b/node_modules/bl/node_modules/readable-stream/LICENSE new file mode 100644 index 0000000..e3d4e69 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. and other Node contributors. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/node_modules/bl/node_modules/readable-stream/README.md b/node_modules/bl/node_modules/readable-stream/README.md new file mode 100644 index 0000000..86b95a3 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/README.md @@ -0,0 +1,36 @@ +# readable-stream + +***Node-core v5.8.0 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream) + + +[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/) +[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/) + + +[![Sauce Test Status](https://saucelabs.com/browser-matrix/readable-stream.svg)](https://saucelabs.com/u/readable-stream) + +```bash +npm install --save readable-stream +``` + +***Node-core streams for userland*** + +This package is a mirror of the Streams2 and Streams3 implementations in +Node-core, including [documentation](doc/stream.markdown). + +If you want to guarantee a stable streams base, regardless of what version of +Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html). + +As of version 2.0.0 **readable-stream** uses semantic versioning. + +# Streams WG Team Members + +* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com> + - Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B +* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com> + - Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242 +* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org> + - Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D +* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com> +* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com> +* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me> diff --git a/node_modules/bl/node_modules/readable-stream/doc/stream.markdown b/node_modules/bl/node_modules/readable-stream/doc/stream.markdown new file mode 100644 index 0000000..0bc3819 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/doc/stream.markdown @@ -0,0 +1,1760 @@ +# Stream + + Stability: 2 - Stable + +A stream is an abstract interface implemented by various objects in +Node.js. For example a [request to an HTTP server][http-incoming-message] is a +stream, as is [`process.stdout`][]. Streams are readable, writable, or both. All +streams are instances of [`EventEmitter`][]. + +You can load the Stream base classes by doing `require('stream')`. +There are base classes provided for [Readable][] streams, [Writable][] +streams, [Duplex][] streams, and [Transform][] streams. + +This document is split up into 3 sections: + +1. The first section explains the parts of the API that you need to be + aware of to use streams in your programs. +2. The second section explains the parts of the API that you need to + use if you implement your own custom streams yourself. The API is designed to + make this easy for you to do. +3. The third section goes into more depth about how streams work, + including some of the internal mechanisms and functions that you + should probably not modify unless you definitely know what you are + doing. + + +## API for Stream Consumers + + + +Streams can be either [Readable][], [Writable][], or both ([Duplex][]). + +All streams are EventEmitters, but they also have other custom methods +and properties depending on whether they are Readable, Writable, or +Duplex. + +If a stream is both Readable and Writable, then it implements all of +the methods and events. So, a [Duplex][] or [Transform][] stream is +fully described by this API, though their implementation may be +somewhat different. + +It is not necessary to implement Stream interfaces in order to consume +streams in your programs. If you **are** implementing streaming +interfaces in your own program, please also refer to +[API for Stream Implementors][]. + +Almost all Node.js programs, no matter how simple, use Streams in some +way. Here is an example of using Streams in an Node.js program: + +```js +const http = require('http'); + +var server = http.createServer( (req, res) => { + // req is an http.IncomingMessage, which is a Readable Stream + // res is an http.ServerResponse, which is a Writable Stream + + var body = ''; + // we want to get the data as utf8 strings + // If you don't set an encoding, then you'll get Buffer objects + req.setEncoding('utf8'); + + // Readable streams emit 'data' events once a listener is added + req.on('data', (chunk) => { + body += chunk; + }); + + // the end event tells you that you have entire body + req.on('end', () => { + try { + var data = JSON.parse(body); + } catch (er) { + // uh oh! bad json! + res.statusCode = 400; + return res.end(`error: ${er.message}`); + } + + // write back something interesting to the user: + res.write(typeof data); + res.end(); + }); +}); + +server.listen(1337); + +// $ curl localhost:1337 -d '{}' +// object +// $ curl localhost:1337 -d '"foo"' +// string +// $ curl localhost:1337 -d 'not json' +// error: Unexpected token o +``` + +### Class: stream.Duplex + +Duplex streams are streams that implement both the [Readable][] and +[Writable][] interfaces. + +Examples of Duplex streams include: + +* [TCP sockets][] +* [zlib streams][zlib] +* [crypto streams][crypto] + +### Class: stream.Readable + + + +The Readable stream interface is the abstraction for a *source* of +data that you are reading from. In other words, data comes *out* of a +Readable stream. + +A Readable stream will not start emitting data until you indicate that +you are ready to receive it. + +Readable streams have two "modes": a **flowing mode** and a **paused +mode**. When in flowing mode, data is read from the underlying system +and provided to your program as fast as possible. In paused mode, you +must explicitly call [`stream.read()`][stream-read] to get chunks of data out. +Streams start out in paused mode. + +**Note**: If no data event handlers are attached, and there are no +[`stream.pipe()`][] destinations, and the stream is switched into flowing +mode, then data will be lost. + +You can switch to flowing mode by doing any of the following: + +* Adding a [`'data'`][] event handler to listen for data. +* Calling the [`stream.resume()`][stream-resume] method to explicitly open the + flow. +* Calling the [`stream.pipe()`][] method to send the data to a [Writable][]. + +You can switch back to paused mode by doing either of the following: + +* If there are no pipe destinations, by calling the + [`stream.pause()`][stream-pause] method. +* If there are pipe destinations, by removing any [`'data'`][] event + handlers, and removing all pipe destinations by calling the + [`stream.unpipe()`][] method. + +Note that, for backwards compatibility reasons, removing [`'data'`][] +event handlers will **not** automatically pause the stream. Also, if +there are piped destinations, then calling [`stream.pause()`][stream-pause] will +not guarantee that the stream will *remain* paused once those +destinations drain and ask for more data. + +Examples of readable streams include: + +* [HTTP responses, on the client][http-incoming-message] +* [HTTP requests, on the server][http-incoming-message] +* [fs read streams][] +* [zlib streams][zlib] +* [crypto streams][crypto] +* [TCP sockets][] +* [child process stdout and stderr][] +* [`process.stdin`][] + +#### Event: 'close' + +Emitted when the stream and any of its underlying resources (a file +descriptor, for example) have been closed. The event indicates that +no more events will be emitted, and no further computation will occur. + +Not all streams will emit the `'close'` event. + +#### Event: 'data' + +* `chunk` {Buffer|String} The chunk of data. + +Attaching a `'data'` event listener to a stream that has not been +explicitly paused will switch the stream into flowing mode. Data will +then be passed as soon as it is available. + +If you just want to get all the data out of the stream as fast as +possible, this is the best way to do so. + +```js +var readable = getReadableStreamSomehow(); +readable.on('data', (chunk) => { + console.log('got %d bytes of data', chunk.length); +}); +``` + +#### Event: 'end' + +This event fires when there will be no more data to read. + +Note that the `'end'` event **will not fire** unless the data is +completely consumed. This can be done by switching into flowing mode, +or by calling [`stream.read()`][stream-read] repeatedly until you get to the +end. + +```js +var readable = getReadableStreamSomehow(); +readable.on('data', (chunk) => { + console.log('got %d bytes of data', chunk.length); +}); +readable.on('end', () => { + console.log('there will be no more data.'); +}); +``` + +#### Event: 'error' + +* {Error Object} + +Emitted if there was an error receiving data. + +#### Event: 'readable' + +When a chunk of data can be read from the stream, it will emit a +`'readable'` event. + +In some cases, listening for a `'readable'` event will cause some data +to be read into the internal buffer from the underlying system, if it +hadn't already. + +```javascript +var readable = getReadableStreamSomehow(); +readable.on('readable', () => { + // there is some data to read now +}); +``` + +Once the internal buffer is drained, a `'readable'` event will fire +again when more data is available. + +The `'readable'` event is not emitted in the "flowing" mode with the +sole exception of the last one, on end-of-stream. + +The `'readable'` event indicates that the stream has new information: +either new data is available or the end of the stream has been reached. +In the former case, [`stream.read()`][stream-read] will return that data. In the +latter case, [`stream.read()`][stream-read] will return null. For instance, in +the following example, `foo.txt` is an empty file: + +```js +const fs = require('fs'); +var rr = fs.createReadStream('foo.txt'); +rr.on('readable', () => { + console.log('readable:', rr.read()); +}); +rr.on('end', () => { + console.log('end'); +}); +``` + +The output of running this script is: + +``` +$ node test.js +readable: null +end +``` + +#### readable.isPaused() + +* Return: {Boolean} + +This method returns whether or not the `readable` has been **explicitly** +paused by client code (using [`stream.pause()`][stream-pause] without a +corresponding [`stream.resume()`][stream-resume]). + +```js +var readable = new stream.Readable + +readable.isPaused() // === false +readable.pause() +readable.isPaused() // === true +readable.resume() +readable.isPaused() // === false +``` + +#### readable.pause() + +* Return: `this` + +This method will cause a stream in flowing mode to stop emitting +[`'data'`][] events, switching out of flowing mode. Any data that becomes +available will remain in the internal buffer. + +```js +var readable = getReadableStreamSomehow(); +readable.on('data', (chunk) => { + console.log('got %d bytes of data', chunk.length); + readable.pause(); + console.log('there will be no more data for 1 second'); + setTimeout(() => { + console.log('now data will start flowing again'); + readable.resume(); + }, 1000); +}); +``` + +#### readable.pipe(destination[, options]) + +* `destination` {stream.Writable} The destination for writing data +* `options` {Object} Pipe options + * `end` {Boolean} End the writer when the reader ends. Default = `true` + +This method pulls all the data out of a readable stream, and writes it +to the supplied destination, automatically managing the flow so that +the destination is not overwhelmed by a fast readable stream. + +Multiple destinations can be piped to safely. + +```js +var readable = getReadableStreamSomehow(); +var writable = fs.createWriteStream('file.txt'); +// All the data from readable goes into 'file.txt' +readable.pipe(writable); +``` + +This function returns the destination stream, so you can set up pipe +chains like so: + +```js +var r = fs.createReadStream('file.txt'); +var z = zlib.createGzip(); +var w = fs.createWriteStream('file.txt.gz'); +r.pipe(z).pipe(w); +``` + +For example, emulating the Unix `cat` command: + +```js +process.stdin.pipe(process.stdout); +``` + +By default [`stream.end()`][stream-end] is called on the destination when the +source stream emits [`'end'`][], so that `destination` is no longer writable. +Pass `{ end: false }` as `options` to keep the destination stream open. + +This keeps `writer` open so that "Goodbye" can be written at the +end. + +```js +reader.pipe(writer, { end: false }); +reader.on('end', () => { + writer.end('Goodbye\n'); +}); +``` + +Note that [`process.stderr`][] and [`process.stdout`][] are never closed until +the process exits, regardless of the specified options. + +#### readable.read([size]) + +* `size` {Number} Optional argument to specify how much data to read. +* Return {String|Buffer|Null} + +The `read()` method pulls some data out of the internal buffer and +returns it. If there is no data available, then it will return +`null`. + +If you pass in a `size` argument, then it will return that many +bytes. If `size` bytes are not available, then it will return `null`, +unless we've ended, in which case it will return the data remaining +in the buffer. + +If you do not specify a `size` argument, then it will return all the +data in the internal buffer. + +This method should only be called in paused mode. In flowing mode, +this method is called automatically until the internal buffer is +drained. + +```js +var readable = getReadableStreamSomehow(); +readable.on('readable', () => { + var chunk; + while (null !== (chunk = readable.read())) { + console.log('got %d bytes of data', chunk.length); + } +}); +``` + +If this method returns a data chunk, then it will also trigger the +emission of a [`'data'`][] event. + +Note that calling [`stream.read([size])`][stream-read] after the [`'end'`][] +event has been triggered will return `null`. No runtime error will be raised. + +#### readable.resume() + +* Return: `this` + +This method will cause the readable stream to resume emitting [`'data'`][] +events. + +This method will switch the stream into flowing mode. If you do *not* +want to consume the data from a stream, but you *do* want to get to +its [`'end'`][] event, you can call [`stream.resume()`][stream-resume] to open +the flow of data. + +```js +var readable = getReadableStreamSomehow(); +readable.resume(); +readable.on('end', () => { + console.log('got to the end, but did not read anything'); +}); +``` + +#### readable.setEncoding(encoding) + +* `encoding` {String} The encoding to use. +* Return: `this` + +Call this function to cause the stream to return strings of the specified +encoding instead of Buffer objects. For example, if you do +`readable.setEncoding('utf8')`, then the output data will be interpreted as +UTF-8 data, and returned as strings. If you do `readable.setEncoding('hex')`, +then the data will be encoded in hexadecimal string format. + +This properly handles multi-byte characters that would otherwise be +potentially mangled if you simply pulled the Buffers directly and +called [`buf.toString(encoding)`][] on them. If you want to read the data +as strings, always use this method. + +Also you can disable any encoding at all with `readable.setEncoding(null)`. +This approach is very useful if you deal with binary data or with large +multi-byte strings spread out over multiple chunks. + +```js +var readable = getReadableStreamSomehow(); +readable.setEncoding('utf8'); +readable.on('data', (chunk) => { + assert.equal(typeof chunk, 'string'); + console.log('got %d characters of string data', chunk.length); +}); +``` + +#### readable.unpipe([destination]) + +* `destination` {stream.Writable} Optional specific stream to unpipe + +This method will remove the hooks set up for a previous [`stream.pipe()`][] +call. + +If the destination is not specified, then all pipes are removed. + +If the destination is specified, but no pipe is set up for it, then +this is a no-op. + +```js +var readable = getReadableStreamSomehow(); +var writable = fs.createWriteStream('file.txt'); +// All the data from readable goes into 'file.txt', +// but only for the first second +readable.pipe(writable); +setTimeout(() => { + console.log('stop writing to file.txt'); + readable.unpipe(writable); + console.log('manually close the file stream'); + writable.end(); +}, 1000); +``` + +#### readable.unshift(chunk) + +* `chunk` {Buffer|String} Chunk of data to unshift onto the read queue + +This is useful in certain cases where a stream is being consumed by a +parser, which needs to "un-consume" some data that it has +optimistically pulled out of the source, so that the stream can be +passed on to some other party. + +Note that `stream.unshift(chunk)` cannot be called after the [`'end'`][] event +has been triggered; a runtime error will be raised. + +If you find that you must often call `stream.unshift(chunk)` in your +programs, consider implementing a [Transform][] stream instead. (See [API +for Stream Implementors][].) + +```js +// Pull off a header delimited by \n\n +// use unshift() if we get too much +// Call the callback with (error, header, stream) +const StringDecoder = require('string_decoder').StringDecoder; +function parseHeader(stream, callback) { + stream.on('error', callback); + stream.on('readable', onReadable); + var decoder = new StringDecoder('utf8'); + var header = ''; + function onReadable() { + var chunk; + while (null !== (chunk = stream.read())) { + var str = decoder.write(chunk); + if (str.match(/\n\n/)) { + // found the header boundary + var split = str.split(/\n\n/); + header += split.shift(); + var remaining = split.join('\n\n'); + var buf = new Buffer(remaining, 'utf8'); + if (buf.length) + stream.unshift(buf); + stream.removeListener('error', callback); + stream.removeListener('readable', onReadable); + // now the body of the message can be read from the stream. + callback(null, header, stream); + } else { + // still reading the header. + header += str; + } + } + } +} +``` + +Note that, unlike [`stream.push(chunk)`][stream-push], `stream.unshift(chunk)` +will not end the reading process by resetting the internal reading state of the +stream. This can cause unexpected results if `unshift()` is called during a +read (i.e. from within a [`stream._read()`][stream-_read] implementation on a +custom stream). Following the call to `unshift()` with an immediate +[`stream.push('')`][stream-push] will reset the reading state appropriately, +however it is best to simply avoid calling `unshift()` while in the process of +performing a read. + +#### readable.wrap(stream) + +* `stream` {Stream} An "old style" readable stream + +Versions of Node.js prior to v0.10 had streams that did not implement the +entire Streams API as it is today. (See [Compatibility][] for +more information.) + +If you are using an older Node.js library that emits [`'data'`][] events and +has a [`stream.pause()`][stream-pause] method that is advisory only, then you +can use the `wrap()` method to create a [Readable][] stream that uses the old +stream as its data source. + +You will very rarely ever need to call this function, but it exists +as a convenience for interacting with old Node.js programs and libraries. + +For example: + +```js +const OldReader = require('./old-api-module.js').OldReader; +const Readable = require('stream').Readable; +const oreader = new OldReader; +const myReader = new Readable().wrap(oreader); + +myReader.on('readable', () => { + myReader.read(); // etc. +}); +``` + +### Class: stream.Transform + +Transform streams are [Duplex][] streams where the output is in some way +computed from the input. They implement both the [Readable][] and +[Writable][] interfaces. + +Examples of Transform streams include: + +* [zlib streams][zlib] +* [crypto streams][crypto] + +### Class: stream.Writable + + + +The Writable stream interface is an abstraction for a *destination* +that you are writing data *to*. + +Examples of writable streams include: + +* [HTTP requests, on the client][] +* [HTTP responses, on the server][] +* [fs write streams][] +* [zlib streams][zlib] +* [crypto streams][crypto] +* [TCP sockets][] +* [child process stdin][] +* [`process.stdout`][], [`process.stderr`][] + +#### Event: 'drain' + +If a [`stream.write(chunk)`][stream-write] call returns `false`, then the +`'drain'` event will indicate when it is appropriate to begin writing more data +to the stream. + +```js +// Write the data to the supplied writable stream one million times. +// Be attentive to back-pressure. +function writeOneMillionTimes(writer, data, encoding, callback) { + var i = 1000000; + write(); + function write() { + var ok = true; + do { + i -= 1; + if (i === 0) { + // last time! + writer.write(data, encoding, callback); + } else { + // see if we should continue, or wait + // don't pass the callback, because we're not done yet. + ok = writer.write(data, encoding); + } + } while (i > 0 && ok); + if (i > 0) { + // had to stop early! + // write some more once it drains + writer.once('drain', write); + } + } +} +``` + +#### Event: 'error' + +* {Error} + +Emitted if there was an error when writing or piping data. + +#### Event: 'finish' + +When the [`stream.end()`][stream-end] method has been called, and all data has +been flushed to the underlying system, this event is emitted. + +```javascript +var writer = getWritableStreamSomehow(); +for (var i = 0; i < 100; i ++) { + writer.write('hello, #${i}!\n'); +} +writer.end('this is the end\n'); +writer.on('finish', () => { + console.error('all writes are now complete.'); +}); +``` + +#### Event: 'pipe' + +* `src` {stream.Readable} source stream that is piping to this writable + +This is emitted whenever the [`stream.pipe()`][] method is called on a readable +stream, adding this writable to its set of destinations. + +```js +var writer = getWritableStreamSomehow(); +var reader = getReadableStreamSomehow(); +writer.on('pipe', (src) => { + console.error('something is piping into the writer'); + assert.equal(src, reader); +}); +reader.pipe(writer); +``` + +#### Event: 'unpipe' + +* `src` {[Readable][] Stream} The source stream that + [unpiped][`stream.unpipe()`] this writable + +This is emitted whenever the [`stream.unpipe()`][] method is called on a +readable stream, removing this writable from its set of destinations. + +```js +var writer = getWritableStreamSomehow(); +var reader = getReadableStreamSomehow(); +writer.on('unpipe', (src) => { + console.error('something has stopped piping into the writer'); + assert.equal(src, reader); +}); +reader.pipe(writer); +reader.unpipe(writer); +``` + +#### writable.cork() + +Forces buffering of all writes. + +Buffered data will be flushed either at [`stream.uncork()`][] or at +[`stream.end()`][stream-end] call. + +#### writable.end([chunk][, encoding][, callback]) + +* `chunk` {String|Buffer} Optional data to write +* `encoding` {String} The encoding, if `chunk` is a String +* `callback` {Function} Optional callback for when the stream is finished + +Call this method when no more data will be written to the stream. If supplied, +the callback is attached as a listener on the [`'finish'`][] event. + +Calling [`stream.write()`][stream-write] after calling +[`stream.end()`][stream-end] will raise an error. + +```js +// write 'hello, ' and then end with 'world!' +var file = fs.createWriteStream('example.txt'); +file.write('hello, '); +file.end('world!'); +// writing more now is not allowed! +``` + +#### writable.setDefaultEncoding(encoding) + +* `encoding` {String} The new default encoding + +Sets the default encoding for a writable stream. + +#### writable.uncork() + +Flush all data, buffered since [`stream.cork()`][] call. + +#### writable.write(chunk[, encoding][, callback]) + +* `chunk` {String|Buffer} The data to write +* `encoding` {String} The encoding, if `chunk` is a String +* `callback` {Function} Callback for when this chunk of data is flushed +* Returns: {Boolean} `true` if the data was handled completely. + +This method writes some data to the underlying system, and calls the +supplied callback once the data has been fully handled. + +The return value indicates if you should continue writing right now. +If the data had to be buffered internally, then it will return +`false`. Otherwise, it will return `true`. + +This return value is strictly advisory. You MAY continue to write, +even if it returns `false`. However, writes will be buffered in +memory, so it is best not to do this excessively. Instead, wait for +the [`'drain'`][] event before writing more data. + + +## API for Stream Implementors + + + +To implement any sort of stream, the pattern is the same: + +1. Extend the appropriate parent class in your own subclass. (The + [`util.inherits()`][] method is particularly helpful for this.) +2. Call the appropriate parent class constructor in your constructor, + to be sure that the internal mechanisms are set up properly. +3. Implement one or more specific methods, as detailed below. + +The class to extend and the method(s) to implement depend on the sort +of stream class you are writing: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Use-case

+
+

Class

+
+

Method(s) to implement

+
+

Reading only

+
+

[Readable](#stream_class_stream_readable_1)

+
+

[_read][stream-_read]

+
+

Writing only

+
+

[Writable](#stream_class_stream_writable_1)

+
+

[_write][stream-_write], [_writev][stream-_writev]

+
+

Reading and writing

+
+

[Duplex](#stream_class_stream_duplex_1)

+
+

[_read][stream-_read], [_write][stream-_write], [_writev][stream-_writev]

+
+

Operate on written data, then read the result

+
+

[Transform](#stream_class_stream_transform_1)

+
+

[_transform][stream-_transform], [_flush][stream-_flush]

+
+ +In your implementation code, it is very important to never call the methods +described in [API for Stream Consumers][]. Otherwise, you can potentially cause +adverse side effects in programs that consume your streaming interfaces. + +### Class: stream.Duplex + + + +A "duplex" stream is one that is both Readable and Writable, such as a TCP +socket connection. + +Note that `stream.Duplex` is an abstract class designed to be extended +with an underlying implementation of the [`stream._read(size)`][stream-_read] +and [`stream._write(chunk, encoding, callback)`][stream-_write] methods as you +would with a Readable or Writable stream class. + +Since JavaScript doesn't have multiple prototypal inheritance, this class +prototypally inherits from Readable, and then parasitically from Writable. It is +thus up to the user to implement both the low-level +[`stream._read(n)`][stream-_read] method as well as the low-level +[`stream._write(chunk, encoding, callback)`][stream-_write] method on extension +duplex classes. + +#### new stream.Duplex(options) + +* `options` {Object} Passed to both Writable and Readable + constructors. Also has the following fields: + * `allowHalfOpen` {Boolean} Default = `true`. If set to `false`, then + the stream will automatically end the readable side when the + writable side ends and vice versa. + * `readableObjectMode` {Boolean} Default = `false`. Sets `objectMode` + for readable side of the stream. Has no effect if `objectMode` + is `true`. + * `writableObjectMode` {Boolean} Default = `false`. Sets `objectMode` + for writable side of the stream. Has no effect if `objectMode` + is `true`. + +In classes that extend the Duplex class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +### Class: stream.PassThrough + +This is a trivial implementation of a [Transform][] stream that simply +passes the input bytes across to the output. Its purpose is mainly +for examples and testing, but there are occasionally use cases where +it can come in handy as a building block for novel sorts of streams. + +### Class: stream.Readable + + + +`stream.Readable` is an abstract class designed to be extended with an +underlying implementation of the [`stream._read(size)`][stream-_read] method. + +Please see [API for Stream Consumers][] for how to consume +streams in your programs. What follows is an explanation of how to +implement Readable streams in your programs. + +#### new stream.Readable([options]) + +* `options` {Object} + * `highWaterMark` {Number} The maximum number of bytes to store in + the internal buffer before ceasing to read from the underlying + resource. Default = `16384` (16kb), or `16` for `objectMode` streams + * `encoding` {String} If specified, then buffers will be decoded to + strings using the specified encoding. Default = `null` + * `objectMode` {Boolean} Whether this stream should behave + as a stream of objects. Meaning that [`stream.read(n)`][stream-read] returns + a single value instead of a Buffer of size n. Default = `false` + * `read` {Function} Implementation for the [`stream._read()`][stream-_read] + method. + +In classes that extend the Readable class, make sure to call the +Readable constructor so that the buffering settings can be properly +initialized. + +#### readable.\_read(size) + +* `size` {Number} Number of bytes to read asynchronously + +Note: **Implement this method, but do NOT call it directly.** + +This method is prefixed with an underscore because it is internal to the +class that defines it and should only be called by the internal Readable +class methods. All Readable stream implementations must provide a \_read +method to fetch data from the underlying resource. + +When `_read()` is called, if data is available from the resource, the `_read()` +implementation should start pushing that data into the read queue by calling +[`this.push(dataChunk)`][stream-push]. `_read()` should continue reading from +the resource and pushing data until push returns `false`, at which point it +should stop reading from the resource. Only when `_read()` is called again after +it has stopped should it start reading more data from the resource and pushing +that data onto the queue. + +Note: once the `_read()` method is called, it will not be called again until +the [`stream.push()`][stream-push] method is called. + +The `size` argument is advisory. Implementations where a "read" is a +single call that returns data can use this to know how much data to +fetch. Implementations where that is not relevant, such as TCP or +TLS, may ignore this argument, and simply provide data whenever it +becomes available. There is no need, for example to "wait" until +`size` bytes are available before calling [`stream.push(chunk)`][stream-push]. + +#### readable.push(chunk[, encoding]) + + +* `chunk` {Buffer|Null|String} Chunk of data to push into the read queue +* `encoding` {String} Encoding of String chunks. Must be a valid + Buffer encoding, such as `'utf8'` or `'ascii'` +* return {Boolean} Whether or not more pushes should be performed + +Note: **This method should be called by Readable implementors, NOT +by consumers of Readable streams.** + +If a value other than null is passed, The `push()` method adds a chunk of data +into the queue for subsequent stream processors to consume. If `null` is +passed, it signals the end of the stream (EOF), after which no more data +can be written. + +The data added with `push()` can be pulled out by calling the +[`stream.read()`][stream-read] method when the [`'readable'`][] event fires. + +This API is designed to be as flexible as possible. For example, +you may be wrapping a lower-level source which has some sort of +pause/resume mechanism, and a data callback. In those cases, you +could wrap the low-level source object by doing something like this: + +```js +// source is an object with readStop() and readStart() methods, +// and an `ondata` member that gets called when it has data, and +// an `onend` member that gets called when the data is over. + +util.inherits(SourceWrapper, Readable); + +function SourceWrapper(options) { + Readable.call(this, options); + + this._source = getLowlevelSourceObject(); + + // Every time there's data, we push it into the internal buffer. + this._source.ondata = (chunk) => { + // if push() returns false, then we need to stop reading from source + if (!this.push(chunk)) + this._source.readStop(); + }; + + // When the source ends, we push the EOF-signaling `null` chunk + this._source.onend = () => { + this.push(null); + }; +} + +// _read will be called when the stream wants to pull more data in +// the advisory size argument is ignored in this case. +SourceWrapper.prototype._read = function(size) { + this._source.readStart(); +}; +``` + +#### Example: A Counting Stream + + + +This is a basic example of a Readable stream. It emits the numerals +from 1 to 1,000,000 in ascending order, and then ends. + +```js +const Readable = require('stream').Readable; +const util = require('util'); +util.inherits(Counter, Readable); + +function Counter(opt) { + Readable.call(this, opt); + this._max = 1000000; + this._index = 1; +} + +Counter.prototype._read = function() { + var i = this._index++; + if (i > this._max) + this.push(null); + else { + var str = '' + i; + var buf = new Buffer(str, 'ascii'); + this.push(buf); + } +}; +``` + +#### Example: SimpleProtocol v1 (Sub-optimal) + +This is similar to the `parseHeader` function described +[here](#stream_readable_unshift_chunk), but implemented as a custom stream. +Also, note that this implementation does not convert the incoming data to a +string. + +However, this would be better implemented as a [Transform][] stream. See +[SimpleProtocol v2][] for a better implementation. + +```js +// A parser for a simple data protocol. +// The "header" is a JSON object, followed by 2 \n characters, and +// then a message body. +// +// NOTE: This can be done more simply as a Transform stream! +// Using Readable directly for this is sub-optimal. See the +// alternative example below under the Transform section. + +const Readable = require('stream').Readable; +const util = require('util'); + +util.inherits(SimpleProtocol, Readable); + +function SimpleProtocol(source, options) { + if (!(this instanceof SimpleProtocol)) + return new SimpleProtocol(source, options); + + Readable.call(this, options); + this._inBody = false; + this._sawFirstCr = false; + + // source is a readable stream, such as a socket or file + this._source = source; + + var self = this; + source.on('end', () => { + self.push(null); + }); + + // give it a kick whenever the source is readable + // read(0) will not consume any bytes + source.on('readable', () => { + self.read(0); + }); + + this._rawHeader = []; + this.header = null; +} + +SimpleProtocol.prototype._read = function(n) { + if (!this._inBody) { + var chunk = this._source.read(); + + // if the source doesn't have data, we don't have data yet. + if (chunk === null) + return this.push(''); + + // check if the chunk has a \n\n + var split = -1; + for (var i = 0; i < chunk.length; i++) { + if (chunk[i] === 10) { // '\n' + if (this._sawFirstCr) { + split = i; + break; + } else { + this._sawFirstCr = true; + } + } else { + this._sawFirstCr = false; + } + } + + if (split === -1) { + // still waiting for the \n\n + // stash the chunk, and try again. + this._rawHeader.push(chunk); + this.push(''); + } else { + this._inBody = true; + var h = chunk.slice(0, split); + this._rawHeader.push(h); + var header = Buffer.concat(this._rawHeader).toString(); + try { + this.header = JSON.parse(header); + } catch (er) { + this.emit('error', new Error('invalid simple protocol data')); + return; + } + // now, because we got some extra data, unshift the rest + // back into the read queue so that our consumer will see it. + var b = chunk.slice(split); + this.unshift(b); + // calling unshift by itself does not reset the reading state + // of the stream; since we're inside _read, doing an additional + // push('') will reset the state appropriately. + this.push(''); + + // and let them know that we are done parsing the header. + this.emit('header', this.header); + } + } else { + // from there on, just provide the data to our consumer. + // careful not to push(null), since that would indicate EOF. + var chunk = this._source.read(); + if (chunk) this.push(chunk); + } +}; + +// Usage: +// var parser = new SimpleProtocol(source); +// Now parser is a readable stream that will emit 'header' +// with the parsed header data. +``` + +### Class: stream.Transform + +A "transform" stream is a duplex stream where the output is causally +connected in some way to the input, such as a [zlib][] stream or a +[crypto][] stream. + +There is no requirement that the output be the same size as the input, +the same number of chunks, or arrive at the same time. For example, a +Hash stream will only ever have a single chunk of output which is +provided when the input is ended. A zlib stream will produce output +that is either much smaller or much larger than its input. + +Rather than implement the [`stream._read()`][stream-_read] and +[`stream._write()`][stream-_write] methods, Transform classes must implement the +[`stream._transform()`][stream-_transform] method, and may optionally +also implement the [`stream._flush()`][stream-_flush] method. (See below.) + +#### new stream.Transform([options]) + +* `options` {Object} Passed to both Writable and Readable + constructors. Also has the following fields: + * `transform` {Function} Implementation for the + [`stream._transform()`][stream-_transform] method. + * `flush` {Function} Implementation for the [`stream._flush()`][stream-_flush] + method. + +In classes that extend the Transform class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +#### Events: 'finish' and 'end' + +The [`'finish'`][] and [`'end'`][] events are from the parent Writable +and Readable classes respectively. The `'finish'` event is fired after +[`stream.end()`][stream-end] is called and all chunks have been processed by +[`stream._transform()`][stream-_transform], `'end'` is fired after all data has +been output which is after the callback in [`stream._flush()`][stream-_flush] +has been called. + +#### transform.\_flush(callback) + +* `callback` {Function} Call this function (optionally with an error + argument) when you are done flushing any remaining data. + +Note: **This function MUST NOT be called directly.** It MAY be implemented +by child classes, and if so, will be called by the internal Transform +class methods only. + +In some cases, your transform operation may need to emit a bit more +data at the end of the stream. For example, a `Zlib` compression +stream will store up some internal state so that it can optimally +compress the output. At the end, however, it needs to do the best it +can with what is left, so that the data will be complete. + +In those cases, you can implement a `_flush()` method, which will be +called at the very end, after all the written data is consumed, but +before emitting [`'end'`][] to signal the end of the readable side. Just +like with [`stream._transform()`][stream-_transform], call +`transform.push(chunk)` zero or more times, as appropriate, and call `callback` +when the flush operation is complete. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +#### transform.\_transform(chunk, encoding, callback) + +* `chunk` {Buffer|String} The chunk to be transformed. Will **always** + be a buffer unless the `decodeStrings` option was set to `false`. +* `encoding` {String} If the chunk is a string, then this is the + encoding type. If chunk is a buffer, then this is the special + value - 'buffer', ignore it in this case. +* `callback` {Function} Call this function (optionally with an error + argument and data) when you are done processing the supplied chunk. + +Note: **This function MUST NOT be called directly.** It should be +implemented by child classes, and called by the internal Transform +class methods only. + +All Transform stream implementations must provide a `_transform()` +method to accept input and produce output. + +`_transform()` should do whatever has to be done in this specific +Transform class, to handle the bytes being written, and pass them off +to the readable portion of the interface. Do asynchronous I/O, +process things, and so on. + +Call `transform.push(outputChunk)` 0 or more times to generate output +from this input chunk, depending on how much data you want to output +as a result of this chunk. + +Call the callback function only when the current chunk is completely +consumed. Note that there may or may not be output as a result of any +particular input chunk. If you supply a second argument to the callback +it will be passed to the push method. In other words the following are +equivalent: + +```js +transform.prototype._transform = function (data, encoding, callback) { + this.push(data); + callback(); +}; + +transform.prototype._transform = function (data, encoding, callback) { + callback(null, data); +}; +``` + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +#### Example: `SimpleProtocol` parser v2 + +The example [here](#stream_example_simpleprotocol_v1_sub_optimal) of a simple +protocol parser can be implemented simply by using the higher level +[Transform][] stream class, similar to the `parseHeader` and `SimpleProtocol +v1` examples. + +In this example, rather than providing the input as an argument, it +would be piped into the parser, which is a more idiomatic Node.js stream +approach. + +```javascript +const util = require('util'); +const Transform = require('stream').Transform; +util.inherits(SimpleProtocol, Transform); + +function SimpleProtocol(options) { + if (!(this instanceof SimpleProtocol)) + return new SimpleProtocol(options); + + Transform.call(this, options); + this._inBody = false; + this._sawFirstCr = false; + this._rawHeader = []; + this.header = null; +} + +SimpleProtocol.prototype._transform = function(chunk, encoding, done) { + if (!this._inBody) { + // check if the chunk has a \n\n + var split = -1; + for (var i = 0; i < chunk.length; i++) { + if (chunk[i] === 10) { // '\n' + if (this._sawFirstCr) { + split = i; + break; + } else { + this._sawFirstCr = true; + } + } else { + this._sawFirstCr = false; + } + } + + if (split === -1) { + // still waiting for the \n\n + // stash the chunk, and try again. + this._rawHeader.push(chunk); + } else { + this._inBody = true; + var h = chunk.slice(0, split); + this._rawHeader.push(h); + var header = Buffer.concat(this._rawHeader).toString(); + try { + this.header = JSON.parse(header); + } catch (er) { + this.emit('error', new Error('invalid simple protocol data')); + return; + } + // and let them know that we are done parsing the header. + this.emit('header', this.header); + + // now, because we got some extra data, emit this first. + this.push(chunk.slice(split)); + } + } else { + // from there on, just provide the data to our consumer as-is. + this.push(chunk); + } + done(); +}; + +// Usage: +// var parser = new SimpleProtocol(); +// source.pipe(parser) +// Now parser is a readable stream that will emit 'header' +// with the parsed header data. +``` + +### Class: stream.Writable + + + +`stream.Writable` is an abstract class designed to be extended with an +underlying implementation of the +[`stream._write(chunk, encoding, callback)`][stream-_write] method. + +Please see [API for Stream Consumers][] for how to consume +writable streams in your programs. What follows is an explanation of +how to implement Writable streams in your programs. + +#### new stream.Writable([options]) + +* `options` {Object} + * `highWaterMark` {Number} Buffer level when + [`stream.write()`][stream-write] starts returning `false`. Default = `16384` + (16kb), or `16` for `objectMode` streams. + * `decodeStrings` {Boolean} Whether or not to decode strings into + Buffers before passing them to [`stream._write()`][stream-_write]. + Default = `true` + * `objectMode` {Boolean} Whether or not the + [`stream.write(anyObj)`][stream-write] is a valid operation. If set you can + write arbitrary data instead of only `Buffer` / `String` data. + Default = `false` + * `write` {Function} Implementation for the + [`stream._write()`][stream-_write] method. + * `writev` {Function} Implementation for the + [`stream._writev()`][stream-_writev] method. + +In classes that extend the Writable class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +#### writable.\_write(chunk, encoding, callback) + +* `chunk` {Buffer|String} The chunk to be written. Will **always** + be a buffer unless the `decodeStrings` option was set to `false`. +* `encoding` {String} If the chunk is a string, then this is the + encoding type. If chunk is a buffer, then this is the special + value - 'buffer', ignore it in this case. +* `callback` {Function} Call this function (optionally with an error + argument) when you are done processing the supplied chunk. + +All Writable stream implementations must provide a +[`stream._write()`][stream-_write] method to send data to the underlying +resource. + +Note: **This function MUST NOT be called directly.** It should be +implemented by child classes, and called by the internal Writable +class methods only. + +Call the callback using the standard `callback(error)` pattern to +signal that the write completed successfully or with an error. + +If the `decodeStrings` flag is set in the constructor options, then +`chunk` may be a string rather than a Buffer, and `encoding` will +indicate the sort of string that it is. This is to support +implementations that have an optimized handling for certain string +data encodings. If you do not explicitly set the `decodeStrings` +option to `false`, then you can safely ignore the `encoding` argument, +and assume that `chunk` will always be a Buffer. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +#### writable.\_writev(chunks, callback) + +* `chunks` {Array} The chunks to be written. Each chunk has following + format: `{ chunk: ..., encoding: ... }`. +* `callback` {Function} Call this function (optionally with an error + argument) when you are done processing the supplied chunks. + +Note: **This function MUST NOT be called directly.** It may be +implemented by child classes, and called by the internal Writable +class methods only. + +This function is completely optional to implement. In most cases it is +unnecessary. If implemented, it will be called with all the chunks +that are buffered in the write queue. + + +## Simplified Constructor API + + + +In simple cases there is now the added benefit of being able to construct a +stream without inheritance. + +This can be done by passing the appropriate methods as constructor options: + +Examples: + +### Duplex + +```js +var duplex = new stream.Duplex({ + read: function(n) { + // sets this._read under the hood + + // push data onto the read queue, passing null + // will signal the end of the stream (EOF) + this.push(chunk); + }, + write: function(chunk, encoding, next) { + // sets this._write under the hood + + // An optional error can be passed as the first argument + next() + } +}); + +// or + +var duplex = new stream.Duplex({ + read: function(n) { + // sets this._read under the hood + + // push data onto the read queue, passing null + // will signal the end of the stream (EOF) + this.push(chunk); + }, + writev: function(chunks, next) { + // sets this._writev under the hood + + // An optional error can be passed as the first argument + next() + } +}); +``` + +### Readable + +```js +var readable = new stream.Readable({ + read: function(n) { + // sets this._read under the hood + + // push data onto the read queue, passing null + // will signal the end of the stream (EOF) + this.push(chunk); + } +}); +``` + +### Transform + +```js +var transform = new stream.Transform({ + transform: function(chunk, encoding, next) { + // sets this._transform under the hood + + // generate output as many times as needed + // this.push(chunk); + + // call when the current chunk is consumed + next(); + }, + flush: function(done) { + // sets this._flush under the hood + + // generate output as many times as needed + // this.push(chunk); + + done(); + } +}); +``` + +### Writable + +```js +var writable = new stream.Writable({ + write: function(chunk, encoding, next) { + // sets this._write under the hood + + // An optional error can be passed as the first argument + next() + } +}); + +// or + +var writable = new stream.Writable({ + writev: function(chunks, next) { + // sets this._writev under the hood + + // An optional error can be passed as the first argument + next() + } +}); +``` + +## Streams: Under the Hood + + + +### Buffering + + + +Both Writable and Readable streams will buffer data on an internal +object which can be retrieved from `_writableState.getBuffer()` or +`_readableState.buffer`, respectively. + +The amount of data that will potentially be buffered depends on the +`highWaterMark` option which is passed into the constructor. + +Buffering in Readable streams happens when the implementation calls +[`stream.push(chunk)`][stream-push]. If the consumer of the Stream does not +call [`stream.read()`][stream-read], then the data will sit in the internal +queue until it is consumed. + +Buffering in Writable streams happens when the user calls +[`stream.write(chunk)`][stream-write] repeatedly, even when it returns `false`. + +The purpose of streams, especially with the [`stream.pipe()`][] method, is to +limit the buffering of data to acceptable levels, so that sources and +destinations of varying speed will not overwhelm the available memory. + +### Compatibility with Older Node.js Versions + + + +In versions of Node.js prior to v0.10, the Readable stream interface was +simpler, but also less powerful and less useful. + +* Rather than waiting for you to call the [`stream.read()`][stream-read] method, + [`'data'`][] events would start emitting immediately. If you needed to do + some I/O to decide how to handle data, then you had to store the chunks + in some kind of buffer so that they would not be lost. +* The [`stream.pause()`][stream-pause] method was advisory, rather than + guaranteed. This meant that you still had to be prepared to receive + [`'data'`][] events even when the stream was in a paused state. + +In Node.js v0.10, the [Readable][] class was added. +For backwards compatibility with older Node.js programs, Readable streams +switch into "flowing mode" when a [`'data'`][] event handler is added, or +when the [`stream.resume()`][stream-resume] method is called. The effect is +that, even if you are not using the new [`stream.read()`][stream-read] method +and [`'readable'`][] event, you no longer have to worry about losing +[`'data'`][] chunks. + +Most programs will continue to function normally. However, this +introduces an edge case in the following conditions: + +* No [`'data'`][] event handler is added. +* The [`stream.resume()`][stream-resume] method is never called. +* The stream is not piped to any writable destination. + +For example, consider the following code: + +```js +// WARNING! BROKEN! +net.createServer((socket) => { + + // we add an 'end' method, but never consume the data + socket.on('end', () => { + // It will never get here. + socket.end('I got your message (but didnt read it)\n'); + }); + +}).listen(1337); +``` + +In versions of Node.js prior to v0.10, the incoming message data would be +simply discarded. However, in Node.js v0.10 and beyond, +the socket will remain paused forever. + +The workaround in this situation is to call the +[`stream.resume()`][stream-resume] method to start the flow of data: + +```js +// Workaround +net.createServer((socket) => { + + socket.on('end', () => { + socket.end('I got your message (but didnt read it)\n'); + }); + + // start the flow of data, discarding it. + socket.resume(); + +}).listen(1337); +``` + +In addition to new Readable streams switching into flowing mode, +pre-v0.10 style streams can be wrapped in a Readable class using the +[`stream.wrap()`][] method. + + +### Object Mode + + + +Normally, Streams operate on Strings and Buffers exclusively. + +Streams that are in **object mode** can emit generic JavaScript values +other than Buffers and Strings. + +A Readable stream in object mode will always return a single item from +a call to [`stream.read(size)`][stream-read], regardless of what the size +argument is. + +A Writable stream in object mode will always ignore the `encoding` +argument to [`stream.write(data, encoding)`][stream-write]. + +The special value `null` still retains its special value for object +mode streams. That is, for object mode readable streams, `null` as a +return value from [`stream.read()`][stream-read] indicates that there is no more +data, and [`stream.push(null)`][stream-push] will signal the end of stream data +(`EOF`). + +No streams in Node.js core are object mode streams. This pattern is only +used by userland streaming libraries. + +You should set `objectMode` in your stream child class constructor on +the options object. Setting `objectMode` mid-stream is not safe. + +For Duplex streams `objectMode` can be set exclusively for readable or +writable side with `readableObjectMode` and `writableObjectMode` +respectively. These options can be used to implement parsers and +serializers with Transform streams. + +```js +const util = require('util'); +const StringDecoder = require('string_decoder').StringDecoder; +const Transform = require('stream').Transform; +util.inherits(JSONParseStream, Transform); + +// Gets \n-delimited JSON string data, and emits the parsed objects +function JSONParseStream() { + if (!(this instanceof JSONParseStream)) + return new JSONParseStream(); + + Transform.call(this, { readableObjectMode : true }); + + this._buffer = ''; + this._decoder = new StringDecoder('utf8'); +} + +JSONParseStream.prototype._transform = function(chunk, encoding, cb) { + this._buffer += this._decoder.write(chunk); + // split on newlines + var lines = this._buffer.split(/\r?\n/); + // keep the last partial line buffered + this._buffer = lines.pop(); + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + try { + var obj = JSON.parse(line); + } catch (er) { + this.emit('error', er); + return; + } + // push the parsed object out to the readable consumer + this.push(obj); + } + cb(); +}; + +JSONParseStream.prototype._flush = function(cb) { + // Just handle any leftover + var rem = this._buffer.trim(); + if (rem) { + try { + var obj = JSON.parse(rem); + } catch (er) { + this.emit('error', er); + return; + } + // push the parsed object out to the readable consumer + this.push(obj); + } + cb(); +}; +``` + +### `stream.read(0)` + +There are some cases where you want to trigger a refresh of the +underlying readable stream mechanisms, without actually consuming any +data. In that case, you can call `stream.read(0)`, which will always +return null. + +If the internal read buffer is below the `highWaterMark`, and the +stream is not currently reading, then calling `stream.read(0)` will trigger +a low-level [`stream._read()`][stream-_read] call. + +There is almost never a need to do this. However, you will see some +cases in Node.js's internals where this is done, particularly in the +Readable stream class internals. + +### `stream.push('')` + +Pushing a zero-byte string or Buffer (when not in [Object mode][]) has an +interesting side effect. Because it *is* a call to +[`stream.push()`][stream-push], it will end the `reading` process. However, it +does *not* add any data to the readable buffer, so there's nothing for +a user to consume. + +Very rarely, there are cases where you have no data to provide now, +but the consumer of your stream (or, perhaps, another bit of your own +code) will know when to check again, by calling [`stream.read(0)`][stream-read]. +In those cases, you *may* call `stream.push('')`. + +So far, the only use case for this functionality is in the +[`tls.CryptoStream`][] class, which is deprecated in Node.js/io.js v1.0. If you +find that you have to use `stream.push('')`, please consider another +approach, because it almost certainly indicates that something is +horribly wrong. + +[`'data'`]: #stream_event_data +[`'drain'`]: #stream_event_drain +[`'end'`]: #stream_event_end +[`'finish'`]: #stream_event_finish +[`'readable'`]: #stream_event_readable +[`buf.toString(encoding)`]: https://nodejs.org/docs/v5.8.0/api/buffer.html#buffer_buf_tostring_encoding_start_end +[`EventEmitter`]: https://nodejs.org/docs/v5.8.0/api/events.html#events_class_eventemitter +[`process.stderr`]: https://nodejs.org/docs/v5.8.0/api/process.html#process_process_stderr +[`process.stdin`]: https://nodejs.org/docs/v5.8.0/api/process.html#process_process_stdin +[`process.stdout`]: https://nodejs.org/docs/v5.8.0/api/process.html#process_process_stdout +[`stream.cork()`]: #stream_writable_cork +[`stream.pipe()`]: #stream_readable_pipe_destination_options +[`stream.uncork()`]: #stream_writable_uncork +[`stream.unpipe()`]: #stream_readable_unpipe_destination +[`stream.wrap()`]: #stream_readable_wrap_stream +[`tls.CryptoStream`]: https://nodejs.org/docs/v5.8.0/api/tls.html#tls_class_cryptostream +[`util.inherits()`]: https://nodejs.org/docs/v5.8.0/api/util.html#util_util_inherits_constructor_superconstructor +[API for Stream Consumers]: #stream_api_for_stream_consumers +[API for Stream Implementors]: #stream_api_for_stream_implementors +[child process stdin]: https://nodejs.org/docs/v5.8.0/api/child_process.html#child_process_child_stdin +[child process stdout and stderr]: https://nodejs.org/docs/v5.8.0/api/child_process.html#child_process_child_stdout +[Compatibility]: #stream_compatibility_with_older_node_js_versions +[crypto]: crypto.html +[Duplex]: #stream_class_stream_duplex +[fs read streams]: https://nodejs.org/docs/v5.8.0/api/fs.html#fs_class_fs_readstream +[fs write streams]: https://nodejs.org/docs/v5.8.0/api/fs.html#fs_class_fs_writestream +[HTTP requests, on the client]: https://nodejs.org/docs/v5.8.0/api/http.html#http_class_http_clientrequest +[HTTP responses, on the server]: https://nodejs.org/docs/v5.8.0/api/http.html#http_class_http_serverresponse +[http-incoming-message]: https://nodejs.org/docs/v5.8.0/api/http.html#http_class_http_incomingmessage +[Object mode]: #stream_object_mode +[Readable]: #stream_class_stream_readable +[SimpleProtocol v2]: #stream_example_simpleprotocol_parser_v2 +[stream-_flush]: #stream_transform_flush_callback +[stream-_read]: #stream_readable_read_size_1 +[stream-_transform]: #stream_transform_transform_chunk_encoding_callback +[stream-_write]: #stream_writable_write_chunk_encoding_callback_1 +[stream-_writev]: #stream_writable_writev_chunks_callback +[stream-end]: #stream_writable_end_chunk_encoding_callback +[stream-pause]: #stream_readable_pause +[stream-push]: #stream_readable_push_chunk_encoding +[stream-read]: #stream_readable_read_size +[stream-resume]: #stream_readable_resume +[stream-write]: #stream_writable_write_chunk_encoding_callback +[TCP sockets]: https://nodejs.org/docs/v5.8.0/api/net.html#net_class_net_socket +[Transform]: #stream_class_stream_transform +[Writable]: #stream_class_stream_writable +[zlib]: zlib.html diff --git a/node_modules/bl/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md b/node_modules/bl/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md new file mode 100644 index 0000000..83275f1 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md @@ -0,0 +1,60 @@ +# streams WG Meeting 2015-01-30 + +## Links + +* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg +* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106 +* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/ + +## Agenda + +Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting. + +* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105) +* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101) +* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102) +* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99) + +## Minutes + +### adopt a charter + +* group: +1's all around + +### What versioning scheme should be adopted? +* group: +1’s 3.0.0 +* domenic+group: pulling in patches from other sources where appropriate +* mikeal: version independently, suggesting versions for io.js +* mikeal+domenic: work with TC to notify in advance of changes +simpler stream creation + +### streamline creation of streams +* sam: streamline creation of streams +* domenic: nice simple solution posted + but, we lose the opportunity to change the model + may not be backwards incompatible (double check keys) + + **action item:** domenic will check + +### remove implicit flowing of streams on(‘data’) +* add isFlowing / isPaused +* mikeal: worrying that we’re documenting polyfill methods – confuses users +* domenic: more reflective API is probably good, with warning labels for users +* new section for mad scientists (reflective stream access) +* calvin: name the “third state” +* mikeal: maybe borrow the name from whatwg? +* domenic: we’re missing the “third state” +* consensus: kind of difficult to name the third state +* mikeal: figure out differences in states / compat +* mathias: always flow on data – eliminates third state + * explore what it breaks + +**action items:** +* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream) +* ask rod/build for infrastructure +* **chris**: explore the “flow on data” approach +* add isPaused/isFlowing +* add new docs section +* move isPaused to that section + + diff --git a/node_modules/bl/node_modules/readable-stream/duplex.js b/node_modules/bl/node_modules/readable-stream/duplex.js new file mode 100644 index 0000000..ca807af --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/duplex.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_duplex.js") diff --git a/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js b/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js new file mode 100644 index 0000000..736693b --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js @@ -0,0 +1,75 @@ +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +'use strict'; + +/**/ + +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ + +module.exports = Duplex; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +var keys = objectKeys(Writable.prototype); +for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + processNextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} \ No newline at end of file diff --git a/node_modules/bl/node_modules/readable-stream/lib/_stream_passthrough.js b/node_modules/bl/node_modules/readable-stream/lib/_stream_passthrough.js new file mode 100644 index 0000000..d06f71f --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/lib/_stream_passthrough.js @@ -0,0 +1,26 @@ +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; \ No newline at end of file diff --git a/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js b/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js new file mode 100644 index 0000000..54a9d5c --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js @@ -0,0 +1,880 @@ +'use strict'; + +module.exports = Readable; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + +/**/ +var isArray = require('isarray'); +/**/ + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Readable.ReadableState = ReadableState; + +var EE = require('events'); + +/**/ +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream; +(function () { + try { + Stream = require('st' + 'ream'); + } catch (_) {} finally { + if (!Stream) Stream = require('events').EventEmitter; + } +})(); +/**/ + +var Buffer = require('buffer').Buffer; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +/**/ +var debugUtil = require('util'); +var debug = undefined; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var StringDecoder; + +util.inherits(Readable, Stream); + +var Duplex; +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~ ~this.highWaterMark; + + this.buffer = []; + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +var Duplex; +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options && typeof options.read === 'function') this._read = options.read; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + + if (!state.objectMode && typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = new Buffer(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); + } else { + var skipAdd; + if (state.decoder && !addToFront && !encoding) { + chunk = state.decoder.write(chunk); + skipAdd = !state.objectMode && chunk.length === 0; + } + + if (!addToFront) state.reading = false; + + // Don't add to the buffer if we've decoded to an empty string chunk and + // we're not in object mode + if (!skipAdd) { + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + } + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +function howMuchToRead(n, state) { + if (state.length === 0 && state.ended) return 0; + + if (state.objectMode) return n === 0 ? 0 : 1; + + if (n === null || isNaN(n)) { + // only flow one buffer at a time + if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length; + } + + if (n <= 0) return 0; + + // If we're asking for more than the target buffer level, + // then raise the water mark. Bump up to the next highest + // power of 2, to prevent increasing it excessively in tiny + // amounts. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + + // don't have that much. return null, unless we've ended. + if (n > state.length) { + if (!state.ended) { + state.needReadable = true; + return 0; + } else { + return state.length; + } + } + + return n; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + var state = this._readableState; + var nOrig = n; + + if (typeof n !== 'number' || n > 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } + + if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + } + + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (doRead && !state.reading) n = howMuchToRead(nOrig, state); + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } + + state.length -= n; + + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (state.length === 0 && !state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended && state.length === 0) endReadable(this); + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function chunkInvalid(state, chunk) { + var er = null; + if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + processNextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + debug('onunpipe'); + if (readable === src) { + cleanup(); + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + if (false === ret) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + if (state.pipesCount === 1 && state.pipes[0] === dest && src.listenerCount('data') === 1 && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + // This is a brutally ugly hack to make sure that our error handler + // is attached before any userland ones. NEVER DO THIS. + if (!dest._events || !dest._events.error) dest.on('error', onerror);else if (isArray(dest._events.error)) dest._events.error.unshift(onerror);else dest._events.error = [onerror, dest._events.error]; + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var _i = 0; _i < len; _i++) { + dests[_i].emit('unpipe', this); + }return this; + } + + // try to find the right one. + var i = indexOf(state.pipes, dest); + if (i === -1) return this; + + state.pipes.splice(i, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + // If listening to data, and it has not explicitly been paused, + // then call resume to start the flow of data on the next tick. + if (ev === 'data' && false !== this._readableState.flowing) { + this.resume(); + } + + if (ev === 'readable' && !this._readableState.endEmitted) { + var state = this._readableState; + if (!state.readableListening) { + state.readableListening = true; + state.emittedReadable = false; + state.needReadable = true; + if (!state.reading) { + processNextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + processNextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + if (state.flowing) { + do { + var chunk = stream.read(); + } while (null !== chunk && state.flowing); + } +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + var events = ['error', 'close', 'destroy', 'pause', 'resume']; + forEach(events, function (ev) { + stream.on(ev, self.emit.bind(self, ev)); + }); + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; +}; + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +function fromList(n, state) { + var list = state.buffer; + var length = state.length; + var stringMode = !!state.decoder; + var objectMode = !!state.objectMode; + var ret; + + // nothing in the list, definitely empty. + if (list.length === 0) return null; + + if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) { + // read it all, truncate the array. + if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length); + list.length = 0; + } else { + // read just some of it. + if (n < list[0].length) { + // just take a part of the first list item. + // slice is the same for buffers and strings. + var buf = list[0]; + ret = buf.slice(0, n); + list[0] = buf.slice(n); + } else if (n === list[0].length) { + // first list is a perfect match + ret = list.shift(); + } else { + // complex case. + // we have enough to cover it, but it spans past the first buffer. + if (stringMode) ret = '';else ret = new Buffer(n); + + var c = 0; + for (var i = 0, l = list.length; i < l && c < n; i++) { + var buf = list[0]; + var cpy = Math.min(n - c, buf.length); + + if (stringMode) ret += buf.slice(0, cpy);else buf.copy(ret, c, 0, cpy); + + if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift(); + + c += cpy; + } + } + } + + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('endReadable called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + processNextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} \ No newline at end of file diff --git a/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js b/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js new file mode 100644 index 0000000..625cdc1 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js @@ -0,0 +1,180 @@ +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +'use strict'; + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + +function TransformState(stream) { + this.afterTransform = function (er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; + this.writeencoding = null; +} + +function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (data !== null && data !== undefined) stream.push(data); + + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = new TransformState(this); + + // when the writable side finishes, then flush out anything remaining. + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + this.once('prefinish', function () { + if (typeof this._flush === 'function') this._flush(function (er) { + done(stream, er); + });else done(stream); + }); +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +function done(stream, er) { + if (er) return stream.emit('error', er); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var ts = stream._transformState; + + if (ws.length) throw new Error('calling transform done when ws.length != 0'); + + if (ts.transforming) throw new Error('calling transform done when still transforming'); + + return stream.push(null); +} \ No newline at end of file diff --git a/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js b/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js new file mode 100644 index 0000000..95916c9 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js @@ -0,0 +1,516 @@ +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + +'use strict'; + +module.exports = Writable; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; +/**/ + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +/**/ +var internalUtil = { + deprecate: require('util-deprecate') +}; +/**/ + +/**/ +var Stream; +(function () { + try { + Stream = require('st' + 'ream'); + } catch (_) {} finally { + if (!Stream) Stream = require('events').EventEmitter; + } +})(); +/**/ + +var Buffer = require('buffer').Buffer; + +util.inherits(Writable, Stream); + +function nop() {} + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +var Duplex; +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~ ~this.highWaterMark; + + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // create the two objects needed to store the corked requests + // they are not a linked list, as no new elements are inserted in there + this.corkedRequestsFree = new CorkedRequest(this); + this.corkedRequestsFree.next = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function writableStateGetBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') + }); + } catch (_) {} +})(); + +var Duplex; +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. + if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options); + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe. Not readable.')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + processNextTick(cb, er); +} + +// If we get something that is not a buffer, string, null, or undefined, +// and we're not in objectMode, then that's an error. +// Otherwise stream chunks are all considered to be of length=1, and the +// watermarks determine how many objects to keep in the buffer, rather than +// how many bytes or characters. +function validChunk(stream, state, chunk, cb) { + var valid = true; + + if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { + var er = new TypeError('Invalid non-string/buffer chunk'); + stream.emit('error', er); + processNextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function () { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = new Buffer(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, chunk, encoding, cb) { + chunk = decodeChunk(state, chunk, encoding); + + if (Buffer.isBuffer(chunk)) encoding = 'buffer'; + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + if (sync) processNextTick(cb, er);else cb(er); + + stream._writableState.errorEmitted = true; + stream.emit('error', er); +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + while (entry) { + buffer[count] = entry; + entry = entry.next; + count += 1; + } + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequestCount = 0; + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('not implemented')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} + +function prefinish(stream, state) { + if (!state.prefinished) { + state.prefinished = true; + stream.emit('prefinish'); + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + if (state.pendingcb === 0) { + prefinish(stream, state); + state.finished = true; + stream.emit('finish'); + } else { + prefinish(stream, state); + } + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) processNextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + + this.finish = function (err) { + var entry = _this.entry; + _this.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = _this; + } else { + state.corkedRequestsFree = _this; + } + }; +} \ No newline at end of file diff --git a/node_modules/bl/node_modules/readable-stream/package.json b/node_modules/bl/node_modules/readable-stream/package.json new file mode 100644 index 0000000..322d825 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/package.json @@ -0,0 +1,66 @@ +{ + "_from": "readable-stream@~2.0.5", + "_id": "readable-stream@2.0.6", + "_inBundle": false, + "_integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "_location": "/bl/readable-stream", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "readable-stream@~2.0.5", + "name": "readable-stream", + "escapedName": "readable-stream", + "rawSpec": "~2.0.5", + "saveSpec": null, + "fetchSpec": "~2.0.5" + }, + "_requiredBy": [ + "/bl" + ], + "_resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "_shasum": "8f90341e68a53ccc928788dacfcd11b36eb9b78e", + "_spec": "readable-stream@~2.0.5", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\bl", + "browser": { + "util": false + }, + "bugs": { + "url": "https://github.com/nodejs/readable-stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" + }, + "deprecated": false, + "description": "Streams3, a user-land copy of the stream library from Node.js", + "devDependencies": { + "tap": "~0.2.6", + "tape": "~4.5.1", + "zuul": "~3.9.0" + }, + "homepage": "https://github.com/nodejs/readable-stream#readme", + "keywords": [ + "readable", + "stream", + "pipe" + ], + "license": "MIT", + "main": "readable.js", + "name": "readable-stream", + "repository": { + "type": "git", + "url": "git://github.com/nodejs/readable-stream.git" + }, + "scripts": { + "browser": "npm run write-zuul && zuul -- test/browser.js", + "test": "tap test/parallel/*.js test/ours/*.js", + "write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml" + }, + "version": "2.0.6" +} diff --git a/node_modules/bl/node_modules/readable-stream/passthrough.js b/node_modules/bl/node_modules/readable-stream/passthrough.js new file mode 100644 index 0000000..27e8d8a --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/passthrough.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_passthrough.js") diff --git a/node_modules/bl/node_modules/readable-stream/readable.js b/node_modules/bl/node_modules/readable-stream/readable.js new file mode 100644 index 0000000..6222a57 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/readable.js @@ -0,0 +1,12 @@ +var Stream = (function (){ + try { + return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify + } catch(_){} +}()); +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = Stream || exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); diff --git a/node_modules/bl/node_modules/readable-stream/transform.js b/node_modules/bl/node_modules/readable-stream/transform.js new file mode 100644 index 0000000..5d482f0 --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/transform.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_transform.js") diff --git a/node_modules/bl/node_modules/readable-stream/writable.js b/node_modules/bl/node_modules/readable-stream/writable.js new file mode 100644 index 0000000..e1e9efd --- /dev/null +++ b/node_modules/bl/node_modules/readable-stream/writable.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_writable.js") diff --git a/node_modules/bl/package.json b/node_modules/bl/package.json new file mode 100644 index 0000000..3579e43 --- /dev/null +++ b/node_modules/bl/package.json @@ -0,0 +1,68 @@ +{ + "_from": "bl@~1.1.2", + "_id": "bl@1.1.2", + "_inBundle": false, + "_integrity": "sha1-/cqHGplxOqANGeO7ukHER4emU5g=", + "_location": "/bl", + "_phantomChildren": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "string_decoder": "0.10.31", + "util-deprecate": "1.0.2" + }, + "_requested": { + "type": "range", + "registry": true, + "raw": "bl@~1.1.2", + "name": "bl", + "escapedName": "bl", + "rawSpec": "~1.1.2", + "saveSpec": null, + "fetchSpec": "~1.1.2" + }, + "_requiredBy": [ + "/google-auth-library/request", + "/googleapis/request" + ], + "_resolved": "https://registry.npmjs.org/bl/-/bl-1.1.2.tgz", + "_shasum": "fdca871a99713aa00d19e3bbba41c44787a65398", + "_spec": "bl@~1.1.2", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\google-auth-library\\node_modules\\request", + "authors": [ + "Rod Vagg (https://github.com/rvagg)", + "Matteo Collina (https://github.com/mcollina)", + "Jarett Cruger (https://github.com/jcrugzz)" + ], + "bugs": { + "url": "https://github.com/rvagg/bl/issues" + }, + "bundleDependencies": false, + "dependencies": { + "readable-stream": "~2.0.5" + }, + "deprecated": false, + "description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!", + "devDependencies": { + "faucet": "0.0.1", + "hash_file": "~0.1.1", + "tape": "~4.4.0" + }, + "homepage": "https://github.com/rvagg/bl", + "keywords": [ + "buffer", + "buffers", + "stream", + "awesomesauce" + ], + "license": "MIT", + "main": "bl.js", + "name": "bl", + "repository": { + "type": "git", + "url": "git+https://github.com/rvagg/bl.git" + }, + "scripts": { + "test": "node test/test.js | faucet" + }, + "version": "1.1.2" +} diff --git a/node_modules/boom/.npmignore b/node_modules/boom/.npmignore new file mode 100644 index 0000000..77ba16c --- /dev/null +++ b/node_modules/boom/.npmignore @@ -0,0 +1,18 @@ +.idea +*.iml +npm-debug.log +dump.rdb +node_modules +results.tap +results.xml +npm-shrinkwrap.json +config.json +.DS_Store +*/.DS_Store +*/*/.DS_Store +._* +*/._* +*/*/._* +coverage.* +lib-cov + diff --git a/node_modules/boom/.travis.yml b/node_modules/boom/.travis.yml new file mode 100644 index 0000000..dd1b24f --- /dev/null +++ b/node_modules/boom/.travis.yml @@ -0,0 +1,8 @@ +language: node_js + +node_js: + - 0.10 + - 4.0 + +sudo: false + diff --git a/node_modules/boom/CONTRIBUTING.md b/node_modules/boom/CONTRIBUTING.md new file mode 100644 index 0000000..8928361 --- /dev/null +++ b/node_modules/boom/CONTRIBUTING.md @@ -0,0 +1 @@ +Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md). diff --git a/node_modules/boom/LICENSE b/node_modules/boom/LICENSE new file mode 100644 index 0000000..3946889 --- /dev/null +++ b/node_modules/boom/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012-2014, Walmart and other contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of any contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + * * * + +The complete list of contributors can be found at: https://github.com/hapijs/boom/graphs/contributors \ No newline at end of file diff --git a/node_modules/boom/README.md b/node_modules/boom/README.md new file mode 100644 index 0000000..cbd91c9 --- /dev/null +++ b/node_modules/boom/README.md @@ -0,0 +1,652 @@ +![boom Logo](https://raw.github.com/hapijs/boom/master/images/boom.png) + +HTTP-friendly error objects + +[![Build Status](https://secure.travis-ci.org/hapijs/boom.png)](http://travis-ci.org/hapijs/boom) +[![Current Version](https://img.shields.io/npm/v/boom.svg)](https://www.npmjs.com/package/boom) + +Lead Maintainer: [Adam Bretz](https://github.com/arb) + +**boom** provides a set of utilities for returning HTTP errors. Each utility returns a `Boom` error response +object (instance of `Error`) which includes the following properties: +- `isBoom` - if `true`, indicates this is a `Boom` object instance. +- `isServer` - convenience bool indicating status code >= 500. +- `message` - the error message. +- `output` - the formatted response. Can be directly manipulated after object construction to return a custom + error response. Allowed root keys: + - `statusCode` - the HTTP status code (typically 4xx or 5xx). + - `headers` - an object containing any HTTP headers where each key is a header name and value is the header content. + - `payload` - the formatted object used as the response payload (stringified). Can be directly manipulated but any + changes will be lost + if `reformat()` is called. Any content allowed and by default includes the following content: + - `statusCode` - the HTTP status code, derived from `error.output.statusCode`. + - `error` - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from `statusCode`. + - `message` - the error message derived from `error.message`. +- inherited `Error` properties. + +The `Boom` object also supports the following method: +- `reformat()` - rebuilds `error.output` using the other object properties. + +## Overview + +- Helper methods + - [`wrap(error, [statusCode], [message])`](#wraperror-statuscode-message) + - [`create(statusCode, [message], [data])`](#createstatuscode-message-data) +- HTTP 4xx Errors + - 400: [`Boom.badRequest([message], [data])`](#boombadrequestmessage-data) + - 401: [`Boom.unauthorized([message], [scheme], [attributes])`](#boomunauthorizedmessage-scheme-attributes) + - 403: [`Boom.forbidden([message], [data])`](#boomforbiddenmessage-data) + - 404: [`Boom.notFound([message], [data])`](#boomnotfoundmessage-data) + - 405: [`Boom.methodNotAllowed([message], [data])`](#boommethodnotallowedmessage-data) + - 406: [`Boom.notAcceptable([message], [data])`](#boomnotacceptablemessage-data) + - 407: [`Boom.proxyAuthRequired([message], [data])`](#boomproxyauthrequiredmessage-data) + - 408: [`Boom.clientTimeout([message], [data])`](#boomclienttimeoutmessage-data) + - 409: [`Boom.conflict([message], [data])`](#boomconflictmessage-data) + - 410: [`Boom.resourceGone([message], [data])`](#boomresourcegonemessage-data) + - 411: [`Boom.lengthRequired([message], [data])`](#boomlengthrequiredmessage-data) + - 412: [`Boom.preconditionFailed([message], [data])`](#boompreconditionfailedmessage-data) + - 413: [`Boom.entityTooLarge([message], [data])`](#boomentitytoolargemessage-data) + - 414: [`Boom.uriTooLong([message], [data])`](#boomuritoolongmessage-data) + - 415: [`Boom.unsupportedMediaType([message], [data])`](#boomunsupportedmediatypemessage-data) + - 416: [`Boom.rangeNotSatisfiable([message], [data])`](#boomrangenotsatisfiablemessage-data) + - 417: [`Boom.expectationFailed([message], [data])`](#boomexpectationfailedmessage-data) + - 422: [`Boom.badData([message], [data])`](#boombaddatamessage-data) + - 428: [`Boom.preconditionRequired([message], [data])`](#boompreconditionrequiredmessage-data) + - 429: [`Boom.tooManyRequests([message], [data])`](#boomtoomanyrequestsmessage-data) +- HTTP 5xx Errors + - 500: [`Boom.badImplementation([message], [data])`](#boombadimplementationmessage-data) + - 501: [`Boom.notImplemented([message], [data])`](#boomnotimplementedmessage-data) + - 502: [`Boom.badGateway([message], [data])`](#boombadgatewaymessage-data) + - 503: [`Boom.serverTimeout([message], [data])`](#boomservertimeoutmessage-data) + - 504: [`Boom.gatewayTimeout([message], [data])`](#boomgatewaytimeoutmessage-data) +- [FAQ](#faq) + + +## Helper Methods + +### `wrap(error, [statusCode], [message])` + +Decorates an error with the **boom** properties where: +- `error` - the error object to wrap. If `error` is already a **boom** object, returns back the same object. +- `statusCode` - optional HTTP status code. Defaults to `500`. +- `message` - optional message string. If the error already has a message, it adds the message as a prefix. + Defaults to no message. + +```js +var error = new Error('Unexpected input'); +Boom.wrap(error, 400); +``` + +### `create(statusCode, [message], [data])` + +Generates an `Error` object with the **boom** decorations where: +- `statusCode` - an HTTP error code number. Must be greater or equal 400. +- `message` - optional message string. +- `data` - additional error data set to `error.data` property. + +```js +var error = Boom.create(400, 'Bad request', { timestamp: Date.now() }); +``` + +## HTTP 4xx Errors + +### `Boom.badRequest([message], [data])` + +Returns a 400 Bad Request error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.badRequest('invalid query'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 400, + "error": "Bad Request", + "message": "invalid query" +} +``` + +### `Boom.unauthorized([message], [scheme], [attributes])` + +Returns a 401 Unauthorized error where: +- `message` - optional message. +- `scheme` can be one of the following: + - an authentication scheme name + - an array of string values. These values will be separated by ', ' and set to the 'WWW-Authenticate' header. +- `attributes` - an object of values to use while setting the 'WWW-Authenticate' header. This value is only used + when `schema` is a string, otherwise it is ignored. Every key/value pair will be included in the + 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the `attributes` key. + `null` and `undefined` will be replaced with an empty string. If `attributes` is set, `message` will be used as + the 'error' segment of the 'WWW-Authenticate' header. If `message` is unset, the 'error' segment of the header + will not be present and `isMissing` will be true on the error object. + +If either `scheme` or `attributes` are set, the resultant `Boom` object will have the 'WWW-Authenticate' header set for the response. + +```js +Boom.unauthorized('invalid password'); +``` + +Generates the following response: + +```json +"payload": { + "statusCode": 401, + "error": "Unauthorized", + "message": "invalid password" +}, +"headers" {} +``` + +```js +Boom.unauthorized('invalid password', 'sample'); +``` + +Generates the following response: + +```json +"payload": { + "statusCode": 401, + "error": "Unauthorized", + "message": "invalid password", + "attributes": { + "error": "invalid password" + } +}, +"headers" { + "WWW-Authenticate": "sample error=\"invalid password\"" +} +``` + +```js +Boom.unauthorized('invalid password', 'sample', { ttl: 0, cache: null, foo: 'bar' }); +``` + +Generates the following response: + +```json +"payload": { + "statusCode": 401, + "error": "Unauthorized", + "message": "invalid password", + "attributes": { + "error": "invalid password", + "ttl": 0, + "cache": "", + "foo": "bar" + } +}, +"headers" { + "WWW-Authenticate": "sample ttl=\"0\", cache=\"\", foo=\"bar\", error=\"invalid password\"" +} +``` + +### `Boom.forbidden([message], [data])` + +Returns a 403 Forbidden error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.forbidden('try again some time'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 403, + "error": "Forbidden", + "message": "try again some time" +} +``` + +### `Boom.notFound([message], [data])` + +Returns a 404 Not Found error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.notFound('missing'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 404, + "error": "Not Found", + "message": "missing" +} +``` + +### `Boom.methodNotAllowed([message], [data])` + +Returns a 405 Method Not Allowed error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.methodNotAllowed('that method is not allowed'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 405, + "error": "Method Not Allowed", + "message": "that method is not allowed" +} +``` + +### `Boom.notAcceptable([message], [data])` + +Returns a 406 Not Acceptable error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.notAcceptable('unacceptable'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 406, + "error": "Not Acceptable", + "message": "unacceptable" +} +``` + +### `Boom.proxyAuthRequired([message], [data])` + +Returns a 407 Proxy Authentication Required error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.proxyAuthRequired('auth missing'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 407, + "error": "Proxy Authentication Required", + "message": "auth missing" +} +``` + +### `Boom.clientTimeout([message], [data])` + +Returns a 408 Request Time-out error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.clientTimeout('timed out'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 408, + "error": "Request Time-out", + "message": "timed out" +} +``` + +### `Boom.conflict([message], [data])` + +Returns a 409 Conflict error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.conflict('there was a conflict'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 409, + "error": "Conflict", + "message": "there was a conflict" +} +``` + +### `Boom.resourceGone([message], [data])` + +Returns a 410 Gone error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.resourceGone('it is gone'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 410, + "error": "Gone", + "message": "it is gone" +} +``` + +### `Boom.lengthRequired([message], [data])` + +Returns a 411 Length Required error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.lengthRequired('length needed'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 411, + "error": "Length Required", + "message": "length needed" +} +``` + +### `Boom.preconditionFailed([message], [data])` + +Returns a 412 Precondition Failed error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.preconditionFailed(); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 412, + "error": "Precondition Failed" +} +``` + +### `Boom.entityTooLarge([message], [data])` + +Returns a 413 Request Entity Too Large error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.entityTooLarge('too big'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 413, + "error": "Request Entity Too Large", + "message": "too big" +} +``` + +### `Boom.uriTooLong([message], [data])` + +Returns a 414 Request-URI Too Large error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.uriTooLong('uri is too long'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 414, + "error": "Request-URI Too Large", + "message": "uri is too long" +} +``` + +### `Boom.unsupportedMediaType([message], [data])` + +Returns a 415 Unsupported Media Type error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.unsupportedMediaType('that media is not supported'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 415, + "error": "Unsupported Media Type", + "message": "that media is not supported" +} +``` + +### `Boom.rangeNotSatisfiable([message], [data])` + +Returns a 416 Requested Range Not Satisfiable error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.rangeNotSatisfiable(); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 416, + "error": "Requested Range Not Satisfiable" +} +``` + +### `Boom.expectationFailed([message], [data])` + +Returns a 417 Expectation Failed error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.expectationFailed('expected this to work'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 417, + "error": "Expectation Failed", + "message": "expected this to work" +} +``` + +### `Boom.badData([message], [data])` + +Returns a 422 Unprocessable Entity error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.badData('your data is bad and you should feel bad'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 422, + "error": "Unprocessable Entity", + "message": "your data is bad and you should feel bad" +} +``` + +### `Boom.preconditionRequired([message], [data])` + +Returns a 428 Precondition Required error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.preconditionRequired('you must supply an If-Match header'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 428, + "error": "Precondition Required", + "message": "you must supply an If-Match header" +} +``` + +### `Boom.tooManyRequests([message], [data])` + +Returns a 429 Too Many Requests error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.tooManyRequests('you have exceeded your request limit'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 429, + "error": "Too Many Requests", + "message": "you have exceeded your request limit" +} +``` + +## HTTP 5xx Errors + +All 500 errors hide your message from the end user. Your message is recorded in the server log. + +### `Boom.badImplementation([message], [data])` + +Returns a 500 Internal Server Error error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.badImplementation('terrible implementation'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 500, + "error": "Internal Server Error", + "message": "An internal server error occurred" +} +``` + +### `Boom.notImplemented([message], [data])` + +Returns a 501 Not Implemented error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.notImplemented('method not implemented'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 501, + "error": "Not Implemented", + "message": "method not implemented" +} +``` + +### `Boom.badGateway([message], [data])` + +Returns a 502 Bad Gateway error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.badGateway('that is a bad gateway'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 502, + "error": "Bad Gateway", + "message": "that is a bad gateway" +} +``` + +### `Boom.serverTimeout([message], [data])` + +Returns a 503 Service Unavailable error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.serverTimeout('unavailable'); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 503, + "error": "Service Unavailable", + "message": "unavailable" +} +``` + +### `Boom.gatewayTimeout([message], [data])` + +Returns a 504 Gateway Time-out error where: +- `message` - optional message. +- `data` - optional additional error data. + +```js +Boom.gatewayTimeout(); +``` + +Generates the following response payload: + +```json +{ + "statusCode": 504, + "error": "Gateway Time-out" +} +``` + +## F.A.Q. + +###### How do I include extra information in my responses? `output.payload` is missing `data`, what gives? + +There is a reason the values passed back in the response payloads are pretty locked down. It's mostly for security and to not leak any important information back to the client. This means you will need to put in a little more effort to include extra information about your custom error. Check out the ["Error transformation"](https://github.com/hapijs/hapi/blob/master/API.md#error-transformation) section in the hapi documentation. diff --git a/node_modules/boom/images/boom.png b/node_modules/boom/images/boom.png new file mode 100644 index 0000000..373bc13 Binary files /dev/null and b/node_modules/boom/images/boom.png differ diff --git a/node_modules/boom/lib/index.js b/node_modules/boom/lib/index.js new file mode 100644 index 0000000..6bdea69 --- /dev/null +++ b/node_modules/boom/lib/index.js @@ -0,0 +1,318 @@ +// Load modules + +var Http = require('http'); +var Hoek = require('hoek'); + + +// Declare internals + +var internals = {}; + +exports.wrap = function (error, statusCode, message) { + + Hoek.assert(error instanceof Error, 'Cannot wrap non-Error object'); + return (error.isBoom ? error : internals.initialize(error, statusCode || 500, message)); +}; + + +exports.create = function (statusCode, message, data) { + + return internals.create(statusCode, message, data, exports.create); +}; + +internals.create = function (statusCode, message, data, ctor) { + + var error = new Error(message ? message : undefined); // Avoids settings null message + Error.captureStackTrace(error, ctor); // Filter the stack to our external API + error.data = data || null; + internals.initialize(error, statusCode); + return error; +}; + +internals.initialize = function (error, statusCode, message) { + + var numberCode = parseInt(statusCode, 10); + Hoek.assert(!isNaN(numberCode) && numberCode >= 400, 'First argument must be a number (400+):', statusCode); + + error.isBoom = true; + error.isServer = numberCode >= 500; + + if (!error.hasOwnProperty('data')) { + error.data = null; + } + + error.output = { + statusCode: numberCode, + payload: {}, + headers: {} + }; + + error.reformat = internals.reformat; + error.reformat(); + + if (!message && + !error.message) { + + message = error.output.payload.error; + } + + if (message) { + error.message = (message + (error.message ? ': ' + error.message : '')); + } + + return error; +}; + + +internals.reformat = function () { + + this.output.payload.statusCode = this.output.statusCode; + this.output.payload.error = Http.STATUS_CODES[this.output.statusCode] || 'Unknown'; + + if (this.output.statusCode === 500) { + this.output.payload.message = 'An internal server error occurred'; // Hide actual error from user + } + else if (this.message) { + this.output.payload.message = this.message; + } +}; + + +// 4xx Client Errors + +exports.badRequest = function (message, data) { + + return internals.create(400, message, data, exports.badRequest); +}; + + +exports.unauthorized = function (message, scheme, attributes) { // Or function (message, wwwAuthenticate[]) + + var err = internals.create(401, message, undefined, exports.unauthorized); + + if (!scheme) { + return err; + } + + var wwwAuthenticate = ''; + var i = 0; + var il = 0; + + if (typeof scheme === 'string') { + + // function (message, scheme, attributes) + + wwwAuthenticate = scheme; + + if (attributes || message) { + err.output.payload.attributes = {}; + } + + if (attributes) { + var names = Object.keys(attributes); + for (i = 0, il = names.length; i < il; ++i) { + var name = names[i]; + if (i) { + wwwAuthenticate += ','; + } + + var value = attributes[name]; + if (value === null || + value === undefined) { // Value can be zero + + value = ''; + } + wwwAuthenticate += ' ' + name + '="' + Hoek.escapeHeaderAttribute(value.toString()) + '"'; + err.output.payload.attributes[name] = value; + } + } + + if (message) { + if (attributes) { + wwwAuthenticate += ','; + } + wwwAuthenticate += ' error="' + Hoek.escapeHeaderAttribute(message) + '"'; + err.output.payload.attributes.error = message; + } + else { + err.isMissing = true; + } + } + else { + + // function (message, wwwAuthenticate[]) + + var wwwArray = scheme; + for (i = 0, il = wwwArray.length; i < il; ++i) { + if (i) { + wwwAuthenticate += ', '; + } + + wwwAuthenticate += wwwArray[i]; + } + } + + err.output.headers['WWW-Authenticate'] = wwwAuthenticate; + + return err; +}; + + +exports.forbidden = function (message, data) { + + return internals.create(403, message, data, exports.forbidden); +}; + + +exports.notFound = function (message, data) { + + return internals.create(404, message, data, exports.notFound); +}; + + +exports.methodNotAllowed = function (message, data) { + + return internals.create(405, message, data, exports.methodNotAllowed); +}; + + +exports.notAcceptable = function (message, data) { + + return internals.create(406, message, data, exports.notAcceptable); +}; + + +exports.proxyAuthRequired = function (message, data) { + + return internals.create(407, message, data, exports.proxyAuthRequired); +}; + + +exports.clientTimeout = function (message, data) { + + return internals.create(408, message, data, exports.clientTimeout); +}; + + +exports.conflict = function (message, data) { + + return internals.create(409, message, data, exports.conflict); +}; + + +exports.resourceGone = function (message, data) { + + return internals.create(410, message, data, exports.resourceGone); +}; + + +exports.lengthRequired = function (message, data) { + + return internals.create(411, message, data, exports.lengthRequired); +}; + + +exports.preconditionFailed = function (message, data) { + + return internals.create(412, message, data, exports.preconditionFailed); +}; + + +exports.entityTooLarge = function (message, data) { + + return internals.create(413, message, data, exports.entityTooLarge); +}; + + +exports.uriTooLong = function (message, data) { + + return internals.create(414, message, data, exports.uriTooLong); +}; + + +exports.unsupportedMediaType = function (message, data) { + + return internals.create(415, message, data, exports.unsupportedMediaType); +}; + + +exports.rangeNotSatisfiable = function (message, data) { + + return internals.create(416, message, data, exports.rangeNotSatisfiable); +}; + + +exports.expectationFailed = function (message, data) { + + return internals.create(417, message, data, exports.expectationFailed); +}; + +exports.badData = function (message, data) { + + return internals.create(422, message, data, exports.badData); +}; + + +exports.preconditionRequired = function (message, data) { + + return internals.create(428, message, data, exports.preconditionRequired); +}; + + +exports.tooManyRequests = function (message, data) { + + return internals.create(429, message, data, exports.tooManyRequests); +}; + + +// 5xx Server Errors + +exports.internal = function (message, data, statusCode) { + + return internals.serverError(message, data, statusCode, exports.internal); +}; + +internals.serverError = function (message, data, statusCode, ctor) { + + var error; + if (data instanceof Error) { + error = exports.wrap(data, statusCode, message); + } else { + error = internals.create(statusCode || 500, message, undefined, ctor); + error.data = data; + } + + return error; +}; + + +exports.notImplemented = function (message, data) { + + return internals.serverError(message, data, 501, exports.notImplemented); +}; + + +exports.badGateway = function (message, data) { + + return internals.serverError(message, data, 502, exports.badGateway); +}; + + +exports.serverTimeout = function (message, data) { + + return internals.serverError(message, data, 503, exports.serverTimeout); +}; + + +exports.gatewayTimeout = function (message, data) { + + return internals.serverError(message, data, 504, exports.gatewayTimeout); +}; + + +exports.badImplementation = function (message, data) { + + var err = internals.serverError(message, data, 500, exports.badImplementation); + err.isDeveloperError = true; + return err; +}; diff --git a/node_modules/boom/package.json b/node_modules/boom/package.json new file mode 100644 index 0000000..79f7f42 --- /dev/null +++ b/node_modules/boom/package.json @@ -0,0 +1,59 @@ +{ + "_from": "boom@2.x.x", + "_id": "boom@2.10.1", + "_inBundle": false, + "_integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "_location": "/boom", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "boom@2.x.x", + "name": "boom", + "escapedName": "boom", + "rawSpec": "2.x.x", + "saveSpec": null, + "fetchSpec": "2.x.x" + }, + "_requiredBy": [ + "/cryptiles", + "/hawk" + ], + "_resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "_shasum": "39c8918ceff5799f83f9492a848f625add0c766f", + "_spec": "boom@2.x.x", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\hawk", + "bugs": { + "url": "https://github.com/hapijs/boom/issues" + }, + "bundleDependencies": false, + "dependencies": { + "hoek": "2.x.x" + }, + "deprecated": false, + "description": "HTTP-friendly error objects", + "devDependencies": { + "code": "1.x.x", + "lab": "7.x.x" + }, + "engines": { + "node": ">=0.10.40" + }, + "homepage": "https://github.com/hapijs/boom#readme", + "keywords": [ + "error", + "http" + ], + "license": "BSD-3-Clause", + "main": "lib/index.js", + "name": "boom", + "repository": { + "type": "git", + "url": "git://github.com/hapijs/boom.git" + }, + "scripts": { + "test": "lab -a code -t 100 -L", + "test-cov-html": "lab -a code -r html -o coverage.html -L" + }, + "version": "2.10.1" +} diff --git a/node_modules/boom/test/index.js b/node_modules/boom/test/index.js new file mode 100644 index 0000000..79a59e9 --- /dev/null +++ b/node_modules/boom/test/index.js @@ -0,0 +1,654 @@ +// Load modules + +var Code = require('code'); +var Boom = require('../lib'); +var Lab = require('lab'); + + +// Declare internals + +var internals = {}; + + +// Test shortcuts + +var lab = exports.lab = Lab.script(); +var describe = lab.describe; +var it = lab.it; +var expect = Code.expect; + + +it('returns the same object when already boom', function (done) { + + var error = Boom.badRequest(); + var wrapped = Boom.wrap(error); + expect(error).to.equal(wrapped); + done(); +}); + +it('returns an error with info when constructed using another error', function (done) { + + var error = new Error('ka-boom'); + error.xyz = 123; + var err = Boom.wrap(error); + expect(err.xyz).to.equal(123); + expect(err.message).to.equal('ka-boom'); + expect(err.output).to.deep.equal({ + statusCode: 500, + payload: { + statusCode: 500, + error: 'Internal Server Error', + message: 'An internal server error occurred' + }, + headers: {} + }); + expect(err.data).to.equal(null); + done(); +}); + +it('does not override data when constructed using another error', function (done) { + + var error = new Error('ka-boom'); + error.data = { useful: 'data' }; + var err = Boom.wrap(error); + expect(err.data).to.equal(error.data); + done(); +}); + +it('sets new message when none exists', function (done) { + + var error = new Error(); + var wrapped = Boom.wrap(error, 400, 'something bad'); + expect(wrapped.message).to.equal('something bad'); + done(); +}); + +it('throws when statusCode is not a number', function (done) { + + expect(function () { + + Boom.create('x'); + }).to.throw('First argument must be a number (400+): x'); + done(); +}); + +it('will cast a number-string to an integer', function (done) { + + var codes = [ + { input: '404', result: 404 }, + { input: '404.1', result: 404 }, + { input: 400, result: 400 }, + { input: 400.123, result: 400 }]; + for (var i = 0, il = codes.length; i < il; ++i) { + var code = codes[i]; + var err = Boom.create(code.input); + expect(err.output.statusCode).to.equal(code.result); + } + + done(); +}); + +it('throws when statusCode is not finite', function (done) { + + expect(function () { + + Boom.create(1 / 0); + }).to.throw('First argument must be a number (400+): null'); + done(); +}); + +it('sets error code to unknown', function (done) { + + var err = Boom.create(999); + expect(err.output.payload.error).to.equal('Unknown'); + done(); +}); + +describe('create()', function () { + + it('does not sets null message', function (done) { + + var error = Boom.unauthorized(null); + expect(error.output.payload.message).to.not.exist(); + expect(error.isServer).to.be.false(); + done(); + }); + + it('sets message and data', function (done) { + + var error = Boom.badRequest('Missing data', { type: 'user' }); + expect(error.data.type).to.equal('user'); + expect(error.output.payload.message).to.equal('Missing data'); + done(); + }); +}); + +describe('isBoom()', function () { + + it('returns true for Boom object', function (done) { + + expect(Boom.badRequest().isBoom).to.equal(true); + done(); + }); + + it('returns false for Error object', function (done) { + + expect((new Error()).isBoom).to.not.exist(); + done(); + }); +}); + +describe('badRequest()', function () { + + it('returns a 400 error statusCode', function (done) { + + var error = Boom.badRequest(); + + expect(error.output.statusCode).to.equal(400); + expect(error.isServer).to.be.false(); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.badRequest('my message').message).to.equal('my message'); + done(); + }); + + it('sets the message to HTTP status if none provided', function (done) { + + expect(Boom.badRequest().message).to.equal('Bad Request'); + done(); + }); +}); + +describe('unauthorized()', function () { + + it('returns a 401 error statusCode', function (done) { + + var err = Boom.unauthorized(); + expect(err.output.statusCode).to.equal(401); + expect(err.output.headers).to.deep.equal({}); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.unauthorized('my message').message).to.equal('my message'); + done(); + }); + + it('returns a WWW-Authenticate header when passed a scheme', function (done) { + + var err = Boom.unauthorized('boom', 'Test'); + expect(err.output.statusCode).to.equal(401); + expect(err.output.headers['WWW-Authenticate']).to.equal('Test error="boom"'); + done(); + }); + + it('returns a WWW-Authenticate header set to the schema array value', function (done) { + + var err = Boom.unauthorized(null, ['Test','one','two']); + expect(err.output.statusCode).to.equal(401); + expect(err.output.headers['WWW-Authenticate']).to.equal('Test, one, two'); + done(); + }); + + it('returns a WWW-Authenticate header when passed a scheme and attributes', function (done) { + + var err = Boom.unauthorized('boom', 'Test', { a: 1, b: 'something', c: null, d: 0 }); + expect(err.output.statusCode).to.equal(401); + expect(err.output.headers['WWW-Authenticate']).to.equal('Test a="1", b="something", c="", d="0", error="boom"'); + expect(err.output.payload.attributes).to.deep.equal({ a: 1, b: 'something', c: '', d: 0, error: 'boom' }); + done(); + }); + + it('returns a WWW-Authenticate header when passed attributes, missing error', function (done) { + + var err = Boom.unauthorized(null, 'Test', { a: 1, b: 'something', c: null, d: 0 }); + expect(err.output.statusCode).to.equal(401); + expect(err.output.headers['WWW-Authenticate']).to.equal('Test a="1", b="something", c="", d="0"'); + expect(err.isMissing).to.equal(true); + done(); + }); + + it('sets the isMissing flag when error message is empty', function (done) { + + var err = Boom.unauthorized('', 'Basic'); + expect(err.isMissing).to.equal(true); + done(); + }); + + it('does not set the isMissing flag when error message is not empty', function (done) { + + var err = Boom.unauthorized('message', 'Basic'); + expect(err.isMissing).to.equal(undefined); + done(); + }); + + it('sets a WWW-Authenticate when passed as an array', function (done) { + + var err = Boom.unauthorized('message', ['Basic', 'Example e="1"', 'Another x="3", y="4"']); + expect(err.output.headers['WWW-Authenticate']).to.equal('Basic, Example e="1", Another x="3", y="4"'); + done(); + }); +}); + + +describe('methodNotAllowed()', function () { + + it('returns a 405 error statusCode', function (done) { + + expect(Boom.methodNotAllowed().output.statusCode).to.equal(405); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.methodNotAllowed('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('notAcceptable()', function () { + + it('returns a 406 error statusCode', function (done) { + + expect(Boom.notAcceptable().output.statusCode).to.equal(406); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.notAcceptable('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('proxyAuthRequired()', function () { + + it('returns a 407 error statusCode', function (done) { + + expect(Boom.proxyAuthRequired().output.statusCode).to.equal(407); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.proxyAuthRequired('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('clientTimeout()', function () { + + it('returns a 408 error statusCode', function (done) { + + expect(Boom.clientTimeout().output.statusCode).to.equal(408); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.clientTimeout('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('conflict()', function () { + + it('returns a 409 error statusCode', function (done) { + + expect(Boom.conflict().output.statusCode).to.equal(409); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.conflict('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('resourceGone()', function () { + + it('returns a 410 error statusCode', function (done) { + + expect(Boom.resourceGone().output.statusCode).to.equal(410); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.resourceGone('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('lengthRequired()', function () { + + it('returns a 411 error statusCode', function (done) { + + expect(Boom.lengthRequired().output.statusCode).to.equal(411); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.lengthRequired('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('preconditionFailed()', function () { + + it('returns a 412 error statusCode', function (done) { + + expect(Boom.preconditionFailed().output.statusCode).to.equal(412); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.preconditionFailed('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('entityTooLarge()', function () { + + it('returns a 413 error statusCode', function (done) { + + expect(Boom.entityTooLarge().output.statusCode).to.equal(413); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.entityTooLarge('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('uriTooLong()', function () { + + it('returns a 414 error statusCode', function (done) { + + expect(Boom.uriTooLong().output.statusCode).to.equal(414); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.uriTooLong('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('unsupportedMediaType()', function () { + + it('returns a 415 error statusCode', function (done) { + + expect(Boom.unsupportedMediaType().output.statusCode).to.equal(415); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.unsupportedMediaType('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('rangeNotSatisfiable()', function () { + + it('returns a 416 error statusCode', function (done) { + + expect(Boom.rangeNotSatisfiable().output.statusCode).to.equal(416); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.rangeNotSatisfiable('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('expectationFailed()', function () { + + it('returns a 417 error statusCode', function (done) { + + expect(Boom.expectationFailed().output.statusCode).to.equal(417); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.expectationFailed('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('badData()', function () { + + it('returns a 422 error statusCode', function (done) { + + expect(Boom.badData().output.statusCode).to.equal(422); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.badData('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('preconditionRequired()', function () { + + it('returns a 428 error statusCode', function (done) { + + expect(Boom.preconditionRequired().output.statusCode).to.equal(428); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.preconditionRequired('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('tooManyRequests()', function () { + + it('returns a 429 error statusCode', function (done) { + + expect(Boom.tooManyRequests().output.statusCode).to.equal(429); + done(); + }); + + it('sets the message with the passed-in message', function (done) { + + expect(Boom.tooManyRequests('my message').message).to.equal('my message'); + done(); + }); +}); + +describe('serverTimeout()', function () { + + it('returns a 503 error statusCode', function (done) { + + expect(Boom.serverTimeout().output.statusCode).to.equal(503); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.serverTimeout('my message').message).to.equal('my message'); + done(); + }); +}); + +describe('forbidden()', function () { + + it('returns a 403 error statusCode', function (done) { + + expect(Boom.forbidden().output.statusCode).to.equal(403); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.forbidden('my message').message).to.equal('my message'); + done(); + }); +}); + +describe('notFound()', function () { + + it('returns a 404 error statusCode', function (done) { + + expect(Boom.notFound().output.statusCode).to.equal(404); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.notFound('my message').message).to.equal('my message'); + done(); + }); +}); + +describe('internal()', function () { + + it('returns a 500 error statusCode', function (done) { + + expect(Boom.internal().output.statusCode).to.equal(500); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + var err = Boom.internal('my message'); + expect(err.message).to.equal('my message'); + expect(err.isServer).to.true(); + expect(err.output.payload.message).to.equal('An internal server error occurred'); + done(); + }); + + it('passes data on the callback if its passed in', function (done) { + + expect(Boom.internal('my message', { my: 'data' }).data.my).to.equal('data'); + done(); + }); + + it('returns an error with composite message', function (done) { + + try { + JSON.parse('{'); + } + catch (err) { + var boom = Boom.internal('Someting bad', err); + expect(boom.message).to.equal('Someting bad: Unexpected end of input'); + expect(boom.isServer).to.be.true(); + done(); + } + }); +}); + +describe('notImplemented()', function () { + + it('returns a 501 error statusCode', function (done) { + + expect(Boom.notImplemented().output.statusCode).to.equal(501); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.notImplemented('my message').message).to.equal('my message'); + done(); + }); +}); + + +describe('badGateway()', function () { + + it('returns a 502 error statusCode', function (done) { + + expect(Boom.badGateway().output.statusCode).to.equal(502); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.badGateway('my message').message).to.equal('my message'); + done(); + }); +}); + +describe('gatewayTimeout()', function () { + + it('returns a 504 error statusCode', function (done) { + + expect(Boom.gatewayTimeout().output.statusCode).to.equal(504); + done(); + }); + + it('sets the message with the passed in message', function (done) { + + expect(Boom.gatewayTimeout('my message').message).to.equal('my message'); + done(); + }); +}); + +describe('badImplementation()', function () { + + it('returns a 500 error statusCode', function (done) { + + var err = Boom.badImplementation(); + expect(err.output.statusCode).to.equal(500); + expect(err.isDeveloperError).to.equal(true); + expect(err.isServer).to.be.true(); + done(); + }); +}); + +describe('stack trace', function () { + + it('should omit lib', function (done) { + + ['badRequest', 'unauthorized', 'forbidden', 'notFound', 'methodNotAllowed', + 'notAcceptable', 'proxyAuthRequired', 'clientTimeout', 'conflict', + 'resourceGone', 'lengthRequired', 'preconditionFailed', 'entityTooLarge', + 'uriTooLong', 'unsupportedMediaType', 'rangeNotSatisfiable', 'expectationFailed', + 'badData', 'preconditionRequired', 'tooManyRequests', + + // 500s + 'internal', 'notImplemented', 'badGateway', 'serverTimeout', 'gatewayTimeout', + 'badImplementation' + ].forEach(function (name) { + + var err = Boom[name](); + expect(err.stack).to.not.match(/\/lib\/index\.js/); + }); + + done(); + }); +}); diff --git a/node_modules/buffer-equal-constant-time/.npmignore b/node_modules/buffer-equal-constant-time/.npmignore new file mode 100644 index 0000000..34e4f5c --- /dev/null +++ b/node_modules/buffer-equal-constant-time/.npmignore @@ -0,0 +1,2 @@ +.*.sw[mnop] +node_modules/ diff --git a/node_modules/buffer-equal-constant-time/.travis.yml b/node_modules/buffer-equal-constant-time/.travis.yml new file mode 100644 index 0000000..78e1c01 --- /dev/null +++ b/node_modules/buffer-equal-constant-time/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: +- "0.11" +- "0.10" diff --git a/node_modules/buffer-equal-constant-time/LICENSE.txt b/node_modules/buffer-equal-constant-time/LICENSE.txt new file mode 100644 index 0000000..9a064f3 --- /dev/null +++ b/node_modules/buffer-equal-constant-time/LICENSE.txt @@ -0,0 +1,12 @@ +Copyright (c) 2013, GoInstant Inc., a salesforce.com company +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of salesforce.com, nor GoInstant, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/buffer-equal-constant-time/README.md b/node_modules/buffer-equal-constant-time/README.md new file mode 100644 index 0000000..4f227f5 --- /dev/null +++ b/node_modules/buffer-equal-constant-time/README.md @@ -0,0 +1,50 @@ +# buffer-equal-constant-time + +Constant-time `Buffer` comparison for node.js. Should work with browserify too. + +[![Build Status](https://travis-ci.org/goinstant/buffer-equal-constant-time.png?branch=master)](https://travis-ci.org/goinstant/buffer-equal-constant-time) + +```sh + npm install buffer-equal-constant-time +``` + +# Usage + +```js + var bufferEq = require('buffer-equal-constant-time'); + + var a = new Buffer('asdf'); + var b = new Buffer('asdf'); + if (bufferEq(a,b)) { + // the same! + } else { + // different in at least one byte! + } +``` + +If you'd like to install an `.equal()` method onto the node.js `Buffer` and +`SlowBuffer` prototypes: + +```js + require('buffer-equal-constant-time').install(); + + var a = new Buffer('asdf'); + var b = new Buffer('asdf'); + if (a.equal(b)) { + // the same! + } else { + // different in at least one byte! + } +``` + +To get rid of the installed `.equal()` method, call `.restore()`: + +```js + require('buffer-equal-constant-time').restore(); +``` + +# Legal + +© 2013 GoInstant Inc., a salesforce.com company + +Licensed under the BSD 3-clause license. diff --git a/node_modules/buffer-equal-constant-time/index.js b/node_modules/buffer-equal-constant-time/index.js new file mode 100644 index 0000000..5462c1f --- /dev/null +++ b/node_modules/buffer-equal-constant-time/index.js @@ -0,0 +1,41 @@ +/*jshint node:true */ +'use strict'; +var Buffer = require('buffer').Buffer; // browserify +var SlowBuffer = require('buffer').SlowBuffer; + +module.exports = bufferEq; + +function bufferEq(a, b) { + + // shortcutting on type is necessary for correctness + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + return false; + } + + // buffer sizes should be well-known information, so despite this + // shortcutting, it doesn't leak any information about the *contents* of the + // buffers. + if (a.length !== b.length) { + return false; + } + + var c = 0; + for (var i = 0; i < a.length; i++) { + /*jshint bitwise:false */ + c |= a[i] ^ b[i]; // XOR + } + return c === 0; +} + +bufferEq.install = function() { + Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal(that) { + return bufferEq(this, that); + }; +}; + +var origBufEqual = Buffer.prototype.equal; +var origSlowBufEqual = SlowBuffer.prototype.equal; +bufferEq.restore = function() { + Buffer.prototype.equal = origBufEqual; + SlowBuffer.prototype.equal = origSlowBufEqual; +}; diff --git a/node_modules/buffer-equal-constant-time/package.json b/node_modules/buffer-equal-constant-time/package.json new file mode 100644 index 0000000..2c9531a --- /dev/null +++ b/node_modules/buffer-equal-constant-time/package.json @@ -0,0 +1,55 @@ +{ + "_from": "buffer-equal-constant-time@^1.0.1", + "_id": "buffer-equal-constant-time@1.0.1", + "_inBundle": false, + "_integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=", + "_location": "/buffer-equal-constant-time", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "buffer-equal-constant-time@^1.0.1", + "name": "buffer-equal-constant-time", + "escapedName": "buffer-equal-constant-time", + "rawSpec": "^1.0.1", + "saveSpec": null, + "fetchSpec": "^1.0.1" + }, + "_requiredBy": [ + "/jwa" + ], + "_resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "_shasum": "f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819", + "_spec": "buffer-equal-constant-time@^1.0.1", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\jwa", + "author": { + "name": "GoInstant Inc., a salesforce.com company" + }, + "bugs": { + "url": "https://github.com/goinstant/buffer-equal-constant-time/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Constant-time comparison of Buffers", + "devDependencies": { + "mocha": "~1.15.1" + }, + "homepage": "https://github.com/goinstant/buffer-equal-constant-time#readme", + "keywords": [ + "buffer", + "equal", + "constant-time", + "crypto" + ], + "license": "BSD-3-Clause", + "main": "index.js", + "name": "buffer-equal-constant-time", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/goinstant/buffer-equal-constant-time.git" + }, + "scripts": { + "test": "mocha test.js" + }, + "version": "1.0.1" +} diff --git a/node_modules/camelcase-keys/index.js b/node_modules/camelcase-keys/index.js new file mode 100644 index 0000000..cd081ee --- /dev/null +++ b/node_modules/camelcase-keys/index.js @@ -0,0 +1,9 @@ +'use strict'; +var mapObj = require('map-obj'); +var camelCase = require('camelcase'); + +module.exports = function (obj) { + return mapObj(obj, function (key, val) { + return [camelCase(key), val]; + }); +}; diff --git a/node_modules/camelcase-keys/package.json b/node_modules/camelcase-keys/package.json new file mode 100644 index 0000000..48dac82 --- /dev/null +++ b/node_modules/camelcase-keys/package.json @@ -0,0 +1,83 @@ +{ + "_from": "camelcase-keys@^1.0.0", + "_id": "camelcase-keys@1.0.0", + "_inBundle": false, + "_integrity": "sha1-vRoRv5sxoc5JNJOpMN4aC69K1+w=", + "_location": "/camelcase-keys", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "camelcase-keys@^1.0.0", + "name": "camelcase-keys", + "escapedName": "camelcase-keys", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/meow" + ], + "_resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-1.0.0.tgz", + "_shasum": "bd1a11bf9b31a1ce493493a930de1a0baf4ad7ec", + "_spec": "camelcase-keys@^1.0.0", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\meow", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/camelcase-keys/issues" + }, + "bundleDependencies": false, + "dependencies": { + "camelcase": "^1.0.1", + "map-obj": "^1.0.0" + }, + "deprecated": false, + "description": "Convert object keys to camelCase", + "devDependencies": { + "ava": "0.0.4" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/camelcase-keys#readme", + "keywords": [ + "map", + "obj", + "object", + "key", + "keys", + "value", + "values", + "val", + "iterate", + "camelcase", + "camel-case", + "camel", + "case", + "dash", + "hyphen", + "dot", + "underscore", + "separator", + "string", + "text", + "convert" + ], + "license": "MIT", + "name": "camelcase-keys", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/camelcase-keys.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.0" +} diff --git a/node_modules/camelcase-keys/readme.md b/node_modules/camelcase-keys/readme.md new file mode 100644 index 0000000..97a200b --- /dev/null +++ b/node_modules/camelcase-keys/readme.md @@ -0,0 +1,32 @@ +# camelcase-keys [![Build Status](https://travis-ci.org/sindresorhus/camelcase-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase-keys) + +> Convert object keys to camelCase using [`camelcase`](https://github.com/sindresorhus/camelcase) + + +## Install + +```sh +$ npm install --save camelcase-keys +``` + + +## Usage + +```js +var camelcaseKeys = require('camelcase-keys'); + +camelcaseKeys({'foo-bar': true}); +//=> {fooBar: true} + + +var argv = require('minimist')(process.argv.slice(2)); +//=> {_: [], 'foo-bar': true} + +camelcaseKeys(argv); +//=> {_: [], fooBar: true} +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/camelcase/index.js b/node_modules/camelcase/index.js new file mode 100644 index 0000000..b46e100 --- /dev/null +++ b/node_modules/camelcase/index.js @@ -0,0 +1,27 @@ +'use strict'; +module.exports = function () { + var str = [].map.call(arguments, function (str) { + return str.trim(); + }).filter(function (str) { + return str.length; + }).join('-'); + + if (!str.length) { + return ''; + } + + if (str.length === 1 || !(/[_.\- ]+/).test(str) ) { + if (str[0] === str[0].toLowerCase() && str.slice(1) !== str.slice(1).toLowerCase()) { + return str; + } + + return str.toLowerCase(); + } + + return str + .replace(/^[_.\- ]+/, '') + .toLowerCase() + .replace(/[_.\- ]+(\w|$)/g, function (m, p1) { + return p1.toUpperCase(); + }); +}; diff --git a/node_modules/camelcase/license b/node_modules/camelcase/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/node_modules/camelcase/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/camelcase/package.json b/node_modules/camelcase/package.json new file mode 100644 index 0000000..b231820 --- /dev/null +++ b/node_modules/camelcase/package.json @@ -0,0 +1,70 @@ +{ + "_from": "camelcase@^1.0.1", + "_id": "camelcase@1.2.1", + "_inBundle": false, + "_integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "_location": "/camelcase", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "camelcase@^1.0.1", + "name": "camelcase", + "escapedName": "camelcase", + "rawSpec": "^1.0.1", + "saveSpec": null, + "fetchSpec": "^1.0.1" + }, + "_requiredBy": [ + "/camelcase-keys" + ], + "_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "_shasum": "9bb5304d2e0b56698b2c758b08a3eaa9daa58a39", + "_spec": "camelcase@^1.0.1", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\camelcase-keys", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/camelcase/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar", + "devDependencies": { + "ava": "0.0.4" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/camelcase#readme", + "keywords": [ + "camelcase", + "camel-case", + "camel", + "case", + "dash", + "hyphen", + "dot", + "underscore", + "separator", + "string", + "text", + "convert" + ], + "license": "MIT", + "name": "camelcase", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/camelcase.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.2.1" +} diff --git a/node_modules/camelcase/readme.md b/node_modules/camelcase/readme.md new file mode 100644 index 0000000..516dc39 --- /dev/null +++ b/node_modules/camelcase/readme.md @@ -0,0 +1,56 @@ +# camelcase [![Build Status](https://travis-ci.org/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase) + +> Convert a dash/dot/underscore/space separated string to camelCase: `foo-bar` → `fooBar` + + +## Install + +```sh +$ npm install --save camelcase +``` + + +## Usage + +```js +var camelCase = require('camelcase'); + +camelCase('foo-bar'); +//=> fooBar + +camelCase('foo_bar'); +//=> fooBar + +camelCase('Foo-Bar'); +//=> fooBar + +camelCase('--foo.bar'); +//=> fooBar + +camelCase('__foo__bar__'); +//=> fooBar + +camelCase('foo bar'); +//=> fooBar + +console.log(process.argv[3]); +//=> --foo-bar +camelCase(process.argv[3]); +//=> fooBar + +camelCase('foo', 'bar'); +//=> fooBar + +camelCase('__foo__', '--bar'); +//=> fooBar +``` + + +## Related + +See [`decamelize`](https://github.com/sindresorhus/decamelize) for the inverse. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/cryptiles/.npmignore b/node_modules/cryptiles/.npmignore new file mode 100644 index 0000000..77ba16c --- /dev/null +++ b/node_modules/cryptiles/.npmignore @@ -0,0 +1,18 @@ +.idea +*.iml +npm-debug.log +dump.rdb +node_modules +results.tap +results.xml +npm-shrinkwrap.json +config.json +.DS_Store +*/.DS_Store +*/*/.DS_Store +._* +*/._* +*/*/._* +coverage.* +lib-cov + diff --git a/node_modules/cryptiles/.travis.yml b/node_modules/cryptiles/.travis.yml new file mode 100644 index 0000000..dd1b24f --- /dev/null +++ b/node_modules/cryptiles/.travis.yml @@ -0,0 +1,8 @@ +language: node_js + +node_js: + - 0.10 + - 4.0 + +sudo: false + diff --git a/node_modules/cryptiles/LICENSE b/node_modules/cryptiles/LICENSE new file mode 100644 index 0000000..cda4473 --- /dev/null +++ b/node_modules/cryptiles/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2014, Eran Hammer and other contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of any contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + * * * + +The complete list of contributors can be found at: https://github.com/hueniverse/cryptiles/graphs/contributors diff --git a/node_modules/cryptiles/README.md b/node_modules/cryptiles/README.md new file mode 100644 index 0000000..4008305 --- /dev/null +++ b/node_modules/cryptiles/README.md @@ -0,0 +1,16 @@ +cryptiles +========= + +General purpose crypto utilities + +[![Build Status](https://secure.travis-ci.org/hapijs/cryptiles.png)](http://travis-ci.org/hapijs/cryptiles) + +Lead Maintainer - [C J Silverio](https://github.com/ceejbot) + +## Methods + +### `randomString( size)` +Returns a cryptographically strong pseudo-random data string. Takes a size argument for the length of the string. + +### `fixedTimeComparison( a, b)` +Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match). Returns `true` if the strings match, `false` if they differ. diff --git a/node_modules/cryptiles/lib/index.js b/node_modules/cryptiles/lib/index.js new file mode 100644 index 0000000..f385870 --- /dev/null +++ b/node_modules/cryptiles/lib/index.js @@ -0,0 +1,68 @@ +// Load modules + +var Crypto = require('crypto'); +var Boom = require('boom'); + + +// Declare internals + +var internals = {}; + + +// Generate a cryptographically strong pseudo-random data + +exports.randomString = function (size) { + + var buffer = exports.randomBits((size + 1) * 6); + if (buffer instanceof Error) { + return buffer; + } + + var string = buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, ''); + return string.slice(0, size); +}; + + +exports.randomBits = function (bits) { + + if (!bits || + bits < 0) { + + return Boom.internal('Invalid random bits count'); + } + + var bytes = Math.ceil(bits / 8); + try { + return Crypto.randomBytes(bytes); + } + catch (err) { + return Boom.internal('Failed generating random bits: ' + err.message); + } +}; + + +// Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match) + +exports.fixedTimeComparison = function (a, b) { + + if (typeof a !== 'string' || + typeof b !== 'string') { + + return false; + } + + var mismatch = (a.length === b.length ? 0 : 1); + if (mismatch) { + b = a; + } + + for (var i = 0, il = a.length; i < il; ++i) { + var ac = a.charCodeAt(i); + var bc = b.charCodeAt(i); + mismatch |= (ac ^ bc); + } + + return (mismatch === 0); +}; + + diff --git a/node_modules/cryptiles/package.json b/node_modules/cryptiles/package.json new file mode 100644 index 0000000..a2aab11 --- /dev/null +++ b/node_modules/cryptiles/package.json @@ -0,0 +1,59 @@ +{ + "_from": "cryptiles@2.x.x", + "_id": "cryptiles@2.0.5", + "_inBundle": false, + "_integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "_location": "/cryptiles", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "cryptiles@2.x.x", + "name": "cryptiles", + "escapedName": "cryptiles", + "rawSpec": "2.x.x", + "saveSpec": null, + "fetchSpec": "2.x.x" + }, + "_requiredBy": [ + "/hawk" + ], + "_resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "_shasum": "3bdfecdc608147c1c67202fa291e7dca59eaa3b8", + "_spec": "cryptiles@2.x.x", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\hawk", + "bugs": { + "url": "https://github.com/hapijs/cryptiles/issues" + }, + "bundleDependencies": false, + "dependencies": { + "boom": "2.x.x" + }, + "deprecated": false, + "description": "General purpose crypto utilities", + "devDependencies": { + "code": "1.x.x", + "lab": "5.x.x" + }, + "engines": { + "node": ">=0.10.40" + }, + "homepage": "https://github.com/hapijs/cryptiles#readme", + "keywords": [ + "cryptography", + "security", + "utilites" + ], + "license": "BSD-3-Clause", + "main": "lib/index.js", + "name": "cryptiles", + "repository": { + "type": "git", + "url": "git://github.com/hapijs/cryptiles.git" + }, + "scripts": { + "test": "lab -a code -t 100 -L", + "test-cov-html": "lab -a code -r html -o coverage.html" + }, + "version": "2.0.5" +} diff --git a/node_modules/cryptiles/test/index.js b/node_modules/cryptiles/test/index.js new file mode 100644 index 0000000..170393f --- /dev/null +++ b/node_modules/cryptiles/test/index.js @@ -0,0 +1,102 @@ +// Load modules + +var Code = require('code'); +var Cryptiles = require('..'); +var Lab = require('lab'); + + +// Declare internals + +var internals = {}; + + +// Test shortcuts + +var lab = exports.lab = Lab.script(); +var describe = lab.describe; +var it = lab.it; +var expect = Code.expect; + + +describe('randomString()', function () { + + it('should generate the right length string', function (done) { + + for (var i = 1; i <= 1000; ++i) { + expect(Cryptiles.randomString(i).length).to.equal(i); + } + + done(); + }); + + it('returns an error on invalid bits size', function (done) { + + expect(Cryptiles.randomString(99999999999999999999).message).to.match(/Failed generating random bits/); + done(); + }); +}); + +describe('randomBits()', function () { + + it('returns an error on invalid input', function (done) { + + expect(Cryptiles.randomBits(0).message).to.equal('Invalid random bits count'); + done(); + }); +}); + +describe('fixedTimeComparison()', function () { + + var a = Cryptiles.randomString(50000); + var b = Cryptiles.randomString(150000); + + it('should take the same amount of time comparing different string sizes', function (done) { + + var now = Date.now(); + Cryptiles.fixedTimeComparison(b, a); + var t1 = Date.now() - now; + + now = Date.now(); + Cryptiles.fixedTimeComparison(b, b); + var t2 = Date.now() - now; + + expect(t2 - t1).to.be.within(-20, 20); + done(); + }); + + it('should return true for equal strings', function (done) { + + expect(Cryptiles.fixedTimeComparison(a, a)).to.equal(true); + done(); + }); + + it('should return false for different strings (size, a < b)', function (done) { + + expect(Cryptiles.fixedTimeComparison(a, a + 'x')).to.equal(false); + done(); + }); + + it('should return false for different strings (size, a > b)', function (done) { + + expect(Cryptiles.fixedTimeComparison(a + 'x', a)).to.equal(false); + done(); + }); + + it('should return false for different strings (size, a = b)', function (done) { + + expect(Cryptiles.fixedTimeComparison(a + 'x', a + 'y')).to.equal(false); + done(); + }); + + it('should return false when not a string', function (done) { + + expect(Cryptiles.fixedTimeComparison('x', null)).to.equal(false); + done(); + }); + + it('should return false when not a string (left)', function (done) { + + expect(Cryptiles.fixedTimeComparison(null, 'x')).to.equal(false); + done(); + }); +}); diff --git a/node_modules/discord.js-musicbot-addon/LICENSE b/node_modules/discord.js-musicbot-addon/LICENSE new file mode 100644 index 0000000..7e5389a --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2016, Ruiqi Mao + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/node_modules/discord.js-musicbot-addon/README.md b/node_modules/discord.js-musicbot-addon/README.md new file mode 100644 index 0000000..8694481 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/README.md @@ -0,0 +1,75 @@ +[![npm package](https://nodei.co/npm/discord.js-musicbot-addon.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/discord.js-musicbot-addon/) +[![Discord Server](https://discordapp.com/api/guilds/427239929924288532/embed.png)](https://discord.gg/FKYrX4X) [![Downlaods](https://img.shields.io/npm/dt/discord.js-musicbot-addon.svg?maxAge=3600)](https://www.npmjs.com/package/discord.js-musicbot-addon) [![Version](https://img.shields.io/npm/v/discord.js-musicbot-addon.svg?maxAge=3600)](https://www.npmjs.com/package/discord.js-musicbot-addon) + +This was originally an update of the original bot from [ruiqimao](https://github.com/ruiqimao/discord.js-music) by [nexu-dev](https://www.npmjs.com/package/discord.js-music-v11), but is now a updated version (again) for [Discord.js](https://discord.js.org/)'s version 11.2^. Fixes deprecated warnings, video playback issues, along with various other add-ons and tweaks to the priors. This module may be buggy and need some fine tuning. Feel free to let me know what problems you encounter by opening an issue on the repo or joining the [Discord server](https://discord.gg/cADwxKs), where I or a `@Helper` will help you. + +# Docs, installation, and so on: +* [Docs](https://github.com/DarkoPendragon/discord.js-musicbot-addon/wiki/Documentation) +* [Installation & Troubleshooting](https://github.com/DarkoPendragon/discord.js-musicbot-addon/wiki/Installation-&-Troubleshooting) +* [Support Server](https://discord.gg/cADwxKs) + +# Basic Example. +*** +This addon is easy to use, and doesn't require any extra configuration besides a YouTube Data API key to run. +More examples can be found on the repo or once downloaded in `examples`. + +__Example basic code, standalone:__ +```javascript +const Discord = require('discord.js'); +const Music = require('discord.js-musicbot-addon'); +const client = new Discord.Client(); + +Music.start(client, { + youtubeKey: 'sum-key_hhereas' +}); + +client.login("token"); +``` + +# Changelog +*** +## 12.0.6 +* Updated the `README.md` file, like I should have. +* Added some more exports. I think. +* Added docs to the repo. + +## 12.0.5 +* Forgot to map the join command. Did that. + +## 12.0.4 +* Added a `join` command, and related options. +* Added `anyoneCanJoin`. +* Fixed `console.error` in the startup function. +* To save space, be it small, examples are no longer downloaded with npm. + +## 12.0.3 +* Added some easy-exports incase you want to change up some shit. Will be listed above. +* Changed some console logging to make sure it logs as an error, not just data. +* Fixed `searchHelp` (used to be `searcHelp`... Yeah). + +## 12.0.2 +* Redid some parts of the `executeQueue` function. +* Redid a tiny bit of the `play`, `leave` functions. +* Redid the entire `isQueueEmpty` function. +* Lived another day. + +## 12.0.1 +* Fixed a `Promise` format error in `checkQueues`. +* Fixed `index.min.js`. + +# 12.0.0 +* `ownerOverMember` now overrides `canAdjust`. +* Re-worked queue system and related functions. +* `verifyQueue` changed to `isQueueEmpty`. +* Made a real update. +* Removed the `owner` command. +* Fixed aliases. +* Added an `index.min.js` file to the repo for people wanting to squeeze size. +* Added `clearOnLeave`. +* The bot will no longer clear the queue on `leave` unless `clearOnLeave` is true. +* Baked chocolate for my girlfriend. +* Added `checkQueues`. *Use only if needed.* +* Cleared browser history for the past week. #nekoparaForLife. + +## 11.0.3 & Lower +* ~deprecated versions~ diff --git a/node_modules/discord.js-musicbot-addon/index.js b/node_modules/discord.js-musicbot-addon/index.js new file mode 100644 index 0000000..1035461 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/index.js @@ -0,0 +1,2273 @@ +/* + * Original code from nexu-dev, https://github.com/nexu-dev/discord.js-client + * Newly edited by Darko Pendragon (Demise). + * Other Credits: + * - Erik Rodabaugh. + * - mcao. + * - Naz (BluSpring). + * - MatthewJ217. + */ + +const ytdl = require('ytdl-core'); +const {YTSearcher} = require('ytsearcher'); +const ypi = require('youtube-playlist-info'); +const Discord = require('discord.js'); +const PACKAGE = require('./package.json'); + +/* + * Takes a discord.js client and turns it into a music bot. + * Extra thanks to Rodabaugh (Erik) for helping with some tweaks and ideas. + * + * @param {Client} client - The discord.js client. + * @param {object} options - Options to configure the client bot. + */ + +exports.start = (client, options) => { + class Music { + constructor(client, options) { + this.commands = new Map(); + this.aliases = new Map(); + this.youtubeKey = (options && options.youtubeKey); + this.botPrefix = (options && options.prefix) || '!'; + this.embedColor = (options && options.embedColor) || 'GREEN'; + this.thumbnailType = (options && options.thumbnailType) || "high"; + this.anyoneCanLeave = Boolean((options && options.anyoneCanLeave) || false); + this.global = (options && options.global) || false; + this.maxQueueSize = parseInt((options && options.maxQueueSize) || 100); + this.defVolume = parseInt((options && options.defVolume) || 50); + this.anyoneCanSkip = Boolean((options && options.anyoneCanSkip) || false); + this.clearInvoker = Boolean((options && options.clearInvoker) || false); + this.helpCmd = (options && options.helpCmd) || 'musichelp'; + this.disableHelp = Boolean((options && options.disableHelp) || false); + this.helpHelp = (options && options.helpHelp) || "Shows help for commands."; + this.helpAlt = (options && options.helpAlt) || []; + this.playCmd = (options && options.playCmd) || 'play'; + this.disablePlay = Boolean((options && options.disablePlay) || false); + this.playHelp = (options && options.playHelp) || "Queue a song/playlist by URL or search for a song."; + this.playAlt = (options && options.playAlt) || []; + this.skipCmd = (options && options.skipCmd) || 'skip'; + this.disableSkip = Boolean((options && options.disableSkip) || false); + this.skipHelp = (options && options.skipHelp) || "Skip a song or multi songs."; + this.skipAlt = (options && options.skipAlt) || []; + this.joinCmd = (options && options.joinCmd) || 'join'; + this.disableJoin = Boolean((options && options.disableJoin) || false); + this.joinHelp = (options && options.joinHelp) || "Join your current voice channel."; + this.joinAlt = (options && options.joinAlt) || []; + this.queueCmd = (options && options.queueCmd) || 'queue'; + this.disableQueue = Boolean((options && options.disableQueue) || false); + this.queueHelp = (options && options.queueHelp) || "Shows the current queue."; + this.queueAlt = (options && options.queueAlt) || []; + this.pauseCmd = (options && options.pauseCmd) || 'pause'; + this.pauseHelp = (options && options.pauseHelp) || "Pauses the queue."; + this.disablePause = Boolean((options && options.disablePause) || false); + this.pauseAlt = (options && options.pauseAlt) || []; + this.resumeCmd = (options && options.resumeCmd) || 'resume'; + this.disableResume = Boolean((options && options.disableResume) || false); + this.resumeHelp = (options && options.resumeHelp) || "Resume the queue."; + this.resumeAlt = (options && options.resumeAlt) || []; + this.volumeCmd = (options && options.volumeCmd) || 'volume'; + this.disableVolume = Boolean((options && options.disableVolume) || false); + this.volumeHelp = (options && options.volumeHelp) || "Adjusts the volume of the bot."; + this.volumeAlt = (options && options.volumeAlt) || []; + this.leaveCmd = (options && options.leaveCmd) || 'leave'; + this.disableLeave = Boolean((options && options.disableLeave) || false); + this.leaveHelp = (options && options.leaveHelp) || "Leave and clear the queue."; + this.leaveAlt = (options && options.leaveAlt) || []; + this.clearCmd = (options && options.clearCmd) || 'clearqueue'; + this.disableClear = Boolean((options && options.disableClear) || false); + this.clearHelp = (options && options.clearHelp) || "Clears the current queue."; + this.clearAlt = (options && options.clearAlt) || []; + this.searchCmd = (options && options.searchCmd) || 'search'; + this.disableSearch = Boolean((options && options.disableSearch) || false); + this.searchHelp = (options && options.searchHelp) || "Searchs for up to 10 results."; + this.searchAlt = (options && options.searchAlt) || []; + this.loopCmd = (options && options.loopCmd) || 'loop'; + this.disableLoop = Boolean((options && options.disableLoop) || false); + this.loopHelp = (options && options.loopHelp) || "Changes the loop state."; + this.loopAlt = (options && options.loopAlt) || []; + this.setCmd = (options && options.setCmd) || 'set'; + this.disableSet = Boolean((options && options.disableSet) || false); + this.setHelp = (options && options.setHelp) || "Changes settings for the server. Use without specifing a setting to see valid settings."; + this.setAlt = (options && options.setAlt) || []; + this.ownerCmd = (options && options.ownerCmd) || 'owner'; + this.disableOwnerCmd = Boolean((options && options.disableOwnerCmd) || false); + this.ownerHelp = (options && options.ownerHelp) || "Owner commands and functions."; + this.ownerAlt = (options && options.ownerAlt) || []; + this.npCmd = (options && options.npCmd) || 'np'; + this.disableNp = Boolean((options && options.disableNp) || false); + this.npHelp = (options && options.npHelp) || "Shows the currently playing song."; + this.npAlt = (options && options.npAlt) || []; + this.enableQueueStat = Boolean((options && options.enableQueueStat) || false); + this.anyoneCanAdjust = Boolean((options && options.anyoneCanAdjust) || false); + this.ownerOverMember = Boolean((options && options.ownerOverMember) || false); + this.botOwner = (options && options.botOwner) || null; + this.logging = Boolean((options && options.logging) || false); + this.enableAliveMessage = Boolean((options && options.enableAliveMessage) || false); + this.aliveMessage = (options && options.aliveMessage) || ""; + this.aliveMessageTime = parseInt((options && options.aliveMessageTime) || 600000); + this.requesterName = Boolean((options && options.requesterName) || false); + this.inlineEmbeds = Boolean((options && options.inlineEmbeds) || false); + this.maxWait = parseInt((options && options.maxWait) || 15000); + this.anyoneCanPause = Boolean((options && options.anyoneCanPause) || true); + this.dateLocal = (options && options.dateLocal) || 'en-US'; + this.clearOnLeave = (options && options.clearOnLeave) || false; + this.checkQueues = (options && options.checkQueues) || false; + this.queues = new Map(); + this.botPrefixs = new Map(); + this.advancedMode = (options && options.advancedMode) || {}; + this.botAdmins = (options && options.botAdmins) || []; + } + + logger(cmd, msg, text) { + console.log(`[${cmd}] [${msg.guild.name}] ${text}`); + } + } + + var musicbot = new Music(client, options); + exports.bot = musicbot; + + if (musicbot.advancedMode && musicbot.advancedMode.enabled) { + musicbot.advancedMode = { + enabled: Boolean((options && options.advancedMode.enabled) || false), + multiPrefix: Boolean((options && options.advancedMode.multiPrefix) || false), + serverPrefixs: (options && options.advancedMode.serverPrefixs) || {} + }; + }; + + async function musicBotStart() { + if (process.version.slice(1) + .split('.')[0] < 8) { + console.error(new Error(`[MusicBot] node 8 or higher is needed, please update`)); + process.exit(1); + } + + if (musicbot.disableLeave && + musicbot.disableSkip && + musicbot.disablePlay && + musicbot.disableQueue && + musicbot.disableHelp && + musicbot.disableResume && + musicbot.disablePause && + musicbot.disableLoop && + musicbot.disableClear && + musicbot.disableNp && + musicbot.disableSearch && + musicbot.disableVolume) { + console.error(new Error(`all commands disabled`)); + process.exit(1); + } + + if (typeof musicbot.embedColor !== 'object' && typeof musicbot.embedColor !== 'number' && typeof musicbot.embedColor !== 'string') { + console.error(new TypeError(`embedColor must be an object (array), number, or a string`)); + process.exit(1); + } + + if (typeof musicbot.botAdmins !== 'object') { + console.error(new TypeError(`botAdmins must be an object (array)`)); + process.exit(1); + } + if (typeof musicbot.clearOnLeave !== 'boolean') { + console.error(new TypeError(`clearOnLeave must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.checkQueues !== 'boolean') { + console.error(new TypeError(`checkQueues must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.dateLocal !== 'string') { + console.error(new TypeError(`dateLocal must be a string`)); + process.exit(1); + } + if (typeof musicbot.advancedMode !== 'object') { + console.error(new TypeError(`advancedMode must be an object`)); + process.exit(1); + } + if (musicbot.advancedMode.enabled && typeof musicbot.advancedMode.enabled !== 'boolean') { + console.error(new TypeError(`advancedMode.enabled must be a boolean`)); + process.exit(1); + } + if (musicbot.advancedMode.multiPrefix && typeof musicbot.advancedMode.multiPrefix !== 'boolean') { + console.error(new TypeError(`advancedMode.multiPrefix must be a boolean`)); + process.exit(1); + } + if (musicbot.advancedMode.serverPrefixs && typeof musicbot.advancedMode.serverPrefixs !== 'object') { + console.error(new TypeError(`advancedMode.serverPrefixs must be an object`)); + process.exit(1); + } + + if (typeof musicbot.thumbnailType !== 'string') { + console.error(new TypeError(`thumbnailType must be a string`)); + process.exit(1); + }; + if (!musicbot.thumbnailType.match(/default|medium|high/)) { + console.error(new Error(`thumbnailType must be one of the following: default, medium, high`)); + process.exit(1); + }; + if (typeof musicbot.helpHelp !== 'string') { + console.error(new TypeError(`helpHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.helpAlt !== 'object') { + console.error(new TypeError(`helpAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.playHelp !== 'string') { + console.error(new TypeError(`playHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.playAlt !== 'object') { + console.error(new TypeError(`playAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.queueHelp !== 'string') { + console.error(new TypeError(`queueHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.queueAlt !== 'object') { + console.error(new TypeError(`queueAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.pauseHelp !== 'string') { + console.error(new TypeError(`pauseHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.pauseAlt !== 'object') { + console.error(new TypeError(`pauseAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.resumeHelp !== 'string') { + console.error(new TypeError(`resumeHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.resumeAlt !== 'object') { + console.error(new TypeError(`resumeAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.volumeHelp !== 'string') { + console.error(new TypeError(`volumeHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.volumeAlt !== 'object') { + console.error(new TypeError(`volumeAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.leaveHelp !== 'string') { + console.error(new TypeError(`leaveHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.leaveAlt !== 'object') { + console.error(new TypeError(`leaveAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.clearHelp !== 'string') { + console.error(new TypeError(`clearHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.clearAlt !== 'object') { + console.error(new TypeError(`clearAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.loopHelp !== 'string') { + console.error(new TypeError(`loopHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.loopAlt !== 'object') { + console.error(new TypeError(`loopAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.npHelp !== 'string') { + console.error(new TypeError(`npHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.npAlt !== 'object') { + console.error(new TypeError(`npAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.ownerHelp !== 'string') { + console.error(new TypeError(`ownerHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.ownerAlt !== 'object') { + console.error(new TypeError(`ownerAlt must be an array`)); + process.exit(1); + }; + if (typeof musicbot.skipHelp !== 'string') { + console.error(new TypeError(`skipHelp must be a string`)) + process.exit(1); + }; + if (typeof musicbot.skipAlt !== 'object') { + console.error(new TypeError(`skipAlt must be an array`)); + process.exit(1); + }; + if (!musicbot.youtubeKey) { + console.error(new Error(`youtubeKey is required but missing`)); + process.exit(1); + }; + if (musicbot.youtubeKey && typeof musicbot.youtubeKey !== 'string') { + console.error(new TypeError(`youtubeKey must be a string`)); + process.exit(1); + }; + if (typeof musicbot.disableHelp !== 'boolean') { + console.error(new TypeError(`disableHelp must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disablePlay !== 'boolean') { + console.error(new TypeError(`disablePlay must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disableSkip !== 'boolean') { + console.error(new TypeError(`disableSkip must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disableQueue !== 'boolean') { + console.error(new TypeError(`disableQueue must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disablePause !== 'boolean') { + console.error(new TypeError(`disablePause must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disableResume !== 'boolean') { + console.error(new TypeError(`disableResume must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disableLeave !== 'boolean') { + console.error(new TypeError(`disableLeave must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disableClear !== 'boolean') { + console.error(new TypeError(`disableClear must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disableLoop !== 'boolean') { + console.error(new TypeError(`disableLoop must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disableNp !== 'boolean') { + console.error(new TypeError(`disableNp must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.disableOwnerCmd !== 'boolean') { + console.error(new TypeError(`disableOwnerCmd must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.ownerCmd !== 'string') { + console.error(new TypeError(`ownerCmd must be a string`)); + process.exit(1); + } + if (typeof musicbot.ownerOverMember !== 'boolean') { + console.error(new TypeError(`ownerOverMember must be a boolean`)); + process.exit(1); + }; + if (musicbot.ownerOverMember && typeof musicbot.botOwner !== 'string') { + console.error(new TypeError(`botOwner must be a string`)); + process.exit(1); + }; + if (typeof musicbot.botPrefix !== 'string') { + console.error(new TypeError(`prefix must be a string`)); + process.exit(1); + }; + if (musicbot.botPrefix.length < 1 || musicbot.botPrefix.length > 10) { + console.error(new RangeError(`prefix length must be between 1 and 10`)); + process.exit(1); + }; + if (typeof musicbot.global !== 'boolean') { + console.error(new TypeError(`global must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.maxQueueSize !== 'number') { + console.error(new TypeError(`maxQueueSize must be a number`)); + process.exit(1); + }; + if (!Number.isInteger(musicbot.maxQueueSize)) { + console.error(new TypeError(`maxQueueSize must be an integer`)); + process.exit(1); + }; + if (typeof musicbot.defVolume !== 'number') { + console.error(new TypeError(`defaultVolume must be a number`)); + process.exit(1); + }; + if (!Number.isInteger(musicbot.defVolume) || musicbot.defVolume < 1 || musicbot.defVolume > 200) { + console.error(new TypeError(`defaultVolume must be an integer between 1 and 200`)); + process.exit(1); + }; + if (typeof musicbot.anyoneCanSkip !== 'boolean') { + console.error(new TypeError(`anyoneCanSkip must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.clearInvoker !== 'boolean') { + console.error(new TypeError(`clearInvoker must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.enableAliveMessage !== 'boolean') { + console.error(new TypeError(`enableAliveMessage must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.aliveMessage !== 'string') { + console.error(new TypeError(`aliveMessage must be a string`)); + process.exit(1); + }; + if (typeof musicbot.aliveMessageTime !== 'number') { + console.error(new TypeError(`aliveMessageTime must be a number`)); + process.exit(1); + }; + if (typeof musicbot.helpCmd !== 'string') { + console.error(new TypeError(`helpCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.playCmd !== 'string') { + console.error(new TypeError(`playCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.searchCmd !== 'string') { + console.error(new TypeError(`searchCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.disableSearch !== 'boolean') { + console.error(new TypeError(`disableSearch must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.skipCmd !== 'string') { + console.error(new TypeError(`skipCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.queueCmd !== 'string') { + console.error(new TypeError(`queueCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.pauseCmd !== 'string') { + console.error(new TypeError(`pauseCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.npCmd !== 'string') { + console.error(new TypeError(`npCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.resumeCmd !== 'string') { + console.error(new TypeError(`resumeCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.volumeCmd !== 'string') { + console.error(new TypeError(`volumeCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.leaveCmd !== 'string') { + console.error(new TypeError(`leaveCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.clearCmd !== 'string') { + console.error(new TypeError(`clearCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.loopCmd !== 'string') { + console.error(new TypeError(`loopCmd must be a string`)); + process.exit(1); + }; + if (typeof musicbot.enableQueueStat !== 'boolean') { + console.error(new TypeError(`enableQueueStat must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.anyoneCanAdjust !== 'boolean') { + console.error(new TypeError(`anyoneCanAdjust must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.logging !== 'boolean') { + console.error(new TypeError(`logging must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.requesterName !== 'boolean') { + console.error(new TypeError(`requesterName must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.inlineEmbeds !== 'boolean') { + console.error(new TypeError(`inlineEmbeds must be a boolean`)); + process.exit(1); + }; + if (typeof musicbot.joinCmd !== "string") { + console.error(new TypeError(`joinCmd must be a string`)); + process.exit(1); + } + if (typeof musicbot.disableJoin !== "boolean") { + console.error(new TypeError(`disableJoin must be a boolean`)); + process.exit(1); + } + if (typeof musicbot.joinAlt !== "object") { + console.error(new TypeError(`joinAlt must be an object (array)`)); + process.exit(1); + } + if (typeof musicbot.joinHelp !== "string") { + console.error(new TypeError(`joinHelp must be a string`)); + process.exit(1); + } + if (musicbot.global && musicbot.maxQueueSize < 50) console.warn(`global queues are enabled while maxQueueSize is below 50! Recommended to use a higher size.`); + + // Set those commands, baby. + try { + if (!musicbot.commands.has(musicbot.helpCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.helpCmd} command.`); + const help_props = { + name: musicbot.helpCmd, + usage: `${musicbot.botPrefix}${musicbot.helpCmd} [command]`, + disabled: musicbot.disableHelp, + help: musicbot.helpHelp, + aliases: musicbot.helpAlt, + admin: false, + run: "musichelp" + }; + musicbot.commands.set(musicbot.helpCmd, help_props); + + if (musicbot.helpAlt.length > 0) { + musicbot.helpAlt.forEach(alt => { + musicbot.aliases.set(alt, help_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.searchCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.searchCmd} command.`); + const search_props = { + name: musicbot.searchCmd, + usage: `${musicbot.botPrefix}${musicbot.searchCmd} `, + disabled: musicbot.disableSearch, + help: musicbot.searchHelp, + aliases: musicbot.searchAlt, + admin: false, + run: "search" + }; + musicbot.commands.set(musicbot.searchCmd, search_props); + + if (musicbot.searchAlt.length > 0) { + musicbot.searchAlt.forEach(alt => { + musicbot.aliases.set(alt, search_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.playCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.playCmd} command.`); + const play_props = { + name: musicbot.playCmd, + usage: `${musicbot.botPrefix}${musicbot.playCmd} `, + disabled: musicbot.disablePlay, + help: musicbot.playHelp, + aliases: musicbot.playAlt, + admin: false, + run: "play" + }; + musicbot.commands.set(musicbot.playCmd, play_props); + + if (musicbot.playAlt.length > 0) { + musicbot.playAlt.forEach(alt => { + musicbot.aliases.set(alt, play_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.skipCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.skipCmd} command.`); + const skip_props = { + name: musicbot.skipCmd, + usage: `${musicbot.botPrefix}${musicbot.skipCmd} [numberOfSongs]`, + disabled: musicbot.disableSkip, + help: musicbot.skipHelp, + aliases: musicbot.skipAlt, + admin: true, + run: "skip" + }; + musicbot.commands.set(musicbot.skipCmd, skip_props); + + if (musicbot.skipAlt.length > 0) { + musicbot.skipAlt.forEach(alt => { + musicbot.aliases.set(alt, skip_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.queueCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.queueCmd} command.`); + const queue_props = { + name: musicbot.queueCmd, + usage: `${musicbot.botPrefix}${musicbot.queueCmd} [songNumber]`, + disabled: musicbot.disableQueue, + help: musicbot.queueHelp, + aliases: musicbot.queueAlt, + admin: false, + run: "queue" + }; + musicbot.commands.set(musicbot.queueCmd, queue_props); + + if (musicbot.queueAlt.length > 0) { + musicbot.queueAlt.forEach(alt => { + musicbot.aliases.set(alt, queue_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.pauseCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.pauseCmd} command.`); + const pause_props = { + name: musicbot.pauseCmd, + usage: null, + disabled: musicbot.disablePause, + help: musicbot.pauseHelp, + aliases: musicbot.pauseAlt, + admin: false, + run: "pause" + }; + musicbot.commands.set(musicbot.pauseCmd, pause_props); + + if (musicbot.pauseAlt.length > 0) { + musicbot.pauseAlt.forEach(alt => { + musicbot.aliases.set(alt, pause_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.resumeCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.resumeCmd} command.`); + const resume_props = { + name: musicbot.resumeCmd, + usage: null, + disabled: musicbot.disableResume, + help: musicbot.resumeHelp, + aliases: musicbot.resumeAlt, + admin: false, + run: "resume" + }; + musicbot.commands.set(musicbot.resumeCmd, resume_props); + + if (musicbot.resumeAlt.length > 0) { + musicbot.resumeAlt.forEach(alt => { + musicbot.aliases.set(alt, resume_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.volumeCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.volumeCmd} command.`); + const volume_props = { + name: musicbot.volumeCmd, + usage: `${musicbot.botPrefix}${musicbot.volumeCmd} <1 - 200>`, + disabled: musicbot.disableVolume, + help: musicbot.volumeHelp, + aliases: musicbot.volumeAlt, + admin: false, + run: "volume" + }; + musicbot.commands.set(musicbot.volumeCmd, volume_props); + + if (musicbot.volumeAlt.length > 0) { + musicbot.volumeAlt.forEach(alt => { + musicbot.aliases.set(alt, volume_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.clearCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.clearCmd} command.`); + const clear_props = { + name: musicbot.clearCmd, + usage: null, + disabled: musicbot.disableClear, + help: musicbot.clearHelp, + aliases: musicbot.clearAlt, + admin: false, + run: "clearqueue" + }; + musicbot.commands.set(musicbot.clearCmd, clear_props); + + if (musicbot.clearAlt.length > 0) { + musicbot.clearAlt.forEach(alt => { + musicbot.aliases.set(alt, clear_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.npCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.npCmd} command.`); + const np_props = { + name: musicbot.npCmd, + usage: null, + disabled: musicbot.disableNp, + help: musicbot.npHelp, + aliases: musicbot.npAlt, + admin: false, + run: "np" + }; + musicbot.commands.set(musicbot.npCmd, np_props); + + if (musicbot.npAlt.length > 0) { + musicbot.npAlt.forEach(alt => { + musicbot.aliases.set(alt, np_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.leaveCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.leaveCmd} command.`); + const leave_props = { + name: musicbot.leaveCmd, + usage: null, + disabled: musicbot.disableLeave, + help: musicbot.leaveHelp, + aliases: musicbot.leaveAlt, + admin: false, + run: "leave" + }; + musicbot.commands.set(musicbot.leaveCmd, leave_props); + + if (musicbot.leaveAlt.length > 0) { + musicbot.leaveAlt.forEach(alt => { + musicbot.aliases.set(alt, leave_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.loopCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.loopCmd} command.`); + const loop_props = { + name: musicbot.loopCmd, + usage: null, + disabled: musicbot.disableLoop, + help: musicbot.loopHelp, + aliases: musicbot.loopAlt, + admin: false, + run: "loop" + }; + musicbot.commands.set(musicbot.loopCmd, loop_props); + + if (musicbot.loopAlt.length > 0) { + musicbot.loopAlt.forEach(alt => { + musicbot.aliases.set(alt, loop_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.setCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.setCmd} command.`); + const set_props = { + name: musicbot.setCmd, + usage: `${musicbot.botPrefix}${musicbot.setCmd} `, + disabled: musicbot.disableSet, + help: musicbot.setHelp, + aliases: musicbot.setAlt, + admin: false, + run: "set" + }; + musicbot.commands.set(musicbot.setCmd, set_props); + + if (musicbot.setAlt.length > 0) { + musicbot.setAlt.forEach(alt => { + musicbot.aliases.set(alt, set_props); + }); + }; + + }; + if (!musicbot.commands.has(musicbot.joinCmd)) { + if (musicbot.logging) console.log(`[MUSIC] Mapping ${musicbot.joinCmd} command.`); + const join_props = { + name: musicbot.joinCmd, + usage: `${musicbot.botPrefix}${musicbot.joinCmd}`, + disabled: musicbot.disableJoin, + help: musicbot.joinHelp, + aliases: musicbot.joinAlt, + admin: false, + run: "join" + }; + musicbot.commands.set(musicbot.joinCmd, join_props); + + if (musicbot.joinAlt.length > 0) { + musicbot.setAlt.forEach(alt => { + musicbot.aliases.set(alt, join_props); + }); + }; + + }; + } catch (e) { + console.error(e.stack); + process.exit(1); + }; + }; + musicBotStart(); + + //Set the YouTube API key. + musicbot.searcher = new YTSearcher({ + key: musicbot.youtubeKey, + revealkey: true + }); + + exports.changeKey = (key) => { + return new Promise((resolve, reject) => { + if (!key || typeof key !== "string") reject("invalid key provided"); + musicbot.youtubeKey = key; + musicbot.searcher = new YTSearcher({ + key: key, + revealkey: true + }); + resolve(musicbot); + }); + }; + + // Catch message events. + client.on('message', msg => { + const message = msg.content.trim(); + + if (musicbot.advancedMode.enabled && musicbot.advancedMode.multiPrefix) { + if (musicbot.botPrefixs.has(msg.guild.id)) { + // Get the custom prefix. + const prefix = musicbot.botPrefixs.get(msg.guild.id) + .prefix; + if (!message.startsWith(prefix)) return; + + // Get the command, suffix. + const command = message.substring(prefix.toString() + .length) + .split(/[ \n]/)[0].trim(); + const suffix = message.substring(prefix.toString() + .length + command.length) + .trim(); + const args = message.slice(prefix.toString() + .length + command.length) + .trim() + .split(/ +/g); + + // Process the commands. + if (musicbot.commands.has(command)) { + let tCmd = musicbot.commands.get(command); + if (!tCmd.disabled) return musicbot[tCmd.run](msg, suffix, args); + } else if (musicbot.aliases.has(command)) { + let aCmd = musicbot.aliases.get(command); + if (!aCmd.disabled) return musicbot[aCmd.run](msg, suffix, args); + }; + } else if (message.startsWith(musicbot.botPrefix)) { + // Get the command, suffix. + const command = message.substring(musicbot.botPrefix.length) + .split(/[ \n]/)[0].trim(); + const suffix = message.substring(musicbot.botPrefix.length + command.length) + .trim(); + const args = message.slice(musicbot.botPrefix.length + command.length) + .trim() + .split(/ +/g); + + // Process the commands. + if (musicbot.commands.has(command)) { + let tCmd = musicbot.commands.get(command); + if (!tCmd.disabled) return musicbot[tCmd.run](msg, suffix, args); + } else if (musicbot.aliases.has(command)) { + let aCmd = musicbot.aliases.get(command); + if (!aCmd.disabled) return musicbot[aCmd.run](msg, suffix, args); + }; + }; + } else if (message.startsWith(musicbot.botPrefix)) { + // Get the command, suffix. + const command = message.substring(musicbot.botPrefix.length) + .split(/[ \n]/)[0].trim(); + const suffix = message.substring(musicbot.botPrefix.length + command.length) + .trim(); + const args = message.slice(musicbot.botPrefix.length + command.length) + .trim() + .split(/ +/g); + + // Process the commands. + if (musicbot.commands.has(command)) { + let tCmd = musicbot.commands.get(command); + if (!tCmd.disabled) return musicbot[tCmd.run](msg, suffix, args); + } else if (musicbot.aliases.has(command)) { + let aCmd = musicbot.aliases.get(command); + if (!aCmd.disabled) return musicbot[aCmd.run](msg, suffix, args); + }; + }; + }); + + // Client ready event for some extra stuff. + client.on("ready", () => { + + if (musicbot.advancedMode && musicbot.advancedMode.enabled === true) { + if (musicbot.advancedMode && musicbot.advancedMode.multiPrefix === true) { + if (typeof musicbot.advancedMode.serverPrefixs === 'object') { + client.guilds.forEach(server => { + if (musicbot.advancedMode.serverPrefixs.has(server.id)) { + var thisServer = musicbot.advancedMode.serverPrefixs.get(server.id) + let props = { + id: server.id, + prefix: thisServer.prefix + }; + musicbot.botPrefixs.set(server.id, props); + } else { + let props = { + id: server.id, + prefix: musicbot.botPrefix + }; + musicbot.botPrefixs.set(server.id, props); + }; + }); + }; + }; + }; + + if (musicbot.enableAliveMessage) { + setInterval(function liveMessage() { + if (musicbot.aliveMessage.length < 3) { + musicbot.aliveMessage = `----------------------------------\n${client.user.username} online since ${client.readyAt}!\n----------------------------------`; + } else { + musicbot.aliveMessage = musicbot.aliveMessage.replace(/{{username}}/g, `${client.user.username}`) + .replace(/{{starttime}}/g, `${client.readyAt}`); + } + console.log(musicbot.aliveMessage); + }, musicbot.aliveMessageTime); + }; + console.log(`------- ${client.user.username} -------\n> Version: ${PACKAGE.version}\n> Extra Logging: ${musicbot.logging}.\n> Using Global Queue: ${musicbot.global}.\n> Node.js Version: ${process.version}\n------- ${client.user.username} -------`); + if (!musicbot.enableQueueStat) console.log(`[MUSIC] enableQueueStat is 'false'. Queue will not have a Playing/Paused indicator.`); + + if (musicbot.checkQueues == true) { + console.warn(`[MUSIC] checkQueues is enabled.`); + + musicbot.verify = (q) => { + return new Promise((resolve, reject) => { + if (!q) reject(0); + else if (q && q.songs == null) reject(1); + else if (q && q.songs.length > musicbot.maxQueueSize && musicbot.maxQueueSize !== 0) reject(1); + else if (q && q.songs.length < 0) reject(1); + else if (q && typeof q.loop !== "string") reject(2); + else if (q && !q.id) reject(3); + + q.songs.forEach(song => { + if (!song.title || !song.url || !song.queuedOn || !song.requester) reject(4); + }) + + resolve("pass"); + }); + }; + exports.verifyQueue = musicbot.verify; + setInterval(() => { + + musicbot.queues.forEach(queue => { + musicbot.verify(queue).then((res) => { + if (musicbot.logging) console.log(`[Check Queues Music] Queue ${queue.id} passed verification.`); + }).catch((res) => { + if (res >= 0) { + let prop = { + songs: [], + last: null, + loop: "none", + id: `${queue.toString()}` + }; + musicbot.queues.set(queue.id, prop) + }; + + try { + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == `${queue.toString()}`); + if (voiceConnection !== null) { + voiceConnection.player.dispatcher.end(); + voiceConnection.disconnect(); + }; + } catch (e) { + console.error(e); + }; + }) + }) + }, 3600000) + } + }); + + musicbot.updatePrefix = (server, prefix) => { + if (musicbot && musicbot.advancedMode.enabled && musicbot.advancedMode.multiPrefix) { + return new Promise((resolve, reject) => { + if (typeof server !== 'string') reject(`server was not a string`); + if (typeof prefix !== 'string') reject(`prefix was not a string`); + + let props; + if (musicbot.botPrefixs.has(server)) { + props = musicbot.botPrefixs.get(server); + props.prefix = prefix; + musicbot.botPrefixs.set(server, props); + resolve(`Prefix updated to \`${prefix}\`!`); + } else { + let props = { + id: server, + prefix: prefix + }; + musicbot.botPrefixs.set(server, props); + resolve(`Prefix updated to \`${prefix}\`!`); + } + }) + }; + }; + exports.updatePrefix = musicbot.updatePrefix; + + /** + * Checks if a user is an admin. + * + * @param {GuildMember} member - The guild member + * @returns {boolean} - If the user is admin. + */ + musicbot.isAdmin = (member) => { + if (musicbot.ownerOverMember && member.id === musicbot.botOwner) return true; + if (musicbot.botAdmins.includes(member.id)) return true; + return member.hasPermission("ADMINISTRATOR"); + }; + + /** + * Checks if the user can skip the song. + * + * @param {GuildMember} member - The guild member + * @param {array} queue - The current queue + * @returns {boolean} - If the user can skip + */ + musicbot.canSkip = (member, queue) => { + if (musicbot.anyoneCanSkip) return true; + else if (musicbot.botAdmins.includes(member.id)) return true; + else if (musicbot.ownerOverMember && member.id === musicbot.botOwner) return true; + else if (queue[0].requester === member.id) return true; + else if (musicbot.isAdmin(member)) return true; + else return false; + }; + + /** + * Checks if the user can adjust volume. + * + * @param {GuildMember} member - The guild member + * @param {array} queue - The current queue + * @returns {boolean} - If the user can adjust + */ + musicbot.canAdjust = (member, queue) => { + if (musicbot.anyoneCanAdjust) return true; + else if (musicbot.botAdmins.includes(member.id)) return true; + else if (musicbot.ownerOverMember && member.id === musicbot.botOwner) return true; + else if (queue[0].requester === member.id) return true; + else if (musicbot.isAdmin(member)) return true; + else return false; + }; + + /** + * Deletes the command message if invoker is on. + * + * @param {Message} msg - the message of the command. + */ + musicbot.dInvoker = (msg) => { + if (musicbot.clearInvoker) { + if (!msg) return; + msg.delete(); + } + }; + + /** + * Gets the song queue of the server. + * + * @param {string} server - The server id. + * @param {boolean} state - Whether or not to just return songs. + * @returns {object} - The song queue. + */ + musicbot.getQueue = (server, state) => { + // Check if global queues are enabled. + if (musicbot.global) server = '_'; // Change to global queue. + + if (!musicbot.queues.has(server)) { // Event if no queue is found. + // The new queue object/data. + let q = { + songs: [], + last: null, + loop: "none", + id: server + }; + musicbot.queues.set(server, q); // Set the data. + }; + + if (state == true) return musicbot.queues.get(server).songs; // Return the queue songs. + else if (!state || state == false) return musicbot.queues.get(server); // Return the queue. + }; + + /** + * Sets the last played song of the server. + * + * @param {string} server - The server id. + * @param {object} last - Video to be set for last. + * @returns {Promise} - Returns the queue once last is set. + */ + musicbot.setLast = (server, last) => { + return new Promise((resolve, reject) => { + // if (musicbot.global) reject("Global Enabled"); + let q; + + if (musicbot.queues.has(server)) { // Check if a queue exists. + q = musicbot.queues.get(server); // Fetch queue. + q.last = last; // Set last. + musicbot.queues.set(server, q); // Set new queue data. + resolve(musicbot.queues.get(server)); // Resolve the queue. + } else { + reject("no server queue"); // Reject if no queue is found. + }; + }); + }; + + /** + * Gets the last played song of the server. + * + * @param {integer} server - The server id. + * @returns {Promise} - Retunrs the queues last. + */ + musicbot.getLast = (server) => { + return new Promise((resolve, reject) => { + // if (musicbot.global) reject("Global Enabled"); + let q = musicbot.queues.has(server) ? musicbot.queues.get(server).last : null; // Fetch/check for queue last. + if (!q || !q.last) resolve(null) // Resolve null if no queue or no last. + else if (q.last) resolve(q.last); // Resolve the 'last' object. + }); + }; + + /** + * Verifies if the queue is empty or not. + * + * @param {object} queue - Queue to check if empty. + * @returns {Promise} - If empty or not. + */ + musicbot.isQueueEmpty = (queue) => { + return new Promise((resolve, reject) => { + if (!queue) reject("no queue passed"); // Reject if no queue passed. + + // Check if it's songs passed, instead of an entire queue. + // If it equals and object (array), check for length instead of songs. + if (typeof queue == "object") { + if (queue.length > 0) resolve(false) + else if (queue.length <= 0) resolve(true); + } else { + if (queue && queue.songs) { // Check songs in an entire queue object. + if (queue.songs.length > 0) resolve(false) // Resolve false for a queue with songs. + else if (queue.songs.length <= 0) resolve(true); // Resolve true for an empty queue. + } else { + reject("no queue/songs found"); + }; + }; + + }); + }; + exports.isQueueEmpty = musicbot.isQueueEmpty; + + /** + * Makes a servers queue and related data empty. + * + * @param {string} server - Server id. + * @returns {Promise} - Retruns queue or error. + */ + musicbot.emptyQueue = (server) => { + return new Promise((resolve, reject) => { + let q = musicbot.queues.has(server) ? musicbot.queues.get(server) : null; // Fetch/check for queue. + if (!q) reject(new Error(`[emptyQueue] no queue found for ${server}`)); // Error if there's no queue. + + // Blank queue object. + let blank = { + songs: [], + last: null, + loop: "none", + id: server + }; + + musicbot.queues.set(server, blank); // Set the queue data to the blank object. + + resolve(musicbot.queues.get(server)); // Resolve once done. + }); + }; + + /** + * The help command. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + */ + musicbot.musichelp = (msg, suffix) => { + musicbot.dInvoker(msg); + let command = suffix.trim(); + if (!suffix) { + if (msg.channel.permissionsFor(msg.guild.me) + .has('EMBED_LINKS')) { + const embed = new Discord.RichEmbed(); + embed.setAuthor("Commands", msg.author.displayAvatarURL); + embed.setDescription(`Use \`${musicbot.botPrefix}${musicbot.helpCmd} command name\` for help on usage.`); + // embed.addField(musicbot.helpCmd, musicbot.helpHelp); + const newCmds = Array.from(musicbot.commands); + for (var i = 0; i < newCmds.length; i++) { + let thisCmd = newCmds[i][1]; + if (!thisCmd.disabled) { + embed.addField(thisCmd.name, thisCmd.help); + }; + }; + embed.setColor(musicbot.embedColor); + setTimeout(() => { + if (musicbot.messageHelp) { + let sent = false; + msg.author.send({ + embed + }) + .then(() => { + sent = true; + }); + setTimeout(() => { + if (!sent) return msg.channel.send({ + embed + }); + }, 1200); + } else { + return msg.channel.send({ + embed + }); + }; + }, 1500); + } else { + var cmdmsg = `= Music Commands =\nUse ${musicbot.botPrefix}${musicbot.helpCmd} [command] for help on a command.\n`; + const newCmds = Array.from(musicbot.commands); + for (var i = 0; i < newCmds.length; i++) { + let thisCmd = newCmds[i][1]; + if (!thisCmd.disabled) { + cmdmsg = cmdmsg + `\n• ${thisCmd.name}: ${thisCmd.help}`; + }; + }; + setTimeout(() => { + if (musicbot.messageHelp) { + let sent = false; + msg.author.send(cmdmsg, { + code: 'asciidoc' + }) + .then(() => { + sent = true; + }); + setTimeout(() => { + if (!sent) return msg.channel.send(cmdmsg, { + code: 'asciidoc' + }); + }, 500); + } else { + return msg.channel.send(cmdmsg, { + code: 'asciidoc' + }); + }; + }, 1500); + }; + } else if (musicbot.commands.has(command) || musicbot.aliases.has(command)) { + if (msg.channel.permissionsFor(msg.guild.me) + .has('EMBED_LINKS')) { + const embed = new Discord.RichEmbed(); + command = musicbot.commands.get(command) || musicbot.aliases.get(command); + embed.setAuthor(command.name, msg.client.user.avatarURL); + embed.setDescription(command.help); + if (command.aliases.length > 0) embed.addField(`Aliases`, command.aliases.join(", "), musicbot.inlineEmbeds); + if (command.usage !== null) embed.addField(`Usage`, command.usage, musicbot.inlineEmbeds); + embed.setColor(musicbot.embedColor); + msg.channel.send({ + embed + }); + } else { + command = musicbot.commands.get(command) || musicbot.aliases.get(command); + var cmdhelp = `= ${command.name} =\n`; + cmdhelp + `\n${command.help}`; + if (command.usage !== null) cmdhelp = cmdhelp + `\nUsage: ${command.usage}\n`; + if (command.aliases.length > 0) cmdhelp = cmdhelp + `\nAliases: ${command.aliases.join(", ")}`; + msg.channel.send(cmdhelp, { + code: 'asciidoc' + }); + }; + } else { + msg.channel.send(musicbot.note('fail', `${suffix} is not a valid command!`)); + }; + }; + + /** + * The command for adding a song to the queue. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + */ + musicbot.play = (msg, suffix) => { + musicbot.dInvoker(msg); + // Make sure the user is in a voice channel. + if (msg.member.voiceChannel === undefined) return msg.channel.send(musicbot.note('fail', `You're not in a voice channel.`)); + + // Make sure the suffix exists. + if (!suffix) return msg.channel.send(musicbot.note('fail', 'No video specified!')); + + // Get the queue. + const queue = musicbot.getQueue(msg.guild.id); + + // Check if the queue has reached its maximum size. + if (queue.songs.length >= musicbot.maxQueueSize && musicbot.maxQueueSize !== 0) return msg.channel.send(musicbot.note('fail', 'Maximum queue size reached!')); + + // Get the video information. + // I don't know why I use trim when I don't need to... Yeah. + var searchstring = suffix.trim(); + msg.channel.send(musicbot.note('search', `Searching: \`${searchstring}\``)) + .then(response => { + if (searchstring.startsWith('http') && searchstring.includes("list=")) { + var playid = searchstring.toString() + .split('list=')[1]; + if (playid.toString() + .includes('?')) playid = playid.split('?')[0]; + if (playid.toString() + .includes('&t=')) playid = playid.split('&t=')[0]; + + ypi.playlistInfo(musicbot.youtubeKey, playid, function(playlistItems) { + const newItems = Array.from(playlistItems); + var index = 0; + var ran = 0; + + newItems.forEach(video => { + ran++; + if (queue.songs.length == (musicbot.maxQueueSize + 1) && musicbot.maxQueueSize !== 0) return; + if (video.resourceId.kind == 'youtube#video') { + if (!video.url) video.url = `https://www.youtube.com/watch?v=` + video.resourceId.videoId; + video.requester = msg.author.id; + video.queuedOn = new Date().toLocaleDateString(musicbot.dateLocal, { weekday: 'long', hour: 'numeric' }); + if (musicbot.requesterName) video.requesterAvatarURL = msg.author.displayAvatarURL; + queue.songs.push(video); + if (queue.songs.length === 1) musicbot.executeQueue(msg, queue); + index++; + }; + if (ran == newItems.length) { + if (index = 0) msg.channel.send(musicbot.note('fail', `Coudln't get any songs from that playlist.`)) + else if (index == 1) msg.channel.send(musicbot.note('note', `Queued one song.`)); + else if (index > 1) msg.channel.send(musicbot.note('note', `Queued ${index} songs.`)); + } + }); + }); + } else { + musicbot.searcher.search(searchstring, { + type: 'video' + }) + .then(searchResult => { + if (!searchResult.totalResults || searchResult.totalResults === 0) return response.edit(musicbot.note('fail', 'Failed to get search results.')); + var result = searchResult.first; + result.requester = msg.author.id; + result.channelURL = `https://www.youtube.com/channel/${result.channelId}`; + result.queuedOn = new Date().toLocaleDateString(musicbot.dateLocal, { weekday: 'long', hour: 'numeric' }); + if (musicbot.requesterName) result.requesterAvatarURL = msg.author.displayAvatarURL; + queue.songs.push(result); + + if (queue.songs.length > 1) { + if (msg.channel.permissionsFor(msg.guild.me).has('EMBED_LINKS')) { + const embed = new Discord.RichEmbed(); + try { + embed.setAuthor('Adding To Queue', client.user.avatarURL); + var songTitle = result.title.replace(/\\/g, '\\\\') + .replace(/\`/g, '\\`') + .replace(/\*/g, '\\*') + .replace(/_/g, '\\_') + .replace(/~/g, '\\~') + .replace(/`/g, '\\`'); + embed.setColor(musicbot.embedColor); + embed.addField(result.channelTitle, `[${songTitle}](${result.url})`, musicbot.inlineEmbeds); + embed.addField("Queued On", result.queuedOn, musicbot.inlineEmbeds); + embed.setThumbnail(result.thumbnails.high.url); + const resMem = client.users.get(result.requester); + if (musicbot.requesterName && resMem) embed.setFooter(`Requested by ${client.users.get(result.requester).username}`, result.requesterAvatarURL); + if (musicbot.requesterName && !resMem) embed.setFooter(`Requested by \`UnknownUser (ID: ${result.requester})\``, result.requesterAvatarURL); + msg.channel.send({ + embed + }); + } catch (e) { + console.error(`[${msg.guild.name}] [npCmd] ` + e.stack); + }; + } else { + try { + var songTitle = result.title.replace(/\\/g, '\\\\') + .replace(/\`/g, '\\`') + .replace(/\*/g, '\\*') + .replace(/_/g, '\\_') + .replace(/~/g, '\\~') + .replace(/`/g, '\\`'); + msg.channel.send(`Now Playing: **${songTitle}**\nRequested By: ${client.users.get(result.requester).username}\nQueued On: ${result.queuedOn}`) + } catch (e) { + console.error(`[${msg.guild.name}] [npCmd] ` + e.stack); + }; + } + } + + if (queue.songs.length === 1 || !client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id)) musicbot.executeQueue(msg, queue); + }); + } + }) + .catch(console.log); + }; + + /** + * The command for adding a song to the queue. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + */ + musicbot.search = (msg, suffix) => { + musicbot.dInvoker(msg); + // Make sure the user is in a voice channel. + if (msg.member.voiceChannel === undefined) return msg.channel.send(musicbot.note('fail', `You're not in a voice channel~`)); + + // Make sure the suffix exists. + if (!suffix) return msg.channel.send(musicbot.note('fail', 'No video specified!')); + + // Get the queue. + const queue = musicbot.getQueue(msg.guild.id); + + // Check if the queue has reached its maximum size. + if (queue.songs.length >= musicbot.maxQueueSize && musicbot.maxQueueSize !== 0) return msg.channel.send(musicbot.note('fail', 'Maximum queue size reached!')); + + // Get the video information. + // This is pretty much just play but 10 results to queue. + var searchstring = suffix.trim(); + msg.channel.send(musicbot.note('search', `Searching: \`${searchstring}\``)) + .then(response => { + musicbot.searcher.search(searchstring, { + type: 'video' + }) + .then(searchResult => { + if (!searchResult.totalResults || searchResult.totalResults === 0) return response.edit(musicbot.note('fail', 'Failed to get search results.')); + + const startTheFun = async (videos, max) => { + // if (msg.channel.permissionsFor(msg.guild.me).has('EMBED_LINKS')) { + // + // } else { + // + // } + const embed = new Discord.RichEmbed(); + embed.setTitle(`Choose Your Video`); + embed.setColor(musicbot.embedColor); + var index = 0; + videos.forEach(function(video) { + index++; + embed.addField(`${index} (${video.channelTitle})`, `[${musicbot.note('font', video.title)}](${video.url})`, musicbot.inlineEmbeds); + }); + embed.setFooter(`Search by: ${msg.author.username}`, msg.author.displayAvatarURL); + msg.channel.send({ + embed + }) + .then(firstMsg => { + var filter = null; + if (max === 0) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.trim() === (`cancel`); + } else if (max === 1) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.trim() === (`cancel`); + } else if (max === 2) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.includes('3') || + m.content.trim() === (`cancel`); + } else if (max === 3) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.includes('3') || + m.content.includes('4') || + m.content.trim() === (`cancel`); + } else if (max === 4) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.includes('3') || + m.content.includes('4') || + m.content.includes('5') || + m.content.trim() === (`cancel`); + } else if (max === 5) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.includes('3') || + m.content.includes('4') || + m.content.includes('5') || + m.content.includes('6') || + m.content.trim() === (`cancel`); + } else if (max === 6) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.includes('3') || + m.content.includes('4') || + m.content.includes('5') || + m.content.includes('6') || + m.content.includes('7') || + m.content.trim() === (`cancel`); + } else if (max === 7) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.includes('3') || + m.content.includes('4') || + m.content.includes('5') || + m.content.includes('6') || + m.content.includes('7') || + m.content.includes('8') || + m.content.trim() === (`cancel`); + } else if (max === 8) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.includes('3') || + m.content.includes('4') || + m.content.includes('5') || + m.content.includes('6') || + m.content.includes('7') || + m.content.includes('8') || + m.content.includes('9') || + m.content.trim() === (`cancel`); + } else if (max === 9) { + filter = m => m.author.id === msg.author.id && + m.content.includes('1') || + m.content.includes('2') || + m.content.includes('3') || + m.content.includes('4') || + m.content.includes('5') || + m.content.includes('6') || + m.content.includes('7') || + m.content.includes('8') || + m.content.includes('9') || + m.content.includes('10') || + m.content.trim() === (`cancel`); + } + msg.channel.awaitMessages(filter, { + max: 1, + time: 60000, + errors: ['time'] + }) + .then(collected => { + const newColl = Array.from(collected); + const mcon = newColl[0][1].content; + + if (mcon === "cancel") return firstMsg.edit(musicbot.note('note', 'Searching canceled.')); + const song_number = parseInt(mcon) - 1; + if (song_number >= 0) { + firstMsg.delete(); + return msg.channel.send(musicbot.note('note', `Queued **${musicbot.note('font', videos[song_number].title)}**`)) + .then(() => { + queue.songs.push(videos[song_number]); + if (queue.songs.length === 1 || !client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id)) musicbot.executeQueue(msg, queue); + }) + .catch(console.log); + }; + }) + .catch(collected => { + if (collected.toString() + .match(/error|Error|TypeError|RangeError|Uncaught/)) return firstMsg.edit(`\`\`\`xl\nSearching canceled. ${collected}\n\`\`\``); + return firstMsg.edit(`\`\`\`xl\nSearching canceled.\n\`\`\``); + }); + }) + }; + + const max = searchResult.totalResults >= 10 ? 9 : searchResult.totalResults - 1; + var videos = []; + for (var i = 0; i < 99; i++) { + var result = searchResult.currentPage[i]; + result.requester = msg.author.id; + if (musicbot.requesterName) result.requesterAvatarURL = msg.author.displayAvatarURL; + result.channelURL = `https://www.youtube.com/channel/${result.channelId}`; + result.queuedOn = new Date().toLocaleDateString(musicbot.dateLocal, { weekday: 'long', hour: 'numeric' }); + videos.push(result); + if (i === max) { + i = 101; + startTheFun(videos, max); + } + }; + }); + }) + .catch(console.log); + }; + + + /** + * The command for skipping a song. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + * @returns {} - The response message. + */ + musicbot.skip = (msg, suffix) => { + musicbot.dInvoker(msg) + // Get the voice connection. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection === null) return msg.channel.send(musicbot.note('fail', 'No music being played.')); + + // Get the queue. + const queue = musicbot.getQueue(msg.guild.id); + + if (!musicbot.canSkip(msg.member, queue.songs)) return msg.channel.send(musicbot.note('fail', `You cannot skip this as you didn't queue it.`)) + .then((response) => { + response.delete(5000); + }); + + let q = musicbot.queues.get(msg.guild.id); + if (q.loop !== "none") { + q.loop == "none"; + musicbot.queues.set(msg.guild.server, q); + }; + + // Get the number to skip. + let toSkip = 1; // Default 1. + if (!isNaN(suffix) && parseInt(suffix) > 0) { + toSkip = parseInt(suffix); + } + toSkip = Math.min(toSkip, queue.songs.length); + + // Skip. + queue.songs.splice(0, toSkip - 1); + + // Resume and stop playing. + try { + const dispatcher = voiceConnection.player.dispatcher; + if (!dispatcher || dispatcher === null) { + if (musicbot.logging) return console.log(new Error(`dispatcher null on skip cmd [${msg.guild.name}] [${msg.author.username}]`)); + }; + if (voiceConnection.paused) dispatcher.resume(); + dispatcher.end(); + } catch (e) { + if (musicbot.logging) console.log(new Error(`Skip command dispatcher error from userID ${msg.author.id} in guildID ${msg.guild.id}\n${e.stack}`)); + const nerr = e.toString() + .split(':'); + return msg.channel.send(musicbot.note('fail', `Error occoured!\n\`\`\`\n${nerr[0]}: ${nerr[1]}\n\`\`\``)); + }; + + if (musicbot.queues.has(msg.guild.id) && musicbot.queues.get(msg.guild.id).loop !== "none") return msg.channel.send(musicbot.note('note', 'Skipped **' + toSkip + '**! (Disabled Looping)')); + else return msg.channel.send(musicbot.note('note', 'Skipped **' + toSkip + '**!')); + } + + /** + * The command for listing the queue. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + */ + musicbot.queue = (msg, suffix) => { + musicbot.dInvoker(msg); + // Get the queue. + const queue = musicbot.getQueue(msg.guild.id, true); + + musicbot.isQueueEmpty(musicbot.queues.get(msg.guild.id)).then(res => { + if (res == true) return msg.channel.send(musicbot.note('note', 'Queue empty.')) + }).catch(res => { + if (res) { + console.log(`[isQueueEmpty] [queueCmd] [${msg.guild.name}]: ${new Error(res)}`) + return msg.channel.send(musicbot.note('fail', 'Error occoured!')) + } + }); + + let text; + // Get the queue text. + // Choice added for names to shorten the text a bit if wanted. + if (msg.channel.permissionsFor(msg.guild.me).has('EMBED_LINKS')) { + const songNum = suffix ? parseInt(suffix) - 1 : null; + let maxRes = queue.length; + + if (suffix) { + if (msg.channel.permissionsFor(msg.guild.me).has('EMBED_LINKS')) { + if (songNum > queue.length) return msg.channel.send(musicbot.note('fail', 'Not a valid song number.')); + const embed = new Discord.RichEmbed(); + const reqMem = client.users.get(queue[songNum].requester); + embed.setAuthor(`Queued Song #${suffix}`, client.user.avatarURL); + embed.addField(queue[songNum].channelTitle, `[${queue[songNum].title}](${queue[songNum].url})`, musicbot.inlineEmbeds); + embed.addField(`Queued On`, queue[songNum].queuedOn, musicbot.inlineEmbeds); + embed.setThumbnail(queue[songNum].thumbnails[musicbot.thumbnailType].url); + embed.setColor(musicbot.embedColor); + if (musicbot.requesterName && reqMem) embed.setFooter(`Queued by: ${reqMem.username}`, queue[songNum].requesterAvatarURL); + if (musicbot.requesterName && !reqMem) embed.setFooter(`Queued by: \`UnknownUser (id: ${queue[songNum].requester})\``, queue[songNum].requesterAvatarURL) + msg.channel.send({embed}); + } else { + + } + } else { + const embed = new Discord.RichEmbed(); + if (queue.length > 25) maxRes = 25; + if (musicbot.enableQueueStat) { + //Get the status of the queue. + let queueStatus = 'Stopped'; + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection !== null) { + const dispatcher = voiceConnection.player.dispatcher; + queueStatus = dispatcher.paused ? 'Paused' : 'Playing'; + + embed.setAuthor(`Song Queue (${queueStatus})`, client.user.avatarURL); + } else { + embed.setAuthor(`Song Queue`, client.user.avatarURL); + } + } + + try { + for (var i = 0; i < maxRes; i++) { + if (queue[i] !== queue.last && queue[i] !== queue.loop) { + embed.addField(`${queue[i].channelTitle}`, `[${queue[i].title}](${queue[i].url})`, musicbot.inlineEmbeds); + } + }; + embed.setColor(musicbot.embedColor); + embed.setFooter(`Total songs: ${queue.length}`, msg.author.displayAvatarURL); + } catch (e) { + console.log(e.stack); + }; + + setTimeout(() => { + msg.channel.send({ + embed + }); + }, 1500); + } + } else { + try { + if (musicbot.requesterName) { + text = queue.map((video, index) => ( + (index + 1) + ': ' + video.title + ' | Requested by ' + client.users.get(video.requester) + .username + )) + .join('\n'); + } else { + text = queue.map((video, index) => ( + (index + 1) + ': ' + video.title + )) + .join('\n'); + }; + } catch (e) { + if (musicbot.logging) console.log(`[${msg.guild.name}] [queueCmd] ` + e.stack); + const nerr = e.toString() + .split(':'); + return msg.channel.send(musicbot.note('fail', `Error occoured!\n\`\`\`\n${nerr[0]}: ${nerr[1]}\n\`\`\``)); + + } finally { + + if (text.length > 1900) { + const newText = text.substr(0, 1899); + const otherText = text.substr(1900, text.length); + if (otherText.length > 1900) { + let queueStatus = 'Stopped'; + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection !== null) { + const dispatcher = voiceConnection.player.dispatcher; + queueStatus = dispatcher.paused ? 'Paused' : 'Playing'; + } + msg.channel.send(musicbot.note('wrap', 'Queue (' + queueStatus + '):\n' + "Past character limit...")); + } else { + if (musicbot.enableQueueStat) { + // Get the status of the queue. + let queueStatus = 'Stopped'; + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection !== null) { + const dispatcher = voiceConnection.player.dispatcher; + queueStatus = dispatcher.paused ? 'Paused' : 'Playing'; + } + + // Send the queue and status. + msg.channel.send(musicbot.note('wrap', 'Queue (' + queueStatus + '):\n' + newText)); + msg.channel.send(musicbot.note('wrap', 'Queue (2) (' + queueStatus + '):\n' + otherText)); + } else { + msg.channel.send(musicbot.note('wrap', 'Queue:\n' + newText)); + msg.channel.send(musicbot.note('wrap', 'Queue (2):\n' + otherText)); + } + }; + } else { + if (musicbot.enableQueueStat) { + // Get the status of the queue. + let queueStatus = 'Stopped'; + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection !== null) { + const dispatcher = voiceConnection.player.dispatcher; + queueStatus = dispatcher.paused ? 'Paused' : 'Playing'; + } + + // Send the queue and status. + msg.channel.send(musicbot.note('wrap', 'Queue (' + queueStatus + '):\n' + text)); + } else { + msg.channel.send(musicbot.note('wrap', 'Queue:\n' + text)); + } + } + } + } + }; + + /** + * The command for information about the current song. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + * @returns {} - The response message. + */ + musicbot.np = (msg, suffix) => { + musicbot.dInvoker(msg); + // Get the voice connection. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + const queue = musicbot.getQueue(msg.guild.id, true); + if (voiceConnection === null && queue.length > 0) return msg.channel.send(musicbot.note('fail', 'No music is being played, but an ongoing queue is avainable.')); + else if (voiceConnection === null) return msg.channel.send(musicbot.note('fail', 'No music is being played.')); + const dispatcher = voiceConnection.player.dispatcher; + + + musicbot.isQueueEmpty(musicbot.queues.get(msg.guild.id)).then(res => { + if (res == true) return msg.channel.send(musicbot.note('note', 'Queue empty.')) + }).catch(res => { + if (res) { + console.log(`[isQueueEmpty] [np] [${msg.guild.name}]: ${new Error(res)}`) + return msg.channel.send(musicbot.note('fail', 'Error occoured!')) + } + }) + + if (msg.channel.permissionsFor(msg.guild.me) + .has('EMBED_LINKS')) { + const embed = new Discord.RichEmbed(); + try { + embed.setAuthor('Now Playing', client.user.avatarURL); + var songTitle = queue[0].title.replace(/\\/g, '\\\\') + .replace(/\`/g, '\\`') + .replace(/\*/g, '\\*') + .replace(/_/g, '\\_') + .replace(/~/g, '\\~') + .replace(/`/g, '\\`'); + embed.setColor(musicbot.embedColor); + embed.addField(queue[0].channelTitle, `[${songTitle}](${queue[0].url})`, musicbot.inlineEmbeds); + embed.addField("Queued On", queue[0].queuedOn, musicbot.inlineEmbeds); + embed.setThumbnail(queue[0].thumbnails.high.url); + const resMem = client.users.get(queue[0].requester); + if (musicbot.requesterName && resMem) embed.setFooter(`Requested by ${client.users.get(queue[0].requester).username}`, queue[0].requesterAvatarURL); + if (musicbot.requesterName && !resMem) embed.setFooter(`Requested by \`UnknownUser (ID: ${queue[0].requester})\``, queue[0].requesterAvatarURL); + msg.channel.send({ + embed + }); + } catch (e) { + console.error(`[${msg.guild.name}] [npCmd] ` + e.stack); + }; + } else { + try { + var songTitle = queue[0].title.replace(/\\/g, '\\\\') + .replace(/\`/g, '\\`') + .replace(/\*/g, '\\*') + .replace(/_/g, '\\_') + .replace(/~/g, '\\~') + .replace(/`/g, '\\`'); + msg.channel.send(`Now Playing: **${songTitle}**\nRequested By: ${client.users.get(queue[0].requester).username}\nQueued On: ${queue[0].queuedOn}`) + } catch (e) { + console.error(`[${msg.guild.name}] [npCmd] ` + e.stack); + }; + } + } + + /** + * The command for pausing the current song. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + * @returns {} - The response message. + */ + musicbot.pause = (msg, suffix) => { + musicbot.dInvoker(msg) + // Get the voice connection. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection === null) return msg.channel.send(musicbot.note('fail', 'No music being played.')); + + if (!musicbot.isAdmin(msg.member) && !musicbot.anyoneCanPause) return msg.channel.send(musicbot.note('fail', 'Only Admins are allowed to use this command.')); + + // Pause. + const dispatcher = voiceConnection.player.dispatcher; + if (dispatcher.paused) return msg.channel.send(musicbot.note(`fail`, `Music already paused!`)); + msg.channel.send(musicbot.note('note', 'Playback paused.')); + if (!dispatcher.paused) dispatcher.pause(); + } + + /** + * The command for leaving the channel and clearing the queue. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + * @returns {} - The response message. + */ + musicbot.leave = (msg, suffix) => { + musicbot.dInvoker(msg); + + if (musicbot.isAdmin(msg.member) || musicbot.anyoneCanLeave === true) { + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection === null) return msg.channel.send(musicbot.note('fail', 'I\'m not in a voice channel.')); + + if (musicbot.clearOnLeave) musicbot.emptyQueue(msg.guild.id); // Clear the queue if clearOnLeave is true. + + // End the stream and disconnect. + if (!voiceConnection.player.dispatcher) return; + voiceConnection.player.dispatcher.end(); + voiceConnection.disconnect(); + msg.channel.send(musicbot.note('note', 'Successfully left your voice channel!')); + + setTimeout(() => { + let vc = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (!vc.player.dispatcher) return; + try { + vc.player.dispatcher.end(); + vc.disconnect(); + } catch (e) { + console.error(`[leaevCmd] [${msg.guild.name}] ${e.stack}`); + } + }, 2500); + } else { + const chance = Math.floor((Math.random() * 100) + 1); + if (chance <= 10) return msg.channel.send(musicbot.note('fail', `I'm afraid I can't let you do that, ${msg.author.username}.`)) + else return msg.channel.send(musicbot.note('fail', 'Sorry, you\'re not allowed to do that.')); + } + } + + /** + * The command for joining the voice channel. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + * @returns {} - The response message. + */ + musicbot.join = (msg, suffix) => { + musicbot.dInvoker(msg); + + if (musicbot.isAdmin(msg.member) || musicbot.anyoneCanJoin === true) { + if (msg.member.voiceChannel && msg.member.voiceChannel.joinable) { + msg.member.voiceChannel.join().then((connection) => { + msg.channel.send(musicbot.note("note", "Joined your voice channel. :ok_hand:")); + }).catch((error) => { + console.error(error); + msg.channel.send(musicbot.note("fail", "Error occoured!")); + }); + } else if (!msg.member.voiceChannel) { + return msg.channel.send(musicbot.note("fail", "Doesn't seem you're in a voice channel.")); + } else if (msg.member.voiceChannel && !msg.member.voiceChannel.joinable) { + return msg.channel.send(musicbot.note("fail", "Can't join your voice channel.")); + }; + } else { + const chance = Math.floor((Math.random() * 100) + 1); + if (chance <= 10) return msg.channel.send(musicbot.note('fail', `I'm afraid I can't let you do that, ${msg.author.username}.`)) + else return msg.channel.send(musicbot.note('fail', 'Sorry, you\'re not allowed to do that.')); + } + } + + /** + * The command for clearing the song queue. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + */ + musicbot.clearqueue = (msg, suffix) => { + musicbot.dInvoker(msg) + if (!musicbot.queues.has(msg.guild.id)) return msg.channel.send(musicbot.note('fail', 'No server queue.')); + + if (musicbot.isAdmin(msg.member)) { + musicbot.emptyQueue(msg.guild.id).then(() => { + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection !== null) { + voiceConnection.player.dispatcher.end(); + voiceConnection.disconnect(); + }; + msg.channel.send(musicbot.note('note', 'Queue cleared.')); + }).catch((res) => { + console.log(new Error(`[clearQueue] [${msg.guild.name}] ${res}`)); + }) + } else { + msg.channel.send(musicbot.note('fail', `I'm sorry, but you cannot do this.`)); + } + } + + /** + * The command for resuming the current song. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + * @returns {} - The response message. + */ + musicbot.resume = (msg, suffix) => { + musicbot.dInvoker(msg) + // Get the voice connection. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection === null) return msg.channel.send(musicbot.note('fail', 'No music is being played.')); + + if (!musicbot.isAdmin(msg.member) && !musicbot.anyoneCanPause) return msg.channel.send(musicbot.note('fail', `I'm sorry, but you cannot do this.`)); + + // Resume. + msg.channel.send(musicbot.note('note', 'Playback resumed.')); + const dispatcher = voiceConnection.player.dispatcher; + if (dispatcher.paused) dispatcher.resume(); + }; + + /** + * The command for changing the song volume. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + * @returns {} - The response message. + */ + musicbot.volume = (msg, suffix) => { + musicbot.dInvoker(msg) + // Get the voice connection. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection === null) return msg.channel.send(musicbot.note('fail', 'No music is being played.')); + + if (!suffix) return msg.channel.send(musicbot.note('fail', 'No volume specified.')); + suffix = parseInt(suffix); + + // Get the queue. + const queue = musicbot.getQueue(msg.guild.id, true); + + if (!musicbot.canAdjust(msg.member, queue)) return msg.channel.send(musicbot.note('fail', `I'm sorry, but you cannot do that.`)); + + // Get the dispatcher + const dispatcher = voiceConnection.player.dispatcher; + + if (suffix > 200 || suffix <= 0) return msg.channel.send(musicbot.note('fail', 'Volume out of range, must be within 1 - 200')); + + dispatcher.setVolume((suffix / 100)); + msg.channel.send(musicbot.note('note', 'Volume set to ' + suffix)); + } + + /** + * Looping command/option. + * + * @param {Message} msg - Original message. + * @param {object} queue - The song queue for this server. + * @param {string} suffix - Command suffix. + */ + musicbot.loop = (msg, suffix) => { + musicbot.dInvoker(msg); + + if (!musicbot.queues.has(msg.guild.id)) return msg.channel.send(musicbot.note('fail', `No queue for this server found!`)); + var queue = musicbot.queues.get(msg.guild.id); + + if (queue.loop == "none" || !queue.loop) { + queue.loop = "single"; + musicbot.queues.set(msg.guild.id, queue); + return msg.channel.send(musicbot.note('note', 'Looping single enabled! :repeat_one:')); + } else if (queue.loop == "single") { + queue.loop = "queue"; + musicbot.queues.set(msg.guild.id, queue); + return msg.channel.send(musicbot.note('note', 'Looping queue enabled! :repeat:')); + } else if (queue.loop == "queue") { + queue.loop == "none"; + musicbot.queues.set(msg.guild.id, queue); + return msg.channel.send(musicbot.note('note', 'Looping disabled! :arrow_forward:')); + } + }; + + /** + * Set command function. + * + * @param {Message} msg - Original message. + * @param {string} suffix - Command suffix. + */ + musicbot.set = (msg, suffix, args) => { + if (!musicbot.isAdmin(msg.member)) return msg.channel.send(musicbot.note('fail', `Only admins may do this!`)); + const valid = ["prefix"]; + if (!args[0]) return msg.channel.send(musicbot.note('note', `Valid settings are: ${valid.join(", ")}.`)); + if (!valid.includes(args[0])) return msg.channel.send(musicbot.note('fail', 'Not a valid setting!')); + if (args[0] && args[0] == "prefix") { + const newPrefix = args.slice(1, args.length) + .join(" "); + if (!newPrefix || newPrefix.legnth < 1) return msg.channel.send(musicbot.note('fail', 'Please specify a prefix!')); + musicbot.updatePrefix(msg.guild.id, newPrefix) + .then(response => { + if (response) msg.channel.send(musicbot.note('note', response)); + }) + .catch(err => { + if (err) { + msg.channel.send(musicbot.note('fail', `Error!\n${err}`)); + return console.log(`[updatePrefix] [${msg.guild.id}] ${err}`); + } + }) + } + }; + + /** + * Executes the next song in the queue. + * + * @param {Message} msg - Original message. + * @param {object} queue - The song queue for this server. + * @returns {} - The voice channel. + */ + musicbot.executeQueue = (msg, queue) => { + if (queue.songs.length <= 0) { + const vc = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (vc === null) return; + }; + + // If the queue is empty, finish. + musicbot.isQueueEmpty(queue).then(res => { + if (res == true) { + msg.channel.send(musicbot.note('note', 'Playback finished.')); + + // Leave the voice channel. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection !== null) return voiceConnection.disconnect(); + }; + }).catch(res => { + if (res) { + console.error(`[executeQueue]: ${new Error(res)}`); + + msg.channel.send(musicbot.note('fail', 'Error occoured on starting the queue!')); + + // Leave the voice channel. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection !== null) return voiceConnection.disconnect(); + } + }) + + new Promise((resolve, reject) => { + // Join the voice channel if not already in one. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection === null) { + // Check if the user is in a voice channel. + if (msg.member.voiceChannel && msg.member.voiceChannel.joinable) { + msg.member.voiceChannel.join() + .then(connection => { + resolve(connection); + }) + .catch((error) => { + console.log(error); + }); + } else if (!msg.member.voiceChannel.joinable) { + msg.channel.send(musicbot.note('fail', 'I do not have permission to join your voice channel!')) + reject(); + } else { + // Otherwise, clear the queue and do nothing. + musicbot.emptyQueue(msg.guild.id).then(() => { + reject(); + }) + } + } else { + resolve(voiceConnection); + } + }) + .then(connection => { + // Get the first item in the queue. + const video = queue.songs[0]; + + // Play the video. + try { + musicbot.getLast(msg.guild.id).then((response) => { + const re = response; + musicbot.setLast(msg.guild.id, video).then((res) => { + const wew = musicbot.queues.get(msg.guild.id); + if (re !== video && wew.loop == 'none') musicbot.np(msg); + }).catch((res) => { + msg.channel.send(musicbot.note('fail', 'Error occoured, try again!')); + return console.error(new Error("Dispatcher SetLast: " + res)); + }) + }).catch((response) => { + if (response) { + msg.channel.send(musicbot.note('fail', 'Error occoured, try again!')); + return console.error(new Error("Dispatcher GetLast: " + response)); + } + }); + + let dispatcher = connection.playStream(ytdl(video.url, { + filter: 'audioonly' + }), { + volume: (musicbot.defVolume / 100) + }) + + connection.on('error', (error) => { + // Skip to the next song. + console.log(`Dispatcher/connection: ${error}`); + if (msg && msg.channel) msg.channel.send(musicbot.note('fail', `Dispatcher error!\n\`${error}\``)); + queue.songs.shift(); + musicbot.executeQueue(msg, queue); + }); + + dispatcher.on('error', (error) => { + // Skip to the next song. + console.log(`Dispatcher: ${error.stack}`); + if (msg && msg.channel) msg.channel.send(musicbot.note('fail', `Dispatcher error!\n\`${error}\``)); + queue.songs.shift(); + musicbot.executeQueue(msg, queue); + }); + + dispatcher.on('end', () => { + // Wait a second. + setTimeout(() => { + let nqueue = musicbot.getQueue(msg.guild.id); + + if (nqueue.loop == "single") { + musicbot.executeQueue(msg, queue); // Restart song. + } else if (nqueue.loop == "queue") { + queue.songs.push(queue.songs[0]) // Add song 1 to the bottom of the queue. + queue.songs.shift() // Next song. + musicbot.executeQueue(msg, queue) // Start next song. + } else { + if (queue.songs.length > 0) { // Remove the song from the queue. + queue.songs.shift(); // Play the next song in the queue. + musicbot.executeQueue(msg, queue); + } else if (queue.songs.length <= 0) { + if (msg && msg.channel) msg.channel.send(musicbot.note('note', 'Playback finished.')); + + // Leave the voice channel. + const voiceConnection = client.voiceConnections.find(val => val.channel.guild.id == msg.guild.id); + if (voiceConnection !== null) return voiceConnection.disconnect(); + } + } + }, 1000); + }); + } catch (error) { + console.log(error); + } + }) + .catch((error) => { + console.log(error); + }); + }; + + //Text wrapping and cleaning. + musicbot.note = (type, text) => { + if (type === 'wrap') { + let ntext = text + .replace(/`/g, '`' + String.fromCharCode(8203)) + .replace(/@/g, '@' + String.fromCharCode(8203)) + .replace(client.token, 'REMOVED'); + return '```\n' + ntext + '\n```'; + } else if (type === 'note') { + return ':musical_note: | ' + text.replace(/`/g, '`' + String.fromCharCode(8203)); + } else if (type === 'search') { + return ':mag: | ' + text.replace(/`/g, '`' + String.fromCharCode(8203)); + } else if (type === 'fail') { + return ':no_entry_sign: | ' + text.replace(/`/g, '`' + String.fromCharCode(8203)); + } else if (type === 'font') { + return text.replace(/`/g, '`' + String.fromCharCode(8203)) + .replace(/@/g, '@' + String.fromCharCode(8203)) + .replace(/\\/g, '\\\\') + .replace(/\*/g, '\\*') + .replace(/_/g, '\\_') + .replace(/~/g, '\\~') + .replace(/`/g, '\\`'); + } else { + console.error(new Error(`${type} was an invalid type`)); + } + }; + exports.note = musicbot.note; + exports.addAdmin = (admin) => { + return new Promise((resolve, reject) => { + if (!admin || typeof admin !== "string") reject("invalid admin object"); + musicbot.botAdmins.push(admin); + resolve(musicbot.botAdmins); + }); + }; + exports.getQueue = (server) => { + if (!server) { + console.error(new Error("no server provided for getQueue")); + return null; + }; + let q = musicbot.queues.has(server) ? musicbot.queues.get(server) : null; + return q; + } + exports.setQueue = (data) => { + return new Promise((resolve, reject) => { + if (!data) reject(new Error("no data passed to setQueue")); + if (typeof data == "string") { + data = { + songs: [], + last: null, + loop: "none", + id: data + }; + musicbot.queues.set(data.id, data); + resolve(musicbot.queues.get(data.id)); + } else if (typeof data == "object") { + if (!data.songs || typeof data.songs !== "object") data.songs = []; + if (!data.last) data.last = null; + if (!data.loop || typeof data.loop !== "string") data.loop = "none"; + if (!data.id || typeof data.id !== "string") data.id = data.toString(); + musicbot.queues.set(data.id, data); + resolve(musicbot.queues.get(data.id)); + } else { + reject(new Error("data didn't equal a string or object")); + } + }); + }; +}; diff --git a/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/LICENSE b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/LICENSE new file mode 100644 index 0000000..00e8ea8 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (C) 2017 by fent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/README.md b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/README.md new file mode 100644 index 0000000..dea879e --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/README.md @@ -0,0 +1,51 @@ +# node-m3u8stream + +Concatenates segments from a [m3u8 playlist](https://tools.ietf.org/html/draft-pantos-http-live-streaming-20) into a consumable stream. + +[![Build Status](https://secure.travis-ci.org/fent/node-m3u8stream.svg)](http://travis-ci.org/fent/node-m3u8stream) +[![Dependency Status](https://david-dm.org/fent/node-m3u8stream.svg)](https://david-dm.org/fent/node-m3u8stream) +[![codecov](https://codecov.io/gh/fent/node-m3u8stream/branch/master/graph/badge.svg)](https://codecov.io/gh/fent/node-m3u8stream) + + +# Usage + +```js +const fs = require('fs'); +const m3u8stream = require('m3u8stream') + +m3u8stream('http://somesite.com/link/to/the/playlist.m3u8') + .pipe(fs.createWriteStream('videofile.mp4')); +``` + + +# API + +### m3u8stream(url, [options]) + +Creates a readable stream of binary media data. `options` can have the following + +* `chunkReadahead` - How many chunks to preload ahead. Default is `3`. +* `highWaterMark` - How much of the download to buffer into the stream. See [node's docs](https://nodejs.org/api/stream.html#stream_constructor_new_stream_writable_options) for more. Note that the actual amount buffered can be higher since each chunk request maintains its own buffer. +* `requestOptions` - Any options you want to pass to [miniget](https://github.com/fent/node-miniget), such as `headers`. +* `refreshInterval` - How often to refresh the playlist. If end of segment list is approached before the next interval, then it will refresh sooner. + +Stream has an `.end()` method, that if called, stops requesting segments, and refreshing the playlist. + +### Limitations + +Currently, it does not support [encrypted media segments](https://tools.ietf.org/html/draft-pantos-http-live-streaming-20#section-4.3.2.4). This is because the sites where this was tested on and intended for, YouTube and Twitch, don't use it. + +This does not parse master playlists, only media playlists. If you want to parse a master playlist to get links to media playlists, you can try the [m3u8 module](https://github.com/tedconf/node-m3u8). + + +# Install + + npm install m3u8stream + + +# Tests +Tests are written with [mocha](https://mochajs.org) + +```bash +npm test +``` diff --git a/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/index.js b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/index.js new file mode 100644 index 0000000..76f38f2 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/index.js @@ -0,0 +1,105 @@ +const PassThrough = require('stream').PassThrough; +const urlResolve = require('url').resolve; +const miniget = require('miniget'); +const m3u8 = require('./m3u8-parser'); +const Queue = require('./queue'); + + +/** + * @param {String} playlistURL + * @param {Object} options + * @return {stream.Readable} + */ +module.exports = (playlistURL, options) => { + var stream = new PassThrough(); + options = options || {}; + var chunkReadahead = options.chunkReadahead || 3; + var refreshInterval = options.refreshInterval || 600000; // 10 minutes + var requestOptions = options.requestOptions; + + var currSegment; + var streamQueue = new Queue((segment, callback) => { + currSegment = segment; + segment.pipe(stream, { end: false }); + segment.on('end', callback); + }, { concurrency: 1 }); + + var requestQueue = new Queue((segmentURL, callback) => { + var segment = miniget(urlResolve(playlistURL, segmentURL), requestOptions); + segment.on('error', callback); + streamQueue.push(segment, callback); + }, { + concurrency: chunkReadahead, + unique: (segmentURL) => segmentURL, + }); + + function onError(err) { + if (destroyed) { return; } + stream.emit('error', err); + // Stop on any error. + stream.end(); + } + + // When to look for items again. + var refreshThreshold; + var fetchingPlaylist = false; + var destroyed = false; + var ended = false; + function onQueuedEnd(err) { + currSegment = null; + if (err) { + onError(err); + } else if (!fetchingPlaylist && !destroyed && !ended && + requestQueue.tasks.length + requestQueue.active === refreshThreshold) { + refreshPlaylist(); + } else if (ended && !requestQueue.tasks.length && !requestQueue.active) { + stream.end(); + } + } + + var tid, currPlaylist; + function refreshPlaylist() { + clearTimeout(tid); + fetchingPlaylist = true; + currPlaylist = miniget(playlistURL, requestOptions); + currPlaylist.on('error', onError); + var parser = currPlaylist.pipe(new m3u8()); + parser.on('tag', (tagName) => { + if (tagName === 'EXT-X-ENDLIST') { + ended = true; + currPlaylist.unpipe(); + clearTimeout(tid); + } + }); + var totalItems = 0; + parser.on('item', (item) => { + totalItems++; + requestQueue.push(item, onQueuedEnd); + }); + parser.on('end', () => { + currPlaylist = null; + refreshThreshold = Math.ceil(totalItems * 0.01); + tid = setTimeout(refreshPlaylist, refreshInterval); + fetchingPlaylist = false; + }); + } + refreshPlaylist(); + + stream.end = () => { + destroyed = true; + streamQueue.die(); + requestQueue.die(); + clearTimeout(tid); + if (currPlaylist) { + currPlaylist.unpipe(); + currPlaylist.abort(); + } + if (currSegment) { + currSegment.unpipe(); + currSegment.abort(); + } + PassThrough.prototype.end.call(stream); + }; + + return stream; +}; diff --git a/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/m3u8-parser.js b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/m3u8-parser.js new file mode 100644 index 0000000..614b025 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/m3u8-parser.js @@ -0,0 +1,47 @@ +'use strict'; + +const Writable = require('stream').Writable; + + +/** + * A very simple m3u8 playlist file parser that detects tags and segments. + * + * @extends WritableStream + * @constructor + */ +module.exports = class m3u8parser extends Writable { + constructor() { + super({ decodeStrings: false }); + this._lastLine = ''; + this.on('finish', () => { + this._parseLine(this._lastLine); + this.emit('end'); + }); + } + + _parseLine(line) { + var tag = line.match(/^#(EXT[A-Z0-9-]+)(?::(.*))?/); + if (tag) { + // This is a tag. + this.emit('tag', tag[1], tag[2] || null); + + } else if (!/^#/.test(line) && line.trim()) { + // This is a segment + this.emit('item', line.trim()); + } + } + + _write(chunk, encoding, callback) { + var lines = chunk.toString('utf8').split('\n'); + if (this._lastLine) { lines[0] = this._lastLine + lines[0]; } + lines.forEach((line, i) => { + if (i < lines.length - 1) { + this._parseLine(line); + } else { + // Save the last line in case it has been broken up. + this._lastLine = line; + } + }); + callback(); + } +}; diff --git a/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/queue.js b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/queue.js new file mode 100644 index 0000000..02a2458 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/lib/queue.js @@ -0,0 +1,67 @@ +'use strict'; + +module.exports = class Queue { + /** + * A really simple queue with concurrency that optionally + * only adds unique tasks. + * + * @param {Function(Object, Function)} worker + * @param {Object} options + */ + constructor(worker, options) { + this._worker = worker; + options = options || {}; + this._concurrency = options.concurrency || 1; + this._unique = options.unique; + this._tasksMap = {}; + this.tasks = []; + this.active = 0; + } + + + /** + * Push a task to the queue. + * + * @param {Object} item + * @param {Function(Error)} callback + */ + push(item) { + if (this._unique) { + var key = this._unique(item); + if (this._tasksMap[key] === true) { return; } + this._tasksMap[key] = true; + } + this.tasks.push(arguments); + this._next(); + } + + + /** + * Process next job in queue. + */ + _next() { + if (this.active >= this._concurrency || !this.tasks.length) { return; } + var task = this.tasks.shift(); + var item = task[0]; + var callback = task[1]; + var callbackCalled = false; + this.active++; + this._worker(item, (err) => { + if (callbackCalled) { return; } + if (this._unique) { delete this._tasksMap[this._unique(item)]; } + this.active--; + callbackCalled = true; + if (callback) { callback(err); } + this._next(); + }); + } + + + /** + * Stops processing queued jobs. + */ + die() { + this.tasks = []; + this._tasksMap = {}; + } +}; diff --git a/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/package.json b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/package.json new file mode 100644 index 0000000..a503687 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/m3u8stream/package.json @@ -0,0 +1,67 @@ +{ + "_from": "m3u8stream@^0.2.1", + "_id": "m3u8stream@0.2.2", + "_inBundle": false, + "_integrity": "sha512-R/xWLXBtVr0m9sPruRL4p9uO01JyHxhcQ4nhqQhVgyT802OZyVW+dn+fWHvTnbfE6YMLc65TksZZut+Mh2OVMQ==", + "_location": "/discord.js-musicbot-addon/m3u8stream", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "m3u8stream@^0.2.1", + "name": "m3u8stream", + "escapedName": "m3u8stream", + "rawSpec": "^0.2.1", + "saveSpec": null, + "fetchSpec": "^0.2.1" + }, + "_requiredBy": [ + "/discord.js-musicbot-addon/ytdl-core" + ], + "_resolved": "http://registry.npmjs.org/m3u8stream/-/m3u8stream-0.2.2.tgz", + "_shasum": "02ef837253595f2557efab86c4234018e8a60da2", + "_spec": "m3u8stream@^0.2.1", + "_where": "C:\\Users\\matth\\Documents\\GitHub\\Moonglow\\node_modules\\discord.js-musicbot-addon\\node_modules\\ytdl-core", + "author": { + "name": "fent", + "url": "https://github.com/fent" + }, + "bugs": { + "url": "https://github.com/fent/node-m3u8stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "miniget": "^1.1.0" + }, + "deprecated": false, + "description": "Concatenates segments from a m3u8 playlist into a consumable stream.", + "devDependencies": { + "istanbul": "^0.4.5", + "mocha": "^5.0.0", + "nock": "^9.0.9", + "sinon": "^5.0.0" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/fent/node-m3u8stream#readme", + "keywords": [ + "m3u8", + "live", + "stream" + ], + "license": "MIT", + "main": "./lib/index.js", + "name": "m3u8stream", + "repository": { + "type": "git", + "url": "git://github.com/fent/node-m3u8stream.git" + }, + "scripts": { + "test": "istanbul cover node_modules/.bin/_mocha -- test/*-test.js" + }, + "version": "0.2.2" +} diff --git a/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/CHANGELOG.md b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/CHANGELOG.md new file mode 100644 index 0000000..65e71d0 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/CHANGELOG.md @@ -0,0 +1,21 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +## [0.20.1](https://github.com/fent/node-ytdl-core/compare/v0.20.0...v0.20.1) (2018-02-07) + + +### Bug Fixes + +* **signature:** YouTube change for signature deciphering ([18b3f22](https://github.com/fent/node-ytdl-core/commit/18b3f22)), closes [#282](https://github.com/fent/node-ytdl-core/issues/282) + + + + +# [0.20.0](https://github.com/fent/node-ytdl-core/compare/v0.19.0...v0.20.0) (2018-01-30) + + +### Features + +* **info:** Change URL format in getInfo ([#279](https://github.com/fent/node-ytdl-core/issues/279)) ([ece4264](https://github.com/fent/node-ytdl-core/commit/ece4264)) diff --git a/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/LICENSE b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/LICENSE new file mode 100644 index 0000000..ddb6522 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (C) 2012 by fent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/README.md b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/README.md new file mode 100644 index 0000000..fd2118d --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/README.md @@ -0,0 +1,156 @@ +# node-ytdl-core + +Yet another youtube downloading module. Written with only Javascript and a node-friendly streaming interface. + +[![Build Status](https://secure.travis-ci.org/fent/node-ytdl-core.svg)](http://travis-ci.org/fent/node-ytdl-core) +[![Dependency Status](https://david-dm.org/fent/node-ytdl-core.svg)](https://david-dm.org/fent/node-ytdl-core) +[![codecov](https://codecov.io/gh/fent/node-ytdl-core/branch/master/graph/badge.svg)](https://codecov.io/gh/fent/node-ytdl-core) + +For a CLI version of this, check out [ytdl](https://github.com/fent/node-ytdl) and [pully](https://github.com/JimmyBoh/pully). + +# Usage + +```js +const fs = require('fs'); +const ytdl = require('ytdl-core'); + +ytdl('http://www.youtube.com/watch?v=A02s8omM_hI') + .pipe(fs.createWriteStream('video.flv')); +``` + + +# API +### ytdl(url, options) + +Attempts to download a video from the given url. Returns a readable stream. `options` can have the following keys + +* `quality` - Video quality to download. Can be an [itag value](http://en.wikipedia.org/wiki/YouTube#Quality_and_formats) value, a list of itag values, or `highest`/`lowest`/`highestaudio`/`highestvideo`. `highestaudio`/`highestvideo` both prefer audio/video only respectively. Defaults to `highest`. +* `filter` - Can be `audioandvideo` to filter formats that contain both video and audio, `video` to filter for formats that contain video, `videoonly` for formats that contain video and no additional audio track. Can also be `audio` or `audioonly`. You can give a filtering function that gets called with each format available. Used to decide what format to download. This function is given the `format` object as its first argument, and should return true if the format is preferable. +* `format` - This can be a specific `format` object returned from `getInfo`. This is primarily used to download specific video or audio streams. Note: Supplying this option will ignore the `filter` and `quality` options since the format is explicitly provided. +* `range` - A byte range in the form `{start: INT, end: INT}` that specifies part of the file to download. ie {start: 10355705, end: 12452856}. Note: this downloads a portion of the file, and not a separately spliced video. +* `begin` - What time to begin downloading the video, supports formats 00:00:00.000, or 0ms, 0s, 0m, 0h, or number of milliseconds. Example: 1:30, 05:10.123, 10m30s. This option may not work on super short (less than 30s) videos, and has to be at or above 6s, see [#129](https://github.com/fent/node-ytdl-core/issues/129). It may also not work for some formats, see [#219](https://github.com/fent/node-ytdl-core/issues/219). +* `requestOptions` - Anything to merge into the request options which [miniget](https://github.com/fent/node-miniget) is called with, such as headers. +* `highWaterMark` - How much of the video download to buffer into memory. See [node's docs](https://nodejs.org/api/stream.html#stream_constructor_new_stream_writable_options) for more. +* `retries` - The number of retries ytdl is allowed to do before terminating the stream with an error. The default is set to 5. +* `lang` - The 2 character symbol of a language. Is by default set to "en". + +```js +// Example with `filter` option. +ytdl(url, { filter: (format) => format.container === 'mp4' }) + .pipe(fs.createWriteStream('video.mp4')); +``` + +#### Event: 'info' +* `Object` - Info. +* `Object` - Format. + +Emitted when the a video's `info` hash is fetched. Along with the chosen format metadata to download. `format.url` might be different if `start` was given. + +An example of what Info and format may look like is in the [example folder](example/info.json). + +#### Event: 'response' +* `http.ServerResponse` - Response. + +Emitted when the video response has been found, and has started downloading. Can be used to get the size of download. This is also emitted if there is an error with the download or it needs to reconnect to YouTube. + +#### Event: 'progress' +* `Number` - Chunk length. +* `Number` - Total downloaded. +* `Number` - Total download length. + +Emitted whenever a new chunk is received. Passes values descriping the download progress and the parsed percentage. + +### Stream#destroy() + +Destroys the underlying connection. + +### ytdl.getInfo(url, [options], [callback(err, info)]) + +Use this if you only want to get metainfo from a video. If `callback` isn't given, returns a promise. + +### ytdl.downloadFromInfo(info, options) + +Once you have received metadata from a video with the `getInfo` function, +you may pass that `info`, along with other `options` to `downloadFromInfo`. + +### ytdl.chooseFormat(formats, options) + +Can be used if you'd like to choose a format yourself with the [options above](#ytdlurl-options). + +```js +ytdl.getInfo(videoID, (err, info) { + if (err) throw err; + var format = ytdl.chooseFormat(info.formats, { quality: '134' }); + if (format) { + console.log('Format found!'); + } +}) +``` + +### ytdl.filterFormats(formats, filter) + +```js +ytdl.getInfo(videoID, (err, info) { + if (err) throw err; + var audioFormats = ytdl.filterFormats(info.formats, 'audioonly'); + console.log('Formats with only audio: ' + audioFormats.length); +}) +``` + +If you'd like to work with only some formats, you can use the [`filter` option above](#ytdlurl-options). + +### ytdl.validateID(id) + +Returns true if given string satisfies YouTube's ID format. + +### ytdl.validateURL(url) + +Returns true if able to parse out a valid video ID. + +### ytdl.getURLVideoID(url) + +Returns a video ID From a YouTube URL. + +### ytdl.getVideoID(str) + +Same as the above `ytdl.getURLVideoID()`, but can be called with the video ID directly, in which case it returns it. This is what ytdl uses internally. + +## Limitations + +ytdl cannot download videos that fall into the following +* Regionally restricted (requires a [proxy](example/proxy.js)) +* Private +* Rentals + +## Handling Separate Streams + +Typically 1080p or better video does not have audio encoded with it. The audio must be downloaded separately and merged via an appropriate encoding library. `ffmpeg` is the most widely used tool, with many [Node.js modules available](https://www.npmjs.com/search?q=ffmpeg). Use the `format` objects returned from `ytdl.getInfo` to download specific streams to combine to fit your needs. Look at [example/ffmpeg.js](example/ffmpeg.js) for an example on doing this. + +## What if it stops working? + +Youtube updates their website all the time, it's not that rare for this to stop working. If it doesn't work for you and you're using the latest version, feel free to open up an issue. Make sure to check if there isn't one already with the same error. + +If you'd like to help fix the issue, look at the type of error first. The most common one is + + Could not extract signature deciphering actions + +Run the tests at `test/irl-test.js` just to make sure that this is actually an issue with ytdl-core. + + mocha test/irl-test.js + +These tests are not mocked, and they actually try to start downloading a few videos. If these fail, then it's time to debug. + +For getting started with that, you can look at the `extractActions()` function in [`/lib/sig.js`](https://github.com/fent/node-ytdl-core/blob/master/lib/sig.js). + + +# Install + + npm install ytdl-core + + +# Tests +Tests are written with [mocha](https://mochajs.org) + +```bash +npm test +``` diff --git a/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/formats.js b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/formats.js new file mode 100644 index 0000000..861a1f7 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/formats.js @@ -0,0 +1,737 @@ +/** + * http://en.wikipedia.org/wiki/YouTube#Quality_and_formats + */ +module.exports = { + + '5': { + container: 'flv', + resolution: '240p', + encoding: 'Sorenson H.283', + profile: null, + bitrate: '0.25', + audioEncoding: 'mp3', + audioBitrate: 64, + }, + + '6': { + container: 'flv', + resolution: '270p', + encoding: 'Sorenson H.263', + profile: null, + bitrate: '0.8', + audioEncoding: 'mp3', + audioBitrate: 64, + }, + + '13': { + container: '3gp', + resolution: null, + encoding: 'MPEG-4 Visual', + profile: null, + bitrate: '0.5', + audioEncoding: 'aac', + audioBitrate: null, + }, + + '17': { + container: '3gp', + resolution: '144p', + encoding: 'MPEG-4 Visual', + profile: 'simple', + bitrate: '0.05', + audioEncoding: 'aac', + audioBitrate: 24, + }, + + '18': { + container: 'mp4', + resolution: '360p', + encoding: 'H.264', + profile: 'baseline', + bitrate: '0.5', + audioEncoding: 'aac', + audioBitrate: 96, + }, + + '22': { + container: 'mp4', + resolution: '720p', + encoding: 'H.264', + profile: 'high', + bitrate: '2-3', + audioEncoding: 'aac', + audioBitrate: 192, + }, + + '34': { + container: 'flv', + resolution: '360p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.5', + audioEncoding: 'aac', + audioBitrate: 128, + }, + + '35': { + container: 'flv', + resolution: '480p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.8-1', + audioEncoding: 'aac', + audioBitrate: 128, + }, + + '36': { + container: '3gp', + resolution: '240p', + encoding: 'MPEG-4 Visual', + profile: 'simple', + bitrate: '0.175', + audioEncoding: 'aac', + audioBitrate: 32, + }, + + '37': { + container: 'mp4', + resolution: '1080p', + encoding: 'H.264', + profile: 'high', + bitrate: '3-5.9', + audioEncoding: 'aac', + audioBitrate: 192, + }, + + '38': { + container: 'mp4', + resolution: '3072p', + encoding: 'H.264', + profile: 'high', + bitrate: '3.5-5', + audioEncoding: 'aac', + audioBitrate: 192, + }, + + '43': { + container: 'webm', + resolution: '360p', + encoding: 'VP8', + profile: null, + bitrate: '0.5-0.75', + audioEncoding: 'vorbis', + audioBitrate: 128, + }, + + '44': { + container: 'webm', + resolution: '480p', + encoding: 'VP8', + profile: null, + bitrate: '1', + audioEncoding: 'vorbis', + audioBitrate: 128, + }, + + '45': { + container: 'webm', + resolution: '720p', + encoding: 'VP8', + profile: null, + bitrate: '2', + audioEncoding: 'vorbis', + audioBitrate: 192, + }, + + '46': { + container: 'webm', + resolution: '1080p', + encoding: 'vp8', + profile: null, + bitrate: null, + audioEncoding: 'vorbis', + audioBitrate: 192, + }, + + '82': { + container: 'mp4', + resolution: '360p', + encoding: 'H.264', + profile: '3d', + bitrate: '0.5', + audioEncoding: 'aac', + audioBitrate: 96, + }, + + '83': { + container: 'mp4', + resolution: '240p', + encoding: 'H.264', + profile: '3d', + bitrate: '0.5', + audioEncoding: 'aac', + audioBitrate: 96, + }, + + '84': { + container: 'mp4', + resolution: '720p', + encoding: 'H.264', + profile: '3d', + bitrate: '2-3', + audioEncoding: 'aac', + audioBitrate: 192, + }, + + '85': { + container: 'mp4', + resolution: '1080p', + encoding: 'H.264', + profile: '3d', + bitrate: '3-4', + audioEncoding: 'aac', + audioBitrate: 192, + }, + + '100': { + container: 'webm', + resolution: '360p', + encoding: 'VP8', + profile: '3d', + bitrate: null, + audioEncoding: 'vorbis', + audioBitrate: 128, + }, + + '101': { + container: 'webm', + resolution: '360p', + encoding: 'VP8', + profile: '3d', + bitrate: null, + audioEncoding: 'vorbis', + audioBitrate: 192, + }, + + '102': { + container: 'webm', + resolution: '720p', + encoding: 'VP8', + profile: '3d', + bitrate: null, + audioEncoding: 'vorbis', + audioBitrate: 192, + }, + + // DASH (video only) + '133': { + container: 'mp4', + resolution: '240p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.2-0.3', + audioEncoding: null, + audioBitrate: null, + }, + + '134': { + container: 'mp4', + resolution: '360p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.3-0.4', + audioEncoding: null, + audioBitrate: null, + }, + + '135': { + container: 'mp4', + resolution: '480p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.5-1', + audioEncoding: null, + audioBitrate: null, + }, + + '136': { + container: 'mp4', + resolution: '720p', + encoding: 'H.264', + profile: 'main', + bitrate: '1-1.5', + audioEncoding: null, + audioBitrate: null, + }, + + '137': { + container: 'mp4', + resolution: '1080p', + encoding: 'H.264', + profile: 'high', + bitrate: '2.5-3', + audioEncoding: null, + audioBitrate: null, + }, + + '138': { + container: 'mp4', + resolution: '4320p', + encoding: 'H.264', + profile: 'high', + bitrate: '13.5-25', + audioEncoding: null, + audioBitrate: null, + }, + + '160': { + container: 'mp4', + resolution: '144p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.1', + audioEncoding: null, + audioBitrate: null, + }, + + '242': { + container: 'webm', + resolution: '240p', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '0.1-0.2', + audioEncoding: null, + audioBitrate: null, + }, + + '243': { + container: 'webm', + resolution: '360p', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '0.25', + audioEncoding: null, + audioBitrate: null, + }, + + '244': { + container: 'webm', + resolution: '480p', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '0.5', + audioEncoding: null, + audioBitrate: null, + }, + + '247': { + container: 'webm', + resolution: '720p', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '0.7-0.8', + audioEncoding: null, + audioBitrate: null, + }, + + '248': { + container: 'webm', + resolution: '1080p', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '1.5', + audioEncoding: null, + audioBitrate: null, + }, + + '264': { + container: 'mp4', + resolution: '1440p', + encoding: 'H.264', + profile: 'high', + bitrate: '4-4.5', + audioEncoding: null, + audioBitrate: null, + }, + + '266': { + container: 'mp4', + resolution: '2160p', + encoding: 'H.264', + profile: 'high', + bitrate: '12.5-16', + audioEncoding: null, + audioBitrate: null, + }, + + '271': { + container: 'webm', + resolution: '1440p', + encoding: 'VP9', + profile: 'profle 0', + bitrate: '9', + audioEncoding: null, + audioBitrate: null, + }, + + '272': { + container: 'webm', + resolution: '4320p', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '20-25', + audioEncoding: null, + audioBitrate: null, + }, + + '278': { + container: 'webm', + resolution: '144p 15fps', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '0.08', + audioEncoding: null, + audioBitrate: null, + }, + + '298': { + container: 'mp4', + resolution: '720p', + encoding: 'H.264', + profile: 'main', + bitrate: '3-3.5', + audioEncoding: null, + audioBitrate: null, + }, + + '299': { + container: 'mp4', + resolution: '1080p', + encoding: 'H.264', + profile: 'high', + bitrate: '5.5', + audioEncoding: null, + audioBitrate: null, + }, + + '302': { + container: 'webm', + resolution: '720p HFR', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '2.5', + audioEncoding: null, + audioBitrate: null, + }, + + '303': { + container: 'webm', + resolution: '1080p HFR', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '5', + audioEncoding: null, + audioBitrate: null, + }, + + '308': { + container: 'webm', + resolution: '1440p HFR', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '10', + audioEncoding: null, + audioBitrate: null, + }, + + '313': { + container: 'webm', + resolution: '2160p', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '13-15', + audioEncoding: null, + audioBitrate: null, + }, + + '315': { + container: 'webm', + resolution: '2160p HFR', + encoding: 'VP9', + profile: 'profile 0', + bitrate: '20-25', + audioEncoding: null, + audioBitrate: null, + }, + + '330': { + container: 'webm', + resolution: '144p HDR, HFR', + encoding: 'VP9', + profile: 'profile 2', + bitrate: '0.08', + audioEncoding: null, + audioBitrate: null, + }, + + '331': { + container: 'webm', + resolution: '240p HDR, HFR', + encoding: 'VP9', + profile: 'profile 2', + bitrate: '0.1-0.15', + audioEncoding: null, + audioBitrate: null, + }, + + '332': { + container: 'webm', + resolution: '360p HDR, HFR', + encoding: 'VP9', + profile: 'profile 2', + bitrate: '0.25', + audioEncoding: null, + audioBitrate: null, + }, + + '333': { + container: 'webm', + resolution: '240p HDR, HFR', + encoding: 'VP9', + profile: 'profile 2', + bitrate: '0.5', + audioEncoding: null, + audioBitrate: null, + }, + + '334': { + container: 'webm', + resolution: '720p HDR, HFR', + encoding: 'VP9', + profile: 'profile 2', + bitrate: '1', + audioEncoding: null, + audioBitrate: null, + }, + + '335': { + container: 'webm', + resolution: '1080p HDR, HFR', + encoding: 'VP9', + profile: 'profile 2', + bitrate: '1.5-2', + audioEncoding: null, + audioBitrate: null, + }, + + '336': { + container: 'webm', + resolution: '1440p HDR, HFR', + encoding: 'VP9', + profile: 'profile 2', + bitrate: '5-7', + audioEncoding: null, + audioBitrate: null, + }, + + '337': { + container: 'webm', + resolution: '2160p HDR, HFR', + encoding: 'VP9', + profile: 'profile 2', + bitrate: '12-14', + audioEncoding: null, + audioBitrate: null, + }, + + // DASH (audio only) + '139': { + container: 'mp4', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'aac', + audioBitrate: 48, + }, + + '140': { + container: 'm4a', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'aac', + audioBitrate: 128, + }, + + '141': { + container: 'mp4', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'aac', + audioBitrate: 256, + }, + + '171': { + container: 'webm', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'vorbis', + audioBitrate: 128, + }, + + '172': { + container: 'webm', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'vorbis', + audioBitrate: 192, + }, + + '249': { + container: 'webm', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'opus', + audioBitrate: 48, + }, + '250': { + container: 'webm', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'opus', + audioBitrate: 64, + }, + '251': { + container: 'webm', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'opus', + audioBitrate: 160, + }, + + // Live streaming + '91': { + container: 'ts', + resolution: '144p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.1', + audioEncoding: 'aac', + audioBitrate: 48, + }, + + '92': { + container: 'ts', + resolution: '240p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.15-0.3', + audioEncoding: 'aac', + audioBitrate: 48, + }, + + '93': { + container: 'ts', + resolution: '360p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.5-1', + audioEncoding: 'aac', + audioBitrate: 128, + }, + + '94': { + container: 'ts', + resolution: '480p', + encoding: 'H.264', + profile: 'main', + bitrate: '0.8-1.25', + audioEncoding: 'aac', + audioBitrate: 128, + }, + + '95': { + container: 'ts', + resolution: '720p', + encoding: 'H.264', + profile: 'main', + bitrate: '1.5-3', + audioEncoding: 'aac', + audioBitrate: 256, + }, + + '96': { + container: 'ts', + resolution: '1080p', + encoding: 'H.264', + profile: 'high', + bitrate: '2.5-6', + audioEncoding: 'aac', + audioBitrate: 256, + }, + + '120': { + container: 'flv', + resolution: '720p', + encoding: 'H.264', + profile: 'Main@L3.1', + bitrate: '2', + audioEncoding: 'aac', + audioBitrate: 128, + }, + + '127': { + container: 'ts', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'aac', + audioBitrate: 96, + }, + + '128': { + container: 'ts', + resolution: null, + encoding: null, + profile: null, + bitrate: null, + audioEncoding: 'aac', + audioBitrate: 96, + }, + + '132': { + container: 'ts', + resolution: '240p', + encoding: 'H.264', + profile: 'baseline', + bitrate: '0.15-0.2', + audioEncoding: 'aac', + audioBitrate: 48, + }, + + '151': { + container: 'ts', + resolution: '720p', + encoding: 'H.264', + profile: 'baseline', + bitrate: '0.05', + audioEncoding: 'aac', + audioBitrate: 24, + }, + +}; diff --git a/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/index.js b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/index.js new file mode 100644 index 0000000..4597fcf --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/index.js @@ -0,0 +1,197 @@ +const PassThrough = require('stream').PassThrough; +const deprecate = require('util').deprecate; +const getInfo = require('./info'); +const util = require('./util'); +const sig = require('./sig'); +const request = require('miniget'); +const m3u8stream = require('m3u8stream'); + + +/** + * @param {String} link + * @param {!Object} options + * @return {ReadableStream} + */ +var ytdl = module.exports = function ytdl(link, options) { + var stream = createStream(options); + getInfo(link, options, (err, info) => { + if (err) { + stream.emit('error', err); + return; + } + + downloadFromInfoCallback(stream, info, options); + }); + + return stream; +}; + + +ytdl.getInfo = getInfo; +ytdl.chooseFormat = util.chooseFormat; +ytdl.filterFormats = util.filterFormats; +ytdl.validateID = util.validateID; +ytdl.validateURL = util.validateURL; +ytdl.validateLink = deprecate(util.validateURL, + 'ytdl.validateLink: Renamed to ytdl.validateURL'); +ytdl.getURLVideoID = util.getURLVideoID; +ytdl.getVideoID = util.getVideoID; +ytdl.cache = sig.cache; + + +function createStream(options) { + var stream = new PassThrough({ + highWaterMark: options && options.highWaterMark || null, + }); + stream.destroy = () => { stream._isDestroyed = true; }; + return stream; +} + + +/** + * Chooses a format to download. + * + * @param {stream.Readable} stream + * @param {Object} info + * @param {Object} options + */ +function downloadFromInfoCallback(stream, info, options) { + options = options || {}; + var format = util.chooseFormat(info.formats, options); + if (format instanceof Error) { + // The caller expects this function to be async. + setImmediate(() => { + stream.emit('error', format); + }); + return; + } + stream.emit('info', info, format); + if (stream._isDestroyed) { return; } + + var url = format.url; + if (format.live) { + let req = m3u8stream(url, { + chunkReadahead: +info.live_chunk_readahead, + requestOptions: options.requestOptions, + }); + req.on('error', stream.emit.bind(stream, 'error')); + stream.destroy = req.end.bind(req); + req.pipe(stream); + + } else { + if (options.begin) { + url += '&begin=' + util.fromHumanTime(options.begin); + } + doDownload(stream, url, options, { + trys: options.retries || 5, + range: { + start: options.range && options.range.start ? options.range.start : 0, + end: options.range && options.range.end ? options.range.end : -1, + }, + downloaded: 0, + }); + } +} + + +/** + * Tries to download the video. If the download stops halfway, attempts to + * reconnect, continuing the download where it left off. + * + * @param {stream.Readable} stream + * @param {String} url + * @param {Object} options + * @param {Object} reconnectInfo + */ +function doDownload(stream, url, options, reconnectInfo) { + if (reconnectInfo.trys === 0) { + stream.emit('error', new Error('Too many reconnects')); + return; + } + + // Start downloading the video. + var rangedUrl = url; + if (reconnectInfo.downloaded !== 0 || + reconnectInfo.range.start !== 0 || + reconnectInfo.range.end !== -1) { + let start = reconnectInfo.range.start + reconnectInfo.downloaded; + let end = reconnectInfo.range.end != -1 ? reconnectInfo.range.end : ''; + rangedUrl += '&range=' + start + '-' + end; + } + + var req = request(rangedUrl, options.requestOptions); + + function cleanup() { + req.removeListener('end', onend); + req.removeListener('data', ondata); + req.unpipe(); + } + + var myres = false; + stream.destroy = () => { + stream._isDestroyed = true; + req.abort(); + cleanup(); + }; + + // Forward events from the request to the stream. + ['abort', 'request', 'response'].forEach(function(event) { + req.on(event, (arg) => { + stream.emit.call(stream, event, arg); + }); + }); + + function onend() { + cleanup(); + + // Reconnect if there is more to be downloaded. + if (reconnectInfo.downloaded < reconnectInfo.total) { + reconnectInfo.trys = reconnectInfo.trys - 1; + doDownload(stream, url, options, reconnectInfo); + } else { + stream.end(); + } + } + + req.on('error', (err) => { + if (stream._isDestroyed || !myres) { + stream.emit('error', err); + } else { + onend(); + } + }); + + req.on('response', (res) => { + myres = true; + if (stream._isDestroyed) { return; } + if (reconnectInfo.downloaded === 0) { + reconnectInfo.total = parseInt(res.headers['content-length']); + } + }); + + function ondata(chunk) { + var downloaded = reconnectInfo.downloaded += chunk.length; + stream.emit('progress', chunk.length, downloaded, reconnectInfo.total); + } + + req.on('data', ondata); + req.on('end', onend); + req.pipe(stream, { end: false }); +} + + +/** + * Can be used to download video after its `info` is gotten through + * `ytdl.getInfo()`. In case the user might want to look at the + * `info` object before deciding to download. + * + * @param {Object} info + * @param {!Object} options + */ +ytdl.downloadFromInfo = (info, options) => { + var stream = createStream(options); + setImmediate(() => { + downloadFromInfoCallback(stream, info, options); + }); + return stream; +}; diff --git a/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/info.js b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/info.js new file mode 100644 index 0000000..1ba9d6f --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/info.js @@ -0,0 +1,322 @@ +const urllib = require('url'); +const querystring = require('querystring'); +const sax = require('sax'); +const request = require('miniget'); +const util = require('./util'); +const sig = require('./sig'); +const FORMATS = require('./formats'); + + +const VIDEO_URL = 'https://www.youtube.com/watch?v='; +const EMBED_URL = 'https://www.youtube.com/embed/'; +const VIDEO_EURL = 'https://youtube.googleapis.com/v/'; +const INFO_HOST = 'www.youtube.com'; +const INFO_PATH = '/get_video_info'; +const KEYS_TO_SPLIT = [ + 'keywords', + 'fmt_list', + 'fexp', + 'watermark' +]; + + +/** + * Gets info from a video. + * + * @param {String} link + * @param {Object} options + * @param {Function(Error, Object)} callback + */ +module.exports = function getInfo(link, options, callback) { + if (typeof options === 'function') { + callback = options; + options = {}; + } else if (!options) { + options = {}; + } + if (!callback) { + return new Promise((resolve, reject) => { + getInfo(link, options, (err, info) => { + if (err) return reject(err); + resolve(info); + }); + }); + } + + var id = util.getVideoID(link); + if (id instanceof Error) return callback(id); + + // Try getting config from the video page first. + var params = 'hl=' + (options.lang || 'en'); + var url = VIDEO_URL + id + '&' + params; + + request(url, options.requestOptions, (err, res, body) => { + if (err) return callback(err); + + // Check if there are any errors with this video page. + var unavailableMsg = util.between(body, '
'); + if (unavailableMsg && + !/\bhid\b/.test(util.between(unavailableMsg, 'class="', '"'))) { + // Ignore error about age restriction. + if (!body.includes('
', '').trim())); + } + } + + // Parse out additional metadata from this page. + var additional = { + // Get the author/uploader. + author: util.getAuthor(body), + + // Get the day the vid was published. + published: util.getPublished(body), + + // Get description. + description: util.getVideoDescription(body), + + // Get related videos. + related_videos: util.getRelatedVideos(body), + + // Give the standard link to the video. + video_url: VIDEO_URL + id, + }; + + var jsonStr = util.between(body, 'ytplayer.config = ', ''); + var config; + if (jsonStr) { + config = jsonStr.slice(0, jsonStr.lastIndexOf(';ytplayer.load')); + gotConfig(id, options, additional, config, false, callback); + + } else { + // If the video page doesn't work, maybe because it has mature content. + // and requires an account logged in to view, try the embed page. + url = EMBED_URL + id + '?' + params; + request(url, options.requestOptions, (err, res, body) => { + if (err) return callback(err); + config = util.between(body, 't.setConfig({\'PLAYER_CONFIG\': ', '},\''); + gotConfig(id, options, additional, config, true, callback); + }); + } + }); +}; + + +/** + * @param {Object} id + * @param {Object} options + * @param {Object} additional + * @param {Object} config + * @param {Boolean} fromEmbed + * @param {Function(Error, Object)} callback + */ +function gotConfig(id, options, additional, config, fromEmbed, callback) { + if (!config) { + return callback(new Error('Could not find player config')); + } + try { + config = JSON.parse(config + (fromEmbed ? '}' : '')); + } catch (err) { + return callback(new Error('Error parsing config: ' + err.message)); + } + var url = urllib.format({ + protocol: 'https', + host: INFO_HOST, + pathname: INFO_PATH, + query: { + video_id: id, + eurl: VIDEO_EURL + id, + ps: 'default', + gl: 'US', + hl: (options.lang || 'en'), + sts: config.sts, + }, + }); + request(url, options.requestOptions, (err, res, body) => { + if (err) return callback(err); + var info = querystring.parse(body); + if (info.requires_purchase === '1') { + return callback(new Error('Video requires purchase')); + } else if (info.status === 'fail') { + if (info.errorcode === '150' && config.args) { + info = config.args; + } else { + return callback( + new Error(`Code ${info.errorcode}: ${util.stripHTML(info.reason)}`)); + } + } + + // Split some keys by commas. + KEYS_TO_SPLIT.forEach((key) => { + if (!info[key]) return; + info[key] = info[key] + .split(',') + .filter((v) => v !== ''); + }); + + var player_response = config.args.player_response || info.player_response; + if (player_response) { + try { + info.player_response = JSON.parse(player_response); + } catch (err) { + return callback( + new Error('Error parsing `player_response`: ' + err.message)); + } + } + + info.fmt_list = info.fmt_list ? + info.fmt_list.map((format) => format.split('/')) : []; + + info.formats = util.parseFormats(info); + + // Add additional properties to info. + Object.assign(info, additional); + + if (info.formats.length || + config.args.dashmpd || info.dashmpd || info.hlsvp) { + var html5playerfile = urllib.resolve(VIDEO_URL, config.assets.js); + sig.getTokens(html5playerfile, options, (err, tokens) => { + if (err) return callback(err); + + sig.decipherFormats(info.formats, tokens, options.debug); + + var funcs = []; + + if (config.args.dashmpd) { + let dashmpd = decipherURL(config.args.dashmpd, tokens); + funcs.push(getDashManifest.bind(null, dashmpd, options)); + } + + if (info.dashmpd && info.dashmpd !== config.args.dashmpd) { + let dashmpd = decipherURL(info.dashmpd, tokens); + funcs.push(getDashManifest.bind(null, dashmpd, options)); + } + + if (info.hlsvp) { + info.hlsvp = decipherURL(info.hlsvp, tokens); + funcs.push(getM3U8.bind(null, info.hlsvp, options)); + } + + util.parallel(funcs, (err, results) => { + if (err) return callback(err); + if (results[0]) { mergeFormats(info, results[0]); } + if (results[1]) { mergeFormats(info, results[1]); } + if (results[2]) { mergeFormats(info, results[2]); } + if (!info.formats.length) { + callback(new Error('No formats found')); + return; + } + + if (options.debug) { + info.formats.forEach((format) => { + var itag = format.itag; + if (!FORMATS[itag]) { + console.warn(`No format metadata for itag ${itag} found`); + } + }); + } + + info.formats.forEach(util.addFormatMeta); + info.formats.sort(util.sortFormats); + callback(null, info); + + }); + }); + } else { + callback(new Error('This video is unavailable')); + } + }); +} + + +/** + * @param {String} url + * @param {Array.} tokens + */ +function decipherURL(url, tokens) { + return url.replace(/\/s\/([a-fA-F0-9.]+)/, (_, s) => { + return '/signature/' + sig.decipher(tokens, s); + }); +} + + +/** + * Merges formats from DASH or M3U8 with formats from video info page. + * + * @param {Object} info + * @param {Object} formatsMap + */ +function mergeFormats(info, formatsMap) { + info.formats.forEach((f) => { + var cf = formatsMap[f.itag]; + if (cf) { + for (let key in f) { cf[key] = f[key]; } + } else { + formatsMap[f.itag] = f; + } + }); + info.formats = []; + for (let itag in formatsMap) { info.formats.push(formatsMap[itag]); } +} + + +/** + * Gets additional DASH formats. + * + * @param {String} url + * @param {Object} options + * @param {Function(!Error, Array.)} callback + */ +function getDashManifest(url, options, callback) { + var formats = {}; + var currentFormat = null; + var expectUrl = false; + + var parser = sax.parser(false); + parser.onerror = callback; + parser.onopentag = (node) => { + if (node.name === 'REPRESENTATION') { + var itag = node.attributes.ID; + currentFormat = { itag: itag }; + formats[itag] = currentFormat; + } + expectUrl = node.name === 'BASEURL'; + }; + parser.ontext = (text) => { + if (expectUrl) { + currentFormat.url = text; + } + }; + parser.onend = () => { callback(null, formats); }; + + var req = request(urllib.resolve(VIDEO_URL, url), options.requestOptions); + req.setEncoding('utf8'); + req.on('error', callback); + req.on('data', (chunk) => { parser.write(chunk); }); + req.on('end', parser.close.bind(parser)); +} + + +/** + * Gets additional formats. + * + * @param {String} url + * @param {Object} options + * @param {Function(!Error, Array.)} callback + */ +function getM3U8(url, options, callback) { + url = urllib.resolve(VIDEO_URL, url); + request(url, options.requestOptions, (err, res, body) => { + if (err) return callback(err); + + var formats = {}; + body + .split('\n') + .filter((line) => /https?:\/\//.test(line)) + .forEach((line) => { + var itag = line.match(/\/itag\/(\d+)\//)[1]; + formats[itag] = { itag: itag, url: line }; + }); + callback(null, formats); + }); +} diff --git a/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/sig.js b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/sig.js new file mode 100644 index 0000000..4793dc6 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/sig.js @@ -0,0 +1,264 @@ +const url = require('url'); +const request = require('miniget'); + + +// A shared cache to keep track of html5player.js tokens. +exports.cache = new Map(); + + +/** + * Extract signature deciphering tokens from html5player file. + * + * @param {String} html5playerfile + * @param {Object} options + * @param {Function(!Error, Array.)} callback + */ +exports.getTokens = (html5playerfile, options, callback) => { + var key, cachedTokens; + var rs = /(?:html5)?player[-_]([a-zA-Z0-9\-_]+)(?:\.js|\/)/ + .exec(html5playerfile); + if (rs) { + key = rs[1]; + cachedTokens = exports.cache.get(key); + } else { + console.warn('Could not extract html5player key:', html5playerfile); + } + if (cachedTokens) { + callback(null, cachedTokens); + } else { + request(html5playerfile, options.requestOptions, (err, res, body) => { + if (err) return callback(err); + + var tokens = exports.extractActions(body); + if (key && (!tokens || !tokens.length)) { + callback(new Error('Could not extract signature deciphering actions')); + return; + } + + exports.cache.set(key, tokens); + callback(null, tokens); + }); + } +}; + + +/** + * Decipher a signature based on action tokens. + * + * @param {Array.} tokens + * @param {String} sig + * @return {String} + */ +exports.decipher = (tokens, sig) => { + sig = sig.split(''); + for (let i = 0, len = tokens.length; i < len; i++) { + let token = tokens[i], pos; + switch (token[0]) { + case 'r': + sig = sig.reverse(); + break; + case 'w': + pos = ~~token.slice(1); + sig = swapHeadAndPosition(sig, pos); + break; + case 's': + pos = ~~token.slice(1); + sig = sig.slice(pos); + break; + case 'p': + pos = ~~token.slice(1); + sig.splice(0, pos); + break; + } + } + return sig.join(''); +}; + + +/** + * Swaps the first element of an array with one of given position. + * + * @param {Array.} arr + * @param {Number} position + * @return {Array.} + */ +function swapHeadAndPosition(arr, position) { + var first = arr[0]; + arr[0] = arr[position % arr.length]; + arr[position] = first; + return arr; +} + + +var jsVarStr = '[a-zA-Z_\\$][a-zA-Z_0-9]*'; +var jsSingleQuoteStr = `'[^'\\\\]*(:?\\\\[\\s\\S][^'\\\\]*)*'`; +var jsDoubleQuoteStr = `"[^"\\\\]*(:?\\\\[\\s\\S][^"\\\\]*)*"`; +var jsQuoteStr = `(?:${jsSingleQuoteStr}|${jsDoubleQuoteStr})`; +var jsKeyStr = `(?:${jsVarStr}|${jsQuoteStr})`; +var jsPropStr = `(?:\\.${jsVarStr}|\\[${jsQuoteStr}\\])`; +var jsEmptyStr = `(?:''|"")`; +var reverseStr = ':function\\(a\\)\\{' + + '(?:return )?a\\.reverse\\(\\)' + +'\\}'; +var sliceStr = ':function\\(a,b\\)\\{' + + 'return a\\.slice\\(b\\)' + +'\\}'; +var spliceStr = ':function\\(a,b\\)\\{' + + 'a\\.splice\\(0,b\\)' + +'\\}'; +var swapStr = ':function\\(a,b\\)\\{' + + 'var c=a\\[0\\];a\\[0\\]=a\\[b(?:%a\\.length)?\\];a\\[b(?:%a\\.length)?\\]=c(?:;return a)?' + +'\\}'; +var actionsObjRegexp = new RegExp( + `var (${jsVarStr})=\\{((?:(?:` + + jsKeyStr + reverseStr + '|' + + jsKeyStr + sliceStr + '|' + + jsKeyStr + spliceStr + '|' + + jsKeyStr + swapStr + + '),?\\r?\\n?)+)\\};' +); +var actionsFuncRegexp = new RegExp(`function(?: ${jsVarStr})?\\(a\\)\\{` + + `a=a\\.split\\(${jsEmptyStr}\\);\\s*` + + `((?:(?:a=)?${jsVarStr}` + + jsPropStr + + '\\(a,\\d+\\);)+)' + + `return a\\.join\\(${jsEmptyStr}\\)` + + '\\}' +); +var reverseRegexp = new RegExp(`(?:^|,)(${jsKeyStr})${reverseStr}`, 'm'); +var sliceRegexp = new RegExp(`(?:^|,)(${jsKeyStr})${sliceStr}`, 'm'); +var spliceRegexp = new RegExp(`(?:^|,)(${jsKeyStr})${spliceStr}`, 'm'); +var swapRegexp = new RegExp(`(?:^|,)(${jsKeyStr})${swapStr}`, 'm'); + + +/** + * Extracts the actions that should be taken to decipher a signature. + * + * This searches for a function that performs string manipulations on + * the signature. We already know what the 3 possible changes to a signature + * are in order to decipher it. There is + * + * * Reversing the string. + * * Removing a number of characters from the beginning. + * * Swapping the first character with another position. + * + * Note, `Array#slice()` used to be used instead of `Array#splice()`, + * it's kept in case we encounter any older html5player files. + * + * After retrieving the function that does this, we can see what actions + * it takes on a signature. + * + * @param {String} body + * @return {Array.} + */ +exports.extractActions = (body) => { + var objResult = actionsObjRegexp.exec(body); + var funcResult = actionsFuncRegexp.exec(body); + if (!objResult || !funcResult) { return null; } + + var obj = objResult[1].replace(/\$/g, '\\$'); + var objBody = objResult[2].replace(/\$/g, '\\$'); + var funcBody = funcResult[1].replace(/\$/g, '\\$'); + + var result = reverseRegexp.exec(objBody); + var reverseKey = result && result[1] + .replace(/\$/g, '\\$') + .replace(/\$|^'|^"|'$|"$/g, ''); + result = sliceRegexp.exec(objBody); + var sliceKey = result && result[1] + .replace(/\$/g, '\\$') + .replace(/\$|^'|^"|'$|"$/g, ''); + result = spliceRegexp.exec(objBody); + var spliceKey = result && result[1] + .replace(/\$/g, '\\$') + .replace(/\$|^'|^"|'$|"$/g, ''); + result = swapRegexp.exec(objBody); + var swapKey = result && result[1] + .replace(/\$/g, '\\$') + .replace(/\$|^'|^"|'$|"$/g, ''); + + var keys = `(${[reverseKey, sliceKey, spliceKey, swapKey].join('|')})`; + var myreg = '(?:a=)?' + obj + + `(?:\\.${keys}|\\['${keys}'\\]|\\["${keys}"\\])` + + '\\(a,(\\d+)\\)'; + var tokenizeRegexp = new RegExp(myreg, 'g'); + var tokens = []; + while ((result = tokenizeRegexp.exec(funcBody)) !== null) { + let key = result[1] || result[2] || result[3]; + switch (key) { + case swapKey: + tokens.push('w' + result[4]); + break; + case reverseKey: + tokens.push('r'); + break; + case sliceKey: + tokens.push('s' + result[4]); + break; + case spliceKey: + tokens.push('p' + result[4]); + break; + } + } + return tokens; +}; + + +/** + * @param {Object} format + * @param {String} sig + * @param {Boolean} debug + */ +exports.setDownloadURL = (format, sig, debug) => { + var decodedUrl; + if (format.url) { + decodedUrl = format.url; + } else { + if (debug) { + console.warn('Download url not found for itag ' + format.itag); + } + return; + } + + try { + decodedUrl = decodeURIComponent(decodedUrl); + } catch (err) { + if (debug) { + console.warn('Could not decode url: ' + err.message); + } + return; + } + + // Make some adjustments to the final url. + var parsedUrl = url.parse(decodedUrl, true); + + // Deleting the `search` part is necessary otherwise changes to + // `query` won't reflect when running `url.format()` + delete parsedUrl.search; + + var query = parsedUrl.query; + + // This is needed for a speedier download. + // See https://github.com/fent/node-ytdl-core/issues/127 + query.ratebypass = 'yes'; + if (sig) { + query.signature = sig; + } + + format.url = url.format(parsedUrl); +}; + + +/** + * Applies `sig.decipher()` to all format URL's. + * + * @param {Array.} formats + * @param {Array.} tokens + * @param {Boolean} debug + */ +exports.decipherFormats = (formats, tokens, debug) => { + formats.forEach((format) => { + var sig = tokens && format.s ? exports.decipher(tokens, format.s) : null; + exports.setDownloadURL(format, sig, debug); + }); +}; diff --git a/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/util.js b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/util.js new file mode 100644 index 0000000..1655a45 --- /dev/null +++ b/node_modules/discord.js-musicbot-addon/node_modules/ytdl-core/lib/util.js @@ -0,0 +1,499 @@ +const qs = require('querystring'); +const url = require('url'); +const Entities = require('html-entities').AllHtmlEntities; +const FORMATS = require('./formats'); + + +const VIDEO_URL = 'https://www.youtube.com/watch?v='; + + +/** + * Parses a string representation of amount of milliseconds. + * + * @param {String} time + * @return {Number} + */ +var timeRegexp = /(?:(\d+)h)?(?:(\d+)m(?!s))?(?:(\d+)s)?(?:(\d+)(?:ms)?)?/; +exports.parseTime = (time) => { + var result = timeRegexp.exec(time.toString()); + var hours = result[1] || 0; + var mins = result[2] || 0; + var secs = result[3] || 0; + var ms = result[4] || 0; + + return hours * 3600000 + mins * 60000 + secs * 1000 + parseInt(ms, 10); +}; + + +// Use these to help sort formats, higher is better. +var audioEncodingRanks = { + mp3: 1, + vorbis: 2, + aac: 3, + opus: 4, + flac: 5, +}; +var videoEncodingRanks = { + 'Sorenson H.283': 1, + 'MPEG-4 Visual': 2, + 'VP8': 3, + 'VP9': 4, + 'H.264': 5, +}; + + +/** + * Sort formats from highest quality to lowest. + * By resolution, then video bitrate, then audio bitrate. + * + * @param {Object} a + * @param {Object} b + */ +exports.sortFormats = (a, b) => { + var ares = a.resolution ? parseInt(a.resolution.slice(0, -1), 10) : 0; + var bres = b.resolution ? parseInt(b.resolution.slice(0, -1), 10) : 0; + var afeats = ~~!!ares * 2 + ~~!!a.audioBitrate; + var bfeats = ~~!!bres * 2 + ~~!!b.audioBitrate; + + function getBitrate(c) { + if (c.bitrate) { + let s = c.bitrate.split('-'); + return parseFloat(s[s.length - 1], 10); + } else { + return 0; + } + } + + function audioScore(c) { + var abitrate = c.audioBitrate || 0; + var aenc = audioEncodingRanks[c.audioEncoding] || 0; + return abitrate + aenc / 10; + } + + if (afeats === bfeats) { + if (ares === bres) { + let avbitrate = getBitrate(a); + let bvbitrate = getBitrate(b); + if (avbitrate === bvbitrate) { + let aascore = audioScore(a); + let bascore = audioScore(b); + if (aascore === bascore) { + let avenc = videoEncodingRanks[a.encoding] || 0; + let bvenc = videoEncodingRanks[b.encoding] || 0; + return bvenc - avenc; + } else { + return bascore - aascore; + } + } else { + return bvbitrate - avbitrate; + } + } else { + return bres - ares; + } + } else { + return bfeats - afeats; + } +}; + + +/** + * Choose a format depending on the given options. + * + * @param {Array.} formats + * @param {Object} options + * @return {Object|Error} + */ +exports.chooseFormat = (formats, options) => { + if (typeof options.format === 'object') { + return options.format; + } + + if (options.filter) { + formats = exports.filterFormats(formats, options.filter); + if (formats.length === 0) { + return new Error('No formats found with custom filter'); + } + } + + var format; + var quality = options.quality || 'highest'; + function getBitrate(f) { + let s = f.bitrate.split('-'); + return parseFloat(s[s.length - 1], 10); + } + switch (quality) { + case 'highest': + format = formats[0]; + break; + + case 'lowest': + format = formats[formats.length - 1]; + break; + + case 'highestaudio': + formats = exports.filterFormats(formats, 'audio'); + format = null; + for (let f of formats) { + if (!format + || f.audioBitrate > format.audioBitrate + || (f.audioBitrate === format.audioBitrate && format.encoding && !f.encoding)) + format = f; + } + break; + + case 'highestvideo': + formats = exports.filterFormats(formats, 'video'); + format = null; + for (let f of formats) { + if (!format + || getBitrate(f) > getBitrate(format) + || (getBitrate(f) === getBitrate(format) && format.audioEncoding && !f.audioEncoding)) + format = f; + } + break; + + default: { + let getFormat = (itag) => { + return formats.find((format) => format.itag === '' + itag); + }; + if (Array.isArray(quality)) { + quality.find((q) => format = getFormat(q)); + } else { + format = getFormat(quality); + } + } + + } + + if (!format) { + return new Error('No such format found: ' + quality); + } + return format; +}; + + +/** + * @param {Array.} formats + * @param {Function} filter + * @return {Array.} + */ +exports.filterFormats = (formats, filter) => { + var fn; + switch (filter) { + case 'audioandvideo': + fn = (format) => format.bitrate && format.audioBitrate; + break; + + case 'video': + fn = (format) => format.bitrate; + break; + + case 'videoonly': + fn = (format) => format.bitrate && !format.audioBitrate; + break; + + case 'audio': + fn = (format) => format.audioBitrate; + break; + + case 'audioonly': + fn = (format) => !format.bitrate && format.audioBitrate; + break; + + default: + if (typeof filter === 'function') { + fn = filter; + } else { + throw new TypeError(`Given filter (${filter}) is not supported`); + } + } + return formats.filter(fn); +}; + + +/** + * Extract string inbetween another. + * + * @param {String} haystack + * @param {String} left + * @param {String} right + * @return {String} + */ +exports.between = (haystack, left, right) => { + var pos; + pos = haystack.indexOf(left); + if (pos === -1) { return ''; } + haystack = haystack.slice(pos + left.length); + pos = haystack.indexOf(right); + if (pos === -1) { return ''; } + haystack = haystack.slice(0, pos); + return haystack; +}; + + +/** + * Get video ID. + * + * There are a few type of video URL formats. + * - http://www.youtube.com/watch?v=VIDEO_ID + * - http://m.youtube.com/watch?v=VIDEO_ID + * - http://youtu.be/VIDEO_ID + * - http://www.youtube.com/v/VIDEO_ID + * - http://www.youtube.com/embed/VIDEO_ID + * + * @param {String} link + * @return {String|Error} + */ +exports.getURLVideoID = function(link) { + var parsed = url.parse(link, true); + var id = parsed.query.v; + if (parsed.hostname === 'youtu.be' || + (parsed.hostname === 'youtube.com' || + parsed.hostname === 'www.youtube.com') && !id) { + var s = parsed.pathname.split('/'); + id = s[s.length - 1]; + } + if (!id) { + return new Error('No video id found: ' + link); + } + id = id.substring(0, 11); + if (!exports.validateID(id)) { + return new TypeError(`Video id (${id}) does not match expected ` + + `format (${idRegex.toString()})`); + } + return id; +}; + + +/** + * Gets video ID either from a url or by checking if the given string + * matches the video ID format. + * + * @param {String} str + * @return {String|Error} + */ +exports.getVideoID = (str) => { + if (exports.validateID(str)) { + return str; + } else { + return exports.getURLVideoID(str); + } +}; + + +/** + * Returns true if given id satifies YouTube's id format. + * + * @param {String} id + * @return {Boolean} + */ +var idRegex = /^[a-zA-Z0-9-_]{11}$/; +exports.validateID = (id) => { + return idRegex.test(id); +}; + + +/** + * Checks wether the input string includes a valid id. + * + * @param {String} string + * @return {Boolean} + */ +exports.validateURL = (string) => { + return !(exports.getURLVideoID(string) instanceof Error); +}; + + +/** + * @param {Object} info + * @return {Array.} + */ +exports.parseFormats = (info) => { + var formats = []; + if (info.url_encoded_fmt_stream_map) { + formats = formats + .concat(info.url_encoded_fmt_stream_map.split(',')); + } + if (info.adaptive_fmts) { + formats = formats.concat(info.adaptive_fmts.split(',')); + } + + formats = formats.map((format) => qs.parse(format)); + delete info.url_encoded_fmt_stream_map; + delete info.adaptive_fmts; + + return formats; +}; + + +/** + * @param {Object} format + */ +exports.addFormatMeta = (format) => { + var meta = FORMATS[format.itag]; + for (let key in meta) { + format[key] = meta[key]; + } + + if (/\/live\/1\//.test(format.url)) { + format.live = true; + } +}; + + +/** + * Get only the string from an HTML string. + * + * @param {String} html + * @return {String} + */ +exports.stripHTML = (html) => { + return html + .replace(/\n/g, ' ') + .replace(/\s*<\s*br\s*\/?\s*>\s*/gi, '\n') + .replace(/<\s*\/\s*p\s*>\s*<\s*p[^>]*>/gi, '\n') + .replace(/<.*?>/gi, '') + .trim(); +}; + + +/** + * Get video description from html + * + * @param {String} html + * @return {String} + */ +exports.getVideoDescription = (html) => { + var regex = /(.+?)<\/p>[\n\r\s]*?<\/div>/im; + var description = html.match(regex); + return description ? + new Entities().decode(exports.stripHTML(description[1])) : ''; +}; + + +/** + * Get video Owner from html. + * + * @param {String} body + * @return {Object} + */ +var authorRegexp = /]+>(.+?(?=<\/a>))/; +var aliasRegExp = / { + var ownerinfo = exports.between(body, + '