├── .editorconfig ├── .gitattributes ├── .github └── workflows │ ├── build.yml │ └── deploy.yml ├── .gitignore ├── .prettierrc ├── LICENSE ├── README-fa.md ├── README.md ├── package-lock.json ├── package.json ├── resources ├── provider-list.txt └── proxy-list.txt ├── src ├── auth.ts ├── clash.ts ├── collector.ts ├── config.ts ├── helpers.ts ├── interfaces.ts ├── panel.ts ├── qrcode.ts ├── sub.ts ├── trojan.ts ├── variables.ts ├── vless.ts └── worker.ts ├── tsconfig.json ├── worker-configuration.d.ts └── wrangler.toml /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | tab_width = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.yml] 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build worker.js 2 | on: 3 | push: 4 | branches: ["main"] 5 | release: 6 | types: ["published"] 7 | 8 | jobs: 9 | build: 10 | permissions: 11 | contents: write 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v4 18 | 19 | - name: Setup Node.js 20 | uses: actions/setup-node@v4 21 | with: 22 | node-version: "latest" 23 | cache: "npm" 24 | 25 | - name: Install modules 26 | run: npm i wrangler@latest 27 | 28 | - name: Build 29 | run: npx wrangler build 30 | 31 | - name: Add Header 32 | run: cp ${{ github.workspace }}/dist/worker.js ${{ github.workspace }}/dist/worker-original.js && echo -e "/*!\r\n * v2ray Subscription Worker (${{ github.sha }})\r\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\r\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\r\n */\r\n" > ${{ github.workspace }}/dist/worker.js && cat ${{ github.workspace }}/dist/worker-original.js >> ${{ github.workspace }}/dist/worker.js 33 | 34 | - name: Upload to Artifacts 35 | uses: actions/upload-artifact@v4 36 | with: 37 | name: worker 38 | path: ${{ github.workspace }}/dist/worker.js 39 | 40 | - name: Add Release Header 41 | run: echo -e "/*!\r\n * v2ray Subscription Worker ${{ github.event.release.tag_name }}\r\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\r\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\r\n */\r\n" > ${{ github.workspace }}/dist/worker.js && cat ${{ github.workspace }}/dist/worker-original.js >> ${{ github.workspace }}/dist/worker.js 42 | 43 | - name: Upload to GitHub Release 44 | uses: svenstaro/upload-release-action@v2 45 | if: github.event_name == 'release' 46 | with: 47 | repo_token: ${{ secrets.GITHUB_TOKEN }} 48 | file: ${{ github.workspace }}/dist/worker.js 49 | asset_name: worker.js 50 | tag: ${{ github.ref }} 51 | overwrite: true -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Worker 2 | on: 3 | repository_dispatch: 4 | 5 | jobs: 6 | deploy: 7 | runs-on: ubuntu-latest 8 | timeout-minutes: 60 9 | 10 | steps: 11 | - name: Checkout code 12 | uses: actions/checkout@v4 13 | 14 | - name: Setup Node.js 15 | uses: actions/setup-node@v4 16 | with: 17 | node-version: "latest" 18 | cache: "npm" 19 | 20 | - name: Install modules 21 | run: npm i wrangler@latest 22 | 23 | - name: Build 24 | run: npx wrangler build 25 | 26 | - name: Add Header 27 | run: cp ${{ github.workspace }}/dist/worker.js ${{ github.workspace }}/dist/worker-original.js && echo -e "/*!\n * v2ray Subscription Worker (${{ github.sha }})\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\n */\n\n$(cat ${{ github.workspace }}/dist/worker.js)" > ${{ github.workspace }}/dist/worker.js 28 | 29 | - name: Deploy 30 | run: sed -i "s/KV_NAME/{{ secrets.KV_NAME }}/g" wrangler.toml && wrangler deploy --api-token ${{ secrets.CF_API_TOKEN }} --account-id ${{ secrets.CF_ACCOUNT_ID }} 31 | 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Dependency directories 6 | node_modules/ 7 | 8 | # other 9 | .old 10 | .wrangler 11 | dist/ 12 | resources/.local/ 13 | package-lock.json 14 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 140, 3 | "singleQuote": true, 4 | "semi": true, 5 | "useTabs": true 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README-fa.md: -------------------------------------------------------------------------------- 1 | 2 | ## V2Ray Worker 3 | راهکار جامع کانفیگ‌های v2ray روی ورکر 4 | 5 | [English version](https://github.com/vfarid/v2ray-worker/blob/main/README.md) 6 | 7 | ### کانال یوتیوب 8 | [ویدیوی آموزشی - اندروید](https://youtu.be/Jb_6jmrKKyo) 9 | 10 | ### کانال تلگرام 11 | [در کانال تلگرام بخوانید](https://t.me/vahidgeek/140) 12 | 13 | ### روش استفاده 14 | برای استفاده از این کد، اسکریپت worker.js را از بخش از آخرین نسخه دانلود کرده و روی یک ورکر جدید آپلود کنید. 15 | برای این کار لازم است ابتدا اکانت کلادفلر خود را ایجاد کرده و یک ورکر جدید بر روی اکانت اضافه کنید. در صورتی که قبلا این کار را انجام نداده‌اید، ویدیوهای آموزش بالا را مشاهده نمایید. 16 | 17 | ### کلادفلر KV 18 | در این اسکریپت، برای ذخیره‌ی اطلاعات پنل کنترل، از KV کلادفلر استفاده شده که لازم است برای بهره‌برداری از تمام قابلیت این ورکر، این بخش را راه اندازی کنید. 19 | برای راه اندازی، دو بخش را باید تنظیم کنید: 20 | - ابتدا در بخش KV در زیرمجموعه‌ی Workers یک Namespace جدید با نام دلخواه اضافه کنید. 21 | - در صفحه اصلی ورکر، قبل از محیط ویرایشگر، به بخش Setting رفته و گزینه‌ی variables را انتخاب کنید. سپس اسکرول کنید تا به بخش KV برسید. در این بخش یک متغیر جدید با نام settings اضافه کرده و نامی که در بخش قبل برای namespace وارد کرده بودید را انتخاب کنید. 22 | 23 | اکنون میتوانید آدس ورکر خود را در بروزر وارد کرده و پنل کنترل را مشاهده کنید. راهنمای استفاده روی پنل کنترل وجود دارد. 24 | 25 | ### Credits 26 | Built-in vless config generator is based on [Zizifn Edge Tunnel](https://github.com/zizifn/edgetunnel), re-written using Typescript. 27 | Built-in trojan config generator is based on [ca110us/epeius](https://github.com/ca110us/epeius/tree/main), re-written using Typescript. 28 | Proxy IPs source: https://rentry.co/CF-proxyIP 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # V2Ray Worker 2 | Total solution for v2ray configs over Cloudflare's worker 3 | 4 | [نسخه فارسی](https://github.com/vfarid/v2ray-worker/blob/main/README-fa.md) 5 | 6 | ## How to use 7 | 8 | To be completed... 9 | 10 | ## Deploy 11 | 1. Fork this Repo and enable Github Action 12 | 2. Open CloudFlare and create KV namespace with name `settings` then copy the ID 13 | 3. Go to this forked repo and set secrets with name `KV_NAME` and fill with KV settings ID 14 | 4. Edit this `README.md` file, then find and replace this button url bellow with yours `https://github.com/USER/REPO_NAME` then save it. 15 | 4. then press `Deploy With Workers` and follow the instruction 16 | 17 | [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/vfarid/v2ray-worker) 18 | 19 | ### Credits 20 | Built-in vless config generator is based on [Zizifn Edge Tunnel](https://github.com/zizifn/edgetunnel), re-written using Typescript. 21 | Built-in trojan config generator is based on [ca110us/epeius](https://github.com/ca110us/epeius/tree/main), re-written using Typescript. 22 | Proxy IPs source: https://rentry.co/CF-proxyIP 23 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "v2ray-worker", 3 | "version": "2.4", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "v2ray-worker", 9 | "version": "2.4", 10 | "dependencies": { 11 | "bcryptjs": "^2.4.3", 12 | "buffer": "^6.0.3", 13 | "crypto-js": "^4.2.0", 14 | "js-yaml": "^4.1.0", 15 | "uuid": "^9.0.1" 16 | }, 17 | "devDependencies": { 18 | "@cloudflare/workers-types": "^4.20240529.0", 19 | "@types/bcryptjs": "^2.4.6", 20 | "@types/crypto-js": "^4.2.2", 21 | "@types/js-yaml": "^4.0.9", 22 | "@types/node": "^20.12.13", 23 | "@types/uuid": "^9.0.8", 24 | "typescript": "^5.0.4", 25 | "wrangler": "^3.57.2" 26 | } 27 | }, 28 | "node_modules/@cloudflare/kv-asset-handler": { 29 | "version": "0.3.2", 30 | "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.3.2.tgz", 31 | "integrity": "sha512-EeEjMobfuJrwoctj7FA1y1KEbM0+Q1xSjobIEyie9k4haVEBB7vkDvsasw1pM3rO39mL2akxIAzLMUAtrMHZhA==", 32 | "dev": true, 33 | "license": "MIT OR Apache-2.0", 34 | "dependencies": { 35 | "mime": "^3.0.0" 36 | }, 37 | "engines": { 38 | "node": ">=16.13" 39 | } 40 | }, 41 | "node_modules/@cloudflare/workerd-darwin-64": { 42 | "version": "1.20240524.0", 43 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20240524.0.tgz", 44 | "integrity": "sha512-ATaXjefbTsrv4mpn4Fdua114RRDXcX5Ky+Mv+f4JTUllgalmqC4CYMN4jxRz9IpJU/fNMN8IEfvUyuJBAcl9Iw==", 45 | "cpu": [ 46 | "x64" 47 | ], 48 | "dev": true, 49 | "license": "Apache-2.0", 50 | "optional": true, 51 | "os": [ 52 | "darwin" 53 | ], 54 | "engines": { 55 | "node": ">=16" 56 | } 57 | }, 58 | "node_modules/@cloudflare/workerd-darwin-arm64": { 59 | "version": "1.20240524.0", 60 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20240524.0.tgz", 61 | "integrity": "sha512-wnbsZI4CS0QPCd+wnBHQ40C28A/2Qo4ESi1YhE2735G3UNcc876MWksZhsubd+XH0XPIra6eNFqyw6wRMpQOXA==", 62 | "cpu": [ 63 | "arm64" 64 | ], 65 | "dev": true, 66 | "license": "Apache-2.0", 67 | "optional": true, 68 | "os": [ 69 | "darwin" 70 | ], 71 | "engines": { 72 | "node": ">=16" 73 | } 74 | }, 75 | "node_modules/@cloudflare/workerd-linux-64": { 76 | "version": "1.20240524.0", 77 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20240524.0.tgz", 78 | "integrity": "sha512-E8mj+HPBryKwaJAiNsYzXtVjKCL0KvUBZbtxJxlWM4mLSQhT+uwGT3nydb/hFY59rZnQgZslw0oqEWht5TEYiQ==", 79 | "cpu": [ 80 | "x64" 81 | ], 82 | "dev": true, 83 | "license": "Apache-2.0", 84 | "optional": true, 85 | "os": [ 86 | "linux" 87 | ], 88 | "engines": { 89 | "node": ">=16" 90 | } 91 | }, 92 | "node_modules/@cloudflare/workerd-linux-arm64": { 93 | "version": "1.20240524.0", 94 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20240524.0.tgz", 95 | "integrity": "sha512-/Fr1W671t2triNCDCBWdStxngnbUfZunZ/2e4kaMLzJDJLYDtYdmvOUCBDzUD4ssqmIMbn9RCQQ0U+CLEoqBqw==", 96 | "cpu": [ 97 | "arm64" 98 | ], 99 | "dev": true, 100 | "license": "Apache-2.0", 101 | "optional": true, 102 | "os": [ 103 | "linux" 104 | ], 105 | "engines": { 106 | "node": ">=16" 107 | } 108 | }, 109 | "node_modules/@cloudflare/workerd-windows-64": { 110 | "version": "1.20240524.0", 111 | "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20240524.0.tgz", 112 | "integrity": "sha512-G+ThDEx57g9mAEKqhWnHaaJgpeGYtyhkmwM/BDpLqPks/rAY5YEfZbY4YL1pNk1kkcZDXGrwIsY8xe9Apf5JdA==", 113 | "cpu": [ 114 | "x64" 115 | ], 116 | "dev": true, 117 | "license": "Apache-2.0", 118 | "optional": true, 119 | "os": [ 120 | "win32" 121 | ], 122 | "engines": { 123 | "node": ">=16" 124 | } 125 | }, 126 | "node_modules/@cloudflare/workers-types": { 127 | "version": "4.20240529.0", 128 | "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20240529.0.tgz", 129 | "integrity": "sha512-W5obfjAwCNdYk3feUHtDfUxtTU6WIq83k6gmrLLJv+HkgCkOTwwrDNs+3w1Qln0tMj+FQx/fbwxw3ZuHIoyzGg==", 130 | "dev": true, 131 | "license": "MIT OR Apache-2.0" 132 | }, 133 | "node_modules/@cspotcode/source-map-support": { 134 | "version": "0.8.1", 135 | "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", 136 | "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", 137 | "dev": true, 138 | "license": "MIT", 139 | "dependencies": { 140 | "@jridgewell/trace-mapping": "0.3.9" 141 | }, 142 | "engines": { 143 | "node": ">=12" 144 | } 145 | }, 146 | "node_modules/@esbuild-plugins/node-globals-polyfill": { 147 | "version": "0.2.3", 148 | "resolved": "https://registry.npmjs.org/@esbuild-plugins/node-globals-polyfill/-/node-globals-polyfill-0.2.3.tgz", 149 | "integrity": "sha512-r3MIryXDeXDOZh7ih1l/yE9ZLORCd5e8vWg02azWRGj5SPTuoh69A2AIyn0Z31V/kHBfZ4HgWJ+OK3GTTwLmnw==", 150 | "dev": true, 151 | "license": "ISC", 152 | "peerDependencies": { 153 | "esbuild": "*" 154 | } 155 | }, 156 | "node_modules/@esbuild-plugins/node-modules-polyfill": { 157 | "version": "0.2.2", 158 | "resolved": "https://registry.npmjs.org/@esbuild-plugins/node-modules-polyfill/-/node-modules-polyfill-0.2.2.tgz", 159 | "integrity": "sha512-LXV7QsWJxRuMYvKbiznh+U1ilIop3g2TeKRzUxOG5X3YITc8JyyTa90BmLwqqv0YnX4v32CSlG+vsziZp9dMvA==", 160 | "dev": true, 161 | "license": "ISC", 162 | "dependencies": { 163 | "escape-string-regexp": "^4.0.0", 164 | "rollup-plugin-node-polyfills": "^0.2.1" 165 | }, 166 | "peerDependencies": { 167 | "esbuild": "*" 168 | } 169 | }, 170 | "node_modules/@esbuild/android-arm": { 171 | "version": "0.17.19", 172 | "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", 173 | "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", 174 | "cpu": [ 175 | "arm" 176 | ], 177 | "dev": true, 178 | "license": "MIT", 179 | "optional": true, 180 | "os": [ 181 | "android" 182 | ], 183 | "engines": { 184 | "node": ">=12" 185 | } 186 | }, 187 | "node_modules/@esbuild/android-arm64": { 188 | "version": "0.17.19", 189 | "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", 190 | "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", 191 | "cpu": [ 192 | "arm64" 193 | ], 194 | "dev": true, 195 | "license": "MIT", 196 | "optional": true, 197 | "os": [ 198 | "android" 199 | ], 200 | "engines": { 201 | "node": ">=12" 202 | } 203 | }, 204 | "node_modules/@esbuild/android-x64": { 205 | "version": "0.17.19", 206 | "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", 207 | "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", 208 | "cpu": [ 209 | "x64" 210 | ], 211 | "dev": true, 212 | "license": "MIT", 213 | "optional": true, 214 | "os": [ 215 | "android" 216 | ], 217 | "engines": { 218 | "node": ">=12" 219 | } 220 | }, 221 | "node_modules/@esbuild/darwin-arm64": { 222 | "version": "0.17.19", 223 | "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", 224 | "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", 225 | "cpu": [ 226 | "arm64" 227 | ], 228 | "dev": true, 229 | "license": "MIT", 230 | "optional": true, 231 | "os": [ 232 | "darwin" 233 | ], 234 | "engines": { 235 | "node": ">=12" 236 | } 237 | }, 238 | "node_modules/@esbuild/darwin-x64": { 239 | "version": "0.17.19", 240 | "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", 241 | "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", 242 | "cpu": [ 243 | "x64" 244 | ], 245 | "dev": true, 246 | "license": "MIT", 247 | "optional": true, 248 | "os": [ 249 | "darwin" 250 | ], 251 | "engines": { 252 | "node": ">=12" 253 | } 254 | }, 255 | "node_modules/@esbuild/freebsd-arm64": { 256 | "version": "0.17.19", 257 | "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", 258 | "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", 259 | "cpu": [ 260 | "arm64" 261 | ], 262 | "dev": true, 263 | "license": "MIT", 264 | "optional": true, 265 | "os": [ 266 | "freebsd" 267 | ], 268 | "engines": { 269 | "node": ">=12" 270 | } 271 | }, 272 | "node_modules/@esbuild/freebsd-x64": { 273 | "version": "0.17.19", 274 | "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", 275 | "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", 276 | "cpu": [ 277 | "x64" 278 | ], 279 | "dev": true, 280 | "license": "MIT", 281 | "optional": true, 282 | "os": [ 283 | "freebsd" 284 | ], 285 | "engines": { 286 | "node": ">=12" 287 | } 288 | }, 289 | "node_modules/@esbuild/linux-arm": { 290 | "version": "0.17.19", 291 | "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", 292 | "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", 293 | "cpu": [ 294 | "arm" 295 | ], 296 | "dev": true, 297 | "license": "MIT", 298 | "optional": true, 299 | "os": [ 300 | "linux" 301 | ], 302 | "engines": { 303 | "node": ">=12" 304 | } 305 | }, 306 | "node_modules/@esbuild/linux-arm64": { 307 | "version": "0.17.19", 308 | "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", 309 | "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", 310 | "cpu": [ 311 | "arm64" 312 | ], 313 | "dev": true, 314 | "license": "MIT", 315 | "optional": true, 316 | "os": [ 317 | "linux" 318 | ], 319 | "engines": { 320 | "node": ">=12" 321 | } 322 | }, 323 | "node_modules/@esbuild/linux-ia32": { 324 | "version": "0.17.19", 325 | "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", 326 | "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", 327 | "cpu": [ 328 | "ia32" 329 | ], 330 | "dev": true, 331 | "license": "MIT", 332 | "optional": true, 333 | "os": [ 334 | "linux" 335 | ], 336 | "engines": { 337 | "node": ">=12" 338 | } 339 | }, 340 | "node_modules/@esbuild/linux-loong64": { 341 | "version": "0.17.19", 342 | "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", 343 | "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", 344 | "cpu": [ 345 | "loong64" 346 | ], 347 | "dev": true, 348 | "license": "MIT", 349 | "optional": true, 350 | "os": [ 351 | "linux" 352 | ], 353 | "engines": { 354 | "node": ">=12" 355 | } 356 | }, 357 | "node_modules/@esbuild/linux-mips64el": { 358 | "version": "0.17.19", 359 | "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", 360 | "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", 361 | "cpu": [ 362 | "mips64el" 363 | ], 364 | "dev": true, 365 | "license": "MIT", 366 | "optional": true, 367 | "os": [ 368 | "linux" 369 | ], 370 | "engines": { 371 | "node": ">=12" 372 | } 373 | }, 374 | "node_modules/@esbuild/linux-ppc64": { 375 | "version": "0.17.19", 376 | "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", 377 | "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", 378 | "cpu": [ 379 | "ppc64" 380 | ], 381 | "dev": true, 382 | "license": "MIT", 383 | "optional": true, 384 | "os": [ 385 | "linux" 386 | ], 387 | "engines": { 388 | "node": ">=12" 389 | } 390 | }, 391 | "node_modules/@esbuild/linux-riscv64": { 392 | "version": "0.17.19", 393 | "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", 394 | "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", 395 | "cpu": [ 396 | "riscv64" 397 | ], 398 | "dev": true, 399 | "license": "MIT", 400 | "optional": true, 401 | "os": [ 402 | "linux" 403 | ], 404 | "engines": { 405 | "node": ">=12" 406 | } 407 | }, 408 | "node_modules/@esbuild/linux-s390x": { 409 | "version": "0.17.19", 410 | "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", 411 | "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", 412 | "cpu": [ 413 | "s390x" 414 | ], 415 | "dev": true, 416 | "license": "MIT", 417 | "optional": true, 418 | "os": [ 419 | "linux" 420 | ], 421 | "engines": { 422 | "node": ">=12" 423 | } 424 | }, 425 | "node_modules/@esbuild/linux-x64": { 426 | "version": "0.17.19", 427 | "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", 428 | "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", 429 | "cpu": [ 430 | "x64" 431 | ], 432 | "dev": true, 433 | "license": "MIT", 434 | "optional": true, 435 | "os": [ 436 | "linux" 437 | ], 438 | "engines": { 439 | "node": ">=12" 440 | } 441 | }, 442 | "node_modules/@esbuild/netbsd-x64": { 443 | "version": "0.17.19", 444 | "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", 445 | "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", 446 | "cpu": [ 447 | "x64" 448 | ], 449 | "dev": true, 450 | "license": "MIT", 451 | "optional": true, 452 | "os": [ 453 | "netbsd" 454 | ], 455 | "engines": { 456 | "node": ">=12" 457 | } 458 | }, 459 | "node_modules/@esbuild/openbsd-x64": { 460 | "version": "0.17.19", 461 | "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", 462 | "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", 463 | "cpu": [ 464 | "x64" 465 | ], 466 | "dev": true, 467 | "license": "MIT", 468 | "optional": true, 469 | "os": [ 470 | "openbsd" 471 | ], 472 | "engines": { 473 | "node": ">=12" 474 | } 475 | }, 476 | "node_modules/@esbuild/sunos-x64": { 477 | "version": "0.17.19", 478 | "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", 479 | "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", 480 | "cpu": [ 481 | "x64" 482 | ], 483 | "dev": true, 484 | "license": "MIT", 485 | "optional": true, 486 | "os": [ 487 | "sunos" 488 | ], 489 | "engines": { 490 | "node": ">=12" 491 | } 492 | }, 493 | "node_modules/@esbuild/win32-arm64": { 494 | "version": "0.17.19", 495 | "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", 496 | "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", 497 | "cpu": [ 498 | "arm64" 499 | ], 500 | "dev": true, 501 | "license": "MIT", 502 | "optional": true, 503 | "os": [ 504 | "win32" 505 | ], 506 | "engines": { 507 | "node": ">=12" 508 | } 509 | }, 510 | "node_modules/@esbuild/win32-ia32": { 511 | "version": "0.17.19", 512 | "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", 513 | "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", 514 | "cpu": [ 515 | "ia32" 516 | ], 517 | "dev": true, 518 | "license": "MIT", 519 | "optional": true, 520 | "os": [ 521 | "win32" 522 | ], 523 | "engines": { 524 | "node": ">=12" 525 | } 526 | }, 527 | "node_modules/@esbuild/win32-x64": { 528 | "version": "0.17.19", 529 | "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", 530 | "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", 531 | "cpu": [ 532 | "x64" 533 | ], 534 | "dev": true, 535 | "license": "MIT", 536 | "optional": true, 537 | "os": [ 538 | "win32" 539 | ], 540 | "engines": { 541 | "node": ">=12" 542 | } 543 | }, 544 | "node_modules/@fastify/busboy": { 545 | "version": "2.1.1", 546 | "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", 547 | "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", 548 | "dev": true, 549 | "license": "MIT", 550 | "engines": { 551 | "node": ">=14" 552 | } 553 | }, 554 | "node_modules/@jridgewell/resolve-uri": { 555 | "version": "3.1.2", 556 | "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", 557 | "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", 558 | "dev": true, 559 | "license": "MIT", 560 | "engines": { 561 | "node": ">=6.0.0" 562 | } 563 | }, 564 | "node_modules/@jridgewell/sourcemap-codec": { 565 | "version": "1.4.15", 566 | "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", 567 | "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", 568 | "dev": true, 569 | "license": "MIT" 570 | }, 571 | "node_modules/@jridgewell/trace-mapping": { 572 | "version": "0.3.9", 573 | "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", 574 | "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", 575 | "dev": true, 576 | "license": "MIT", 577 | "dependencies": { 578 | "@jridgewell/resolve-uri": "^3.0.3", 579 | "@jridgewell/sourcemap-codec": "^1.4.10" 580 | } 581 | }, 582 | "node_modules/@types/bcryptjs": { 583 | "version": "2.4.6", 584 | "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.6.tgz", 585 | "integrity": "sha512-9xlo6R2qDs5uixm0bcIqCeMCE6HiQsIyel9KQySStiyqNl2tnj2mP3DX1Nf56MD6KMenNNlBBsy3LJ7gUEQPXQ==", 586 | "dev": true, 587 | "license": "MIT" 588 | }, 589 | "node_modules/@types/crypto-js": { 590 | "version": "4.2.2", 591 | "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz", 592 | "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==", 593 | "dev": true, 594 | "license": "MIT" 595 | }, 596 | "node_modules/@types/js-yaml": { 597 | "version": "4.0.9", 598 | "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", 599 | "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", 600 | "dev": true, 601 | "license": "MIT" 602 | }, 603 | "node_modules/@types/node": { 604 | "version": "20.12.13", 605 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.13.tgz", 606 | "integrity": "sha512-gBGeanV41c1L171rR7wjbMiEpEI/l5XFQdLLfhr/REwpgDy/4U8y89+i8kRiLzDyZdOkXh+cRaTetUnCYutoXA==", 607 | "dev": true, 608 | "license": "MIT", 609 | "dependencies": { 610 | "undici-types": "~5.26.4" 611 | } 612 | }, 613 | "node_modules/@types/node-forge": { 614 | "version": "1.3.11", 615 | "resolved": "https://registry.npmjs.org/@types/node-forge/-/node-forge-1.3.11.tgz", 616 | "integrity": "sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==", 617 | "dev": true, 618 | "license": "MIT", 619 | "dependencies": { 620 | "@types/node": "*" 621 | } 622 | }, 623 | "node_modules/@types/uuid": { 624 | "version": "9.0.8", 625 | "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.8.tgz", 626 | "integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==", 627 | "dev": true, 628 | "license": "MIT" 629 | }, 630 | "node_modules/acorn": { 631 | "version": "8.11.3", 632 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", 633 | "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", 634 | "dev": true, 635 | "license": "MIT", 636 | "bin": { 637 | "acorn": "bin/acorn" 638 | }, 639 | "engines": { 640 | "node": ">=0.4.0" 641 | } 642 | }, 643 | "node_modules/acorn-walk": { 644 | "version": "8.3.2", 645 | "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", 646 | "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", 647 | "dev": true, 648 | "license": "MIT", 649 | "engines": { 650 | "node": ">=0.4.0" 651 | } 652 | }, 653 | "node_modules/anymatch": { 654 | "version": "3.1.3", 655 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", 656 | "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", 657 | "dev": true, 658 | "license": "ISC", 659 | "dependencies": { 660 | "normalize-path": "^3.0.0", 661 | "picomatch": "^2.0.4" 662 | }, 663 | "engines": { 664 | "node": ">= 8" 665 | } 666 | }, 667 | "node_modules/argparse": { 668 | "version": "2.0.1", 669 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 670 | "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", 671 | "license": "Python-2.0" 672 | }, 673 | "node_modules/as-table": { 674 | "version": "1.0.55", 675 | "resolved": "https://registry.npmjs.org/as-table/-/as-table-1.0.55.tgz", 676 | "integrity": "sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==", 677 | "dev": true, 678 | "license": "MIT", 679 | "dependencies": { 680 | "printable-characters": "^1.0.42" 681 | } 682 | }, 683 | "node_modules/base64-js": { 684 | "version": "1.5.1", 685 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", 686 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", 687 | "funding": [ 688 | { 689 | "type": "github", 690 | "url": "https://github.com/sponsors/feross" 691 | }, 692 | { 693 | "type": "patreon", 694 | "url": "https://www.patreon.com/feross" 695 | }, 696 | { 697 | "type": "consulting", 698 | "url": "https://feross.org/support" 699 | } 700 | ], 701 | "license": "MIT" 702 | }, 703 | "node_modules/bcryptjs": { 704 | "version": "2.4.3", 705 | "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", 706 | "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==", 707 | "license": "MIT" 708 | }, 709 | "node_modules/binary-extensions": { 710 | "version": "2.3.0", 711 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", 712 | "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", 713 | "dev": true, 714 | "license": "MIT", 715 | "engines": { 716 | "node": ">=8" 717 | }, 718 | "funding": { 719 | "url": "https://github.com/sponsors/sindresorhus" 720 | } 721 | }, 722 | "node_modules/blake3-wasm": { 723 | "version": "2.1.5", 724 | "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz", 725 | "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==", 726 | "dev": true, 727 | "license": "MIT" 728 | }, 729 | "node_modules/braces": { 730 | "version": "3.0.3", 731 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", 732 | "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", 733 | "dev": true, 734 | "license": "MIT", 735 | "dependencies": { 736 | "fill-range": "^7.1.1" 737 | }, 738 | "engines": { 739 | "node": ">=8" 740 | } 741 | }, 742 | "node_modules/buffer": { 743 | "version": "6.0.3", 744 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", 745 | "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", 746 | "funding": [ 747 | { 748 | "type": "github", 749 | "url": "https://github.com/sponsors/feross" 750 | }, 751 | { 752 | "type": "patreon", 753 | "url": "https://www.patreon.com/feross" 754 | }, 755 | { 756 | "type": "consulting", 757 | "url": "https://feross.org/support" 758 | } 759 | ], 760 | "license": "MIT", 761 | "dependencies": { 762 | "base64-js": "^1.3.1", 763 | "ieee754": "^1.2.1" 764 | } 765 | }, 766 | "node_modules/capnp-ts": { 767 | "version": "0.7.0", 768 | "resolved": "https://registry.npmjs.org/capnp-ts/-/capnp-ts-0.7.0.tgz", 769 | "integrity": "sha512-XKxXAC3HVPv7r674zP0VC3RTXz+/JKhfyw94ljvF80yynK6VkTnqE3jMuN8b3dUVmmc43TjyxjW4KTsmB3c86g==", 770 | "dev": true, 771 | "license": "MIT", 772 | "dependencies": { 773 | "debug": "^4.3.1", 774 | "tslib": "^2.2.0" 775 | } 776 | }, 777 | "node_modules/chokidar": { 778 | "version": "3.6.0", 779 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", 780 | "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", 781 | "dev": true, 782 | "license": "MIT", 783 | "dependencies": { 784 | "anymatch": "~3.1.2", 785 | "braces": "~3.0.2", 786 | "glob-parent": "~5.1.2", 787 | "is-binary-path": "~2.1.0", 788 | "is-glob": "~4.0.1", 789 | "normalize-path": "~3.0.0", 790 | "readdirp": "~3.6.0" 791 | }, 792 | "engines": { 793 | "node": ">= 8.10.0" 794 | }, 795 | "funding": { 796 | "url": "https://paulmillr.com/funding/" 797 | }, 798 | "optionalDependencies": { 799 | "fsevents": "~2.3.2" 800 | } 801 | }, 802 | "node_modules/cookie": { 803 | "version": "0.5.0", 804 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", 805 | "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", 806 | "dev": true, 807 | "license": "MIT", 808 | "engines": { 809 | "node": ">= 0.6" 810 | } 811 | }, 812 | "node_modules/crypto-js": { 813 | "version": "4.2.0", 814 | "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", 815 | "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", 816 | "license": "MIT" 817 | }, 818 | "node_modules/data-uri-to-buffer": { 819 | "version": "2.0.2", 820 | "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.2.tgz", 821 | "integrity": "sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==", 822 | "dev": true, 823 | "license": "MIT" 824 | }, 825 | "node_modules/debug": { 826 | "version": "4.3.5", 827 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", 828 | "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", 829 | "dev": true, 830 | "license": "MIT", 831 | "dependencies": { 832 | "ms": "2.1.2" 833 | }, 834 | "engines": { 835 | "node": ">=6.0" 836 | }, 837 | "peerDependenciesMeta": { 838 | "supports-color": { 839 | "optional": true 840 | } 841 | } 842 | }, 843 | "node_modules/esbuild": { 844 | "version": "0.17.19", 845 | "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", 846 | "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", 847 | "dev": true, 848 | "hasInstallScript": true, 849 | "license": "MIT", 850 | "bin": { 851 | "esbuild": "bin/esbuild" 852 | }, 853 | "engines": { 854 | "node": ">=12" 855 | }, 856 | "optionalDependencies": { 857 | "@esbuild/android-arm": "0.17.19", 858 | "@esbuild/android-arm64": "0.17.19", 859 | "@esbuild/android-x64": "0.17.19", 860 | "@esbuild/darwin-arm64": "0.17.19", 861 | "@esbuild/darwin-x64": "0.17.19", 862 | "@esbuild/freebsd-arm64": "0.17.19", 863 | "@esbuild/freebsd-x64": "0.17.19", 864 | "@esbuild/linux-arm": "0.17.19", 865 | "@esbuild/linux-arm64": "0.17.19", 866 | "@esbuild/linux-ia32": "0.17.19", 867 | "@esbuild/linux-loong64": "0.17.19", 868 | "@esbuild/linux-mips64el": "0.17.19", 869 | "@esbuild/linux-ppc64": "0.17.19", 870 | "@esbuild/linux-riscv64": "0.17.19", 871 | "@esbuild/linux-s390x": "0.17.19", 872 | "@esbuild/linux-x64": "0.17.19", 873 | "@esbuild/netbsd-x64": "0.17.19", 874 | "@esbuild/openbsd-x64": "0.17.19", 875 | "@esbuild/sunos-x64": "0.17.19", 876 | "@esbuild/win32-arm64": "0.17.19", 877 | "@esbuild/win32-ia32": "0.17.19", 878 | "@esbuild/win32-x64": "0.17.19" 879 | } 880 | }, 881 | "node_modules/escape-string-regexp": { 882 | "version": "4.0.0", 883 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", 884 | "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", 885 | "dev": true, 886 | "license": "MIT", 887 | "engines": { 888 | "node": ">=10" 889 | }, 890 | "funding": { 891 | "url": "https://github.com/sponsors/sindresorhus" 892 | } 893 | }, 894 | "node_modules/estree-walker": { 895 | "version": "0.6.1", 896 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", 897 | "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", 898 | "dev": true, 899 | "license": "MIT" 900 | }, 901 | "node_modules/exit-hook": { 902 | "version": "2.2.1", 903 | "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-2.2.1.tgz", 904 | "integrity": "sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==", 905 | "dev": true, 906 | "license": "MIT", 907 | "engines": { 908 | "node": ">=6" 909 | }, 910 | "funding": { 911 | "url": "https://github.com/sponsors/sindresorhus" 912 | } 913 | }, 914 | "node_modules/fill-range": { 915 | "version": "7.1.1", 916 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", 917 | "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", 918 | "dev": true, 919 | "license": "MIT", 920 | "dependencies": { 921 | "to-regex-range": "^5.0.1" 922 | }, 923 | "engines": { 924 | "node": ">=8" 925 | } 926 | }, 927 | "node_modules/fsevents": { 928 | "version": "2.3.3", 929 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", 930 | "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", 931 | "dev": true, 932 | "hasInstallScript": true, 933 | "license": "MIT", 934 | "optional": true, 935 | "os": [ 936 | "darwin" 937 | ], 938 | "engines": { 939 | "node": "^8.16.0 || ^10.6.0 || >=11.0.0" 940 | } 941 | }, 942 | "node_modules/function-bind": { 943 | "version": "1.1.2", 944 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", 945 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", 946 | "dev": true, 947 | "license": "MIT", 948 | "funding": { 949 | "url": "https://github.com/sponsors/ljharb" 950 | } 951 | }, 952 | "node_modules/get-source": { 953 | "version": "2.0.12", 954 | "resolved": "https://registry.npmjs.org/get-source/-/get-source-2.0.12.tgz", 955 | "integrity": "sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w==", 956 | "dev": true, 957 | "license": "Unlicense", 958 | "dependencies": { 959 | "data-uri-to-buffer": "^2.0.0", 960 | "source-map": "^0.6.1" 961 | } 962 | }, 963 | "node_modules/glob-parent": { 964 | "version": "5.1.2", 965 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 966 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 967 | "dev": true, 968 | "license": "ISC", 969 | "dependencies": { 970 | "is-glob": "^4.0.1" 971 | }, 972 | "engines": { 973 | "node": ">= 6" 974 | } 975 | }, 976 | "node_modules/glob-to-regexp": { 977 | "version": "0.4.1", 978 | "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", 979 | "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", 980 | "dev": true, 981 | "license": "BSD-2-Clause" 982 | }, 983 | "node_modules/hasown": { 984 | "version": "2.0.2", 985 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", 986 | "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", 987 | "dev": true, 988 | "license": "MIT", 989 | "dependencies": { 990 | "function-bind": "^1.1.2" 991 | }, 992 | "engines": { 993 | "node": ">= 0.4" 994 | } 995 | }, 996 | "node_modules/ieee754": { 997 | "version": "1.2.1", 998 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", 999 | "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", 1000 | "funding": [ 1001 | { 1002 | "type": "github", 1003 | "url": "https://github.com/sponsors/feross" 1004 | }, 1005 | { 1006 | "type": "patreon", 1007 | "url": "https://www.patreon.com/feross" 1008 | }, 1009 | { 1010 | "type": "consulting", 1011 | "url": "https://feross.org/support" 1012 | } 1013 | ], 1014 | "license": "BSD-3-Clause" 1015 | }, 1016 | "node_modules/is-binary-path": { 1017 | "version": "2.1.0", 1018 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", 1019 | "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", 1020 | "dev": true, 1021 | "license": "MIT", 1022 | "dependencies": { 1023 | "binary-extensions": "^2.0.0" 1024 | }, 1025 | "engines": { 1026 | "node": ">=8" 1027 | } 1028 | }, 1029 | "node_modules/is-core-module": { 1030 | "version": "2.13.1", 1031 | "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", 1032 | "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", 1033 | "dev": true, 1034 | "license": "MIT", 1035 | "dependencies": { 1036 | "hasown": "^2.0.0" 1037 | }, 1038 | "funding": { 1039 | "url": "https://github.com/sponsors/ljharb" 1040 | } 1041 | }, 1042 | "node_modules/is-extglob": { 1043 | "version": "2.1.1", 1044 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 1045 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 1046 | "dev": true, 1047 | "license": "MIT", 1048 | "engines": { 1049 | "node": ">=0.10.0" 1050 | } 1051 | }, 1052 | "node_modules/is-glob": { 1053 | "version": "4.0.3", 1054 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 1055 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 1056 | "dev": true, 1057 | "license": "MIT", 1058 | "dependencies": { 1059 | "is-extglob": "^2.1.1" 1060 | }, 1061 | "engines": { 1062 | "node": ">=0.10.0" 1063 | } 1064 | }, 1065 | "node_modules/is-number": { 1066 | "version": "7.0.0", 1067 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 1068 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 1069 | "dev": true, 1070 | "license": "MIT", 1071 | "engines": { 1072 | "node": ">=0.12.0" 1073 | } 1074 | }, 1075 | "node_modules/js-yaml": { 1076 | "version": "4.1.0", 1077 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", 1078 | "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", 1079 | "license": "MIT", 1080 | "dependencies": { 1081 | "argparse": "^2.0.1" 1082 | }, 1083 | "bin": { 1084 | "js-yaml": "bin/js-yaml.js" 1085 | } 1086 | }, 1087 | "node_modules/magic-string": { 1088 | "version": "0.25.9", 1089 | "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", 1090 | "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", 1091 | "dev": true, 1092 | "license": "MIT", 1093 | "dependencies": { 1094 | "sourcemap-codec": "^1.4.8" 1095 | } 1096 | }, 1097 | "node_modules/mime": { 1098 | "version": "3.0.0", 1099 | "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", 1100 | "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", 1101 | "dev": true, 1102 | "license": "MIT", 1103 | "bin": { 1104 | "mime": "cli.js" 1105 | }, 1106 | "engines": { 1107 | "node": ">=10.0.0" 1108 | } 1109 | }, 1110 | "node_modules/miniflare": { 1111 | "version": "3.20240524.0", 1112 | "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20240524.0.tgz", 1113 | "integrity": "sha512-RQAfpz7spI6gWlczeUYvJBgGyt0gNR2pYoCydgukCYZ+0bGfJl0yAiNFW62uH7uMZli/4juWPpQOBI5m7URoyA==", 1114 | "dev": true, 1115 | "license": "MIT", 1116 | "dependencies": { 1117 | "@cspotcode/source-map-support": "0.8.1", 1118 | "acorn": "^8.8.0", 1119 | "acorn-walk": "^8.2.0", 1120 | "capnp-ts": "^0.7.0", 1121 | "exit-hook": "^2.2.1", 1122 | "glob-to-regexp": "^0.4.1", 1123 | "stoppable": "^1.1.0", 1124 | "undici": "^5.28.2", 1125 | "workerd": "1.20240524.0", 1126 | "ws": "^8.11.0", 1127 | "youch": "^3.2.2", 1128 | "zod": "^3.20.6" 1129 | }, 1130 | "bin": { 1131 | "miniflare": "bootstrap.js" 1132 | }, 1133 | "engines": { 1134 | "node": ">=16.13" 1135 | } 1136 | }, 1137 | "node_modules/ms": { 1138 | "version": "2.1.2", 1139 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 1140 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 1141 | "dev": true, 1142 | "license": "MIT" 1143 | }, 1144 | "node_modules/mustache": { 1145 | "version": "4.2.0", 1146 | "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", 1147 | "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", 1148 | "dev": true, 1149 | "license": "MIT", 1150 | "bin": { 1151 | "mustache": "bin/mustache" 1152 | } 1153 | }, 1154 | "node_modules/nanoid": { 1155 | "version": "3.3.7", 1156 | "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", 1157 | "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", 1158 | "dev": true, 1159 | "funding": [ 1160 | { 1161 | "type": "github", 1162 | "url": "https://github.com/sponsors/ai" 1163 | } 1164 | ], 1165 | "license": "MIT", 1166 | "bin": { 1167 | "nanoid": "bin/nanoid.cjs" 1168 | }, 1169 | "engines": { 1170 | "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" 1171 | } 1172 | }, 1173 | "node_modules/node-forge": { 1174 | "version": "1.3.1", 1175 | "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", 1176 | "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", 1177 | "dev": true, 1178 | "license": "(BSD-3-Clause OR GPL-2.0)", 1179 | "engines": { 1180 | "node": ">= 6.13.0" 1181 | } 1182 | }, 1183 | "node_modules/normalize-path": { 1184 | "version": "3.0.0", 1185 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", 1186 | "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", 1187 | "dev": true, 1188 | "license": "MIT", 1189 | "engines": { 1190 | "node": ">=0.10.0" 1191 | } 1192 | }, 1193 | "node_modules/path-parse": { 1194 | "version": "1.0.7", 1195 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", 1196 | "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", 1197 | "dev": true, 1198 | "license": "MIT" 1199 | }, 1200 | "node_modules/path-to-regexp": { 1201 | "version": "6.2.2", 1202 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.2.tgz", 1203 | "integrity": "sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==", 1204 | "dev": true, 1205 | "license": "MIT" 1206 | }, 1207 | "node_modules/picomatch": { 1208 | "version": "2.3.1", 1209 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 1210 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 1211 | "dev": true, 1212 | "license": "MIT", 1213 | "engines": { 1214 | "node": ">=8.6" 1215 | }, 1216 | "funding": { 1217 | "url": "https://github.com/sponsors/jonschlinkert" 1218 | } 1219 | }, 1220 | "node_modules/printable-characters": { 1221 | "version": "1.0.42", 1222 | "resolved": "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.42.tgz", 1223 | "integrity": "sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==", 1224 | "dev": true, 1225 | "license": "Unlicense" 1226 | }, 1227 | "node_modules/readdirp": { 1228 | "version": "3.6.0", 1229 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", 1230 | "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", 1231 | "dev": true, 1232 | "license": "MIT", 1233 | "dependencies": { 1234 | "picomatch": "^2.2.1" 1235 | }, 1236 | "engines": { 1237 | "node": ">=8.10.0" 1238 | } 1239 | }, 1240 | "node_modules/resolve": { 1241 | "version": "1.22.8", 1242 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", 1243 | "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", 1244 | "dev": true, 1245 | "license": "MIT", 1246 | "dependencies": { 1247 | "is-core-module": "^2.13.0", 1248 | "path-parse": "^1.0.7", 1249 | "supports-preserve-symlinks-flag": "^1.0.0" 1250 | }, 1251 | "bin": { 1252 | "resolve": "bin/resolve" 1253 | }, 1254 | "funding": { 1255 | "url": "https://github.com/sponsors/ljharb" 1256 | } 1257 | }, 1258 | "node_modules/resolve.exports": { 1259 | "version": "2.0.2", 1260 | "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", 1261 | "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", 1262 | "dev": true, 1263 | "license": "MIT", 1264 | "engines": { 1265 | "node": ">=10" 1266 | } 1267 | }, 1268 | "node_modules/rollup-plugin-inject": { 1269 | "version": "3.0.2", 1270 | "resolved": "https://registry.npmjs.org/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz", 1271 | "integrity": "sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==", 1272 | "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.", 1273 | "dev": true, 1274 | "license": "MIT", 1275 | "dependencies": { 1276 | "estree-walker": "^0.6.1", 1277 | "magic-string": "^0.25.3", 1278 | "rollup-pluginutils": "^2.8.1" 1279 | } 1280 | }, 1281 | "node_modules/rollup-plugin-node-polyfills": { 1282 | "version": "0.2.1", 1283 | "resolved": "https://registry.npmjs.org/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz", 1284 | "integrity": "sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA==", 1285 | "dev": true, 1286 | "license": "MIT", 1287 | "dependencies": { 1288 | "rollup-plugin-inject": "^3.0.0" 1289 | } 1290 | }, 1291 | "node_modules/rollup-pluginutils": { 1292 | "version": "2.8.2", 1293 | "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", 1294 | "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", 1295 | "dev": true, 1296 | "license": "MIT", 1297 | "dependencies": { 1298 | "estree-walker": "^0.6.1" 1299 | } 1300 | }, 1301 | "node_modules/selfsigned": { 1302 | "version": "2.4.1", 1303 | "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.4.1.tgz", 1304 | "integrity": "sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q==", 1305 | "dev": true, 1306 | "license": "MIT", 1307 | "dependencies": { 1308 | "@types/node-forge": "^1.3.0", 1309 | "node-forge": "^1" 1310 | }, 1311 | "engines": { 1312 | "node": ">=10" 1313 | } 1314 | }, 1315 | "node_modules/source-map": { 1316 | "version": "0.6.1", 1317 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 1318 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 1319 | "dev": true, 1320 | "license": "BSD-3-Clause", 1321 | "engines": { 1322 | "node": ">=0.10.0" 1323 | } 1324 | }, 1325 | "node_modules/sourcemap-codec": { 1326 | "version": "1.4.8", 1327 | "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", 1328 | "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", 1329 | "deprecated": "Please use @jridgewell/sourcemap-codec instead", 1330 | "dev": true, 1331 | "license": "MIT" 1332 | }, 1333 | "node_modules/stacktracey": { 1334 | "version": "2.1.8", 1335 | "resolved": "https://registry.npmjs.org/stacktracey/-/stacktracey-2.1.8.tgz", 1336 | "integrity": "sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw==", 1337 | "dev": true, 1338 | "license": "Unlicense", 1339 | "dependencies": { 1340 | "as-table": "^1.0.36", 1341 | "get-source": "^2.0.12" 1342 | } 1343 | }, 1344 | "node_modules/stoppable": { 1345 | "version": "1.1.0", 1346 | "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", 1347 | "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", 1348 | "dev": true, 1349 | "license": "MIT", 1350 | "engines": { 1351 | "node": ">=4", 1352 | "npm": ">=6" 1353 | } 1354 | }, 1355 | "node_modules/supports-preserve-symlinks-flag": { 1356 | "version": "1.0.0", 1357 | "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", 1358 | "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", 1359 | "dev": true, 1360 | "license": "MIT", 1361 | "engines": { 1362 | "node": ">= 0.4" 1363 | }, 1364 | "funding": { 1365 | "url": "https://github.com/sponsors/ljharb" 1366 | } 1367 | }, 1368 | "node_modules/to-regex-range": { 1369 | "version": "5.0.1", 1370 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 1371 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 1372 | "dev": true, 1373 | "license": "MIT", 1374 | "dependencies": { 1375 | "is-number": "^7.0.0" 1376 | }, 1377 | "engines": { 1378 | "node": ">=8.0" 1379 | } 1380 | }, 1381 | "node_modules/tslib": { 1382 | "version": "2.6.2", 1383 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", 1384 | "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", 1385 | "dev": true, 1386 | "license": "0BSD" 1387 | }, 1388 | "node_modules/typescript": { 1389 | "version": "5.4.5", 1390 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", 1391 | "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", 1392 | "dev": true, 1393 | "license": "Apache-2.0", 1394 | "bin": { 1395 | "tsc": "bin/tsc", 1396 | "tsserver": "bin/tsserver" 1397 | }, 1398 | "engines": { 1399 | "node": ">=14.17" 1400 | } 1401 | }, 1402 | "node_modules/undici": { 1403 | "version": "5.28.4", 1404 | "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", 1405 | "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", 1406 | "dev": true, 1407 | "license": "MIT", 1408 | "dependencies": { 1409 | "@fastify/busboy": "^2.0.0" 1410 | }, 1411 | "engines": { 1412 | "node": ">=14.0" 1413 | } 1414 | }, 1415 | "node_modules/undici-types": { 1416 | "version": "5.26.5", 1417 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 1418 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", 1419 | "dev": true, 1420 | "license": "MIT" 1421 | }, 1422 | "node_modules/uuid": { 1423 | "version": "9.0.1", 1424 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", 1425 | "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", 1426 | "funding": [ 1427 | "https://github.com/sponsors/broofa", 1428 | "https://github.com/sponsors/ctavan" 1429 | ], 1430 | "license": "MIT", 1431 | "bin": { 1432 | "uuid": "dist/bin/uuid" 1433 | } 1434 | }, 1435 | "node_modules/workerd": { 1436 | "version": "1.20240524.0", 1437 | "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20240524.0.tgz", 1438 | "integrity": "sha512-LWLe5D8PVHBcqturmBbwgI71r7YPpIMYZoVEH6S4G35EqIJ55cb0n3FipoSyraoIfpcCxCFxX1K6WsRHbP3pFA==", 1439 | "dev": true, 1440 | "hasInstallScript": true, 1441 | "license": "Apache-2.0", 1442 | "bin": { 1443 | "workerd": "bin/workerd" 1444 | }, 1445 | "engines": { 1446 | "node": ">=16" 1447 | }, 1448 | "optionalDependencies": { 1449 | "@cloudflare/workerd-darwin-64": "1.20240524.0", 1450 | "@cloudflare/workerd-darwin-arm64": "1.20240524.0", 1451 | "@cloudflare/workerd-linux-64": "1.20240524.0", 1452 | "@cloudflare/workerd-linux-arm64": "1.20240524.0", 1453 | "@cloudflare/workerd-windows-64": "1.20240524.0" 1454 | } 1455 | }, 1456 | "node_modules/wrangler": { 1457 | "version": "3.57.2", 1458 | "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.57.2.tgz", 1459 | "integrity": "sha512-QegYf0FW+4prlFKE9iHr1EGrCo8ejcGL9gaqEXrzQ0vbTdazykYbY0I5UpHFLNq2dIF9I/ifEoLRKr636tyHEw==", 1460 | "dev": true, 1461 | "license": "MIT OR Apache-2.0", 1462 | "dependencies": { 1463 | "@cloudflare/kv-asset-handler": "0.3.2", 1464 | "@esbuild-plugins/node-globals-polyfill": "^0.2.3", 1465 | "@esbuild-plugins/node-modules-polyfill": "^0.2.2", 1466 | "blake3-wasm": "^2.1.5", 1467 | "chokidar": "^3.5.3", 1468 | "esbuild": "0.17.19", 1469 | "miniflare": "3.20240524.0", 1470 | "nanoid": "^3.3.3", 1471 | "path-to-regexp": "^6.2.0", 1472 | "resolve": "^1.22.8", 1473 | "resolve.exports": "^2.0.2", 1474 | "selfsigned": "^2.0.1", 1475 | "source-map": "0.6.1", 1476 | "xxhash-wasm": "^1.0.1" 1477 | }, 1478 | "bin": { 1479 | "wrangler": "bin/wrangler.js", 1480 | "wrangler2": "bin/wrangler.js" 1481 | }, 1482 | "engines": { 1483 | "node": ">=16.17.0" 1484 | }, 1485 | "optionalDependencies": { 1486 | "fsevents": "~2.3.2" 1487 | }, 1488 | "peerDependencies": { 1489 | "@cloudflare/workers-types": "^4.20240524.0" 1490 | }, 1491 | "peerDependenciesMeta": { 1492 | "@cloudflare/workers-types": { 1493 | "optional": true 1494 | } 1495 | } 1496 | }, 1497 | "node_modules/ws": { 1498 | "version": "8.17.0", 1499 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz", 1500 | "integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==", 1501 | "dev": true, 1502 | "license": "MIT", 1503 | "engines": { 1504 | "node": ">=10.0.0" 1505 | }, 1506 | "peerDependencies": { 1507 | "bufferutil": "^4.0.1", 1508 | "utf-8-validate": ">=5.0.2" 1509 | }, 1510 | "peerDependenciesMeta": { 1511 | "bufferutil": { 1512 | "optional": true 1513 | }, 1514 | "utf-8-validate": { 1515 | "optional": true 1516 | } 1517 | } 1518 | }, 1519 | "node_modules/xxhash-wasm": { 1520 | "version": "1.0.2", 1521 | "resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.0.2.tgz", 1522 | "integrity": "sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A==", 1523 | "dev": true, 1524 | "license": "MIT" 1525 | }, 1526 | "node_modules/youch": { 1527 | "version": "3.3.3", 1528 | "resolved": "https://registry.npmjs.org/youch/-/youch-3.3.3.tgz", 1529 | "integrity": "sha512-qSFXUk3UZBLfggAW3dJKg0BMblG5biqSF8M34E06o5CSsZtH92u9Hqmj2RzGiHDi64fhe83+4tENFP2DB6t6ZA==", 1530 | "dev": true, 1531 | "license": "MIT", 1532 | "dependencies": { 1533 | "cookie": "^0.5.0", 1534 | "mustache": "^4.2.0", 1535 | "stacktracey": "^2.1.8" 1536 | } 1537 | }, 1538 | "node_modules/zod": { 1539 | "version": "3.23.8", 1540 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", 1541 | "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", 1542 | "dev": true, 1543 | "license": "MIT", 1544 | "funding": { 1545 | "url": "https://github.com/sponsors/colinhacks" 1546 | } 1547 | } 1548 | } 1549 | } 1550 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "v2ray-worker", 3 | "version": "2.4", 4 | "author": { 5 | "name": "Vahid Farid" 6 | }, 7 | "private": true, 8 | "scripts": { 9 | "deploy": "wrangler deploy", 10 | "start": "wrangler dev" 11 | }, 12 | "devDependencies": { 13 | "@cloudflare/workers-types": "^4.20240529.0", 14 | "@types/bcryptjs": "^2.4.6", 15 | "@types/crypto-js": "^4.2.2", 16 | "@types/js-yaml": "^4.0.9", 17 | "@types/node": "^20.12.13", 18 | "@types/uuid": "^9.0.8", 19 | "typescript": "^5.0.4", 20 | "wrangler": "^3.57.2" 21 | }, 22 | "dependencies": { 23 | "bcryptjs": "^2.4.3", 24 | "buffer": "^6.0.3", 25 | "crypto-js": "^4.2.0", 26 | "js-yaml": "^4.1.0", 27 | "uuid": "^9.0.1" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /resources/provider-list.txt: -------------------------------------------------------------------------------- 1 | https://raw.githubusercontent.com/mahdibland/V2RayAggregator/master/sub/list/00.txt 2 | https://raw.githubusercontent.com/Leon406/SubCrawler/main/sub/share/all4 3 | https://raw.githubusercontent.com/mfuu/v2ray/master/clash.yaml 4 | https://raw.githubusercontent.com/peasoft/NoMoreWalls/master/list.yml 5 | https://raw.githubusercontent.com/a2470982985/getNode/main/clash.yaml 6 | https://raw.githubusercontent.com/mlabalabala/v2ray-node/main/nodefree4clash.txt 7 | https://raw.githubusercontent.com/mahdibland/V2RayAggregator/master/sub/sub_merge.txt 8 | https://raw.githubusercontent.com/mfuu/v2ray/master/v2ray -------------------------------------------------------------------------------- /resources/proxy-list.txt: -------------------------------------------------------------------------------- 1 | ni.radically.pro,USA 2 | usa.revil.link,USA 3 | 152.67.9.19,IND 4 | 193.123.81.105,UAE 5 | 139.185.34.131,UAE 6 | 43.153.80.208,USA 7 | proxyip.us.hw.090227.xyz,USA 8 | proxyip.digitalocean.hw.090227.xyz,USA 9 | proxyip.oracle.fxxk.dedyn.io,USA 10 | 156.146.53.83,USA 11 | 99.83.209.185,USA 12 | 62.3.12.185,TUR 13 | 192.237.192.175,USA 14 | 72.13.122.137,USA 15 | 140.238.64.65,GBR 16 | 146.70.175.162,NLD 17 | 143.47.227.123,NLD 18 | 132.226.10.65,JPN 19 | 152.70.86.93,JPN 20 | 152.69.178.16,AUS 21 | 192.9.177.204,AUS 22 | 140.238.195.98,AUS 23 | 47.236.203.169,SGP 24 | 8.219.174.142,SGP 25 | ircpipproxy.duckdns.org,UK 26 | ipdb.rr.nu 27 | cdn-all.xn--b6gac.eu.org 28 | cdn.xn--b6gac.eu.org 29 | edgetunnel.anycast.eu.org,SGP 30 | proxyip.aliyun.fxxk.dedyn.io,USA 31 | proxyip.vultr.fxxk.dedyn.io,USA 32 | proxyip.multacom.fxxk.dedyn.io,USA 33 | -------------------------------------------------------------------------------- /src/auth.ts: -------------------------------------------------------------------------------- 1 | import * as bcrypt from 'bcryptjs' 2 | import { GenerateToken, Delay } from "./helpers" 3 | import { Env } from "./interfaces" 4 | import { version } from "./variables" 5 | 6 | export async function GetLogin(request: Request, env: Env): Promise { 7 | const url: URL = new URL(request.url) 8 | let htmlMessage = "" 9 | const message = url.searchParams.get("message") 10 | if (message == "error") { 11 | htmlMessage = `
Invalid password / کلمه عبور معتبر نمی‌باشد!
` 12 | } 13 | 14 | const htmlContent = ` 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 |
24 |
V2RAY Worker - Control Panel
25 |
26 | Version ${version} 27 |
28 |
29 | ${htmlMessage} 30 |
31 |
32 | Enter password / کلمه‌ی عبور را وارد کنید: 33 |
34 |
35 | 36 | 37 |
38 |
39 | 40 |
41 |
42 |
43 | 44 | 45 | ` 46 | 47 | return new Response(htmlContent, { 48 | headers: {"Content-Type": "text/html"}, 49 | }) 50 | } 51 | 52 | export async function PostLogin(request: Request, env: Env): Promise { 53 | const url: URL = new URL(request.url) 54 | const formData = await request.formData() 55 | const password: string = formData.get("password") || "" 56 | let hashedPassword: string = await env.settings.get("Password") || "" 57 | 58 | await Delay(1000) 59 | 60 | const match = await bcrypt.compare(password, hashedPassword) 61 | 62 | if (match) { 63 | const token: string = GenerateToken(24) 64 | await env.settings.put("Token", token) 65 | return Response.redirect(`${url.protocol}//${url.hostname}${url.port != "443" ? ":" + url.port : ""}/?token=${token}`, 302) 66 | } 67 | 68 | return Response.redirect(`${url.protocol}//${url.hostname}${url.port != "443" ? ":" + url.port : ""}/login?message=error`, 302) 69 | } 70 | -------------------------------------------------------------------------------- /src/clash.ts: -------------------------------------------------------------------------------- 1 | import yaml from 'js-yaml' 2 | import { defaultClashConfig } from "./variables" 3 | import { Config, ClashConfig } from './interfaces'; 4 | 5 | export function ToYamlSubscription(configList: Array): string { 6 | let clash = defaultClashConfig 7 | clash.proxies = configList.map((conf: Config) => { 8 | let { 9 | configType, 10 | type, 11 | remarks, 12 | address, 13 | tls, 14 | alpn, 15 | merged, 16 | ...rest 17 | } = conf 18 | if (conf.type) { 19 | rest.network = conf.type 20 | } 21 | let config: ClashConfig = { 22 | name: conf.remarks, 23 | server: conf.address, 24 | type: conf.configType, 25 | tls: conf.tls == "tls", 26 | cipher: "auto", 27 | ...rest 28 | } 29 | return config 30 | }) 31 | let proxyTiers: { 32 | "All": Array, 33 | "Built-in": Array, 34 | "Merged": Array, 35 | "Original": Array, 36 | } = { 37 | "All": [], 38 | "Built-in": [], 39 | "Merged": [], 40 | "Original": [], 41 | } 42 | configList.forEach((conf: Config) => { 43 | const grp = ["vless-ws", "trojan-ws"].includes(conf.path.split("?")[0].split("/")[0]) ? "Built-in" : (conf?.merged ? 'Merged' : 'Original') 44 | proxyTiers[grp].push(conf.remarks) 45 | proxyTiers["All"].push(conf.remarks) 46 | }); 47 | 48 | clash['proxy-groups'] = [ 49 | { 50 | name: "All", 51 | type: "select", 52 | proxies: [ 53 | "All - UrlTest", 54 | "All - Fallback", 55 | "All - LoadBalance(ch)", 56 | "All - LoadBalance(rr)", 57 | "Built-in - UrlTest", 58 | "Merged - UrlTest", 59 | "Original - UrlTest", 60 | ].concat(proxyTiers["All"]), 61 | }, 62 | { 63 | name: "All - UrlTest", 64 | type: "url-test", 65 | url: "http://clients3.google.com/generate_204", 66 | interval: 600, 67 | proxies: proxyTiers["All"], 68 | }, 69 | { 70 | name: "All - Fallback", 71 | type: "fallback", 72 | url: "http://clients3.google.com/generate_204", 73 | interval: 600, 74 | proxies: proxyTiers["All"], 75 | }, 76 | { 77 | name: "All - LoadBalance(ch)", 78 | type: "load-balance", 79 | strategy: "consistent-hashing", 80 | url: "http://clients3.google.com/generate_204", 81 | interval: 600, 82 | proxies: proxyTiers["All"], 83 | }, 84 | { 85 | name: "All - LoadBalance(rr)", 86 | type: "load-balance", 87 | strategy: "round-robin", 88 | url: "http://clients3.google.com/generate_204", 89 | interval: 600, 90 | proxies: proxyTiers["All"], 91 | }, 92 | { 93 | name: "Built-in - UrlTest", 94 | type: "url-test", 95 | url: "http://clients3.google.com/generate_204", 96 | interval: 600, 97 | proxies: proxyTiers["Built-in"], 98 | }, 99 | { 100 | name: "Merged - UrlTest", 101 | type: "url-test", 102 | url: "http://clients3.google.com/generate_204", 103 | interval: 600, 104 | proxies: proxyTiers["Merged"], 105 | }, 106 | { 107 | name: "Original - UrlTest", 108 | type: "url-test", 109 | url: "http://clients3.google.com/generate_204", 110 | interval: 600, 111 | proxies: proxyTiers["Original"], 112 | }, 113 | ] 114 | 115 | return yaml.dump(clash) 116 | } -------------------------------------------------------------------------------- /src/collector.ts: -------------------------------------------------------------------------------- 1 | import yaml from 'js-yaml' 2 | import { Buffer } from 'buffer' 3 | import { GetVlessConfigList } from './vless' 4 | import { GetTrojanConfigList } from './trojan' 5 | import { MixConfig, ValidateConfig, DecodeConfig } from "./config" 6 | import { GetMultipleRandomElements, RemoveDuplicateConfigs, AddNumberToConfigs, IsBase64, MuddleDomain } from "./helpers" 7 | import { version, providersUri, defaultProtocols, defaultALPNList, defaultPFList, fragmentsLengthList, fragmentsIntervalList } from "./variables" 8 | import { Env, Config } from "./interfaces" 9 | 10 | 11 | export async function GetConfigList(url: URL, env: Env): Promise> { 12 | let maxConfigs: number = 200 13 | const maxBuiltInConfigsPerType: number = 20 14 | let protocols: Array = [] 15 | let providers: Array = [] 16 | let alpnList: Array = [] 17 | let fingerPrints: Array = [] 18 | let includeOriginalConfigs: boolean = true 19 | let includeMergedConfigs: boolean = true 20 | let cleanDomainIPs: Array = [] 21 | let myConfigs: Array = [] 22 | let settingsNotAvailable: boolean = true 23 | let enableFragments = false 24 | 25 | try { 26 | maxConfigs = parseInt(await env.settings.get("MaxConfigs") || "200") 27 | const settingsVersion = await env.settings.get("Version") || "2.0" 28 | if (settingsVersion == version) { 29 | protocols = await env.settings.get("Protocols").then(val => {return val ? val.split("\n") : []}) 30 | } 31 | const blockPorn = await env.settings.get("BlockPorn") == "yes" 32 | const limitCountries = ((await env.settings.get("Countries")) || "").trim().length > 0 33 | 34 | if (blockPorn) { 35 | protocols = ["built-in-vless"] 36 | maxConfigs = maxBuiltInConfigsPerType 37 | } else if (limitCountries) { 38 | protocols = ["built-in-vless", "built-in-trojan"] 39 | maxConfigs = maxBuiltInConfigsPerType * 2 40 | } 41 | 42 | providers = (await env.settings.get("Providers"))?.split("\n").filter(t => t.trim().length > 0) || [] 43 | myConfigs = (await env.settings.get("Configs"))?.split("\n").filter(t => t.trim().length > 0) || [] 44 | alpnList = (await env.settings.get("ALPNs"))?.split("\n").filter(t => t.trim().length > 0) || [] 45 | fingerPrints = (await env.settings.get("FingerPrints"))?.split("\n").filter(t => t.trim().length > 0) || [] 46 | includeOriginalConfigs = (await env.settings.get("IncludeOriginalConfigs") || "yes") == "yes" 47 | includeMergedConfigs = ((await env.settings.get("IncludeMergedConfigs") || "yes") == "yes") && (protocols.includes("vmess") || protocols.includes("vless") || myConfigs.length > 0) 48 | cleanDomainIPs = (await env.settings.get("CleanDomainIPs"))?.split("\n").filter(t => t.trim().length > 0) || [] 49 | settingsNotAvailable = (await env.settings.get("MaxConfigs")) === null 50 | enableFragments = await env.settings.get("EnableFragments") == "yes" 51 | } catch { } 52 | 53 | if (!protocols.length && !myConfigs) { 54 | protocols = defaultProtocols 55 | } 56 | 57 | alpnList = alpnList.length ? alpnList : defaultALPNList 58 | fingerPrints = fingerPrints.length ? fingerPrints : defaultPFList 59 | cleanDomainIPs = cleanDomainIPs.length ? cleanDomainIPs : [MuddleDomain(url.hostname)] 60 | 61 | if (protocols.includes("built-in-vless")) { 62 | maxConfigs = maxConfigs - maxBuiltInConfigsPerType 63 | } 64 | if (protocols.includes("built-in-trojan")) { 65 | maxConfigs = maxConfigs - maxBuiltInConfigsPerType 66 | } 67 | 68 | if (settingsNotAvailable) { 69 | includeOriginalConfigs = true 70 | includeMergedConfigs = true 71 | } 72 | if (!providers.length) { 73 | providers = await fetch(providersUri).then(r => r.text()).then(t => t.trim().split("\n").filter(t => t.trim().length > 0)) 74 | } 75 | 76 | if (includeOriginalConfigs && includeMergedConfigs) { 77 | maxConfigs = Math.floor(maxConfigs / 2) 78 | } 79 | 80 | let configList: Array = [] 81 | let acceptableConfigList: Array = [] 82 | let finalConfigList: Array = [] 83 | let newConfigs: Array = [] 84 | const configPerList: number = Math.floor(maxConfigs / Object.keys(providers).length) 85 | 86 | for (const providerUrl of providers) { 87 | try { 88 | var content: string = await fetch(providerUrl).then(r => r.text()) 89 | try { 90 | const json: any = yaml.load(content) 91 | newConfigs = json.proxies; 92 | if (!newConfigs.length) { 93 | throw "no-yaml" 94 | } 95 | newConfigs = newConfigs.filter((cnf: any) => protocols.includes(cnf.type)).filter(ValidateConfig) 96 | } catch (e) { 97 | if (IsBase64(content)) { 98 | content = Buffer.from(content, "base64").toString("utf-8") 99 | } 100 | newConfigs = content.split("\n").filter((cnf: string) => cnf.match(new RegExp(`^(${protocols.join("|")}):\/\/`, "i"))) 101 | if (newConfigs.length) { 102 | newConfigs = newConfigs.map(DecodeConfig).filter(ValidateConfig) 103 | } 104 | } 105 | if (includeMergedConfigs) { 106 | acceptableConfigList.push({ 107 | url: providerUrl, 108 | count: configPerList, 109 | configs: newConfigs.filter((cnf: any) => ["vmess", "vless"].includes(cnf.configType)), 110 | mergedConfigs: null, 111 | }) 112 | } 113 | if (includeOriginalConfigs) { 114 | configList.push({ 115 | url: providerUrl, 116 | count: configPerList, 117 | configs: newConfigs, 118 | }) 119 | } 120 | } catch (e) { } 121 | } 122 | 123 | if (!cleanDomainIPs.length) { 124 | cleanDomainIPs = [MuddleDomain(url.hostname)] 125 | } 126 | 127 | let address: string = cleanDomainIPs[Math.floor(Math.random() * cleanDomainIPs.length)] 128 | for (const i in acceptableConfigList) { 129 | const el: any = acceptableConfigList[i] 130 | acceptableConfigList[i].mergedConfigs = el.configs 131 | .map((cnf: any) => MixConfig(cnf, url, address, el.name)) 132 | .filter((cnf: any) => cnf?.merged && cnf?.remarks) 133 | } 134 | 135 | let remaining: number = 0 136 | for (let i: number = 0; i < 5; i++) { 137 | for (const el of acceptableConfigList) { 138 | if (el.count > el.mergedConfigs.length) { 139 | remaining = remaining + el.count - el.mergedConfigs.length 140 | el.count = el.mergedConfigs.length 141 | } else if (el.count < el.mergedConfigs.length && remaining > 0) { 142 | el.count = el.count + Math.ceil(remaining / 3) 143 | remaining = remaining - Math.ceil(remaining / 3) 144 | } 145 | } 146 | } 147 | 148 | for (const el of acceptableConfigList) { 149 | finalConfigList = finalConfigList.concat( 150 | GetMultipleRandomElements(el.mergedConfigs, el.count) 151 | ) 152 | } 153 | 154 | if (includeOriginalConfigs) { 155 | let remaining = 0 156 | for (let i = 0; i < 5; i++) { 157 | for (const el of configList) { 158 | if (el.count > el.configs.length) { 159 | remaining = remaining + el.count - el.configs.length 160 | el.count = el.configs.length 161 | } else if (el.count < el.configs.length && remaining > 0) { 162 | el.count = el.count + Math.ceil(remaining / 3) 163 | remaining = remaining - Math.ceil(remaining / 3) 164 | } 165 | } 166 | } 167 | for (const el of configList) { 168 | finalConfigList = finalConfigList.concat( 169 | GetMultipleRandomElements(el.configs, el.count) 170 | ) 171 | } 172 | } 173 | 174 | if (myConfigs.length) { 175 | let myValidConfigs: Array = myConfigs.map(DecodeConfig).filter(ValidateConfig) 176 | if (includeOriginalConfigs || !includeMergedConfigs) { 177 | finalConfigList = finalConfigList.concat(myValidConfigs) 178 | } 179 | if (includeMergedConfigs) { 180 | let myMergedConfigs: Array = myValidConfigs.map((cnf: any) => MixConfig(cnf, url, address, "my")) 181 | console.log(myValidConfigs, myMergedConfigs) 182 | myMergedConfigs = myMergedConfigs.filter((cnf: any) => cnf?.merged && cnf?.remarks) 183 | console.log(myValidConfigs, myMergedConfigs) 184 | finalConfigList = finalConfigList.concat(myMergedConfigs) 185 | } 186 | } 187 | 188 | finalConfigList = RemoveDuplicateConfigs(finalConfigList.filter(ValidateConfig)) 189 | 190 | let vlessConfigList: Array = [] 191 | let trojanConfigList: Array = [] 192 | let startNo = 1 193 | 194 | if (protocols.includes("built-in-vless")) { 195 | vlessConfigList = await GetVlessConfigList(url.hostname, cleanDomainIPs, startNo, maxBuiltInConfigsPerType, env) 196 | startNo += maxBuiltInConfigsPerType 197 | } 198 | if (protocols.includes("built-in-trojan")) { 199 | trojanConfigList = await GetTrojanConfigList(url.hostname, cleanDomainIPs, startNo, maxBuiltInConfigsPerType, env) 200 | startNo += maxBuiltInConfigsPerType 201 | } 202 | finalConfigList = vlessConfigList.concat(trojanConfigList).concat(AddNumberToConfigs(finalConfigList, startNo)) 203 | 204 | finalConfigList = finalConfigList.map((conf: Config) => { 205 | conf.fp = fingerPrints[Math.floor(Math.random() * fingerPrints.length)] 206 | conf.alpn = alpnList[Math.floor(Math.random() * alpnList.length)] 207 | if (enableFragments && conf.tls == "tls") { 208 | conf.fragment = `tlshello,${fragmentsLengthList[Math.floor(Math.random() * fragmentsLengthList.length)]},${fragmentsIntervalList[Math.floor(Math.random() * fragmentsIntervalList.length)]}` 209 | } 210 | return conf 211 | }) 212 | 213 | return finalConfigList 214 | } -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | import { Buffer } from 'buffer' 2 | import { IsIp, IsValidUUID, MuddleDomain } from "./helpers" 3 | import { cfPorts, supportedCiphers } from "./variables" 4 | import { Config } from "./interfaces" 5 | 6 | export function MixConfig(cnf: Config, url: URL, address: string, provider: string): Config | null { 7 | const hostname: string = MuddleDomain(url.hostname) 8 | try { 9 | let conf = {...cnf}; 10 | const type = conf.network || conf.type || "" 11 | if (!["ws", "h2", "http"].includes(type)) { 12 | throw new Error("Network is not supported!") 13 | } else if (!cfPorts.includes(conf.port)) { 14 | throw new Error("Port is not matched!") 15 | } 16 | 17 | let addr = conf.sni || conf.host || conf.address 18 | if (IsIp(addr)) { 19 | throw new Error("Invalid SNI!") 20 | } 21 | 22 | if (addr.toLocaleLowerCase().endsWith('.workers.dev') || addr.toLocaleLowerCase().endsWith('.pages.dev')) { 23 | throw new Error("Config is running on Cloudflare, Skipped!") 24 | } 25 | 26 | conf.remarks = conf.remarks + "-worker" 27 | const path = conf.path 28 | conf.host = hostname 29 | conf.sni = hostname 30 | conf.address = address 31 | conf.path = `/${addr}:${conf.port}/${path.replace(/^\//g, "")}` 32 | conf.merged = true 33 | return conf 34 | } catch (e) { 35 | return null 36 | } 37 | } 38 | 39 | export function EncodeConfig(conf: Config): string { 40 | try { 41 | if (conf.configType == "vmess") { 42 | const config = { 43 | type: conf.type, 44 | ps: conf.remarks, 45 | add: conf.address, 46 | port: conf.port, 47 | id: conf.uuid, 48 | aid: conf.alterId || 0, 49 | tls: conf.tls, 50 | sni: conf.sni, 51 | net: conf.network, 52 | path: conf.path, 53 | host: conf.host, 54 | alpn: conf.alpn, 55 | fp: conf.fp, 56 | } 57 | return `vmess://${Buffer.from(JSON.stringify(config), "utf-8").toString("base64")}` 58 | } else if (conf.configType == "vless") { 59 | return `vless://${ 60 | conf.uuid 61 | }@${ 62 | conf.address 63 | }:${ 64 | conf.port 65 | }?encryption=${ 66 | encodeURIComponent(conf.encryption || "none") 67 | }&type=${ 68 | conf.type || conf.network 69 | }${ 70 | conf.path ? "&path=" + encodeURIComponent(conf.path) : "" 71 | }${ 72 | conf.host ? "&host=" + encodeURIComponent(conf.host) : "" 73 | }${ 74 | conf.security ? "&security=" + encodeURIComponent(conf.security) : "" 75 | }${ 76 | conf.flow ? "&flow=" + encodeURIComponent(conf.flow) : "" 77 | }${ 78 | conf.pbk ? "&pbk=" + encodeURIComponent(conf.pbk) : "" 79 | }${ 80 | conf.sid ? "&sid=" + encodeURIComponent(conf.sid) : "" 81 | }${ 82 | conf.spx ? "&spx=" + encodeURIComponent(conf.spx) : "" 83 | }${ 84 | conf.seed ? "&seed=" + encodeURIComponent(conf.seed) : "" 85 | }${ 86 | conf.quicSecurity ? "&quicSecurity=" + encodeURIComponent(conf.quicSecurity) : "" 87 | }${ 88 | conf.key ? "&key=" + encodeURIComponent(conf.key) : "" 89 | }${ 90 | conf.mode ? "&mode=" + encodeURIComponent(conf.mode) : "" 91 | }${ 92 | conf.authority ? "&authority=" + encodeURIComponent(conf.authority) : "" 93 | }${ 94 | conf.headerType ? "&headerType=" + encodeURIComponent(conf.headerType) : "" 95 | }${ 96 | conf.alpn ? "&alpn=" + encodeURIComponent(conf.alpn) : "" 97 | }${ 98 | conf.fp ? "&fp=" + encodeURIComponent(conf.fp) : "" 99 | }${ 100 | conf.fragment ? "&fragment=" + encodeURIComponent(conf.fragment) : "" 101 | }&sni=${ 102 | encodeURIComponent(conf.sni || conf.host || conf.address) 103 | }#${ 104 | encodeURIComponent(conf.remarks) 105 | }`; 106 | 107 | } else if (conf.configType == "trojan") { 108 | return `${ 109 | conf.configType 110 | }://${ 111 | conf.password || conf.uuid 112 | }@${ 113 | conf.address 114 | }:${ 115 | conf.port 116 | }?type=${ 117 | conf.network 118 | }${ 119 | conf.cipher ? "&cipher=" + encodeURIComponent(conf.cipher) : "" 120 | }${ 121 | conf.path ? "&path=" + conf.path : "" 122 | }${ 123 | conf.host ? "&host=" + conf.host : "" 124 | }${ 125 | conf.alpn ? "&alpn=" + encodeURIComponent(conf.alpn) : "" 126 | }${ 127 | conf.fp ? "&fp=" + encodeURIComponent(conf.fp) : "" 128 | }${ 129 | conf.tls ? "&tls=1" : "" 130 | }&sni=${ 131 | encodeURIComponent(conf.sni || conf.host || conf.address) 132 | }#${ 133 | encodeURIComponent(conf.remarks) 134 | }`; 135 | // } else if (conf.type == "ss") { 136 | // return `${ 137 | // conf.type 138 | // }://${ 139 | // conf.password || conf.uuid 140 | // }@${ 141 | // conf.server 142 | // }:${ 143 | // conf.port || "80" 144 | // }?cipher=${ 145 | // conf.cipher || "none" 146 | // }${ 147 | // conf.path ? "&path=" + encodeURIComponent(conf.path) : "" 148 | // }${ 149 | // conf.host ? "&host=" + encodeURIComponent(conf.host) : "" 150 | // }${ 151 | // conf.tfo ? "&tfo=1" : "" 152 | // }${ 153 | // conf.obfs ? "&obfs=" + encodeURIComponent(conf.obfs) : "" 154 | // }${ 155 | // conf.protocol ? "&protocol=" + encodeURIComponent(conf.protocol) : "" 156 | // }${ 157 | // conf["protocol-param"] ? "&protocol-param=" + encodeURIComponent(conf["protocol-param"]) : "" 158 | // }${ 159 | // conf["obfs-param"] ? "&obfs-param=" + encodeURIComponent(conf["obfs-param"]) : "" 160 | // }#${ 161 | // encodeURIComponent(conf.name) 162 | // }`; 163 | // // } else if (conf.type == "ssr") { 164 | // // return `${conf.type}://${Buffer.from( 165 | // // `${conf.server}:${conf.port}:origin:${conf.cipher}:${conf["protocol-param"]} 166 | // // , "utf-8").toString("base64")}` 167 | } 168 | } catch (e) { 169 | // console.log(e, conf) 170 | } 171 | return "" 172 | } 173 | 174 | export function DecodeConfig(configStr: string): Config { 175 | let conf: any = null 176 | if (configStr.startsWith("vmess://")) { 177 | try { 178 | conf = JSON.parse(Buffer.from(configStr.substring(8), "base64").toString("utf-8")) 179 | const type = conf?.type || "" 180 | conf = { 181 | configType: "vmess", 182 | remarks: conf?.ps, 183 | address: conf.add, 184 | port: parseInt(conf.port), 185 | uuid: conf.id, 186 | alterId: conf?.aid || 0, 187 | security: conf?.scy || "auto", 188 | network: conf.net, 189 | type: type == conf.net ? "" : type, 190 | host: conf?.host, 191 | path: conf?.path || "", 192 | tls: conf?.tls || "", 193 | sni: conf?.sni || conf?.host, 194 | } as Config 195 | } catch (e) { } 196 | } else if (configStr.startsWith("vless://")) { 197 | try { 198 | const url: URL = new URL(configStr) 199 | conf = { 200 | configType: "vless", 201 | remarks: decodeURIComponent(url.hash.substring(1)), 202 | address: url.hostname, 203 | port: parseInt(url.port || (url.searchParams.get('tls') == "tls" ? "443" : "80")), 204 | uuid: url.username, 205 | security: url.searchParams.get('security') || "", 206 | encryption: url.searchParams.get('encryption') || "none", 207 | type: url.searchParams.get('type') || "tcp", 208 | serviceName: url.searchParams.get('serviceName') || "", 209 | host: url.searchParams.get('host') || "", 210 | path: url.searchParams.get('path') || "", 211 | tls: url.searchParams.get('security') == "tls" ? "tls" : "", 212 | sni: url.searchParams.get('sni') || "", 213 | flow: url.searchParams.get('flow') || "", 214 | pbk: url.searchParams.get('pbk') || "", 215 | sid: url.searchParams.get('sid') || "", 216 | spx: url.searchParams.get('spx') || "", 217 | headerType: url.searchParams.get('headerType') || "", 218 | seed: url.searchParams.get('seed') || "", 219 | quicSecurity: url.searchParams.get('quicSecurity') || "", 220 | key: url.searchParams.get('key') || "", 221 | mode: url.searchParams.get('mode') || "", 222 | authority: url.searchParams.get('authority') || "", 223 | } as Config 224 | } catch (e) { 225 | // console.log(e, configStr) 226 | } 227 | } 228 | return conf 229 | } 230 | 231 | export function ValidateConfig(conf: Config): boolean { 232 | try { 233 | if (["vmess", "vless"].includes(conf.configType) && IsValidUUID(conf.uuid as string) && conf.remarks) { 234 | return !!(conf.address || conf.sni) 235 | } else if (["trojan"].includes(conf.configType) && (conf.uuid || conf.password) && conf.remarks) { 236 | return !!(conf.address || conf.sni) 237 | // } else if (["ss", "ssr"].includes(conf.type) && supportedCiphers.includes(conf.cipher as string)) { 238 | // return !!(conf.server || conf.servername) 239 | } 240 | } catch (e) { } 241 | 242 | return false 243 | } 244 | -------------------------------------------------------------------------------- /src/helpers.ts: -------------------------------------------------------------------------------- 1 | import sha224 from 'crypto-js/sha224' 2 | import CryptoJSHex from 'crypto-js/enc-hex' 3 | import { v5 as uuidv5 } from "uuid" 4 | import { Env, Config } from "./interfaces" 5 | import { providersUri, proxiesUri } from "./variables" 6 | 7 | export function GetMultipleRandomElements(arr: Array, num: number): Array { 8 | let shuffled = arr.sort(() => 0.5 - Math.random()) 9 | return shuffled.slice(0, num) 10 | } 11 | 12 | export function IsIp(str: string): boolean { 13 | try { 14 | if (str == "" || str == undefined) return false 15 | if (!/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){2}\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-4])$/.test(str)) { 16 | return false 17 | } 18 | let ls = str.split('.') 19 | if (ls == null || ls.length != 4 || ls[3] == "0" || parseInt(ls[3]) === 0) { 20 | return false 21 | } 22 | return true 23 | } catch (e) { } 24 | return false 25 | } 26 | 27 | export function IsValidUUID(uuid: string): boolean { 28 | return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(uuid) 29 | } 30 | 31 | export function GetVlessConfig(no: number, uuid: string, sni: string, address: string, port: number) { 32 | if (address.toLowerCase() == sni.toLowerCase()) { 33 | address = sni 34 | } 35 | return { 36 | remarks: `${no}-vless-worker-${address}`, 37 | configType: "vless", 38 | security: "tls", 39 | tls: "tls", 40 | network: "ws", 41 | port: port, 42 | sni: sni, 43 | uuid: uuid, 44 | host: sni, 45 | path: "vless-ws/?ed=2048", 46 | address: address, 47 | } as Config 48 | } 49 | 50 | export function GetTrojanConfig(no: number, sha224Password: string, sni: string, address: string, port: number) { 51 | if (address.toLowerCase() == sni.toLowerCase()) { 52 | address = sni 53 | } 54 | return { 55 | remarks: `${no}-trojan-worker-${address}`, 56 | configType: "trojan", 57 | security: "tls", 58 | tls: "tls", 59 | network: "ws", 60 | port: port, 61 | sni: sni, 62 | password: sha224Password, 63 | host: sni, 64 | path: "trojan-ws/?ed=2048", 65 | address: address, 66 | } as Config 67 | } 68 | 69 | export function IsBase64(str: string): boolean { 70 | return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/.test(str) 71 | } 72 | 73 | export function RemoveDuplicateConfigs(configList: Array): Array { 74 | const seen: { [key: string]: boolean } = {} 75 | 76 | return configList.filter((conf: Config) => { 77 | const key = conf.remarks + conf.port + conf.address + conf.uuid 78 | if (!seen[key]) { 79 | seen[key] = true 80 | return true 81 | } 82 | return false 83 | }) 84 | } 85 | 86 | export function AddNumberToConfigs(configList: Array, start: number): Array { 87 | const seen: { [key: string]: boolean } = {} 88 | 89 | return configList.map((conf: Config, index: number) => { 90 | conf.remarks = (index + start) + "-" + conf.remarks 91 | return conf 92 | }) 93 | } 94 | 95 | export function GenerateToken(length: number = 32): string { 96 | const buffer: Uint8Array = new Uint8Array(length) 97 | for (let i = 0; i < length; i++) { 98 | buffer[i] = Math.floor(Math.random() * 256) 99 | } 100 | return Array.from(buffer).map(byte => byte.toString(16).padStart(2, '0')).join('') 101 | } 102 | 103 | export function Delay(ms: number): Promise { 104 | return new Promise((resolve) => setTimeout(resolve, ms)) 105 | } 106 | 107 | export function MuddleDomain(hostname: string): string { 108 | const parts: string[] = hostname.split(".") 109 | const subdomain: string = parts.slice(0, parts.length -2).join(".") 110 | const domain: string = parts.slice(-2).join(".") 111 | 112 | const muddledDomain: string = domain.split("").map( 113 | char => Math.random() < 0.5 ? char.toLowerCase() : char.toUpperCase() 114 | ).join("") 115 | 116 | return subdomain + "." + muddledDomain 117 | } 118 | 119 | export async function getDefaultProviders(): Promise> { 120 | return fetch(providersUri).then(r => r.text()).then(t => t.trim().split("\n")) 121 | } 122 | 123 | export async function getDefaultProxies(): Promise> { 124 | return fetch(proxiesUri).then(r => r.text()).then(t => t.trim().split("\n").filter(t => t.trim().length > 0)) 125 | } 126 | 127 | export async function getProxies(env: Env): Promise> { 128 | let proxyIPList: Array = [] 129 | try { 130 | proxyIPList = (await env.settings.get("Proxies"))?.trim().split("\n").filter(t => t.trim().length > 0) || [] 131 | } catch (e) { 132 | // Ignore 133 | } 134 | if (!proxyIPList.length) { 135 | proxyIPList = await getDefaultProxies() 136 | } 137 | 138 | return proxyIPList 139 | } 140 | 141 | export function getUUID(sni: string) : string { 142 | return uuidv5(sni.toLowerCase(), "ebc4a168-a6fe-47ce-bc25-6183c6212dcc") as string 143 | } 144 | 145 | export function getSHA224Password(sni: string) : string { 146 | return sha224(sni.toLowerCase()).toString(CryptoJSHex) 147 | } 148 | -------------------------------------------------------------------------------- /src/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface RemoteSocketWrapper { 2 | value: Socket | null; 3 | } 4 | 5 | export interface CustomArrayBuffer { 6 | earlyData: ArrayBufferLike | null, 7 | error: any 8 | } 9 | 10 | export interface VlessHeader { 11 | hasError: boolean, 12 | message: string | undefined, 13 | addressRemote: string, 14 | addressType: number, 15 | portRemote: number, 16 | rawDataIndex: number, 17 | vlessVersion: Uint8Array, 18 | isUDP: boolean, 19 | isMUX: boolean, 20 | } 21 | 22 | export interface UDPOutbound { 23 | write: CallableFunction 24 | } 25 | 26 | export interface Config { 27 | configType: string, 28 | remarks: string, 29 | address: string, 30 | port: number, 31 | uuid?: string, 32 | type?: string, 33 | password?: string, 34 | alterId?: number, 35 | cipher?: string, 36 | security?: string, 37 | encryption?: string, 38 | tls?: string, 39 | sni?: string, 40 | network: string, 41 | path: string, 42 | host?: string, 43 | alpn?: string, 44 | fp?: string, 45 | obfs?: string, 46 | protocol?: string, 47 | fragment?: string, 48 | tfo?: string, 49 | pbk?: string, 50 | spx?: string, 51 | sid?: string, 52 | headerType?: string, 53 | flow?: string, 54 | serviceName?: string, 55 | seed?: string, 56 | quicSecurity?: string, 57 | key?: string, 58 | mode?: string, 59 | authority?: string, 60 | merged?: boolean, 61 | } 62 | 63 | export interface ClashConfig { 64 | name: string, 65 | type: string, 66 | server: string, 67 | port: number, 68 | uuid?: string, 69 | password?: string, 70 | alterId?: number, 71 | cipher?: string, 72 | security?: string, 73 | encryption?: string, 74 | tls?: boolean, 75 | sni?: string, 76 | network: string, 77 | path: string, 78 | host?: string, 79 | alpn?: string, 80 | fp?: string, 81 | obfs?: string, 82 | protocol?: string, 83 | fragment?: string, 84 | tfo?: string, 85 | pbk?: string, 86 | spx?: string, 87 | sid?: string, 88 | headerType?: string, 89 | flow?: string, 90 | serviceName?: string, 91 | seed?: string, 92 | quicSecurity?: string, 93 | key?: string, 94 | mode?: string, 95 | authority?: string, 96 | merged?: boolean, 97 | "skip-cert-verify"?: boolean, 98 | } 99 | 100 | export interface WSOpts { 101 | path: string, 102 | headers: WSHeaders, 103 | } 104 | 105 | export interface WSHeaders { 106 | Host: string, 107 | } 108 | 109 | export interface Env { 110 | settings: KVNamespace 111 | } 112 | -------------------------------------------------------------------------------- /src/panel.ts: -------------------------------------------------------------------------------- 1 | import * as bcrypt from 'bcryptjs' 2 | import { GenerateToken } from "./helpers" 3 | import { version, defaultProtocols, proxiesUri } from "./variables" 4 | import { Env } from "./interfaces" 5 | 6 | export async function GetPanel(request: Request, env: Env): Promise { 7 | const url: URL = new URL(request.url) 8 | try { 9 | const hash: string | null = await env.settings.get("Password") 10 | const token: string | null = await env.settings.get("Token") 11 | 12 | if (hash && url.searchParams.get("token") != token) { 13 | return Response.redirect(`${url.origin}/login`, 302) 14 | } 15 | 16 | const settingsVersion: string = await env.settings.get("Version") || "2.0" 17 | if (settingsVersion != version) { 18 | // console.log(settingsVersion, version) 19 | await env.settings.delete("Providers") 20 | await env.settings.delete("Protocols") 21 | } 22 | const maxConfigs: number = parseInt(await env.settings.get("MaxConfigs") || "200") 23 | const protocols: Array = (await env.settings.get("Protocols"))?.split("\n").filter(t => t.trim().length > 0) || defaultProtocols 24 | const alpnList: Array = (await env.settings.get("ALPNs"))?.split("\n").filter(t => t.trim().length > 0) || [] 25 | const fingerPrints: Array = (await env.settings.get("FingerPrints"))?.split("\n").filter(t => t.trim().length > 0) || [] 26 | const cleanDomainIPs: Array = (await env.settings.get("CleanDomainIPs"))?.split("\n").filter(t => t.trim().length > 0) || [] 27 | const configs: Array = (await env.settings.get("Configs"))?.split("\n").filter(t => t.trim().length > 0) || [] 28 | const includeOriginalConfigs: string = await env.settings.get("IncludeOriginalConfigs") || "yes" 29 | const includeMergedConfigs: string = await env.settings.get("IncludeMergedConfigs") || "yes" 30 | const enableFragments: string = await env.settings.get("EnableFragments") || "no" 31 | const blockPorn: string = await env.settings.get("BlockPorn") || "no" 32 | const providers = (await env.settings.get("Providers"))?.split("\n").filter(t => t.trim().length > 0) || [] 33 | const countries = (await env.settings.get("Countries"))?.split(",").filter(t => t.trim().length > 0) || [] 34 | 35 | let allCountries = await fetch(proxiesUri).then(r => r.text()).then(t => { 36 | return t.trim().split("\n").map(t => { 37 | const arr = t.split(",") 38 | return arr.length > 0 ? arr[1]?.toString().trim().toUpperCase() : "" 39 | }).filter(t => t) 40 | }) 41 | allCountries = [...new Set(allCountries)].sort() 42 | 43 | let htmlMessage = "" 44 | const message = url.searchParams.get("message") 45 | if (message == "success") { 46 | htmlMessage = `
Settings saved successfully.
تنظیمات با موفقیت ذخیره شد.
` 47 | } else if (message == "error") { 48 | htmlMessage = `
Failed to save settings!
خطا در ذخیره‌ی تنظیمات!
` 49 | } 50 | 51 | let passwordSection = "" 52 | if (hash) { 53 | passwordSection = ` 54 |
55 | 56 |
57 | ` 58 | } else { 59 | passwordSection = ` 60 |
61 | 62 |
63 |
64 | 67 | 68 |
69 | Minimum 6 chars / حداقل ۶ کاراکتر وارد کنید. 70 |
71 |

72 | 75 | 76 |
77 | ` 78 | } 79 | 80 | let htmlContent = ` 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 280 | 281 | 282 |
283 |
284 |
285 |
286 |    ${version} 287 |
288 |
289 | ${htmlMessage} 290 |
291 | 292 | 293 | 294 |
295 |
296 | 297 | 298 | 299 |
300 |
301 |
302 | 303 |
304 |
305 | 306 | 307 |
308 |
309 | 310 | 311 |
312 |
313 |
314 |
315 | 316 | 317 |
318 |
319 |
320 | 321 |
322 |
323 | 324 | 325 |
326 |
327 | 328 | 329 |
330 |
331 | 332 | 333 |
334 |
335 | 336 | 337 |
338 |
339 |
340 |
341 | 342 | 343 | 344 | 345 |
346 | 347 | 359 |
360 |
361 |
362 | 363 | 364 |
365 |
366 |
367 | 368 | 369 |
370 |
371 | ${allCountries.map(t => ` `).join(`    `)} 372 |
373 |
374 |
375 | 376 | 377 |
378 |
379 |
380 | 381 | 382 | 383 | 384 |
385 |
386 | 387 | 388 | 389 | 390 |
391 |
392 | 393 |     394 | 395 | 396 | 397 |
398 |
399 | 400 | 401 | 402 | 403 |
404 | ${passwordSection} 405 | 406 | 407 |
408 |
409 |
410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | @vahidfarid
421 | 422 | 425 | vfarid

426 |
427 |
428 |
429 | 430 | 431 | ` 432 | 433 | return new Response(htmlContent, { 434 | headers: {"Content-Type": "text/html"}, 435 | }) 436 | } catch (e) { 437 | if (e instanceof TypeError) { 438 | const htmlContent = ` 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 |
447 |
448 |
449 |
450 |    ${version} 451 |
452 |
453 |
454 | 455 | 456 | 457 |
458 |
459 | 460 | 461 | 462 |
463 |
464 |
465 |
466 |
    467 |
  1. 468 | 469 |
  2. 470 |
  3. 471 | 472 |
  4. 473 |
474 |
475 |
476 |
477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | @vahidfarid
488 | 489 | 492 | vfarid

493 |
494 |
495 |
496 | 497 | 574 | 575 | ` 576 | 577 | return new Response(htmlContent, { 578 | headers: {"Content-Type": "text/html"}, 579 | }) 580 | } else { 581 | throw e 582 | } 583 | } 584 | } 585 | 586 | export async function PostPanel(request: Request, env: Env): Promise { 587 | const url: URL = new URL(request.url) 588 | let token: string | null = await env.settings.get("Token") 589 | try { 590 | const formData = await request.formData() 591 | 592 | let hashedPassword: string | null = await env.settings.get("Password") 593 | 594 | if (hashedPassword && url.searchParams.get("token") != token) { 595 | return Response.redirect(`${url.origin}/login`, 302) 596 | } 597 | 598 | if (formData.get("reset_password")) { 599 | await env.settings.delete("Password") 600 | await env.settings.delete("Token") 601 | return Response.redirect(`${url.origin}?message=success`, 302) 602 | } else if (formData.get("save")) { 603 | const password: string = formData.get("password")?.toString() || "" 604 | if (password) { 605 | if (password.length < 6 || password !== formData.get("password_confirmation")) { 606 | return Response.redirect(`${url.origin}?message=invalid-password`, 302) 607 | } 608 | hashedPassword = await bcrypt.hash(password, 10); 609 | 610 | token = GenerateToken(24) 611 | await env.settings.put("Password", hashedPassword) 612 | await env.settings.put("Token", token) 613 | } 614 | let maxConfigs = parseInt(formData.get("max")?.toString() || "200") 615 | if (maxConfigs < 50) { 616 | maxConfigs = 50 617 | } 618 | await env.settings.put("MaxConfigs", maxConfigs.toString()) 619 | await env.settings.put("Protocols", formData.getAll("protocols")?.join("\n").trim()) 620 | await env.settings.put("ALPNs", formData.get("alpn_list_check")?.toString() ? formData.get("alpn_list")?.toString().trim().split("\n").map(str => str.trim()).join("\n") || "" : "") 621 | await env.settings.put("FingerPrints", formData.get("fp_list_check")?.toString() ? formData.get("fp_list")?.toString().trim().split("\n").map(str => str.trim()).join("\n") || "" : "") 622 | await env.settings.put("Providers", formData.get("providers_check")?.toString() ? formData.get("providers")?.toString().trim().split("\n").map(str => str.trim()).join("\n") || "" : "") 623 | await env.settings.put("Countries", formData.get("countries_check")?.toString() ? formData.getAll("countries[]")?.join(",") || "" : "") 624 | await env.settings.put("CleanDomainIPs", formData.get("clean_ips_check")?.toString() ? formData.get("clean_ips")?.toString().trim().split("\n").map(str => str.trim()).join("\n") || "" : "") 625 | await env.settings.put("Configs", formData.get("configs_check")?.toString() ? formData.get("configs")?.toString().trim().split("\n").map(str => str.trim()).join("\n") || "" : "") 626 | await env.settings.put("IncludeOriginalConfigs", formData.get("original")?.toString() || "no") 627 | await env.settings.put("IncludeMergedConfigs", formData.get("merged")?.toString() || "no") 628 | await env.settings.put("BlockPorn", formData.get("block_porn")?.toString() || "no") 629 | await env.settings.put("EnableFragments", formData.get("enable_fragments")?.toString() || "no") 630 | await env.settings.put("Version", version) 631 | } else { 632 | await env.settings.delete("MaxConfigs") 633 | await env.settings.delete("Protocols") 634 | await env.settings.delete("ALPNs") 635 | await env.settings.delete("FingerPrints") 636 | await env.settings.delete("Providers") 637 | await env.settings.delete("Countries") 638 | await env.settings.delete("CleanDomainIPs") 639 | await env.settings.delete("Configs") 640 | await env.settings.delete("IncludeOriginalConfigs") 641 | await env.settings.delete("IncludeMergedConfigs") 642 | await env.settings.delete("UUID") 643 | await env.settings.delete("Password") 644 | await env.settings.delete("Token") 645 | await env.settings.delete("BlockPorn") 646 | await env.settings.delete("EnableFragments") 647 | } 648 | 649 | return Response.redirect(`${url.origin}?message=success${token ? "&token=" + token : ""}`, 302) 650 | } catch (e) { 651 | return Response.redirect(`${url.origin}?message=error${token ? "&token=" + token : ""}`, 302) 652 | } 653 | } 654 | -------------------------------------------------------------------------------- /src/qrcode.ts: -------------------------------------------------------------------------------- 1 | import QRCode from 'qrcode' 2 | 3 | const generateQR = async (conf: string) => { 4 | return await QRCode.toDataURL(conf) 5 | } 6 | -------------------------------------------------------------------------------- /src/sub.ts: -------------------------------------------------------------------------------- 1 | import { Buffer } from 'buffer' 2 | import { EncodeConfig } from './config' 3 | import { Config } from './interfaces' 4 | 5 | export function ToRawSubscription(configList: Array): string { 6 | return configList.map(EncodeConfig).join("\n") 7 | } 8 | 9 | export function ToBase64Subscription(configList: Array): string { 10 | return Buffer.from(configList.map(EncodeConfig).join("\n"), "utf-8").toString("base64") 11 | } 12 | -------------------------------------------------------------------------------- /src/trojan.ts: -------------------------------------------------------------------------------- 1 | import { connect } from 'cloudflare:sockets' 2 | import { GetTrojanConfig, MuddleDomain, getSHA224Password, getUUID } from "./helpers" 3 | import { cfPorts, proxiesUri } from "./variables" 4 | import { RemoteSocketWrapper, CustomArrayBuffer, VlessHeader, UDPOutbound, Config, Env } from "./interfaces" 5 | import { encodeBase64 } from 'bcryptjs' 6 | 7 | const WS_READY_STATE_OPEN: number = 1 8 | const WS_READY_STATE_CLOSING: number = 2 9 | let proxyIP: string = "" 10 | let proxyList: Array = [] 11 | let filterCountries: string = "" 12 | let countries: Array = [] 13 | 14 | export async function GetTrojanConfigList(sni: string, addressList: Array, start: number, max: number, env: Env) { 15 | filterCountries = "" 16 | proxyList = [] 17 | let configList: Array = [] 18 | for (let i = 0; i < max; i++) { 19 | configList.push(GetTrojanConfig( 20 | i + start, 21 | getUUID(sni), 22 | MuddleDomain(sni), 23 | addressList[Math.floor(Math.random() * addressList.length)], 24 | cfPorts[Math.floor(Math.random() * cfPorts.length)] 25 | )) 26 | } 27 | 28 | return configList 29 | } 30 | 31 | export async function TrojanOverWSHandler(request: Request, sni: string, env: Env) { 32 | const sha224Password = getSHA224Password(getUUID(sni)) 33 | const [client, webSocket]: Array = Object.values(new WebSocketPair) 34 | webSocket.accept() 35 | 36 | let address: string = "" 37 | const earlyDataHeader: string = request.headers.get("sec-websocket-protocol") || "" 38 | const readableWebSocketStream = MakeReadableWebSocketStream(webSocket, earlyDataHeader) 39 | 40 | let remoteSocketWapper: RemoteSocketWrapper = { 41 | value: null, 42 | } 43 | 44 | readableWebSocketStream.pipeTo(new WritableStream({ 45 | async write(chunk, controller) { 46 | if (remoteSocketWapper.value) { 47 | const writer = remoteSocketWapper.value.writable.getWriter(); 48 | await writer.write(chunk); 49 | writer.releaseLock(); 50 | return; 51 | } 52 | const { 53 | hasError, 54 | message, 55 | portRemote = 443, 56 | addressRemote = "", 57 | rawClientData, 58 | } = await ParseTrojanHeader(chunk, sha224Password); 59 | address = addressRemote; 60 | if (hasError) { 61 | throw new Error(message); 62 | } 63 | HandleTCPOutbound(remoteSocketWapper, addressRemote, portRemote, rawClientData, webSocket, env); 64 | }, 65 | })).catch((err) => { }); 66 | return new Response(null, { 67 | status: 101, 68 | webSocket: client 69 | }); 70 | } 71 | 72 | async function ParseTrojanHeader(buffer: ArrayBuffer, sha224Password: string) { 73 | if (buffer.byteLength < 56) { 74 | return { 75 | hasError: true, 76 | message: "invalid data" 77 | }; 78 | } 79 | let crLfIndex: number = 56; 80 | if (new Uint8Array(buffer.slice(56, 57))[0] !== 0x0d || new Uint8Array(buffer.slice(57, 58))[0] !== 0x0a) { 81 | return { 82 | hasError: true, 83 | message: "invalid header format (missing CR LF)" 84 | }; 85 | } 86 | const password: string = new TextDecoder().decode(buffer.slice(0, crLfIndex)); 87 | if (password !== sha224Password) { 88 | return { 89 | hasError: true, 90 | message: "invalid password" 91 | }; 92 | } 93 | 94 | const socks5DataBuffer: ArrayBuffer = buffer.slice(crLfIndex + 2); 95 | if (socks5DataBuffer.byteLength < 6) { 96 | return { 97 | hasError: true, 98 | message: "invalid SOCKS5 request data" 99 | }; 100 | } 101 | 102 | const view: DataView = new DataView(socks5DataBuffer); 103 | const cmd: number = view.getUint8(0); 104 | if (cmd !== 1) { 105 | return { 106 | hasError: true, 107 | message: "unsupported command, only TCP (CONNECT) is allowed" 108 | }; 109 | } 110 | 111 | const atype: number = view.getUint8(1); 112 | let addressLength: number = 0; 113 | let addressIndex: number = 2; 114 | let address: string = ""; 115 | switch (atype) { 116 | case 1: 117 | addressLength = 4; 118 | address = new Uint8Array( 119 | socks5DataBuffer.slice(addressIndex, addressIndex + addressLength) 120 | ).join("."); 121 | break; 122 | case 3: 123 | addressLength = new Uint8Array( 124 | socks5DataBuffer.slice(addressIndex, addressIndex + 1) 125 | )[0]; 126 | addressIndex += 1; 127 | address = new TextDecoder().decode( 128 | socks5DataBuffer.slice(addressIndex, addressIndex + addressLength) 129 | ); 130 | break; 131 | case 4: 132 | addressLength = 16; 133 | const dataView = new DataView(socks5DataBuffer.slice(addressIndex, addressIndex + addressLength)); 134 | const ipv6 = []; 135 | for (let i = 0; i < 8; i++) { 136 | ipv6.push(dataView.getUint16(i * 2).toString(16)); 137 | } 138 | address = ipv6.join(":"); 139 | break; 140 | default: 141 | return { 142 | hasError: true, 143 | message: `invalid addressType is ${atype}` 144 | }; 145 | } 146 | 147 | if (!address) { 148 | return { 149 | hasError: true, 150 | message: `address is empty, addressType is ${atype}` 151 | }; 152 | } 153 | 154 | const portIndex: number = addressIndex + addressLength; 155 | const portBuffer: ArrayBuffer = socks5DataBuffer.slice(portIndex, portIndex + 2); 156 | const portRemote: number = new DataView(portBuffer).getUint16(0); 157 | return { 158 | hasError: false, 159 | addressRemote: address, 160 | portRemote, 161 | rawClientData: socks5DataBuffer.slice(portIndex + 4), 162 | }; 163 | } 164 | 165 | async function HandleTCPOutbound(remoteSocket: RemoteSocketWrapper, addressRemote: string, portRemote: number, rawClientData: ArrayBuffer | undefined, webSocket: WebSocket, env: Env): Promise { 166 | const maxRetryCount = 5 167 | let retryCount = 0; 168 | 169 | async function connectAndWrite(address: string, port: number) { 170 | const socketAddress: SocketAddress = { 171 | hostname: address, 172 | port: port, 173 | } 174 | const tcpSocket: Socket = connect(socketAddress) 175 | remoteSocket.value = tcpSocket 176 | // console.log(`connected to ${address}:${port}`); 177 | const writer: WritableStreamDefaultWriter = tcpSocket.writable.getWriter() 178 | await writer.write(rawClientData) 179 | writer.releaseLock() 180 | return tcpSocket 181 | } 182 | 183 | async function retry() { 184 | retryCount++ 185 | if (retryCount > maxRetryCount) { 186 | return 187 | } 188 | 189 | if (!proxyList.length) { 190 | countries = (await env.settings.get("Countries"))?.split(",").filter(t => t.trim().length > 0) || [] 191 | proxyList = await fetch(proxiesUri).then(r => r.text()).then(t => t.trim().split("\n").filter(t => t.trim().length > 0)) 192 | if (countries.length > 0) { 193 | proxyList = proxyList.filter(t => { 194 | const arr = t.split(",") 195 | if (arr.length > 0) { 196 | return countries.includes(arr[1]) 197 | } 198 | }) 199 | } 200 | proxyList = proxyList.map(ip => ip.split(",")[0]) 201 | } 202 | if (proxyList.length > 0) { 203 | proxyIP = proxyList[Math.floor(Math.random() * proxyList.length)] 204 | const tcpSocket: Socket = await connectAndWrite(proxyIP, portRemote) 205 | RemoteSocketToWS(tcpSocket, webSocket, retry) 206 | } 207 | } 208 | 209 | const tcpSocket: Socket = await connectAndWrite(addressRemote, portRemote) 210 | RemoteSocketToWS(tcpSocket, webSocket, retry) 211 | } 212 | 213 | function MakeReadableWebSocketStream(webSocketServer: WebSocket, earlyDataHeader: string): ReadableStream { 214 | let readableStreamCancel = false; 215 | const stream = new ReadableStream({ 216 | start(controller) { 217 | webSocketServer.addEventListener("message", (event) => { 218 | if (readableStreamCancel) { 219 | return; 220 | } 221 | const message = event.data; 222 | controller.enqueue(message); 223 | }); 224 | webSocketServer.addEventListener("close", () => { 225 | SafeCloseWebSocket(webSocketServer); 226 | if (readableStreamCancel) { 227 | return; 228 | } 229 | controller.close(); 230 | }); 231 | webSocketServer.addEventListener("error", (err) => { 232 | controller.error(err); 233 | }); 234 | const { earlyData, error } = Base64ToArrayBuffer(earlyDataHeader); 235 | if (error) { 236 | controller.error(error); 237 | } else if (earlyData) { 238 | controller.enqueue(earlyData); 239 | } 240 | }, 241 | pull(controller) {}, 242 | cancel(reason) { 243 | if (readableStreamCancel) { 244 | return; 245 | } 246 | readableStreamCancel = true; 247 | SafeCloseWebSocket(webSocketServer); 248 | } 249 | }); 250 | return stream; 251 | } 252 | 253 | async function RemoteSocketToWS(remoteSocket: Socket, webSocket: WebSocket, retry: (() => Promise) | null): Promise { 254 | let hasIncomingData: boolean = false 255 | await remoteSocket.readable 256 | .pipeTo( 257 | new WritableStream({ 258 | async write(chunk: Uint8Array, controller: WritableStreamDefaultController) { 259 | try { 260 | hasIncomingData = true 261 | if (webSocket.readyState !== WS_READY_STATE_OPEN) { 262 | controller.error("webSocket.readyState is not open, maybe close") 263 | } 264 | webSocket.send(chunk) 265 | } catch (e) { } 266 | }, 267 | abort(reason: any) { 268 | // console.error("remoteConnection!.readable abort", reason) 269 | }, 270 | }) 271 | ) 272 | .catch((error) => { 273 | // console.error("RemoteSocketToWS has exception ", error.stack || error) 274 | SafeCloseWebSocket(webSocket) 275 | }) 276 | 277 | if (hasIncomingData === false && retry) { 278 | retry() 279 | } 280 | } 281 | 282 | function IsValidSHA224(hash: string): boolean { 283 | const sha224Regex = /^[0-9a-f]{56}$/i; 284 | return sha224Regex.test(hash); 285 | } 286 | 287 | function Base64ToArrayBuffer(base64Str: string): CustomArrayBuffer { 288 | if (!base64Str) { 289 | return { 290 | earlyData: null, 291 | error: null 292 | } 293 | } 294 | try { 295 | base64Str = base64Str.replace(/-/g, '+').replace(/_/g, '/') 296 | const decode: string = atob(base64Str) 297 | const arryBuffer: Uint8Array = Uint8Array.from(decode, (c) => c.charCodeAt(0)) 298 | return { 299 | earlyData: arryBuffer.buffer, 300 | error: null 301 | } 302 | } catch (error) { 303 | return { 304 | earlyData: null, 305 | error 306 | } 307 | } 308 | } 309 | 310 | function SafeCloseWebSocket(socket: WebSocket): void { 311 | try { 312 | if (socket.readyState === WS_READY_STATE_OPEN || socket.readyState === WS_READY_STATE_CLOSING) { 313 | socket.close() 314 | } 315 | } catch (error) { } 316 | } 317 | -------------------------------------------------------------------------------- /src/variables.ts: -------------------------------------------------------------------------------- 1 | export const version: string = "2.4" 2 | export const providersUri: string = "https://raw.githubusercontent.com/vfarid/v2ray-worker/main/resources/provider-list.txt" 3 | export const proxiesUri: string = "https://raw.githubusercontent.com/vfarid/v2ray-worker/main/resources/proxy-list.txt" 4 | 5 | export const defaultProtocols: Array = [ 6 | "vmess", 7 | "built-in-vless", 8 | "vless", 9 | "built-in-trojan", 10 | ] 11 | 12 | export const defaultALPNList: Array = [ 13 | "h3,h2,http/1.1", 14 | "h3,h2,http/1.1", 15 | "h3,h2,http/1.1", 16 | "h3,h2", 17 | "h2,http/1.1", 18 | "h2", 19 | "http/1.1", 20 | ] 21 | 22 | export const defaultPFList: Array = [ 23 | "chrome", 24 | "firefox", 25 | "randomized", 26 | "safari", 27 | "chrome", 28 | "edge", 29 | "randomized", 30 | "ios", 31 | "chrome", 32 | "android", 33 | "randomized", 34 | ] 35 | 36 | export const cfPorts: Array = [ 37 | 443, 38 | 2053, 39 | 2083, 40 | 2087, 41 | 2096, 42 | 8443, 43 | ] 44 | 45 | export const supportedCiphers: Array = [ 46 | "none", 47 | "auto", 48 | "plain", 49 | "aes-128-cfb", 50 | "aes-192-cfb", 51 | "aes-256-cfb", 52 | "rc4-md5", 53 | "chacha20-ietf", 54 | "xchacha20", 55 | "chacha20-ietf-poly1305", 56 | ] 57 | 58 | export const fragmentsLengthList: Array = [ 59 | "10-20", 60 | "10-50", 61 | "20-50", 62 | "30-80", 63 | "50-100", 64 | ] 65 | 66 | export const fragmentsIntervalList: Array = [ 67 | "10-20", 68 | "10-50", 69 | "20-50", 70 | ] 71 | 72 | export const defaultClashConfig = { 73 | port: 7890, 74 | "socks-port": 7891, 75 | "allow-lan": false, 76 | mode: "rule", 77 | "log-level": "info", 78 | "external-controller": "127.0.0.1:9090", 79 | dns: { 80 | "enable": true, 81 | "ipv6": false, 82 | "enhanced-mode": "fake-ip", 83 | "nameserver": [ 84 | "114.114.114.114", 85 | "223.5.5.5", 86 | "8.8.8.8", 87 | "9.9.9.9", 88 | "1.1.1.1", 89 | "https://dns.google/dns-query", 90 | "tls://dns.google:853" 91 | ] 92 | }, 93 | proxies: [], 94 | "proxy-groups": [], 95 | rules: [ 96 | "GEOIP,IR,DIRECT", 97 | "DOMAIN-SUFFIX,ir,DIRECT", 98 | "IP-CIDR,127.0.0.0/8,DIRECT", 99 | "IP-CIDR,192.168.0.0/16,DIRECT", 100 | "IP-CIDR,172.16.0.0/12,DIRECT", 101 | "IP-CIDR,10.0.0.0/8,DIRECT", 102 | "MATCH,All" 103 | ], 104 | } 105 | 106 | export const defaultV2rayConfig = { 107 | "stats":{}, 108 | "log": { 109 | "loglevel": "warning" 110 | }, 111 | "policy":{ 112 | "levels": { 113 | "8": { 114 | "handshake": 4, 115 | "connIdle": 300, 116 | "uplinkOnly": 1, 117 | "downlinkOnly": 1 118 | } 119 | }, 120 | "system": { 121 | "statsOutboundUplink": true, 122 | "statsOutboundDownlink": true 123 | } 124 | }, 125 | "inbounds": [{ 126 | "tag": "socks", 127 | "port": 10808, 128 | "protocol": "socks", 129 | "settings": { 130 | "auth": "noauth", 131 | "udp": true, 132 | "userLevel": 8 133 | }, 134 | "sniffing": { 135 | "enabled": true, 136 | "destOverride": [ 137 | "http", 138 | "tls" 139 | ] 140 | } 141 | }, 142 | { 143 | "tag": "http", 144 | "port": 10809, 145 | "protocol": "http", 146 | "settings": { 147 | "userLevel": 8 148 | } 149 | } 150 | ], 151 | "outbounds": [{ 152 | "tag": "proxy", 153 | "protocol": "", 154 | "settings": { 155 | "vnext": [ 156 | { 157 | "address": "", 158 | "port": 443, 159 | "users": [ 160 | { 161 | "id": "", 162 | "alterId": 0, 163 | "security": "auto", 164 | "level": 8, 165 | "encryption": "none", 166 | "flow": "", 167 | } 168 | ] 169 | } 170 | ], 171 | }, 172 | "streamSettings": { 173 | "network": "tcp", 174 | "security": "", 175 | "sockopts": {}, 176 | }, 177 | "mux": { 178 | "enabled": false 179 | } 180 | }, 181 | { 182 | "protocol": "freedom", 183 | "settings": {}, 184 | "tag": "direct" 185 | }, 186 | { 187 | "protocol": "blackhole", 188 | "tag": "block", 189 | "settings": { 190 | "response": { 191 | "type": "http" 192 | } 193 | } 194 | } 195 | ], 196 | "routing": { 197 | "domainStrategy": "IPIfNonMatch", 198 | "rules": [] 199 | }, 200 | "dns": { 201 | "hosts": {}, 202 | "servers": [] 203 | } 204 | } 205 | 206 | -------------------------------------------------------------------------------- /src/vless.ts: -------------------------------------------------------------------------------- 1 | import { connect } from 'cloudflare:sockets' 2 | import { GetVlessConfig, MuddleDomain, getUUID } from "./helpers" 3 | import { cfPorts, proxiesUri } from "./variables" 4 | import { RemoteSocketWrapper, CustomArrayBuffer, VlessHeader, UDPOutbound, Config, Env } from "./interfaces" 5 | 6 | const WS_READY_STATE_OPEN: number = 1 7 | const WS_READY_STATE_CLOSING: number = 2 8 | let proxyIP: string = "" 9 | let proxyList: Array = [] 10 | let blockPorn: string = "" 11 | let filterCountries: string = "" 12 | let countries: Array = [] 13 | 14 | export async function GetVlessConfigList(sni: string, addressList: Array, start: number, max: number, env: Env) { 15 | filterCountries = "" 16 | blockPorn = "" 17 | proxyList = [] 18 | const uuid = getUUID(sni) 19 | let configList: Array = [] 20 | for (let i = 0; i < max; i++) { 21 | configList.push(GetVlessConfig( 22 | i + start, 23 | uuid, 24 | MuddleDomain(sni), 25 | addressList[Math.floor(Math.random() * addressList.length)], 26 | cfPorts[Math.floor(Math.random() * cfPorts.length)] 27 | )) 28 | } 29 | 30 | return configList 31 | } 32 | 33 | export async function VlessOverWSHandler(request: Request, sni: string, env: Env) { 34 | const uuid = getUUID(sni) 35 | const [client, webSocket]: Array = Object.values(new WebSocketPair) 36 | webSocket.accept() 37 | 38 | let address: string = "" 39 | const earlyDataHeader: string = request.headers.get("sec-websocket-protocol") || "" 40 | const readableWebSocketStream = MakeReadableWebSocketStream(webSocket, earlyDataHeader) 41 | 42 | let remoteSocketWapper: RemoteSocketWrapper = { 43 | value: null, 44 | } 45 | let udpStreamWrite: CallableFunction | null = null 46 | let isDns = false 47 | 48 | readableWebSocketStream.pipeTo(new WritableStream({ 49 | async write(chunk, controller) { 50 | if (isDns && udpStreamWrite) { 51 | return udpStreamWrite(chunk) 52 | } 53 | if (remoteSocketWapper.value) { 54 | const writer = remoteSocketWapper.value.writable.getWriter() 55 | await writer.write(chunk) 56 | writer.releaseLock() 57 | return 58 | } 59 | 60 | const { 61 | hasError, 62 | message, 63 | addressRemote = '', 64 | addressType, 65 | portRemote = 443, 66 | rawDataIndex, 67 | vlessVersion = new Uint8Array([0, 0]), 68 | isUDP, 69 | isMUX, 70 | } = ProcessVlessHeader(chunk, uuid) 71 | 72 | address = addressRemote 73 | 74 | if (hasError) { 75 | throw new Error(message) 76 | } 77 | 78 | if (isUDP) { 79 | if (portRemote === 53) { 80 | isDns = true 81 | } else { 82 | throw new Error('UDP proxy only enable for DNS which is port 53') 83 | } 84 | } else if (isMUX) { 85 | throw new Error('MUX is not supported!') 86 | } 87 | 88 | const vlessResponseHeader: Uint8Array = new Uint8Array([vlessVersion[0], 0]) 89 | const rawClientData: Uint8Array = chunk.slice(rawDataIndex) 90 | 91 | if (isDns) { 92 | const { write }: UDPOutbound = await HandleUDPOutbound(webSocket, vlessResponseHeader, env) 93 | udpStreamWrite = write 94 | udpStreamWrite(rawClientData) 95 | return 96 | } 97 | 98 | HandleTCPOutbound(remoteSocketWapper, addressRemote, portRemote, rawClientData, webSocket, vlessResponseHeader, env) 99 | } 100 | })).catch((err) => { }) 101 | 102 | return new Response(null, { 103 | status: 101, 104 | webSocket: client, 105 | }) 106 | } 107 | 108 | function MakeReadableWebSocketStream(webSocketServer: WebSocket, earlyDataHeader: string): ReadableStream { 109 | let readableStreamCancel: boolean = false 110 | const stream: ReadableStream = new ReadableStream({ 111 | start(controller) { 112 | webSocketServer.addEventListener('message', (event) => { 113 | if (readableStreamCancel) { 114 | return 115 | } 116 | const message: string | ArrayBuffer = event.data 117 | controller.enqueue(message) 118 | }) 119 | 120 | webSocketServer.addEventListener('close', () => { 121 | SafeCloseWebSocket(webSocketServer) 122 | if (readableStreamCancel) { 123 | return 124 | } 125 | controller.close() 126 | }) 127 | 128 | webSocketServer.addEventListener('error', (err) => { 129 | controller.error(err) 130 | }) 131 | 132 | const {earlyData, error}: CustomArrayBuffer = Base64ToArrayBuffer(earlyDataHeader) 133 | 134 | if (error) { 135 | controller.error(error) 136 | } else if (earlyData) { 137 | controller.enqueue(earlyData) 138 | } 139 | }, 140 | cancel(reason) { 141 | if (readableStreamCancel) { 142 | return 143 | } 144 | readableStreamCancel = true 145 | SafeCloseWebSocket(webSocketServer) 146 | } 147 | }) 148 | 149 | return stream 150 | } 151 | 152 | function ProcessVlessHeader(vlessBuffer: ArrayBuffer, uuid: string): VlessHeader { 153 | if (vlessBuffer.byteLength < 24) { 154 | return { 155 | hasError: true, 156 | message: 'Invalid data', 157 | } as VlessHeader 158 | } 159 | 160 | const version: Uint8Array = new Uint8Array(vlessBuffer.slice(0, 1)) 161 | let isValidUser: boolean = false 162 | let isUDP: boolean = false 163 | let isMUX: boolean = false 164 | 165 | if (Stringify(new Uint8Array(vlessBuffer.slice(1, 17))) === uuid) { 166 | isValidUser = true 167 | } 168 | 169 | if (!isValidUser) { 170 | return { 171 | hasError: true, 172 | message: 'Invalid user', 173 | } as VlessHeader 174 | } 175 | 176 | const optLength: number = new Uint8Array(vlessBuffer.slice(17, 18))[0] 177 | 178 | const command: number = new Uint8Array( 179 | vlessBuffer.slice(18 + optLength, 18 + optLength + 1) 180 | )[0] 181 | 182 | if (command === 1) { 183 | } else if (command === 2) { 184 | isUDP = true 185 | } else if (command === 3) { 186 | isMUX = true 187 | } else { 188 | return { 189 | hasError: true, 190 | message: `Command ${command} is not support, command 01-tcp, 02-udp, 03-mux`, 191 | } as VlessHeader 192 | } 193 | 194 | const portIndex: number = 18 + optLength + 1 195 | const portBuffer: ArrayBuffer = vlessBuffer.slice(portIndex, portIndex + 2) 196 | const portRemote: number = new DataView(portBuffer).getUint16(0) 197 | 198 | let addressIndex: number = portIndex + 2 199 | const addressBuffer: Uint8Array = new Uint8Array( 200 | vlessBuffer.slice(addressIndex, addressIndex + 1) 201 | ) 202 | 203 | const addressType: number = addressBuffer[0] 204 | let addressLength: number = 0 205 | let addressValueIndex: number = addressIndex + 1 206 | let addressValue: string = "" 207 | 208 | switch (addressType) { 209 | case 1: 210 | addressLength = 4 211 | addressValue = new Uint8Array( 212 | vlessBuffer.slice(addressValueIndex, addressValueIndex + addressLength) 213 | ).join(".") 214 | break 215 | case 2: 216 | addressLength = new Uint8Array( 217 | vlessBuffer.slice(addressValueIndex, addressValueIndex + 1) 218 | )[0] 219 | addressValueIndex += 1 220 | addressValue = new TextDecoder().decode( 221 | vlessBuffer.slice(addressValueIndex, addressValueIndex + addressLength) 222 | ) 223 | break 224 | case 3: 225 | addressLength = 16 226 | const dataView = new DataView( 227 | vlessBuffer.slice(addressValueIndex, addressValueIndex + addressLength) 228 | ) 229 | const ipv6: Array = [] 230 | for (let i = 0; i < 8; i++) { 231 | ipv6.push(dataView.getUint16(i * 2).toString(16)) 232 | } 233 | addressValue = ipv6.join(":") 234 | break 235 | default: 236 | return { 237 | hasError: true, 238 | message: `invild addressType is ${addressType}`, 239 | } as VlessHeader 240 | } 241 | if (!addressValue) { 242 | return { 243 | hasError: true, 244 | message: `addressValue is empty, addressType is ${addressType}`, 245 | } as VlessHeader 246 | } 247 | 248 | return { 249 | hasError: false, 250 | addressRemote: addressValue, 251 | addressType: addressType, 252 | portRemote: portRemote, 253 | rawDataIndex: addressValueIndex + addressLength, 254 | vlessVersion: version, 255 | isUDP: isUDP, 256 | isMUX: isMUX, 257 | } as VlessHeader 258 | } 259 | 260 | async function HandleUDPOutbound(webSocket: WebSocket, vlessResponseHeader: ArrayBuffer, env: Env): Promise { 261 | let isVlessHeaderSent = false 262 | const transformStream = new TransformStream({ 263 | transform(chunk, controller) { 264 | for (let index: number = 0; index < chunk.byteLength;) { 265 | const lengthBuffer = chunk.slice(index, index + 2) 266 | const udpPakcetLength = new DataView(lengthBuffer).getUint16(0) 267 | const udpData = new Uint8Array( 268 | chunk.slice(index + 2, index + 2 + udpPakcetLength) 269 | ) 270 | index = index + 2 + udpPakcetLength 271 | controller.enqueue(udpData) 272 | } 273 | } 274 | }) 275 | 276 | if (blockPorn == "") { 277 | blockPorn = await env.settings.get("BlockPorn") || 'no' 278 | } 279 | 280 | // only handle dns udp for now 281 | transformStream.readable.pipeTo(new WritableStream({ 282 | async write(chunk: any) { 283 | const resp = await fetch(blockPorn == "yes" ? "https://1.1.1.3/dns-query": "https://1.1.1.1/dns-query", { 284 | method: 'POST', 285 | headers: { 286 | 'content-type': 'application/dns-message', 287 | }, 288 | body: chunk, 289 | }) 290 | const dnsQueryResult: ArrayBuffer = await resp.arrayBuffer() 291 | const udpSize: number = dnsQueryResult.byteLength 292 | const udpSizeBuffer: Uint8Array = new Uint8Array([(udpSize >> 8) & 0xff, udpSize & 0xff]) 293 | if (webSocket.readyState === WS_READY_STATE_OPEN) { 294 | if (isVlessHeaderSent) { 295 | webSocket.send(await new Blob([udpSizeBuffer, dnsQueryResult]).arrayBuffer()) 296 | } else { 297 | webSocket.send(await new Blob([vlessResponseHeader, udpSizeBuffer, dnsQueryResult]).arrayBuffer()) 298 | isVlessHeaderSent = true 299 | } 300 | } 301 | } 302 | })).catch((error) => { }) 303 | 304 | const writer: WritableStreamDefaultWriter = transformStream.writable.getWriter() 305 | return { 306 | write(chunk: Uint8Array) { 307 | writer.write(chunk) 308 | } 309 | } 310 | } 311 | 312 | async function HandleTCPOutbound(remoteSocket: RemoteSocketWrapper, addressRemote: string, portRemote: number, rawClientData: Uint8Array, webSocket: WebSocket, vlessResponseHeader: Uint8Array, env: Env): Promise { 313 | const maxRetryCount = 5 314 | let retryCount = 0; 315 | 316 | async function connectAndWrite(address: string, port: number) { 317 | const socketAddress: SocketAddress = { 318 | hostname: address, 319 | port: port, 320 | } 321 | const socketOptions: SocketOptions = { 322 | allowHalfOpen: false, 323 | // secureTransport: "starttls", 324 | } 325 | const tcpSocket: Socket = connect(socketAddress, socketOptions)//.startTls() 326 | remoteSocket.value = tcpSocket 327 | const writer: WritableStreamDefaultWriter = tcpSocket.writable.getWriter() 328 | await writer.write(rawClientData) 329 | writer.releaseLock() 330 | return tcpSocket 331 | } 332 | 333 | async function retry() { 334 | retryCount++ 335 | if (retryCount > maxRetryCount) { 336 | return 337 | } 338 | 339 | if (!proxyList.length) { 340 | countries = (await env.settings.get("Countries"))?.split(",").filter(t => t.trim().length > 0) || [] 341 | proxyList = await fetch(proxiesUri).then(r => r.text()).then(t => t.trim().split("\n").filter(t => t.trim().length > 0)) 342 | if (countries.length > 0) { 343 | proxyList = proxyList.filter(t => { 344 | const arr = t.split(",") 345 | if (arr.length > 0) { 346 | return countries.includes(arr[1]) 347 | } 348 | }) 349 | } 350 | proxyList = proxyList.map(ip => ip.split(",")[0]) 351 | console.log(proxyList) 352 | } 353 | if (proxyList.length > 0) { 354 | proxyIP = proxyList[Math.floor(Math.random() * proxyList.length)] 355 | const tcpSocket: Socket = await connectAndWrite(proxyIP, portRemote) 356 | RemoteSocketToWS(tcpSocket, webSocket, vlessResponseHeader, retry) 357 | } 358 | } 359 | 360 | const tcpSocket: Socket = await connectAndWrite(addressRemote, portRemote) 361 | RemoteSocketToWS(tcpSocket, webSocket, vlessResponseHeader, retry) 362 | } 363 | 364 | async function RemoteSocketToWS(remoteSocket: Socket, webSocket: WebSocket, vlessResponseHeader: ArrayBuffer, retry: (() => Promise) | null): Promise { 365 | let vlessHeader: ArrayBuffer | null = vlessResponseHeader 366 | let hasIncomingData: boolean = false 367 | await remoteSocket.readable 368 | .pipeTo( 369 | new WritableStream({ 370 | async write(chunk: Uint8Array, controller: WritableStreamDefaultController) { 371 | try { 372 | hasIncomingData = true 373 | if (webSocket.readyState !== WS_READY_STATE_OPEN) { 374 | controller.error("webSocket.readyState is not open, maybe close") 375 | } 376 | if (vlessHeader) { 377 | webSocket.send(await new Blob([vlessHeader, chunk]).arrayBuffer()) 378 | vlessHeader = null 379 | } else { 380 | webSocket.send(chunk) 381 | } 382 | } catch (e) { } 383 | }, 384 | abort(reason: any) { 385 | // console.error("remoteConnection!.readable abort", reason) 386 | }, 387 | }) 388 | ) 389 | .catch((error) => { 390 | // console.error("remoteSocketToWS has exception ", error.stack || error) 391 | SafeCloseWebSocket(webSocket) 392 | }) 393 | 394 | if (hasIncomingData === false && retry) { 395 | retry() 396 | } 397 | } 398 | 399 | function SafeCloseWebSocket(socket: WebSocket): void { 400 | try { 401 | if (socket.readyState === WS_READY_STATE_OPEN || socket.readyState === WS_READY_STATE_CLOSING) { 402 | socket.close() 403 | } 404 | } catch (error) { } 405 | } 406 | 407 | function Base64ToArrayBuffer(base64Str: string): CustomArrayBuffer { 408 | if (!base64Str) { 409 | return { 410 | earlyData: null, 411 | error: null 412 | } 413 | } 414 | try { 415 | base64Str = base64Str.replace(/-/g, '+').replace(/_/g, '/') 416 | const decode: string = atob(base64Str) 417 | const arryBuffer: Uint8Array = Uint8Array.from(decode, (c) => c.charCodeAt(0)) 418 | return { 419 | earlyData: arryBuffer.buffer, 420 | error: null 421 | } 422 | } catch (error) { 423 | return { 424 | earlyData: null, 425 | error 426 | } 427 | } 428 | } 429 | 430 | function IsValidVlessUUID(uuid: string): boolean { 431 | return /^[0-9a-f]{8}-[0-9a-f]{4}-[5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(uuid); 432 | } 433 | 434 | function Stringify(arr: Uint8Array, offset: number = 0): string { 435 | const uuid = UnsafeStringify(arr, offset); 436 | if (!IsValidVlessUUID(uuid)) { 437 | throw TypeError("Stringified UUID is invalid"); 438 | } 439 | return uuid; 440 | } 441 | 442 | const byteToHex: Array = []; 443 | for (let i = 0; i < 256; ++i) { 444 | byteToHex.push((i + 256).toString(16).slice(1)); 445 | } 446 | 447 | function UnsafeStringify(arr: Uint8Array, offset = 0) : string { 448 | return `${ 449 | byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] 450 | }-${ 451 | byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] 452 | }-${ 453 | byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] 454 | }-${ 455 | byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] 456 | }-${ 457 | byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]] 458 | }`.toLowerCase(); 459 | } 460 | -------------------------------------------------------------------------------- /src/worker.ts: -------------------------------------------------------------------------------- 1 | import { VlessOverWSHandler } from "./vless" 2 | import { TrojanOverWSHandler } from "./trojan" 3 | import { GetPanel, PostPanel } from "./panel" 4 | import { GetLogin, PostLogin } from "./auth" 5 | import { GetConfigList } from "./collector" 6 | import { ToYamlSubscription } from "./clash" 7 | import { ToBase64Subscription, ToRawSubscription } from "./sub" 8 | // import { ToCustomConfigSubscription } from "./custom" 9 | import { Env, Config } from "./interfaces" 10 | 11 | let panelPath = "" 12 | 13 | export default { 14 | async fetch(request: Request, env: Env): Promise { 15 | const url: URL = new URL(request.url) 16 | const path: string = url.pathname.replace(/^\/|\/$/g, "") 17 | const lcPath = path.toLowerCase() 18 | 19 | if (["sub", "clash", /*"custom", */"raw"].includes(lcPath)) { 20 | const configList: Array = await GetConfigList(url, env) 21 | if (lcPath == "clash") { 22 | return new Response(ToYamlSubscription(configList)); 23 | // } else if (lcPath == "custom") { 24 | // return new Response(ToCustomConfigSubscription(configList)); 25 | } else if (lcPath == "raw") { 26 | return new Response(ToRawSubscription(configList)); 27 | } else { 28 | return new Response(ToBase64Subscription(configList)); 29 | } 30 | } else if (lcPath == "vless-ws") { 31 | return VlessOverWSHandler(request, url.hostname, env); 32 | } else if (lcPath == "trojan-ws") { 33 | return TrojanOverWSHandler(request, url.hostname, env); 34 | } else if (lcPath == "login") { 35 | if (request.method === "GET") { 36 | return GetLogin(request, env) 37 | } else if (request.method === "POST") { 38 | return PostLogin(request, env) 39 | } 40 | } else if (path) { 41 | return fetch(new Request(new URL("https://" + path), request)) 42 | } else { 43 | if (request.method === "GET") { 44 | return GetPanel(request, env) 45 | } else if (request.method === "POST") { 46 | return PostPanel(request, env) 47 | } 48 | } 49 | return new Response("Invalid request!"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | "lib": ["es2021"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | "jsx": "react", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ 22 | // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | 26 | /* Modules */ 27 | "module": "es2022", /* Specify what module code is generated. */ 28 | // "rootDir": "./", /* Specify the root folder within your source files. */ 29 | "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ 30 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 31 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 32 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 33 | // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ 34 | "types": [ 35 | "@cloudflare/workers-types", 36 | "@types/node", 37 | ], /* Specify type package names to be included without being referenced in a source file. */ 38 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 39 | "resolveJsonModule": true, /* Enable importing .json files */ 40 | // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ 41 | 42 | /* JavaScript Support */ 43 | "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ 44 | "checkJs": false, /* Enable error reporting in type-checked JavaScript files. */ 45 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ 46 | 47 | /* Emit */ 48 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 49 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 50 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 51 | "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 52 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ 53 | // "outDir": "./", /* Specify an output folder for all emitted files. */ 54 | "removeComments": false /* Disable emitting comments. */, 55 | "noEmit": true, /* Disable emitting files from a compilation. */ 56 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 57 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ 58 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 59 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 60 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 61 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 62 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 63 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 64 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 65 | // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ 66 | // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ 67 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 68 | // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ 69 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 70 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 71 | 72 | /* Interop Constraints */ 73 | "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 74 | "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 75 | // "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ 76 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 77 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 78 | 79 | /* Type Checking */ 80 | "strict": true, /* Enable all strict type-checking options. */ 81 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ 82 | // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ 83 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 84 | // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ 85 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 86 | // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ 87 | // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ 88 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 89 | // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ 90 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ 91 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 92 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 93 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 94 | // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ 95 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 96 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ 97 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 98 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 99 | 100 | /* Completeness */ 101 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 102 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /worker-configuration.d.ts: -------------------------------------------------------------------------------- 1 | interface Env { 2 | // Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/ 3 | // MY_KV_NAMESPACE: KVNamespace; 4 | // 5 | // Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/ 6 | // MY_DURABLE_OBJECT: DurableObjectNamespace; 7 | // 8 | // Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/ 9 | // MY_BUCKET: R2Bucket; 10 | // 11 | // Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/ 12 | // MY_SERVICE: Fetcher; 13 | // 14 | // Example binding to a Queue. Learn more at https://developers.cloudflare.com/queues/javascript-apis/ 15 | // MY_QUEUE: Queue; 16 | } 17 | -------------------------------------------------------------------------------- /wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "sub" 2 | main = "src/worker.ts" 3 | compatibility_date = "2024-05-29" 4 | compatibility_flags = ["nodejs_compat"] 5 | 6 | kv_namespaces = [ 7 | { binding = "settings", id = "KV_NAME" } 8 | ] 9 | --------------------------------------------------------------------------------