├── .htaccess ├── License ├── Readme.md ├── img ├── .icon.svg ├── icon.png └── icon │ ├── .config.json │ ├── fontello.css │ └── fontello.woff2 ├── index.html ├── lib ├── anchorme.min.js ├── base64js.min.js ├── bulma.min.css ├── msgpack.min.js └── pell │ ├── .ver │ ├── actions.js │ ├── pell.css │ ├── pell.js │ └── utilities.js ├── manifest.json ├── src ├── app.js ├── lang │ └── lang.js └── utils │ ├── helper.js │ └── idb.js ├── sw.js └── tools ├── aes ├── aes-mount.sh └── gen_sw.sh /.htaccess: -------------------------------------------------------------------------------- 1 | Header set Access-Control-Allow-Origin "*" 2 | 3 | RewriteEngine On 4 | RewriteCond %{HTTPS} !=on 5 | RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 6 | -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 DUKELEC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | This is a PWA (Progressive Web Apps) encryption tool. 2 | It uses the AES-256-CBC encryption algorithm and uses string as password. 3 | 4 | - When the encrypted data is small, the encrypted content is directly shared in the URL: `https://CDE_TOOL_URL/#BASE64_STRING`. 5 | - When the encrypted data is large, such as including pictures, videos, and files, you need to share the packaged encrypted file with `https://CDE_TOOL_URL` separately. 6 | - You can also upload encrypted file to a file server and simply share the URL as follows: `https://CDE_TOOL_URL/#:https://ENCRYPTED_FILE_URL` (`https://` after `#:` is optional) (The file server should support CORS, or use CORS proxy instead). 7 | 8 | `tools/aes` is a script encryption tool that uses the openssl command, which can be used to verify the correctness of web page encryption. 9 | More specific packaging formats can be found at the top of the `src/app.js` comments. 10 | -------------------------------------------------------------------------------- /img/.icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /img/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dukelec/cde/687f60c4a684cf6eddf0050e95b377ff1511ec00/img/icon.png -------------------------------------------------------------------------------- /img/icon/.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "css_prefix_text": "fa-", 4 | "css_use_suffix": false, 5 | "hinting": true, 6 | "units_per_em": 1000, 7 | "ascent": 850, 8 | "glyphs": [ 9 | { 10 | "uid": "4c6c7d8fdb866ba292790696b18d839c", 11 | "css": "key", 12 | "code": 59392, 13 | "src": "custom_icons", 14 | "selected": true, 15 | "svg": { 16 | "path": "M1000 343.8C1000 533.6 846.1 687.5 656.3 687.5 634.3 687.5 612.9 685.4 592.1 681.5L545.2 734.3A46.9 46.9 0 0 1 510.2 750H437.5V828.1C437.5 854 416.5 875 390.6 875H312.5V953.1C312.5 979 291.5 1000 265.6 1000H46.9C21 1000 0 979 0 953.1V800.7C0 788.2 4.9 776.3 13.7 767.5L329.7 451.5C318.6 417.6 312.5 381.4 312.5 343.8 312.5 153.9 466.4 0 656.2 0 846.7 0 1000 153.3 1000 343.8ZM656.3 250C656.3 301.8 698.2 343.8 750 343.8S843.8 301.8 843.8 250 801.8 156.3 750 156.3 656.3 198.2 656.3 250Z", 17 | "width": 1000 18 | }, 19 | "search": [ 20 | "fa-key" 21 | ] 22 | }, 23 | { 24 | "uid": "f8cb57a93a9beeef2348e735a408aafa", 25 | "css": "bars", 26 | "code": 59393, 27 | "src": "custom_icons", 28 | "selected": true, 29 | "svg": { 30 | "path": "M31.3 257.8H843.8C861 257.8 875 243.8 875 226.6V148.4C875 131.2 861 117.2 843.8 117.2H31.3C14 117.2 0 131.2 0 148.4V226.6C0 243.8 14 257.8 31.3 257.8ZM31.3 570.3H843.8C861 570.3 875 556.3 875 539.1V460.9C875 443.7 861 429.7 843.8 429.7H31.3C14 429.7 0 443.7 0 460.9V539.1C0 556.3 14 570.3 31.3 570.3ZM31.3 882.8H843.8C861 882.8 875 868.8 875 851.6V773.4C875 756.2 861 742.2 843.8 742.2H31.3C14 742.2 0 756.2 0 773.4V851.6C0 868.8 14 882.8 31.3 882.8Z", 31 | "width": 875 32 | }, 33 | "search": [ 34 | "svg1" 35 | ] 36 | }, 37 | { 38 | "uid": "873da36d78081ac2e56763e65c237445", 39 | "css": "upload", 40 | "code": 59394, 41 | "src": "custom_icons", 42 | "selected": true, 43 | "svg": { 44 | "path": "M578.1 750H421.9C395.9 750 375 729.1 375 703.1V375H203.7C168.9 375 151.6 333 176.2 308.4L473.2 11.1C487.9-3.5 511.9-3.5 526.6 11.1L823.8 308.4C848.4 333 831.1 375 796.3 375H625V703.1C625 729.1 604.1 750 578.1 750ZM1000 734.4V953.1C1000 979.1 979.1 1000 953.1 1000H46.9C20.9 1000 0 979.1 0 953.1V734.4C0 708.4 20.9 687.5 46.9 687.5H312.5V703.1C312.5 763.5 361.5 812.5 421.9 812.5H578.1C638.5 812.5 687.5 763.5 687.5 703.1V687.5H953.1C979.1 687.5 1000 708.4 1000 734.4ZM757.8 906.3C757.8 884.8 740.2 867.2 718.8 867.2S679.7 884.8 679.7 906.3 697.3 945.3 718.8 945.3 757.8 927.7 757.8 906.3ZM882.8 906.3C882.8 884.8 865.2 867.2 843.8 867.2S804.7 884.8 804.7 906.3 822.3 945.3 843.8 945.3 882.8 927.7 882.8 906.3Z", 45 | "width": 1000 46 | }, 47 | "search": [ 48 | "svg2" 49 | ] 50 | }, 51 | { 52 | "uid": "241dbad2b50e215838610601a3c19bcb", 53 | "css": "comment-alt", 54 | "code": 59395, 55 | "src": "custom_icons", 56 | "selected": true, 57 | "svg": { 58 | "path": "M875 0H125C56.1 0 0 56.1 0 125V687.5C0 756.4 56.1 812.5 125 812.5H312.5V976.6C312.5 990.4 323.8 1000 335.9 1000 340.6 1000 345.5 998.6 349.8 995.3L593.8 812.5H875C943.9 812.5 1000 756.4 1000 687.5V125C1000 56.1 943.9 0 875 0ZM906.3 687.5C906.3 704.7 892.2 718.8 875 718.8H562.5L537.5 737.5 406.3 835.9V718.8H125C107.8 718.8 93.8 704.7 93.8 687.5V125C93.8 107.8 107.8 93.8 125 93.8H875C892.2 93.8 906.3 107.8 906.3 125V687.5Z", 59 | "width": 1000 60 | }, 61 | "search": [ 62 | "svg3" 63 | ] 64 | }, 65 | { 66 | "uid": "e662585e72f0082431238fe66a0f2c98", 67 | "css": "sync", 68 | "code": 59396, 69 | "src": "custom_icons", 70 | "selected": true, 71 | "svg": { 72 | "path": "M861.2 24.6L868.9 186.2C780.1 81.8 647.8 15.6 500 15.6 263.3 15.6 66.3 185.4 24 409.8 21.3 424.2 32.4 437.5 47.1 437.5H142.9C153.8 437.5 163.2 430 165.7 419.4 202 268.4 337.8 156.3 500 156.3 618.9 156.3 723.7 216.5 785.4 308.2L587.1 298.7C573.7 298.1 562.5 308.7 562.5 322.1V414.7C562.5 427.7 573 438.2 585.9 438.2H977.2C990.2 438.2 1000.7 427.7 1000.7 414.7V23.4C1000.7 10.5 990.2 0 977.2 0H884.6C871.2 0 860.6 11.2 861.2 24.6ZM500 843.8C381.1 843.8 276.3 783.5 214.6 691.8L413.6 701.3C427 701.9 438.1 691.3 438.1 677.9V585.3C438.1 572.3 427.7 561.9 414.7 561.9H23.4C10.5 561.9 0 572.3 0 585.3V976.6C0 989.5 10.5 1000 23.4 1000H116C129.4 1000 140.1 988.8 139.4 975.4L131.3 814.1C220.2 918.3 352.4 984.4 500 984.4 736.7 984.4 933.7 814.6 976 590.2 978.7 575.8 967.6 562.5 952.9 562.5H857.1C846.2 562.5 836.8 570 834.3 580.6 798 731.6 662.2 843.8 500 843.8Z", 73 | "width": 1000 74 | }, 75 | "search": [ 76 | "svg4" 77 | ] 78 | }, 79 | { 80 | "uid": "efe646b1dbef940d67ba7f6e8ac4c460", 81 | "css": "sign-out-alt", 82 | "code": 59397, 83 | "src": "custom_icons", 84 | "selected": true, 85 | "svg": { 86 | "path": "M970.7 533.2L642.6 861.3C613.3 890.6 562.5 870.1 562.5 828.1V640.6H296.9C270.9 640.6 250 619.7 250 593.8V406.3C250 380.3 270.9 359.4 296.9 359.4H562.5V171.9C562.5 130.1 613.1 109.4 642.6 138.7L970.7 466.8C988.9 485.2 988.9 514.8 970.7 533.2ZM375 851.6V773.4C375 760.5 364.5 750 351.6 750H187.5C152.9 750 125 722.1 125 687.5V312.5C125 277.9 152.9 250 187.5 250H351.6C364.5 250 375 239.5 375 226.6V148.4C375 135.5 364.5 125 351.6 125H187.5C84 125 0 209 0 312.5V687.5C0 791 84 875 187.5 875H351.6C364.5 875 375 864.5 375 851.6Z", 87 | "width": 1000 88 | }, 89 | "search": [ 90 | "svg5" 91 | ] 92 | }, 93 | { 94 | "uid": "fca49f13e63f75dc652c1cc3970b893d", 95 | "css": "github", 96 | "code": 59398, 97 | "src": "custom_icons", 98 | "selected": true, 99 | "svg": { 100 | "path": "M324 776.2C324 780.1 319.5 783.2 313.9 783.2 307.4 783.8 302.9 780.7 302.9 776.2 302.9 772.3 307.4 769.1 313.1 769.1 318.9 768.6 324 771.7 324 776.2ZM263.3 767.4C261.9 771.3 265.8 775.8 271.7 777 276.8 778.9 282.6 777 283.8 773S281.3 764.6 275.4 762.9C270.3 761.5 264.6 763.5 263.3 767.4ZM349.6 764.1C343.9 765.4 340 769.1 340.6 773.6 341.2 777.5 346.3 780.1 352.1 778.7 357.8 777.3 361.7 773.6 361.1 769.7 360.5 766 355.3 763.5 349.6 764.1ZM478.1 15.6C207.2 15.6 0 221.3 0 492.2 0 708.8 136.3 894.1 331.1 959.4 356.1 963.9 364.8 948.4 364.8 935.7 364.8 923.6 364.3 856.8 364.3 815.8 364.3 815.8 227.5 845.1 198.8 757.6 198.8 757.6 176.6 700.8 144.5 686.1 144.5 686.1 99.8 655.5 147.7 656.1 147.7 656.1 196.3 660 223 706.4 265.8 781.8 337.5 760.2 365.4 747.3 369.9 716 382.6 694.3 396.7 681.4 287.5 669.3 177.3 653.5 177.3 465.6 177.3 411.9 192.2 385 223.4 350.6 218.4 337.9 201.8 285.5 228.5 218 269.3 205.3 363.3 270.7 363.3 270.7 402.3 259.8 444.3 254.1 485.9 254.1S569.5 259.8 608.6 270.7C608.6 270.7 702.5 205.1 743.4 218 770.1 285.7 753.5 337.9 748.4 350.6 779.7 385.2 798.8 412.1 798.8 465.6 798.8 654.1 683.8 669.1 574.6 681.4 592.6 696.9 607.8 726.2 607.8 772.1 607.8 837.9 607.2 919.3 607.2 935.4 607.2 948 616.2 963.5 641 959 836.3 894.1 968.8 708.8 968.8 492.2 968.8 221.3 749 15.6 478.1 15.6ZM189.8 689.3C187.3 691.2 187.9 695.7 191.2 699.4 194.3 702.5 198.8 703.9 201.4 701.4 203.9 699.4 203.3 694.9 200 691.2 196.9 688.1 192.4 686.7 189.8 689.3ZM168.8 673.4C167.4 676 169.3 679.1 173.2 681.1 176.4 683 180.3 682.4 181.6 679.7 183 677.1 181.1 674 177.1 672.1 173.2 670.9 170.1 671.5 168.8 673.4ZM232 743C228.9 745.5 230.1 751.4 234.6 755.1 239.1 759.6 244.7 760.2 247.3 757 249.8 754.5 248.6 748.6 244.7 744.9 240.4 740.4 234.6 739.8 232 743ZM209.8 714.3C206.6 716.2 206.6 721.3 209.8 725.8 212.9 730.3 218.2 732.2 220.7 730.3 223.8 727.7 223.8 722.7 220.7 718.2 218 713.7 212.9 711.7 209.8 714.3Z", 101 | "width": 969 102 | }, 103 | "search": [ 104 | "svg6" 105 | ] 106 | }, 107 | { 108 | "uid": "dd853798911520681db8e2954fa9613d", 109 | "css": "arrow-down", 110 | "code": 59399, 111 | "src": "custom_icons", 112 | "selected": true, 113 | "svg": { 114 | "path": "M806.8 434.6L850.2 477.9C868.6 496.3 868.6 526 850.2 544.1L470.7 923.8C452.3 942.2 422.7 942.2 404.5 923.8L24.8 544.1C6.4 525.8 6.4 496.1 24.8 477.9L68.2 434.6C86.7 416 117 416.4 135.2 435.4L359.4 670.7V109.4C359.4 83.4 380.3 62.5 406.3 62.5H468.8C494.7 62.5 515.6 83.4 515.6 109.4V670.7L739.8 435.4C758 416.2 788.3 415.8 806.8 434.6Z", 115 | "width": 875 116 | }, 117 | "search": [ 118 | "svg7" 119 | ] 120 | }, 121 | { 122 | "uid": "087aa45700fb6cd1f1b91b352626b2fd", 123 | "css": "arrow-up", 124 | "code": 59400, 125 | "src": "custom_icons", 126 | "selected": true, 127 | "svg": { 128 | "path": "M68.2 565.4L24.8 522.1C6.4 503.7 6.4 474 24.8 455.9L404.3 76.2C422.7 57.8 452.3 57.8 470.5 76.2L850 455.7C868.4 474 868.4 503.7 850 521.9L806.6 565.2C788.1 583.8 757.8 583.4 739.6 564.5L515.6 329.3V890.6C515.6 916.6 494.7 937.5 468.8 937.5H406.3C380.3 937.5 359.4 916.6 359.4 890.6V329.3L135.2 564.6C117 583.8 86.7 584.2 68.2 565.4Z", 129 | "width": 875 130 | }, 131 | "search": [ 132 | "svg8" 133 | ] 134 | }, 135 | { 136 | "uid": "c2eb11a1dd9c40fd73ee909bd9908b76", 137 | "css": "eraser", 138 | "code": 59401, 139 | "src": "custom_icons", 140 | "selected": true, 141 | "svg": { 142 | "path": "M972.5 535C1009.2 498.4 1009.2 439.1 972.5 402.5L660 90C623.4 53.3 564.1 53.3 527.5 90L27.5 590C-9.2 626.6-9.2 685.9 27.5 722.5L215 910A93.8 93.8 0 0 0 281.3 937.5H976.6C989.5 937.5 1000 927 1000 914.1V835.9C1000 823 989.5 812.5 976.6 812.5H695.1L972.5 535ZM381.5 412.7L649.8 681 518.3 812.5H294.2L137.9 656.3 381.5 412.7Z", 143 | "width": 1000 144 | }, 145 | "search": [ 146 | "svg9" 147 | ] 148 | }, 149 | { 150 | "uid": "8420c3753d5508a45bd9ec4df82a332b", 151 | "css": "share-alt", 152 | "code": 59402, 153 | "src": "custom_icons", 154 | "selected": true, 155 | "svg": { 156 | "path": "M687.5 625C643.3 625 602.8 640.3 570.7 665.8L370.6 540.7A188.6 188.6 0 0 0 370.6 459.3L570.7 334.2C602.8 359.7 643.3 375 687.5 375 791.1 375 875 291.1 875 187.5S791.1 0 687.5 0 500 83.9 500 187.5C500 201.5 501.5 215.1 504.4 228.2L304.3 353.3C272.2 327.8 231.7 312.5 187.5 312.5 83.9 312.5 0 396.4 0 500S83.9 687.5 187.5 687.5C231.7 687.5 272.2 672.2 304.3 646.7L504.4 771.8A188.1 188.1 0 0 0 500 812.5C500 916.1 583.9 1000 687.5 1000S875 916.1 875 812.5 791.1 625 687.5 625Z", 157 | "width": 875 158 | }, 159 | "search": [ 160 | "svg10" 161 | ] 162 | }, 163 | { 164 | "uid": "d1346bc75190a8da75c6add2740753f7", 165 | "css": "clipboard", 166 | "code": 59403, 167 | "src": "custom_icons", 168 | "selected": true, 169 | "svg": { 170 | "path": "M656.3 125H500C500 56.1 443.9 0 375 0S250 56.1 250 125H93.8C42 125 0 167 0 218.8V906.3C0 958 42 1000 93.8 1000H656.3C708 1000 750 958 750 906.3V218.8C750 167 708 125 656.3 125ZM644.5 906.3H105.5A11.7 11.7 0 0 1 93.8 894.5V230.5A11.7 11.7 0 0 1 105.5 218.8H187.5V289.1C187.5 302 198 312.5 210.9 312.5H539.1C552 312.5 562.5 302 562.5 289.1V218.8H644.5A11.7 11.7 0 0 1 656.3 230.5V894.5A11.7 11.7 0 0 1 644.5 906.3ZM375 78.1C400.9 78.1 421.9 99.1 421.9 125S400.9 171.9 375 171.9 328.1 150.9 328.1 125 349.1 78.1 375 78.1", 171 | "width": 750 172 | }, 173 | "search": [ 174 | "svg11" 175 | ] 176 | }, 177 | { 178 | "uid": "776fba3066c7cd4a3814e4e1c1497ca8", 179 | "css": "file-download", 180 | "code": 59404, 181 | "src": "custom_icons", 182 | "selected": true, 183 | "svg": { 184 | "path": "M437.5 265.6V0H46.9C20.9 0 0 20.9 0 46.9V953.1C0 979.1 20.9 1000 46.9 1000H703.1C729.1 1000 750 979.1 750 953.1V312.5H484.4C458.6 312.5 437.5 291.4 437.5 265.6ZM586.8 678.4L398.5 865.4C385.5 878.3 364.5 878.3 351.5 865.4L163.2 678.4C143.4 658.8 157.3 625 185.2 625H312.5V468.8C312.5 451.5 326.5 437.5 343.8 437.5H406.3C423.5 437.5 437.5 451.5 437.5 468.8V625H564.8C592.7 625 606.6 658.8 586.8 678.4ZM736.3 205.1L545.1 13.7C536.3 4.9 524.4 0 511.9 0H500V250H750V238.1C750 225.8 745.1 213.9 736.3 205.1Z", 185 | "width": 750 186 | }, 187 | "search": [ 188 | "svg12" 189 | ] 190 | } 191 | ] 192 | } -------------------------------------------------------------------------------- /img/icon/fontello.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'fontello'; 3 | src: url('./fontello.woff2?5295219'); 4 | font-weight: normal; 5 | font-style: normal; 6 | } 7 | /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */ 8 | /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */ 9 | /* 10 | @media screen and (-webkit-min-device-pixel-ratio:0) { 11 | @font-face { 12 | font-family: 'fontello'; 13 | src: url('../font/fontello.svg?5295219#fontello') format('svg'); 14 | } 15 | } 16 | */ 17 | 18 | [class^="fa-"]:before, [class*=" fa-"]:before { 19 | font-family: "fontello"; 20 | font-style: normal; 21 | font-weight: normal; 22 | speak: none; 23 | 24 | display: inline-block; 25 | text-decoration: inherit; 26 | width: 1em; 27 | margin-right: .2em; 28 | text-align: center; 29 | /* opacity: .8; */ 30 | 31 | /* For safety - reset parent styles, that can break glyph codes*/ 32 | font-variant: normal; 33 | text-transform: none; 34 | 35 | /* fix buttons height, for twitter bootstrap */ 36 | line-height: 1em; 37 | 38 | /* Animation center compensation - margins should be symmetric */ 39 | /* remove if not needed */ 40 | margin-left: .2em; 41 | 42 | /* you can be more comfortable with increased icons size */ 43 | /* font-size: 120%; */ 44 | 45 | /* Font smoothing. That was taken from TWBS */ 46 | -webkit-font-smoothing: antialiased; 47 | -moz-osx-font-smoothing: grayscale; 48 | 49 | /* Uncomment for 3D effect */ 50 | /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ 51 | } 52 | 53 | .fa-key:before { content: '\e800'; } /* '' */ 54 | .fa-bars:before { content: '\e801'; } /* '' */ 55 | .fa-upload:before { content: '\e802'; } /* '' */ 56 | .fa-comment-alt:before { content: '\e803'; } /* '' */ 57 | .fa-sync:before { content: '\e804'; } /* '' */ 58 | .fa-sign-out-alt:before { content: '\e805'; } /* '' */ 59 | .fa-github:before { content: '\e806'; } /* '' */ 60 | .fa-arrow-down:before { content: '\e807'; } /* '' */ 61 | .fa-arrow-up:before { content: '\e808'; } /* '' */ 62 | .fa-eraser:before { content: '\e809'; } /* '' */ 63 | .fa-share-alt:before { content: '\e80a'; } /* '' */ 64 | .fa-clipboard:before { content: '\e80b'; } /* '' */ 65 | .fa-file-download:before { content: '\e80c'; } /* '' */ 66 | -------------------------------------------------------------------------------- /img/icon/fontello.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dukelec/cde/687f60c4a684cf6eddf0050e95b377ff1511ec00/img/icon/fontello.woff2 -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | CDEncrypt 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 72 | 73 | Loading... 74 | 75 | 267 | 268 | 269 | -------------------------------------------------------------------------------- /lib/anchorme.min.js: -------------------------------------------------------------------------------- 1 | !function(A,u){"object"==typeof exports&&"undefined"!=typeof module?module.exports=u():"function"==typeof define&&define.amd?define(u):(A=A||self).anchorme=u()}(this,function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function A(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}function u(A,u){return A(u={exports:{}},u.exports),u.exports}var N=u(function(A,u){Object.defineProperty(u,"__esModule",{value:!0}),u.TLDs="(AAA|AARP|ABARTH|ABB|ABBOTT|ABBVIE|ABC|ABLE|ABOGADO|ABUDHABI|AC|ACADEMY|ACCENTURE|ACCOUNTANT|ACCOUNTANTS|ACO|ACTOR|AD|ADAC|ADS|ADULT|AE|AEG|AERO|AETNA|AF|AFAMILYCOMPANY|AFL|AFRICA|AG|AGAKHAN|AGENCY|AI|AIG|AIGO|AIRBUS|AIRFORCE|AIRTEL|AKDN|AL|ALFAROMEO|ALIBABA|ALIPAY|ALLFINANZ|ALLSTATE|ALLY|ALSACE|ALSTOM|AM|AMERICANEXPRESS|AMERICANFAMILY|AMEX|AMFAM|AMICA|AMSTERDAM|ANALYTICS|ANDROID|ANQUAN|ANZ|AO|AOL|APARTMENTS|APP|APPLE|AQ|AQUARELLE|AR|ARAB|ARAMCO|ARCHI|ARMY|ARPA|ART|ARTE|AS|ASDA|ASIA|ASSOCIATES|AT|ATHLETA|ATTORNEY|AU|AUCTION|AUDI|AUDIBLE|AUDIO|AUSPOST|AUTHOR|AUTO|AUTOS|AVIANCA|AW|AWS|AX|AXA|AZ|AZURE|BA|BABY|BAIDU|BANAMEX|BANANAREPUBLIC|BAND|BANK|BAR|BARCELONA|BARCLAYCARD|BARCLAYS|BAREFOOT|BARGAINS|BASEBALL|BASKETBALL|BAUHAUS|BAYERN|BB|BBC|BBT|BBVA|BCG|BCN|BD|BE|BEATS|BEAUTY|BEER|BENTLEY|BERLIN|BEST|BESTBUY|BET|BF|BG|BH|BHARTI|BI|BIBLE|BID|BIKE|BING|BINGO|BIO|BIZ|BJ|BLACK|BLACKFRIDAY|BLOCKBUSTER|BLOG|BLOOMBERG|BLUE|BM|BMS|BMW|BN|BNPPARIBAS|BO|BOATS|BOEHRINGER|BOFA|BOM|BOND|BOO|BOOK|BOOKING|BOSCH|BOSTIK|BOSTON|BOT|BOUTIQUE|BOX|BR|BRADESCO|BRIDGESTONE|BROADWAY|BROKER|BROTHER|BRUSSELS|BS|BT|BUDAPEST|BUGATTI|BUILD|BUILDERS|BUSINESS|BUY|BUZZ|BV|BW|BY|BZ|BZH|CA|CAB|CAFE|CAL|CALL|CALVINKLEIN|CAM|CAMERA|CAMP|CANCERRESEARCH|CANON|CAPETOWN|CAPITAL|CAPITALONE|CAR|CARAVAN|CARDS|CARE|CAREER|CAREERS|CARS|CASA|CASE|CASEIH|CASH|CASINO|CAT|CATERING|CATHOLIC|CBA|CBN|CBRE|CBS|CC|CD|CEB|CENTER|CEO|CERN|CF|CFA|CFD|CG|CH|CHANEL|CHANNEL|CHARITY|CHASE|CHAT|CHEAP|CHINTAI|CHRISTMAS|CHROME|CHURCH|CI|CIPRIANI|CIRCLE|CISCO|CITADEL|CITI|CITIC|CITY|CITYEATS|CK|CL|CLAIMS|CLEANING|CLICK|CLINIC|CLINIQUE|CLOTHING|CLOUD|CLUB|CLUBMED|CM|CN|CO|COACH|CODES|COFFEE|COLLEGE|COLOGNE|COM|COMCAST|COMMBANK|COMMUNITY|COMPANY|COMPARE|COMPUTER|COMSEC|CONDOS|CONSTRUCTION|CONSULTING|CONTACT|CONTRACTORS|COOKING|COOKINGCHANNEL|COOL|COOP|CORSICA|COUNTRY|COUPON|COUPONS|COURSES|CPA|CR|CREDIT|CREDITCARD|CREDITUNION|CRICKET|CROWN|CRS|CRUISE|CRUISES|CSC|CU|CUISINELLA|CV|CW|CX|CY|CYMRU|CYOU|CZ|DABUR|DAD|DANCE|DATA|DATE|DATING|DATSUN|DAY|DCLK|DDS|DE|DEAL|DEALER|DEALS|DEGREE|DELIVERY|DELL|DELOITTE|DELTA|DEMOCRAT|DENTAL|DENTIST|DESI|DESIGN|DEV|DHL|DIAMONDS|DIET|DIGITAL|DIRECT|DIRECTORY|DISCOUNT|DISCOVER|DISH|DIY|DJ|DK|DM|DNP|DO|DOCS|DOCTOR|DOG|DOMAINS|DOT|DOWNLOAD|DRIVE|DTV|DUBAI|DUCK|DUNLOP|DUPONT|DURBAN|DVAG|DVR|DZ|EARTH|EAT|EC|ECO|EDEKA|EDU|EDUCATION|EE|EG|EMAIL|EMERCK|ENERGY|ENGINEER|ENGINEERING|ENTERPRISES|EPSON|EQUIPMENT|ER|ERICSSON|ERNI|ES|ESQ|ESTATE|ESURANCE|ET|ETISALAT|EU|EUROVISION|EUS|EVENTS|EXCHANGE|EXPERT|EXPOSED|EXPRESS|EXTRASPACE|FAGE|FAIL|FAIRWINDS|FAITH|FAMILY|FAN|FANS|FARM|FARMERS|FASHION|FAST|FEDEX|FEEDBACK|FERRARI|FERRERO|FI|FIAT|FIDELITY|FIDO|FILM|FINAL|FINANCE|FINANCIAL|FIRE|FIRESTONE|FIRMDALE|FISH|FISHING|FIT|FITNESS|FJ|FK|FLICKR|FLIGHTS|FLIR|FLORIST|FLOWERS|FLY|FM|FO|FOO|FOOD|FOODNETWORK|FOOTBALL|FORD|FOREX|FORSALE|FORUM|FOUNDATION|FOX|FR|FREE|FRESENIUS|FRL|FROGANS|FRONTDOOR|FRONTIER|FTR|FUJITSU|FUJIXEROX|FUN|FUND|FURNITURE|FUTBOL|FYI|GA|GAL|GALLERY|GALLO|GALLUP|GAME|GAMES|GAP|GARDEN|GAY|GB|GBIZ|GD|GDN|GE|GEA|GENT|GENTING|GEORGE|GF|GG|GGEE|GH|GI|GIFT|GIFTS|GIVES|GIVING|GL|GLADE|GLASS|GLE|GLOBAL|GLOBO|GM|GMAIL|GMBH|GMO|GMX|GN|GODADDY|GOLD|GOLDPOINT|GOLF|GOO|GOODYEAR|GOOG|GOOGLE|GOP|GOT|GOV|GP|GQ|GR|GRAINGER|GRAPHICS|GRATIS|GREEN|GRIPE|GROCERY|GROUP|GS|GT|GU|GUARDIAN|GUCCI|GUGE|GUIDE|GUITARS|GURU|GW|GY|HAIR|HAMBURG|HANGOUT|HAUS|HBO|HDFC|HDFCBANK|HEALTH|HEALTHCARE|HELP|HELSINKI|HERE|HERMES|HGTV|HIPHOP|HISAMITSU|HITACHI|HIV|HK|HKT|HM|HN|HOCKEY|HOLDINGS|HOLIDAY|HOMEDEPOT|HOMEGOODS|HOMES|HOMESENSE|HONDA|HORSE|HOSPITAL|HOST|HOSTING|HOT|HOTELES|HOTELS|HOTMAIL|HOUSE|HOW|HR|HSBC|HT|HU|HUGHES|HYATT|HYUNDAI|IBM|ICBC|ICE|ICU|ID|IE|IEEE|IFM|IKANO|IL|IM|IMAMAT|IMDB|IMMO|IMMOBILIEN|IN|INC|INDUSTRIES|INFINITI|INFO|ING|INK|INSTITUTE|INSURANCE|INSURE|INT|INTEL|INTERNATIONAL|INTUIT|INVESTMENTS|IO|IPIRANGA|IQ|IR|IRISH|IS|ISMAILI|IST|ISTANBUL|IT|ITAU|ITV|IVECO|JAGUAR|JAVA|JCB|JCP|JE|JEEP|JETZT|JEWELRY|JIO|JLL|JM|JMP|JNJ|JO|JOBS|JOBURG|JOT|JOY|JP|JPMORGAN|JPRS|JUEGOS|JUNIPER|KAUFEN|KDDI|KE|KERRYHOTELS|KERRYLOGISTICS|KERRYPROPERTIES|KFH|KG|KH|KI|KIA|KIM|KINDER|KINDLE|KITCHEN|KIWI|KM|KN|KOELN|KOMATSU|KOSHER|KP|KPMG|KPN|KR|KRD|KRED|KUOKGROUP|KW|KY|KYOTO|KZ|LA|LACAIXA|LAMBORGHINI|LAMER|LANCASTER|LANCIA|LAND|LANDROVER|LANXESS|LASALLE|LAT|LATINO|LATROBE|LAW|LAWYER|LB|LC|LDS|LEASE|LECLERC|LEFRAK|LEGAL|LEGO|LEXUS|LGBT|LI|LIDL|LIFE|LIFEINSURANCE|LIFESTYLE|LIGHTING|LIKE|LILLY|LIMITED|LIMO|LINCOLN|LINDE|LINK|LIPSY|LIVE|LIVING|LIXIL|LK|LLC|LLP|LOAN|LOANS|LOCKER|LOCUS|LOFT|LOL|LONDON|LOTTE|LOTTO|LOVE|LPL|LPLFINANCIAL|LR|LS|LT|LTD|LTDA|LU|LUNDBECK|LUPIN|LUXE|LUXURY|LV|LY|MA|MACYS|MADRID|MAIF|MAISON|MAKEUP|MAN|MANAGEMENT|MANGO|MAP|MARKET|MARKETING|MARKETS|MARRIOTT|MARSHALLS|MASERATI|MATTEL|MBA|MC|MCKINSEY|MD|ME|MED|MEDIA|MEET|MELBOURNE|MEME|MEMORIAL|MEN|MENU|MERCKMSD|METLIFE|MG|MH|MIAMI|MICROSOFT|MIL|MINI|MINT|MIT|MITSUBISHI|MK|ML|MLB|MLS|MM|MMA|MN|MO|MOBI|MOBILE|MODA|MOE|MOI|MOM|MONASH|MONEY|MONSTER|MORMON|MORTGAGE|MOSCOW|MOTO|MOTORCYCLES|MOV|MOVIE|MP|MQ|MR|MS|MSD|MT|MTN|MTR|MU|MUSEUM|MUTUAL|MV|MW|MX|MY|MZ|NA|NAB|NAGOYA|NAME|NATIONWIDE|NATURA|NAVY|NBA|NC|NE|NEC|NET|NETBANK|NETFLIX|NETWORK|NEUSTAR|NEW|NEWHOLLAND|NEWS|NEXT|NEXTDIRECT|NEXUS|NF|NFL|NG|NGO|NHK|NI|NICO|NIKE|NIKON|NINJA|NISSAN|NISSAY|NL|NO|NOKIA|NORTHWESTERNMUTUAL|NORTON|NOW|NOWRUZ|NOWTV|NP|NR|NRA|NRW|NTT|NU|NYC|NZ|OBI|OBSERVER|OFF|OFFICE|OKINAWA|OLAYAN|OLAYANGROUP|OLDNAVY|OLLO|OM|OMEGA|ONE|ONG|ONL|ONLINE|ONYOURSIDE|OOO|OPEN|ORACLE|ORANGE|ORG|ORGANIC|ORIGINS|OSAKA|OTSUKA|OTT|OVH|PA|PAGE|PANASONIC|PARIS|PARS|PARTNERS|PARTS|PARTY|PASSAGENS|PAY|PCCW|PE|PET|PF|PFIZER|PG|PH|PHARMACY|PHD|PHILIPS|PHONE|PHOTO|PHOTOGRAPHY|PHOTOS|PHYSIO|PICS|PICTET|PICTURES|PID|PIN|PING|PINK|PIONEER|PIZZA|PK|PL|PLACE|PLAY|PLAYSTATION|PLUMBING|PLUS|PM|PN|PNC|POHL|POKER|POLITIE|PORN|POST|PR|PRAMERICA|PRAXI|PRESS|PRIME|PRO|PROD|PRODUCTIONS|PROF|PROGRESSIVE|PROMO|PROPERTIES|PROPERTY|PROTECTION|PRU|PRUDENTIAL|PS|PT|PUB|PW|PWC|PY|QA|QPON|QUEBEC|QUEST|QVC|RACING|RADIO|RAID|RE|READ|REALESTATE|REALTOR|REALTY|RECIPES|RED|REDSTONE|REDUMBRELLA|REHAB|REISE|REISEN|REIT|RELIANCE|REN|RENT|RENTALS|REPAIR|REPORT|REPUBLICAN|REST|RESTAURANT|REVIEW|REVIEWS|REXROTH|RICH|RICHARDLI|RICOH|RIGHTATHOME|RIL|RIO|RIP|RMIT|RO|ROCHER|ROCKS|RODEO|ROGERS|ROOM|RS|RSVP|RU|RUGBY|RUHR|RUN|RW|RWE|RYUKYU|SA|SAARLAND|SAFE|SAFETY|SAKURA|SALE|SALON|SAMSCLUB|SAMSUNG|SANDVIK|SANDVIKCOROMANT|SANOFI|SAP|SARL|SAS|SAVE|SAXO|SB|SBI|SBS|SC|SCA|SCB|SCHAEFFLER|SCHMIDT|SCHOLARSHIPS|SCHOOL|SCHULE|SCHWARZ|SCIENCE|SCJOHNSON|SCOR|SCOT|SD|SE|SEARCH|SEAT|SECURE|SECURITY|SEEK|SELECT|SENER|SERVICES|SES|SEVEN|SEW|SEX|SEXY|SFR|SG|SH|SHANGRILA|SHARP|SHAW|SHELL|SHIA|SHIKSHA|SHOES|SHOP|SHOPPING|SHOUJI|SHOW|SHOWTIME|SHRIRAM|SI|SILK|SINA|SINGLES|SITE|SJ|SK|SKI|SKIN|SKY|SKYPE|SL|SLING|SM|SMART|SMILE|SN|SNCF|SO|SOCCER|SOCIAL|SOFTBANK|SOFTWARE|SOHU|SOLAR|SOLUTIONS|SONG|SONY|SOY|SPACE|SPORT|SPOT|SPREADBETTING|SR|SRL|SS|ST|STADA|STAPLES|STAR|STATEBANK|STATEFARM|STC|STCGROUP|STOCKHOLM|STORAGE|STORE|STREAM|STUDIO|STUDY|STYLE|SU|SUCKS|SUPPLIES|SUPPLY|SUPPORT|SURF|SURGERY|SUZUKI|SV|SWATCH|SWIFTCOVER|SWISS|SX|SY|SYDNEY|SYMANTEC|SYSTEMS|SZ|TAB|TAIPEI|TALK|TAOBAO|TARGET|TATAMOTORS|TATAR|TATTOO|TAX|TAXI|TC|TCI|TD|TDK|TEAM|TECH|TECHNOLOGY|TEL|TEMASEK|TENNIS|TEVA|TF|TG|TH|THD|THEATER|THEATRE|TIAA|TICKETS|TIENDA|TIFFANY|TIPS|TIRES|TIROL|TJ|TJMAXX|TJX|TK|TKMAXX|TL|TM|TMALL|TN|TO|TODAY|TOKYO|TOOLS|TOP|TORAY|TOSHIBA|TOTAL|TOURS|TOWN|TOYOTA|TOYS|TR|TRADE|TRADING|TRAINING|TRAVEL|TRAVELCHANNEL|TRAVELERS|TRAVELERSINSURANCE|TRUST|TRV|TT|TUBE|TUI|TUNES|TUSHU|TV|TVS|TW|TZ|UA|UBANK|UBS|UG|UK|UNICOM|UNIVERSITY|UNO|UOL|UPS|US|UY|UZ|VA|VACATIONS|VANA|VANGUARD|VC|VE|VEGAS|VENTURES|VERISIGN|VERSICHERUNG|VET|VG|VI|VIAJES|VIDEO|VIG|VIKING|VILLAS|VIN|VIP|VIRGIN|VISA|VISION|VIVA|VIVO|VLAANDEREN|VN|VODKA|VOLKSWAGEN|VOLVO|VOTE|VOTING|VOTO|VOYAGE|VU|VUELOS|WALES|WALMART|WALTER|WANG|WANGGOU|WATCH|WATCHES|WEATHER|WEATHERCHANNEL|WEBCAM|WEBER|WEBSITE|WED|WEDDING|WEIBO|WEIR|WF|WHOSWHO|WIEN|WIKI|WILLIAMHILL|WIN|WINDOWS|WINE|WINNERS|WME|WOLTERSKLUWER|WOODSIDE|WORK|WORKS|WORLD|WOW|WS|WTC|WTF|XBOX|XEROX|XFINITY|XIHUAN|XIN|XN--11B4C3D|XN--1CK2E1B|XN--1QQW23A|XN--2SCRJ9C|XN--30RR7Y|XN--3BST00M|XN--3DS443G|XN--3E0B707E|XN--3HCRJ9C|XN--3OQ18VL8PN36A|XN--3PXU8K|XN--42C2D9A|XN--45BR5CYL|XN--45BRJ9C|XN--45Q11C|XN--4GBRIM|XN--54B7FTA0CC|XN--55QW42G|XN--55QX5D|XN--5SU34J936BGSG|XN--5TZM5G|XN--6FRZ82G|XN--6QQ986B3XL|XN--80ADXHKS|XN--80AO21A|XN--80AQECDR1A|XN--80ASEHDB|XN--80ASWG|XN--8Y0A063A|XN--90A3AC|XN--90AE|XN--90AIS|XN--9DBQ2A|XN--9ET52U|XN--9KRT00A|XN--B4W605FERD|XN--BCK1B9A5DRE4C|XN--C1AVG|XN--C2BR7G|XN--CCK2B3B|XN--CG4BKI|XN--CLCHC0EA0B2G2A9GCD|XN--CZR694B|XN--CZRS0T|XN--CZRU2D|XN--D1ACJ3B|XN--D1ALF|XN--E1A4C|XN--ECKVDTC9D|XN--EFVY88H|XN--FCT429K|XN--FHBEI|XN--FIQ228C5HS|XN--FIQ64B|XN--FIQS8S|XN--FIQZ9S|XN--FJQ720A|XN--FLW351E|XN--FPCRJ9C3D|XN--FZC2C9E2C|XN--FZYS8D69UVGM|XN--G2XX48C|XN--GCKR3F0F|XN--GECRJ9C|XN--GK3AT1E|XN--H2BREG3EVE|XN--H2BRJ9C|XN--H2BRJ9C8C|XN--HXT814E|XN--I1B6B1A6A2E|XN--IMR513N|XN--IO0A7I|XN--J1AEF|XN--J1AMH|XN--J6W193G|XN--JLQ61U9W7B|XN--JVR189M|XN--KCRX77D1X4A|XN--KPRW13D|XN--KPRY57D|XN--KPU716F|XN--KPUT3I|XN--L1ACC|XN--LGBBAT1AD8J|XN--MGB9AWBF|XN--MGBA3A3EJT|XN--MGBA3A4F16A|XN--MGBA7C0BBN0A|XN--MGBAAKC7DVF|XN--MGBAAM7A8H|XN--MGBAB2BD|XN--MGBAH1A3HJKRD|XN--MGBAI9AZGQP6J|XN--MGBAYH7GPA|XN--MGBBH1A|XN--MGBBH1A71E|XN--MGBC0A9AZCG|XN--MGBCA7DZDO|XN--MGBCPQ6GPA1A|XN--MGBERP4A5D4AR|XN--MGBGU82A|XN--MGBI4ECEXP|XN--MGBPL2FH|XN--MGBT3DHD|XN--MGBTX2B|XN--MGBX4CD0AB|XN--MIX891F|XN--MK1BU44C|XN--MXTQ1M|XN--NGBC5AZD|XN--NGBE9E0A|XN--NGBRX|XN--NODE|XN--NQV7F|XN--NQV7FS00EMA|XN--NYQY26A|XN--O3CW4H|XN--OGBPF8FL|XN--OTU796D|XN--P1ACF|XN--P1AI|XN--PBT977C|XN--PGBS0DH|XN--PSSY2U|XN--Q7CE6A|XN--Q9JYB4C|XN--QCKA1PMC|XN--QXA6A|XN--QXAM|XN--RHQV96G|XN--ROVU88B|XN--RVC1E0AM3E|XN--S9BRJ9C|XN--SES554G|XN--T60B56A|XN--TCKWE|XN--TIQ49XQYJ|XN--UNUP4Y|XN--VERMGENSBERATER-CTB|XN--VERMGENSBERATUNG-PWB|XN--VHQUV|XN--VUQ861B|XN--W4R85EL8FHU5DNRA|XN--W4RS40L|XN--WGBH1C|XN--WGBL6A|XN--XHQ521B|XN--XKC2AL3HYE2A|XN--XKC2DL3A5EE0H|XN--Y9A3AQ|XN--YFRO4I67O|XN--YGBI2AMMX|XN--ZFR164B|XXX|XYZ|YACHTS|YAHOO|YAMAXUN|YANDEX|YE|YODOBASHI|YOGA|YOKOHAMA|YOU|YOUTUBE|YT|YUN|ZA|ZAPPOS|ZARA|ZERO|ZIP|ZM|ZONE|ZUERICH|ZW|TEST)"});A(N);N.TLDs;var L=u(function(A,E){Object.defineProperty(E,"__esModule",{value:!0}),E.openingParenthesis="([\"'{",E.closingParenthesis=")]\"'}",E.parenthesis=E.openingParenthesis.split("").map(function(A,u){return""+A+E.closingParenthesis.charAt(u)}),E.htmlAttributes=["src","data","href","cite","formaction","icon","manifest","poster","codebase","background","profile","usemap","itemtype","action","longdesc","classid","archive"],E.nonLatinAlphabetRanges="\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0\\u08A2-\\u08AC\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA697\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA793\\uA7A0-\\uA7AA\\uA7F8-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC",E.TLDs=N.TLDs});A(L);L.openingParenthesis,L.closingParenthesis,L.parenthesis,L.htmlAttributes,L.nonLatinAlphabetRanges,L.TLDs;var B=u(function(A,u){function S(A,u,E){return"function"==typeof E?E(A,u):E}Object.defineProperty(u,"__esModule",{value:!0}),u.transform=function(A,u){var E="",N=1/0,C={},O=!1;if(u&&u.specialTransform)for(var I=0;I'+(A.string.length>N?O?A.string.substring(0,Math.floor(N/2))+"…"+A.string.substring(A.string.length-Math.ceil(N/2),A.string.length):A.string.substring(0,N)+"…":A.string)+"")}});A(B);B.transform;var e=u(function(A,u){Object.defineProperty(u,"__esModule",{value:!0});var E="([a-z0-9]+(-+[a-z0-9]+)*\\.)+("+L.TLDs+")",N="a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()",C="((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",O="\\[(([a-f0-9:]+:+)+[a-f0-9]+)\\]",I="(https?:|ftps?:)\\/\\/",R="((("+I+")?("+E+"|"+C+"|("+I+")("+O+"|"+("([a-z0-9]+(-+[a-z0-9]+)*\\.)+([a-z0-9][a-z0-9-]{0,"+(Math.max.apply(t,L.TLDs.split("|").map(function(A){return A.length}))-2)+"}[a-z0-9])")+"))(?!@\\w)(:(\\d{1,5}))?)|(((https?:|ftps?:)\\/\\/)\\S+))",S=R+"((((\\/((["+N+"]+(\\/["+N+L.nonLatinAlphabetRanges+"]*)*))?)?)((\\?(["+N+"\\/?]*))?)((\\#(["+N+"\\/?]*))?))?\\b(((["+N+"\\/"+L.nonLatinAlphabetRanges+"][a-zA-Z\\d\\-_~+=\\/"+L.nonLatinAlphabetRanges+"]+)?))+)";u.email="\\b(mailto:)?([a-z0-9!#$%&'*+=?^_`{|}~-]+(\\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*)@("+E+"|"+C+")\\b",u.url="("+S+")|(\\b"+R+"(((\\/(([a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()]+(\\/[a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()]*)*))?)?)((\\?([a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()\\/?]*))?)((\\#([a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()\\/?]*))?))?\\b(([\\/]?))+)",u.file="(file:\\/\\/\\/)([a-z]+:(\\/|\\\\)+)?([\\w.]+([\\/\\\\]?)+)+",u.final="("+u.url+")|("+u.email+")|("+u.file+")",u.finalRegex=new RegExp(u.final,"gi"),u.ipRegex=new RegExp("^("+C+"|"+O+")$","i"),u.emailRegex=new RegExp("^("+u.email+")$","i"),u.fileRegex=new RegExp("^("+u.file+")$","i"),u.urlRegex=new RegExp("^("+u.url+")$","i");var T={isURL:0,isEmail:0,isFile:0,file:{fileName:0,protocol:0},email:{protocol:0,local:0,host:0},url:{ipv4:0,ipv6:0,ipv4Confirmation:0,byProtocol:0,port:0,protocol1:0,protocol2:0,protocol3:0,protocolWithDomain:0,path:0,secondPartOfPath:0,query:0,fragment:0}};u.iidxes=T;for(var B=["file:///some/file/path/filename.pdf","mailto:e+_mail.me@sub.domain.com","http://sub.domain.co.uk:3000/p/a/t/h_(asd)/h?q=abc123#dfdf","http://www.عربي.com","http://127.0.0.1:3000/p/a/t_(asd)/h?q=abc123#dfdf","http://[2a00:1450:4025:401::67]/k/something","a.org/abc/ი_გგ"].join(" "),e=null,D=0;null!==(e=u.finalRegex.exec(B));)0===D&&(T.isFile=e.lastIndexOf(e[0]),T.file.fileName=e.indexOf("filename.pdf"),T.file.protocol=e.indexOf("file:///")),1===D&&(T.isEmail=e.lastIndexOf(e[0]),T.email.protocol=e.indexOf("mailto:"),T.email.local=e.indexOf("e+_mail.me"),T.email.host=e.indexOf("sub.domain.com")),2===D&&(T.isURL=e.lastIndexOf(e[0]),T.url.protocol1=e.indexOf("http://"),T.url.protocolWithDomain=e.indexOf("http://sub.domain.co.uk:3000"),T.url.port=e.indexOf("3000"),T.url.path=e.indexOf("/p/a/t/h_(asd)/h"),T.url.query=e.indexOf("q=abc123"),T.url.fragment=e.indexOf("dfdf")),3===D&&(T.url.byProtocol=e.lastIndexOf("http://www.عربي.com"),T.url.protocol2=e.lastIndexOf("http://")),4===D&&(T.url.ipv4=e.indexOf("127.0.0.1"),T.url.ipv4Confirmation=e.indexOf("0.")),5===D&&(T.url.ipv6=e.indexOf("2a00:1450:4025:401::67"),T.url.protocol3=e.lastIndexOf("http://")),6===D&&(T.url.secondPartOfPath=e.indexOf("გგ")),D++});A(e);e.email,e.url,e.file,e.finalRegex,e.ipRegex,e.emailRegex,e.fileRegex,e.urlRegex,e.iidxes;var D=u(function(A,u){Object.defineProperty(u,"__esModule",{value:!0}),u.checkParenthesis=function(A,u,E,N){return N===u&&(E.split(A).length-E.split(u).length==1||A===u&&E.split(A).length%2==0||void 0)},u.maximumAttrLength=L.htmlAttributes.sort(function(A,u){return u.length-A.length})[0].length,u.isInsideAttribute=function(A){return/\s[a-z0-9-]+=('|")$/i.test(A)||/: ?url\(('|")?$/i.test(A)},u.isInsideAnchorTag=function(A,u,E){for(var N=A.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),C=new RegExp("(?=()("+N+"))[\\s\\S]*?("+N+")(?!\"|')","gi"),O=null;null!==(O=C.exec(u));){if(O.index+O[0].length===E)return!0}return!1}});A(D);D.checkParenthesis,D.maximumAttrLength,D.isInsideAttribute,D.isInsideAnchorTag;return A(u(function(A,u){Object.defineProperty(u,"__esModule",{value:!0});function T(I){for(var R=[],S=null,A=function(){var A=S.index,N=A+S[0].length,C=S[0];if("/"===I.charAt(N)&&(C+=I.charAt(N),N++),-1")&&-10){throw new Error("Invalid string. Length must be a multiple of 4")}var n=r.indexOf("=");if(n===-1)n=e;var t=n===e?0:4-n%4;return[n,t]}function f(r){var e=c(r);var n=e[0];var t=e[1];return(n+t)*3/4-t}function h(r,e,n){return(e+n)*3/4-n}function i(r){var e;var n=c(r);var t=n[0];var o=n[1];var a=new d(h(r,t,o));var f=0;var i=o>0?t-4:t;var u;for(u=0;u>16&255;a[f++]=e>>8&255;a[f++]=e&255}if(o===2){e=v[r.charCodeAt(u)]<<2|v[r.charCodeAt(u+1)]>>4;a[f++]=e&255}if(o===1){e=v[r.charCodeAt(u)]<<10|v[r.charCodeAt(u+1)]<<4|v[r.charCodeAt(u+2)]>>2;a[f++]=e>>8&255;a[f++]=e&255}return a}function s(r){return u[r>>18&63]+u[r>>12&63]+u[r>>6&63]+u[r&63]}function l(r,e,n){var t;var o=[];for(var a=e;ai?i:f+a))}if(t===1){e=r[n-1];o.push(u[e>>2]+u[e<<4&63]+"==")}else if(t===2){e=(r[n-2]<<8)+r[n-1];o.push(u[e>>10]+u[e>>4&63]+u[e<<2&63]+"=")}return o.join("")}},{}]},{},[])("/")}); 2 | -------------------------------------------------------------------------------- /lib/msgpack.min.js: -------------------------------------------------------------------------------- 1 | !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.msgpack=t()}}(function(){return function t(r,e,n){function i(f,u){if(!e[f]){if(!r[f]){var a="function"==typeof require&&require;if(!u&&a)return a(f,!0);if(o)return o(f,!0);var s=new Error("Cannot find module '"+f+"'");throw s.code="MODULE_NOT_FOUND",s}var c=e[f]={exports:{}};r[f][0].call(c.exports,function(t){var e=r[f][1][t];return i(e?e:t)},c,c.exports,t,r,e,n)}return e[f].exports}for(var o="function"==typeof require&&require,f=0;f>>6,e[n++]=128|63&o):o<55296||o>57343?(e[n++]=224|o>>>12,e[n++]=128|o>>>6&63,e[n++]=128|63&o):(o=(o-55296<<10|t.charCodeAt(f++)-56320)+65536,e[n++]=240|o>>>18,e[n++]=128|o>>>12&63,e[n++]=128|o>>>6&63,e[n++]=128|63&o);return n-r}function i(t,r,e){var n=this,i=0|r;e||(e=n.length);for(var o="",f=0;i=65536?(f-=65536,o+=String.fromCharCode((f>>>10)+55296,(1023&f)+56320)):o+=String.fromCharCode(f));return o}function o(t,r,e,n){var i;e||(e=0),n||0===n||(n=this.length),r||(r=0);var o=n-e;if(t===this&&e=0;i--)t[i+r]=this[i+e];else for(i=0;ithis.buffer.length)throw new Error(v);return this.offset=e,r}return{bufferish:p,write:t,fetch:a,flush:r,push:c,pull:h,read:s,reserve:e,offset:0}}function f(){function t(){var t=this.start;if(t1?this.bufferish.concat(t):t[0];return t.length=0,r}function n(t){var r=0|t;if(this.buffer){var e=this.buffer.length,n=0|this.offset,i=n+r;if(ithis.minBufferSize)this.flush(),this.push(t);else{var e=this.reserve(r);p.prototype.copy.call(t,this.buffer,e)}}return{bufferish:p,write:u,fetch:t,flush:r,push:c,pull:e,read:s,reserve:n,send:i,maxBufferSize:y,minBufferSize:d,offset:0,start:0}}function u(){throw new Error("method not implemented: write()")}function a(){throw new Error("method not implemented: fetch()")}function s(){var t=this.buffers&&this.buffers.length;return t?(this.flush(),this.pull()):this.fetch()}function c(t){var r=this.buffers||(this.buffers=[]);r.push(t)}function h(){var t=this.buffers||(this.buffers=[]);return t.shift()}function l(t){function r(r){for(var e in t)r[e]=t[e];return r}return r}e.FlexDecoder=n,e.FlexEncoder=i;var p=t("./bufferish"),d=2048,y=65536,v="BUFFER_SHORTAGE";n.mixin=l(o()),n.mixin(n.prototype),i.mixin=l(f()),i.mixin(i.prototype)},{"./bufferish":8}],22:[function(t,r,e){function n(t){function r(t){var r=s(t),n=e[r];if(!n)throw new Error("Invalid type: "+(r?"0x"+r.toString(16):r));return n(t)}var e=c.getReadToken(t);return r}function i(){var t=this.options;return this.decode=n(t),t&&t.preset&&a.setExtUnpackers(this),this}function o(t,r){var e=this.extUnpackers||(this.extUnpackers=[]);e[t]=h.filter(r)}function f(t){function r(r){return new u(r,t)}var e=this.extUnpackers||(this.extUnpackers=[]);return e[t]||r}var u=t("./ext-buffer").ExtBuffer,a=t("./ext-unpacker"),s=t("./read-format").readUint8,c=t("./read-token"),h=t("./codec-base");h.install({addExtUnpacker:o,getExtUnpacker:f,init:i}),e.preset=i.call(h.preset)},{"./codec-base":9,"./ext-buffer":17,"./ext-unpacker":19,"./read-format":23,"./read-token":24}],23:[function(t,r,e){function n(t){var r=k.hasArrayBuffer&&t&&t.binarraybuffer,e=t&&t.int64,n=T&&t&&t.usemap,B={map:n?o:i,array:f,str:u,bin:r?s:a,ext:c,uint8:h,uint16:p,uint32:y,uint64:g(8,e?E:b),int8:l,int16:d,int32:v,int64:g(8,e?A:w),float32:g(4,m),float64:g(8,x)};return B}function i(t,r){var e,n={},i=new Array(r),o=new Array(r),f=t.codec.decode;for(e=0;e>>8,i[n]=e}}function s(t){return function(r,e){var n=r.reserve(5),i=r.buffer;i[n++]=t,i[n++]=e>>>24,i[n++]=e>>>16,i[n++]=e>>>8,i[n]=e}}function c(t,r,e,n){return function(i,o){var f=i.reserve(r+1);i.buffer[f++]=t,e.call(i.buffer,o,f,n)}}function h(t,r){new g(this,r,t)}function l(t,r){new b(this,r,t)}function p(t,r){y.write(this,t,r,!1,23,4)}function d(t,r){y.write(this,t,r,!1,52,8)}var y=t("ieee754"),v=t("int64-buffer"),g=v.Uint64BE,b=v.Int64BE,w=t("./write-uint8").uint8,E=t("./bufferish"),Buffer=E.global,A=E.hasBuffer&&"TYPED_ARRAY_SUPPORT"in Buffer,m=A&&!Buffer.TYPED_ARRAY_SUPPORT,x=E.hasBuffer&&Buffer.prototype||{};e.getWriteToken=n},{"./bufferish":8,"./write-uint8":28,ieee754:32,"int64-buffer":33}],27:[function(t,r,e){function n(t){function r(t,r){var e=r?195:194;_[e](t,r)}function e(t,r){var e,n=0|r;return r!==n?(e=203,void _[e](t,r)):(e=-32<=n&&n<=127?255&n:0<=n?n<=255?204:n<=65535?205:206:-128<=n?208:-32768<=n?209:210,void _[e](t,n))}function n(t,r){var e=207;_[e](t,r.toArray())}function o(t,r){var e=211;_[e](t,r.toArray())}function v(t){return t<32?1:t<=255?2:t<=65535?3:5}function g(t){return t<32?1:t<=65535?3:5}function b(t){function r(r,e){var n=e.length,i=5+3*n;r.offset=r.reserve(i);var o=r.buffer,f=t(n),u=r.offset+f;n=s.write.call(o,e,u);var a=t(n);if(f!==a){var c=u+a-f,h=u+n;s.copy.call(o,o,c,u,h)}var l=1===a?160+n:a<=3?215+a:219;_[l](r,n),r.offset+=n}return r}function w(t,r){if(null===r)return A(t,r);if(I(r))return Y(t,r);if(i(r))return m(t,r);if(f.isUint64BE(r))return n(t,r);if(u.isInt64BE(r))return o(t,r);var e=t.codec.getExtPacker(r);return e&&(r=e(r)),r instanceof l?U(t,r):void D(t,r)}function E(t,r){return I(r)?k(t,r):void w(t,r)}function A(t,r){var e=192;_[e](t,r)}function m(t,r){var e=r.length,n=e<16?144+e:e<=65535?220:221;_[n](t,e);for(var i=t.codec.encode,o=0;o=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function y(t){return+t!=t&&(t=0),Buffer.alloc(+t)}function v(t,r){if(Buffer.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return X(t).length;default:if(n)return q(t).length;r=(""+r).toLowerCase(),n=!0}}function g(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if(e>>>=0,r>>>=0,e<=r)return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,r,e);case"utf8":case"utf-8":return k(this,r,e);case"ascii":return T(this,r,e);case"latin1":case"binary":return S(this,r,e);case"base64":return R(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function w(t,r,e,n,i){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof r&&(r=Buffer.from(r,n)),Buffer.isBuffer(r))return 0===r.length?-1:E(t,r,e,n,i);if("number"==typeof r)return r=255&r,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):E(t,[r],e,n,i);throw new TypeError("val must be string, number or Buffer")}function E(t,r,e,n,i){function o(t,r){return 1===f?t[r]:t.readUInt16BE(r*f)}var f=1,u=t.length,a=r.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;f=2,u/=2,a/=2,e/=2}var s;if(i){var c=-1;for(s=e;su&&(e=u-a),s=e;s>=0;s--){for(var h=!0,l=0;li&&(n=i)):n=i;var o=r.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var f=0;f239?4:o>223?3:o>191?2:1;if(i+u<=e){var a,s,c,h;switch(u){case 1:o<128&&(f=o);break;case 2:a=t[i+1],128===(192&a)&&(h=(31&o)<<6|63&a,h>127&&(f=h));break;case 3:a=t[i+1],s=t[i+2],128===(192&a)&&128===(192&s)&&(h=(15&o)<<12|(63&a)<<6|63&s,h>2047&&(h<55296||h>57343)&&(f=h));break;case 4:a=t[i+1],s=t[i+2],c=t[i+3],128===(192&a)&&128===(192&s)&&128===(192&c)&&(h=(15&o)<<18|(63&a)<<12|(63&s)<<6|63&c,h>65535&&h<1114112&&(f=h))}}null===f?(f=65533,u=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=u}return _(n)}function _(t){var r=t.length;if(r<=$)return String.fromCharCode.apply(String,t);for(var e="",n=0;nn)&&(e=n);for(var i="",o=r;oe)throw new RangeError("Trying to access beyond buffer length")}function D(t,r,e,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||rt.length)throw new RangeError("Index out of range")}function O(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i>>8*(n?i:1-i)}function L(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i>>8*(n?i:3-i)&255}function M(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function N(t,r,e,n,i){return i||M(t,r,e,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,r,e,n,23,4),e+4}function F(t,r,e,n,i){return i||M(t,r,e,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,r,e,n,52,8),e+8}function j(t){ 2 | if(t=z(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function z(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return t<16?"0"+t.toString(16):t.toString(16)}function q(t,r){r=r||1/0;for(var e,n=t.length,i=null,o=[],f=0;f55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function W(t){for(var r=[],e=0;e>8,i=e%256,o.push(i),o.push(n);return o}function X(t){return Z.toByteArray(j(t))}function G(t,r,e,n){for(var i=0;i=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function H(t){return t!==t}var Z=t("base64-js"),K=t("ieee754"),Q=t("isarray");e.Buffer=Buffer,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,Buffer.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:n(),e.kMaxLength=i(),Buffer.poolSize=8192,Buffer._augment=function(t){return t.__proto__=Buffer.prototype,t},Buffer.from=function(t,r,e){return f(null,t,r,e)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0})),Buffer.alloc=function(t,r,e){return a(null,t,r,e)},Buffer.allocUnsafe=function(t){return s(null,t)},Buffer.allocUnsafeSlow=function(t){return s(null,t)},Buffer.isBuffer=function(t){return!(null==t||!t._isBuffer)},Buffer.compare=function(t,r){if(!Buffer.isBuffer(t)||!Buffer.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},Buffer.prototype.compare=function(t,r,e,n,i){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(r>>>=0,e>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,f=e-r,u=Math.min(o,f),a=this.slice(n,i),s=t.slice(r,e),c=0;ci)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return A(this,t,r,e);case"utf8":case"utf-8":return m(this,t,r,e);case"ascii":return x(this,t,r,e);case"latin1":case"binary":return B(this,t,r,e);case"base64":return U(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;Buffer.prototype.slice=function(t,r){var e=this.length;t=~~t,r=void 0===r?e:~~r,t<0?(t+=e,t<0&&(t=0)):t>e&&(t=e),r<0?(r+=e,r<0&&(r=0)):r>e&&(r=e),r0&&(i*=256);)n+=this[t+--r]*i;return n},Buffer.prototype.readUInt8=function(t,r){return r||C(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,r){return r||C(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,r){return r||C(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,r){return r||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,r){return r||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,r,e){t=0|t,r=0|r,e||C(t,r,this.length);for(var n=this[t],i=1,o=0;++o=i&&(n-=Math.pow(2,8*r)),n},Buffer.prototype.readIntBE=function(t,r,e){t=0|t,r=0|r,e||C(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*r)),o},Buffer.prototype.readInt8=function(t,r){return r||C(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},Buffer.prototype.readInt16LE=function(t,r){r||C(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},Buffer.prototype.readInt16BE=function(t,r){r||C(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},Buffer.prototype.readInt32LE=function(t,r){return r||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,r){return r||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,r){return r||C(t,4,this.length),K.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,r){return r||C(t,4,this.length),K.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,r){return r||C(t,8,this.length),K.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,r){return r||C(t,8,this.length),K.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,r,e,n){if(t=+t,r=0|r,e=0|e,!n){var i=Math.pow(2,8*e)-1;D(this,t,r,e,i,0)}var o=1,f=0;for(this[r]=255&t;++f=0&&(f*=256);)this[r+o]=t/f&255;return r+e},Buffer.prototype.writeUInt8=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},Buffer.prototype.writeUInt16LE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},Buffer.prototype.writeUInt16BE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},Buffer.prototype.writeUInt32LE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):L(this,t,r,!0),r+4},Buffer.prototype.writeUInt32BE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):L(this,t,r,!1),r+4},Buffer.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r=0|r,!n){var i=Math.pow(2,8*e-1);D(this,t,r,e,i-1,-i)}var o=0,f=1,u=0;for(this[r]=255&t;++o>0)-u&255;return r+e},Buffer.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r=0|r,!n){var i=Math.pow(2,8*e-1);D(this,t,r,e,i-1,-i)}var o=e-1,f=1,u=0;for(this[r+o]=255&t;--o>=0&&(f*=256);)t<0&&0===u&&0!==this[r+o+1]&&(u=1),this[r+o]=(t/f>>0)-u&255;return r+e},Buffer.prototype.writeInt8=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},Buffer.prototype.writeInt16LE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},Buffer.prototype.writeInt16BE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},Buffer.prototype.writeInt32LE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):L(this,t,r,!0),r+4},Buffer.prototype.writeInt32BE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):L(this,t,r,!1),r+4},Buffer.prototype.writeFloatLE=function(t,r,e){return N(this,t,r,!0,e)},Buffer.prototype.writeFloatBE=function(t,r,e){return N(this,t,r,!1,e)},Buffer.prototype.writeDoubleLE=function(t,r,e){return F(this,t,r,!0,e)},Buffer.prototype.writeDoubleBE=function(t,r,e){return F(this,t,r,!1,e)},Buffer.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r=0;--i)t[i+r]=this[i+e];else if(o<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,e=void 0===e?this.length:e>>>0,t||(t=0);var o;if("number"==typeof t)for(o=r;o0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[r-2]?2:"="===t[r-1]?1:0}function i(t){return 3*t.length/4-n(t)}function o(t){var r,e,i,o,f,u,a=t.length;f=n(t),u=new h(3*a/4-f),i=f>0?a-4:a;var s=0;for(r=0,e=0;r>16&255,u[s++]=o>>8&255,u[s++]=255&o;return 2===f?(o=c[t.charCodeAt(r)]<<2|c[t.charCodeAt(r+1)]>>4,u[s++]=255&o):1===f&&(o=c[t.charCodeAt(r)]<<10|c[t.charCodeAt(r+1)]<<4|c[t.charCodeAt(r+2)]>>2,u[s++]=o>>8&255,u[s++]=255&o),u}function f(t){return s[t>>18&63]+s[t>>12&63]+s[t>>6&63]+s[63&t]}function u(t,r,e){for(var n,i=[],o=r;oc?c:a+f));return 1===n?(r=t[e-1],i+=s[r>>2],i+=s[r<<4&63],i+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],i+=s[r>>10],i+=s[r>>4&63],i+=s[r<<2&63],i+="="),o.push(i),o.join("")}e.byteLength=i,e.toByteArray=o,e.fromByteArray=a;for(var s=[],c=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=l.length;p>1,c=-7,h=e?i-1:0,l=e?-1:1,p=t[r+h];for(h+=l,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[r+h],h+=l,c-=8);for(f=o&(1<<-c)-1,o>>=-c,c+=n;c>0;f=256*f+t[r+h],h+=l,c-=8);if(0===o)o=1-s;else{if(o===a)return f?NaN:(p?-1:1)*(1/0);f+=Math.pow(2,n),o-=s}return(p?-1:1)*f*Math.pow(2,o-n)},e.write=function(t,r,e,n,i,o){var f,u,a,s=8*o-i-1,c=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,f=c):(f=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-f))<1&&(f--,a*=2),r+=f+h>=1?l/a:l*Math.pow(2,1-h),r*a>=2&&(f++,a/=2),f+h>=c?(u=0,f=c):f+h>=1?(u=(r*a-1)*Math.pow(2,i),f+=h):(u=r*Math.pow(2,h-1)*Math.pow(2,i),f=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(f=f<0;t[e+p]=255&f,p+=d,f/=256,s-=8);t[e+p-d]|=128*y}},{}],33:[function(t,r,e){(function(Buffer){var t,r,n,i;!function(e){function o(t,r,n){function i(t,r,e,n){return this instanceof i?v(this,t,r,e,n):new i(t,r,e,n)}function o(t){return!(!t||!t[F])}function v(t,r,e,n,i){if(E&&A&&(r instanceof A&&(r=new E(r)),n instanceof A&&(n=new E(n))),!(r||e||n||g))return void(t.buffer=h(m,0));if(!s(r,e)){var o=g||Array;i=e,n=r,e=0,r=new o(8)}t.buffer=r,t.offset=e|=0,b!==typeof n&&("string"==typeof n?x(r,e,n,i||10):s(n,i)?c(r,e,n,i):"number"==typeof i?(k(r,e+T,n),k(r,e+S,i)):n>0?O(r,e,n):n<0?L(r,e,n):c(r,e,m,0))}function x(t,r,e,n){var i=0,o=e.length,f=0,u=0;"-"===e[0]&&i++;for(var a=i;i=0))break;u=u*n+s,f=f*n+Math.floor(u/B),u%=B}a&&(f=~f,u?u=B-u:f++),k(t,r+T,f),k(t,r+S,u)}function P(){var t=this.buffer,r=this.offset,e=_(t,r+T),i=_(t,r+S);return n||(e|=0),e?e*B+i:i}function R(t){var r=this.buffer,e=this.offset,i=_(r,e+T),o=_(r,e+S),f="",u=!n&&2147483648&i;for(u&&(i=~i,o=B-o),t=t||10;;){var a=i%t*B+o;if(i=Math.floor(i/t),o=Math.floor(a/t),f=(a%t).toString(t)+f,!i&&!o)break}return u&&(f="-"+f),f}function k(t,r,e){t[r+D]=255&e,e>>=8,t[r+C]=255&e,e>>=8,t[r+Y]=255&e,e>>=8,t[r+I]=255&e}function _(t,r){return t[r+I]*U+(t[r+Y]<<16)+(t[r+C]<<8)+t[r+D]}var T=r?0:4,S=r?4:0,I=r?0:3,Y=r?1:2,C=r?2:1,D=r?3:0,O=r?l:d,L=r?p:y,M=i.prototype,N="is"+t,F="_"+N;return M.buffer=void 0,M.offset=0,M[F]=!0,M.toNumber=P,M.toString=R,M.toJSON=P,M.toArray=f,w&&(M.toBuffer=u),E&&(M.toArrayBuffer=a),i[N]=o,e[t]=i,i}function f(t){var r=this.buffer,e=this.offset;return g=null,t!==!1&&0===e&&8===r.length&&x(r)?r:h(r,e)}function u(t){var r=this.buffer,e=this.offset;if(g=w,t!==!1&&0===e&&8===r.length&&Buffer.isBuffer(r))return r;var n=new w(8);return c(n,0,r,e),n}function a(t){var r=this.buffer,e=this.offset,n=r.buffer;if(g=E,t!==!1&&0===e&&n instanceof A&&8===n.byteLength)return n;var i=new E(8);return c(i,0,r,e),i.buffer}function s(t,r){var e=t&&t.length;return r|=0,e&&r+8<=e&&"string"!=typeof t[r]}function c(t,r,e,n){r|=0,n|=0;for(var i=0;i<8;i++)t[r++]=255&e[n++]}function h(t,r){return Array.prototype.slice.call(t,r,r+8)}function l(t,r,e){for(var n=r+8;n>r;)t[--n]=255&e,e/=256}function p(t,r,e){var n=r+8;for(e++;n>r;)t[--n]=255&-e^255,e/=256}function d(t,r,e){for(var n=r+8;rB', 9 | result: () => exec('bold'), 10 | state: () => queryCommandState('bold'), 11 | title: 'Bold', 12 | } 13 | 14 | export const code = { 15 | icon: '</>', 16 | result: () => exec(formatBlock, '
'),
 17 |   title: 'Code',
 18 | }
 19 | 
 20 | export const heading1 = {
 21 |   icon: 'H1',
 22 |   result: () => exec(formatBlock, '

'), 23 | title: 'Heading 1', 24 | } 25 | 26 | export const heading2 = { 27 | icon: 'H2', 28 | result: () => exec(formatBlock, '

'), 29 | title: 'Heading 2', 30 | } 31 | 32 | export const image = { 33 | icon: '📷', 34 | result: () => { 35 | const url = window.prompt('Enter the image URL') 36 | if (url) exec('insertImage', url) 37 | }, 38 | title: 'Image', 39 | } 40 | 41 | export const italic = { 42 | icon: 'I', 43 | result: () => exec('italic'), 44 | state: () => queryCommandState('italic'), 45 | title: 'Italic', 46 | } 47 | 48 | export const line = { 49 | icon: '―', 50 | result: () => exec('insertHorizontalRule'), 51 | title: 'Horizontal Line', 52 | } 53 | 54 | export const link = { 55 | icon: '🔗', 56 | result: () => { 57 | const url = window.prompt('Enter the link URL') 58 | if (url) exec('createLink', url) 59 | }, 60 | title: 'Link', 61 | } 62 | 63 | export const olist = { 64 | icon: '#', 65 | result: () => exec('insertOrderedList'), 66 | title: 'Ordered List', 67 | } 68 | 69 | export const paragraph = { 70 | icon: '¶', 71 | result: () => exec(formatBlock, '

'), 72 | title: 'Paragraph', 73 | } 74 | 75 | export const quote = { 76 | icon: '“ ”', 77 | result: () => exec(formatBlock, '

'), 78 | title: 'Quote', 79 | } 80 | 81 | export const strikethrough = { 82 | icon: 'S', 83 | result: () => exec('strikeThrough'), 84 | state: () => queryCommandState('strikeThrough'), 85 | title: 'Strike-through', 86 | } 87 | 88 | export const ulist = { 89 | icon: '•', 90 | result: () => exec('insertUnorderedList'), 91 | title: 'Unordered List', 92 | } 93 | 94 | export const underline = { 95 | icon: 'U', 96 | result: () => exec('underline'), 97 | state: () => queryCommandState('underline'), 98 | title: 'Underline', 99 | } 100 | 101 | export const defaultActions = { 102 | bold, 103 | code, 104 | heading1, 105 | heading2, 106 | image, 107 | italic, 108 | line, 109 | link, 110 | olist, 111 | paragraph, 112 | quote, 113 | strikethrough, 114 | ulist, 115 | underline, 116 | } 117 | -------------------------------------------------------------------------------- /lib/pell/pell.css: -------------------------------------------------------------------------------- 1 | .pell { 2 | border: 1px solid rgba(10, 10, 10, 0.1); 3 | box-sizing: border-box; 4 | } 5 | 6 | .pell-content { 7 | box-sizing: border-box; 8 | height: 300px; 9 | outline: 0; 10 | overflow-y: auto; 11 | padding: 10px; 12 | } 13 | 14 | .pell-actionbar { 15 | background-color: #FFF; 16 | border-bottom: 1px solid rgba(10, 10, 10, 0.1); 17 | } 18 | 19 | .pell-button { 20 | background-color: transparent; 21 | border: none; 22 | cursor: pointer; 23 | height: 30px; 24 | outline: 0; 25 | width: 30px; 26 | vertical-align: bottom; 27 | } 28 | 29 | .pell-button-selected { 30 | background-color: #F0F0F0; 31 | } 32 | -------------------------------------------------------------------------------- /lib/pell/pell.js: -------------------------------------------------------------------------------- 1 | import { 2 | defaultActions, 3 | } from './actions.js' 4 | 5 | import { 6 | addEventListener, 7 | appendChild, 8 | createElement, 9 | defaultParagraphSeparatorString, 10 | exec, 11 | formatBlock, 12 | queryCommandValue, 13 | } from './utilities.js' 14 | 15 | const defaultClasses = { 16 | actionbar: 'pell-actionbar', 17 | button: 'pell-button', 18 | content: 'pell-content', 19 | selected: 'pell-button-selected', 20 | } 21 | 22 | export const init = settings => { 23 | const actions = settings.actions 24 | ? ( 25 | settings.actions.map(action => { 26 | if (typeof action === 'string') return defaultActions[action] 27 | else if (defaultActions[action.name]) return { ...defaultActions[action.name], ...action } 28 | return action 29 | }) 30 | ) 31 | : Object.keys(defaultActions).map(action => defaultActions[action]) 32 | 33 | const classes = { ...defaultClasses, ...settings.classes } 34 | 35 | const defaultParagraphSeparator = settings[defaultParagraphSeparatorString] || 'div' 36 | 37 | const actionbar = createElement('div') 38 | actionbar.className = classes.actionbar 39 | appendChild(settings.element, actionbar) 40 | 41 | const content = settings.element.content = createElement('div') 42 | content.contentEditable = true 43 | content.className = classes.content 44 | content.oninput = ({ target: { firstChild } }) => { 45 | if (firstChild && firstChild.nodeType === 3) exec(formatBlock, `<${defaultParagraphSeparator}>`) 46 | else if (content.innerHTML === '
') content.innerHTML = '' 47 | settings.onChange(content.innerHTML) 48 | } 49 | content.onkeydown = event => { 50 | if (event.key === 'Enter' && queryCommandValue(formatBlock) === 'blockquote') { 51 | setTimeout(() => exec(formatBlock, `<${defaultParagraphSeparator}>`), 0) 52 | } 53 | } 54 | appendChild(settings.element, content) 55 | 56 | actions.forEach(action => { 57 | const button = createElement('button') 58 | button.className = classes.button 59 | button.innerHTML = action.icon 60 | button.title = action.title 61 | button.setAttribute('type', 'button') 62 | button.onclick = () => action.result() && content.focus() 63 | 64 | if (action.state) { 65 | const handler = () => button.classList[action.state() ? 'add' : 'remove'](classes.selected) 66 | addEventListener(content, 'keyup', handler) 67 | addEventListener(content, 'mouseup', handler) 68 | addEventListener(button, 'click', handler) 69 | } 70 | 71 | appendChild(actionbar, button) 72 | }) 73 | 74 | if (settings.styleWithCSS) exec('styleWithCSS') 75 | exec(defaultParagraphSeparatorString, defaultParagraphSeparator) 76 | 77 | return settings.element 78 | } 79 | 80 | export default { 81 | init, exec 82 | } 83 | -------------------------------------------------------------------------------- /lib/pell/utilities.js: -------------------------------------------------------------------------------- 1 | export const addEventListener = (parent, type, listener) => parent.addEventListener(type, listener) 2 | 3 | export const appendChild = (parent, child) => parent.appendChild(child) 4 | 5 | export const createElement = tag => document.createElement(tag) 6 | 7 | export const defaultParagraphSeparatorString = 'defaultParagraphSeparator' 8 | 9 | export const exec = (command, value = null) => document.execCommand(command, false, value) 10 | 11 | export const formatBlock = 'formatBlock' 12 | 13 | export const queryCommandState = command => document.queryCommandState(command) 14 | 15 | export const queryCommandValue = command => document.queryCommandValue(command) 16 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "CDEncrypt", 3 | "name": "CDEncrypt", 4 | "icons": [ 5 | { 6 | "src":"img/icon.png", 7 | "sizes": "180x180" 8 | } 9 | ], 10 | "start_url": "/", 11 | "display": "standalone" 12 | } 13 | -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (MIT License) 3 | * 4 | * Author: Duke Fong 5 | */ 6 | 7 | /* Message format: 'cde|' + msgpack('message body...') or msgpack: 8 | * { 9 | * b: 'message body...', 10 | * f: { 11 | * file_name: {type: 'image/jpeg', data: Uint8Array} 12 | * }, 13 | * // v: 0, // version 14 | * // fonts: { 15 | * // font_name: Uint8Array 16 | * // } 17 | * } 18 | */ 19 | 20 | import pell from '../lib/pell/pell.js' 21 | import { L } from './lang/lang.js' 22 | import { 23 | sha256, aes256, aes256_blk0_d, 24 | dat2hex, dat2str, str2dat, 25 | escape_html, date2num, 26 | read_file, download, 27 | readable_size, linkable } from './utils/helper.js' 28 | import { Idb } from './utils/idb.js'; 29 | 30 | 31 | let first_install = false; 32 | let editor; 33 | let in_plaintext_ori = ''; // before convert links by anchorme 34 | 35 | let db = null; 36 | let pw_list = []; // password list 37 | let pw_def = null; // default password 38 | 39 | let in_prj = { b: '', f: {} }; 40 | let in_prj_url_map = {}; 41 | 42 | let out_pw = null; // password for edit & reply 43 | let out_prj = { b: '', f: {} }; 44 | let out_prj_url_map = {}; // filename: blob_url 45 | 46 | 47 | function html_blob_conv(html, url_map, cde2blob=true) { 48 | let parser = new DOMParser() 49 | let doc = parser.parseFromString(html, "text/html"); 50 | for (let a of ['src', 'href', 'poster']) { 51 | for (let elem of doc.querySelectorAll(`[${a}]`)) { 52 | let url = elem.getAttribute(a); 53 | if (cde2blob) { 54 | if (url.search("cde:") == 0) { 55 | let name = url.slice(4); 56 | if (!url_map[name]) { 57 | console.warn(`lost file: ${name}`); 58 | continue; 59 | } 60 | elem.setAttribute(a, url_map[name]); 61 | } 62 | } else { 63 | if (url.search("blob:") == 0) { 64 | let filtered = Object.entries(url_map).filter(([k,v]) => v == url); 65 | let fname = filtered.length ? filtered[0][0] : null; 66 | elem.setAttribute(a, `cde:${fname}`); 67 | } 68 | } 69 | } 70 | } 71 | return doc.body.innerHTML; 72 | } 73 | 74 | async function to_local() { 75 | let parser = new DOMParser() 76 | let doc = parser.parseFromString(editor.content.innerHTML, "text/html"); 77 | for (let a of ['src', 'href', 'poster']) { 78 | for (let elem of doc.querySelectorAll(`[${a}]`)) { 79 | let url = elem.getAttribute(a); 80 | if (url.search("blob:") == 0) 81 | continue; 82 | console.log('to_local:', url); 83 | try { 84 | let loc = new URL(url); 85 | if (loc.protocol == 'http:') { 86 | console.log(`to_local: force https: ${loc.href}`) 87 | loc.protocol = 'https:'; 88 | } 89 | const response = await fetch(loc); 90 | const blob = await response.blob(); 91 | const ab = await new Response(blob).arrayBuffer(); 92 | const u8a = new Uint8Array(ab); 93 | let sha = await sha256(u8a); 94 | let name = `_${Object.keys(out_prj.f).length+1}.${blob.type.split('/')[1]}`; 95 | out_prj_url_map[name] = URL.createObjectURL(blob); 96 | out_prj.f[name] = {'type': blob.type, 'data': u8a}; 97 | elem.setAttribute(a, out_prj_url_map[name]); 98 | } catch (e) { 99 | if (!confirm(`${L('Download resource error, continue?\n(Please try browser plug-ins e.g. CORS Unblock.)')}\n${url}: ${e}`)) 100 | return; 101 | } 102 | } 103 | } 104 | editor.content.innerHTML = doc.body.innerHTML; 105 | out_prj.b = html_blob_conv(editor.content.innerHTML, out_prj_url_map, false); 106 | await db.set('tmp', 'b', out_prj.b); 107 | await db.set('tmp', 'f', out_prj.f); 108 | update_out_files(); 109 | alert(L('OK')); 110 | } 111 | 112 | 113 | window.addEventListener('load', async function() { 114 | console.log("load app"); 115 | db = await new Idb(); 116 | pw_list = await db.get('var', 'pw_list'); 117 | pw_def = await db.get('var', 'pw_def'); 118 | if (!pw_list) { 119 | first_install = true; 120 | pw_list = []; 121 | await db.set('var', 'pw_list', pw_list); 122 | } 123 | if (!pw_def && pw_list.length) { 124 | pw_def = pw_list[0]; 125 | await db.set('var', 'pw_def', pw_def); 126 | } 127 | out_pw = pw_def; // use default passwd 128 | update_out_pw(); 129 | 130 | out_prj.b = await db.get('tmp', 'b') || ''; 131 | out_prj.f = await db.get('tmp', 'f') || {}; 132 | for (let name in out_prj.f) { 133 | let f = out_prj.f[name]; 134 | let blob = new Blob([f['data']], {type: f['type']}); 135 | out_prj_url_map[name] = URL.createObjectURL(blob); 136 | } 137 | 138 | editor = pell.init({ 139 | element: document.getElementById('editor'), 140 | onChange: async html => { 141 | out_prj.b = html_blob_conv(html, out_prj_url_map, false); 142 | await db.set('tmp', 'b', out_prj.b); 143 | }, 144 | defaultParagraphSeparator: 'p', 145 | styleWithCSS: false, 146 | actions: [ 147 | 'bold', 148 | 'code', 149 | 'heading1', 150 | 'heading2', 151 | 'image', 152 | 'italic', 153 | 'line', 154 | 'link', 155 | 'olist', 156 | 'paragraph', 157 | 'quote', 158 | 'strikethrough', 159 | 'ulist', 160 | 'underline', 161 | { 162 | name: 'backColor', 163 | icon: '
A
', 164 | title: 'Highlight Color', 165 | result: () => pell.exec('backColor', 'pink') 166 | }, 167 | { 168 | name: 'default', 169 | icon: '', 170 | title: 'Remove Format', 171 | result: () => pell.exec('removeFormat') 172 | } 173 | ], 174 | classes: { 175 | actionbar: 'pell-actionbar', 176 | button: 'pell-button', 177 | content: 'pell-content', 178 | selected: 'pell-button-selected' 179 | } 180 | }); 181 | 182 | editor.content.innerHTML = html_blob_conv(out_prj.b, out_prj_url_map); 183 | update_out_files(); 184 | 185 | update_modal_passwd_list(); 186 | update_modal_passwd_sel(); 187 | 188 | if (location.protocol != 'https:' && location.hostname != 'localhost') { 189 | alert(L('Error: only support https')); 190 | location.href = location.href.replace("http://", "https://"); 191 | } 192 | 193 | await decrypt(location.hash.slice(1)); 194 | init_sw(); 195 | }); 196 | 197 | document.getElementById('clean_all').onclick = async function() { 198 | if (!confirm(L('Are you sure you want to clean all?'))) 199 | return; 200 | await db.clear('var'); 201 | await db.clear('tmp'); 202 | alert(L('Clean all finished')); 203 | location = location.origin + location.pathname; 204 | }; 205 | 206 | document.getElementById('out_add_file').onchange = async function() { 207 | for (let file of this.files) { 208 | let dat = await read_file(file); 209 | out_prj.f[file.name] = {'type': file.type, 'data': dat}; 210 | out_prj_url_map[file.name] = URL.createObjectURL(file); 211 | } 212 | update_out_files(); 213 | await db.set('tmp', 'f', out_prj.f); 214 | this.value = ''; 215 | }; 216 | 217 | function update_out_files() { 218 | let list = document.getElementById('out_files'); 219 | list.innerHTML = ''; 220 | 221 | for (let name in out_prj.f) { 222 | let name_e = escape_html(name); 223 | let is_image = out_prj.f[name]['type'].startsWith('image'); 224 | let is_video = out_prj.f[name]['type'].startsWith('video'); 225 | let html = ` 226 | `; 238 | list.insertAdjacentHTML('beforeend', html); 239 | list.lastElementChild.getElementsByTagName("button")[0].onclick = function() { 240 | if (is_image) { 241 | pell.exec('insertImage', out_prj_url_map[name]); 242 | } else if (is_video) { 243 | let html = ``; 244 | pell.exec('insertHTML', html) 245 | } 246 | }; 247 | list.lastElementChild.getElementsByTagName("button")[1].onclick = async function() { 248 | URL.revokeObjectURL(out_prj_url_map[name]); 249 | delete out_prj.f[name]; 250 | delete out_prj_url_map[name]; 251 | await db.set('tmp', 'f', out_prj.f); 252 | update_out_files(); 253 | }; 254 | } 255 | } 256 | 257 | function update_in_files() { 258 | let list = document.getElementById('in_files'); 259 | list.innerHTML = ''; 260 | for (let name in in_prj.f) { 261 | let f = in_prj.f[name]; 262 | let blob_url = in_prj_url_map[name]; 263 | list.innerHTML += ` 264 | `; 272 | } 273 | } 274 | 275 | function update_modal_passwd_list() { 276 | let list = document.getElementById('passwd_list'); 277 | list.innerHTML = ''; 278 | 279 | for (let i = 0; i < pw_list.length; i++) { // escape 280 | let pw = pw_list[i]; 281 | let html = ` 282 | `; 290 | list.insertAdjacentHTML('beforeend', html); 291 | list.lastElementChild.getElementsByTagName("button")[0].onclick = async function() { 292 | pw_list = pw_list.filter(val => val != pw); 293 | await db.set('var', 'pw_list', pw_list); 294 | if (pw_def == pw) { 295 | pw_def = null; 296 | if (pw_list.length) 297 | pw_def = pw_list[0]; 298 | await db.set('var', 'pw_def', pw_def); 299 | } 300 | if (out_pw == pw) { 301 | out_pw = pw_def; 302 | update_out_pw(); 303 | } 304 | update_modal_passwd_list(); 305 | update_modal_passwd_sel(); 306 | }; 307 | } 308 | } 309 | 310 | function update_modal_passwd_sel() { 311 | let list = document.getElementById('passwd_sel'); 312 | list.innerHTML = ''; 313 | 314 | for (let i = 0; i < pw_list.length; i++) { // escape 315 | let pw = pw_list[i]; 316 | let html = ` 317 | `; 325 | list.insertAdjacentHTML('beforeend', html); 326 | list.lastElementChild.getElementsByTagName("button")[0].onclick = async function() { 327 | out_pw = pw_def = pw; 328 | await db.set('var', 'pw_def', pw_def); 329 | modal_close('modal_passwd_sel'); 330 | update_out_pw(); 331 | }; 332 | } 333 | } 334 | 335 | async function _add_passwd(pw) { 336 | // remove exist first: move exist to top 337 | pw_list = pw_list.filter(val => val != pw); 338 | pw_list.unshift(pw); 339 | await db.set('var', 'pw_list', pw_list); 340 | update_modal_passwd_list(); 341 | update_modal_passwd_sel(); 342 | if (!out_pw) 343 | out_pw = pw; 344 | update_out_pw(); 345 | } 346 | 347 | window.add_passwd = async () => { 348 | let pw = prompt(L('New password:')); 349 | if (!pw) 350 | return; 351 | await _add_passwd(pw); 352 | }; 353 | 354 | function update_out_pw() { 355 | if (out_pw) { 356 | let pw_e = escape_html(out_pw.slice(0,3)); 357 | let i = pw_list.findIndex(val => val == out_pw); 358 | document.getElementById('out_pw').innerHTML = `#${i}: ${pw_e}…`; 359 | } else { 360 | document.getElementById('out_pw').innerHTML = `--`; 361 | } 362 | } 363 | 364 | // share_url, show_url, share_file, download_file 365 | async function encrypt(method='show_url') { 366 | if (!out_pw) { 367 | alert(L('Please set password')); 368 | return; 369 | } 370 | if (!out_prj.b && !Object.keys(out_prj.f).length) { 371 | alert(L('Please input text')); 372 | return; 373 | } 374 | if (method.startsWith('share') && !navigator.share) { 375 | alert(L('Sharing is not supported')); 376 | return; 377 | } 378 | 379 | const key = await sha256(str2dat(out_pw)); 380 | const header = str2dat('cde|'); 381 | const content = msgpack.encode(Object.keys(out_prj.f).length ? out_prj : out_prj.b); 382 | const combined = new Uint8Array([...header, ...content]); 383 | const out = await aes256(combined, key); 384 | document.getElementById('show_out_url').innerHTML = ''; 385 | 386 | if (method.search('url') >= 0 && out.length >= 4000) { 387 | if (!confirm(L('Data is too large for URL encoding, continue?'))) 388 | return; 389 | } 390 | 391 | if (method == 'share_url') { 392 | let b64 = base64js.fromByteArray(out); 393 | navigator.share({ url: `${location.origin+location.pathname}#${b64}` }); 394 | return; 395 | } 396 | 397 | if (method == 'show_url') { 398 | let b64 = base64js.fromByteArray(out); 399 | let url = `${location.origin+location.pathname}#${b64}`; 400 | document.getElementById('show_out_url').innerHTML = url; 401 | navigator.clipboard.writeText(url).then(function() { 402 | alert(L('Copy to clipboard successed')); 403 | }, function() { 404 | alert(L('Copy to clipboard failed')); 405 | }); 406 | return; 407 | } 408 | 409 | let fname = document.getElementById('out_fname').value; 410 | if (!fname) 411 | fname = date2num(); 412 | 413 | if (method == 'share_file') { 414 | fname += '.txt'; 415 | 416 | let file = new File([out], fname, {type: 'text/plain'}); 417 | console.log("share file:", file); 418 | let data = {files: [file]}; 419 | 420 | if (!navigator.canShare || !navigator.canShare(data)) { 421 | // Search: Web Share API - Level 2, permitted extensions 422 | // only image, video, audio and text files can be shared 423 | alert(L('File sharing is not supported')); 424 | return; 425 | } 426 | 427 | navigator.share(data) 428 | .then(() => { 429 | console.log('Successfully sent share'); 430 | }) 431 | .catch((err) => { 432 | console.log('Error sharing: ', err); 433 | }); 434 | return; 435 | } 436 | 437 | if (method == 'download_file') { 438 | download(out, fname); 439 | return; 440 | } 441 | }; 442 | 443 | async function _decrypt(dat, pw) { 444 | let key = await sha256(str2dat(pw)); 445 | let content; 446 | try { 447 | let blk0 = await aes256_blk0_d(dat.slice(0, 16), key); // try to decrypt the first block 448 | let header = blk0.slice(0, 4); 449 | if (dat2str(header) != 'cde|') 450 | return null; 451 | let combined = await aes256(dat, key, 'decrypt'); 452 | content = combined.slice(4); 453 | } catch (e) { 454 | console.log('decrypt err'); 455 | return null; 456 | } 457 | 458 | try { 459 | return msgpack.decode(content); 460 | } catch (e) { 461 | console.log('msgpack decode err'); 462 | return null; 463 | } 464 | } 465 | 466 | async function decrypt(dat) { 467 | if (typeof dat == 'string') { 468 | let str = dat; 469 | /* 470 | if (!str) { 471 | let c = await navigator.clipboard.readText(); 472 | let hash_pos = c.search('#'); 473 | if (hash_pos < 0) 474 | return; 475 | str = c.slice(hash_pos + 1); 476 | } */ 477 | if (!str) 478 | return; 479 | if (str.startsWith(':')) { 480 | if (str.startsWith(':http') || str.startsWith(':/') || str.startsWith(':.')) 481 | await fetch_remote(str.slice(1)); 482 | else 483 | await fetch_remote('https://' + str.slice(1)); 484 | return; 485 | } 486 | 487 | try { 488 | dat = base64js.toByteArray(str); 489 | } catch (e) { 490 | alert(L('The Base64 string is invalid')); 491 | return; 492 | } 493 | } 494 | 495 | let pw = null; 496 | let pw_index = -1; 497 | let ret; 498 | for (let i = 0; i < pw_list.length; i++) { 499 | pw = pw_list[i]; 500 | ret = await _decrypt(dat, pw); 501 | if (ret) { 502 | pw_index = i; 503 | break; 504 | } 505 | } 506 | if (pw_index == -1) { 507 | while (true) { 508 | pw = prompt(L('No password suitable, add new password:')); 509 | if (!pw) 510 | return; 511 | ret = await _decrypt(dat, pw); 512 | if (ret) { 513 | modal_close('modal_fetch'); 514 | break; 515 | } 516 | } 517 | await _add_passwd(pw); 518 | pw_index = 0; 519 | } 520 | 521 | if (typeof ret == 'string') 522 | in_prj = { b: ret, f: {} } 523 | else 524 | in_prj = ret; 525 | let pw_e = escape_html(pw.slice(0,3)); 526 | let i = pw_list.findIndex(val => val == pw); 527 | document.getElementById('in_cur_pw').innerHTML = `#${i}: ${pw_e}…`; 528 | out_pw = pw; 529 | update_out_pw(); 530 | 531 | in_prj_url_map = {}; 532 | let list = document.getElementById('in_files'); 533 | list.innerHTML = ''; 534 | for (let name in in_prj.f) { 535 | let f = in_prj.f[name]; 536 | let blob = new Blob([f['data']], {type: f['type']}); 537 | in_prj_url_map[name] = URL.createObjectURL(blob); 538 | } 539 | update_in_files(); 540 | in_plaintext_ori = html_blob_conv(in_prj.b, in_prj_url_map); 541 | document.getElementById('in_plaintext').innerHTML = in_plaintext_ori; 542 | linkable(document.getElementById('in_plaintext')); 543 | } 544 | 545 | async function fetch_remote(url) { 546 | modal_open('modal_fetch'); 547 | let controller = new AbortController(); 548 | document.getElementById('fetch_progress').value = 0; 549 | document.getElementById('fetch_progress_text').innerHTML = '0%'; 550 | document.getElementById('fetch_size').innerHTML = ''; 551 | document.getElementById('fetch_status').innerHTML = ''; 552 | document.getElementById("fetch_ok").disabled = true; 553 | for (let elem of document.getElementsByName('fetch_cancel')) { 554 | elem.onclick = () => { 555 | modal_close('modal_fetch'); 556 | controller.abort(); 557 | } 558 | } 559 | let response; 560 | try { 561 | console.log(`fetch_remote: ${url}`); 562 | response = await fetch(url, {signal: controller.signal}); 563 | } catch (e) { 564 | document.getElementById('fetch_status').innerHTML = `${L('Error')}: ${e}`; 565 | return; 566 | } 567 | const reader = response.body.getReader(); 568 | const total_len = +response.headers.get('Content-Length'); 569 | let received_len = 0; 570 | let chunks = []; 571 | while(true) { 572 | try { 573 | const {done, value} = await reader.read(); 574 | if (done) 575 | break; 576 | chunks.push(value); 577 | received_len += value.length; 578 | if (total_len > 0) { 579 | let progress = Math.round(received_len / total_len * 100); 580 | document.getElementById('fetch_progress').value = progress; 581 | document.getElementById('fetch_progress_text').innerHTML = `${progress}%`; 582 | } 583 | document.getElementById('fetch_size').innerHTML = 584 | `${L('Received')} ${readable_size(received_len)} / ${readable_size(total_len)}`; 585 | } catch (e) { 586 | console.log('fetch read catch', e); 587 | document.getElementById('fetch_status').innerHTML = `| ${L('Error')}: ${e}`; 588 | return; 589 | } 590 | } 591 | if (response.status !== 200) { 592 | document.getElementById('fetch_status').innerHTML = `| ${L('Error')}: ${response.status}`; 593 | return; 594 | } 595 | let dat = new Uint8Array(received_len); 596 | let pos = 0; 597 | for(let chunk of chunks) { 598 | dat.set(chunk, pos); 599 | pos += chunk.length; 600 | } 601 | document.getElementById('fetch_status').innerHTML = `| ${L('Done!')}`; 602 | document.getElementById("fetch_ok").disabled = false; 603 | document.getElementById("fetch_ok").onclick = async () => { 604 | await decrypt(dat); 605 | modal_close('modal_fetch'); 606 | }; 607 | } 608 | 609 | document.getElementById('in_add_file').onchange = async function() { 610 | if (!this.files.length) 611 | return; 612 | let dat = await read_file(this.files[0]); 613 | await decrypt(dat); 614 | this.value = ''; 615 | }; 616 | 617 | document.getElementById('in_add_text').onclick = async function() { 618 | let str = prompt(L('Input URL or Base64 string:')); 619 | if (!str) 620 | return; 621 | let hash_pos = str.search('#'); 622 | if (hash_pos >= 0) 623 | str = str.slice(hash_pos + 1); 624 | await decrypt(str); 625 | }; 626 | 627 | document.getElementById('re_edit').onclick = async function() { 628 | out_prj_url_map = in_prj_url_map; 629 | out_prj = in_prj; 630 | editor.content.innerHTML = in_plaintext_ori; 631 | update_out_files(); 632 | await db.set('tmp', 'b', out_prj.b); 633 | await db.set('tmp', 'f', out_prj.f); 634 | alert(L('OK')); 635 | }; 636 | 637 | document.getElementById('preview').onclick = async function() { 638 | in_prj_url_map = out_prj_url_map; 639 | in_prj = out_prj; 640 | in_plaintext_ori = editor.content.innerHTML; 641 | document.getElementById('in_plaintext').innerHTML = in_plaintext_ori; 642 | linkable(document.getElementById('in_plaintext')); 643 | update_in_files(); 644 | document.getElementById('in_cur_pw').innerHTML = '--'; 645 | alert(L('OK')); 646 | }; 647 | 648 | 649 | document.getElementById('share_url').onclick = async () => await encrypt('share_url'); 650 | document.getElementById('show_url').onclick = async () => await encrypt('show_url'); 651 | document.getElementById('share_file').onclick = async () => await encrypt('share_file'); 652 | document.getElementById('download_file').onclick = async () => await encrypt('download_file'); 653 | document.getElementById('to_local').onclick = async () => await to_local(); 654 | 655 | window.modal_open = id => document.getElementById(id).classList.add('is-active'); 656 | window.modal_close = id => document.getElementById(id).classList.remove('is-active'); 657 | 658 | function init_sw() { 659 | console.log('init_sw...'); 660 | if ('serviceWorker' in navigator) { 661 | navigator.serviceWorker.register('/sw.js', { 662 | scope: '/' 663 | }).then(function(reg) { 664 | if (reg.installing) { 665 | console.log('Service worker installing'); 666 | } else if (reg.waiting) { 667 | console.log('Service worker installed'); 668 | } else if (reg.active) { 669 | console.log('Service worker active'); 670 | } 671 | }).catch(function(error) { 672 | console.log('Registration failed with ' + error); 673 | }); 674 | 675 | navigator.serviceWorker.addEventListener('controllerchange', () => { 676 | if (!first_install) { 677 | alert(L('Switching APP to new version.')); 678 | location.reload(); 679 | } 680 | }); 681 | } 682 | } 683 | -------------------------------------------------------------------------------- /src/lang/lang.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (MIT License) 3 | * 4 | * Author: Duke Fong 5 | */ 6 | 7 | let trans_hk = { 8 | 'Passwords': '密碼', 9 | 'Open File': '文件導入', 10 | 'Input Text': '字符導入', 11 | 'Reload Page': '刷新頁面', 12 | 'Clean All': '清除所有數據', 13 | 14 | 'Plaintext': '明文', 15 | 'Use password': '使用密碼', 16 | 'Content': '內容', 17 | 'Files': '文件', 18 | 'Edit': '編輯', 19 | 'Preview': '預覽', 20 | 21 | 'Reply': '回覆', 22 | 'Add File': '添加文件', 23 | 'Save Resources Locally': '保存資源到本地', 24 | 'Share URL': '分享鏈接', 25 | 'Show URL': '顯示鏈接', 26 | 'Share File': '分享文件', 27 | 'Download File': '下載文件', 28 | 29 | 'Password List': '密碼列表', 30 | 'Add': '添加', 31 | 'Cancel': '取消', 32 | 'Password Select': '選擇密碼', 33 | 34 | 'Set': '選擇', 35 | 'Password': '密碼', 36 | 'Insert': '插入', 37 | 'Remove': '刪除', 38 | 39 | 'Download Progress': '下載進度', 40 | 'Received': '已接收', 41 | 'Done!': '完成!', 42 | 'Error': '出錯', 43 | 44 | 'Download resource error, continue?\n(Please try browser plug-ins e.g. CORS Unblock.)': '下載資源出錯,繼續?\n(請嘗試瀏覽器插件例如 CORS Unblock.)', 45 | 'Error: only support https': '錯誤:只支持 https', 46 | 'The Base64 string is invalid': 'Base64 字符串無效', 47 | 'File name, use date if empty': '文件名,留空使用日期', 48 | 'Are you sure you want to clean all?': '是否確認清除所有數據?', 49 | 'Clean all finished': '全部清除成功', 50 | 'Please set password': '請設置密碼', 51 | 'Please input text': '請輸入文字', 52 | 'Sharing is not supported': '不支持分享', 53 | 'Data is too large for URL encoding, continue?': '數據對於 URL 編碼過大,是否繼續?', 54 | 'Copy to clipboard successed': '成功複製到剪切板', 55 | 'Copy to clipboard failed': '複製到剪切板失敗', 56 | 'File sharing is not supported': '不支持的文件分享', 57 | 'No password suitable, add new password:': '無匹配的密碼,增加新密碼:', 58 | 'Input URL or Base64 string:': '請輸入 URL 或 Base64 字串:', 59 | 'New password:': '新密碼:', 60 | 61 | 'OK': '好', 62 | 'Switching APP to new version.': '切換 APP 至新版本' 63 | }; 64 | 65 | // cat lang.js | cconv -f UTF8 -t UTF8-CN 66 | let trans_cn = { 67 | 'Passwords': '密码', 68 | 'Open File': '文件导入', 69 | 'Input Text': '字符导入', 70 | 'Reload Page': '刷新页面', 71 | 'Clean All': '清除所有数据', 72 | 73 | 'Plaintext': '明文', 74 | 'Use password': '使用密码', 75 | 'Content': '内容', 76 | 'Files': '文件', 77 | 'Edit': '编辑', 78 | 'Preview': '预览', 79 | 80 | 'Reply': '回覆', 81 | 'Add File': '添加文件', 82 | 'Save Resources Locally': '保存资源到本地', 83 | 'Share URL': '分享链接', 84 | 'Show URL': '显示链接', 85 | 'Share File': '分享文件', 86 | 'Download File': '下载文件', 87 | 88 | 'Password List': '密码列表', 89 | 'Add': '添加', 90 | 'Cancel': '取消', 91 | 'Password Select': '选择密码', 92 | 93 | 'Set': '选择', 94 | 'Password': '密码', 95 | 'Insert': '插入', 96 | 'Remove': '删除', 97 | 98 | 'Download Progress': '下载进度', 99 | 'Received': '已接收', 100 | 'Done!': '完成!', 101 | 'Error': '出错', 102 | 103 | 'Download resource error, continue?\n(Please try browser plug-ins e.g. CORS Unblock.)': '下载资源出错,继续?\n(请尝试浏览器插件例如 CORS Unblock.)', 104 | 'Error: only support https': '错误:只支持 https', 105 | 'The Base64 string is invalid': 'Base64 字符串无效', 106 | 'File name, use date if empty': '文件名,留空使用日期', 107 | 'Are you sure you want to clean all?': '是否确认清除所有数据?', 108 | 'Clean all finished': '全部清除成功', 109 | 'Please set password': '请设置密码', 110 | 'Please input text': '请输入文字', 111 | 'Sharing is not supported': '不支持分享', 112 | 'Data is too large for URL encoding, continue?': '数据对于 URL 编码过大,是否继续?', 113 | 'Copy to clipboard successed': '成功复制到剪切板', 114 | 'Copy to clipboard failed': '复制到剪切板失败', 115 | 'File sharing is not supported': '不支持的文件分享', 116 | 'No password suitable, add new password:': '无匹配的密码,增加新密码:', 117 | 'Input URL or Base64 string:': '请输入 URL 或 Base64 字串:', 118 | 'New password:': '新密码:', 119 | 120 | 'OK': '好', 121 | 'Switching APP to new version.': '切换 APP 至新版本' 122 | }; 123 | 124 | 125 | let lang = 'en'; 126 | if (navigator.language.startsWith('zh')) { 127 | lang = 'hk'; 128 | if (navigator.language.includes('CN')) 129 | lang = 'cn'; 130 | } 131 | 132 | function L(ori, mark=null) { 133 | if (lang == 'en') 134 | return ori; 135 | if (!mark) 136 | mark = ori; 137 | let ret = lang == 'hk' ? trans_hk[mark] : trans_cn[mark]; 138 | return ret || ori; 139 | } 140 | 141 | export { L }; 142 | -------------------------------------------------------------------------------- /src/utils/helper.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (MIT License) 3 | * 4 | * Author: Duke Fong 5 | */ 6 | 7 | async function read_file(file) { 8 | return await new Promise((resolve, reject) => { 9 | let reader = new FileReader(); 10 | 11 | reader.onload = () => { 12 | resolve(new Uint8Array(reader.result)); 13 | }; 14 | reader.onerror = reject; 15 | reader.readAsArrayBuffer(file); 16 | }) 17 | } 18 | 19 | async function load_img(img, url) { 20 | let ret = -1; 21 | await new Promise(resolve => { 22 | img.src = url; 23 | img.onload = () => { ret = 0; resolve(); }; 24 | img.onerror = () => { console.error(`load_img: ${url}`); resolve(); }; 25 | }); 26 | return ret; 27 | } 28 | 29 | function date2num() { 30 | let d = (new Date()).toLocaleString('en-GB'); 31 | let s = d.split(/[^0-9]/); 32 | return `${s[2]}${s[1]}${s[0]}${s[4]}${s[5]}${s[6]}`; 33 | } 34 | 35 | async function sha256(dat) { 36 | const hashBuffer = await crypto.subtle.digest('SHA-256', dat); 37 | return new Uint8Array(hashBuffer); 38 | } 39 | 40 | async function aes256(dat, key, type='encrypt') { 41 | let iv = new Uint8Array(16); // zeros 42 | let _key = await crypto.subtle.importKey('raw', key, {name: 'AES-CBC'}, false, ['encrypt', 'decrypt']); 43 | 44 | if (type == 'encrypt') 45 | return new Uint8Array(await crypto.subtle.encrypt({name: 'AES-CBC', iv: iv}, _key, dat)); 46 | else 47 | return new Uint8Array(await crypto.subtle.decrypt({name: 'AES-CBC', iv: iv}, _key, dat)); 48 | } 49 | 50 | // decrypt the first block and trick the padding check 51 | async function aes256_blk0_d(dat, key) { 52 | let iv = new Uint8Array(16); // zeros 53 | let _key = await crypto.subtle.importKey('raw', key, {name: 'AES-CBC'}, false, ['encrypt', 'decrypt']); 54 | 55 | let pad_dat = new Uint8Array(16); 56 | for (let i = 0; i < 16; i++) 57 | pad_dat[i] = 16; // PKCS#7 58 | let pad_tmp = new Uint8Array(await crypto.subtle.encrypt({name: 'AES-CBC', iv: dat}, _key, pad_dat)); 59 | let pad = pad_tmp.slice(0, 16); 60 | let dat_pad = new Uint8Array([...dat, ...pad]); 61 | return new Uint8Array(await crypto.subtle.decrypt({name: 'AES-CBC', iv: iv}, _key, dat_pad)); 62 | } 63 | 64 | function dat2hex(dat, join='') { 65 | const dat_array = Array.from(dat); 66 | return dat_array.map(b => b.toString(16).padStart(2, '0')).join(join); 67 | } 68 | 69 | function dat2str(dat) { 70 | return new TextDecoder().decode(dat); 71 | } 72 | 73 | function str2dat(str) { 74 | let encoder = new TextEncoder(); 75 | return encoder.encode(str); 76 | } 77 | 78 | // list: ['x', 'y'] 79 | // map: {'rotation': 'r'} 80 | function cpy(dst, src, list, map = {}) { 81 | for (let i of list) { 82 | if (i in src) 83 | dst[i] = src[i]; 84 | } 85 | for (let i in map) { 86 | if (i in src) 87 | dst[map[i]] = src[i]; 88 | } 89 | } 90 | 91 | function download_url(data, fileName) { 92 | var a; 93 | a = document.createElement('a'); 94 | a.href = data; 95 | a.download = fileName; 96 | document.body.appendChild(a); 97 | a.style = 'display: none'; 98 | a.click(); 99 | a.remove(); 100 | }; 101 | 102 | function download(data, fileName='dat.bin', mimeType='application/octet-stream') { 103 | var blob, url; 104 | blob = new Blob([data], {type: mimeType}); 105 | url = window.URL.createObjectURL(blob); 106 | download_url(url, fileName); 107 | setTimeout(function() { return window.URL.revokeObjectURL(url); }, 1000); 108 | }; 109 | 110 | function escape_html(unsafe) { 111 | return unsafe 112 | .replace(/&/g, "&") 113 | .replace(//g, ">") 115 | .replace(/"/g, """) 116 | .replace(/'/g, "'"); 117 | } 118 | 119 | function readable_size(bytes, fixed=3, si=true) { 120 | var thresh = si ? 1000 : 1024; 121 | if(Math.abs(bytes) < thresh) { 122 | return bytes + ' B'; 123 | } 124 | var units = si 125 | ? ['kB','MB','GB','TB','PB','EB','ZB','YB'] 126 | : ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB']; 127 | var u = -1; 128 | do { 129 | bytes /= thresh; 130 | ++u; 131 | } while(Math.abs(bytes) >= thresh && u < units.length - 1); 132 | return bytes.toFixed(fixed)+' '+units[u]; 133 | } 134 | 135 | function walk(el, fn) { 136 | for (let i = 0, len = el.childNodes.length; i < len; i++) { 137 | let node = el.childNodes[i]; 138 | if (node.nodeType === 3) 139 | fn(node); 140 | else if (node.nodeType === 1 && node.nodeName !== "SCRIPT") 141 | walk(node, fn); 142 | } 143 | } 144 | 145 | function linkable(el) { 146 | walk(el, function(n) { 147 | let replacementNode = document.createElement('span'); 148 | let newHtml = anchorme(n.textContent); 149 | n.parentNode.insertBefore(replacementNode, n); 150 | n.parentNode.removeChild(n); 151 | replacementNode.outerHTML = newHtml; 152 | }); 153 | } 154 | 155 | export { 156 | read_file, load_img, date2num, 157 | sha256, aes256, aes256_blk0_d, 158 | dat2hex, dat2str, str2dat, 159 | cpy, 160 | download, 161 | escape_html, readable_size, 162 | walk, linkable 163 | }; 164 | -------------------------------------------------------------------------------- /src/utils/idb.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (MIT License) 3 | * 4 | * Author: Duke Fong 5 | */ 6 | 7 | class Idb { 8 | constructor(db_name = 'cde', store_list = ['var', 'tmp']) { 9 | 10 | let _dbp = new Promise((resolve, reject) => { 11 | const openreq = indexedDB.open(db_name, 1); 12 | openreq.onerror = () => reject(openreq.error); 13 | openreq.onsuccess = () => resolve(openreq.result); 14 | // First time setup: create an empty object store 15 | openreq.onupgradeneeded = () => { 16 | console.log(`db: ${db_name}: create stores: ${store_list}`); 17 | for (let i in store_list) 18 | openreq.result.createObjectStore(store_list[i]); 19 | }; 20 | }); 21 | 22 | return (async () => { 23 | this.db = await _dbp; 24 | return this; 25 | })(); 26 | } 27 | 28 | trans(store_name, type) { 29 | let store; 30 | let _sp = new Promise((resolve, reject) => { 31 | const transaction = this.db.transaction(store_name, type); 32 | transaction.oncomplete = () => resolve(); 33 | transaction.onabort = transaction.onerror = () => reject(transaction.error); 34 | store = transaction.objectStore(store_name); 35 | }); 36 | return {_sp, store}; 37 | } 38 | 39 | async get(store_name, key) { 40 | let {_sp, store} = this.trans(store_name, 'readonly'); 41 | let req = store.get(key); 42 | await _sp; 43 | return req.result; 44 | } 45 | async set(store_name, key, value) { 46 | let {_sp, store} = this.trans(store_name, 'readwrite'); 47 | store.put(value, key); 48 | await _sp; 49 | } 50 | async del(store_name, key) { 51 | let {_sp, store} = this.trans(store_name, 'readwrite'); 52 | store.delete(key); 53 | await _sp; 54 | } 55 | async clear(store_name) { 56 | let {_sp, store} = this.trans(store_name, 'readwrite'); 57 | store.clear(); 58 | await _sp; 59 | } 60 | async keys(store_name) { 61 | let {_sp, store} = this.trans(store_name, 'readonly'); 62 | let req = store.getAllKeys(); 63 | await _sp; 64 | return req.result; 65 | } 66 | 67 | stores() { 68 | return this.db.objectStoreNames; 69 | } 70 | } 71 | 72 | export { Idb }; 73 | -------------------------------------------------------------------------------- /sw.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (MIT License) 3 | * 4 | * Author: Duke Fong 5 | */ 6 | 7 | // update file list by tool gen_sw.sh under tools/ 8 | 9 | var cache_name = 'cde-1.20'; 10 | var cache_files = { 11 | "/img/icon/fontello.css" : "9143594ce27fc81648d345becdd74ba85cec2b2836908f12789d70e18e38174e", 12 | "/img/icon/fontello.woff2" : "c6f250032c14345783273890e92bb27611ffc2690afc851a138ac9fe2e275a44", 13 | "/img/icon.png" : "7160ad0053e77a16333b06123d567195777c67813dfe87d6c17e4df9d6f791b9", 14 | "/manifest.json" : "02e874ad409a13334237157db7f34026542ec5cc3c5745c7fc0f216c1981af00", 15 | "/src/lang/lang.js" : "dfebd527a1c59df65abfcf25c51b4c946b7d702712e9b7d5e2f70f775ca06567", 16 | "/src/utils/helper.js" : "6e16f8705d2d690ed26ffbc9bb852246ce689bb966756ea0f0fc0bf3aadc728f", 17 | "/src/utils/idb.js" : "c277349bf34bdf1f8610a9d4cb0bcd6aadb5ae22300861cd87e9597ab597d796", 18 | "/src/app.js" : "3c62c88af2d4cd2a5c82a5eb43a7ec0f6223d893b9463673a18ddd811a6bfa8a", 19 | "/lib/pell/pell.css" : "dd7012f74f875db0c7f6aa447ec86812914991e07cb8b32cd8db669b531f2e27", 20 | "/lib/pell/actions.js" : "2ad31c233702a0f9a5aa8cb9c66741b7aec7ae110a3dc94c22a2b8b867bc959a", 21 | "/lib/pell/utilities.js" : "73d5066c77258f034b604863824e1aa9b96304bbf36c906148def635300da60c", 22 | "/lib/pell/pell.js" : "b862bb1b70e255e886347fd49e1608965b62241ff2b110e812d8600dfcf84245", 23 | "/lib/bulma.min.css" : "0fd339cab543a859656bb9e510b0da6192295df1560f2b50b6257e4da1fa1752", 24 | "/lib/anchorme.min.js" : "87de70486f3fcaded74ac742724f8bf3cefd08b636323c90ee3619f35e958463", 25 | "/lib/msgpack.min.js" : "c670cb2d82b1285c0b12640ad52919f48ec8c268dd794446b57524ff45a74d1a", 26 | "/lib/base64js.min.js" : "f549a4c1d0eb4a6140081aea9c009cfff6fc2d0c289336d9e4542a03bf6281f5", 27 | "/" : "13c7de9fe4cd4bf6626e4f08c134ab70c16dd738075f21d6d3dde5d9e0dcee56" 28 | }; 29 | 30 | 31 | async function sha256(dat) { 32 | const hashBuffer = await crypto.subtle.digest('SHA-256', dat); 33 | return new Uint8Array(hashBuffer); 34 | } 35 | 36 | function dat2hex(dat, join='') { 37 | const dat_array = Array.from(dat); 38 | return dat_array.map(b => b.toString(16).padStart(2, '0')).join(join); 39 | } 40 | 41 | async function resp_sha(resp) { 42 | const reader = resp.body.getReader(); 43 | let dat = new Uint8Array(); 44 | while (true) { 45 | const ret = await reader.read(); 46 | if (ret.value && ret.value.length) 47 | dat = new Uint8Array([ ...dat, ...ret.value ]); 48 | if (ret.done) 49 | break; 50 | } 51 | const sha = await sha256(dat); 52 | return dat2hex(sha); 53 | } 54 | 55 | 56 | async function cache_all(event) { 57 | let r = Math.random(); 58 | console.log(`sw: cache add all, r: ${r}`); 59 | let cache = await caches.open(cache_name); 60 | for (let k in cache_files) { 61 | let response = await fetch(`${k}?r=${r}`, {cache: 'no-store'}); 62 | const sha = await resp_sha(response.clone()); 63 | if (sha == cache_files[k]) 64 | cache.put(k, response); 65 | else 66 | console.warn(`sw: ${k} hash error: ${sha} != ${cache_files[k]}`); 67 | } 68 | console.log('sw: cache add all finished'); 69 | } 70 | 71 | async function handle_request(event) { 72 | let loc = new URL(event.request.url); 73 | let k = loc.pathname; 74 | 75 | let cache = await caches.open(cache_name); 76 | let response = await cache.match(loc.host == location.host ? k : event.request); 77 | if (response) 78 | return response; 79 | 80 | if (loc.host == location.host && (k in cache_files)) { 81 | let r = Math.random(); 82 | response = await fetch(`${k}?r=${r}`, {cache: 'no-store'}); 83 | const sha = await resp_sha(response.clone()); 84 | if (sha == cache_files[k]) { 85 | console.log(`sw: add ${k} to cache`); 86 | cache.put(k, response.clone()); 87 | } else { 88 | console.warn(`sw: ${k} hash still error: ${sha} != ${cache_files[k]}`); 89 | } 90 | } else { 91 | if (loc.protocol == 'http:') { 92 | console.log(`sw: force https: ${loc.href}`) 93 | loc.protocol = 'https:'; 94 | response = await fetch(loc); 95 | } else { 96 | console.log(`sw: fetch: ${event.request.url}`); 97 | response = await fetch(event.request); 98 | } 99 | } 100 | return response; 101 | } 102 | 103 | async function handle_activate(event) { 104 | let c_keys = await caches.keys(); 105 | for (let c of c_keys) { 106 | if (c != cache_name) { 107 | console.log(`sw: del: ${c}`); 108 | await caches.delete(c); 109 | } else { 110 | console.log(`sw: retain: ${c}`); 111 | } 112 | } 113 | } 114 | 115 | 116 | self.addEventListener('install', event => { 117 | event.waitUntil(cache_all(event)); 118 | self.skipWaiting(); 119 | }); 120 | 121 | self.addEventListener('fetch', event => { 122 | event.respondWith(handle_request(event)); 123 | }); 124 | 125 | self.addEventListener('activate', event => { 126 | event.waitUntil(handle_activate(event)); 127 | event.waitUntil(clients.claim()); 128 | }); 129 | 130 | -------------------------------------------------------------------------------- /tools/aes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Usage: $0 passwd input out [-d] # -d for decryption" 3 | set -e 4 | 5 | [[ "$#" != "3" && "$#" != "4" ]] && exit 6 | 7 | echo "passwd: $1" 8 | KEY=$(echo -n "$1" | sha256sum) 9 | KEY=${KEY:0:64} 10 | echo "KEY: $KEY" 11 | 12 | echo "in: $2" 13 | echo "out: $3" 14 | echo "addition: $4" 15 | 16 | echo "processing..." 17 | openssl enc -aes-256-cbc -nosalt $4 -K "$KEY" -iv "00000000000000000000000000000000" -in "$2" -out "$3" 18 | 19 | -------------------------------------------------------------------------------- /tools/aes-mount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software License Agreement (MIT License) 4 | # 5 | # Author: Duke Fong 6 | # 7 | # Image file <--> Directory, on-the-fly encryption tool 8 | # 9 | # Format: aes-cbc-plain 10 | # KEY: sha256sum of password string 11 | # IV: sector index (little-endian, sector size: 512 bytes) 12 | 13 | XTERM=xterm 14 | which gnome-terminal &> /dev/null && XTERM="gnome-terminal" 15 | which xfce4-terminal &> /dev/null && XTERM="xfce4-terminal" 16 | 17 | tty -s; [ $? -ne 0 ] && { $XTERM -e "bash -c \"$0 $@\""; exit; } 18 | [ $UID -ne 0 ] && { echo "restart as root"; sudo _uid=$UID "$0" "$@"; exit $?; } 19 | [ "$_uid" == "" ] && _uid=0 20 | set -e 21 | 22 | function exe() { echo "\$ $@"; "$@"; } 23 | 24 | function anykey_exit() { 25 | [ "$1" == 0 ] && ecode=0 || ecode=1 26 | read -n1 -r -p "press any key to exit ($ecode)..." 27 | [ "$ecode" == 0 ] && exit || exit 1 28 | } 29 | 30 | if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" ]]; then 31 | echo "Usage:" 32 | echo " $0 FILE : Toggle mount" 33 | echo " $0 FILE [u]mount [PATH] : Mount / umount, or mount to PATH" 34 | echo " $0 FILE new SIZE : Create image file, units: K/M/G" 35 | echo " $0 FILE shrink : Shrink file size" 36 | echo " $0 FILE expand SIZE : Expand file to size" 37 | echo " $0 FILE passwd : Change file password" 38 | echo "" 39 | echo "You can drag an image file onto the script to run the toggle command." 40 | exit 41 | fi 42 | 43 | FILE_PATH="$(readlink -f "$1")" 44 | FILE_DIR="$(dirname "$FILE_PATH")" 45 | FILE_NAME="$(basename "$FILE_PATH")" 46 | NAME="${FILE_NAME%.*}" # remove file extention 47 | 48 | CMD="$2" 49 | MAP_EXIST=0 50 | MOUNT_DIR="" 51 | if [ -b "/dev/mapper/$NAME" ]; then 52 | INFO="$(cryptsetup status "$NAME")" 53 | [[ ! "$INFO" =~ "$FILE_PATH" ]] && { echo "Name $NAME conflict!"; exit 1; } 54 | MAP_EXIST=1 55 | MOUNT_DIR="$(lsblk -o MOUNTPOINT -nr "/dev/mapper/$NAME")" 56 | fi 57 | [ "$NAME" == "" ] && { echo "Name empty!"; exit 1; } 58 | 59 | 60 | if [ "$CMD" == "new" ]; then 61 | file_sz=`numfmt --from=iec "$3"` 62 | file_sz_iec=`numfmt --to=iec $file_sz` 63 | echo "new $FILE_PATH, size: $file_sz ($file_sz_iec)" 64 | [ "$((file_sz))" == "0" ] && { echo "file_sz wrong: $file_sz"; exit 1; } 65 | [ "$((file_sz % 512))" != "0" ] && { echo "file_sz is not multiple of 512"; exit 1; } 66 | exe dd if=/dev/zero of="$FILE_PATH" bs=512 count=0 seek=$((file_sz/512)) 67 | exe cryptsetup create "$NAME" "$FILE_PATH" --hash sha256 --cipher aes-cbc-plain --key-size 256 68 | exe mkfs.ext4 /dev/mapper/"$NAME" 69 | exe cryptsetup remove "$NAME" 70 | echo "done" 71 | exit 72 | fi 73 | 74 | 75 | if [ "$CMD" == "shrink" ]; then 76 | [ "$MAP_EXIST" == "1" ] && { echo "please umount first"; exit 1; } 77 | exe cryptsetup create "$NAME" "$FILE_PATH" --hash sha256 --cipher aes-cbc-plain --key-size 256 78 | dumpe2fs "/dev/mapper/$NAME" > /dev/null || { exe cryptsetup remove "$NAME"; exit 1; } 79 | block_size=`dumpe2fs "/dev/mapper/$NAME" 2>&1 | grep "Block size:"` 80 | block_size=${block_size##* } 81 | block_count=`dumpe2fs "/dev/mapper/$NAME" 2>&1 | grep "Block count:"` 82 | block_count=${block_count##* } 83 | exe e2fsck -f "/dev/mapper/$NAME" 84 | exe resize2fs -M "/dev/mapper/$NAME" 85 | block_count_m=`dumpe2fs "/dev/mapper/$NAME" 2>&1 | grep "Block count:"` 86 | block_count_m=${block_count_m##* } 87 | exe cryptsetup remove "$NAME" 88 | echo "shrink: block_size: ${block_size}, block_count: ${block_count} -> ${block_count_m}" 89 | read -p "continue (Y/n)? " 90 | if [[ "$REPLY" =~ ^[Yy]$ || "$REPLY" == "" ]]; then 91 | exe dd if=/dev/zero of="$FILE_PATH" bs=${block_size} count=0 seek=${block_count_m} 92 | echo "done" 93 | fi 94 | exit 95 | fi 96 | 97 | if [[ "$CMD" == "expand" && "$3" != "" ]]; then 98 | file_sz=`stat -c '%s' $FILE_PATH` 99 | tgt_sz=`numfmt --from=iec $3` 100 | file_sz_iec=`numfmt --to=iec $file_sz` 101 | tgt_sz_iec=`numfmt --to=iec $tgt_sz` 102 | echo "expand: file_sz: $file_sz ($file_sz_iec) -> tgt_sz: $tgt_sz ($tgt_sz_iec)" 103 | [ "$MAP_EXIST" == "1" ] && { echo "please umount first"; exit 1; } 104 | [ "$((file_sz))" == "0" ] && { echo "file_sz wrong: $file_sz"; exit 1; } 105 | [ "$((file_sz % 512))" != "0" ] && echo "file_sz is not multiple of 512" 106 | [ "$((tgt_sz))" == "0" ] && { echo "tgt_sz wrong: $tgt_sz"; exit 1; } 107 | [ "$((tgt_sz % 512))" != "0" ] && { echo "file_sz is not multiple of 512"; exit 1; } 108 | [ "$((tgt_sz >= file_sz))" == "0" ] && { echo "tgt_sz must larger than file_sz"; exit 1; } 109 | 110 | read -p "continue (Y/n)? " 111 | if [[ "$REPLY" =~ ^[Yy]$ || "$REPLY" == "" ]]; then 112 | exe dd if=/dev/zero of="$FILE_PATH" bs=512 count=0 seek=$((tgt_sz/512)) 113 | exe cryptsetup create "$NAME" "$FILE_PATH" --hash sha256 --cipher aes-cbc-plain --key-size 256 114 | exe e2fsck -f "/dev/mapper/$NAME" 115 | exe resize2fs "/dev/mapper/$NAME" # without -M 116 | exe cryptsetup remove "$NAME" 117 | echo "done" 118 | fi 119 | exit 120 | fi 121 | 122 | if [ "$CMD" == "passwd" ]; then 123 | file_sz=`stat -c '%s' $FILE_PATH` 124 | [ "$MOUNT_DIR" == "" ] && { echo "please mount first"; exit 1; } 125 | [ "$((file_sz))" == "0" ] && { echo "file_sz wrong: $file_sz"; exit 1; } 126 | [ "$((file_sz % 512))" != "0" ] && { echo "file_sz is not multiple of 512"; exit 1; } 127 | exe dd if=/dev/zero of="$FILE_PATH".tmp bs=512 count=0 seek=$((file_sz/512)) 128 | echo "change passwd, please input new passwd:" 129 | exe cryptsetup create "$NAME".tmp "$FILE_PATH".tmp --hash sha256 --cipher aes-cbc-plain --key-size 256 130 | exe mkfs.ext4 /dev/mapper/"$NAME".tmp 131 | exe mkdir "$MOUNT_DIR".tmp 132 | exe mount "/dev/mapper/$NAME".tmp "$MOUNT_DIR".tmp 133 | exe cp -a "$MOUNT_DIR"/. "$MOUNT_DIR".tmp/ # include hidden files 134 | sync 135 | exe umount "$MOUNT_DIR".tmp 136 | exe cryptsetup remove "$NAME".tmp 137 | exe umount "$MOUNT_DIR" 138 | exe cryptsetup remove "$NAME" 139 | exe mv "$FILE_PATH" "$FILE_PATH".old 140 | exe mv "$FILE_PATH".tmp "$FILE_PATH" 141 | [ "$(ls -A "$MOUNT_DIR")" == "" ] && exe rm -r "$MOUNT_DIR" 142 | [ "$(ls -A "$MOUNT_DIR".tmp)" == "" ] && exe rm -r "$MOUNT_DIR".tmp 143 | echo "done" 144 | exit 145 | fi 146 | 147 | # toggle mount 148 | [ "$CMD" == "" ] && { [ "$MAP_EXIST" == "0" ] && CMD="mount" || CMD="umount"; } 149 | [ "$CMD" == "mount" ] && { [ "$3" != "" ] && MOUNT_DIR="$3" || MOUNT_DIR="$FILE_DIR/$NAME"; } 150 | 151 | if [ "$CMD" == "mount" ]; then 152 | echo "do mount" 153 | [ "$MAP_EXIST" == "1" ] && { echo "/dev/mapper/$NAME already exist!"; anykey_exit; } 154 | [ ! -d "$MOUNT_DIR" ] && { exe mkdir "$MOUNT_DIR" || anykey_exit; } 155 | exe cryptsetup create "$NAME" "$FILE_PATH" --hash sha256 --cipher aes-cbc-plain --key-size 256 156 | exe mount "/dev/mapper/$NAME" "$MOUNT_DIR" && ret=0 || ret=1 157 | if [ $ret == 0 ]; then 158 | exe chown $_uid "$MOUNT_DIR" 159 | echo "succeeded" 160 | else 161 | [ "$(ls -A "$MOUNT_DIR")" == "" ] && exe rm -r "$MOUNT_DIR" 162 | exe cryptsetup remove "$NAME" 163 | anykey_exit 164 | fi 165 | 166 | elif [ "$CMD" == "umount" ]; then 167 | echo "do umount" 168 | sync 169 | if [ "$MOUNT_DIR" != "" ]; then 170 | exe umount "$MOUNT_DIR" || anykey_exit 171 | [ "$(ls -A "$MOUNT_DIR")" == "" ] && exe rm -r "$MOUNT_DIR" 172 | else 173 | [[ -d "$FILE_DIR/$NAME" && "$(ls -A "$FILE_DIR/$NAME")" == "" ]] && exe rm -r "$FILE_DIR/$NAME" 174 | fi 175 | exe cryptsetup remove "$NAME" 176 | echo "done" 177 | fi 178 | 179 | anykey_exit 0 180 | 181 | -------------------------------------------------------------------------------- /tools/gen_sw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # for subdir: ./gen_sw.sh /cde 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | files="$(find ./ -not -path '*/\.*' -type f)" 8 | 9 | echo "$files" | while read -r line; do 10 | line="${line:1}" 11 | file="$line" 12 | [[ "$line" == "/httpd.conf" ]] && continue 13 | [[ "$line" == "/Readme.md" ]] && continue 14 | [[ "$line" == "/sw.js" ]] && continue 15 | [[ "$line" =~ ^"/tools/" ]] && continue 16 | [[ "$line" =~ ^"/cgi-bin/" ]] && continue 17 | [[ "$line" == "/index.html" ]] && line="/" 18 | echo " \"$1$line\" : \"$(sha256sum "./$file" | awk '{ print $1 }')\"," 19 | done 20 | 21 | --------------------------------------------------------------------------------